This is a slight respin of this patch, handling the -moverride string more gracefully. We need to explicitly save and restore it in TARGET_OPTION_SAVE otherwise the option gen machinery gets confused about its type and during its printing uses the wrong format code for the pointer, leading to a warning that may trigger during bootstrap. Otherwise it is the same as the previous version. Bootstrapped and tested on aarch64. I'd like to propose this version instead of the original. Ok? Thanks, Kyrill 2015-07-17 Kyrylo Tkachov * config/aarch64/aarch64.opt (explicit_tune_core): New TargetVariable. (explicit_arch): Likewise. (x_aarch64_isa_flags): Likewise. (mgeneral-regs-only): Mark as Save. (mfix-cortex-a53-835769): Likewise. (mcmodel=): Likewise. (mstrict-align): Likewise. (momit-leaf-frame-pointer): Likewise. (mtls-dialect): Likewise. (master=): Likewise. * config/aarch64/aarch64.h (ASM_DECLARE_FUNCTION_NAME): Define. (aarch64_isa_flags): Remove extern declaration. * config/aarch64/aarch64.c (aarch64_validate_mcpu): Return a bool to indicate success or failure. (aarch64_validate_march): Likewise. (aarch64_validate_mtune): Likewise. (aarch64_isa_flags): Delete. (aarch64_override_options_internal): Access opts->x_aarch64_isa_flags instead of aarch64_isa_flags. (aarch64_get_tune_cpu): New function. (aarch64_get_arch): Likewise. (aarch64_override_options): Use above and set up explicit_tune_core and explicit_arch. (aarch64_print_extension): Move earlier in file. Add isa_flags argument and use that instead of the global aarch64_isa_flags. (aarch64_option_save): New function. (aarch64_option_restore): Likewise. (aarch64_option_print): Likewise. (aarch64_declare_function_name): Likewise. (aarch64_start_file): Delete. (TARGET_ASM_FILE_START): Do not define. (TARGET_OPTION_RESTORE, TARGET_OPTION_PRINT): Define. * config/aarch64/aarch64-protos.h (aarch64_declare_function_name): Declare prototype. On 16/07/15 16:20, Kyrill Tkachov wrote: > Hi all, > > This is one of the main patches in the series. > The backend compilation state can be described by the options in aarch64.opt marked as Save. > This causes the options-save.c machinery to save and restore them when asked them and the > TARGET_OPTION_SAVE and TARGET_OPTION_RESTORE should handle all the extra stuff that's required > to reinitialise the backend. > > This patch marks the options that we want to support for SWITCHABLE_TARGET as Save and adds 3 > extra variables: explicit_tune_core, explicit_arch and x_aarch64_isa_flags. > These 3 variables are used to store the explicit core to tune for (as specified by -mcpu or -mtune), > the explicitly specified architecture (as specified by -mcpu or -march) and the architecture > features (as specified by the extension string to -march,-mcpu or derived from them). > > The aarch64_isa_flags definition is moved from aarch64.c into aarch64.opt and marked as a TargetVariable. > This means that the auto-generated machinery in options-save.c will automatically save and restore it for us. > > The patch defines the TARGET_OPTION_RESTORE hook to extract the selected_tune and selected_arch from the > explicit_tune_core and explicit_arch variables and restore the backend compilation state using the > aarch64_override_options_internal machinery that we refactored earlier. > > A TARGET_OPTION_PRINT implementation is added to print out the explicit_arch and explicit_tune_core options, > as well as aarch64_isa_flags. > > As preparation for SWITCHABLE_TARGETS this patch also changes the output assembly format a bit. > Since we want to potentially handle multiple values of aarch64_isa_flags within a file in the future, we don't > want to just print out a global .arch or .cpu directive in the beginning of the assembly file. > Instead, we want to print out the .arch directive on a per-function basis. This is accomplished by > defining the ASM_DECLARE_FUNCTION_NAME hook and printing out selected_arch and aarch64_isa_flags there. > As an added bonus we can print out the tuning name in the comments and since we added a proper ident > field to the processor struct that we store in explicit_tune_core, we can print out the full tune name > in an assembly comment. > > For example, compiling with -mcpu=cortex-a57.cortex-a53 we now get: > > .file "sha1_1.c" > .text > .align 2 > .p2align 4,,15 > .global foo > .arch armv8-a+fp+simd+crc > //.tune cortex-a57.cortex-a53 > .type foo, %function > foo: > add w0, w0, 5 > ret > .size foo, .-foo > .ident "GCC: (unknown) 6.0.0 20150522 (experimental)" > > instead of: > .cpu cortex-a57+fp+simd+crc > .file "sha1_1.c" > .text > .align 2 > .p2align 4,,15 > .global foo > .type foo, %function > foo: > add w0, w0, 5 > ret > .size foo, .-foo > .ident "GCC: (fsf-trunk.670) 6.0.0 20150416 (experimental)" > > Consequently, TARGET_ASM_FILE_START is deleted. > > > Bootstrapped and tested on aarch64. > Ok for trunk? > > Thanks, > Kyrill > > 2015-07-16 Kyrylo Tkachov > > * config/aarch64/aarch64.opt (explicit_tune_core): New TargetVariable. > (explicit_arch): Likewise. > (x_aarch64_isa_flags): Likewise. > (mgeneral-regs-only): Mark as Save. > (mfix-cortex-a53-835769): Likewise. > (mcmodel=): Likewise. > (mstrict-align): Likewise. > (momit-leaf-frame-pointer): Likewise. > (mtls-dialect): Likewise. > (master=): Likewise. > * config/aarch64/aarch64.h (ASM_DECLARE_FUNCTION_NAME): Define. > (aarch64_isa_flags): Remove extern declaration. > * config/aarch64/aarch64.c (aarch64_validate_mcpu): Return a bool > to indicate success or failure. > (aarch64_validate_march): Likewise. > (aarch64_validate_mtune): Likewise. > (aarch64_isa_flags): Delete. > (aarch64_override_options_internal): Access opts->x_aarch64_isa_flags > instead of aarch64_isa_flags. > (aarch64_get_tune_cpu): New function. > (aarch64_get_arch): Likewise. > (aarch64_override_options): Use above and set up explicit_tune_core > and explicit_arch. > (aarch64_print_extension): Move earlier in file. Add isa_flags > argument and use that instead of the global aarch64_isa_flags. > (aarch64_option_restore): Likewise. > (aarch64_option_print): Likewise. > (aarch64_declare_function_name): Likewise. > (aarch64_start_file): Delete. > (TARGET_ASM_FILE_START): Do not define. > (TARGET_OPTION_RESTORE, TARGET_OPTION_PRINT): Define. > * config/aarch64/aarch64-protos.h (aarch64_declare_function_name): > Declare prototype.