From patchwork Tue Dec 19 01:23:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feng Wang X-Patchwork-Id: 180702 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1647556dyi; Mon, 18 Dec 2023 17:25:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGE/Wp5czXF5tYWp2AgT/YAni+9WuGuDn6+29Z2rDElm5l8RZK0d7BD84nlbfwwoCrXLX8T X-Received: by 2002:a05:6870:c081:b0:203:db4a:5858 with SMTP id c1-20020a056870c08100b00203db4a5858mr1481196oad.31.1702949122510; Mon, 18 Dec 2023 17:25:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702949122; cv=pass; d=google.com; s=arc-20160816; b=RkQhqbm8OcYrqm23OZw33HKF0KeojfyEGJMg66gHXg1uowVz/1j3YXacRyopd+dIqU Lk+mlYeQ8zS3swQZ/CB9ThidnW+3JK/j9/g6309rpaCvM+PUkh0xOSJ66IpVx0EMpgYi iNIL284O1Wj/msQ9aRC0SsW/203T4zxcucg6oKJsYeRGydS/dU7TXLqY+t6rVPJbPkA7 O98JxRyhGVJkh3WrhkTRAXx6FaydYHav0W7vY62wGcCiF9RqJVH+XnTyYYsCxh7EgZJE 7KwPLLdsbqNL5om4Ey9QxQ6c9XBviw40iZkkBhndABRG1jJAvX7vRr1LTImf7rE8jT4c Vb8A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to; bh=xTGc/og6PR3qwCkhyF6ZKZC23AvDvE5NeqmDZE5VFOk=; fh=wZsTJjjR4v8BRcXwQWcyfe6tMSjhJr9Wj68rYddjXWo=; b=HaNuoQZmH9v1crD94q+RWOHQAEp3j7l7wwzZDr07bESFyOfLoRFvxO/KO3v7EWQ6sK ERj+XIlhBKyYkwmUTBAHMI13m0GuEW9SVY9MKdNb94C6YTiPwlWBpa6pDN1IQboX8RFf 7zEdWgtvFY+jmkh0XsdEjvQs2B7+wrWIR5kpzKPngk4OM8Qd6S9Q8XBCYhWnI/qclRbg XWWN9vJuKI6qtPGL+4atHYdEFQqNVng2dZaxGDxTlhHlsS4dp2KeU2gK6l9gbuecHTAu 55+YksJ/M8bp7//FvRps8YpTX4zSm3t1hiDdTmCEL8PZUOpzZfgBPAcMN+w6rm+ReF4b nPkw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r4-20020ac85c84000000b004260c724189si9696991qta.474.2023.12.18.17.25.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 17:25:22 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 30A953857BBD for ; Tue, 19 Dec 2023 01:25:22 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from zg8tmtyylji0my4xnjqumte4.icoremail.net (zg8tmtyylji0my4xnjqumte4.icoremail.net [162.243.164.118]) by sourceware.org (Postfix) with ESMTP id EA1753858031 for ; Tue, 19 Dec 2023 01:24:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EA1753858031 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 EA1753858031 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=162.243.164.118 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702949099; cv=none; b=iqPSMym4igYXBPaCNHu7eSylPz98MYLWnCdcDmiWlFabUIDlXLx8UUDJaSS4kSBON22dslzXvYajc1DHf4C7zs0biHaTwk8jH7SKDx5/l69bUTMGC6I/AjtGZqzKfMl9kQ5zBKeLrSPWaDoUmIsTwEDUBRD+qp+qgmzxkxNjpXs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702949099; c=relaxed/simple; bh=kUrf4tCIPlsNFDJll+U2zQSrSwEfVYUW/o+OubccdRs=; h=From:To:Subject:Date:Message-Id; b=BhPlSFKVjb2MLczHXCx7SUHX82iIPQNX1r1J7pLRV9rOzqOeBNFCG/8McSarQZQcOHyK1/Di00mZI6aQsPNB5eIC2rlBrtJlViu/FXnla+jkuQw2IUaJGbxmpbzMJIrq1CPBcuY/hOIVrPmsRE6rbmZLkyzefbijPsZ+/FLIRSY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost.localdomain (unknown [10.12.130.31]) by app2 (Coremail) with SMTP id TQJkCgD3hdSQ8IBlBRgCAA--.22773S4; Tue, 19 Dec 2023 09:23:28 +0800 (CST) From: Feng Wang To: gcc-patches@gcc.gnu.org Cc: Feng Wang Subject: [committed] RISC-V: Add required_extensions in function_group Date: Tue, 19 Dec 2023 01:23:41 +0000 Message-Id: <20231219012341.11792-1-wangfeng@eswincomputing.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: TQJkCgD3hdSQ8IBlBRgCAA--.22773S4 X-Coremail-Antispam: 1UD129KBjvJXoW3AF4fJFWfCFy7KF15Kw4kJFb_yoW7Zw1Upa y5Ar1akr95JFsxuryftFWrGw1fCw4Igw4Iyrs5Cw4UAay7WrZ7t3Z8K3W2vF18ZF1rCr1I 93WF9FyF9w17ArJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkI14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVWxJr0_GcWl84ACjcxK6I8E87Iv6xkF7I0E14v26r xl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj 6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkIecxEwVCm-wCF 04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r 18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jrv_JF1lIxkGc2Ij64vI r41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr 1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvE x4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7VUbrMaUUUUUU== X-CM-SenderInfo: pzdqwwxhqjqvxvzl0uprps33xlqjhudrp/ X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785671578670786444 X-GMAIL-MSGID: 1785671578670786444 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