From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 47482 invoked by alias); 23 Oct 2017 17:32:53 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 47471 invoked by uid 89); 23 Oct 2017 17:32:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=2759 X-HELO: mail-wm0-f53.google.com Received: from mail-wm0-f53.google.com (HELO mail-wm0-f53.google.com) (74.125.82.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:32:51 +0000 Received: by mail-wm0-f53.google.com with SMTP id q124so11025712wmb.0 for ; Mon, 23 Oct 2017 10:32:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=4EXM+Tda4j5x2OVa+CXVOuSL/ppPuiPDr5cf9EsRPN4=; b=LR99G3CfDErOlLDLdxILy18wraiKDBGzDtmJIwWZpTfSiZ20hFtV4AN3E1DuAKO8/R ZafTy3SOB7GaS3qodjbJNcec1VoVYBu/WtnacsjsrGIHKAqLUayZF0d64k0j4+2dqHST lG+COVozZAlNRD43TrzB+kQBY7+YRF9zyQ7yHdyqFEtw4+gllalCyYPNDQgCt6Uc5ltq BcEM/xym4fUxDsI41lYEtUeDrLM42sJx2aYqk8fA6CRF/POeRSAa8PJqz5a3DprdA6Wl xfv04epjhNCx/cnfQPpcv/dX/beFSK7gNfYvqqo+LShQWdsR6UAIcPQaWKEQI1H8G5CC RqDw== X-Gm-Message-State: AMCzsaWl7Ck2dq07zIRK3MlrEmc8riPa9+XV2K9Xpk6t+poQO1z5SdVv mUd7VvDv56vvGJbAc5lKtvx913Xk7jU= X-Google-Smtp-Source: ABhQp+Ss3yUWJgp0+dtz8ejOXVdZwZpuFrGc1FndY7CAlStr+WMDS87emx8P44nj3wChfDilPNqHDA== X-Received: by 10.28.7.82 with SMTP id 79mr5797749wmh.4.1508779968978; Mon, 23 Oct 2017 10:32:48 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id g136sm3598135wmd.40.2017.10.23.10.32.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:32:48 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [081/nnn] poly_int: brig vector elements References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 17:33:00 -0000 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <8760b5hirk.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2017-10/txt/msg01582.txt.bz2 This patch adds a brig-specific wrapper around TYPE_VECTOR_SUBPARTS, since presumably it will never need to support variable vector lengths. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/brig/ * brigfrontend/brig-util.h (gccbrig_type_vector_subparts): New function. * brigfrontend/brig-basic-inst-handler.cc (brig_basic_inst_handler::build_shuffle): Use it instead of TYPE_VECTOR_SUBPARTS. (brig_basic_inst_handler::build_unpack): Likewise. (brig_basic_inst_handler::build_pack): Likewise. (brig_basic_inst_handler::build_unpack_lo_or_hi): Likewise. (brig_basic_inst_handler::operator ()): Likewise. (brig_basic_inst_handler::build_lower_element_broadcast): Likewise. * brigfrontend/brig-code-entry-handler.cc (brig_code_entry_handler::get_tree_cst_for_hsa_operand): Likewise. (brig_code_entry_handler::get_comparison_result_type): Likewise. (brig_code_entry_handler::expand_or_call_builtin): Likewise. Index: gcc/brig/brigfrontend/brig-util.h =================================================================== --- gcc/brig/brigfrontend/brig-util.h 2017-10-02 09:10:56.960755788 +0100 +++ gcc/brig/brigfrontend/brig-util.h 2017-10-23 17:22:46.882758777 +0100 @@ -76,4 +76,12 @@ bool gccbrig_might_be_host_defined_var_p /* From hsa.h. */ bool hsa_type_packed_p (BrigType16_t type); +/* Return the number of elements in a VECTOR_TYPE. BRIG does not support + variable-length vectors. */ +inline unsigned HOST_WIDE_INT +gccbrig_type_vector_subparts (const_tree type) +{ + return TYPE_VECTOR_SUBPARTS (type); +} + #endif Index: gcc/brig/brigfrontend/brig-basic-inst-handler.cc =================================================================== --- gcc/brig/brigfrontend/brig-basic-inst-handler.cc 2017-08-10 14:36:07.092506123 +0100 +++ gcc/brig/brigfrontend/brig-basic-inst-handler.cc 2017-10-23 17:22:46.882758777 +0100 @@ -97,9 +97,10 @@ brig_basic_inst_handler::build_shuffle ( output elements can originate from any input element. */ vec *mask_offset_vals = NULL; + unsigned int element_count = gccbrig_type_vector_subparts (arith_type); + vec *input_mask_vals = NULL; - size_t input_mask_element_size - = exact_log2 (TYPE_VECTOR_SUBPARTS (arith_type)); + size_t input_mask_element_size = exact_log2 (element_count); /* Unpack the tightly packed mask elements to BIT_FIELD_REFs from which to construct the mask vector as understood by @@ -109,7 +110,7 @@ brig_basic_inst_handler::build_shuffle ( tree mask_element_type = build_nonstandard_integer_type (input_mask_element_size, true); - for (size_t i = 0; i < TYPE_VECTOR_SUBPARTS (arith_type); ++i) + for (size_t i = 0; i < element_count; ++i) { tree mask_element = build3 (BIT_FIELD_REF, mask_element_type, mask_operand, @@ -119,17 +120,15 @@ brig_basic_inst_handler::build_shuffle ( mask_element = convert (element_type, mask_element); tree offset; - if (i < TYPE_VECTOR_SUBPARTS (arith_type) / 2) + if (i < element_count / 2) offset = build_int_cst (element_type, 0); else - offset - = build_int_cst (element_type, TYPE_VECTOR_SUBPARTS (arith_type)); + offset = build_int_cst (element_type, element_count); CONSTRUCTOR_APPEND_ELT (mask_offset_vals, NULL_TREE, offset); CONSTRUCTOR_APPEND_ELT (input_mask_vals, NULL_TREE, mask_element); } - tree mask_vec_type - = build_vector_type (element_type, TYPE_VECTOR_SUBPARTS (arith_type)); + tree mask_vec_type = build_vector_type (element_type, element_count); tree mask_vec = build_constructor (mask_vec_type, input_mask_vals); tree offset_vec = build_constructor (mask_vec_type, mask_offset_vals); @@ -158,7 +157,8 @@ brig_basic_inst_handler::build_unpack (t vec *input_mask_vals = NULL; vec *and_mask_vals = NULL; - size_t element_count = TYPE_VECTOR_SUBPARTS (TREE_TYPE (operands[0])); + size_t element_count + = gccbrig_type_vector_subparts (TREE_TYPE (operands[0])); tree vec_type = build_vector_type (element_type, element_count); for (size_t i = 0; i < element_count; ++i) @@ -213,7 +213,7 @@ brig_basic_inst_handler::build_pack (tre TODO: Reuse this for implementing 'bitinsert' without a builtin call. */ - size_t ecount = TYPE_VECTOR_SUBPARTS (TREE_TYPE (operands[0])); + size_t ecount = gccbrig_type_vector_subparts (TREE_TYPE (operands[0])); size_t vecsize = int_size_in_bytes (TREE_TYPE (operands[0])) * BITS_PER_UNIT; tree wide_type = build_nonstandard_integer_type (vecsize, 1); @@ -275,9 +275,10 @@ brig_basic_inst_handler::build_unpack_lo { tree element_type = get_unsigned_int_type (TREE_TYPE (arith_type)); tree mask_vec_type - = build_vector_type (element_type, TYPE_VECTOR_SUBPARTS (arith_type)); + = build_vector_type (element_type, + gccbrig_type_vector_subparts (arith_type)); - size_t element_count = TYPE_VECTOR_SUBPARTS (arith_type); + size_t element_count = gccbrig_type_vector_subparts (arith_type); vec *input_mask_vals = NULL; size_t offset = (brig_opcode == BRIG_OPCODE_UNPACKLO) ? 0 : element_count / 2; @@ -600,8 +601,8 @@ brig_basic_inst_handler::operator () (co } size_t promoted_type_size = int_size_in_bytes (promoted_type) * 8; - - for (size_t i = 0; i < TYPE_VECTOR_SUBPARTS (arith_type); ++i) + size_t element_count = gccbrig_type_vector_subparts (arith_type); + for (size_t i = 0; i < element_count; ++i) { tree operand0 = convert (promoted_type, operand0_elements.at (i)); tree operand1 = convert (promoted_type, operand1_elements.at (i)); @@ -708,7 +709,8 @@ brig_basic_inst_handler::build_lower_ele tree element_type = TREE_TYPE (TREE_TYPE (vec_operand)); size_t esize = 8 * int_size_in_bytes (element_type); - size_t element_count = TYPE_VECTOR_SUBPARTS (TREE_TYPE (vec_operand)); + size_t element_count + = gccbrig_type_vector_subparts (TREE_TYPE (vec_operand)); tree mask_inner_type = build_nonstandard_integer_type (esize, 1); vec *constructor_vals = NULL; Index: gcc/brig/brigfrontend/brig-code-entry-handler.cc =================================================================== --- gcc/brig/brigfrontend/brig-code-entry-handler.cc 2017-10-02 09:10:56.960755788 +0100 +++ gcc/brig/brigfrontend/brig-code-entry-handler.cc 2017-10-23 17:22:46.882758777 +0100 @@ -641,7 +641,8 @@ brig_code_entry_handler::get_tree_cst_fo { /* In case of vector type elements (or sole vectors), create a vector ctor. */ - size_t element_count = TYPE_VECTOR_SUBPARTS (tree_element_type); + size_t element_count + = gccbrig_type_vector_subparts (tree_element_type); if (bytes_left < scalar_element_size * element_count) fatal_error (UNKNOWN_LOCATION, "Not enough bytes left for the initializer " @@ -844,7 +845,7 @@ brig_code_entry_handler::get_comparison_ size_t element_size = int_size_in_bytes (TREE_TYPE (source_type)); return build_vector_type (build_nonstandard_boolean_type (element_size * BITS_PER_UNIT), - TYPE_VECTOR_SUBPARTS (source_type)); + gccbrig_type_vector_subparts (source_type)); } else return gccbrig_tree_type_for_hsa_type (BRIG_TYPE_B1); @@ -949,7 +950,8 @@ brig_code_entry_handler::expand_or_call_ tree_stl_vec result_elements; - for (size_t i = 0; i < TYPE_VECTOR_SUBPARTS (arith_type); ++i) + size_t element_count = gccbrig_type_vector_subparts (arith_type); + for (size_t i = 0; i < element_count; ++i) { tree_stl_vec call_operands; if (operand0_elements.size () > 0)