summaryrefslogtreecommitdiff
path: root/gcc/target.def
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2019-09-27 08:39:16 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2019-09-27 08:39:16 +0000
commitc6447c2014b76b5c077a07712a7f0b0aaa2e14d4 (patch)
tree9921a7089999908bc2646d4e3529ed4eeef6495a /gcc/target.def
parent18908a56e18f15f84a91a4529923dd0878b2294f (diff)
[C][C++] Allow targets to check calls to BUILT_IN_MD functions
For SVE, we'd like the frontends to check calls to target-specific built-in functions in the same way that they already do for "normal" builtins. This patch adds a target hook for that and extends check_builtin_function_arguments accordingly. A slight complication is that when TARGET_RESOLVE_OVERLOADED_BUILTIN has resolved an overload, it can use build_function_call_vec to build the call to the underlying non-overloaded function decl. This in turn coerces the arguments to the function type and then calls check_builtin_function_arguments to check the final call. If the target does find a problem in this final call, it can be useful to refer to the original overloaded function decl in diagnostics, since that's what the user wrote. The patch therefore passes the original decl as a final optional parameter to build_function_call_vec. 2019-09-27 Richard Sandiford <richard.sandiford@arm.com> gcc/ * target.def (check_builtin_call): New target hook. * doc/tm.texi.in (TARGET_CHECK_BUILTIN_CALL): New @hook. * doc/tm.texi: Regenerate. gcc/c-family/ * c-common.h (build_function_call_vec): Take the original function decl as an optional final parameter. (check_builtin_function_arguments): Take the original function decl. * c-common.c (check_builtin_function_arguments): Likewise. Handle all built-in functions, not just BUILT_IN_NORMAL ones. Use targetm.check_builtin_call to check BUILT_IN_MD functions. gcc/c/ * c-typeck.c (build_function_call_vec): Take the original function decl as an optional final parameter. Pass all built-in calls to check_builtin_function_arguments. gcc/cp/ * cp-tree.h (build_cxx_call): Take the original function decl as an optional final parameter. (cp_build_function_call_vec): Likewise. * call.c (build_cxx_call): Likewise. Pass all built-in calls to check_builtin_function_arguments. * typeck.c (build_function_call_vec): Take the original function decl as an optional final parameter and pass it to cp_build_function_call_vec. (cp_build_function_call_vec): Take the original function decl as an optional final parameter and pass it to build_cxx_call. From-SVN: r276176
Diffstat (limited to 'gcc/target.def')
-rw-r--r--gcc/target.def18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/target.def b/gcc/target.def
index 01609136848..f9446fa05a2 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -2397,6 +2397,24 @@ another @code{CALL_EXPR}.\n\
@var{arglist} really has type @samp{VEC(tree,gc)*}",
tree, (unsigned int /*location_t*/ loc, tree fndecl, void *arglist), NULL)
+DEFHOOK
+(check_builtin_call,
+ "Perform semantic checking on a call to a machine-specific built-in\n\
+function after its arguments have been constrained to the function\n\
+signature. Return true if the call is valid, otherwise report an error\n\
+and return false.\n\
+\n\
+This hook is called after @code{TARGET_RESOLVE_OVERLOADED_BUILTIN}.\n\
+The call was originally to built-in function @var{orig_fndecl},\n\
+but after the optional @code{TARGET_RESOLVE_OVERLOADED_BUILTIN}\n\
+step is now to built-in function @var{fndecl}. @var{loc} is the\n\
+location of the call and @var{args} is an array of function arguments,\n\
+of which there are @var{nargs}. @var{arg_loc} specifies the location\n\
+of each argument.",
+ bool, (location_t loc, vec<location_t> arg_loc, tree fndecl,
+ tree orig_fndecl, unsigned int nargs, tree *args),
+ NULL)
+
/* Fold a target-specific builtin to a tree valid for both GIMPLE
and GENERIC. */
DEFHOOK