Andrew Carlotti <andrew.carlo...@arm.com> writes: > Add infrastructure to allow rewriting the architecture strings passed to > the assembler (either as -march options or .arch directives). There was > already canonicalisation everywhere except for an -march driver option > passed directly to the compiler; this patch applies the same > canonicalisation there as well. > > gcc/ChangeLog: > > * common/config/aarch64/aarch64-common.cc > (aarch64_get_arch_string_for_assembler): New. > (aarch64_rewrite_march): New. > (aarch64_rewrite_selected_cpu): Call new function. > * config/aarch64/aarch64-elf.h (ASM_SPEC): Remove identity mapping. > * config/aarch64/aarch64-protos.h > (aarch64_get_arch_string_for_assembler): New. > * config/aarch64/aarch64.cc > (aarch64_declare_function_name): Call new function. > (aarch64_start_file): Ditto. > * config/aarch64/aarch64.h > * config/aarch64/aarch64.h > (EXTRA_SPEC_FUNCTIONS): Use new macro name. > (MCPU_TO_MARCH_SPEC): Rename to... > (MARCH_REWRITE_SPEC): ...this, and add new spec rule. > (aarch64_rewrite_march): New declaration. > (MCPU_TO_MARCH_SPEC_FUNCTIONS): Rename to... > (MARCH_REWRITE_SPEC_FUNCTIONS): ...this, and add new function. > (ASM_CPU_SPEC): Use new macro name.
Looks good, but it'll need to be rebased on top of Tamar's fix to MARCH_REWRITE_SPEC (please wait for that to go in first). On that: > @@ -1502,18 +1502,21 @@ extern const char *host_detect_local_cpu (int argc, > const char **argv); > {"cpu", "%{!march=*:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \ > CONFIG_TUNE_SPEC > > -#define MCPU_TO_MARCH_SPEC \ > - " %{mcpu=*:-march=%:rewrite_mcpu(%{mcpu=*:%*})}" > +#define MARCH_REWRITE_SPEC \ > + " %{mcpu=*:-march=%:rewrite_mcpu(%{mcpu=*:%*})}" \ > + " %{march=*:-march=%:rewrite_march(%{march=*:%*})}" I suppose the way of handling both Tamar's change and yours would be something like: "%{march=*:-march=%:rewrite_march(%{march=*:%*})" \ ";:%{mcpu=*:-march=%:rewrite_mcpu(%{mcpu=*:%*})}}" (untested). > +extern const char *aarch64_rewrite_march (int argc, const char **argv); > extern const char *aarch64_rewrite_mcpu (int argc, const char **argv); > extern const char *is_host_cpu_not_armv8_base (int argc, const char **argv); > -#define MCPU_TO_MARCH_SPEC_FUNCTIONS \ > +#define MARCH_REWRITE_SPEC_FUNCTIONS \ MARCH_REWRITE_SPEC_FUNCTIONS also doesn't quite cover it. How about just AARCH64_BASE_SPEC_FUNCTIONS, since its purpose is to define the functions needed for both cross and native hosts? OK with those changes if you agree. Thanks, Richard > + { "rewrite_march", aarch64_rewrite_march }, \ > { "rewrite_mcpu", aarch64_rewrite_mcpu }, \ > { "is_local_not_armv8_base", is_host_cpu_not_armv8_base }, > > > #define ASM_CPU_SPEC \ > - MCPU_TO_MARCH_SPEC > + MARCH_REWRITE_SPEC > > #define EXTRA_SPECS \ > { "asm_cpu_spec", ASM_CPU_SPEC } > diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc > index > 75ba66a979c979fd01948b0a2066a15371df9bfa..95861c1088052cc60d1e02c654ee970cb8bc3bef > 100644 > --- a/gcc/config/aarch64/aarch64.cc > +++ b/gcc/config/aarch64/aarch64.cc > @@ -24831,16 +24831,12 @@ aarch64_declare_function_name (FILE *stream, const > char* name, > targ_options = TREE_TARGET_OPTION (target_option_current_node); > gcc_assert (targ_options); > > - const struct processor *this_arch > - = aarch64_get_arch (targ_options->x_selected_arch); > - > auto isa_flags = aarch64_get_asm_isa_flags (targ_options); > - std::string extension > - = aarch64_get_extension_string_for_isa_flags (isa_flags, > - this_arch->flags); > + aarch64_arch arch = targ_options->x_selected_arch; > + std::string to_print > + = aarch64_get_arch_string_for_assembler (arch, isa_flags); > /* Only update the assembler .arch string if it is distinct from the last > such string we printed. */ > - std::string to_print = this_arch->name + extension; > if (to_print != aarch64_last_printed_arch_string) > { > asm_fprintf (asm_out_file, "\t.arch %s\n", to_print.c_str ()); > @@ -24962,19 +24958,16 @@ aarch64_start_file (void) > struct cl_target_option *default_options > = TREE_TARGET_OPTION (target_option_default_node); > > - const struct processor *default_arch > - = aarch64_get_arch (default_options->x_selected_arch); > + aarch64_arch default_arch = default_options->x_selected_arch; > auto default_isa_flags = aarch64_get_asm_isa_flags (default_options); > - std::string extension > - = aarch64_get_extension_string_for_isa_flags (default_isa_flags, > - default_arch->flags); > - > - aarch64_last_printed_arch_string = default_arch->name + extension; > - aarch64_last_printed_tune_string = ""; > - asm_fprintf (asm_out_file, "\t.arch %s\n", > - aarch64_last_printed_arch_string.c_str ()); > - > - default_file_start (); > + std::string arch_string > + = aarch64_get_arch_string_for_assembler (default_arch, > default_isa_flags); > + aarch64_last_printed_arch_string = arch_string; > + aarch64_last_printed_tune_string = ""; > + asm_fprintf (asm_out_file, "\t.arch %s\n", > + arch_string.c_str ()); > + > + default_file_start (); > } > > /* Emit load exclusive. */