public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Carlotti <andrew.carlotti@arm.com>
To: gcc-patches@gcc.gnu.org
Cc: Richard Sandiford <richard.sandiford@arm.com>
Subject: [PATCH 03/12] aarch64: Don't use 0 for aarch64_feature_flags
Date: Tue, 14 May 2024 15:56:05 +0100	[thread overview]
Message-ID: <dce1d13e-f8f5-d397-2f52-12e1f01b9437@e124511.cambridge.arm.com> (raw)
In-Reply-To: <0c99ec88-434d-a9de-0e0e-c281cb2dff4d@e124511.cambridge.arm.com>

Replace all uses of 0 for aarch64_feature_flags variable initialisation
with the (almost) new macro AARCH64_NO_FEATURES.

This is needed because a later commit will disallow casts to
aarch64_feature_flags from integer types.

gcc/ChangeLog:

	* common/config/aarch64/aarch64-common.cc
	(all_extensions): Use AARCH64_NO_FEATURES.
	(all_cores): Ditto.
	(all_architectures): Ditto.
	(aarch64_get_extension_string_for_isa_flags): Ditto.
	* config/aarch64/aarch64-feature-deps.h (get_flags): Ditto.
	(get_enable): Ditto.
	(get_flags_off): Ditto.
	* config/aarch64/aarch64-opts.h (AARCH64_NO_FEATURES): Define.
	* config/aarch64/aarch64-protos.h: Use AARCH64_NO_FEATURES.
	* config/aarch64/aarch64-sve-builtins-sme.def
	(REQUIRED_EXTENSIONS): Ditto.
	* config/aarch64/aarch64-sve-builtins.cc
	(function_groups): Ditto.
	* config/aarch64/aarch64-sve-builtins.h:
	(get_contiguous_base): Ditto.
	(sve_switcher): Ditto.
	* config/aarch64/aarch64.cc (all_architectures): Ditto.
	(all_cores): Ditto.
	(AARCH64_NO_FEATURES): Remove superceded #define and #undef.
	(aarch64_override_options): Use AARCH64_NO_FEATURES.
	(aarch64_process_target_attr): Remove dead initialisation.
	* config/aarch64/driver-aarch64.cc
	(aarch64_cpu_data): Use AARCH64_NO_FEATURES.
	(aarch64_arches): Ditto.
	(host_detect_local_cpu): Ditto.


diff --git a/gcc/common/config/aarch64/aarch64-common.cc b/gcc/common/config/aarch64/aarch64-common.cc
index 951d041d3109b935e90a7cb5d714940414e81761..162b622564ab543cadfc24a7341f1fc476733f45 100644
--- a/gcc/common/config/aarch64/aarch64-common.cc
+++ b/gcc/common/config/aarch64/aarch64-common.cc
@@ -158,7 +158,8 @@ static constexpr aarch64_option_extension all_extensions[] =
   {NAME, AARCH64_FL_##IDENT, feature_deps::IDENT ().explicit_on, \
    feature_deps::get_flags_off (feature_deps::root_off_##IDENT)},
 #include "config/aarch64/aarch64-option-extensions.def"
-  {NULL, 0, 0, 0}
+  {NULL, AARCH64_NO_FEATURES, AARCH64_NO_FEATURES,
+    AARCH64_NO_FEATURES}
 };
 
 struct processor_name_to_arch
@@ -183,7 +184,7 @@ static constexpr processor_name_to_arch all_cores[] =
   {NAME, AARCH64_ARCH_##ARCH_IDENT, feature_deps::cpu_##CORE_IDENT},
 #include "config/aarch64/aarch64-cores.def"
   {"generic", AARCH64_ARCH_V8A, feature_deps::V8A ().enable},
-  {"", aarch64_no_arch, 0}
+  {"", aarch64_no_arch, AARCH64_NO_FEATURES}
 };
 
 /* Map architecture revisions to their string representation.  */
@@ -192,7 +193,7 @@ static constexpr arch_to_arch_name all_architectures[] =
 #define AARCH64_ARCH(NAME, B, ARCH_IDENT, D, E)	\
   {AARCH64_ARCH_##ARCH_IDENT, NAME, feature_deps::ARCH_IDENT ().enable},
 #include "config/aarch64/aarch64-arches.def"
-  {aarch64_no_arch, "", 0}
+  {aarch64_no_arch, "", AARCH64_NO_FEATURES}
 };
 
 /* Parse the architecture extension string STR and update ISA_FLAGS
@@ -299,14 +300,14 @@ aarch64_get_extension_string_for_isa_flags
      However, assemblers with Armv8-R AArch64 support should not have this
      issue, so we don't need this fix when targeting Armv8-R.  */
   auto explicit_flags = (!(current_flags & AARCH64_FL_V8R)
-			 ? AARCH64_FL_CRC : 0);
+			 ? AARCH64_FL_CRC : AARCH64_NO_FEATURES);
 
   /* Add the features in isa_flags & ~current_flags using the smallest
      possible number of extensions.  We can do this by iterating over the
      array in reverse order, since the array is sorted topologically.
      But in order to make the output more readable, it seems better
      to add the strings in definition order.  */
-  aarch64_feature_flags added = 0;
+  aarch64_feature_flags added = AARCH64_NO_FEATURES;
   auto flags_crypto = AARCH64_FL_AES | AARCH64_FL_SHA2;
   for (unsigned int i = ARRAY_SIZE (all_extensions); i-- > 0; )
     {
diff --git a/gcc/config/aarch64/aarch64-feature-deps.h b/gcc/config/aarch64/aarch64-feature-deps.h
index 79126db88254b89f74a8583d50a77bc27865e265..992e133d76935d411ce4cd39480c07ea18c62ddf 100644
--- a/gcc/config/aarch64/aarch64-feature-deps.h
+++ b/gcc/config/aarch64/aarch64-feature-deps.h
@@ -26,7 +26,7 @@ namespace feature_deps {
 /* Together, these definitions of get_flags take a list of
    feature names (representing functions that are defined below)
    and return the set of associated flags.  */
-constexpr aarch64_feature_flags get_flags () { return 0; }
+constexpr aarch64_feature_flags get_flags () { return AARCH64_NO_FEATURES; }
 
 template<typename T1, typename ...Ts>
 constexpr aarch64_feature_flags
@@ -37,7 +37,7 @@ get_flags (T1 i, Ts... args)
 
 /* Like get_flags, but return the transitive closure of those features
    and the ones that they rely on.  */
-constexpr aarch64_feature_flags get_enable () { return 0; }
+constexpr aarch64_feature_flags get_enable () { return AARCH64_NO_FEATURES; }
 
 template<typename T1, typename ...Ts>
 constexpr aarch64_feature_flags
@@ -97,9 +97,10 @@ template<aarch64_feature> struct info;
 constexpr aarch64_feature_flags
 get_flags_off (aarch64_feature_flags mask)
 {
-  return (0
+  return (AARCH64_NO_FEATURES
 #define AARCH64_OPT_EXTENSION(A, IDENT, C, D, E, F) \
-	  | (feature_deps::IDENT ().enable & mask ? AARCH64_FL_##IDENT : 0)
+	  | (feature_deps::IDENT ().enable & mask ? AARCH64_FL_##IDENT \
+	     : AARCH64_NO_FEATURES)
 #include "config/aarch64/aarch64-option-extensions.def"
 	  );
 }
diff --git a/gcc/config/aarch64/aarch64-opts.h b/gcc/config/aarch64/aarch64-opts.h
index 06a4fed3833482543891b4f7c778933f7cebd631..376d7b5ad25e8838bc83fd9ab1c6f09c6de10835 100644
--- a/gcc/config/aarch64/aarch64-opts.h
+++ b/gcc/config/aarch64/aarch64-opts.h
@@ -29,6 +29,8 @@ constexpr unsigned int AARCH64_NUM_ISA_MODES = (0
 #define DEF_AARCH64_ISA_MODE(IDENT) + 1
 #include "aarch64-isa-modes.def"
 );
+
+#define AARCH64_NO_FEATURES aarch64_feature_flags (0)
 #endif
 
 /* The various cores that implement AArch64.  */
diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index 42639e9efcf1e0f9362f759ae63a31b8eeb0d581..4b1fefdd53843e97d3249bfb4d9fed2ffe60f865 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -736,7 +736,8 @@ const unsigned int AARCH64_BUILTIN_CLASS = (1 << AARCH64_BUILTIN_SHIFT) - 1;
 class aarch64_simd_switcher
 {
 public:
-  aarch64_simd_switcher (aarch64_feature_flags extra_flags = 0);
+  aarch64_simd_switcher (aarch64_feature_flags extra_flags =
+			 AARCH64_NO_FEATURES);
   ~aarch64_simd_switcher ();
 
 private:
diff --git a/gcc/config/aarch64/aarch64-sve-builtins-sme.def b/gcc/config/aarch64/aarch64-sve-builtins-sme.def
index 416df0b3637744503aa2f5f25fc21e204a4e2a77..4d2c96e8aa0865d5139338924f3bb4394efda04f 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins-sme.def
+++ b/gcc/config/aarch64/aarch64-sve-builtins-sme.def
@@ -32,7 +32,7 @@
   DEF_SME_ZA_FUNCTION_GS (NAME, SHAPE, TYPES, none, PREDS)
 #endif
 
-#define REQUIRED_EXTENSIONS 0
+#define REQUIRED_EXTENSIONS AARCH64_NO_FEATURES
 DEF_SME_FUNCTION (arm_has_sme, bool_inherent, none, none)
 DEF_SME_FUNCTION (arm_in_streaming_mode, bool_inherent, none, none)
 #undef REQUIRED_EXTENSIONS
diff --git a/gcc/config/aarch64/aarch64-sve-builtins.h b/gcc/config/aarch64/aarch64-sve-builtins.h
index 9cc07d5fa3debb855e787a0874a4c94bcaec65db..9028fa8554e553bfa1ea017cf3320d59ea3f82fb 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins.h
+++ b/gcc/config/aarch64/aarch64-sve-builtins.h
@@ -666,7 +666,7 @@ public:
 
   rtx convert_to_pmode (rtx);
   rtx get_contiguous_base (machine_mode, unsigned int = 1, unsigned int = 2,
-			   aarch64_feature_flags = 0);
+			   aarch64_feature_flags = AARCH64_NO_FEATURES);
   rtx get_fallback_value (machine_mode, unsigned int,
 			  unsigned int, unsigned int &);
   rtx get_reg_target ();
@@ -799,7 +799,7 @@ public:
 class sve_switcher : public aarch64_simd_switcher
 {
 public:
-  sve_switcher (aarch64_feature_flags = 0);
+  sve_switcher (aarch64_feature_flags = AARCH64_NO_FEATURES);
   ~sve_switcher ();
 
 private:
diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc b/gcc/config/aarch64/aarch64-sve-builtins.cc
index f3983a123e354a7626d4646363883d444fa6b8a5..d555f350cd79ebed21dab77208b0ce291ab90e79 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins.cc
+++ b/gcc/config/aarch64/aarch64-sve-builtins.cc
@@ -894,7 +894,7 @@ static CONSTEXPR const function_group_info function_groups[] = {
 static CONSTEXPR const function_group_info neon_sve_function_groups[] = {
 #define DEF_NEON_SVE_FUNCTION(NAME, SHAPE, TYPES, GROUPS, PREDS) \
   { #NAME, &neon_sve_bridge_functions::NAME, &shapes::SHAPE, types_##TYPES, \
-    groups_##GROUPS, preds_##PREDS, 0 },
+    groups_##GROUPS, preds_##PREDS, AARCH64_NO_FEATURES },
 #include "aarch64-neon-sve-bridge-builtins.def"
 };
 
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 4e6ad1023f638c9756ee9503b1ecbd3c1573871a..582dac5129faccee0db3a68f6bdf866e8b41a059 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -450,7 +450,8 @@ static CONSTEXPR const processor all_architectures[] =
   {NAME, CORE, CORE, AARCH64_ARCH_##ARCH_IDENT, \
    feature_deps::ARCH_IDENT ().enable, NULL},
 #include "aarch64-arches.def"
-  {NULL, aarch64_none, aarch64_none, aarch64_no_arch, 0, NULL}
+  {NULL, aarch64_none, aarch64_none, aarch64_no_arch, AARCH64_NO_FEATURES,
+  NULL}
 };
 
 /* Processor cores implementing AArch64.  */
@@ -460,7 +461,8 @@ static const struct processor all_cores[] =
   {NAME, IDENT, SCHED, AARCH64_ARCH_##ARCH, \
    feature_deps::cpu_##IDENT, &COSTS##_tunings},
 #include "aarch64-cores.def"
-  {NULL, aarch64_none, aarch64_none, aarch64_no_arch, 0, NULL}
+  {NULL, aarch64_none, aarch64_none, aarch64_no_arch, AARCH64_NO_FEATURES,
+   NULL}
 };
 /* Internal representation of system registers.  */
 typedef struct {
@@ -490,8 +492,6 @@ typedef struct {
 #define AARCH64_FEATURES(N, ...) \
   AARCH64_OR_FEATURES_##N (0, __VA_ARGS__)
 
-#define AARCH64_NO_FEATURES	   0
-
 /* Flags associated with the properties of system registers.  It mainly serves
    to mark particular registers as read or write only.  */
 #define F_DEPRECATED		   (1 << 1)
@@ -514,8 +514,6 @@ const sysreg_t aarch64_sysregs[] =
 #undef CPENC
 };
 
-#undef AARCH64_NO_FEATURES
-
 using sysreg_map_t = hash_map<nofree_string_hash, const sysreg_t *>;
 static sysreg_map_t *sysreg_map = nullptr;
 
@@ -18788,9 +18786,9 @@ static const struct aarch_branch_protect_type aarch64_branch_protect_types[] =
 static void
 aarch64_override_options (void)
 {
-  aarch64_feature_flags cpu_isa = 0;
-  aarch64_feature_flags arch_isa = 0;
-  aarch64_set_asm_isa_flags (0);
+  aarch64_feature_flags cpu_isa = AARCH64_NO_FEATURES;
+  aarch64_feature_flags arch_isa = AARCH64_NO_FEATURES;
+  aarch64_set_asm_isa_flags (AARCH64_NO_FEATURES);
 
   const struct processor *cpu = NULL;
   const struct processor *arch = NULL;
@@ -19553,7 +19551,7 @@ aarch64_process_target_attr (tree args)
 	{
 	  /* Check if token is possibly an arch extension without
 	     leading '+'.  */
-	  aarch64_feature_flags isa_temp = 0;
+	  aarch64_feature_flags isa_temp;
 	  auto with_plus = std::string ("+") + token;
 	  enum aarch_parse_opt_result ext_res
 	    = aarch64_parse_extension (with_plus.c_str (), &isa_temp, nullptr);
diff --git a/gcc/config/aarch64/driver-aarch64.cc b/gcc/config/aarch64/driver-aarch64.cc
index b620351e572038d84da5d401a9c295fe19797b4e..56fd4d8d7666e569ae5f20b9d5ab8933335c4fa5 100644
--- a/gcc/config/aarch64/driver-aarch64.cc
+++ b/gcc/config/aarch64/driver-aarch64.cc
@@ -67,7 +67,8 @@ struct aarch64_core_data
 static CONSTEXPR const aarch64_core_data aarch64_cpu_data[] =
 {
 #include "aarch64-cores.def"
-  { NULL, NULL, INVALID_IMP, INVALID_CORE, ALL_VARIANTS, 0 }
+  { NULL, NULL, INVALID_IMP, INVALID_CORE, ALL_VARIANTS,
+    AARCH64_NO_FEATURES }
 };
 
 
@@ -85,7 +86,7 @@ struct aarch64_arch_driver_info
 static CONSTEXPR const aarch64_arch_driver_info aarch64_arches[] =
 {
 #include "aarch64-arches.def"
-  {NULL, NULL, 0}
+  {NULL, NULL, AARCH64_NO_FEATURES}
 };
 
 
@@ -261,9 +262,9 @@ host_detect_local_cpu (int argc, const char **argv)
   unsigned int variants[2] = { ALL_VARIANTS, ALL_VARIANTS };
   unsigned int n_variants = 0;
   bool processed_exts = false;
-  aarch64_feature_flags extension_flags = 0;
-  aarch64_feature_flags unchecked_extension_flags = 0;
-  aarch64_feature_flags default_flags = 0;
+  aarch64_feature_flags extension_flags = AARCH64_NO_FEATURES;
+  aarch64_feature_flags unchecked_extension_flags = AARCH64_NO_FEATURES;
+  aarch64_feature_flags default_flags = AARCH64_NO_FEATURES;
   std::string buf;
   size_t sep_pos = -1;
   char *fcpu_info;

  parent reply	other threads:[~2024-05-14 14:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-14 14:54 [PATCH 00/12] aarch64: Extend aarch64_feature_flags to 128 bits Andrew Carlotti
2024-05-14 14:55 ` [PATCH 01/12] aarch64: Remove unused global aarch64_tune_flags Andrew Carlotti
2024-05-14 14:55 ` [PATCH 02/12] aarch64: Move AARCH64_NUM_ISA_MODES definition Andrew Carlotti
2024-05-14 14:56 ` Andrew Carlotti [this message]
2024-05-14 14:56 ` [PATCH 04/12] aarch64: Don't compare aarch64_feature_flags to 0 Andrew Carlotti
2024-05-14 14:56 ` [PATCH 05/12] aarch64: Eliminate a temporary variable Andrew Carlotti
2024-05-14 14:57 ` [PATCH 06/12] aarch64: Introduce aarch64_isa_mode type Andrew Carlotti
2024-05-14 14:57 ` [PATCH 07/12] aarch64: Define aarch64_get_{asm_|}isa_flags Andrew Carlotti
2024-05-14 14:58 ` [PATCH 08/12] aarch64: Decouple feature flag option storage type Andrew Carlotti
2024-05-14 14:58 ` [PATCH 09/12] aarch64: Assign flags to local constexpr variable Andrew Carlotti
2024-05-14 14:59 ` [PATCH 10/12] aarch64: Add aarch64_feature_flags_from_index macro Andrew Carlotti
2024-05-14 14:59 ` [RFC 11/12] Add explicit bool casts to .md condition users Andrew Carlotti
2024-05-14 15:00 ` [PATCH 12/12] aarch64: Extend aarch64_feature_flags to 128 bits Andrew Carlotti
2024-05-17 15:45 ` [PATCH 00/12] " Richard Sandiford
2024-05-20 12:09   ` Andrew Carlotti
2024-05-20 15:53     ` Richard Sandiford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dce1d13e-f8f5-d397-2f52-12e1f01b9437@e124511.cambridge.arm.com \
    --to=andrew.carlotti@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.sandiford@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).