From patchwork Mon Dec 18 03:28:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feng Wang X-Patchwork-Id: 180131 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1006355dyi; Sun, 17 Dec 2023 19:29:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IFENUEx4J/WeBRjcacR/A2cabjDgZZWC3ZJi4zJoeheGoKYQhWDp+XFVsaAamPihK0Brsv/ X-Received: by 2002:a05:620a:800a:b0:77e:fba3:3e6c with SMTP id ee10-20020a05620a800a00b0077efba33e6cmr24514002qkb.53.1702870185456; Sun, 17 Dec 2023 19:29:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702870185; cv=pass; d=google.com; s=arc-20160816; b=RmQVXpKcE3O1tbmyqcGDPjPuJna3frIqh4LA0Q2BzEmaycGkuBlpAymYqDkf8zp6ss jz7up7qnVFyHTsEyWj2HFuYhCNNXlqliZWy0xDCb9RkK8I27mtm1S+b4VIqrFIspOSv8 /tvknunQy7izsjB6lCP1CpvkeeBJMeGhpR4UYm//F3ejy5T1yplgpe+mW2DSn0PNarc3 WZfS5awBhQH6GIogiaWfQxtN2/Gr6GoF+aQ1mbUnrj/1UG2G78D0EzU/RKfEs4pVMs9W Z9o8VprmtG8NryyCWE8kdu1Ny34FiOIaml521YTbrZORTqPI/naAu0PYwlhjwlWeW+rH gT2A== 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=Puwh6aWFkQFHAcgMxtgtl8u0zENvfqZymSUfjOfMnnI=; b=yaIsgccpLhAzCDtNEPqa626vVJZrhrxGOls7nRTUTarY8Xd2sTQEVuHg+IBz46MCAZ VWTBVacvZOU7ve78ZyRQXZe/FehjSJ4gj7Y4hKvjAfcbtdBpvJEmvqcjNl/MauHbfgW/ F0ZLW/tqCjzggYp4s471pPJ0eG9IljorxSssCYkTjw1kvacdSYatRKBsBLj6QvXDL6of iDtDjERVz3aHtXvX5lqE/Kjr8G0YzqT9GEX0/x9QDhpO1n6bfAQ/9XEHXbDQKZljPshd vj6Q1QjkVcTumtLPsBOst8XYLJDHOuKZCxETdtbK2EmVHjCoHmnGEt+yjK/JSSqpOdS3 loTQ== 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 r22-20020a05620a299600b0077f2cb9c6aesi23758652qkp.673.2023.12.17.19.29.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 19:29:45 -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 309353857C62 for ; Mon, 18 Dec 2023 03:29:45 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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: 1785588807120345444 X-GMAIL-MSGID: 1785588807120345444 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