From: Juzhe-Zhong Date: Tue, 5 Sep 2023 08:47:25 +0000 (+0800) Subject: RISC-V: Export functions as global extern preparing for dynamic LMUL patch use X-Git-Tag: basepoints/gcc-15~6465 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=509c10a62546b9b3430040e455b7258322a024e6;p=thirdparty%2Fgcc.git RISC-V: Export functions as global extern preparing for dynamic LMUL patch use 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. --- diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h index dd7aa360ec5b..0b4dd45380d1 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 63945487006d..1ca3f1dc8df5 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 4a7eb47972e7..01a8d714db89 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 a81bb53a5218..e7e5c14617ee 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