Re: [PATCH] AArch64: Cleanup option processing code

2022-05-26 Thread Richard Sandiford via Gcc-patches
Wilco Dijkstra  writes:
> Further cleanup option processing. Remove the duplication of global
> variables for CPU and tune settings so that CPU option processing is
> simplified even further. Move global variables that need save and
> restore due to target option processing into aarch64.opt. This removes
> the need for explicit saving/restoring and unnecessary reparsing of
> options.
>
> Bootstrap OK, regress pass, OK for commit?

OK, thanks.

It looks like this makes the AARCH64_ARCH ARCH_REV parameter redundant,
is that right?

Richard

> gcc/
> * config/aarch64/aarch64.opt (explicit_tune_core): Rename to
> selected_tune.
> (explicit_arch): Rename to selected_arch.
> (x_aarch64_override_tune_string): Remove.
> (aarch64_ra_sign_key): Add as TargetVariable so it gets 
> saved/restored.
> (aarch64_override_tune_string): Add Save so it gets saved/restored.
> * config/aarch64/aarch64.h (aarch64_architecture_version): Remove.
> * config/aarch64/aarch64.cc (aarch64_architecture_version): Remove.
> (processor): Remove archtecture_version field.
> (selected_arch): Remove global.
> (selected_cpu): Remove global.
> (selected_tune): Remove global.
> (aarch64_ra_sign_key): Move global to aarch64.opt so it is saved.
> (aarch64_override_options_internal): Use aarch64_get_tune_cpu.
> (aarch64_override_options): Further simplify code to only set
> selected_arch and selected_tune globals.
> (aarch64_option_save): Remove now that target options are saved.
> (aarch64_option_restore): Remove redundant target option restores.
> * config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins): Use
> AARCH64_ISA_V9.
> * config/aarch64/aarch64-opts.h (aarch64_key_type): Add, moved from...
> * config/aarch64/aarch64-protos.h (aarch64_key_type): Remove.
> (aarch64_ra_sign_key): Remove.
>
> ---
>
> diff --git a/gcc/config/aarch64/aarch64-c.cc b/gcc/config/aarch64/aarch64-c.cc
> index 
> 767ee0c763c56a022089a647c7425afb00644644..3d2fb5ec2ef33e66aaa59d216c53a29737262794
>  100644
> --- a/gcc/config/aarch64/aarch64-c.cc
> +++ b/gcc/config/aarch64/aarch64-c.cc
> @@ -82,7 +82,7 @@ aarch64_update_cpp_builtins (cpp_reader *pfile)
>  {
>aarch64_def_or_undef (flag_unsafe_math_optimizations, "__ARM_FP_FAST", 
> pfile);
>
> -  builtin_define_with_int_value ("__ARM_ARCH", aarch64_architecture_version);
> +  builtin_define_with_int_value ("__ARM_ARCH", AARCH64_ISA_V9 ? 9 : 8);
>
>builtin_define_with_int_value ("__ARM_SIZEOF_MINIMAL_ENUM",
>  flag_short_enums ? 1 : 4);
> diff --git a/gcc/config/aarch64/aarch64-opts.h 
> b/gcc/config/aarch64/aarch64-opts.h
> index 
> 93572fe8330218568435f485a366101eb2c58da9..421648a156a02cc1f43660eddc5de38c2f366a72
>  100644
> --- a/gcc/config/aarch64/aarch64-opts.h
> +++ b/gcc/config/aarch64/aarch64-opts.h
> @@ -98,4 +98,10 @@ enum stack_protector_guard {
>SSP_GLOBAL   /* global canary */
>  };
>
> +/* The key type that -msign-return-address should use.  */
> +enum aarch64_key_type {
> +  AARCH64_KEY_A,
> +  AARCH64_KEY_B
> +};
> +
>  #endif
> diff --git a/gcc/config/aarch64/aarch64-protos.h 
> b/gcc/config/aarch64/aarch64-protos.h
> index 
> df311812e8d4b87c0ad8692adacedcd79a8e0f64..dabd047d7ba2c532238720d59ecd59f0f5ba822f
>  100644
> --- a/gcc/config/aarch64/aarch64-protos.h
> +++ b/gcc/config/aarch64/aarch64-protos.h
> @@ -672,14 +672,6 @@ enum simd_immediate_check {
>AARCH64_CHECK_MOV  = AARCH64_CHECK_ORR | AARCH64_CHECK_BIC
>  };
>
> -/* The key type that -msign-return-address should use.  */
> -enum aarch64_key_type {
> -  AARCH64_KEY_A,
> -  AARCH64_KEY_B
> -};
> -
> -extern enum aarch64_key_type aarch64_ra_sign_key;
> -
>  extern struct tune_params aarch64_tune_params;
>
>  /* The available SVE predicate patterns, known in the ACLE as "svpattern".  
> */
> diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
> index 
> f835da33b72f36bbf25a0e1328135411bd8ab4f6..80cfe4b740798072ed2a3d08089ff889943f916a
>  100644
> --- a/gcc/config/aarch64/aarch64.h
> +++ b/gcc/config/aarch64/aarch64.h
> @@ -148,9 +148,6 @@
>
>  #define PCC_BITFIELD_TYPE_MATTERS  1
>
> -/* Major revision number of the ARM Architecture implemented by the target.  
> */
> -extern unsigned aarch64_architecture_version;
> -
>  /* Instruction tuning/selection flags.  */
>
>  /* Bit values used to identify processor capabilities.  */
> diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
> index 
> 060c67a93b95b717563ed063509e3e31c978d891..6bdfd55bcd6308c71fb6cfccb5922b71830c7c4f
>  100644
> --- a/gcc/config/aarch64/aarch64.cc
> +++ b/gcc/config/aarch64/aarch64.cc
> @@ -306,9 +306,6 @@ static bool aarch64_print_address_internal (FILE*, 
> machine_mode, rtx,
> aarch64_addr_query_type);
>  static HOST_WIDE_INT 

[PATCH] AArch64: Cleanup option processing code

2022-05-25 Thread Wilco Dijkstra via Gcc-patches

Further cleanup option processing. Remove the duplication of global
variables for CPU and tune settings so that CPU option processing is
simplified even further. Move global variables that need save and 
restore due to target option processing into aarch64.opt. This removes
the need for explicit saving/restoring and unnecessary reparsing of
options.

Bootstrap OK, regress pass, OK for commit?

gcc/
* config/aarch64/aarch64.opt (explicit_tune_core): Rename to
selected_tune.
(explicit_arch): Rename to selected_arch.
(x_aarch64_override_tune_string): Remove.
(aarch64_ra_sign_key): Add as TargetVariable so it gets saved/restored.
(aarch64_override_tune_string): Add Save so it gets saved/restored.
* config/aarch64/aarch64.h (aarch64_architecture_version): Remove.
* config/aarch64/aarch64.cc (aarch64_architecture_version): Remove.
(processor): Remove archtecture_version field.
(selected_arch): Remove global.
(selected_cpu): Remove global.
(selected_tune): Remove global.
(aarch64_ra_sign_key): Move global to aarch64.opt so it is saved.
(aarch64_override_options_internal): Use aarch64_get_tune_cpu.
(aarch64_override_options): Further simplify code to only set
selected_arch and selected_tune globals.
(aarch64_option_save): Remove now that target options are saved.
(aarch64_option_restore): Remove redundant target option restores.
* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins): Use
AARCH64_ISA_V9.
* config/aarch64/aarch64-opts.h (aarch64_key_type): Add, moved from...
* config/aarch64/aarch64-protos.h (aarch64_key_type): Remove.
(aarch64_ra_sign_key): Remove.

---

diff --git a/gcc/config/aarch64/aarch64-c.cc b/gcc/config/aarch64/aarch64-c.cc
index 
767ee0c763c56a022089a647c7425afb00644644..3d2fb5ec2ef33e66aaa59d216c53a29737262794
 100644
--- a/gcc/config/aarch64/aarch64-c.cc
+++ b/gcc/config/aarch64/aarch64-c.cc
@@ -82,7 +82,7 @@ aarch64_update_cpp_builtins (cpp_reader *pfile)
 {
   aarch64_def_or_undef (flag_unsafe_math_optimizations, "__ARM_FP_FAST", 
pfile);
 
-  builtin_define_with_int_value ("__ARM_ARCH", aarch64_architecture_version);
+  builtin_define_with_int_value ("__ARM_ARCH", AARCH64_ISA_V9 ? 9 : 8);
 
   builtin_define_with_int_value ("__ARM_SIZEOF_MINIMAL_ENUM",
 flag_short_enums ? 1 : 4);
diff --git a/gcc/config/aarch64/aarch64-opts.h 
b/gcc/config/aarch64/aarch64-opts.h
index 
93572fe8330218568435f485a366101eb2c58da9..421648a156a02cc1f43660eddc5de38c2f366a72
 100644
--- a/gcc/config/aarch64/aarch64-opts.h
+++ b/gcc/config/aarch64/aarch64-opts.h
@@ -98,4 +98,10 @@ enum stack_protector_guard {
   SSP_GLOBAL   /* global canary */
 };
 
+/* The key type that -msign-return-address should use.  */
+enum aarch64_key_type {
+  AARCH64_KEY_A,
+  AARCH64_KEY_B
+};
+
 #endif
diff --git a/gcc/config/aarch64/aarch64-protos.h 
b/gcc/config/aarch64/aarch64-protos.h
index 
df311812e8d4b87c0ad8692adacedcd79a8e0f64..dabd047d7ba2c532238720d59ecd59f0f5ba822f
 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -672,14 +672,6 @@ enum simd_immediate_check {
   AARCH64_CHECK_MOV  = AARCH64_CHECK_ORR | AARCH64_CHECK_BIC
 };
 
-/* The key type that -msign-return-address should use.  */
-enum aarch64_key_type {
-  AARCH64_KEY_A,
-  AARCH64_KEY_B
-};
-
-extern enum aarch64_key_type aarch64_ra_sign_key;
-
 extern struct tune_params aarch64_tune_params;
 
 /* The available SVE predicate patterns, known in the ACLE as "svpattern".  */
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index 
f835da33b72f36bbf25a0e1328135411bd8ab4f6..80cfe4b740798072ed2a3d08089ff889943f916a
 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -148,9 +148,6 @@
 
 #define PCC_BITFIELD_TYPE_MATTERS  1
 
-/* Major revision number of the ARM Architecture implemented by the target.  */
-extern unsigned aarch64_architecture_version;
-
 /* Instruction tuning/selection flags.  */
 
 /* Bit values used to identify processor capabilities.  */
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 
060c67a93b95b717563ed063509e3e31c978d891..6bdfd55bcd6308c71fb6cfccb5922b71830c7c4f
 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -306,9 +306,6 @@ static bool aarch64_print_address_internal (FILE*, 
machine_mode, rtx,
aarch64_addr_query_type);
 static HOST_WIDE_INT aarch64_clamp_to_uimm12_shift (HOST_WIDE_INT val);
 
-/* Major revision number of the ARM Architecture implemented by the target.  */
-unsigned aarch64_architecture_version;
-
 /* The processor for which instructions should be scheduled.  */
 enum aarch64_processor aarch64_tune = cortexa53;
 
@@ -2677,7 +2674,6 @@ struct processor
   enum aarch64_processor ident;