aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/riscv/riscv-vector-builtins.h
diff options
context:
space:
mode:
authorxuli <xuli1@eswincomputing.com>2023-10-30 08:23:15 +0000
committerxuli <xuli1@eswincomputing.com>2023-11-06 02:27:17 +0000
commit1a55724f7870719d51a7acc0ccada254fcfd1cda (patch)
tree9448e841dd7f5f92b7313dccc6860b9df7ceaf23 /gcc/config/riscv/riscv-vector-builtins.h
parentfd5147177b9fa04943a3a55512b81f8f46ab4ac5 (diff)
downloadgcc-1a55724f7870719d51a7acc0ccada254fcfd1cda.zip
gcc-1a55724f7870719d51a7acc0ccada254fcfd1cda.tar.gz
gcc-1a55724f7870719d51a7acc0ccada254fcfd1cda.tar.bz2
RISC-V: Implement RESOLVE_OVERLOADED_BUILTIN for RVV intrinsic
Update in v6: * Rename maybe_require_frm_p to may_require_frm_p. * Rename maybe_require_vxrm_p to may_require_vxrm_p. * Move may_require_frm_p and may_require_vxrm_p to function_base. Update in v5: * Split has_vxrm_or_frm_p into maybe_require_frm_p and maybe_require_vxrm_p. * Adjust comments. Update in v4: * Remove class function_resolver. * Remove function get_non_overloaded_instance. * Add overloaded hash traits for non-overloaded intrinsic. * All overloaded intrinsics are implemented, and the tests pass. Update in v3: * Rewrite comment for overloaded function add. * Move get_non_overloaded_instance to function_base. Update in v2: * Add get_non_overloaded_instance for function instance. * Fix overload check for policy function. * Enrich the test cases check. Original log: This patch would like add the framework to support the RVV overloaded intrinsic API in riscv-xxx-xxx-gcc, like riscv-xxx-xxx-g++ did. However, it almost leverage the hook TARGET_RESOLVE_OVERLOADED_BUILTIN with below steps. * Register overloaded functions. * Add function_resolver for overloaded function resolving. * Add resolve API for function shape with default implementation. * Implement HOOK for navigating the overloaded API to non-overloaded API. gcc/ChangeLog: * config/riscv/riscv-c.cc (riscv_resolve_overloaded_builtin): New function for the hook. (riscv_register_pragmas): Register the hook. * config/riscv/riscv-protos.h (resolve_overloaded_builtin): New decl. * config/riscv/riscv-vector-builtins-bases.cc: New function impl. * config/riscv/riscv-vector-builtins-shapes.cc (build_one): Register overloaded function. * config/riscv/riscv-vector-builtins.cc (struct non_overloaded_registered_function_hasher): New hash table. (function_builder::add_function): Add overloaded arg. (function_builder::add_unique_function): Map overloaded function to non-overloaded function. (function_builder::add_overloaded_function): New API impl. (registered_function::overloaded_hash): Calculate hash value. (has_vxrm_or_frm_p): New function impl. (non_overloaded_registered_function_hasher::hash): Ditto. (non_overloaded_registered_function_hasher::equal): Ditto. (handle_pragma_vector): Allocate space for hash table. (resolve_overloaded_builtin): New function impl. * config/riscv/riscv-vector-builtins.h (function_base::may_require_frm_p): Ditto. (function_base::may_require_vxrm_p): Ditto. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/overloaded_rv32_vadd.c: New test. * gcc.target/riscv/rvv/base/overloaded_rv32_vfadd.c: New test. * gcc.target/riscv/rvv/base/overloaded_rv32_vget_vset.c: New test. * gcc.target/riscv/rvv/base/overloaded_rv32_vloxseg2ei16.c: New test. * gcc.target/riscv/rvv/base/overloaded_rv32_vmv.c: New test. * gcc.target/riscv/rvv/base/overloaded_rv32_vreinterpret.c: New test. * gcc.target/riscv/rvv/base/overloaded_rv64_vadd.c: New test. * gcc.target/riscv/rvv/base/overloaded_rv64_vfadd.c: New test. * gcc.target/riscv/rvv/base/overloaded_rv64_vget_vset.c: New test. * gcc.target/riscv/rvv/base/overloaded_rv64_vloxseg2ei16.c: New test. * gcc.target/riscv/rvv/base/overloaded_rv64_vmv.c: New test. * gcc.target/riscv/rvv/base/overloaded_rv64_vreinterpret.c: New test. * gcc.target/riscv/rvv/base/overloaded_vadd.h: New test. * gcc.target/riscv/rvv/base/overloaded_vfadd.h: New test. * gcc.target/riscv/rvv/base/overloaded_vget_vset.h: New test. * gcc.target/riscv/rvv/base/overloaded_vloxseg2ei16.h: New test. * gcc.target/riscv/rvv/base/overloaded_vmv.h: New test. * gcc.target/riscv/rvv/base/overloaded_vreinterpret.h: New test. Signed-off-by: Li Xu <xuli1@eswincomputing.com> Co-Authored-By: Pan Li <pan2.li@intel.com>
Diffstat (limited to 'gcc/config/riscv/riscv-vector-builtins.h')
-rw-r--r--gcc/config/riscv/riscv-vector-builtins.h27
1 files changed, 26 insertions, 1 deletions
diff --git a/gcc/config/riscv/riscv-vector-builtins.h b/gcc/config/riscv/riscv-vector-builtins.h
index e358a8e..cd8ccab 100644
--- a/gcc/config/riscv/riscv-vector-builtins.h
+++ b/gcc/config/riscv/riscv-vector-builtins.h
@@ -277,6 +277,8 @@ public:
void apply_predication (const function_instance &, tree, vec<tree> &) const;
void add_unique_function (const function_instance &, const function_shape *,
tree, vec<tree> &);
+ void add_overloaded_function (const function_instance &,
+ const function_shape *);
void register_function_group (const function_group_info &);
void append_name (const char *);
void append_base_name (const char *);
@@ -288,7 +290,8 @@ private:
tree get_attributes (const function_instance &);
registered_function &add_function (const function_instance &, const char *,
- tree, tree, bool);
+ tree, tree, bool, const char *,
+ const vec<tree> &, bool);
/* True if we should create a separate decl for each instance of an
overloaded function, instead of using function_builder. */
@@ -417,6 +420,12 @@ public:
/* Return true if intrinsics has rounding mode operand. */
virtual bool has_rounding_mode_operand_p () const;
+ /* Return true if intrinsics maybe require vxrm operand. */
+ virtual bool may_require_vxrm_p () const;
+
+ /* Return true if intrinsics maybe require frm operand. */
+ virtual bool may_require_frm_p () const;
+
/* Try to fold the given gimple call. Return the new gimple statement
on success, otherwise return null. */
virtual gimple *fold (gimple_folder &) const { return NULL; }
@@ -674,6 +683,22 @@ function_base::has_rounding_mode_operand_p () const
return false;
}
+/* We choose to return false by default since most of the intrinsics does
+ not need frm operand. */
+inline bool
+function_base::may_require_frm_p () const
+{
+ return false;
+}
+
+/* We choose to return false by default since most of the intrinsics does
+ not need vxrm operand. */
+inline bool
+function_base::may_require_vxrm_p () const
+{
+ return false;
+}
+
/* Since most of intrinsics can be overloaded, we set it true by default. */
inline bool
function_base::can_be_overloaded_p (enum predication_type_index) const