diff options
author | Andrew Carlotti <andrew.carlotti@arm.com> | 2023-07-18 16:40:58 +0100 |
---|---|---|
committer | Andrew Carlotti <andrew.carlotti@arm.com> | 2024-08-19 15:49:47 +0100 |
commit | baf71ec56b40858c5b2a4cc8481403685d753477 (patch) | |
tree | abfdc93baad77165fd2f95a3a40cef52572daad4 /gcc/config/aarch64 | |
parent | a4b39dc4bfad2b224cd2041568d469b5724f8f88 (diff) | |
download | gcc-baf71ec56b40858c5b2a4cc8481403685d753477.zip gcc-baf71ec56b40858c5b2a4cc8481403685d753477.tar.gz gcc-baf71ec56b40858c5b2a4cc8481403685d753477.tar.bz2 |
aarch64: Move check_required_extensions
Move SVE extension checking functionality to aarch64-builtins.cc, so
that it can be shared by non-SVE intrinsics.
gcc/ChangeLog:
* config/aarch64/aarch64-sve-builtins.cc (check_builtin_call)
(expand_builtin): Update calls to the below.
(report_missing_extension, report_missing_registers)
(check_required_extensions): Move out of aarch64_sve namespace,
rename, and move into...
* config/aarch64/aarch64-builtins.cc (aarch64_report_missing_extension)
(aarch64_report_missing_registers)
(aarch64_check_required_extensions) ...here.
* config/aarch64/aarch64-protos.h (aarch64_check_required_extensions):
Add prototype.
Diffstat (limited to 'gcc/config/aarch64')
-rw-r--r-- | gcc/config/aarch64/aarch64-builtins.cc | 100 | ||||
-rw-r--r-- | gcc/config/aarch64/aarch64-protos.h | 2 | ||||
-rw-r--r-- | gcc/config/aarch64/aarch64-sve-builtins.cc | 107 |
3 files changed, 106 insertions, 103 deletions
diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc index 30669f8..a07adce 100644 --- a/gcc/config/aarch64/aarch64-builtins.cc +++ b/gcc/config/aarch64/aarch64-builtins.cc @@ -2180,6 +2180,106 @@ aarch64_general_builtin_decl (unsigned code, bool) return aarch64_builtin_decls[code]; } +/* True if we've already complained about attempts to use functions + when the required extension is disabled. */ +static bool reported_missing_extension_p; + +/* True if we've already complained about attempts to use functions + which require registers that are missing. */ +static bool reported_missing_registers_p; + +/* Report an error against LOCATION that the user has tried to use + function FNDECL when extension EXTENSION is disabled. */ +static void +aarch64_report_missing_extension (location_t location, tree fndecl, + const char *extension) +{ + /* Avoid reporting a slew of messages for a single oversight. */ + if (reported_missing_extension_p) + return; + + error_at (location, "ACLE function %qD requires ISA extension %qs", + fndecl, extension); + inform (location, "you can enable %qs using the command-line" + " option %<-march%>, or by using the %<target%>" + " attribute or pragma", extension); + reported_missing_extension_p = true; +} + +/* Report an error against LOCATION that the user has tried to use + function FNDECL when non-general registers are disabled. */ +static void +aarch64_report_missing_registers (location_t location, tree fndecl) +{ + /* Avoid reporting a slew of messages for a single oversight. */ + if (reported_missing_registers_p) + return; + + error_at (location, + "ACLE function %qD is incompatible with the use of %qs", + fndecl, "-mgeneral-regs-only"); + reported_missing_registers_p = true; +} + +/* Check whether all the AARCH64_FL_* values in REQUIRED_EXTENSIONS are + enabled, given that those extensions are required for function FNDECL. + Report an error against LOCATION if not. */ +bool +aarch64_check_required_extensions (location_t location, tree fndecl, + aarch64_feature_flags required_extensions) +{ + if ((required_extensions & ~aarch64_isa_flags) == 0) + return true; + + auto missing_extensions = required_extensions & ~aarch64_asm_isa_flags; + + if (missing_extensions == 0) + { + /* All required extensions are enabled in aarch64_asm_isa_flags, so the + error must be the use of general-regs-only. */ + aarch64_report_missing_registers (location, fndecl); + return false; + } + + if (missing_extensions & AARCH64_FL_SM_OFF) + { + error_at (location, "ACLE function %qD cannot be called when" + " SME streaming mode is enabled", fndecl); + return false; + } + + if (missing_extensions & AARCH64_FL_SM_ON) + { + error_at (location, "ACLE function %qD can only be called when" + " SME streaming mode is enabled", fndecl); + return false; + } + + if (missing_extensions & AARCH64_FL_ZA_ON) + { + error_at (location, "ACLE function %qD can only be called from" + " a function that has %qs state", fndecl, "za"); + return false; + } + + static const struct { + aarch64_feature_flags flag; + const char *name; + } extensions[] = { +#define AARCH64_OPT_EXTENSION(EXT_NAME, IDENT, C, D, E, F) \ + { AARCH64_FL_##IDENT, EXT_NAME }, +#include "aarch64-option-extensions.def" + }; + + for (unsigned int i = 0; i < ARRAY_SIZE (extensions); ++i) + if (missing_extensions & extensions[i].flag) + { + aarch64_report_missing_extension (location, fndecl, extensions[i].name); + return false; + } + gcc_unreachable (); +} + bool aarch64_general_check_builtin_call (location_t location, vec<location_t>, unsigned int code, tree fndecl, diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h index 44b881b..d03c1fe 100644 --- a/gcc/config/aarch64/aarch64-protos.h +++ b/gcc/config/aarch64/aarch64-protos.h @@ -1018,6 +1018,8 @@ tree aarch64_general_builtin_rsqrt (unsigned int); void handle_arm_acle_h (void); void handle_arm_neon_h (void); +bool aarch64_check_required_extensions (location_t, tree, + aarch64_feature_flags); bool aarch64_general_check_builtin_call (location_t, vec<location_t>, unsigned int, tree, unsigned int, tree *); diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc b/gcc/config/aarch64/aarch64-sve-builtins.cc index 1fe380d..5ca9ec3 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins.cc +++ b/gcc/config/aarch64/aarch64-sve-builtins.cc @@ -947,14 +947,6 @@ static hash_table<registered_function_hasher> *function_table; are IDENTIFIER_NODEs. */ static GTY(()) hash_map<tree, registered_function *> *overload_names[2]; -/* True if we've already complained about attempts to use functions - when the required extension is disabled. */ -static bool reported_missing_extension_p; - -/* True if we've already complained about attempts to use functions - which require registers that are missing. */ -static bool reported_missing_registers_p; - /* Record that TYPE is an ABI-defined SVE type that contains NUM_ZR SVE vectors and NUM_PR SVE predicates. MANGLED_NAME, if nonnull, is the ABI-defined mangling of the type. ACLE_NAME is the <arm_sve.h> name of the type. */ @@ -1076,98 +1068,6 @@ lookup_fndecl (tree fndecl) return &(*registered_functions)[subcode]->instance; } -/* Report an error against LOCATION that the user has tried to use - function FNDECL when extension EXTENSION is disabled. */ -static void -report_missing_extension (location_t location, tree fndecl, - const char *extension) -{ - /* Avoid reporting a slew of messages for a single oversight. */ - if (reported_missing_extension_p) - return; - - error_at (location, "ACLE function %qD requires ISA extension %qs", - fndecl, extension); - inform (location, "you can enable %qs using the command-line" - " option %<-march%>, or by using the %<target%>" - " attribute or pragma", extension); - reported_missing_extension_p = true; -} - -/* Report an error against LOCATION that the user has tried to use - function FNDECL when non-general registers are disabled. */ -static void -report_missing_registers (location_t location, tree fndecl) -{ - /* Avoid reporting a slew of messages for a single oversight. */ - if (reported_missing_registers_p) - return; - - error_at (location, - "ACLE function %qD is incompatible with the use of %qs", - fndecl, "-mgeneral-regs-only"); - reported_missing_registers_p = true; -} - -/* Check whether all the AARCH64_FL_* values in REQUIRED_EXTENSIONS are - enabled, given that those extensions are required for function FNDECL. - Report an error against LOCATION if not. */ -static bool -check_required_extensions (location_t location, tree fndecl, - aarch64_feature_flags required_extensions) -{ - if ((required_extensions & ~aarch64_isa_flags) == 0) - return true; - - auto missing_extensions = required_extensions & ~aarch64_asm_isa_flags; - - if (missing_extensions == 0) - { - /* All required extensions are enabled in aarch64_asm_isa_flags, so the - error must be the use of general-regs-only. */ - report_missing_registers (location, fndecl); - return false; - } - - - if (missing_extensions & AARCH64_FL_SM_OFF) - { - error_at (location, "ACLE function %qD cannot be called when" - " SME streaming mode is enabled", fndecl); - return false; - } - - if (missing_extensions & AARCH64_FL_SM_ON) - { - error_at (location, "ACLE function %qD can only be called when" - " SME streaming mode is enabled", fndecl); - return false; - } - - if (missing_extensions & AARCH64_FL_ZA_ON) - { - error_at (location, "ACLE function %qD can only be called from" - " a function that has %qs state", fndecl, "za"); - return false; - } - - static const struct { - aarch64_feature_flags flag; - const char *name; - } extensions[] = { -#define AARCH64_OPT_EXTENSION(EXT_NAME, IDENT, C, D, E, F) \ - { AARCH64_FL_##IDENT, EXT_NAME }, -#include "aarch64-option-extensions.def" - }; - - for (unsigned int i = 0; i < ARRAY_SIZE (extensions); ++i) - if (missing_extensions & extensions[i].flag) - { - report_missing_extension (location, fndecl, extensions[i].name); - return false; - } - gcc_unreachable (); -} /* Report that LOCATION has a call to FNDECL in which argument ARGNO was not an integer constant expression. ARGNO counts from zero. */ @@ -4763,7 +4663,8 @@ check_builtin_call (location_t location, vec<location_t>, unsigned int code, tree fndecl, unsigned int nargs, tree *args) { const registered_function &rfn = *(*registered_functions)[code]; - if (!check_required_extensions (location, rfn.decl, rfn.required_extensions)) + if (!aarch64_check_required_extensions (location, rfn.decl, + rfn.required_extensions)) return false; return function_checker (location, rfn.instance, fndecl, TREE_TYPE (rfn.decl), nargs, args).check (); @@ -4786,8 +4687,8 @@ rtx expand_builtin (unsigned int code, tree exp, rtx target) { registered_function &rfn = *(*registered_functions)[code]; - if (!check_required_extensions (EXPR_LOCATION (exp), rfn.decl, - rfn.required_extensions)) + if (!aarch64_check_required_extensions (EXPR_LOCATION (exp), rfn.decl, + rfn.required_extensions)) return target; return function_expander (rfn.instance, rfn.decl, exp, target).expand (); } |