From patchwork Tue Sep 5 08:47:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "juzhe.zhong@rivai.ai" X-Patchwork-Id: 137489 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp1545040vqo; Tue, 5 Sep 2023 01:48:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFI2ONon3x+QectBajtzTI+hUigebE3KmR8cz96Pzpk6jFK5MYlWJzfmbUFbMSqE0nLslxS X-Received: by 2002:a17:906:518d:b0:9a1:b33a:e464 with SMTP id y13-20020a170906518d00b009a1b33ae464mr13975116ejk.31.1693903691258; Tue, 05 Sep 2023 01:48:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693903691; cv=none; d=google.com; s=arc-20160816; b=g3Xz4xVk8MTK8D7a1piPWCdyGCC5i5VG0M8XH4p9whd6IJjiVAC2M+B1gL12q7bDoQ Y9ikqb8Sz6y3ojnjWnyNRtNoDm7vTwIlVVPzpzXzsU5bP2DhPm+kiwMzu0LWNXR4xXfV qv8onSiNV5m0ZefwGWeFW49edUE/5E/s00Q6vdxPj3jNph2Z7FFya3JOqrJLqdHtgm+V GCg0Yb9UyWyOwJbj2cgBX3B55KU2FSsz3WFxj3i/gIZ8JJnfooFbRY1d7UaIuFaeBkYO ZSVcDMvBiHUTdNkKaw7R1HiLKvk+SCbd7YbV5BvQkE7yVqtnOjm6Dbxnj/INj7cskVu2 l0hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id :content-transfer-encoding:mime-version:message-id:date:subject:to :from:dmarc-filter:delivered-to; bh=pjYgVxck+LcR483j5YspQnYpwMkHFeHqLNHVbMPRqKw=; fh=arl273cIQBNH1P6XLxHQvF0scgitfd773vOV+bwQx3o=; b=F4wG/9Lh+0kg6rdwGYWEVJW9OYyWFJ//9d5ckVmOIy2bXlSKLq6C1MzR9gIbnKsvVa /fi6gGEW1yW8PR0WCg260h9LyyMDuqkYW+JhO8kYzfEDBwFcg2VVWl4H1afPRPTD72eX /m6ciSDIOHQIKPdGowsvaej51FiJx5kCIQzf/h2BP4PBZsnf9MEwnaeitDKTwHMc6nzH z2duWvCv2lxkJ8XDZhhruQikLVt7vZtPOPsABvhIFvbd+5RI8BV1UHSHtTykDhwBtSLU tOY68BVJk5ify74BKjb390N7V+myhC2WlxmxnSb23GLvIKQdkWrKwRNZNfoD8bPWs9aq 4Ozw== ARC-Authentication-Results: i=1; mx.google.com; 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 s2-20020a170906960200b00993686e193csi1468072ejx.53.2023.09.05.01.48.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 01:48:11 -0700 (PDT) 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; 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 05A243858298 for ; Tue, 5 Sep 2023 08:48:07 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbg153.qq.com (smtpbg153.qq.com [13.245.218.24]) by sourceware.org (Postfix) with ESMTPS id 85F0C3858D35 for ; Tue, 5 Sep 2023 08:47:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 85F0C3858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivai.ai Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivai.ai X-QQ-mid: bizesmtp79t1693903649tqrjs6xx Received: from rios-cad121.hadoop.rioslab.org ( [58.60.1.9]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 05 Sep 2023 16:47:28 +0800 (CST) X-QQ-SSF: 01400000000000G0V000000A0000000 X-QQ-FEAT: vrqOr+ppv0vVtwGne/HK+lWbj24QpBJsN5+5tHIJm0LJhNeztHtPjFBTWac3X t5O/hLL05A1Vx96xLNtM0hnqtS2OyxE5ToQGUMY7JU66l49uuWHMBRiJ7pesg6eguWVFAzv AVnchvU72+Z5z+jOZ1LJro7+2mBozNTbn9C/nBCXS0h0lXpAhMzGvMUXSuOfyvkEsHPpjoq /Zseh+p6w2ySodgn8JtXC62dUSaxgvQcNaCjC3cJW7rLRAw8poSCLKY9dgggX2C8BwDSdi+ RHzzLzdWqtJBMd8AGvHPbHfxGT7Mv7K4EHjCxQlYtybVBEhPEpWDle2pH63Djv4REFwvKJ5 STzjZN0JbQUOvHhNTasmXNbOlbYkud32bMrr2i+fUyQi1ByKxtPDcLrA2y8nytmRQ/z8rfJ WDKXeDwDpCOZ21sIUciuxQ== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 6646636783062219905 From: Juzhe-Zhong To: gcc-patches@gcc.gnu.org Subject: [PATCH] RISC-V: Export functions as global extern preparing for dynamic LMUL patch use Date: Tue, 5 Sep 2023 16:47:25 +0800 Message-Id: <20230905084725.1212443-1-juzhe.zhong@rivai.ai> X-Mailer: git-send-email 2.36.3 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvrgz:qybglogicsvrgz7a-one-0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP 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: , Cc: kito.cheng@sifive.com, kito.cheng@gmail.com, Juzhe-Zhong Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776186756656775286 X-GMAIL-MSGID: 1776186756656775286 Notice those functions need to be use by COST model for dynamic LMUL use. Extract as a single patch and committed. gcc/ChangeLog: * config/riscv/riscv-protos.h (lookup_vector_type_attribute): Export global. (get_all_predecessors): New function. (get_all_successors): Ditto. * config/riscv/riscv-v.cc (get_all_predecessors): Ditto. (get_all_successors): Ditto. * config/riscv/riscv-vector-builtins.cc (sizeless_type_p): Export global. * config/riscv/riscv-vsetvl.cc (get_all_predecessors): Remove it. --- gcc/config/riscv/riscv-protos.h | 3 ++ gcc/config/riscv/riscv-v.cc | 48 +++++++++++++++++++++++ gcc/config/riscv/riscv-vector-builtins.cc | 2 +- gcc/config/riscv/riscv-vsetvl.cc | 25 ------------ 4 files changed, 52 insertions(+), 26 deletions(-) diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h index dd7aa360ec5..0b4dd45380d 100644 --- a/gcc/config/riscv/riscv-protos.h +++ b/gcc/config/riscv/riscv-protos.h @@ -365,6 +365,7 @@ enum avl_type /* Routines implemented in riscv-vector-builtins.cc. */ void init_builtins (void); const char *mangle_builtin_type (const_tree); +tree lookup_vector_type_attribute (const_tree); #ifdef GCC_TARGET_H bool verify_type_context (location_t, type_context_kind, const_tree, bool); bool expand_vec_perm_const (machine_mode, machine_mode, rtx, rtx, rtx, @@ -493,6 +494,8 @@ enum floating_point_rounding_mode get_frm_mode (rtx); opt_machine_mode vectorize_related_mode (machine_mode, scalar_mode, poly_uint64); unsigned int autovectorize_vector_modes (vec *, bool); +hash_set get_all_predecessors (basic_block); +hash_set get_all_successors (basic_block); } /* We classify builtin types into two classes: diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc index 63945487006..1ca3f1dc8df 100644 --- a/gcc/config/riscv/riscv-v.cc +++ b/gcc/config/riscv/riscv-v.cc @@ -3387,4 +3387,52 @@ expand_fold_extract_last (rtx *ops) emit_label (end_label); } +hash_set +get_all_predecessors (basic_block bb) +{ + hash_set blocks; + auto_vec work_list; + hash_set visited_list; + work_list.safe_push (bb); + + while (!work_list.is_empty ()) + { + basic_block new_bb = work_list.pop (); + visited_list.add (new_bb); + edge e; + edge_iterator ei; + FOR_EACH_EDGE (e, ei, new_bb->preds) + { + if (!visited_list.contains (e->src)) + work_list.safe_push (e->src); + blocks.add (e->src); + } + } + return blocks; +} + +hash_set +get_all_successors (basic_block bb) +{ + hash_set blocks; + auto_vec work_list; + hash_set visited_list; + work_list.safe_push (bb); + + while (!work_list.is_empty ()) + { + basic_block new_bb = work_list.pop (); + visited_list.add (new_bb); + edge e; + edge_iterator ei; + FOR_EACH_EDGE (e, ei, new_bb->succs) + { + if (!visited_list.contains (e->dest)) + work_list.safe_push (e->dest); + blocks.add (e->dest); + } + } + return blocks; +} + } // namespace riscv_vector diff --git a/gcc/config/riscv/riscv-vector-builtins.cc b/gcc/config/riscv/riscv-vector-builtins.cc index 4a7eb47972e..01a8d714db8 100644 --- a/gcc/config/riscv/riscv-vector-builtins.cc +++ b/gcc/config/riscv/riscv-vector-builtins.cc @@ -2671,7 +2671,7 @@ sizeless_type_p (const_tree type) /* If TYPE is an ABI-defined RVV type, return its attribute descriptor, otherwise return null. */ -static tree +tree lookup_vector_type_attribute (const_tree type) { if (type == error_mark_node) diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc index a81bb53a521..e7e5c14617e 100644 --- a/gcc/config/riscv/riscv-vsetvl.cc +++ b/gcc/config/riscv/riscv-vsetvl.cc @@ -521,31 +521,6 @@ get_same_bb_set (hash_set &sets, const basic_block cfg_bb) return nullptr; } -/* Recursively find all predecessor blocks for cfg_bb. */ -static hash_set -get_all_predecessors (basic_block cfg_bb) -{ - hash_set blocks; - auto_vec work_list; - hash_set visited_list; - work_list.safe_push (cfg_bb); - - while (!work_list.is_empty ()) - { - basic_block new_cfg_bb = work_list.pop (); - visited_list.add (new_cfg_bb); - edge e; - edge_iterator ei; - FOR_EACH_EDGE (e, ei, new_cfg_bb->preds) - { - if (!visited_list.contains (e->src)) - work_list.safe_push (e->src); - blocks.add (e->src); - } - } - return blocks; -} - /* Helper function to get SEW operand. We always have SEW value for all RVV instructions that have VTYPE OP. */ static uint8_t