diff mbox series

[v2,11/11] aarch64: Extend aarch64_feature_flags to 128 bits

Message ID b5532218-fa29-7aa3-3c75-5a4cf8afa266@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:16 p.m. UTC
Replace the existing uint64_t typedef with a bbitmap<2> typedef.  Most
of the preparatory work was carried out in previous commits, so this
patch itself is fairly small.

gcc/ChangeLog:

	* common/config/aarch64/aarch64-common.cc
	(aarch64_set_asm_isa_flags): Store a second uint64_t value.
	* config/aarch64/aarch64-opts.h
	(aarch64_feature_flags): Switch typedef to bbitmap<2>.
	* config/aarch64/aarch64.cc
	(aarch64_set_current_function): Extract isa mode from val[0].
	* config/aarch64/aarch64.h
	(aarch64_get_asm_isa_flags): Load a second uint64_t value.
	(aarch64_get_isa_flags): Ditto.
	(aarch64_asm_isa_flags): Ditto.
	(aarch64_isa_flags): Ditto.
	(HANDLE): Use bbitmap<2>::from_index to initialise flags.
	(AARCH64_FL_ISA_MODES): Do arithmetic on integer type.
	(AARCH64_ISA_MODE): Extract value from bbitmap<2> array.
	* config/aarch64/aarch64.opt
	(aarch64_asm_isa_flags_1): New variable.
	(aarch64_isa_flags_1): Ditto.

Comments

Richard Sandiford July 11, 2024, 5:09 p.m. UTC | #1
Andrew Carlotti <andrew.carlotti@arm.com> writes:
> Replace the existing uint64_t typedef with a bbitmap<2> typedef.  Most
> of the preparatory work was carried out in previous commits, so this
> patch itself is fairly small.
>
> gcc/ChangeLog:
>
> 	* common/config/aarch64/aarch64-common.cc
> 	(aarch64_set_asm_isa_flags): Store a second uint64_t value.
> 	* config/aarch64/aarch64-opts.h
> 	(aarch64_feature_flags): Switch typedef to bbitmap<2>.
> 	* config/aarch64/aarch64.cc
> 	(aarch64_set_current_function): Extract isa mode from val[0].
> 	* config/aarch64/aarch64.h
> 	(aarch64_get_asm_isa_flags): Load a second uint64_t value.
> 	(aarch64_get_isa_flags): Ditto.
> 	(aarch64_asm_isa_flags): Ditto.
> 	(aarch64_isa_flags): Ditto.
> 	(HANDLE): Use bbitmap<2>::from_index to initialise flags.
> 	(AARCH64_FL_ISA_MODES): Do arithmetic on integer type.
> 	(AARCH64_ISA_MODE): Extract value from bbitmap<2> array.
> 	* config/aarch64/aarch64.opt
> 	(aarch64_asm_isa_flags_1): New variable.
> 	(aarch64_isa_flags_1): Ditto.

OK, thanks.  It might be nice to avoid the direct access of .val[0],
but I don't have a concrete suggestion yet, and it's not worth holding
the series up over.

Richard

> diff --git a/gcc/common/config/aarch64/aarch64-common.cc b/gcc/common/config/aarch64/aarch64-common.cc
> index bd0770dd0d84005701afed35d4af356380a405e9..64b65b7ff9e4bf7c72bf0c5db6fa976a51fe9f32 100644
> --- a/gcc/common/config/aarch64/aarch64-common.cc
> +++ b/gcc/common/config/aarch64/aarch64-common.cc
> @@ -67,15 +67,19 @@ static const struct default_options aarch_option_optimization_table[] =
>    };
>  
>  
> -/* Set OPTS->x_aarch64_asm_isa_flags_0 to FLAGS and update
> -   OPTS->x_aarch64_isa_flags_0 accordingly.  */
> +/* Set OPTS->x_aarch64_asm_isa_flags_<0..n> to FLAGS and update
> +   OPTS->x_aarch64_isa_flags_<0..n> accordingly.  */
>  void
>  aarch64_set_asm_isa_flags (gcc_options *opts, aarch64_feature_flags flags)
>  {
> -  opts->x_aarch64_asm_isa_flags_0 = flags;
> +  opts->x_aarch64_asm_isa_flags_0 = flags.val[0];
> +  opts->x_aarch64_asm_isa_flags_1 = flags.val[1];
> +
>    if (opts->x_target_flags & MASK_GENERAL_REGS_ONLY)
>      flags &= ~feature_deps::get_flags_off (AARCH64_FL_FP);
> -  opts->x_aarch64_isa_flags_0 = flags;
> +
> +  opts->x_aarch64_isa_flags_0 = flags.val[0];
> +  opts->x_aarch64_isa_flags_1 = flags.val[1];
>  }
>  
>  /* Implement TARGET_HANDLE_OPTION.
> diff --git a/gcc/config/aarch64/aarch64-opts.h b/gcc/config/aarch64/aarch64-opts.h
> index 2c36bfaad19b999238601d44709c280ef987046b..80ec1a05253da62b20eebb5e491f04c6da6851e7 100644
> --- a/gcc/config/aarch64/aarch64-opts.h
> +++ b/gcc/config/aarch64/aarch64-opts.h
> @@ -23,14 +23,16 @@
>  #define GCC_AARCH64_OPTS_H
>  
>  #ifndef USED_FOR_TARGET
> -typedef uint64_t aarch64_isa_mode;
> +#include "bbitmap.h"
>  
> -typedef uint64_t aarch64_feature_flags;
> +typedef uint64_t aarch64_isa_mode;
>  
>  constexpr unsigned int AARCH64_NUM_ISA_MODES = (0
>  #define DEF_AARCH64_ISA_MODE(IDENT) + 1
>  #include "aarch64-isa-modes.def"
>  );
> +
> +typedef bbitmap<2> aarch64_feature_flags;
>  #endif
>  
>  /* The various cores that implement AArch64.  */
> diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
> index 902de6bd269d7111186d58248d1d2e1614217fa2..8056c33795738b779bc14697803da3eee04fe330 100644
> --- a/gcc/config/aarch64/aarch64.h
> +++ b/gcc/config/aarch64/aarch64.h
> @@ -23,17 +23,21 @@
>  #define GCC_AARCH64_H
>  
>  #define aarch64_get_asm_isa_flags(opts) \
> -  (aarch64_feature_flags ((opts)->x_aarch64_asm_isa_flags_0))
> +  (aarch64_feature_flags ((opts)->x_aarch64_asm_isa_flags_0, \
> +			  (opts)->x_aarch64_asm_isa_flags_1))
>  #define aarch64_get_isa_flags(opts) \
> -  (aarch64_feature_flags ((opts)->x_aarch64_isa_flags_0))
> +  (aarch64_feature_flags ((opts)->x_aarch64_isa_flags_0, \
> +			  (opts)->x_aarch64_isa_flags_1))
>  
>  /* Make these flags read-only so that all uses go via
>     aarch64_set_asm_isa_flags.  */
>  #ifdef GENERATOR_FILE
>  #undef aarch64_asm_isa_flags
> -#define aarch64_asm_isa_flags (aarch64_feature_flags (aarch64_asm_isa_flags_0))
> +#define aarch64_asm_isa_flags (aarch64_feature_flags (aarch64_asm_isa_flags_0,\
> +						      aarch64_asm_isa_flags_1))
>  #undef aarch64_isa_flags
> -#define aarch64_isa_flags (aarch64_feature_flags (aarch64_isa_flags_0))
> +#define aarch64_isa_flags (aarch64_feature_flags (aarch64_isa_flags_0, \
> +						  aarch64_isa_flags_1))
>  #else
>  #undef aarch64_asm_isa_flags
>  #define aarch64_asm_isa_flags (aarch64_get_asm_isa_flags (&global_options))
> @@ -167,8 +171,8 @@ enum class aarch64_feature : unsigned char {
>  
>  /* Define unique flags for each of the above.  */
>  #define HANDLE(IDENT) \
> -  constexpr auto AARCH64_FL_##IDENT \
> -    = aarch64_feature_flags (1) << int (aarch64_feature::IDENT);
> +  constexpr auto AARCH64_FL_##IDENT ATTRIBUTE_UNUSED \
> +    = aarch64_feature_flags::from_index (int (aarch64_feature::IDENT));
>  #define DEF_AARCH64_ISA_MODE(IDENT) HANDLE (IDENT)
>  #define AARCH64_OPT_EXTENSION(A, IDENT, C, D, E, F) HANDLE (IDENT)
>  #define AARCH64_ARCH(A, B, IDENT, D, E) HANDLE (IDENT)
> @@ -191,7 +195,7 @@ constexpr auto AARCH64_ISA_MODE_SM_STATE ATTRIBUTE_UNUSED
>  
>  /* The mask of all ISA modes.  */
>  constexpr auto AARCH64_FL_ISA_MODES
> -  = (aarch64_feature_flags (1) << AARCH64_NUM_ISA_MODES) - 1;
> +  = aarch64_feature_flags ((1 << AARCH64_NUM_ISA_MODES) - 1);
>  
>  /* The default ISA mode, for functions with no attributes that specify
>     something to the contrary.  */
> @@ -210,7 +214,7 @@ constexpr auto AARCH64_FL_DEFAULT_ISA_MODE ATTRIBUTE_UNUSED
>  
>  #define AARCH64_HAVE_ISA(X) (bool (aarch64_isa_flags & AARCH64_FL_##X))
>  
> -#define AARCH64_ISA_MODE           (aarch64_isa_mode) (aarch64_isa_flags & AARCH64_FL_ISA_MODES)
> +#define AARCH64_ISA_MODE    ((aarch64_isa_flags & AARCH64_FL_ISA_MODES).val[0])
>  
>  /* The current function is a normal non-streaming function.  */
>  #define TARGET_NON_STREAMING AARCH64_HAVE_ISA (SM_OFF)
> diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
> index 229e438115c268f876c6d77e1fcc4faa2f7d231b..0d9e80d85b207e547d114e215096238eb17cc8bf 100644
> --- a/gcc/config/aarch64/aarch64.cc
> +++ b/gcc/config/aarch64/aarch64.cc
> @@ -19121,7 +19121,7 @@ aarch64_set_current_function (tree fndecl)
>       aarch64_pragma_target_parse.  */
>    if (old_tree == new_tree
>        && (!fndecl || aarch64_previous_fndecl)
> -      && (aarch64_isa_mode) (isa_flags & AARCH64_FL_ISA_MODES) == new_isa_mode)
> +      && (isa_flags & AARCH64_FL_ISA_MODES).val[0] == new_isa_mode)
>      {
>        gcc_assert (AARCH64_ISA_MODE == new_isa_mode);
>        return;
> @@ -19136,11 +19136,11 @@ aarch64_set_current_function (tree fndecl)
>    /* The ISA mode can vary based on function type attributes and
>       function declaration attributes.  Make sure that the target
>       options correctly reflect these attributes.  */
> -  if ((aarch64_isa_mode) (isa_flags & AARCH64_FL_ISA_MODES) != new_isa_mode)
> +  if ((isa_flags & AARCH64_FL_ISA_MODES).val[0] != new_isa_mode)
>      {
>        auto base_flags = (aarch64_asm_isa_flags & ~AARCH64_FL_ISA_MODES);
>        aarch64_set_asm_isa_flags (base_flags
> -				 | (aarch64_feature_flags) new_isa_mode);
> +				 | aarch64_feature_flags (new_isa_mode));
>  
>        aarch64_override_options_internal (&global_options);
>        new_tree = build_target_option_node (&global_options,
> diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
> index 45aab49de27bdfa0fb3f67ec06c7dcf0ac242fb3..2f90f10352af75f70112d07894ab200f48b143f4 100644
> --- a/gcc/config/aarch64/aarch64.opt
> +++ b/gcc/config/aarch64/aarch64.opt
> @@ -33,9 +33,15 @@ enum aarch64_arch selected_arch = aarch64_no_arch
>  TargetVariable
>  uint64_t aarch64_asm_isa_flags_0 = 0
>  
> +TargetVariable
> +uint64_t aarch64_asm_isa_flags_1 = 0
> +
>  TargetVariable
>  uint64_t aarch64_isa_flags_0 = 0
>  
> +TargetVariable
> +uint64_t aarch64_isa_flags_1 = 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 bd0770dd0d84005701afed35d4af356380a405e9..64b65b7ff9e4bf7c72bf0c5db6fa976a51fe9f32 100644
--- a/gcc/common/config/aarch64/aarch64-common.cc
+++ b/gcc/common/config/aarch64/aarch64-common.cc
@@ -67,15 +67,19 @@  static const struct default_options aarch_option_optimization_table[] =
   };
 
 
-/* Set OPTS->x_aarch64_asm_isa_flags_0 to FLAGS and update
-   OPTS->x_aarch64_isa_flags_0 accordingly.  */
+/* Set OPTS->x_aarch64_asm_isa_flags_<0..n> to FLAGS and update
+   OPTS->x_aarch64_isa_flags_<0..n> accordingly.  */
 void
 aarch64_set_asm_isa_flags (gcc_options *opts, aarch64_feature_flags flags)
 {
-  opts->x_aarch64_asm_isa_flags_0 = flags;
+  opts->x_aarch64_asm_isa_flags_0 = flags.val[0];
+  opts->x_aarch64_asm_isa_flags_1 = flags.val[1];
+
   if (opts->x_target_flags & MASK_GENERAL_REGS_ONLY)
     flags &= ~feature_deps::get_flags_off (AARCH64_FL_FP);
-  opts->x_aarch64_isa_flags_0 = flags;
+
+  opts->x_aarch64_isa_flags_0 = flags.val[0];
+  opts->x_aarch64_isa_flags_1 = flags.val[1];
 }
 
 /* Implement TARGET_HANDLE_OPTION.
diff --git a/gcc/config/aarch64/aarch64-opts.h b/gcc/config/aarch64/aarch64-opts.h
index 2c36bfaad19b999238601d44709c280ef987046b..80ec1a05253da62b20eebb5e491f04c6da6851e7 100644
--- a/gcc/config/aarch64/aarch64-opts.h
+++ b/gcc/config/aarch64/aarch64-opts.h
@@ -23,14 +23,16 @@ 
 #define GCC_AARCH64_OPTS_H
 
 #ifndef USED_FOR_TARGET
-typedef uint64_t aarch64_isa_mode;
+#include "bbitmap.h"
 
-typedef uint64_t aarch64_feature_flags;
+typedef uint64_t aarch64_isa_mode;
 
 constexpr unsigned int AARCH64_NUM_ISA_MODES = (0
 #define DEF_AARCH64_ISA_MODE(IDENT) + 1
 #include "aarch64-isa-modes.def"
 );
+
+typedef bbitmap<2> aarch64_feature_flags;
 #endif
 
 /* The various cores that implement AArch64.  */
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index 902de6bd269d7111186d58248d1d2e1614217fa2..8056c33795738b779bc14697803da3eee04fe330 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -23,17 +23,21 @@ 
 #define GCC_AARCH64_H
 
 #define aarch64_get_asm_isa_flags(opts) \
-  (aarch64_feature_flags ((opts)->x_aarch64_asm_isa_flags_0))
+  (aarch64_feature_flags ((opts)->x_aarch64_asm_isa_flags_0, \
+			  (opts)->x_aarch64_asm_isa_flags_1))
 #define aarch64_get_isa_flags(opts) \
-  (aarch64_feature_flags ((opts)->x_aarch64_isa_flags_0))
+  (aarch64_feature_flags ((opts)->x_aarch64_isa_flags_0, \
+			  (opts)->x_aarch64_isa_flags_1))
 
 /* Make these flags read-only so that all uses go via
    aarch64_set_asm_isa_flags.  */
 #ifdef GENERATOR_FILE
 #undef aarch64_asm_isa_flags
-#define aarch64_asm_isa_flags (aarch64_feature_flags (aarch64_asm_isa_flags_0))
+#define aarch64_asm_isa_flags (aarch64_feature_flags (aarch64_asm_isa_flags_0,\
+						      aarch64_asm_isa_flags_1))
 #undef aarch64_isa_flags
-#define aarch64_isa_flags (aarch64_feature_flags (aarch64_isa_flags_0))
+#define aarch64_isa_flags (aarch64_feature_flags (aarch64_isa_flags_0, \
+						  aarch64_isa_flags_1))
 #else
 #undef aarch64_asm_isa_flags
 #define aarch64_asm_isa_flags (aarch64_get_asm_isa_flags (&global_options))
@@ -167,8 +171,8 @@  enum class aarch64_feature : unsigned char {
 
 /* Define unique flags for each of the above.  */
 #define HANDLE(IDENT) \
-  constexpr auto AARCH64_FL_##IDENT \
-    = aarch64_feature_flags (1) << int (aarch64_feature::IDENT);
+  constexpr auto AARCH64_FL_##IDENT ATTRIBUTE_UNUSED \
+    = aarch64_feature_flags::from_index (int (aarch64_feature::IDENT));
 #define DEF_AARCH64_ISA_MODE(IDENT) HANDLE (IDENT)
 #define AARCH64_OPT_EXTENSION(A, IDENT, C, D, E, F) HANDLE (IDENT)
 #define AARCH64_ARCH(A, B, IDENT, D, E) HANDLE (IDENT)
@@ -191,7 +195,7 @@  constexpr auto AARCH64_ISA_MODE_SM_STATE ATTRIBUTE_UNUSED
 
 /* The mask of all ISA modes.  */
 constexpr auto AARCH64_FL_ISA_MODES
-  = (aarch64_feature_flags (1) << AARCH64_NUM_ISA_MODES) - 1;
+  = aarch64_feature_flags ((1 << AARCH64_NUM_ISA_MODES) - 1);
 
 /* The default ISA mode, for functions with no attributes that specify
    something to the contrary.  */
@@ -210,7 +214,7 @@  constexpr auto AARCH64_FL_DEFAULT_ISA_MODE ATTRIBUTE_UNUSED
 
 #define AARCH64_HAVE_ISA(X) (bool (aarch64_isa_flags & AARCH64_FL_##X))
 
-#define AARCH64_ISA_MODE           (aarch64_isa_mode) (aarch64_isa_flags & AARCH64_FL_ISA_MODES)
+#define AARCH64_ISA_MODE    ((aarch64_isa_flags & AARCH64_FL_ISA_MODES).val[0])
 
 /* The current function is a normal non-streaming function.  */
 #define TARGET_NON_STREAMING AARCH64_HAVE_ISA (SM_OFF)
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 229e438115c268f876c6d77e1fcc4faa2f7d231b..0d9e80d85b207e547d114e215096238eb17cc8bf 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -19121,7 +19121,7 @@  aarch64_set_current_function (tree fndecl)
      aarch64_pragma_target_parse.  */
   if (old_tree == new_tree
       && (!fndecl || aarch64_previous_fndecl)
-      && (aarch64_isa_mode) (isa_flags & AARCH64_FL_ISA_MODES) == new_isa_mode)
+      && (isa_flags & AARCH64_FL_ISA_MODES).val[0] == new_isa_mode)
     {
       gcc_assert (AARCH64_ISA_MODE == new_isa_mode);
       return;
@@ -19136,11 +19136,11 @@  aarch64_set_current_function (tree fndecl)
   /* The ISA mode can vary based on function type attributes and
      function declaration attributes.  Make sure that the target
      options correctly reflect these attributes.  */
-  if ((aarch64_isa_mode) (isa_flags & AARCH64_FL_ISA_MODES) != new_isa_mode)
+  if ((isa_flags & AARCH64_FL_ISA_MODES).val[0] != new_isa_mode)
     {
       auto base_flags = (aarch64_asm_isa_flags & ~AARCH64_FL_ISA_MODES);
       aarch64_set_asm_isa_flags (base_flags
-				 | (aarch64_feature_flags) new_isa_mode);
+				 | aarch64_feature_flags (new_isa_mode));
 
       aarch64_override_options_internal (&global_options);
       new_tree = build_target_option_node (&global_options,
diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
index 45aab49de27bdfa0fb3f67ec06c7dcf0ac242fb3..2f90f10352af75f70112d07894ab200f48b143f4 100644
--- a/gcc/config/aarch64/aarch64.opt
+++ b/gcc/config/aarch64/aarch64.opt
@@ -33,9 +33,15 @@  enum aarch64_arch selected_arch = aarch64_no_arch
 TargetVariable
 uint64_t aarch64_asm_isa_flags_0 = 0
 
+TargetVariable
+uint64_t aarch64_asm_isa_flags_1 = 0
+
 TargetVariable
 uint64_t aarch64_isa_flags_0 = 0
 
+TargetVariable
+uint64_t aarch64_isa_flags_1 = 0
+
 TargetVariable
 unsigned aarch_enable_bti = 2