From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zg8tndyumtaxlji0oc4xnzya.icoremail.net (zg8tndyumtaxlji0oc4xnzya.icoremail.net [46.101.248.176]) by sourceware.org (Postfix) with ESMTP id 5663C3858012 for ; Mon, 18 Dec 2023 03:29:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5663C3858012 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=eswincomputing.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=eswincomputing.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5663C3858012 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=46.101.248.176 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702870162; cv=none; b=D8m4R6jKChiRmENx7lduRZNZkfR4fnMZlvHYTajevaj/9srPlm2IHPAt1jZ5E1JOtxfkt7o9J0pdoKZdX0e/Fp/kkxgYvIOSM4Qk5V6DSmFSqRFuK+8AXquVrnR7cMQyc16p7++COV+QFJAJXuKiSVyBlr2kbMRxXM3zL/A+kwA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702870162; c=relaxed/simple; bh=kUrf4tCIPlsNFDJll+U2zQSrSwEfVYUW/o+OubccdRs=; h=From:To:Subject:Date:Message-Id; b=JRqMTtrCfKo9y634YWPMI3oA3icjCq2NaYtNcRjbTlDf1Sfp8ehX8R3EJ2Zm7LTotTmExohGOI7PASGZ6ImyblIuQCkkP8mERy9vVCF+yDXjpcKGUQ3r6WE4YWRszyzeIx0jBf8SzOIRXCJGVkSXIRPFeK5UOFBcHh7BK4DkVt0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost.localdomain (unknown [10.12.130.31]) by app1 (Coremail) with SMTP id TAJkCgAXlvs3vH9lUuMBAA--.11668S4; Mon, 18 Dec 2023 11:27:52 +0800 (CST) From: Feng Wang To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, jeffreyalaw@gmail.com, juzhe.zhong@rivai.ai, Feng Wang Subject: [PATCH] RISC-V: Add required_extensions in function_group Date: Mon, 18 Dec 2023 03:28:00 +0000 Message-Id: <20231218032800.18938-1-wangfeng@eswincomputing.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID:TAJkCgAXlvs3vH9lUuMBAA--.11668S4 X-Coremail-Antispam: 1UD129KBjvJXoW3AF4fJFWfCFy7KF15Kw4kJFb_yoW7Zw1Upa y5Ar1akr95JFsxuryftFWrGw1fCw4Igw4Iyrs5Cw4UAay7WrZ7t3Z8K3W2vF18ZF1rCr1I 93WF9FyF9w17ArJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUk214x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc2xSY4AK6svPMxAI w28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr 4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxG rwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8Jw CI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2 z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjfUoOJ5UUUUU X-CM-SenderInfo: pzdqwwxhqjqvxvzl0uprps33xlqjhudrp/ X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: In order to add other vector related extensions in the future, this patch add one more parameter in the function_group_info, it will be used to determine whether intrinsic registration processing is required. gcc/ChangeLog: * config/riscv/riscv-vector-builtins-functions.def (REQUIRED_EXTENSIONS): Add new macro for match function. * config/riscv/riscv-vector-builtins.cc (DEF_RVV_FUNCTION): Add one more parameter for macro expanding. (handle_pragma_vector): Add match function calls. * config/riscv/riscv-vector-builtins.h (enum required_ext): Add enum defination for required extension. (struct function_group_info): Add one more parameter for checking required-ext. --- .../riscv/riscv-vector-builtins-functions.def | 2 + gcc/config/riscv/riscv-vector-builtins.cc | 7 ++- gcc/config/riscv/riscv-vector-builtins.h | 46 +++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/gcc/config/riscv/riscv-vector-builtins-functions.def b/gcc/config/riscv/riscv-vector-builtins-functions.def index 1c37fd5fffe..03421d5bc10 100644 --- a/gcc/config/riscv/riscv-vector-builtins-functions.def +++ b/gcc/config/riscv/riscv-vector-builtins-functions.def @@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. If not see #define DEF_RVV_FUNCTION(NAME, SHAPE, PREDS, OPS_INFO) #endif +#define REQUIRED_EXTENSIONS VECTOR_EXT /* Internal helper functions for gimple fold use. */ DEF_RVV_FUNCTION (read_vl, read_vl, none_preds, p_none_void_ops) DEF_RVV_FUNCTION (vlenb, vlenb, none_preds, ul_none_void_ops) @@ -650,5 +651,6 @@ DEF_RVV_FUNCTION (vsoxseg, seg_indexed_loadstore, none_m_preds, tuple_v_scalar_p DEF_RVV_FUNCTION (vsoxseg, seg_indexed_loadstore, none_m_preds, tuple_v_scalar_ptr_eew32_index_ops) DEF_RVV_FUNCTION (vsoxseg, seg_indexed_loadstore, none_m_preds, tuple_v_scalar_ptr_eew64_index_ops) DEF_RVV_FUNCTION (vlsegff, seg_fault_load, full_preds, tuple_v_scalar_const_ptr_size_ptr_ops) +#undef REQUIRED_EXTENSIONS #undef DEF_RVV_FUNCTION diff --git a/gcc/config/riscv/riscv-vector-builtins.cc b/gcc/config/riscv/riscv-vector-builtins.cc index 6330a3a41c3..4e2c66c2de7 100644 --- a/gcc/config/riscv/riscv-vector-builtins.cc +++ b/gcc/config/riscv/riscv-vector-builtins.cc @@ -2685,7 +2685,7 @@ static CONSTEXPR const function_type_info function_types[] = { /* A list of all RVV intrinsic functions. */ static function_group_info function_groups[] = { #define DEF_RVV_FUNCTION(NAME, SHAPE, PREDS, OPS_INFO) \ - {#NAME, &bases::NAME, &shapes::SHAPE, PREDS, OPS_INFO}, + {#NAME, &bases::NAME, &shapes::SHAPE, PREDS, OPS_INFO, REQUIRED_EXTENSIONS}, #include "riscv-vector-builtins-functions.def" }; @@ -4413,7 +4413,10 @@ handle_pragma_vector () = new hash_table (1023); function_builder builder; for (unsigned int i = 0; i < ARRAY_SIZE (function_groups); ++i) - builder.register_function_group (function_groups[i]); + { + if (function_groups[i].match (function_groups[i].required_extensions)) + builder.register_function_group (function_groups[i]); + } } /* Return the function decl with RVV function subcode CODE, or error_mark_node diff --git a/gcc/config/riscv/riscv-vector-builtins.h b/gcc/config/riscv/riscv-vector-builtins.h index cd8ccab1724..4f38c09d73d 100644 --- a/gcc/config/riscv/riscv-vector-builtins.h +++ b/gcc/config/riscv/riscv-vector-builtins.h @@ -110,6 +110,21 @@ static const unsigned int CP_WRITE_CSR = 1U << 5; #define RVV_REQUIRE_MIN_VLEN_64 (1 << 5) /* Require TARGET_MIN_VLEN >= 64. */ #define RVV_REQUIRE_ELEN_FP_16 (1 << 6) /* Require FP ELEN >= 32. */ +/* Enumerates the required extensions. */ +enum required_ext +{ + VECTOR_EXT, /* Vector extension */ + ZVBB_EXT, /* Cryto vector Zvbb sub-ext */ + ZVBB_OR_ZVKB_EXT, /* Cryto vector Zvbb or zvkb sub-ext */ + ZVBC_EXT, /* Crypto vector Zvbc sub-ext */ + ZVKG_EXT, /* Crypto vector Zvkg sub-ext */ + ZVKNED_EXT, /* Crypto vector Zvkned sub-ext */ + ZVKNHA_OR_ZVKNHB_EXT, /* Crypto vector Zvknh[ab] sub-ext */ + ZVKNHB_EXT, /* Crypto vector Zvknhb sub-ext */ + ZVKSED_EXT, /* Crypto vector Zvksed sub-ext */ + ZVKSH_EXT, /* Crypto vector Zvksh sub-ext */ +}; + /* Enumerates the RVV operand types. */ enum operand_type_index { @@ -212,6 +227,35 @@ class function_shape; /* Static information about a set of functions. */ struct function_group_info { + /* Return true if required extension is enabled */ + bool match (required_ext ext_value) const + { + switch (ext_value) + { + case VECTOR_EXT: + return TARGET_VECTOR; + case ZVBB_EXT: + return TARGET_ZVBB; + case ZVBB_OR_ZVKB_EXT: + return (TARGET_ZVBB || TARGET_ZVKB); + case ZVBC_EXT: + return TARGET_ZVBC; + case ZVKG_EXT: + return TARGET_ZVKG; + case ZVKNED_EXT: + return TARGET_ZVKNED; + case ZVKNHA_OR_ZVKNHB_EXT: + return (TARGET_ZVKNHA || TARGET_ZVKNHB); + case ZVKNHB_EXT: + return TARGET_ZVKNHB; + case ZVKSED_EXT: + return TARGET_ZVKSED; + case ZVKSH_EXT: + return TARGET_ZVKSH; + default: + gcc_unreachable (); + } + } /* The base name, as a string. */ const char *base_name; @@ -232,6 +276,8 @@ struct function_group_info on the index value. */ const predication_type_index *preds; const rvv_op_info ops_infos; + /* The required extension value, using it to get the enabled flag. */ + required_ext required_extensions; }; class GTY ((user)) function_instance -- 2.17.1