aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorFeng Wang <wangfeng@eswincomputing.com>2023-12-18 03:28:00 +0000
committerFeng Wang <wangfeng@eswincomputing.com>2023-12-19 01:21:40 +0000
commit15cb5204e4c5f79d1b7179ae2590bb65e24b745f (patch)
tree1c70ac7c965655dab69dfbeaf1ecc2ac9fa1ca10 /gcc
parent08c5d26afade74f8493580fb0380abcc7ee9589b (diff)
downloadgcc-15cb5204e4c5f79d1b7179ae2590bb65e24b745f.zip
gcc-15cb5204e4c5f79d1b7179ae2590bb65e24b745f.tar.gz
gcc-15cb5204e4c5f79d1b7179ae2590bb65e24b745f.tar.bz2
RISC-V: Add required_extensions in function_group
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/riscv/riscv-vector-builtins-functions.def2
-rw-r--r--gcc/config/riscv/riscv-vector-builtins.cc7
-rw-r--r--gcc/config/riscv/riscv-vector-builtins.h46
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 1c37fd5..03421d5 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 6330a3a..4e2c66c2 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<non_overloaded_registered_function_hasher> (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 cd8ccab..4f38c09 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