return aarch64_builtin_decls[code];
}
+bool
+aarch64_general_check_builtin_call (location_t location, vec<location_t>,
+ unsigned int code, tree fndecl,
+ unsigned int nargs ATTRIBUTE_UNUSED, tree *args)
+{
+ switch (code)
+ {
+ case AARCH64_RSR:
+ case AARCH64_RSRP:
+ case AARCH64_RSR64:
+ case AARCH64_RSRF:
+ case AARCH64_RSRF64:
+ case AARCH64_WSR:
+ case AARCH64_WSRP:
+ case AARCH64_WSR64:
+ case AARCH64_WSRF:
+ case AARCH64_WSRF64:
+ tree addr = STRIP_NOPS (args[0]);
+ if (TREE_CODE (TREE_TYPE (addr)) != POINTER_TYPE
+ || TREE_CODE (addr) != ADDR_EXPR
+ || TREE_CODE (TREE_OPERAND (addr, 0)) != STRING_CST)
+ {
+ error_at (location, "first argument to %qD must be a string literal",
+ fndecl);
+ return false;
+ }
+ }
+ /* Default behavior. */
+ return true;
+}
+
typedef enum
{
SIMD_ARG_COPY_TO_REG,
switch (code & AARCH64_BUILTIN_CLASS)
{
case AARCH64_BUILTIN_GENERAL:
- return true;
-
+ return aarch64_general_check_builtin_call (loc, arg_loc, subcode,
+ orig_fndecl, nargs, args);
case AARCH64_BUILTIN_SVE:
return aarch64_sve::check_builtin_call (loc, arg_loc, subcode,
orig_fndecl, nargs, args);
void handle_arm_acle_h (void);
void handle_arm_neon_h (void);
+bool aarch64_general_check_builtin_call (location_t, vec<location_t>,
+ unsigned int, tree, unsigned int,
+ tree *);
+
namespace aarch64_sve {
void init_builtins ();
void handle_arm_sve_h ();
--- /dev/null
+/* Test the __arm_[r,w]sr ACLE intrinsics family. */
+/* Ensure that illegal behavior is rejected by the compiler. */
+
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -O3 -march=armv8-a" } */
+
+#include <arm_acle.h>
+
+void
+test_non_const_sysreg_name ()
+{
+ const char *regname = "trcseqstr";
+ long long a = __arm_rsr64 (regname); /* { dg-error "first argument to '__builtin_aarch64_rsr64' must be a string literal" } */
+ __arm_wsr64 (regname, a); /* { dg-error "first argument to '__builtin_aarch64_wsr64' must be a string literal" } */
+
+ long long b = __arm_rsr64 (nullptr); /* { dg-error "first argument to '__builtin_aarch64_rsr64' must be a string literal" } */
+ __arm_wsr64 (nullptr, b); /* { dg-error "first argument to '__builtin_aarch64_wsr64' must be a string literal" } */
+}