diff mbox series

[v2,06/11] aarch64: Decouple feature flag option storage type

Message ID d36888a3-826c-0756-a6b0-7f46e64f0aa7@e124511.cambridge.arm.com
State New
Headers show
Series aarch64: Extend aarch64_feature_flags to 128 bits | expand

Commit Message

Andrew Carlotti July 11, 2024, 12:14 p.m. UTC
The awk scripts that process the .opt files are relatively fragile and
only handle a limited set of data types correctly.  The unrecognised
aarch64_feature_flags type is handled as a uint64_t, which happens to be
correct for now.  However, that assumption will change when we extend
the mask to 128 bits.

This patch changes the option members to use uint64_t types, and adds a
"_0" suffix to the names (both for future extensibility, and to allow
the original name to be used for the full aarch64_feature_flags mask
within generator files).

gcc/ChangeLog:

	* common/config/aarch64/aarch64-common.cc
	(aarch64_set_asm_isa_flags): Reorder, and add suffix to names.
	* config/aarch64/aarch64.h
	(aarch64_get_asm_isa_flags): Add "_0" suffix.
	(aarch64_get_isa_flags): Ditto.
	(aarch64_asm_isa_flags): Redefine using renamed uint64_t value.
	(aarch64_isa_flags): Ditto.
	* config/aarch64/aarch64.opt:
	(aarch64_asm_isa_flags): Rename to...
	(aarch64_asm_isa_flags_0): ...this, and change to uint64_t.
	(aarch64_isa_flags): Rename to...
	(aarch64_isa_flags_0): ...this, and change to uint64_t.

Comments

Richard Sandiford July 11, 2024, 5:16 p.m. UTC | #1
Andrew Carlotti <andrew.carlotti@arm.com> writes:
> The awk scripts that process the .opt files are relatively fragile and
> only handle a limited set of data types correctly.  The unrecognised
> aarch64_feature_flags type is handled as a uint64_t, which happens to be
> correct for now.  However, that assumption will change when we extend
> the mask to 128 bits.
>
> This patch changes the option members to use uint64_t types, and adds a
> "_0" suffix to the names (both for future extensibility, and to allow
> the original name to be used for the full aarch64_feature_flags mask
> within generator files).
>
> gcc/ChangeLog:
>
> 	* common/config/aarch64/aarch64-common.cc
> 	(aarch64_set_asm_isa_flags): Reorder, and add suffix to names.
> 	* config/aarch64/aarch64.h
> 	(aarch64_get_asm_isa_flags): Add "_0" suffix.
> 	(aarch64_get_isa_flags): Ditto.
> 	(aarch64_asm_isa_flags): Redefine using renamed uint64_t value.
> 	(aarch64_isa_flags): Ditto.
> 	* config/aarch64/aarch64.opt:
> 	(aarch64_asm_isa_flags): Rename to...
> 	(aarch64_asm_isa_flags_0): ...this, and change to uint64_t.
> 	(aarch64_isa_flags): Rename to...
> 	(aarch64_isa_flags_0): ...this, and change to uint64_t.

OK, thanks.

Richard

> diff --git a/gcc/common/config/aarch64/aarch64-common.cc b/gcc/common/config/aarch64/aarch64-common.cc
> index 63c50189a09d5c7c713f57e23a8172f44bf6bec5..bd0770dd0d84005701afed35d4af356380a405e9 100644
> --- a/gcc/common/config/aarch64/aarch64-common.cc
> +++ b/gcc/common/config/aarch64/aarch64-common.cc
> @@ -66,15 +66,16 @@ static const struct default_options aarch_option_optimization_table[] =
>      { OPT_LEVELS_NONE, 0, NULL, 0 }
>    };
>  
> -/* Set OPTS->x_aarch64_asm_isa_flags to FLAGS and update
> -   OPTS->x_aarch64_isa_flags accordingly.  */
> +
> +/* Set OPTS->x_aarch64_asm_isa_flags_0 to FLAGS and update
> +   OPTS->x_aarch64_isa_flags_0 accordingly.  */
>  void
>  aarch64_set_asm_isa_flags (gcc_options *opts, aarch64_feature_flags flags)
>  {
> -  opts->x_aarch64_asm_isa_flags = flags;
> -  opts->x_aarch64_isa_flags = flags;
> +  opts->x_aarch64_asm_isa_flags_0 = flags;
>    if (opts->x_target_flags & MASK_GENERAL_REGS_ONLY)
> -    opts->x_aarch64_isa_flags &= ~feature_deps::get_flags_off (AARCH64_FL_FP);
> +    flags &= ~feature_deps::get_flags_off (AARCH64_FL_FP);
> +  opts->x_aarch64_isa_flags_0 = flags;
>  }
>  
>  /* Implement TARGET_HANDLE_OPTION.
> diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
> index 193f2486176b6bac372a143e2f52041c5a28ebaf..903e708565dc7830e9544813dd315f99d489cad2 100644
> --- a/gcc/config/aarch64/aarch64.h
> +++ b/gcc/config/aarch64/aarch64.h
> @@ -23,13 +23,18 @@
>  #define GCC_AARCH64_H
>  
>  #define aarch64_get_asm_isa_flags(opts) \
> -  (aarch64_feature_flags ((opts)->x_aarch64_asm_isa_flags))
> +  (aarch64_feature_flags ((opts)->x_aarch64_asm_isa_flags_0))
>  #define aarch64_get_isa_flags(opts) \
> -  (aarch64_feature_flags ((opts)->x_aarch64_isa_flags))
> +  (aarch64_feature_flags ((opts)->x_aarch64_isa_flags_0))
>  
>  /* Make these flags read-only so that all uses go via
>     aarch64_set_asm_isa_flags.  */
> -#ifndef GENERATOR_FILE
> +#ifdef GENERATOR_FILE
> +#undef aarch64_asm_isa_flags
> +#define aarch64_asm_isa_flags (aarch64_feature_flags (aarch64_asm_isa_flags_0))
> +#undef aarch64_isa_flags
> +#define aarch64_isa_flags (aarch64_feature_flags (aarch64_isa_flags_0))
> +#else
>  #undef aarch64_asm_isa_flags
>  #define aarch64_asm_isa_flags (aarch64_get_asm_isa_flags (&global_options))
>  #undef aarch64_isa_flags
> diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
> index 6356c419399bd324929cd599e5a4b926b0383469..45aab49de27bdfa0fb3f67ec06c7dcf0ac242fb3 100644
> --- a/gcc/config/aarch64/aarch64.opt
> +++ b/gcc/config/aarch64/aarch64.opt
> @@ -31,10 +31,10 @@ TargetVariable
>  enum aarch64_arch selected_arch = aarch64_no_arch
>  
>  TargetVariable
> -aarch64_feature_flags aarch64_asm_isa_flags = 0
> +uint64_t aarch64_asm_isa_flags_0 = 0
>  
>  TargetVariable
> -aarch64_feature_flags aarch64_isa_flags = 0
> +uint64_t aarch64_isa_flags_0 = 0
>  
>  TargetVariable
>  unsigned aarch_enable_bti = 2
diff mbox series

Patch

diff --git a/gcc/common/config/aarch64/aarch64-common.cc b/gcc/common/config/aarch64/aarch64-common.cc
index 63c50189a09d5c7c713f57e23a8172f44bf6bec5..bd0770dd0d84005701afed35d4af356380a405e9 100644
--- a/gcc/common/config/aarch64/aarch64-common.cc
+++ b/gcc/common/config/aarch64/aarch64-common.cc
@@ -66,15 +66,16 @@  static const struct default_options aarch_option_optimization_table[] =
     { OPT_LEVELS_NONE, 0, NULL, 0 }
   };
 
-/* Set OPTS->x_aarch64_asm_isa_flags to FLAGS and update
-   OPTS->x_aarch64_isa_flags accordingly.  */
+
+/* Set OPTS->x_aarch64_asm_isa_flags_0 to FLAGS and update
+   OPTS->x_aarch64_isa_flags_0 accordingly.  */
 void
 aarch64_set_asm_isa_flags (gcc_options *opts, aarch64_feature_flags flags)
 {
-  opts->x_aarch64_asm_isa_flags = flags;
-  opts->x_aarch64_isa_flags = flags;
+  opts->x_aarch64_asm_isa_flags_0 = flags;
   if (opts->x_target_flags & MASK_GENERAL_REGS_ONLY)
-    opts->x_aarch64_isa_flags &= ~feature_deps::get_flags_off (AARCH64_FL_FP);
+    flags &= ~feature_deps::get_flags_off (AARCH64_FL_FP);
+  opts->x_aarch64_isa_flags_0 = flags;
 }
 
 /* Implement TARGET_HANDLE_OPTION.
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index 193f2486176b6bac372a143e2f52041c5a28ebaf..903e708565dc7830e9544813dd315f99d489cad2 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -23,13 +23,18 @@ 
 #define GCC_AARCH64_H
 
 #define aarch64_get_asm_isa_flags(opts) \
-  (aarch64_feature_flags ((opts)->x_aarch64_asm_isa_flags))
+  (aarch64_feature_flags ((opts)->x_aarch64_asm_isa_flags_0))
 #define aarch64_get_isa_flags(opts) \
-  (aarch64_feature_flags ((opts)->x_aarch64_isa_flags))
+  (aarch64_feature_flags ((opts)->x_aarch64_isa_flags_0))
 
 /* Make these flags read-only so that all uses go via
    aarch64_set_asm_isa_flags.  */
-#ifndef GENERATOR_FILE
+#ifdef GENERATOR_FILE
+#undef aarch64_asm_isa_flags
+#define aarch64_asm_isa_flags (aarch64_feature_flags (aarch64_asm_isa_flags_0))
+#undef aarch64_isa_flags
+#define aarch64_isa_flags (aarch64_feature_flags (aarch64_isa_flags_0))
+#else
 #undef aarch64_asm_isa_flags
 #define aarch64_asm_isa_flags (aarch64_get_asm_isa_flags (&global_options))
 #undef aarch64_isa_flags
diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
index 6356c419399bd324929cd599e5a4b926b0383469..45aab49de27bdfa0fb3f67ec06c7dcf0ac242fb3 100644
--- a/gcc/config/aarch64/aarch64.opt
+++ b/gcc/config/aarch64/aarch64.opt
@@ -31,10 +31,10 @@  TargetVariable
 enum aarch64_arch selected_arch = aarch64_no_arch
 
 TargetVariable
-aarch64_feature_flags aarch64_asm_isa_flags = 0
+uint64_t aarch64_asm_isa_flags_0 = 0
 
 TargetVariable
-aarch64_feature_flags aarch64_isa_flags = 0
+uint64_t aarch64_isa_flags_0 = 0
 
 TargetVariable
 unsigned aarch_enable_bti = 2