public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gas/x86: .arch / -march= enhancements
@ 2022-06-30 12:52 Jan Beulich
  2022-06-30 12:53 ` [PATCH 1/7] x86: don't leak sub-architecture accumulated strings Jan Beulich
                   ` (6 more replies)
  0 siblings, 7 replies; 17+ messages in thread
From: Jan Beulich @ 2022-06-30 12:52 UTC (permalink / raw)
  To: Binutils

The lack of being able to go back to certain known state has bothered
me for quite a while. As did the seemingly arbitrary set of ".no*"
options available to turn off certain features. Finally I did find
time to make an attempt at adding the missing functionality.

1: don't leak sub-architecture accumulated strings
2: de-duplicate sub-architecture strings accumulation
3: permit "default" with .arch
4: macro-ize cpu_arch[] entries
5: introduce fake processor type to mark sub-arch entries in cpu_arch[]
6: generalize disabling of sub-architectures
7: introduce a state stack for .arch

Jan

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/7] x86: don't leak sub-architecture accumulated strings
  2022-06-30 12:52 [PATCH] gas/x86: .arch / -march= enhancements Jan Beulich
@ 2022-06-30 12:53 ` Jan Beulich
  2022-06-30 22:54   ` H.J. Lu
  2022-06-30 12:53 ` [PATCH 2/7] x86: de-duplicate sub-architecture strings accumulation Jan Beulich
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Jan Beulich @ 2022-06-30 12:53 UTC (permalink / raw)
  To: Binutils

While it may not be necessary in i386_target_format() (but then setting
the variable to NULL also wouldn't be necessary), at least in the other
cases strings may already have accumulated.

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -2871,6 +2871,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
 		  check_cpu_arch_compatible (string, cpu_arch[j].flags);
 
 		  cpu_arch_name = cpu_arch[j].name;
+		  xfree (cpu_sub_arch_name);
 		  cpu_sub_arch_name = NULL;
 		  cpu_arch_flags = cpu_arch[j].flags;
 		  if (flag_code == CODE_64BIT)
@@ -13406,6 +13407,7 @@ md_parse_option (int c, const char *arg)
 		    continue;
 
 		  cpu_arch_name = cpu_arch[j].name;
+		  xfree (cpu_sub_arch_name);
 		  cpu_sub_arch_name = NULL;
 		  cpu_arch_flags = cpu_arch[j].flags;
 		  cpu_arch_isa = cpu_arch[j].type;
@@ -14086,6 +14088,7 @@ i386_target_format (void)
 	{
 	  static const i386_cpu_flags iamcu_flags = CPU_IAMCU_FLAGS;
 	  cpu_arch_name = "iamcu";
+	  xfree (cpu_sub_arch_name);
 	  cpu_sub_arch_name = NULL;
 	  cpu_arch_flags = iamcu_flags;
 	  cpu_arch_isa = PROCESSOR_IAMCU;


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 2/7] x86: de-duplicate sub-architecture strings accumulation
  2022-06-30 12:52 [PATCH] gas/x86: .arch / -march= enhancements Jan Beulich
  2022-06-30 12:53 ` [PATCH 1/7] x86: don't leak sub-architecture accumulated strings Jan Beulich
@ 2022-06-30 12:53 ` Jan Beulich
  2022-06-30 22:55   ` H.J. Lu
  2022-06-30 12:53 ` [PATCH 3/7] x86: permit "default" with .arch Jan Beulich
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Jan Beulich @ 2022-06-30 12:53 UTC (permalink / raw)
  To: Binutils

Introduce a helper function to replace 4 instances of similar code. Use
reconcat() to cover the previously explicit free() (which really should
have been xfree() anyway).

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -2851,6 +2851,16 @@ check_cpu_arch_compatible (const char *n
 }
 
 static void
+extend_cpu_sub_arch_name (const char *name)
+{
+  if (cpu_sub_arch_name)
+    cpu_sub_arch_name = reconcat (cpu_sub_arch_name, cpu_sub_arch_name,
+				  name, (const char *) NULL);
+  else
+    cpu_sub_arch_name = xstrdup (name);
+}
+
+static void
 set_cpu_arch (int dummy ATTRIBUTE_UNUSED)
 {
   SKIP_WHITESPACE ();
@@ -2899,16 +2909,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
 
 	      if (!cpu_flags_equal (&flags, &cpu_arch_flags))
 		{
-		  if (cpu_sub_arch_name)
-		    {
-		      char *name = cpu_sub_arch_name;
-		      cpu_sub_arch_name = concat (name,
-						  cpu_arch[j].name,
-						  (const char *) NULL);
-		      free (name);
-		    }
-		  else
-		    cpu_sub_arch_name = xstrdup (cpu_arch[j].name);
+		  extend_cpu_sub_arch_name (string);
 		  cpu_arch_flags = flags;
 		  cpu_arch_isa_flags = flags;
 		}
@@ -2932,15 +2933,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
 					   cpu_noarch[j].flags);
 		if (!cpu_flags_equal (&flags, &cpu_arch_flags))
 		  {
-		    if (cpu_sub_arch_name)
-		      {
-			char *name = cpu_sub_arch_name;
-			cpu_sub_arch_name = concat (name, string,
-						    (const char *) NULL);
-			free (name);
-		      }
-		    else
-		      cpu_sub_arch_name = xstrdup (string);
+		    extend_cpu_sub_arch_name (string);
 		    cpu_arch_flags = flags;
 		    cpu_arch_isa_flags = flags;
 		  }
@@ -13430,16 +13423,7 @@ md_parse_option (int c, const char *arg)
 
 		  if (!cpu_flags_equal (&flags, &cpu_arch_flags))
 		    {
-		      if (cpu_sub_arch_name)
-			{
-			  char *name = cpu_sub_arch_name;
-			  cpu_sub_arch_name = concat (name,
-						      cpu_arch[j].name,
-						      (const char *) NULL);
-			  free (name);
-			}
-		      else
-			cpu_sub_arch_name = xstrdup (cpu_arch[j].name);
+		      extend_cpu_sub_arch_name (cpu_arch[j].name);
 		      cpu_arch_flags = flags;
 		      cpu_arch_isa_flags = flags;
 		    }
@@ -13463,15 +13447,7 @@ md_parse_option (int c, const char *arg)
 					       cpu_noarch[j].flags);
 		    if (!cpu_flags_equal (&flags, &cpu_arch_flags))
 		      {
-			if (cpu_sub_arch_name)
-			  {
-			    char *name = cpu_sub_arch_name;
-			    cpu_sub_arch_name = concat (arch,
-							(const char *) NULL);
-			    free (name);
-			  }
-			else
-			  cpu_sub_arch_name = xstrdup (arch);
+			extend_cpu_sub_arch_name (arch);
 			cpu_arch_flags = flags;
 			cpu_arch_isa_flags = flags;
 		      }


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 3/7] x86: permit "default" with .arch
  2022-06-30 12:52 [PATCH] gas/x86: .arch / -march= enhancements Jan Beulich
  2022-06-30 12:53 ` [PATCH 1/7] x86: don't leak sub-architecture accumulated strings Jan Beulich
  2022-06-30 12:53 ` [PATCH 2/7] x86: de-duplicate sub-architecture strings accumulation Jan Beulich
@ 2022-06-30 12:53 ` Jan Beulich
  2022-06-30 22:58   ` H.J. Lu
  2022-06-30 12:54 ` [PATCH 4/7] x86: macro-ize cpu_arch[] entries Jan Beulich
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Jan Beulich @ 2022-06-30 12:53 UTC (permalink / raw)
  To: Binutils

So far there was no way to reset the architecture to that assembly would
start with in the absence of any overrides (command line or directives).
Note that for Intel MCU "default" is merely an alias of "iamcu".

While there also zap a stray @item from the doc section, as noticed
when inspecting the generated output (which still has some quirks, but
those aren't easy to address without re-flowing almost the entire
section).

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -933,8 +933,8 @@ const relax_typeS md_relax_table[] =
 
 static const arch_entry cpu_arch[] =
 {
-  /* Do not replace the first two entries - i386_target_format()
-     relies on them being there in this order.  */
+  /* Do not replace the first two entries - i386_target_format() and
+     set_cpu_arch() rely on them being there in this order.  */
   { STRING_COMMA_LEN ("generic32"), PROCESSOR_GENERIC32,
     CPU_GENERIC32_FLAGS, 0 },
   { STRING_COMMA_LEN ("generic64"), PROCESSOR_GENERIC64,
@@ -2867,12 +2867,47 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
 
   if (!is_end_of_line[(unsigned char) *input_line_pointer])
     {
-      char *string;
-      int e = get_symbol_name (&string);
-      unsigned int j;
+      char *s;
+      int e = get_symbol_name (&s);
+      const char *string = s;
+      unsigned int j = 0;
       i386_cpu_flags flags;
 
-      for (j = 0; j < ARRAY_SIZE (cpu_arch); j++)
+      if (strcmp (string, "default") == 0)
+	{
+	  if (strcmp (default_arch, "iamcu") == 0)
+	    string = default_arch;
+	  else
+	    {
+	      static const i386_cpu_flags cpu_unknown_flags = CPU_UNKNOWN_FLAGS;
+
+	      cpu_arch_name = NULL;
+	      xfree (cpu_sub_arch_name);
+	      cpu_sub_arch_name = NULL;
+	      cpu_arch_flags = cpu_unknown_flags;
+	      if (flag_code == CODE_64BIT)
+		{
+		  cpu_arch_flags.bitfield.cpu64 = 1;
+		  cpu_arch_flags.bitfield.cpuno64 = 0;
+		}
+	      else
+		{
+		  cpu_arch_flags.bitfield.cpu64 = 0;
+		  cpu_arch_flags.bitfield.cpuno64 = 1;
+		}
+	      cpu_arch_isa = PROCESSOR_UNKNOWN;
+	      cpu_arch_isa_flags = cpu_arch[flag_code == CODE_64BIT].flags;
+	      if (!cpu_arch_tune_set)
+		{
+		  cpu_arch_tune = cpu_arch_isa;
+		  cpu_arch_tune_flags = cpu_arch_isa_flags;
+		}
+
+	      j = ARRAY_SIZE (cpu_arch) + 1;
+	    }
+	}
+
+      for (; j < ARRAY_SIZE (cpu_arch); j++)
 	{
 	  if (strcmp (string, cpu_arch[j].name) == 0)
 	    {
@@ -2945,7 +2980,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
 	  j = ARRAY_SIZE (cpu_arch);
 	}
 
-      if (j >= ARRAY_SIZE (cpu_arch))
+      if (j == ARRAY_SIZE (cpu_arch))
 	as_bad (_("no such architecture: `%s'"), string);
 
       *input_line_pointer = e;
@@ -13841,6 +13876,13 @@ show_arch (FILE *stream, int ext, int ch
 
   p = start;
   left = size - (start - message);
+
+  if (!ext && check)
+    {
+      p = output_message (stream, p, message, start, &left,
+			  STRING_COMMA_LEN ("default"));
+    }
+
   for (j = 0; j < ARRAY_SIZE (cpu_arch); j++)
     {
       /* Should it be skipped?  */
--- a/gas/doc/c-i386.texi
+++ b/gas/doc/c-i386.texi
@@ -1504,6 +1504,7 @@ directive enables a warning when gas det
 supported on the CPU specified.  The choices for @var{cpu_type} are:
 
 @multitable @columnfractions .20 .20 .20 .20
+@item @samp{default}
 @item @samp{i8086} @tab @samp{i186} @tab @samp{i286} @tab @samp{i386}
 @item @samp{i486} @tab @samp{i586} @tab @samp{i686} @tab @samp{pentium}
 @item @samp{pentiumpro} @tab @samp{pentiumii} @tab @samp{pentiumiii} @tab @samp{pentium4}
@@ -1531,7 +1532,7 @@ supported on the CPU specified.  The cho
 @item @samp{.avx512_vpopcntdq} @tab @samp{.avx512_vbmi2} @tab @samp{.avx512_vnni}
 @item @samp{.avx512_bitalg} @tab @samp{.avx512_bf16} @tab @samp{.avx512_vp2intersect}
 @item @samp{.tdx} @tab @samp{.avx_vnni}  @tab @samp{.avx512_fp16}
-@item @samp{.clwb} @tab @samp{.rdpid} @tab @samp{.ptwrite} @tab @item @samp{.ibt}
+@item @samp{.clwb} @tab @samp{.rdpid} @tab @samp{.ptwrite} @tab @samp{.ibt}
 @item @samp{.wbnoinvd} @tab @samp{.pconfig} @tab @samp{.waitpkg} @tab @samp{.cldemote}
 @item @samp{.shstk} @tab @samp{.gfni} @tab @samp{.vaes} @tab @samp{.vpclmulqdq}
 @item @samp{.movdiri} @tab @samp{.movdir64b} @tab @samp{.enqcmd} @tab @samp{.tsxldtrk}
--- /dev/null
+++ b/gas/testsuite/gas/i386/arch-dflt.l
@@ -0,0 +1,19 @@
+.*: Assembler messages:
+.*:3: Error:.*`cmovl'.*
+.*:9: Error:.*`cmovg'.*
+GAS LISTING .*
+
+
+[ 	]*[0-9]*[ 	]+\.text
+[ 	]*[0-9]*[ 	]+start:
+[ 	]*[0-9]*[ 	]+cmovl	%eax, %ecx
+[ 	]*[0-9]*[ 	]*
+[ 	]*[0-9]*[ 	]+\.arch default
+[ 	]*[0-9]*[ 	]+\?\?\?\? 0F4DC8[ 	]+cmovnl	%eax, %ecx
+[ 	]*[0-9]*[ 	]*
+[ 	]*[0-9]*[ 	]+\.arch generic32
+[ 	]*[0-9]*[ 	]+cmovg	%eax, %ecx
+[ 	]*[0-9]*[ 	]*
+[ 	]*[0-9]*[ 	]+\.arch default
+[ 	]*[0-9]*[ 	]+\?\?\?\? 0F4EC8[ 	]+cmovng	%eax, %ecx
+#pass
--- /dev/null
+++ b/gas/testsuite/gas/i386/arch-dflt.s
@@ -0,0 +1,14 @@
+	.text
+start:
+	cmovl	%eax, %ecx
+
+	.arch default
+	cmovnl	%eax, %ecx
+
+	.arch generic32
+	cmovg	%eax, %ecx
+
+	.arch default
+	cmovng	%eax, %ecx
+
+	.end
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -205,6 +205,7 @@ if [gas_32_check] then {
     run_dump_test "arch-12"
     run_dump_test "arch-13"
     run_dump_test "arch-14"
+    run_list_test "arch-dflt" "-march=generic32 -al"
     run_dump_test "8087"
     run_dump_test "287"
     run_dump_test "387"


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 4/7] x86: macro-ize cpu_arch[] entries
  2022-06-30 12:52 [PATCH] gas/x86: .arch / -march= enhancements Jan Beulich
                   ` (2 preceding siblings ...)
  2022-06-30 12:53 ` [PATCH 3/7] x86: permit "default" with .arch Jan Beulich
@ 2022-06-30 12:54 ` Jan Beulich
  2022-06-30 23:00   ` H.J. Lu
  2022-06-30 12:54 ` [PATCH 5/7] x86: introduce fake processor type to mark sub-arch entries in cpu_arch[] Jan Beulich
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Jan Beulich @ 2022-06-30 12:54 UTC (permalink / raw)
  To: Binutils

Putting individual elements behind macros, besides (imo) improving
readability, will make subsequent (and likely also future) changes less
intrusive.

Utilize this right away to pack the table a little more tightly, by
converting "skip" to bool and putting it earlier in a group of bitfields
together with "len".

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -126,10 +126,10 @@ sib_byte;
 typedef struct
 {
   const char *name;		/* arch name */
-  unsigned int len;		/* arch string length */
+  unsigned int len:8;		/* arch string length */
+  bool skip:1;			/* show_arch should skip this. */
   enum processor_type type;	/* arch type */
   i386_cpu_flags flags;		/* cpu feature flags */
-  unsigned int skip;		/* show_arch should skip this. */
 }
 arch_entry;
 
@@ -931,318 +931,174 @@ const relax_typeS md_relax_table[] =
   {0, 0, 4, 0}
 };
 
+#define ARCH(n, t, f, s) \
+  { STRING_COMMA_LEN (#n), s, PROCESSOR_ ## t, CPU_ ## f ## _FLAGS }
+#define SUBARCH(n, e, s) \
+  { STRING_COMMA_LEN ("." #n), s, PROCESSOR_UNKNOWN, CPU_ ## e ## _FLAGS }
+
 static const arch_entry cpu_arch[] =
 {
   /* Do not replace the first two entries - i386_target_format() and
      set_cpu_arch() rely on them being there in this order.  */
-  { STRING_COMMA_LEN ("generic32"), PROCESSOR_GENERIC32,
-    CPU_GENERIC32_FLAGS, 0 },
-  { STRING_COMMA_LEN ("generic64"), PROCESSOR_GENERIC64,
-    CPU_GENERIC64_FLAGS, 0 },
-  { STRING_COMMA_LEN ("i8086"), PROCESSOR_UNKNOWN,
-    CPU_NONE_FLAGS, 0 },
-  { STRING_COMMA_LEN ("i186"), PROCESSOR_UNKNOWN,
-    CPU_I186_FLAGS, 0 },
-  { STRING_COMMA_LEN ("i286"), PROCESSOR_UNKNOWN,
-    CPU_I286_FLAGS, 0 },
-  { STRING_COMMA_LEN ("i386"), PROCESSOR_I386,
-    CPU_I386_FLAGS, 0 },
-  { STRING_COMMA_LEN ("i486"), PROCESSOR_I486,
-    CPU_I486_FLAGS, 0 },
-  { STRING_COMMA_LEN ("i586"), PROCESSOR_PENTIUM,
-    CPU_I586_FLAGS, 0 },
-  { STRING_COMMA_LEN ("i686"), PROCESSOR_PENTIUMPRO,
-    CPU_I686_FLAGS, 0 },
-  { STRING_COMMA_LEN ("pentium"), PROCESSOR_PENTIUM,
-    CPU_I586_FLAGS, 0 },
-  { STRING_COMMA_LEN ("pentiumpro"), PROCESSOR_PENTIUMPRO,
-    CPU_PENTIUMPRO_FLAGS, 0 },
-  { STRING_COMMA_LEN ("pentiumii"), PROCESSOR_PENTIUMPRO,
-    CPU_P2_FLAGS, 0 },
-  { STRING_COMMA_LEN ("pentiumiii"),PROCESSOR_PENTIUMPRO,
-    CPU_P3_FLAGS, 0 },
-  { STRING_COMMA_LEN ("pentium4"), PROCESSOR_PENTIUM4,
-    CPU_P4_FLAGS, 0 },
-  { STRING_COMMA_LEN ("prescott"), PROCESSOR_NOCONA,
-    CPU_CORE_FLAGS, 0 },
-  { STRING_COMMA_LEN ("nocona"), PROCESSOR_NOCONA,
-    CPU_NOCONA_FLAGS, 0 },
-  { STRING_COMMA_LEN ("yonah"), PROCESSOR_CORE,
-    CPU_CORE_FLAGS, 1 },
-  { STRING_COMMA_LEN ("core"), PROCESSOR_CORE,
-    CPU_CORE_FLAGS, 0 },
-  { STRING_COMMA_LEN ("merom"), PROCESSOR_CORE2,
-    CPU_CORE2_FLAGS, 1 },
-  { STRING_COMMA_LEN ("core2"), PROCESSOR_CORE2,
-    CPU_CORE2_FLAGS, 0 },
-  { STRING_COMMA_LEN ("corei7"), PROCESSOR_COREI7,
-    CPU_COREI7_FLAGS, 0 },
-  { STRING_COMMA_LEN ("iamcu"), PROCESSOR_IAMCU,
-    CPU_IAMCU_FLAGS, 0 },
-  { STRING_COMMA_LEN ("k6"), PROCESSOR_K6,
-    CPU_K6_FLAGS, 0 },
-  { STRING_COMMA_LEN ("k6_2"), PROCESSOR_K6,
-    CPU_K6_2_FLAGS, 0 },
-  { STRING_COMMA_LEN ("athlon"), PROCESSOR_ATHLON,
-    CPU_ATHLON_FLAGS, 0 },
-  { STRING_COMMA_LEN ("sledgehammer"), PROCESSOR_K8,
-    CPU_K8_FLAGS, 1 },
-  { STRING_COMMA_LEN ("opteron"), PROCESSOR_K8,
-    CPU_K8_FLAGS, 0 },
-  { STRING_COMMA_LEN ("k8"), PROCESSOR_K8,
-    CPU_K8_FLAGS, 0 },
-  { STRING_COMMA_LEN ("amdfam10"), PROCESSOR_AMDFAM10,
-    CPU_AMDFAM10_FLAGS, 0 },
-  { STRING_COMMA_LEN ("bdver1"), PROCESSOR_BD,
-    CPU_BDVER1_FLAGS, 0 },
-  { STRING_COMMA_LEN ("bdver2"), PROCESSOR_BD,
-    CPU_BDVER2_FLAGS, 0 },
-  { STRING_COMMA_LEN ("bdver3"), PROCESSOR_BD,
-    CPU_BDVER3_FLAGS, 0 },
-  { STRING_COMMA_LEN ("bdver4"), PROCESSOR_BD,
-    CPU_BDVER4_FLAGS, 0 },
-  { STRING_COMMA_LEN ("znver1"), PROCESSOR_ZNVER,
-    CPU_ZNVER1_FLAGS, 0 },
-  { STRING_COMMA_LEN ("znver2"), PROCESSOR_ZNVER,
-    CPU_ZNVER2_FLAGS, 0 },
-  { STRING_COMMA_LEN ("znver3"), PROCESSOR_ZNVER,
-    CPU_ZNVER3_FLAGS, 0 },
-  { STRING_COMMA_LEN ("btver1"), PROCESSOR_BT,
-    CPU_BTVER1_FLAGS, 0 },
-  { STRING_COMMA_LEN ("btver2"), PROCESSOR_BT,
-    CPU_BTVER2_FLAGS, 0 },
-  { STRING_COMMA_LEN (".8087"), PROCESSOR_UNKNOWN,
-    CPU_8087_FLAGS, 0 },
-  { STRING_COMMA_LEN (".287"), PROCESSOR_UNKNOWN,
-    CPU_287_FLAGS, 0 },
-  { STRING_COMMA_LEN (".387"), PROCESSOR_UNKNOWN,
-    CPU_387_FLAGS, 0 },
-  { STRING_COMMA_LEN (".687"), PROCESSOR_UNKNOWN,
-    CPU_687_FLAGS, 0 },
-  { STRING_COMMA_LEN (".cmov"), PROCESSOR_UNKNOWN,
-    CPU_CMOV_FLAGS, 0 },
-  { STRING_COMMA_LEN (".fxsr"), PROCESSOR_UNKNOWN,
-    CPU_FXSR_FLAGS, 0 },
-  { STRING_COMMA_LEN (".mmx"), PROCESSOR_UNKNOWN,
-    CPU_MMX_FLAGS, 0 },
-  { STRING_COMMA_LEN (".sse"), PROCESSOR_UNKNOWN,
-    CPU_SSE_FLAGS, 0 },
-  { STRING_COMMA_LEN (".sse2"), PROCESSOR_UNKNOWN,
-    CPU_SSE2_FLAGS, 0 },
-  { STRING_COMMA_LEN (".sse3"), PROCESSOR_UNKNOWN,
-    CPU_SSE3_FLAGS, 0 },
-  { STRING_COMMA_LEN (".sse4a"), PROCESSOR_UNKNOWN,
-    CPU_SSE4A_FLAGS, 0 },
-  { STRING_COMMA_LEN (".ssse3"), PROCESSOR_UNKNOWN,
-    CPU_SSSE3_FLAGS, 0 },
-  { STRING_COMMA_LEN (".sse4.1"), PROCESSOR_UNKNOWN,
-    CPU_SSE4_1_FLAGS, 0 },
-  { STRING_COMMA_LEN (".sse4.2"), PROCESSOR_UNKNOWN,
-    CPU_SSE4_2_FLAGS, 0 },
-  { STRING_COMMA_LEN (".sse4"), PROCESSOR_UNKNOWN,
-    CPU_SSE4_2_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx"), PROCESSOR_UNKNOWN,
-    CPU_AVX_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx2"), PROCESSOR_UNKNOWN,
-    CPU_AVX2_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx512f"), PROCESSOR_UNKNOWN,
-    CPU_AVX512F_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx512cd"), PROCESSOR_UNKNOWN,
-    CPU_AVX512CD_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx512er"), PROCESSOR_UNKNOWN,
-    CPU_AVX512ER_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx512pf"), PROCESSOR_UNKNOWN,
-    CPU_AVX512PF_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx512dq"), PROCESSOR_UNKNOWN,
-    CPU_AVX512DQ_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx512bw"), PROCESSOR_UNKNOWN,
-    CPU_AVX512BW_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx512vl"), PROCESSOR_UNKNOWN,
-    CPU_AVX512VL_FLAGS, 0 },
-  { STRING_COMMA_LEN (".vmx"), PROCESSOR_UNKNOWN,
-    CPU_VMX_FLAGS, 0 },
-  { STRING_COMMA_LEN (".vmfunc"), PROCESSOR_UNKNOWN,
-    CPU_VMFUNC_FLAGS, 0 },
-  { STRING_COMMA_LEN (".smx"), PROCESSOR_UNKNOWN,
-    CPU_SMX_FLAGS, 0 },
-  { STRING_COMMA_LEN (".xsave"), PROCESSOR_UNKNOWN,
-    CPU_XSAVE_FLAGS, 0 },
-  { STRING_COMMA_LEN (".xsaveopt"), PROCESSOR_UNKNOWN,
-    CPU_XSAVEOPT_FLAGS, 0 },
-  { STRING_COMMA_LEN (".xsavec"), PROCESSOR_UNKNOWN,
-    CPU_XSAVEC_FLAGS, 0 },
-  { STRING_COMMA_LEN (".xsaves"), PROCESSOR_UNKNOWN,
-    CPU_XSAVES_FLAGS, 0 },
-  { STRING_COMMA_LEN (".aes"), PROCESSOR_UNKNOWN,
-    CPU_AES_FLAGS, 0 },
-  { STRING_COMMA_LEN (".pclmul"), PROCESSOR_UNKNOWN,
-    CPU_PCLMUL_FLAGS, 0 },
-  { STRING_COMMA_LEN (".clmul"), PROCESSOR_UNKNOWN,
-    CPU_PCLMUL_FLAGS, 1 },
-  { STRING_COMMA_LEN (".fsgsbase"), PROCESSOR_UNKNOWN,
-    CPU_FSGSBASE_FLAGS, 0 },
-  { STRING_COMMA_LEN (".rdrnd"), PROCESSOR_UNKNOWN,
-    CPU_RDRND_FLAGS, 0 },
-  { STRING_COMMA_LEN (".f16c"), PROCESSOR_UNKNOWN,
-    CPU_F16C_FLAGS, 0 },
-  { STRING_COMMA_LEN (".bmi2"), PROCESSOR_UNKNOWN,
-    CPU_BMI2_FLAGS, 0 },
-  { STRING_COMMA_LEN (".fma"), PROCESSOR_UNKNOWN,
-    CPU_FMA_FLAGS, 0 },
-  { STRING_COMMA_LEN (".fma4"), PROCESSOR_UNKNOWN,
-    CPU_FMA4_FLAGS, 0 },
-  { STRING_COMMA_LEN (".xop"), PROCESSOR_UNKNOWN,
-    CPU_XOP_FLAGS, 0 },
-  { STRING_COMMA_LEN (".lwp"), PROCESSOR_UNKNOWN,
-    CPU_LWP_FLAGS, 0 },
-  { STRING_COMMA_LEN (".movbe"), PROCESSOR_UNKNOWN,
-    CPU_MOVBE_FLAGS, 0 },
-  { STRING_COMMA_LEN (".cx16"), PROCESSOR_UNKNOWN,
-    CPU_CX16_FLAGS, 0 },
-  { STRING_COMMA_LEN (".ept"), PROCESSOR_UNKNOWN,
-    CPU_EPT_FLAGS, 0 },
-  { STRING_COMMA_LEN (".lzcnt"), PROCESSOR_UNKNOWN,
-    CPU_LZCNT_FLAGS, 0 },
-  { STRING_COMMA_LEN (".popcnt"), PROCESSOR_UNKNOWN,
-    CPU_POPCNT_FLAGS, 0 },
-  { STRING_COMMA_LEN (".hle"), PROCESSOR_UNKNOWN,
-    CPU_HLE_FLAGS, 0 },
-  { STRING_COMMA_LEN (".rtm"), PROCESSOR_UNKNOWN,
-    CPU_RTM_FLAGS, 0 },
-  { STRING_COMMA_LEN (".invpcid"), PROCESSOR_UNKNOWN,
-    CPU_INVPCID_FLAGS, 0 },
-  { STRING_COMMA_LEN (".clflush"), PROCESSOR_UNKNOWN,
-    CPU_CLFLUSH_FLAGS, 0 },
-  { STRING_COMMA_LEN (".nop"), PROCESSOR_UNKNOWN,
-    CPU_NOP_FLAGS, 0 },
-  { STRING_COMMA_LEN (".syscall"), PROCESSOR_UNKNOWN,
-    CPU_SYSCALL_FLAGS, 0 },
-  { STRING_COMMA_LEN (".rdtscp"), PROCESSOR_UNKNOWN,
-    CPU_RDTSCP_FLAGS, 0 },
-  { STRING_COMMA_LEN (".3dnow"), PROCESSOR_UNKNOWN,
-    CPU_3DNOW_FLAGS, 0 },
-  { STRING_COMMA_LEN (".3dnowa"), PROCESSOR_UNKNOWN,
-    CPU_3DNOWA_FLAGS, 0 },
-  { STRING_COMMA_LEN (".padlock"), PROCESSOR_UNKNOWN,
-    CPU_PADLOCK_FLAGS, 0 },
-  { STRING_COMMA_LEN (".pacifica"), PROCESSOR_UNKNOWN,
-    CPU_SVME_FLAGS, 1 },
-  { STRING_COMMA_LEN (".svme"), PROCESSOR_UNKNOWN,
-    CPU_SVME_FLAGS, 0 },
-  { STRING_COMMA_LEN (".sse4a"), PROCESSOR_UNKNOWN,
-    CPU_SSE4A_FLAGS, 0 },
-  { STRING_COMMA_LEN (".abm"), PROCESSOR_UNKNOWN,
-    CPU_ABM_FLAGS, 0 },
-  { STRING_COMMA_LEN (".bmi"), PROCESSOR_UNKNOWN,
-    CPU_BMI_FLAGS, 0 },
-  { STRING_COMMA_LEN (".tbm"), PROCESSOR_UNKNOWN,
-    CPU_TBM_FLAGS, 0 },
-  { STRING_COMMA_LEN (".adx"), PROCESSOR_UNKNOWN,
-    CPU_ADX_FLAGS, 0 },
-  { STRING_COMMA_LEN (".rdseed"), PROCESSOR_UNKNOWN,
-    CPU_RDSEED_FLAGS, 0 },
-  { STRING_COMMA_LEN (".prfchw"), PROCESSOR_UNKNOWN,
-    CPU_PRFCHW_FLAGS, 0 },
-  { STRING_COMMA_LEN (".smap"), PROCESSOR_UNKNOWN,
-    CPU_SMAP_FLAGS, 0 },
-  { STRING_COMMA_LEN (".mpx"), PROCESSOR_UNKNOWN,
-    CPU_MPX_FLAGS, 0 },
-  { STRING_COMMA_LEN (".sha"), PROCESSOR_UNKNOWN,
-    CPU_SHA_FLAGS, 0 },
-  { STRING_COMMA_LEN (".clflushopt"), PROCESSOR_UNKNOWN,
-    CPU_CLFLUSHOPT_FLAGS, 0 },
-  { STRING_COMMA_LEN (".prefetchwt1"), PROCESSOR_UNKNOWN,
-    CPU_PREFETCHWT1_FLAGS, 0 },
-  { STRING_COMMA_LEN (".se1"), PROCESSOR_UNKNOWN,
-    CPU_SE1_FLAGS, 0 },
-  { STRING_COMMA_LEN (".clwb"), PROCESSOR_UNKNOWN,
-    CPU_CLWB_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx512ifma"), PROCESSOR_UNKNOWN,
-    CPU_AVX512IFMA_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx512vbmi"), PROCESSOR_UNKNOWN,
-    CPU_AVX512VBMI_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx512_4fmaps"), PROCESSOR_UNKNOWN,
-    CPU_AVX512_4FMAPS_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx512_4vnniw"), PROCESSOR_UNKNOWN,
-    CPU_AVX512_4VNNIW_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx512_vpopcntdq"), PROCESSOR_UNKNOWN,
-    CPU_AVX512_VPOPCNTDQ_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx512_vbmi2"), PROCESSOR_UNKNOWN,
-    CPU_AVX512_VBMI2_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx512_vnni"), PROCESSOR_UNKNOWN,
-    CPU_AVX512_VNNI_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx512_bitalg"), PROCESSOR_UNKNOWN,
-    CPU_AVX512_BITALG_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx_vnni"), PROCESSOR_UNKNOWN,
-    CPU_AVX_VNNI_FLAGS, 0 },
-  { STRING_COMMA_LEN (".clzero"), PROCESSOR_UNKNOWN,
-    CPU_CLZERO_FLAGS, 0 },
-  { STRING_COMMA_LEN (".mwaitx"), PROCESSOR_UNKNOWN,
-    CPU_MWAITX_FLAGS, 0 },
-  { STRING_COMMA_LEN (".ospke"), PROCESSOR_UNKNOWN,
-    CPU_OSPKE_FLAGS, 0 },
-  { STRING_COMMA_LEN (".rdpid"), PROCESSOR_UNKNOWN,
-    CPU_RDPID_FLAGS, 0 },
-  { STRING_COMMA_LEN (".ptwrite"), PROCESSOR_UNKNOWN,
-    CPU_PTWRITE_FLAGS, 0 },
-  { STRING_COMMA_LEN (".ibt"), PROCESSOR_UNKNOWN,
-    CPU_IBT_FLAGS, 0 },
-  { STRING_COMMA_LEN (".shstk"), PROCESSOR_UNKNOWN,
-    CPU_SHSTK_FLAGS, 0 },
-  { STRING_COMMA_LEN (".gfni"), PROCESSOR_UNKNOWN,
-    CPU_GFNI_FLAGS, 0 },
-  { STRING_COMMA_LEN (".vaes"), PROCESSOR_UNKNOWN,
-    CPU_VAES_FLAGS, 0 },
-  { STRING_COMMA_LEN (".vpclmulqdq"), PROCESSOR_UNKNOWN,
-    CPU_VPCLMULQDQ_FLAGS, 0 },
-  { STRING_COMMA_LEN (".wbnoinvd"), PROCESSOR_UNKNOWN,
-    CPU_WBNOINVD_FLAGS, 0 },
-  { STRING_COMMA_LEN (".pconfig"), PROCESSOR_UNKNOWN,
-    CPU_PCONFIG_FLAGS, 0 },
-  { STRING_COMMA_LEN (".waitpkg"), PROCESSOR_UNKNOWN,
-    CPU_WAITPKG_FLAGS, 0 },
-  { STRING_COMMA_LEN (".cldemote"), PROCESSOR_UNKNOWN,
-    CPU_CLDEMOTE_FLAGS, 0 },
-  { STRING_COMMA_LEN (".amx_int8"), PROCESSOR_UNKNOWN,
-    CPU_AMX_INT8_FLAGS, 0 },
-  { STRING_COMMA_LEN (".amx_bf16"), PROCESSOR_UNKNOWN,
-    CPU_AMX_BF16_FLAGS, 0 },
-  { STRING_COMMA_LEN (".amx_tile"), PROCESSOR_UNKNOWN,
-    CPU_AMX_TILE_FLAGS, 0 },
-  { STRING_COMMA_LEN (".movdiri"), PROCESSOR_UNKNOWN,
-    CPU_MOVDIRI_FLAGS, 0 },
-  { STRING_COMMA_LEN (".movdir64b"), PROCESSOR_UNKNOWN,
-    CPU_MOVDIR64B_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx512_bf16"), PROCESSOR_UNKNOWN,
-    CPU_AVX512_BF16_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx512_vp2intersect"), PROCESSOR_UNKNOWN,
-    CPU_AVX512_VP2INTERSECT_FLAGS, 0 },
-  { STRING_COMMA_LEN (".tdx"), PROCESSOR_UNKNOWN,
-    CPU_TDX_FLAGS, 0 },
-  { STRING_COMMA_LEN (".enqcmd"), PROCESSOR_UNKNOWN,
-    CPU_ENQCMD_FLAGS, 0 },
-  { STRING_COMMA_LEN (".serialize"), PROCESSOR_UNKNOWN,
-    CPU_SERIALIZE_FLAGS, 0 },
-  { STRING_COMMA_LEN (".rdpru"), PROCESSOR_UNKNOWN,
-    CPU_RDPRU_FLAGS, 0 },
-  { STRING_COMMA_LEN (".mcommit"), PROCESSOR_UNKNOWN,
-    CPU_MCOMMIT_FLAGS, 0 },
-  { STRING_COMMA_LEN (".sev_es"), PROCESSOR_UNKNOWN,
-    CPU_SEV_ES_FLAGS, 0 },
-  { STRING_COMMA_LEN (".tsxldtrk"), PROCESSOR_UNKNOWN,
-    CPU_TSXLDTRK_FLAGS, 0 },
-  { STRING_COMMA_LEN (".kl"), PROCESSOR_UNKNOWN,
-    CPU_KL_FLAGS, 0 },
-  { STRING_COMMA_LEN (".widekl"), PROCESSOR_UNKNOWN,
-    CPU_WIDEKL_FLAGS, 0 },
-  { STRING_COMMA_LEN (".uintr"), PROCESSOR_UNKNOWN,
-    CPU_UINTR_FLAGS, 0 },
-  { STRING_COMMA_LEN (".hreset"), PROCESSOR_UNKNOWN,
-    CPU_HRESET_FLAGS, 0 },
-  { STRING_COMMA_LEN (".avx512_fp16"), PROCESSOR_UNKNOWN,
-    CPU_AVX512_FP16_FLAGS, 0 },
+  ARCH (generic32, GENERIC32, GENERIC32, false),
+  ARCH (generic64, GENERIC64, GENERIC64, false),
+  ARCH (i8086, UNKNOWN, NONE, false),
+  ARCH (i186, UNKNOWN, I186, false),
+  ARCH (i286, UNKNOWN, I286, false),
+  ARCH (i386, I386, I386, false),
+  ARCH (i486, I486, I486, false),
+  ARCH (i586, PENTIUM, I586, false),
+  ARCH (i686, PENTIUMPRO, I686, false),
+  ARCH (pentium, PENTIUM, I586, false),
+  ARCH (pentiumpro, PENTIUMPRO, PENTIUMPRO, false),
+  ARCH (pentiumii, PENTIUMPRO, P2, false),
+  ARCH (pentiumiii, PENTIUMPRO, P3, false),
+  ARCH (pentium4, PENTIUM4, P4, false),
+  ARCH (prescott, NOCONA, CORE, false),
+  ARCH (nocona, NOCONA, NOCONA, false),
+  ARCH (yonah, CORE, CORE, true),
+  ARCH (core, CORE, CORE, false),
+  ARCH (merom, CORE2, CORE2, true),
+  ARCH (core2, CORE2, CORE2, false),
+  ARCH (corei7, COREI7, COREI7, false),
+  ARCH (iamcu, IAMCU, IAMCU, false),
+  ARCH (k6, K6, K6, false),
+  ARCH (k6_2, K6, K6_2, false),
+  ARCH (athlon, ATHLON, ATHLON, false),
+  ARCH (sledgehammer, K8, K8, true),
+  ARCH (opteron, K8, K8, false),
+  ARCH (k8, K8, K8, false),
+  ARCH (amdfam10, AMDFAM10, AMDFAM10, false),
+  ARCH (bdver1, BD, BDVER1, false),
+  ARCH (bdver2, BD, BDVER2, false),
+  ARCH (bdver3, BD, BDVER3, false),
+  ARCH (bdver4, BD, BDVER4, false),
+  ARCH (znver1, ZNVER, ZNVER1, false),
+  ARCH (znver2, ZNVER, ZNVER2, false),
+  ARCH (znver3, ZNVER, ZNVER3, false),
+  ARCH (btver1, BT, BTVER1, false),
+  ARCH (btver2, BT, BTVER2, false),
+
+  SUBARCH (8087, 8087, false),
+  SUBARCH (287, 287, false),
+  SUBARCH (387, 387, false),
+  SUBARCH (687, 687, false),
+  SUBARCH (cmov, CMOV, false),
+  SUBARCH (fxsr, FXSR, false),
+  SUBARCH (mmx, MMX, false),
+  SUBARCH (sse, SSE, false),
+  SUBARCH (sse2, SSE2, false),
+  SUBARCH (sse3, SSE3, false),
+  SUBARCH (sse4a, SSE4A, false),
+  SUBARCH (ssse3, SSSE3, false),
+  SUBARCH (sse4.1, SSE4_1, false),
+  SUBARCH (sse4.2, SSE4_2, false),
+  SUBARCH (sse4, SSE4_2, false),
+  SUBARCH (avx, AVX, false),
+  SUBARCH (avx2, AVX2, false),
+  SUBARCH (avx512f, AVX512F, false),
+  SUBARCH (avx512cd, AVX512CD, false),
+  SUBARCH (avx512er, AVX512ER, false),
+  SUBARCH (avx512pf, AVX512PF, false),
+  SUBARCH (avx512dq, AVX512DQ, false),
+  SUBARCH (avx512bw, AVX512BW, false),
+  SUBARCH (avx512vl, AVX512VL, false),
+  SUBARCH (vmx, VMX, false),
+  SUBARCH (vmfunc, VMFUNC, false),
+  SUBARCH (smx, SMX, false),
+  SUBARCH (xsave, XSAVE, false),
+  SUBARCH (xsaveopt, XSAVEOPT, false),
+  SUBARCH (xsavec, XSAVEC, false),
+  SUBARCH (xsaves, XSAVES, false),
+  SUBARCH (aes, AES, false),
+  SUBARCH (pclmul, PCLMUL, false),
+  SUBARCH (clmul, PCLMUL, true),
+  SUBARCH (fsgsbase, FSGSBASE, false),
+  SUBARCH (rdrnd, RDRND, false),
+  SUBARCH (f16c, F16C, false),
+  SUBARCH (bmi2, BMI2, false),
+  SUBARCH (fma, FMA, false),
+  SUBARCH (fma4, FMA4, false),
+  SUBARCH (xop, XOP, false),
+  SUBARCH (lwp, LWP, false),
+  SUBARCH (movbe, MOVBE, false),
+  SUBARCH (cx16, CX16, false),
+  SUBARCH (ept, EPT, false),
+  SUBARCH (lzcnt, LZCNT, false),
+  SUBARCH (popcnt, POPCNT, false),
+  SUBARCH (hle, HLE, false),
+  SUBARCH (rtm, RTM, false),
+  SUBARCH (invpcid, INVPCID, false),
+  SUBARCH (clflush, CLFLUSH, false),
+  SUBARCH (nop, NOP, false),
+  SUBARCH (syscall, SYSCALL, false),
+  SUBARCH (rdtscp, RDTSCP, false),
+  SUBARCH (3dnow, 3DNOW, false),
+  SUBARCH (3dnowa, 3DNOWA, false),
+  SUBARCH (padlock, PADLOCK, false),
+  SUBARCH (pacifica, SVME, true),
+  SUBARCH (svme, SVME, false),
+  SUBARCH (sse4a, SSE4A, false),
+  SUBARCH (abm, ABM, false),
+  SUBARCH (bmi, BMI, false),
+  SUBARCH (tbm, TBM, false),
+  SUBARCH (adx, ADX, false),
+  SUBARCH (rdseed, RDSEED, false),
+  SUBARCH (prfchw, PRFCHW, false),
+  SUBARCH (smap, SMAP, false),
+  SUBARCH (mpx, MPX, false),
+  SUBARCH (sha, SHA, false),
+  SUBARCH (clflushopt, CLFLUSHOPT, false),
+  SUBARCH (prefetchwt1, PREFETCHWT1, false),
+  SUBARCH (se1, SE1, false),
+  SUBARCH (clwb, CLWB, false),
+  SUBARCH (avx512ifma, AVX512IFMA, false),
+  SUBARCH (avx512vbmi, AVX512VBMI, false),
+  SUBARCH (avx512_4fmaps, AVX512_4FMAPS, false),
+  SUBARCH (avx512_4vnniw, AVX512_4VNNIW, false),
+  SUBARCH (avx512_vpopcntdq, AVX512_VPOPCNTDQ, false),
+  SUBARCH (avx512_vbmi2, AVX512_VBMI2, false),
+  SUBARCH (avx512_vnni, AVX512_VNNI, false),
+  SUBARCH (avx512_bitalg, AVX512_BITALG, false),
+  SUBARCH (avx_vnni, AVX_VNNI, false),
+  SUBARCH (clzero, CLZERO, false),
+  SUBARCH (mwaitx, MWAITX, false),
+  SUBARCH (ospke, OSPKE, false),
+  SUBARCH (rdpid, RDPID, false),
+  SUBARCH (ptwrite, PTWRITE, false),
+  SUBARCH (ibt, IBT, false),
+  SUBARCH (shstk, SHSTK, false),
+  SUBARCH (gfni, GFNI, false),
+  SUBARCH (vaes, VAES, false),
+  SUBARCH (vpclmulqdq, VPCLMULQDQ, false),
+  SUBARCH (wbnoinvd, WBNOINVD, false),
+  SUBARCH (pconfig, PCONFIG, false),
+  SUBARCH (waitpkg, WAITPKG, false),
+  SUBARCH (cldemote, CLDEMOTE, false),
+  SUBARCH (amx_int8, AMX_INT8, false),
+  SUBARCH (amx_bf16, AMX_BF16, false),
+  SUBARCH (amx_tile, AMX_TILE, false),
+  SUBARCH (movdiri, MOVDIRI, false),
+  SUBARCH (movdir64b, MOVDIR64B, false),
+  SUBARCH (avx512_bf16, AVX512_BF16, false),
+  SUBARCH (avx512_vp2intersect, AVX512_VP2INTERSECT, false),
+  SUBARCH (tdx, TDX, false),
+  SUBARCH (enqcmd, ENQCMD, false),
+  SUBARCH (serialize, SERIALIZE, false),
+  SUBARCH (rdpru, RDPRU, false),
+  SUBARCH (mcommit, MCOMMIT, false),
+  SUBARCH (sev_es, SEV_ES, false),
+  SUBARCH (tsxldtrk, TSXLDTRK, false),
+  SUBARCH (kl, KL, false),
+  SUBARCH (widekl, WIDEKL, false),
+  SUBARCH (uintr, UINTR, false),
+  SUBARCH (hreset, HRESET, false),
+  SUBARCH (avx512_fp16, AVX512_FP16, false),
 };
 
+#undef SUBARCH
+#undef ARCH
+
 static const noarch_entry cpu_noarch[] =
 {
   { STRING_COMMA_LEN ("no87"),  CPU_ANY_X87_FLAGS },


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 5/7] x86: introduce fake processor type to mark sub-arch entries in cpu_arch[]
  2022-06-30 12:52 [PATCH] gas/x86: .arch / -march= enhancements Jan Beulich
                   ` (3 preceding siblings ...)
  2022-06-30 12:54 ` [PATCH 4/7] x86: macro-ize cpu_arch[] entries Jan Beulich
@ 2022-06-30 12:54 ` Jan Beulich
  2022-06-30 23:03   ` H.J. Lu
  2022-06-30 12:55 ` [PATCH 6/7] x86: generalize disabling of sub-architectures Jan Beulich
  2022-06-30 12:55 ` [PATCH 7/7] x86: introduce a state stack for .arch Jan Beulich
  6 siblings, 1 reply; 17+ messages in thread
From: Jan Beulich @ 2022-06-30 12:54 UTC (permalink / raw)
  To: Binutils

This is in preparation of dropping the leading . from the strings.

While there also move PROCESSOR_GENERIC{32,64} from the middle of AMD
entries to near the top.

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -934,7 +934,7 @@ const relax_typeS md_relax_table[] =
 #define ARCH(n, t, f, s) \
   { STRING_COMMA_LEN (#n), s, PROCESSOR_ ## t, CPU_ ## f ## _FLAGS }
 #define SUBARCH(n, e, s) \
-  { STRING_COMMA_LEN ("." #n), s, PROCESSOR_UNKNOWN, CPU_ ## e ## _FLAGS }
+  { STRING_COMMA_LEN ("." #n), s, PROCESSOR_NONE, CPU_ ## e ## _FLAGS }
 
 static const arch_entry cpu_arch[] =
 {
@@ -1471,6 +1471,8 @@ i386_generate_nops (fragS *fragP, char *
 	    case PROCESSOR_GENERIC32:
 	      patt = f32_patt;
 	      break;
+	    case PROCESSOR_NONE:
+	      abort ();
 	    }
 	}
       else
@@ -1516,6 +1518,8 @@ i386_generate_nops (fragS *fragP, char *
 	    case PROCESSOR_GENERIC64:
 	      patt = alt_patt;
 	      break;
+	    case PROCESSOR_NONE:
+	      abort ();
 	    }
 	}
 
--- a/gas/config/tc-i386.h
+++ b/gas/config/tc-i386.h
@@ -228,6 +228,8 @@ extern long i386_generic_table_relax_fra
 enum processor_type
 {
   PROCESSOR_UNKNOWN,
+  PROCESSOR_GENERIC32,
+  PROCESSOR_GENERIC64,
   PROCESSOR_I386,
   PROCESSOR_I486,
   PROCESSOR_PENTIUM,
@@ -241,12 +243,12 @@ enum processor_type
   PROCESSOR_K6,
   PROCESSOR_ATHLON,
   PROCESSOR_K8,
-  PROCESSOR_GENERIC32,
-  PROCESSOR_GENERIC64,
   PROCESSOR_AMDFAM10,
   PROCESSOR_BD,
   PROCESSOR_ZNVER,
-  PROCESSOR_BT
+  PROCESSOR_BT,
+  /* Keep this last.  */
+  PROCESSOR_NONE
 };
 
 extern enum processor_type cpu_arch_tune;


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 6/7] x86: generalize disabling of sub-architectures
  2022-06-30 12:52 [PATCH] gas/x86: .arch / -march= enhancements Jan Beulich
                   ` (4 preceding siblings ...)
  2022-06-30 12:54 ` [PATCH 5/7] x86: introduce fake processor type to mark sub-arch entries in cpu_arch[] Jan Beulich
@ 2022-06-30 12:55 ` Jan Beulich
  2022-06-30 23:11   ` H.J. Lu
  2022-06-30 12:55 ` [PATCH 7/7] x86: introduce a state stack for .arch Jan Beulich
  6 siblings, 1 reply; 17+ messages in thread
From: Jan Beulich @ 2022-06-30 12:55 UTC (permalink / raw)
  To: Binutils

I never really understood upon what basis ".arch .no*" options were made
available. Let's not have any "criteria" at all, and simply allow
disabling of all of them. Then we also have all data for a sub-arch in
a single place, as we now only need a single table.
---
For now I've re-used all CPU_ANY_*_FLAGS there were, but I think we
might be better off introducing such only once dependent features
appear. Until then the base CPU_*_FLAGS can very well be used, just like
done here in all cases where there was no suitable CPU_ANY_*_FLAGS.

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -129,19 +129,11 @@ typedef struct
   unsigned int len:8;		/* arch string length */
   bool skip:1;			/* show_arch should skip this. */
   enum processor_type type;	/* arch type */
-  i386_cpu_flags flags;		/* cpu feature flags */
+  i386_cpu_flags enable;		/* cpu feature enable flags */
+  i386_cpu_flags disable;	/* cpu feature disable flags */
 }
 arch_entry;
 
-/* Used to turn off indicated flags.  */
-typedef struct
-{
-  const char *name;		/* arch name */
-  unsigned int len;		/* arch string length */
-  i386_cpu_flags flags;		/* cpu feature flags */
-}
-noarch_entry;
-
 static void update_code_flag (int, int);
 static void set_code_flag (int);
 static void set_16bit_gcc_code_flag (int);
@@ -932,9 +924,11 @@ const relax_typeS md_relax_table[] =
 };
 
 #define ARCH(n, t, f, s) \
-  { STRING_COMMA_LEN (#n), s, PROCESSOR_ ## t, CPU_ ## f ## _FLAGS }
-#define SUBARCH(n, e, s) \
-  { STRING_COMMA_LEN ("." #n), s, PROCESSOR_NONE, CPU_ ## e ## _FLAGS }
+  { STRING_COMMA_LEN (#n), s, PROCESSOR_ ## t, CPU_ ## f ## _FLAGS, \
+    CPU_NONE_FLAGS }
+#define SUBARCH(n, e, d, s) \
+  { STRING_COMMA_LEN (#n), s, PROCESSOR_NONE, CPU_ ## e ## _FLAGS, \
+    CPU_ ## d ## _FLAGS }
 
 static const arch_entry cpu_arch[] =
 {
@@ -979,182 +973,128 @@ static const arch_entry cpu_arch[] =
   ARCH (btver1, BT, BTVER1, false),
   ARCH (btver2, BT, BTVER2, false),
 
-  SUBARCH (8087, 8087, false),
-  SUBARCH (287, 287, false),
-  SUBARCH (387, 387, false),
-  SUBARCH (687, 687, false),
-  SUBARCH (cmov, CMOV, false),
-  SUBARCH (fxsr, FXSR, false),
-  SUBARCH (mmx, MMX, false),
-  SUBARCH (sse, SSE, false),
-  SUBARCH (sse2, SSE2, false),
-  SUBARCH (sse3, SSE3, false),
-  SUBARCH (sse4a, SSE4A, false),
-  SUBARCH (ssse3, SSSE3, false),
-  SUBARCH (sse4.1, SSE4_1, false),
-  SUBARCH (sse4.2, SSE4_2, false),
-  SUBARCH (sse4, SSE4_2, false),
-  SUBARCH (avx, AVX, false),
-  SUBARCH (avx2, AVX2, false),
-  SUBARCH (avx512f, AVX512F, false),
-  SUBARCH (avx512cd, AVX512CD, false),
-  SUBARCH (avx512er, AVX512ER, false),
-  SUBARCH (avx512pf, AVX512PF, false),
-  SUBARCH (avx512dq, AVX512DQ, false),
-  SUBARCH (avx512bw, AVX512BW, false),
-  SUBARCH (avx512vl, AVX512VL, false),
-  SUBARCH (vmx, VMX, false),
-  SUBARCH (vmfunc, VMFUNC, false),
-  SUBARCH (smx, SMX, false),
-  SUBARCH (xsave, XSAVE, false),
-  SUBARCH (xsaveopt, XSAVEOPT, false),
-  SUBARCH (xsavec, XSAVEC, false),
-  SUBARCH (xsaves, XSAVES, false),
-  SUBARCH (aes, AES, false),
-  SUBARCH (pclmul, PCLMUL, false),
-  SUBARCH (clmul, PCLMUL, true),
-  SUBARCH (fsgsbase, FSGSBASE, false),
-  SUBARCH (rdrnd, RDRND, false),
-  SUBARCH (f16c, F16C, false),
-  SUBARCH (bmi2, BMI2, false),
-  SUBARCH (fma, FMA, false),
-  SUBARCH (fma4, FMA4, false),
-  SUBARCH (xop, XOP, false),
-  SUBARCH (lwp, LWP, false),
-  SUBARCH (movbe, MOVBE, false),
-  SUBARCH (cx16, CX16, false),
-  SUBARCH (ept, EPT, false),
-  SUBARCH (lzcnt, LZCNT, false),
-  SUBARCH (popcnt, POPCNT, false),
-  SUBARCH (hle, HLE, false),
-  SUBARCH (rtm, RTM, false),
-  SUBARCH (invpcid, INVPCID, false),
-  SUBARCH (clflush, CLFLUSH, false),
-  SUBARCH (nop, NOP, false),
-  SUBARCH (syscall, SYSCALL, false),
-  SUBARCH (rdtscp, RDTSCP, false),
-  SUBARCH (3dnow, 3DNOW, false),
-  SUBARCH (3dnowa, 3DNOWA, false),
-  SUBARCH (padlock, PADLOCK, false),
-  SUBARCH (pacifica, SVME, true),
-  SUBARCH (svme, SVME, false),
-  SUBARCH (sse4a, SSE4A, false),
-  SUBARCH (abm, ABM, false),
-  SUBARCH (bmi, BMI, false),
-  SUBARCH (tbm, TBM, false),
-  SUBARCH (adx, ADX, false),
-  SUBARCH (rdseed, RDSEED, false),
-  SUBARCH (prfchw, PRFCHW, false),
-  SUBARCH (smap, SMAP, false),
-  SUBARCH (mpx, MPX, false),
-  SUBARCH (sha, SHA, false),
-  SUBARCH (clflushopt, CLFLUSHOPT, false),
-  SUBARCH (prefetchwt1, PREFETCHWT1, false),
-  SUBARCH (se1, SE1, false),
-  SUBARCH (clwb, CLWB, false),
-  SUBARCH (avx512ifma, AVX512IFMA, false),
-  SUBARCH (avx512vbmi, AVX512VBMI, false),
-  SUBARCH (avx512_4fmaps, AVX512_4FMAPS, false),
-  SUBARCH (avx512_4vnniw, AVX512_4VNNIW, false),
-  SUBARCH (avx512_vpopcntdq, AVX512_VPOPCNTDQ, false),
-  SUBARCH (avx512_vbmi2, AVX512_VBMI2, false),
-  SUBARCH (avx512_vnni, AVX512_VNNI, false),
-  SUBARCH (avx512_bitalg, AVX512_BITALG, false),
-  SUBARCH (avx_vnni, AVX_VNNI, false),
-  SUBARCH (clzero, CLZERO, false),
-  SUBARCH (mwaitx, MWAITX, false),
-  SUBARCH (ospke, OSPKE, false),
-  SUBARCH (rdpid, RDPID, false),
-  SUBARCH (ptwrite, PTWRITE, false),
-  SUBARCH (ibt, IBT, false),
-  SUBARCH (shstk, SHSTK, false),
-  SUBARCH (gfni, GFNI, false),
-  SUBARCH (vaes, VAES, false),
-  SUBARCH (vpclmulqdq, VPCLMULQDQ, false),
-  SUBARCH (wbnoinvd, WBNOINVD, false),
-  SUBARCH (pconfig, PCONFIG, false),
-  SUBARCH (waitpkg, WAITPKG, false),
-  SUBARCH (cldemote, CLDEMOTE, false),
-  SUBARCH (amx_int8, AMX_INT8, false),
-  SUBARCH (amx_bf16, AMX_BF16, false),
-  SUBARCH (amx_tile, AMX_TILE, false),
-  SUBARCH (movdiri, MOVDIRI, false),
-  SUBARCH (movdir64b, MOVDIR64B, false),
-  SUBARCH (avx512_bf16, AVX512_BF16, false),
-  SUBARCH (avx512_vp2intersect, AVX512_VP2INTERSECT, false),
-  SUBARCH (tdx, TDX, false),
-  SUBARCH (enqcmd, ENQCMD, false),
-  SUBARCH (serialize, SERIALIZE, false),
-  SUBARCH (rdpru, RDPRU, false),
-  SUBARCH (mcommit, MCOMMIT, false),
-  SUBARCH (sev_es, SEV_ES, false),
-  SUBARCH (tsxldtrk, TSXLDTRK, false),
-  SUBARCH (kl, KL, false),
-  SUBARCH (widekl, WIDEKL, false),
-  SUBARCH (uintr, UINTR, false),
-  SUBARCH (hreset, HRESET, false),
-  SUBARCH (avx512_fp16, AVX512_FP16, false),
+  SUBARCH (8087, 8087, ANY_X87, false),
+  SUBARCH (87, NONE, ANY_X87, false), /* Disable only!  */
+  SUBARCH (287, 287, ANY_287, false),
+  SUBARCH (387, 387, ANY_387, false),
+  SUBARCH (687, 687, ANY_687, false),
+  SUBARCH (cmov, CMOV, ANY_CMOV, false),
+  SUBARCH (fxsr, FXSR, ANY_FXSR, false),
+  SUBARCH (mmx, MMX, ANY_MMX, false),
+  SUBARCH (sse, SSE, ANY_SSE, false),
+  SUBARCH (sse2, SSE2, ANY_SSE2, false),
+  SUBARCH (sse3, SSE3, ANY_SSE3, false),
+  SUBARCH (sse4a, SSE4A, ANY_SSE4A, false),
+  SUBARCH (ssse3, SSSE3, ANY_SSSE3, false),
+  SUBARCH (sse4.1, SSE4_1, ANY_SSE4_1, false),
+  SUBARCH (sse4.2, SSE4_2, ANY_SSE4_2, false),
+  SUBARCH (sse4, SSE4_2, ANY_SSE4_1, false),
+  SUBARCH (avx, AVX, ANY_AVX, false),
+  SUBARCH (avx2, AVX2, ANY_AVX2, false),
+  SUBARCH (avx512f, AVX512F, ANY_AVX512F, false),
+  SUBARCH (avx512cd, AVX512CD, ANY_AVX512CD, false),
+  SUBARCH (avx512er, AVX512ER, ANY_AVX512ER, false),
+  SUBARCH (avx512pf, AVX512PF, ANY_AVX512PF, false),
+  SUBARCH (avx512dq, AVX512DQ, ANY_AVX512DQ, false),
+  SUBARCH (avx512bw, AVX512BW, ANY_AVX512BW, false),
+  SUBARCH (avx512vl, AVX512VL, ANY_AVX512VL, false),
+  SUBARCH (vmx, VMX, VMX, false),
+  SUBARCH (vmfunc, VMFUNC, VMFUNC, false),
+  SUBARCH (smx, SMX, SMX, false),
+  SUBARCH (xsave, XSAVE, XSAVE, false),
+  SUBARCH (xsaveopt, XSAVEOPT, XSAVEOPT, false),
+  SUBARCH (xsavec, XSAVEC, XSAVEC, false),
+  SUBARCH (xsaves, XSAVES, XSAVES, false),
+  SUBARCH (aes, AES, AES, false),
+  SUBARCH (pclmul, PCLMUL, PCLMUL, false),
+  SUBARCH (clmul, PCLMUL, PCLMUL, true),
+  SUBARCH (fsgsbase, FSGSBASE, FSGSBASE, false),
+  SUBARCH (rdrnd, RDRND, RDRND, false),
+  SUBARCH (f16c, F16C, F16C, false),
+  SUBARCH (bmi2, BMI2, BMI2, false),
+  SUBARCH (fma, FMA, FMA, false),
+  SUBARCH (fma4, FMA4, FMA4, false),
+  SUBARCH (xop, XOP, XOP, false),
+  SUBARCH (lwp, LWP, LWP, false),
+  SUBARCH (movbe, MOVBE, MOVBE, false),
+  SUBARCH (cx16, CX16, CX16, false),
+  SUBARCH (ept, EPT, EPT, false),
+  SUBARCH (lzcnt, LZCNT, LZCNT, false),
+  SUBARCH (popcnt, POPCNT, POPCNT, false),
+  SUBARCH (hle, HLE, HLE, false),
+  SUBARCH (rtm, RTM, RTM, false),
+  SUBARCH (invpcid, INVPCID, INVPCID, false),
+  SUBARCH (clflush, CLFLUSH, CLFLUSH, false),
+  SUBARCH (nop, NOP, NOP, false),
+  SUBARCH (syscall, SYSCALL, SYSCALL, false),
+  SUBARCH (rdtscp, RDTSCP, RDTSCP, false),
+  SUBARCH (3dnow, 3DNOW, 3DNOW, false),
+  SUBARCH (3dnowa, 3DNOWA, 3DNOWA, false),
+  SUBARCH (padlock, PADLOCK, PADLOCK, false),
+  SUBARCH (pacifica, SVME, SVME, true),
+  SUBARCH (svme, SVME, SVME, false),
+  SUBARCH (sse4a, SSE4A, SSE4A, false),
+  SUBARCH (abm, ABM, ABM, false),
+  SUBARCH (bmi, BMI, BMI, false),
+  SUBARCH (tbm, TBM, TBM, false),
+  SUBARCH (adx, ADX, ADX, false),
+  SUBARCH (rdseed, RDSEED, RDSEED, false),
+  SUBARCH (prfchw, PRFCHW, PRFCHW, false),
+  SUBARCH (smap, SMAP, SMAP, false),
+  SUBARCH (mpx, MPX, MPX, false),
+  SUBARCH (sha, SHA, SHA, false),
+  SUBARCH (clflushopt, CLFLUSHOPT, CLFLUSHOPT, false),
+  SUBARCH (prefetchwt1, PREFETCHWT1, PREFETCHWT1, false),
+  SUBARCH (se1, SE1, SE1, false),
+  SUBARCH (clwb, CLWB, CLWB, false),
+  SUBARCH (avx512ifma, AVX512IFMA, ANY_AVX512IFMA, false),
+  SUBARCH (avx512vbmi, AVX512VBMI, ANY_AVX512VBMI, false),
+  SUBARCH (avx512_4fmaps, AVX512_4FMAPS, ANY_AVX512_4FMAPS, false),
+  SUBARCH (avx512_4vnniw, AVX512_4VNNIW, ANY_AVX512_4VNNIW, false),
+  SUBARCH (avx512_vpopcntdq, AVX512_VPOPCNTDQ, ANY_AVX512_VPOPCNTDQ, false),
+  SUBARCH (avx512_vbmi2, AVX512_VBMI2, ANY_AVX512_VBMI2, false),
+  SUBARCH (avx512_vnni, AVX512_VNNI, ANY_AVX512_VNNI, false),
+  SUBARCH (avx512_bitalg, AVX512_BITALG, ANY_AVX512_BITALG, false),
+  SUBARCH (avx_vnni, AVX_VNNI, ANY_AVX_VNNI, false),
+  SUBARCH (clzero, CLZERO, CLZERO, false),
+  SUBARCH (mwaitx, MWAITX, MWAITX, false),
+  SUBARCH (ospke, OSPKE, OSPKE, false),
+  SUBARCH (rdpid, RDPID, RDPID, false),
+  SUBARCH (ptwrite, PTWRITE, PTWRITE, false),
+  SUBARCH (ibt, IBT, ANY_IBT, false),
+  SUBARCH (shstk, SHSTK, ANY_SHSTK, false),
+  SUBARCH (gfni, GFNI, GFNI, false),
+  SUBARCH (vaes, VAES, VAES, false),
+  SUBARCH (vpclmulqdq, VPCLMULQDQ, VPCLMULQDQ, false),
+  SUBARCH (wbnoinvd, WBNOINVD, WBNOINVD, false),
+  SUBARCH (pconfig, PCONFIG, PCONFIG, false),
+  SUBARCH (waitpkg, WAITPKG, WAITPKG, false),
+  SUBARCH (cldemote, CLDEMOTE, CLDEMOTE, false),
+  SUBARCH (amx_int8, AMX_INT8, ANY_AMX_INT8, false),
+  SUBARCH (amx_bf16, AMX_BF16, ANY_AMX_BF16, false),
+  SUBARCH (amx_tile, AMX_TILE, ANY_AMX_TILE, false),
+  SUBARCH (movdiri, MOVDIRI, ANY_MOVDIRI, false),
+  SUBARCH (movdir64b, MOVDIR64B, ANY_MOVDIR64B, false),
+  SUBARCH (avx512_bf16, AVX512_BF16, ANY_AVX512_BF16, false),
+  SUBARCH (avx512_vp2intersect, AVX512_VP2INTERSECT,
+	   ANY_AVX512_VP2INTERSECT, false),
+  SUBARCH (tdx, TDX, ANY_TDX, false),
+  SUBARCH (enqcmd, ENQCMD, ANY_ENQCMD, false),
+  SUBARCH (serialize, SERIALIZE, ANY_SERIALIZE, false),
+  SUBARCH (rdpru, RDPRU, RDPRU, false),
+  SUBARCH (mcommit, MCOMMIT, MCOMMIT, false),
+  SUBARCH (sev_es, SEV_ES, SEV_ES, false),
+  SUBARCH (tsxldtrk, TSXLDTRK, ANY_TSXLDTRK, false),
+  SUBARCH (kl, KL, ANY_KL, false),
+  SUBARCH (widekl, WIDEKL, ANY_WIDEKL, false),
+  SUBARCH (uintr, UINTR, ANY_UINTR, false),
+  SUBARCH (hreset, HRESET, ANY_HRESET, false),
+  SUBARCH (avx512_fp16, AVX512_FP16, ANY_AVX512_FP16, false),
 };
 
 #undef SUBARCH
 #undef ARCH
 
-static const noarch_entry cpu_noarch[] =
-{
-  { STRING_COMMA_LEN ("no87"),  CPU_ANY_X87_FLAGS },
-  { STRING_COMMA_LEN ("no287"),  CPU_ANY_287_FLAGS },
-  { STRING_COMMA_LEN ("no387"),  CPU_ANY_387_FLAGS },
-  { STRING_COMMA_LEN ("no687"),  CPU_ANY_687_FLAGS },
-  { STRING_COMMA_LEN ("nocmov"),  CPU_ANY_CMOV_FLAGS },
-  { STRING_COMMA_LEN ("nofxsr"),  CPU_ANY_FXSR_FLAGS },
-  { STRING_COMMA_LEN ("nommx"),  CPU_ANY_MMX_FLAGS },
-  { STRING_COMMA_LEN ("nosse"),  CPU_ANY_SSE_FLAGS },
-  { STRING_COMMA_LEN ("nosse2"),  CPU_ANY_SSE2_FLAGS },
-  { STRING_COMMA_LEN ("nosse3"),  CPU_ANY_SSE3_FLAGS },
-  { STRING_COMMA_LEN ("nosse4a"),  CPU_ANY_SSE4A_FLAGS },
-  { STRING_COMMA_LEN ("nossse3"),  CPU_ANY_SSSE3_FLAGS },
-  { STRING_COMMA_LEN ("nosse4.1"),  CPU_ANY_SSE4_1_FLAGS },
-  { STRING_COMMA_LEN ("nosse4.2"),  CPU_ANY_SSE4_2_FLAGS },
-  { STRING_COMMA_LEN ("nosse4"),  CPU_ANY_SSE4_1_FLAGS },
-  { STRING_COMMA_LEN ("noavx"),  CPU_ANY_AVX_FLAGS },
-  { STRING_COMMA_LEN ("noavx2"),  CPU_ANY_AVX2_FLAGS },
-  { STRING_COMMA_LEN ("noavx512f"), CPU_ANY_AVX512F_FLAGS },
-  { STRING_COMMA_LEN ("noavx512cd"), CPU_ANY_AVX512CD_FLAGS },
-  { STRING_COMMA_LEN ("noavx512er"), CPU_ANY_AVX512ER_FLAGS },
-  { STRING_COMMA_LEN ("noavx512pf"), CPU_ANY_AVX512PF_FLAGS },
-  { STRING_COMMA_LEN ("noavx512dq"), CPU_ANY_AVX512DQ_FLAGS },
-  { STRING_COMMA_LEN ("noavx512bw"), CPU_ANY_AVX512BW_FLAGS },
-  { STRING_COMMA_LEN ("noavx512vl"), CPU_ANY_AVX512VL_FLAGS },
-  { STRING_COMMA_LEN ("noavx512ifma"), CPU_ANY_AVX512IFMA_FLAGS },
-  { STRING_COMMA_LEN ("noavx512vbmi"), CPU_ANY_AVX512VBMI_FLAGS },
-  { STRING_COMMA_LEN ("noavx512_4fmaps"), CPU_ANY_AVX512_4FMAPS_FLAGS },
-  { STRING_COMMA_LEN ("noavx512_4vnniw"), CPU_ANY_AVX512_4VNNIW_FLAGS },
-  { STRING_COMMA_LEN ("noavx512_vpopcntdq"), CPU_ANY_AVX512_VPOPCNTDQ_FLAGS },
-  { STRING_COMMA_LEN ("noavx512_vbmi2"), CPU_ANY_AVX512_VBMI2_FLAGS },
-  { STRING_COMMA_LEN ("noavx512_vnni"), CPU_ANY_AVX512_VNNI_FLAGS },
-  { STRING_COMMA_LEN ("noavx512_bitalg"), CPU_ANY_AVX512_BITALG_FLAGS },
-  { STRING_COMMA_LEN ("noavx_vnni"), CPU_ANY_AVX_VNNI_FLAGS },
-  { STRING_COMMA_LEN ("noibt"), CPU_ANY_IBT_FLAGS },
-  { STRING_COMMA_LEN ("noshstk"), CPU_ANY_SHSTK_FLAGS },
-  { STRING_COMMA_LEN ("noamx_int8"), CPU_ANY_AMX_INT8_FLAGS },
-  { STRING_COMMA_LEN ("noamx_bf16"), CPU_ANY_AMX_BF16_FLAGS },
-  { STRING_COMMA_LEN ("noamx_tile"), CPU_ANY_AMX_TILE_FLAGS },
-  { STRING_COMMA_LEN ("nomovdiri"), CPU_ANY_MOVDIRI_FLAGS },
-  { STRING_COMMA_LEN ("nomovdir64b"), CPU_ANY_MOVDIR64B_FLAGS },
-  { STRING_COMMA_LEN ("noavx512_bf16"), CPU_ANY_AVX512_BF16_FLAGS },
-  { STRING_COMMA_LEN ("noavx512_vp2intersect"),
-    CPU_ANY_AVX512_VP2INTERSECT_FLAGS },
-  { STRING_COMMA_LEN ("notdx"), CPU_ANY_TDX_FLAGS },
-  { STRING_COMMA_LEN ("noenqcmd"), CPU_ANY_ENQCMD_FLAGS },
-  { STRING_COMMA_LEN ("noserialize"), CPU_ANY_SERIALIZE_FLAGS },
-  { STRING_COMMA_LEN ("notsxldtrk"), CPU_ANY_TSXLDTRK_FLAGS },
-  { STRING_COMMA_LEN ("nokl"), CPU_ANY_KL_FLAGS },
-  { STRING_COMMA_LEN ("nowidekl"), CPU_ANY_WIDEKL_FLAGS },
-  { STRING_COMMA_LEN ("nouintr"), CPU_ANY_UINTR_FLAGS },
-  { STRING_COMMA_LEN ("nohreset"), CPU_ANY_HRESET_FLAGS },
-  { STRING_COMMA_LEN ("noavx512_fp16"), CPU_ANY_AVX512_FP16_FLAGS },
-};
-
 #ifdef I386COFF
 /* Like s_lcomm_internal in gas/read.c but the alignment string
    is allowed to be optional.  */
@@ -2715,9 +2655,9 @@ extend_cpu_sub_arch_name (const char *na
 {
   if (cpu_sub_arch_name)
     cpu_sub_arch_name = reconcat (cpu_sub_arch_name, cpu_sub_arch_name,
-				  name, (const char *) NULL);
+				  ".", name, (const char *) NULL);
   else
-    cpu_sub_arch_name = xstrdup (name);
+    cpu_sub_arch_name = concat (".", name, (const char *) NULL);
 }
 
 static void
@@ -2756,7 +2696,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
 		  cpu_arch_flags.bitfield.cpuno64 = 1;
 		}
 	      cpu_arch_isa = PROCESSOR_UNKNOWN;
-	      cpu_arch_isa_flags = cpu_arch[flag_code == CODE_64BIT].flags;
+	      cpu_arch_isa_flags = cpu_arch[flag_code == CODE_64BIT].enable;
 	      if (!cpu_arch_tune_set)
 		{
 		  cpu_arch_tune = cpu_arch_isa;
@@ -2769,16 +2709,17 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
 
       for (; j < ARRAY_SIZE (cpu_arch); j++)
 	{
-	  if (strcmp (string, cpu_arch[j].name) == 0)
+	  if (strcmp (string + (*string == '.'), cpu_arch[j].name) == 0
+	     && (*string == '.') == (cpu_arch[j].type == PROCESSOR_NONE))
 	    {
 	      if (*string != '.')
 		{
-		  check_cpu_arch_compatible (string, cpu_arch[j].flags);
+		  check_cpu_arch_compatible (string, cpu_arch[j].enable);
 
 		  cpu_arch_name = cpu_arch[j].name;
 		  xfree (cpu_sub_arch_name);
 		  cpu_sub_arch_name = NULL;
-		  cpu_arch_flags = cpu_arch[j].flags;
+		  cpu_arch_flags = cpu_arch[j].enable;
 		  if (flag_code == CODE_64BIT)
 		    {
 		      cpu_arch_flags.bitfield.cpu64 = 1;
@@ -2790,7 +2731,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
 		      cpu_arch_flags.bitfield.cpuno64 = 1;
 		    }
 		  cpu_arch_isa = cpu_arch[j].type;
-		  cpu_arch_isa_flags = cpu_arch[j].flags;
+		  cpu_arch_isa_flags = cpu_arch[j].enable;
 		  if (!cpu_arch_tune_set)
 		    {
 		      cpu_arch_tune = cpu_arch_isa;
@@ -2799,36 +2740,40 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
 		  break;
 		}
 
+	      if (cpu_flags_all_zero (&cpu_arch[j].enable))
+	        continue;
+
 	      flags = cpu_flags_or (cpu_arch_flags,
-				    cpu_arch[j].flags);
+				    cpu_arch[j].enable);
 
 	      if (!cpu_flags_equal (&flags, &cpu_arch_flags))
 		{
-		  extend_cpu_sub_arch_name (string);
+		  extend_cpu_sub_arch_name (string + 1);
 		  cpu_arch_flags = flags;
 		  cpu_arch_isa_flags = flags;
 		}
 	      else
 		cpu_arch_isa_flags
 		  = cpu_flags_or (cpu_arch_isa_flags,
-				  cpu_arch[j].flags);
+				  cpu_arch[j].enable);
 	      (void) restore_line_pointer (e);
 	      demand_empty_rest_of_line ();
 	      return;
 	    }
 	}
 
-      if (*string == '.' && j >= ARRAY_SIZE (cpu_arch))
+      if (startswith (string, ".no") && j >= ARRAY_SIZE (cpu_arch))
 	{
 	  /* Disable an ISA extension.  */
-	  for (j = 0; j < ARRAY_SIZE (cpu_noarch); j++)
-	    if (strcmp (string + 1, cpu_noarch [j].name) == 0)
+	  for (j = 0; j < ARRAY_SIZE (cpu_arch); j++)
+	    if (cpu_arch[j].type == PROCESSOR_NONE
+	        && strcmp (string + 3, cpu_arch[j].name) == 0)
 	      {
 		flags = cpu_flags_and_not (cpu_arch_flags,
-					   cpu_noarch[j].flags);
+					   cpu_arch[j].disable);
 		if (!cpu_flags_equal (&flags, &cpu_arch_flags))
 		  {
-		    extend_cpu_sub_arch_name (string);
+		    extend_cpu_sub_arch_name (string + 1);
 		    cpu_arch_flags = flags;
 		    cpu_arch_isa_flags = flags;
 		  }
@@ -2836,8 +2781,6 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
 		demand_empty_rest_of_line ();
 		return;
 	      }
-
-	  j = ARRAY_SIZE (cpu_arch);
 	}
 
       if (j == ARRAY_SIZE (cpu_arch))
@@ -13288,18 +13231,19 @@ md_parse_option (int c, const char *arg)
 	    *next++ = '\0';
 	  for (j = 0; j < ARRAY_SIZE (cpu_arch); j++)
 	    {
-	      if (arch == saved && strcmp (arch, cpu_arch [j].name) == 0)
+	      if (arch == saved && cpu_arch[j].type != PROCESSOR_NONE
+	          && strcmp (arch, cpu_arch[j].name) == 0)
 		{
 		  /* Processor.  */
-		  if (! cpu_arch[j].flags.bitfield.cpui386)
+		  if (! cpu_arch[j].enable.bitfield.cpui386)
 		    continue;
 
 		  cpu_arch_name = cpu_arch[j].name;
 		  xfree (cpu_sub_arch_name);
 		  cpu_sub_arch_name = NULL;
-		  cpu_arch_flags = cpu_arch[j].flags;
+		  cpu_arch_flags = cpu_arch[j].enable;
 		  cpu_arch_isa = cpu_arch[j].type;
-		  cpu_arch_isa_flags = cpu_arch[j].flags;
+		  cpu_arch_isa_flags = cpu_arch[j].enable;
 		  if (!cpu_arch_tune_set)
 		    {
 		      cpu_arch_tune = cpu_arch_isa;
@@ -13307,39 +13251,41 @@ md_parse_option (int c, const char *arg)
 		    }
 		  break;
 		}
-	      else if (*cpu_arch [j].name == '.'
-		       && strcmp (arch, cpu_arch [j].name + 1) == 0)
+	      else if (cpu_arch[j].type == PROCESSOR_NONE
+		       && strcmp (arch, cpu_arch[j].name) == 0
+		       && !cpu_flags_all_zero (&cpu_arch[j].enable))
 		{
 		  /* ISA extension.  */
 		  i386_cpu_flags flags;
 
 		  flags = cpu_flags_or (cpu_arch_flags,
-					cpu_arch[j].flags);
+					cpu_arch[j].enable);
 
 		  if (!cpu_flags_equal (&flags, &cpu_arch_flags))
 		    {
-		      extend_cpu_sub_arch_name (cpu_arch[j].name);
+		      extend_cpu_sub_arch_name (arch);
 		      cpu_arch_flags = flags;
 		      cpu_arch_isa_flags = flags;
 		    }
 		  else
 		    cpu_arch_isa_flags
 		      = cpu_flags_or (cpu_arch_isa_flags,
-				      cpu_arch[j].flags);
+				      cpu_arch[j].enable);
 		  break;
 		}
 	    }
 
-	  if (j >= ARRAY_SIZE (cpu_arch))
+	  if (j >= ARRAY_SIZE (cpu_arch) && startswith (arch, "no"))
 	    {
 	      /* Disable an ISA extension.  */
-	      for (j = 0; j < ARRAY_SIZE (cpu_noarch); j++)
-		if (strcmp (arch, cpu_noarch [j].name) == 0)
+	      for (j = 0; j < ARRAY_SIZE (cpu_arch); j++)
+		if (cpu_arch[j].type == PROCESSOR_NONE
+		    && strcmp (arch + 2, cpu_arch[j].name) == 0)
 		  {
 		    i386_cpu_flags flags;
 
 		    flags = cpu_flags_and_not (cpu_arch_flags,
-					       cpu_noarch[j].flags);
+					       cpu_arch[j].disable);
 		    if (!cpu_flags_equal (&flags, &cpu_arch_flags))
 		      {
 			extend_cpu_sub_arch_name (arch);
@@ -13348,9 +13294,6 @@ md_parse_option (int c, const char *arg)
 		      }
 		    break;
 		  }
-
-	      if (j >= ARRAY_SIZE (cpu_noarch))
-		j = ARRAY_SIZE (cpu_arch);
 	    }
 
 	  if (j >= ARRAY_SIZE (cpu_arch))
@@ -13367,11 +13310,12 @@ md_parse_option (int c, const char *arg)
 	as_fatal (_("invalid -mtune= option: `%s'"), arg);
       for (j = 0; j < ARRAY_SIZE (cpu_arch); j++)
 	{
-	  if (strcmp (arg, cpu_arch [j].name) == 0)
+	  if (cpu_arch[j].type != PROCESSOR_NONE
+	      && strcmp (arg, cpu_arch[j].name) == 0)
 	    {
 	      cpu_arch_tune_set = 1;
 	      cpu_arch_tune = cpu_arch [j].type;
-	      cpu_arch_tune_flags = cpu_arch[j].flags;
+	      cpu_arch_tune_flags = cpu_arch[j].enable;
 	      break;
 	    }
 	}
@@ -13751,15 +13695,10 @@ show_arch (FILE *stream, int ext, int ch
 
       name = cpu_arch [j].name;
       len = cpu_arch [j].len;
-      if (*name == '.')
+      if (cpu_arch[j].type == PROCESSOR_NONE)
 	{
 	  /* It is an extension.  Skip if we aren't asked to show it.  */
-	  if (ext)
-	    {
-	      name++;
-	      len--;
-	    }
-	  else
+	  if (!ext || cpu_flags_all_zero (&cpu_arch[j].enable))
 	    continue;
 	}
       else if (ext)
@@ -13767,7 +13706,7 @@ show_arch (FILE *stream, int ext, int ch
 	  /* It is an processor.  Skip if we show only extension.  */
 	  continue;
 	}
-      else if (check && ! cpu_arch[j].flags.bitfield.cpui386)
+      else if (check && ! cpu_arch[j].enable.bitfield.cpui386)
 	{
 	  /* It is an impossible processor - skip.  */
 	  continue;
@@ -13778,12 +13717,17 @@ show_arch (FILE *stream, int ext, int ch
 
   /* Display disabled extensions.  */
   if (ext)
-    for (j = 0; j < ARRAY_SIZE (cpu_noarch); j++)
+    for (j = 0; j < ARRAY_SIZE (cpu_arch); j++)
       {
-	name = cpu_noarch [j].name;
-	len = cpu_noarch [j].len;
-	p = output_message (stream, p, message, start, &left, name,
-			    len);
+	char *str;
+
+	if (cpu_arch[j].type != PROCESSOR_NONE
+	    || !cpu_flags_all_zero (&cpu_arch[j].enable))
+	  continue;
+	str = xasprintf ("no%s", cpu_arch[j].name);
+	p = output_message (stream, p, message, start, &left, str,
+			    strlen (str));
+	xfree (str);
       }
 
   *p = '\0';
@@ -13827,7 +13771,7 @@ md_show_usage (FILE *stream)
                           generate code for CPU and EXTENSION, CPU is one of:\n"));
   show_arch (stream, 0, 1);
   fprintf (stream, _("\
-                          EXTENSION is combination of:\n"));
+                          EXTENSION is combination of (possibly \"no\"-prefixed):\n"));
   show_arch (stream, 1, 0);
   fprintf (stream, _("\
   -mtune=CPU              optimize for CPU, CPU is one of:\n"));
@@ -13985,9 +13929,9 @@ i386_target_format (void)
     as_fatal (_("unknown architecture"));
 
   if (cpu_flags_all_zero (&cpu_arch_isa_flags))
-    cpu_arch_isa_flags = cpu_arch[flag_code == CODE_64BIT].flags;
+    cpu_arch_isa_flags = cpu_arch[flag_code == CODE_64BIT].enable;
   if (cpu_flags_all_zero (&cpu_arch_tune_flags))
-    cpu_arch_tune_flags = cpu_arch[flag_code == CODE_64BIT].flags;
+    cpu_arch_tune_flags = cpu_arch[flag_code == CODE_64BIT].enable;
 
   switch (OUTPUT_FLAVOR)
     {


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 7/7] x86: introduce a state stack for .arch
  2022-06-30 12:52 [PATCH] gas/x86: .arch / -march= enhancements Jan Beulich
                   ` (5 preceding siblings ...)
  2022-06-30 12:55 ` [PATCH 6/7] x86: generalize disabling of sub-architectures Jan Beulich
@ 2022-06-30 12:55 ` Jan Beulich
  2022-06-30 23:15   ` H.J. Lu
  6 siblings, 1 reply; 17+ messages in thread
From: Jan Beulich @ 2022-06-30 12:55 UTC (permalink / raw)
  To: Binutils

When using just slightly non-trivial combinations of .arch, it can be
quite useful to be able to go back to prior state without needing to
re-invoke perhaps many earlier directives and without needing to invoke
perhaps many "negative" ones. Like some other architectures allow
saving (pushing) and restoring (popping) present/prior state.

For now require the same .code<N> to be in effect for ".arch pop" that
was in effect for the corresponding ".arch push".

Also change the global "no_cond_jump_promotion" to be bool, to match the
new struct field.

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -788,7 +788,7 @@ i386_cpu_flags cpu_arch_isa_flags;
 
 /* If set, conditional jumps are not automatically promoted to handle
    larger than a byte offset.  */
-static unsigned int no_cond_jump_promotion = 0;
+static bool no_cond_jump_promotion = false;
 
 /* Encode SSE instructions with VEX prefix.  */
 static unsigned int sse2avx;
@@ -2663,6 +2663,20 @@ extend_cpu_sub_arch_name (const char *na
 static void
 set_cpu_arch (int dummy ATTRIBUTE_UNUSED)
 {
+  typedef struct arch_stack_entry
+  {
+    const struct arch_stack_entry *prev;
+    const char *name;
+    char *sub_name;
+    i386_cpu_flags flags;
+    i386_cpu_flags isa_flags;
+    enum processor_type isa;
+    enum flag_code flag_code;
+    char stackop_size;
+    bool no_cond_jump_promotion;
+  } arch_stack_entry;
+  static const arch_stack_entry *arch_stack_top;
+
   SKIP_WHITESPACE ();
 
   if (!is_end_of_line[(unsigned char) *input_line_pointer])
@@ -2706,6 +2720,67 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
 	      j = ARRAY_SIZE (cpu_arch) + 1;
 	    }
 	}
+      else if (strcmp (string, "push") == 0)
+	{
+	  arch_stack_entry *top = XNEW (arch_stack_entry);
+
+	  top->name = cpu_arch_name;
+	  if (cpu_sub_arch_name)
+	    top->sub_name = xstrdup (cpu_sub_arch_name);
+	  else
+	    top->sub_name = NULL;
+	  top->flags = cpu_arch_flags;
+	  top->isa = cpu_arch_isa;
+	  top->isa_flags = cpu_arch_isa_flags;
+	  top->flag_code = flag_code;
+	  top->stackop_size = stackop_size;
+	  top->no_cond_jump_promotion = no_cond_jump_promotion;
+
+	  top->prev = arch_stack_top;
+	  arch_stack_top = top;
+
+	  (void) restore_line_pointer (e);
+	  demand_empty_rest_of_line ();
+	  return;
+	}
+      else if (strcmp (string, "pop") == 0)
+	{
+	  const arch_stack_entry *top = arch_stack_top;
+
+	  if (!top)
+	    as_bad (_(".arch stack is empty"));
+	  else if (top->flag_code != flag_code
+		   || top->stackop_size != stackop_size)
+	    {
+	      static const unsigned int bits[] = {
+	        [CODE_16BIT] = 16,
+	        [CODE_32BIT] = 32,
+	        [CODE_64BIT] = 64,
+	      };
+
+	      as_bad (_("this `.arch pop' requires `.code%u%s' to be in effect"),
+		      bits[top->flag_code],
+		      top->stackop_size == LONG_MNEM_SUFFIX ? "gcc" : "");
+	    }
+	  else
+	    {
+	      arch_stack_top = top->prev;
+
+	      cpu_arch_name = top->name;
+	      xfree (cpu_sub_arch_name);
+	      cpu_sub_arch_name = top->sub_name;
+	      cpu_arch_flags = top->flags;
+	      cpu_arch_isa = top->isa;
+	      cpu_arch_isa_flags = top->isa_flags;
+	      no_cond_jump_promotion = top->no_cond_jump_promotion;
+
+	      XDELETE (top);
+	    }
+
+	  (void) restore_line_pointer (e);
+	  demand_empty_rest_of_line ();
+	  return;
+	}
 
       for (; j < ARRAY_SIZE (cpu_arch); j++)
 	{
@@ -13685,6 +13760,10 @@ show_arch (FILE *stream, int ext, int ch
     {
       p = output_message (stream, p, message, start, &left,
 			  STRING_COMMA_LEN ("default"));
+      p = output_message (stream, p, message, start, &left,
+			  STRING_COMMA_LEN ("push"));
+      p = output_message (stream, p, message, start, &left,
+			  STRING_COMMA_LEN ("pop"));
     }
 
   for (j = 0; j < ARRAY_SIZE (cpu_arch); j++)
--- a/gas/doc/c-i386.texi
+++ b/gas/doc/c-i386.texi
@@ -1504,7 +1504,7 @@ directive enables a warning when gas det
 supported on the CPU specified.  The choices for @var{cpu_type} are:
 
 @multitable @columnfractions .20 .20 .20 .20
-@item @samp{default}
+@item @samp{default} @tab @samp{push} @tab @samp{pop}
 @item @samp{i8086} @tab @samp{i186} @tab @samp{i286} @tab @samp{i386}
 @item @samp{i486} @tab @samp{i586} @tab @samp{i686} @tab @samp{pentium}
 @item @samp{pentiumpro} @tab @samp{pentiumii} @tab @samp{pentiumiii} @tab @samp{pentium4}
--- /dev/null
+++ b/gas/testsuite/gas/i386/arch-stk.l
@@ -0,0 +1,43 @@
+.*: Assembler messages:
+.*:3: Error:.*`cmovl'.*
+.*:10: Error:.*`cmovg'.*
+.*:17: Error:.*`cmovz'.*
+.*:21: Error:.*`\.arch pop'.*`\.code32'.*
+.*:28: Error:.*`\.arch pop'.*`\.code16gcc'.*
+.*:32: Error:.*\.arch.*empty.*
+GAS LISTING .*
+
+
+[ 	]*[0-9]*[ 	]+\.text
+[ 	]*[0-9]*[ 	]+start:
+[ 	]*[0-9]*[ 	]+cmovl	%eax, %ecx
+[ 	]*[0-9]*[ 	]*
+[ 	]*[0-9]*[ 	]+\.arch push
+[ 	]*[0-9]*[ 	]+\.arch default
+[ 	]*[0-9]*[ 	]+\?\?\?\? 0F4DC8[ 	]+cmovnl	%eax, %ecx
+[ 	]*[0-9]*[ 	]*
+[ 	]*[0-9]*[ 	]+\.arch pop
+[ 	]*[0-9]*[ 	]+cmovg	%eax, %ecx
+[ 	]*[0-9]*[ 	]*
+[ 	]*[0-9]*[ 	]+\.arch push
+[ 	]*[0-9]*[ 	]+\.arch \.cmov
+[ 	]*[0-9]*[ 	]+\?\?\?\? 0F4EC8[ 	]+cmovng	%eax, %ecx
+[ 	]*[0-9]*[ 	]*
+[ 	]*[0-9]*[ 	]+\.arch pop
+[ 	]*[0-9]*[ 	]+cmovz	%eax, %ecx
+[ 	]*[0-9]*[ 	]*
+[ 	]*[0-9]*[ 	]+\.arch push
+[ 	]*[0-9]*[ 	]+\.code16
+[ 	]*[0-9]*[ 	]+\.arch pop
+[ 	]*[0-9]*[ 	]+\.code32
+[ 	]*[0-9]*[ 	]+\.arch pop
+[ 	]*[0-9]*[ 	]*
+[ 	]*[0-9]*[ 	]+\.code16gcc
+[ 	]*[0-9]*[ 	]+\.arch push
+[ 	]*[0-9]*[ 	]+\.code32
+[ 	]*[0-9]*[ 	]+\.arch pop
+[ 	]*[0-9]*[ 	]+\.code16gcc
+[ 	]*[0-9]*[ 	]+\.arch pop
+[ 	]*[0-9]*[ 	]*
+[ 	]*[0-9]*[ 	]+\.arch pop
+#pass
--- /dev/null
+++ b/gas/testsuite/gas/i386/arch-stk.s
@@ -0,0 +1,34 @@
+	.text
+start:
+	cmovl	%eax, %ecx
+
+	.arch push
+	.arch default
+	cmovnl	%eax, %ecx
+
+	.arch pop
+	cmovg	%eax, %ecx
+
+	.arch push
+	.arch .cmov
+	cmovng	%eax, %ecx
+
+	.arch pop
+	cmovz	%eax, %ecx
+
+	.arch push
+	.code16
+	.arch pop
+	.code32
+	.arch pop
+
+	.code16gcc
+	.arch push
+	.code32
+	.arch pop
+	.code16gcc
+	.arch pop
+
+	.arch pop
+
+	.end
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -206,6 +206,7 @@ if [gas_32_check] then {
     run_dump_test "arch-13"
     run_dump_test "arch-14"
     run_list_test "arch-dflt" "-march=generic32 -al"
+    run_list_test "arch-stk" "-march=generic32 -al"
     run_dump_test "8087"
     run_dump_test "287"
     run_dump_test "387"


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/7] x86: don't leak sub-architecture accumulated strings
  2022-06-30 12:53 ` [PATCH 1/7] x86: don't leak sub-architecture accumulated strings Jan Beulich
@ 2022-06-30 22:54   ` H.J. Lu
  2022-07-01 10:18     ` Jan Beulich
  0 siblings, 1 reply; 17+ messages in thread
From: H.J. Lu @ 2022-06-30 22:54 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Binutils

On Thu, Jun 30, 2022 at 5:53 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> While it may not be necessary in i386_target_format() (but then setting
> the variable to NULL also wouldn't be necessary), at least in the other
> cases strings may already have accumulated.
>
> --- a/gas/config/tc-i386.c
> +++ b/gas/config/tc-i386.c
> @@ -2871,6 +2871,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
>                   check_cpu_arch_compatible (string, cpu_arch[j].flags);
>
>                   cpu_arch_name = cpu_arch[j].name;
> +                 xfree (cpu_sub_arch_name);
>                   cpu_sub_arch_name = NULL;
>                   cpu_arch_flags = cpu_arch[j].flags;
>                   if (flag_code == CODE_64BIT)
> @@ -13406,6 +13407,7 @@ md_parse_option (int c, const char *arg)
>                     continue;
>
>                   cpu_arch_name = cpu_arch[j].name;
> +                 xfree (cpu_sub_arch_name);
>                   cpu_sub_arch_name = NULL;
>                   cpu_arch_flags = cpu_arch[j].flags;
>                   cpu_arch_isa = cpu_arch[j].type;
> @@ -14086,6 +14088,7 @@ i386_target_format (void)
>         {
>           static const i386_cpu_flags iamcu_flags = CPU_IAMCU_FLAGS;
>           cpu_arch_name = "iamcu";
> +         xfree (cpu_sub_arch_name);
>           cpu_sub_arch_name = NULL;
>           cpu_arch_flags = iamcu_flags;
>           cpu_arch_isa = PROCESSOR_IAMCU;
>

Can we just use free?

-- 
H.J.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/7] x86: de-duplicate sub-architecture strings accumulation
  2022-06-30 12:53 ` [PATCH 2/7] x86: de-duplicate sub-architecture strings accumulation Jan Beulich
@ 2022-06-30 22:55   ` H.J. Lu
  0 siblings, 0 replies; 17+ messages in thread
From: H.J. Lu @ 2022-06-30 22:55 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Binutils

On Thu, Jun 30, 2022 at 5:53 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> Introduce a helper function to replace 4 instances of similar code. Use
> reconcat() to cover the previously explicit free() (which really should
> have been xfree() anyway).
>
> --- a/gas/config/tc-i386.c
> +++ b/gas/config/tc-i386.c
> @@ -2851,6 +2851,16 @@ check_cpu_arch_compatible (const char *n
>  }
>
>  static void
> +extend_cpu_sub_arch_name (const char *name)
> +{
> +  if (cpu_sub_arch_name)
> +    cpu_sub_arch_name = reconcat (cpu_sub_arch_name, cpu_sub_arch_name,
> +                                 name, (const char *) NULL);
> +  else
> +    cpu_sub_arch_name = xstrdup (name);
> +}
> +
> +static void
>  set_cpu_arch (int dummy ATTRIBUTE_UNUSED)
>  {
>    SKIP_WHITESPACE ();
> @@ -2899,16 +2909,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
>
>               if (!cpu_flags_equal (&flags, &cpu_arch_flags))
>                 {
> -                 if (cpu_sub_arch_name)
> -                   {
> -                     char *name = cpu_sub_arch_name;
> -                     cpu_sub_arch_name = concat (name,
> -                                                 cpu_arch[j].name,
> -                                                 (const char *) NULL);
> -                     free (name);
> -                   }
> -                 else
> -                   cpu_sub_arch_name = xstrdup (cpu_arch[j].name);
> +                 extend_cpu_sub_arch_name (string);
>                   cpu_arch_flags = flags;
>                   cpu_arch_isa_flags = flags;
>                 }
> @@ -2932,15 +2933,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
>                                            cpu_noarch[j].flags);
>                 if (!cpu_flags_equal (&flags, &cpu_arch_flags))
>                   {
> -                   if (cpu_sub_arch_name)
> -                     {
> -                       char *name = cpu_sub_arch_name;
> -                       cpu_sub_arch_name = concat (name, string,
> -                                                   (const char *) NULL);
> -                       free (name);
> -                     }
> -                   else
> -                     cpu_sub_arch_name = xstrdup (string);
> +                   extend_cpu_sub_arch_name (string);
>                     cpu_arch_flags = flags;
>                     cpu_arch_isa_flags = flags;
>                   }
> @@ -13430,16 +13423,7 @@ md_parse_option (int c, const char *arg)
>
>                   if (!cpu_flags_equal (&flags, &cpu_arch_flags))
>                     {
> -                     if (cpu_sub_arch_name)
> -                       {
> -                         char *name = cpu_sub_arch_name;
> -                         cpu_sub_arch_name = concat (name,
> -                                                     cpu_arch[j].name,
> -                                                     (const char *) NULL);
> -                         free (name);
> -                       }
> -                     else
> -                       cpu_sub_arch_name = xstrdup (cpu_arch[j].name);
> +                     extend_cpu_sub_arch_name (cpu_arch[j].name);
>                       cpu_arch_flags = flags;
>                       cpu_arch_isa_flags = flags;
>                     }
> @@ -13463,15 +13447,7 @@ md_parse_option (int c, const char *arg)
>                                                cpu_noarch[j].flags);
>                     if (!cpu_flags_equal (&flags, &cpu_arch_flags))
>                       {
> -                       if (cpu_sub_arch_name)
> -                         {
> -                           char *name = cpu_sub_arch_name;
> -                           cpu_sub_arch_name = concat (arch,
> -                                                       (const char *) NULL);
> -                           free (name);
> -                         }
> -                       else
> -                         cpu_sub_arch_name = xstrdup (arch);
> +                       extend_cpu_sub_arch_name (arch);
>                         cpu_arch_flags = flags;
>                         cpu_arch_isa_flags = flags;
>                       }
>

OK.

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/7] x86: permit "default" with .arch
  2022-06-30 12:53 ` [PATCH 3/7] x86: permit "default" with .arch Jan Beulich
@ 2022-06-30 22:58   ` H.J. Lu
  0 siblings, 0 replies; 17+ messages in thread
From: H.J. Lu @ 2022-06-30 22:58 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Binutils

On Thu, Jun 30, 2022 at 5:54 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> So far there was no way to reset the architecture to that assembly would
> start with in the absence of any overrides (command line or directives).
> Note that for Intel MCU "default" is merely an alias of "iamcu".
>
> While there also zap a stray @item from the doc section, as noticed
> when inspecting the generated output (which still has some quirks, but
> those aren't easy to address without re-flowing almost the entire
> section).
>
> --- a/gas/config/tc-i386.c
> +++ b/gas/config/tc-i386.c
> @@ -933,8 +933,8 @@ const relax_typeS md_relax_table[] =
>
>  static const arch_entry cpu_arch[] =
>  {
> -  /* Do not replace the first two entries - i386_target_format()
> -     relies on them being there in this order.  */
> +  /* Do not replace the first two entries - i386_target_format() and
> +     set_cpu_arch() rely on them being there in this order.  */
>    { STRING_COMMA_LEN ("generic32"), PROCESSOR_GENERIC32,
>      CPU_GENERIC32_FLAGS, 0 },
>    { STRING_COMMA_LEN ("generic64"), PROCESSOR_GENERIC64,
> @@ -2867,12 +2867,47 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
>
>    if (!is_end_of_line[(unsigned char) *input_line_pointer])
>      {
> -      char *string;
> -      int e = get_symbol_name (&string);
> -      unsigned int j;
> +      char *s;
> +      int e = get_symbol_name (&s);
> +      const char *string = s;
> +      unsigned int j = 0;
>        i386_cpu_flags flags;
>
> -      for (j = 0; j < ARRAY_SIZE (cpu_arch); j++)
> +      if (strcmp (string, "default") == 0)
> +       {
> +         if (strcmp (default_arch, "iamcu") == 0)
> +           string = default_arch;
> +         else
> +           {
> +             static const i386_cpu_flags cpu_unknown_flags = CPU_UNKNOWN_FLAGS;
> +
> +             cpu_arch_name = NULL;
> +             xfree (cpu_sub_arch_name);

Can we just use free?

> +             cpu_sub_arch_name = NULL;
> +             cpu_arch_flags = cpu_unknown_flags;
> +             if (flag_code == CODE_64BIT)
> +               {
> +                 cpu_arch_flags.bitfield.cpu64 = 1;
> +                 cpu_arch_flags.bitfield.cpuno64 = 0;
> +               }
> +             else
> +               {
> +                 cpu_arch_flags.bitfield.cpu64 = 0;
> +                 cpu_arch_flags.bitfield.cpuno64 = 1;
> +               }
> +             cpu_arch_isa = PROCESSOR_UNKNOWN;
> +             cpu_arch_isa_flags = cpu_arch[flag_code == CODE_64BIT].flags;
> +             if (!cpu_arch_tune_set)
> +               {
> +                 cpu_arch_tune = cpu_arch_isa;
> +                 cpu_arch_tune_flags = cpu_arch_isa_flags;
> +               }
> +
> +             j = ARRAY_SIZE (cpu_arch) + 1;
> +           }
> +       }
> +
> +      for (; j < ARRAY_SIZE (cpu_arch); j++)
>         {
>           if (strcmp (string, cpu_arch[j].name) == 0)
>             {
> @@ -2945,7 +2980,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
>           j = ARRAY_SIZE (cpu_arch);
>         }
>
> -      if (j >= ARRAY_SIZE (cpu_arch))
> +      if (j == ARRAY_SIZE (cpu_arch))
>         as_bad (_("no such architecture: `%s'"), string);
>
>        *input_line_pointer = e;
> @@ -13841,6 +13876,13 @@ show_arch (FILE *stream, int ext, int ch
>
>    p = start;
>    left = size - (start - message);
> +
> +  if (!ext && check)
> +    {
> +      p = output_message (stream, p, message, start, &left,
> +                         STRING_COMMA_LEN ("default"));
> +    }
> +
>    for (j = 0; j < ARRAY_SIZE (cpu_arch); j++)
>      {
>        /* Should it be skipped?  */
> --- a/gas/doc/c-i386.texi
> +++ b/gas/doc/c-i386.texi
> @@ -1504,6 +1504,7 @@ directive enables a warning when gas det
>  supported on the CPU specified.  The choices for @var{cpu_type} are:
>
>  @multitable @columnfractions .20 .20 .20 .20
> +@item @samp{default}
>  @item @samp{i8086} @tab @samp{i186} @tab @samp{i286} @tab @samp{i386}
>  @item @samp{i486} @tab @samp{i586} @tab @samp{i686} @tab @samp{pentium}
>  @item @samp{pentiumpro} @tab @samp{pentiumii} @tab @samp{pentiumiii} @tab @samp{pentium4}
> @@ -1531,7 +1532,7 @@ supported on the CPU specified.  The cho
>  @item @samp{.avx512_vpopcntdq} @tab @samp{.avx512_vbmi2} @tab @samp{.avx512_vnni}
>  @item @samp{.avx512_bitalg} @tab @samp{.avx512_bf16} @tab @samp{.avx512_vp2intersect}
>  @item @samp{.tdx} @tab @samp{.avx_vnni}  @tab @samp{.avx512_fp16}
> -@item @samp{.clwb} @tab @samp{.rdpid} @tab @samp{.ptwrite} @tab @item @samp{.ibt}
> +@item @samp{.clwb} @tab @samp{.rdpid} @tab @samp{.ptwrite} @tab @samp{.ibt}
>  @item @samp{.wbnoinvd} @tab @samp{.pconfig} @tab @samp{.waitpkg} @tab @samp{.cldemote}
>  @item @samp{.shstk} @tab @samp{.gfni} @tab @samp{.vaes} @tab @samp{.vpclmulqdq}
>  @item @samp{.movdiri} @tab @samp{.movdir64b} @tab @samp{.enqcmd} @tab @samp{.tsxldtrk}
> --- /dev/null
> +++ b/gas/testsuite/gas/i386/arch-dflt.l
> @@ -0,0 +1,19 @@
> +.*: Assembler messages:
> +.*:3: Error:.*`cmovl'.*
> +.*:9: Error:.*`cmovg'.*
> +GAS LISTING .*
> +
> +
> +[      ]*[0-9]*[       ]+\.text
> +[      ]*[0-9]*[       ]+start:
> +[      ]*[0-9]*[       ]+cmovl %eax, %ecx
> +[      ]*[0-9]*[       ]*
> +[      ]*[0-9]*[       ]+\.arch default
> +[      ]*[0-9]*[       ]+\?\?\?\? 0F4DC8[      ]+cmovnl        %eax, %ecx
> +[      ]*[0-9]*[       ]*
> +[      ]*[0-9]*[       ]+\.arch generic32
> +[      ]*[0-9]*[       ]+cmovg %eax, %ecx
> +[      ]*[0-9]*[       ]*
> +[      ]*[0-9]*[       ]+\.arch default
> +[      ]*[0-9]*[       ]+\?\?\?\? 0F4EC8[      ]+cmovng        %eax, %ecx
> +#pass
> --- /dev/null
> +++ b/gas/testsuite/gas/i386/arch-dflt.s
> @@ -0,0 +1,14 @@
> +       .text
> +start:
> +       cmovl   %eax, %ecx
> +
> +       .arch default
> +       cmovnl  %eax, %ecx
> +
> +       .arch generic32
> +       cmovg   %eax, %ecx
> +
> +       .arch default
> +       cmovng  %eax, %ecx
> +
> +       .end
> --- a/gas/testsuite/gas/i386/i386.exp
> +++ b/gas/testsuite/gas/i386/i386.exp
> @@ -205,6 +205,7 @@ if [gas_32_check] then {
>      run_dump_test "arch-12"
>      run_dump_test "arch-13"
>      run_dump_test "arch-14"
> +    run_list_test "arch-dflt" "-march=generic32 -al"
>      run_dump_test "8087"
>      run_dump_test "287"
>      run_dump_test "387"
>


-- 
H.J.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/7] x86: macro-ize cpu_arch[] entries
  2022-06-30 12:54 ` [PATCH 4/7] x86: macro-ize cpu_arch[] entries Jan Beulich
@ 2022-06-30 23:00   ` H.J. Lu
  0 siblings, 0 replies; 17+ messages in thread
From: H.J. Lu @ 2022-06-30 23:00 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Binutils

On Thu, Jun 30, 2022 at 5:54 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> Putting individual elements behind macros, besides (imo) improving
> readability, will make subsequent (and likely also future) changes less
> intrusive.
>
> Utilize this right away to pack the table a little more tightly, by
> converting "skip" to bool and putting it earlier in a group of bitfields
> together with "len".
>
> --- a/gas/config/tc-i386.c
> +++ b/gas/config/tc-i386.c
> @@ -126,10 +126,10 @@ sib_byte;
>  typedef struct
>  {
>    const char *name;            /* arch name */
> -  unsigned int len;            /* arch string length */
> +  unsigned int len:8;          /* arch string length */
> +  bool skip:1;                 /* show_arch should skip this. */
>    enum processor_type type;    /* arch type */
>    i386_cpu_flags flags;                /* cpu feature flags */
> -  unsigned int skip;           /* show_arch should skip this. */
>  }
>  arch_entry;
>
> @@ -931,318 +931,174 @@ const relax_typeS md_relax_table[] =
>    {0, 0, 4, 0}
>  };
>
> +#define ARCH(n, t, f, s) \
> +  { STRING_COMMA_LEN (#n), s, PROCESSOR_ ## t, CPU_ ## f ## _FLAGS }
> +#define SUBARCH(n, e, s) \
> +  { STRING_COMMA_LEN ("." #n), s, PROCESSOR_UNKNOWN, CPU_ ## e ## _FLAGS }
> +
>  static const arch_entry cpu_arch[] =
>  {
>    /* Do not replace the first two entries - i386_target_format() and
>       set_cpu_arch() rely on them being there in this order.  */
> -  { STRING_COMMA_LEN ("generic32"), PROCESSOR_GENERIC32,
> -    CPU_GENERIC32_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("generic64"), PROCESSOR_GENERIC64,
> -    CPU_GENERIC64_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("i8086"), PROCESSOR_UNKNOWN,
> -    CPU_NONE_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("i186"), PROCESSOR_UNKNOWN,
> -    CPU_I186_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("i286"), PROCESSOR_UNKNOWN,
> -    CPU_I286_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("i386"), PROCESSOR_I386,
> -    CPU_I386_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("i486"), PROCESSOR_I486,
> -    CPU_I486_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("i586"), PROCESSOR_PENTIUM,
> -    CPU_I586_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("i686"), PROCESSOR_PENTIUMPRO,
> -    CPU_I686_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("pentium"), PROCESSOR_PENTIUM,
> -    CPU_I586_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("pentiumpro"), PROCESSOR_PENTIUMPRO,
> -    CPU_PENTIUMPRO_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("pentiumii"), PROCESSOR_PENTIUMPRO,
> -    CPU_P2_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("pentiumiii"),PROCESSOR_PENTIUMPRO,
> -    CPU_P3_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("pentium4"), PROCESSOR_PENTIUM4,
> -    CPU_P4_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("prescott"), PROCESSOR_NOCONA,
> -    CPU_CORE_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("nocona"), PROCESSOR_NOCONA,
> -    CPU_NOCONA_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("yonah"), PROCESSOR_CORE,
> -    CPU_CORE_FLAGS, 1 },
> -  { STRING_COMMA_LEN ("core"), PROCESSOR_CORE,
> -    CPU_CORE_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("merom"), PROCESSOR_CORE2,
> -    CPU_CORE2_FLAGS, 1 },
> -  { STRING_COMMA_LEN ("core2"), PROCESSOR_CORE2,
> -    CPU_CORE2_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("corei7"), PROCESSOR_COREI7,
> -    CPU_COREI7_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("iamcu"), PROCESSOR_IAMCU,
> -    CPU_IAMCU_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("k6"), PROCESSOR_K6,
> -    CPU_K6_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("k6_2"), PROCESSOR_K6,
> -    CPU_K6_2_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("athlon"), PROCESSOR_ATHLON,
> -    CPU_ATHLON_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("sledgehammer"), PROCESSOR_K8,
> -    CPU_K8_FLAGS, 1 },
> -  { STRING_COMMA_LEN ("opteron"), PROCESSOR_K8,
> -    CPU_K8_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("k8"), PROCESSOR_K8,
> -    CPU_K8_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("amdfam10"), PROCESSOR_AMDFAM10,
> -    CPU_AMDFAM10_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("bdver1"), PROCESSOR_BD,
> -    CPU_BDVER1_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("bdver2"), PROCESSOR_BD,
> -    CPU_BDVER2_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("bdver3"), PROCESSOR_BD,
> -    CPU_BDVER3_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("bdver4"), PROCESSOR_BD,
> -    CPU_BDVER4_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("znver1"), PROCESSOR_ZNVER,
> -    CPU_ZNVER1_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("znver2"), PROCESSOR_ZNVER,
> -    CPU_ZNVER2_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("znver3"), PROCESSOR_ZNVER,
> -    CPU_ZNVER3_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("btver1"), PROCESSOR_BT,
> -    CPU_BTVER1_FLAGS, 0 },
> -  { STRING_COMMA_LEN ("btver2"), PROCESSOR_BT,
> -    CPU_BTVER2_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".8087"), PROCESSOR_UNKNOWN,
> -    CPU_8087_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".287"), PROCESSOR_UNKNOWN,
> -    CPU_287_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".387"), PROCESSOR_UNKNOWN,
> -    CPU_387_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".687"), PROCESSOR_UNKNOWN,
> -    CPU_687_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".cmov"), PROCESSOR_UNKNOWN,
> -    CPU_CMOV_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".fxsr"), PROCESSOR_UNKNOWN,
> -    CPU_FXSR_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".mmx"), PROCESSOR_UNKNOWN,
> -    CPU_MMX_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".sse"), PROCESSOR_UNKNOWN,
> -    CPU_SSE_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".sse2"), PROCESSOR_UNKNOWN,
> -    CPU_SSE2_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".sse3"), PROCESSOR_UNKNOWN,
> -    CPU_SSE3_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".sse4a"), PROCESSOR_UNKNOWN,
> -    CPU_SSE4A_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".ssse3"), PROCESSOR_UNKNOWN,
> -    CPU_SSSE3_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".sse4.1"), PROCESSOR_UNKNOWN,
> -    CPU_SSE4_1_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".sse4.2"), PROCESSOR_UNKNOWN,
> -    CPU_SSE4_2_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".sse4"), PROCESSOR_UNKNOWN,
> -    CPU_SSE4_2_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx"), PROCESSOR_UNKNOWN,
> -    CPU_AVX_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx2"), PROCESSOR_UNKNOWN,
> -    CPU_AVX2_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx512f"), PROCESSOR_UNKNOWN,
> -    CPU_AVX512F_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx512cd"), PROCESSOR_UNKNOWN,
> -    CPU_AVX512CD_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx512er"), PROCESSOR_UNKNOWN,
> -    CPU_AVX512ER_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx512pf"), PROCESSOR_UNKNOWN,
> -    CPU_AVX512PF_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx512dq"), PROCESSOR_UNKNOWN,
> -    CPU_AVX512DQ_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx512bw"), PROCESSOR_UNKNOWN,
> -    CPU_AVX512BW_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx512vl"), PROCESSOR_UNKNOWN,
> -    CPU_AVX512VL_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".vmx"), PROCESSOR_UNKNOWN,
> -    CPU_VMX_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".vmfunc"), PROCESSOR_UNKNOWN,
> -    CPU_VMFUNC_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".smx"), PROCESSOR_UNKNOWN,
> -    CPU_SMX_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".xsave"), PROCESSOR_UNKNOWN,
> -    CPU_XSAVE_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".xsaveopt"), PROCESSOR_UNKNOWN,
> -    CPU_XSAVEOPT_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".xsavec"), PROCESSOR_UNKNOWN,
> -    CPU_XSAVEC_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".xsaves"), PROCESSOR_UNKNOWN,
> -    CPU_XSAVES_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".aes"), PROCESSOR_UNKNOWN,
> -    CPU_AES_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".pclmul"), PROCESSOR_UNKNOWN,
> -    CPU_PCLMUL_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".clmul"), PROCESSOR_UNKNOWN,
> -    CPU_PCLMUL_FLAGS, 1 },
> -  { STRING_COMMA_LEN (".fsgsbase"), PROCESSOR_UNKNOWN,
> -    CPU_FSGSBASE_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".rdrnd"), PROCESSOR_UNKNOWN,
> -    CPU_RDRND_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".f16c"), PROCESSOR_UNKNOWN,
> -    CPU_F16C_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".bmi2"), PROCESSOR_UNKNOWN,
> -    CPU_BMI2_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".fma"), PROCESSOR_UNKNOWN,
> -    CPU_FMA_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".fma4"), PROCESSOR_UNKNOWN,
> -    CPU_FMA4_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".xop"), PROCESSOR_UNKNOWN,
> -    CPU_XOP_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".lwp"), PROCESSOR_UNKNOWN,
> -    CPU_LWP_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".movbe"), PROCESSOR_UNKNOWN,
> -    CPU_MOVBE_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".cx16"), PROCESSOR_UNKNOWN,
> -    CPU_CX16_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".ept"), PROCESSOR_UNKNOWN,
> -    CPU_EPT_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".lzcnt"), PROCESSOR_UNKNOWN,
> -    CPU_LZCNT_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".popcnt"), PROCESSOR_UNKNOWN,
> -    CPU_POPCNT_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".hle"), PROCESSOR_UNKNOWN,
> -    CPU_HLE_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".rtm"), PROCESSOR_UNKNOWN,
> -    CPU_RTM_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".invpcid"), PROCESSOR_UNKNOWN,
> -    CPU_INVPCID_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".clflush"), PROCESSOR_UNKNOWN,
> -    CPU_CLFLUSH_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".nop"), PROCESSOR_UNKNOWN,
> -    CPU_NOP_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".syscall"), PROCESSOR_UNKNOWN,
> -    CPU_SYSCALL_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".rdtscp"), PROCESSOR_UNKNOWN,
> -    CPU_RDTSCP_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".3dnow"), PROCESSOR_UNKNOWN,
> -    CPU_3DNOW_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".3dnowa"), PROCESSOR_UNKNOWN,
> -    CPU_3DNOWA_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".padlock"), PROCESSOR_UNKNOWN,
> -    CPU_PADLOCK_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".pacifica"), PROCESSOR_UNKNOWN,
> -    CPU_SVME_FLAGS, 1 },
> -  { STRING_COMMA_LEN (".svme"), PROCESSOR_UNKNOWN,
> -    CPU_SVME_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".sse4a"), PROCESSOR_UNKNOWN,
> -    CPU_SSE4A_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".abm"), PROCESSOR_UNKNOWN,
> -    CPU_ABM_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".bmi"), PROCESSOR_UNKNOWN,
> -    CPU_BMI_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".tbm"), PROCESSOR_UNKNOWN,
> -    CPU_TBM_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".adx"), PROCESSOR_UNKNOWN,
> -    CPU_ADX_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".rdseed"), PROCESSOR_UNKNOWN,
> -    CPU_RDSEED_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".prfchw"), PROCESSOR_UNKNOWN,
> -    CPU_PRFCHW_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".smap"), PROCESSOR_UNKNOWN,
> -    CPU_SMAP_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".mpx"), PROCESSOR_UNKNOWN,
> -    CPU_MPX_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".sha"), PROCESSOR_UNKNOWN,
> -    CPU_SHA_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".clflushopt"), PROCESSOR_UNKNOWN,
> -    CPU_CLFLUSHOPT_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".prefetchwt1"), PROCESSOR_UNKNOWN,
> -    CPU_PREFETCHWT1_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".se1"), PROCESSOR_UNKNOWN,
> -    CPU_SE1_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".clwb"), PROCESSOR_UNKNOWN,
> -    CPU_CLWB_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx512ifma"), PROCESSOR_UNKNOWN,
> -    CPU_AVX512IFMA_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx512vbmi"), PROCESSOR_UNKNOWN,
> -    CPU_AVX512VBMI_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx512_4fmaps"), PROCESSOR_UNKNOWN,
> -    CPU_AVX512_4FMAPS_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx512_4vnniw"), PROCESSOR_UNKNOWN,
> -    CPU_AVX512_4VNNIW_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx512_vpopcntdq"), PROCESSOR_UNKNOWN,
> -    CPU_AVX512_VPOPCNTDQ_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx512_vbmi2"), PROCESSOR_UNKNOWN,
> -    CPU_AVX512_VBMI2_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx512_vnni"), PROCESSOR_UNKNOWN,
> -    CPU_AVX512_VNNI_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx512_bitalg"), PROCESSOR_UNKNOWN,
> -    CPU_AVX512_BITALG_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx_vnni"), PROCESSOR_UNKNOWN,
> -    CPU_AVX_VNNI_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".clzero"), PROCESSOR_UNKNOWN,
> -    CPU_CLZERO_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".mwaitx"), PROCESSOR_UNKNOWN,
> -    CPU_MWAITX_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".ospke"), PROCESSOR_UNKNOWN,
> -    CPU_OSPKE_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".rdpid"), PROCESSOR_UNKNOWN,
> -    CPU_RDPID_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".ptwrite"), PROCESSOR_UNKNOWN,
> -    CPU_PTWRITE_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".ibt"), PROCESSOR_UNKNOWN,
> -    CPU_IBT_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".shstk"), PROCESSOR_UNKNOWN,
> -    CPU_SHSTK_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".gfni"), PROCESSOR_UNKNOWN,
> -    CPU_GFNI_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".vaes"), PROCESSOR_UNKNOWN,
> -    CPU_VAES_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".vpclmulqdq"), PROCESSOR_UNKNOWN,
> -    CPU_VPCLMULQDQ_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".wbnoinvd"), PROCESSOR_UNKNOWN,
> -    CPU_WBNOINVD_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".pconfig"), PROCESSOR_UNKNOWN,
> -    CPU_PCONFIG_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".waitpkg"), PROCESSOR_UNKNOWN,
> -    CPU_WAITPKG_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".cldemote"), PROCESSOR_UNKNOWN,
> -    CPU_CLDEMOTE_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".amx_int8"), PROCESSOR_UNKNOWN,
> -    CPU_AMX_INT8_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".amx_bf16"), PROCESSOR_UNKNOWN,
> -    CPU_AMX_BF16_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".amx_tile"), PROCESSOR_UNKNOWN,
> -    CPU_AMX_TILE_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".movdiri"), PROCESSOR_UNKNOWN,
> -    CPU_MOVDIRI_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".movdir64b"), PROCESSOR_UNKNOWN,
> -    CPU_MOVDIR64B_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx512_bf16"), PROCESSOR_UNKNOWN,
> -    CPU_AVX512_BF16_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx512_vp2intersect"), PROCESSOR_UNKNOWN,
> -    CPU_AVX512_VP2INTERSECT_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".tdx"), PROCESSOR_UNKNOWN,
> -    CPU_TDX_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".enqcmd"), PROCESSOR_UNKNOWN,
> -    CPU_ENQCMD_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".serialize"), PROCESSOR_UNKNOWN,
> -    CPU_SERIALIZE_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".rdpru"), PROCESSOR_UNKNOWN,
> -    CPU_RDPRU_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".mcommit"), PROCESSOR_UNKNOWN,
> -    CPU_MCOMMIT_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".sev_es"), PROCESSOR_UNKNOWN,
> -    CPU_SEV_ES_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".tsxldtrk"), PROCESSOR_UNKNOWN,
> -    CPU_TSXLDTRK_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".kl"), PROCESSOR_UNKNOWN,
> -    CPU_KL_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".widekl"), PROCESSOR_UNKNOWN,
> -    CPU_WIDEKL_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".uintr"), PROCESSOR_UNKNOWN,
> -    CPU_UINTR_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".hreset"), PROCESSOR_UNKNOWN,
> -    CPU_HRESET_FLAGS, 0 },
> -  { STRING_COMMA_LEN (".avx512_fp16"), PROCESSOR_UNKNOWN,
> -    CPU_AVX512_FP16_FLAGS, 0 },
> +  ARCH (generic32, GENERIC32, GENERIC32, false),
> +  ARCH (generic64, GENERIC64, GENERIC64, false),
> +  ARCH (i8086, UNKNOWN, NONE, false),
> +  ARCH (i186, UNKNOWN, I186, false),
> +  ARCH (i286, UNKNOWN, I286, false),
> +  ARCH (i386, I386, I386, false),
> +  ARCH (i486, I486, I486, false),
> +  ARCH (i586, PENTIUM, I586, false),
> +  ARCH (i686, PENTIUMPRO, I686, false),
> +  ARCH (pentium, PENTIUM, I586, false),
> +  ARCH (pentiumpro, PENTIUMPRO, PENTIUMPRO, false),
> +  ARCH (pentiumii, PENTIUMPRO, P2, false),
> +  ARCH (pentiumiii, PENTIUMPRO, P3, false),
> +  ARCH (pentium4, PENTIUM4, P4, false),
> +  ARCH (prescott, NOCONA, CORE, false),
> +  ARCH (nocona, NOCONA, NOCONA, false),
> +  ARCH (yonah, CORE, CORE, true),
> +  ARCH (core, CORE, CORE, false),
> +  ARCH (merom, CORE2, CORE2, true),
> +  ARCH (core2, CORE2, CORE2, false),
> +  ARCH (corei7, COREI7, COREI7, false),
> +  ARCH (iamcu, IAMCU, IAMCU, false),
> +  ARCH (k6, K6, K6, false),
> +  ARCH (k6_2, K6, K6_2, false),
> +  ARCH (athlon, ATHLON, ATHLON, false),
> +  ARCH (sledgehammer, K8, K8, true),
> +  ARCH (opteron, K8, K8, false),
> +  ARCH (k8, K8, K8, false),
> +  ARCH (amdfam10, AMDFAM10, AMDFAM10, false),
> +  ARCH (bdver1, BD, BDVER1, false),
> +  ARCH (bdver2, BD, BDVER2, false),
> +  ARCH (bdver3, BD, BDVER3, false),
> +  ARCH (bdver4, BD, BDVER4, false),
> +  ARCH (znver1, ZNVER, ZNVER1, false),
> +  ARCH (znver2, ZNVER, ZNVER2, false),
> +  ARCH (znver3, ZNVER, ZNVER3, false),
> +  ARCH (btver1, BT, BTVER1, false),
> +  ARCH (btver2, BT, BTVER2, false),
> +
> +  SUBARCH (8087, 8087, false),
> +  SUBARCH (287, 287, false),
> +  SUBARCH (387, 387, false),
> +  SUBARCH (687, 687, false),
> +  SUBARCH (cmov, CMOV, false),
> +  SUBARCH (fxsr, FXSR, false),
> +  SUBARCH (mmx, MMX, false),
> +  SUBARCH (sse, SSE, false),
> +  SUBARCH (sse2, SSE2, false),
> +  SUBARCH (sse3, SSE3, false),
> +  SUBARCH (sse4a, SSE4A, false),
> +  SUBARCH (ssse3, SSSE3, false),
> +  SUBARCH (sse4.1, SSE4_1, false),
> +  SUBARCH (sse4.2, SSE4_2, false),
> +  SUBARCH (sse4, SSE4_2, false),
> +  SUBARCH (avx, AVX, false),
> +  SUBARCH (avx2, AVX2, false),
> +  SUBARCH (avx512f, AVX512F, false),
> +  SUBARCH (avx512cd, AVX512CD, false),
> +  SUBARCH (avx512er, AVX512ER, false),
> +  SUBARCH (avx512pf, AVX512PF, false),
> +  SUBARCH (avx512dq, AVX512DQ, false),
> +  SUBARCH (avx512bw, AVX512BW, false),
> +  SUBARCH (avx512vl, AVX512VL, false),
> +  SUBARCH (vmx, VMX, false),
> +  SUBARCH (vmfunc, VMFUNC, false),
> +  SUBARCH (smx, SMX, false),
> +  SUBARCH (xsave, XSAVE, false),
> +  SUBARCH (xsaveopt, XSAVEOPT, false),
> +  SUBARCH (xsavec, XSAVEC, false),
> +  SUBARCH (xsaves, XSAVES, false),
> +  SUBARCH (aes, AES, false),
> +  SUBARCH (pclmul, PCLMUL, false),
> +  SUBARCH (clmul, PCLMUL, true),
> +  SUBARCH (fsgsbase, FSGSBASE, false),
> +  SUBARCH (rdrnd, RDRND, false),
> +  SUBARCH (f16c, F16C, false),
> +  SUBARCH (bmi2, BMI2, false),
> +  SUBARCH (fma, FMA, false),
> +  SUBARCH (fma4, FMA4, false),
> +  SUBARCH (xop, XOP, false),
> +  SUBARCH (lwp, LWP, false),
> +  SUBARCH (movbe, MOVBE, false),
> +  SUBARCH (cx16, CX16, false),
> +  SUBARCH (ept, EPT, false),
> +  SUBARCH (lzcnt, LZCNT, false),
> +  SUBARCH (popcnt, POPCNT, false),
> +  SUBARCH (hle, HLE, false),
> +  SUBARCH (rtm, RTM, false),
> +  SUBARCH (invpcid, INVPCID, false),
> +  SUBARCH (clflush, CLFLUSH, false),
> +  SUBARCH (nop, NOP, false),
> +  SUBARCH (syscall, SYSCALL, false),
> +  SUBARCH (rdtscp, RDTSCP, false),
> +  SUBARCH (3dnow, 3DNOW, false),
> +  SUBARCH (3dnowa, 3DNOWA, false),
> +  SUBARCH (padlock, PADLOCK, false),
> +  SUBARCH (pacifica, SVME, true),
> +  SUBARCH (svme, SVME, false),
> +  SUBARCH (sse4a, SSE4A, false),
> +  SUBARCH (abm, ABM, false),
> +  SUBARCH (bmi, BMI, false),
> +  SUBARCH (tbm, TBM, false),
> +  SUBARCH (adx, ADX, false),
> +  SUBARCH (rdseed, RDSEED, false),
> +  SUBARCH (prfchw, PRFCHW, false),
> +  SUBARCH (smap, SMAP, false),
> +  SUBARCH (mpx, MPX, false),
> +  SUBARCH (sha, SHA, false),
> +  SUBARCH (clflushopt, CLFLUSHOPT, false),
> +  SUBARCH (prefetchwt1, PREFETCHWT1, false),
> +  SUBARCH (se1, SE1, false),
> +  SUBARCH (clwb, CLWB, false),
> +  SUBARCH (avx512ifma, AVX512IFMA, false),
> +  SUBARCH (avx512vbmi, AVX512VBMI, false),
> +  SUBARCH (avx512_4fmaps, AVX512_4FMAPS, false),
> +  SUBARCH (avx512_4vnniw, AVX512_4VNNIW, false),
> +  SUBARCH (avx512_vpopcntdq, AVX512_VPOPCNTDQ, false),
> +  SUBARCH (avx512_vbmi2, AVX512_VBMI2, false),
> +  SUBARCH (avx512_vnni, AVX512_VNNI, false),
> +  SUBARCH (avx512_bitalg, AVX512_BITALG, false),
> +  SUBARCH (avx_vnni, AVX_VNNI, false),
> +  SUBARCH (clzero, CLZERO, false),
> +  SUBARCH (mwaitx, MWAITX, false),
> +  SUBARCH (ospke, OSPKE, false),
> +  SUBARCH (rdpid, RDPID, false),
> +  SUBARCH (ptwrite, PTWRITE, false),
> +  SUBARCH (ibt, IBT, false),
> +  SUBARCH (shstk, SHSTK, false),
> +  SUBARCH (gfni, GFNI, false),
> +  SUBARCH (vaes, VAES, false),
> +  SUBARCH (vpclmulqdq, VPCLMULQDQ, false),
> +  SUBARCH (wbnoinvd, WBNOINVD, false),
> +  SUBARCH (pconfig, PCONFIG, false),
> +  SUBARCH (waitpkg, WAITPKG, false),
> +  SUBARCH (cldemote, CLDEMOTE, false),
> +  SUBARCH (amx_int8, AMX_INT8, false),
> +  SUBARCH (amx_bf16, AMX_BF16, false),
> +  SUBARCH (amx_tile, AMX_TILE, false),
> +  SUBARCH (movdiri, MOVDIRI, false),
> +  SUBARCH (movdir64b, MOVDIR64B, false),
> +  SUBARCH (avx512_bf16, AVX512_BF16, false),
> +  SUBARCH (avx512_vp2intersect, AVX512_VP2INTERSECT, false),
> +  SUBARCH (tdx, TDX, false),
> +  SUBARCH (enqcmd, ENQCMD, false),
> +  SUBARCH (serialize, SERIALIZE, false),
> +  SUBARCH (rdpru, RDPRU, false),
> +  SUBARCH (mcommit, MCOMMIT, false),
> +  SUBARCH (sev_es, SEV_ES, false),
> +  SUBARCH (tsxldtrk, TSXLDTRK, false),
> +  SUBARCH (kl, KL, false),
> +  SUBARCH (widekl, WIDEKL, false),
> +  SUBARCH (uintr, UINTR, false),
> +  SUBARCH (hreset, HRESET, false),
> +  SUBARCH (avx512_fp16, AVX512_FP16, false),
>  };
>
> +#undef SUBARCH
> +#undef ARCH
> +
>  static const noarch_entry cpu_noarch[] =
>  {
>    { STRING_COMMA_LEN ("no87"),  CPU_ANY_X87_FLAGS },
>

OK.

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/7] x86: introduce fake processor type to mark sub-arch entries in cpu_arch[]
  2022-06-30 12:54 ` [PATCH 5/7] x86: introduce fake processor type to mark sub-arch entries in cpu_arch[] Jan Beulich
@ 2022-06-30 23:03   ` H.J. Lu
  0 siblings, 0 replies; 17+ messages in thread
From: H.J. Lu @ 2022-06-30 23:03 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Binutils

On Thu, Jun 30, 2022 at 5:54 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> This is in preparation of dropping the leading . from the strings.
>
> While there also move PROCESSOR_GENERIC{32,64} from the middle of AMD
> entries to near the top.
>
> --- a/gas/config/tc-i386.c
> +++ b/gas/config/tc-i386.c
> @@ -934,7 +934,7 @@ const relax_typeS md_relax_table[] =
>  #define ARCH(n, t, f, s) \
>    { STRING_COMMA_LEN (#n), s, PROCESSOR_ ## t, CPU_ ## f ## _FLAGS }
>  #define SUBARCH(n, e, s) \
> -  { STRING_COMMA_LEN ("." #n), s, PROCESSOR_UNKNOWN, CPU_ ## e ## _FLAGS }
> +  { STRING_COMMA_LEN ("." #n), s, PROCESSOR_NONE, CPU_ ## e ## _FLAGS }
>
>  static const arch_entry cpu_arch[] =
>  {
> @@ -1471,6 +1471,8 @@ i386_generate_nops (fragS *fragP, char *
>             case PROCESSOR_GENERIC32:
>               patt = f32_patt;
>               break;
> +           case PROCESSOR_NONE:
> +             abort ();
>             }
>         }
>        else
> @@ -1516,6 +1518,8 @@ i386_generate_nops (fragS *fragP, char *
>             case PROCESSOR_GENERIC64:
>               patt = alt_patt;
>               break;
> +           case PROCESSOR_NONE:
> +             abort ();
>             }
>         }
>
> --- a/gas/config/tc-i386.h
> +++ b/gas/config/tc-i386.h
> @@ -228,6 +228,8 @@ extern long i386_generic_table_relax_fra
>  enum processor_type
>  {
>    PROCESSOR_UNKNOWN,
> +  PROCESSOR_GENERIC32,
> +  PROCESSOR_GENERIC64,
>    PROCESSOR_I386,
>    PROCESSOR_I486,
>    PROCESSOR_PENTIUM,
> @@ -241,12 +243,12 @@ enum processor_type
>    PROCESSOR_K6,
>    PROCESSOR_ATHLON,
>    PROCESSOR_K8,
> -  PROCESSOR_GENERIC32,
> -  PROCESSOR_GENERIC64,
>    PROCESSOR_AMDFAM10,
>    PROCESSOR_BD,
>    PROCESSOR_ZNVER,
> -  PROCESSOR_BT
> +  PROCESSOR_BT,
> +  /* Keep this last.  */
> +  PROCESSOR_NONE
>  };
>
>  extern enum processor_type cpu_arch_tune;
>

OK.

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 6/7] x86: generalize disabling of sub-architectures
  2022-06-30 12:55 ` [PATCH 6/7] x86: generalize disabling of sub-architectures Jan Beulich
@ 2022-06-30 23:11   ` H.J. Lu
  0 siblings, 0 replies; 17+ messages in thread
From: H.J. Lu @ 2022-06-30 23:11 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Binutils

On Thu, Jun 30, 2022 at 5:55 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> I never really understood upon what basis ".arch .no*" options were made
> available. Let's not have any "criteria" at all, and simply allow
> disabling of all of them. Then we also have all data for a sub-arch in
> a single place, as we now only need a single table.
> ---
> For now I've re-used all CPU_ANY_*_FLAGS there were, but I think we
> might be better off introducing such only once dependent features
> appear. Until then the base CPU_*_FLAGS can very well be used, just like
> done here in all cases where there was no suitable CPU_ANY_*_FLAGS.
>
> --- a/gas/config/tc-i386.c
> +++ b/gas/config/tc-i386.c
> @@ -129,19 +129,11 @@ typedef struct
>    unsigned int len:8;          /* arch string length */
>    bool skip:1;                 /* show_arch should skip this. */
>    enum processor_type type;    /* arch type */
> -  i386_cpu_flags flags;                /* cpu feature flags */
> +  i386_cpu_flags enable;               /* cpu feature enable flags */
> +  i386_cpu_flags disable;      /* cpu feature disable flags */
>  }
>  arch_entry;
>
> -/* Used to turn off indicated flags.  */
> -typedef struct
> -{
> -  const char *name;            /* arch name */
> -  unsigned int len;            /* arch string length */
> -  i386_cpu_flags flags;                /* cpu feature flags */
> -}
> -noarch_entry;
> -
>  static void update_code_flag (int, int);
>  static void set_code_flag (int);
>  static void set_16bit_gcc_code_flag (int);
> @@ -932,9 +924,11 @@ const relax_typeS md_relax_table[] =
>  };
>
>  #define ARCH(n, t, f, s) \
> -  { STRING_COMMA_LEN (#n), s, PROCESSOR_ ## t, CPU_ ## f ## _FLAGS }
> -#define SUBARCH(n, e, s) \
> -  { STRING_COMMA_LEN ("." #n), s, PROCESSOR_NONE, CPU_ ## e ## _FLAGS }
> +  { STRING_COMMA_LEN (#n), s, PROCESSOR_ ## t, CPU_ ## f ## _FLAGS, \
> +    CPU_NONE_FLAGS }
> +#define SUBARCH(n, e, d, s) \
> +  { STRING_COMMA_LEN (#n), s, PROCESSOR_NONE, CPU_ ## e ## _FLAGS, \
> +    CPU_ ## d ## _FLAGS }
>
>  static const arch_entry cpu_arch[] =
>  {
> @@ -979,182 +973,128 @@ static const arch_entry cpu_arch[] =
>    ARCH (btver1, BT, BTVER1, false),
>    ARCH (btver2, BT, BTVER2, false),
>
> -  SUBARCH (8087, 8087, false),
> -  SUBARCH (287, 287, false),
> -  SUBARCH (387, 387, false),
> -  SUBARCH (687, 687, false),
> -  SUBARCH (cmov, CMOV, false),
> -  SUBARCH (fxsr, FXSR, false),
> -  SUBARCH (mmx, MMX, false),
> -  SUBARCH (sse, SSE, false),
> -  SUBARCH (sse2, SSE2, false),
> -  SUBARCH (sse3, SSE3, false),
> -  SUBARCH (sse4a, SSE4A, false),
> -  SUBARCH (ssse3, SSSE3, false),
> -  SUBARCH (sse4.1, SSE4_1, false),
> -  SUBARCH (sse4.2, SSE4_2, false),
> -  SUBARCH (sse4, SSE4_2, false),
> -  SUBARCH (avx, AVX, false),
> -  SUBARCH (avx2, AVX2, false),
> -  SUBARCH (avx512f, AVX512F, false),
> -  SUBARCH (avx512cd, AVX512CD, false),
> -  SUBARCH (avx512er, AVX512ER, false),
> -  SUBARCH (avx512pf, AVX512PF, false),
> -  SUBARCH (avx512dq, AVX512DQ, false),
> -  SUBARCH (avx512bw, AVX512BW, false),
> -  SUBARCH (avx512vl, AVX512VL, false),
> -  SUBARCH (vmx, VMX, false),
> -  SUBARCH (vmfunc, VMFUNC, false),
> -  SUBARCH (smx, SMX, false),
> -  SUBARCH (xsave, XSAVE, false),
> -  SUBARCH (xsaveopt, XSAVEOPT, false),
> -  SUBARCH (xsavec, XSAVEC, false),
> -  SUBARCH (xsaves, XSAVES, false),
> -  SUBARCH (aes, AES, false),
> -  SUBARCH (pclmul, PCLMUL, false),
> -  SUBARCH (clmul, PCLMUL, true),
> -  SUBARCH (fsgsbase, FSGSBASE, false),
> -  SUBARCH (rdrnd, RDRND, false),
> -  SUBARCH (f16c, F16C, false),
> -  SUBARCH (bmi2, BMI2, false),
> -  SUBARCH (fma, FMA, false),
> -  SUBARCH (fma4, FMA4, false),
> -  SUBARCH (xop, XOP, false),
> -  SUBARCH (lwp, LWP, false),
> -  SUBARCH (movbe, MOVBE, false),
> -  SUBARCH (cx16, CX16, false),
> -  SUBARCH (ept, EPT, false),
> -  SUBARCH (lzcnt, LZCNT, false),
> -  SUBARCH (popcnt, POPCNT, false),
> -  SUBARCH (hle, HLE, false),
> -  SUBARCH (rtm, RTM, false),
> -  SUBARCH (invpcid, INVPCID, false),
> -  SUBARCH (clflush, CLFLUSH, false),
> -  SUBARCH (nop, NOP, false),
> -  SUBARCH (syscall, SYSCALL, false),
> -  SUBARCH (rdtscp, RDTSCP, false),
> -  SUBARCH (3dnow, 3DNOW, false),
> -  SUBARCH (3dnowa, 3DNOWA, false),
> -  SUBARCH (padlock, PADLOCK, false),
> -  SUBARCH (pacifica, SVME, true),
> -  SUBARCH (svme, SVME, false),
> -  SUBARCH (sse4a, SSE4A, false),
> -  SUBARCH (abm, ABM, false),
> -  SUBARCH (bmi, BMI, false),
> -  SUBARCH (tbm, TBM, false),
> -  SUBARCH (adx, ADX, false),
> -  SUBARCH (rdseed, RDSEED, false),
> -  SUBARCH (prfchw, PRFCHW, false),
> -  SUBARCH (smap, SMAP, false),
> -  SUBARCH (mpx, MPX, false),
> -  SUBARCH (sha, SHA, false),
> -  SUBARCH (clflushopt, CLFLUSHOPT, false),
> -  SUBARCH (prefetchwt1, PREFETCHWT1, false),
> -  SUBARCH (se1, SE1, false),
> -  SUBARCH (clwb, CLWB, false),
> -  SUBARCH (avx512ifma, AVX512IFMA, false),
> -  SUBARCH (avx512vbmi, AVX512VBMI, false),
> -  SUBARCH (avx512_4fmaps, AVX512_4FMAPS, false),
> -  SUBARCH (avx512_4vnniw, AVX512_4VNNIW, false),
> -  SUBARCH (avx512_vpopcntdq, AVX512_VPOPCNTDQ, false),
> -  SUBARCH (avx512_vbmi2, AVX512_VBMI2, false),
> -  SUBARCH (avx512_vnni, AVX512_VNNI, false),
> -  SUBARCH (avx512_bitalg, AVX512_BITALG, false),
> -  SUBARCH (avx_vnni, AVX_VNNI, false),
> -  SUBARCH (clzero, CLZERO, false),
> -  SUBARCH (mwaitx, MWAITX, false),
> -  SUBARCH (ospke, OSPKE, false),
> -  SUBARCH (rdpid, RDPID, false),
> -  SUBARCH (ptwrite, PTWRITE, false),
> -  SUBARCH (ibt, IBT, false),
> -  SUBARCH (shstk, SHSTK, false),
> -  SUBARCH (gfni, GFNI, false),
> -  SUBARCH (vaes, VAES, false),
> -  SUBARCH (vpclmulqdq, VPCLMULQDQ, false),
> -  SUBARCH (wbnoinvd, WBNOINVD, false),
> -  SUBARCH (pconfig, PCONFIG, false),
> -  SUBARCH (waitpkg, WAITPKG, false),
> -  SUBARCH (cldemote, CLDEMOTE, false),
> -  SUBARCH (amx_int8, AMX_INT8, false),
> -  SUBARCH (amx_bf16, AMX_BF16, false),
> -  SUBARCH (amx_tile, AMX_TILE, false),
> -  SUBARCH (movdiri, MOVDIRI, false),
> -  SUBARCH (movdir64b, MOVDIR64B, false),
> -  SUBARCH (avx512_bf16, AVX512_BF16, false),
> -  SUBARCH (avx512_vp2intersect, AVX512_VP2INTERSECT, false),
> -  SUBARCH (tdx, TDX, false),
> -  SUBARCH (enqcmd, ENQCMD, false),
> -  SUBARCH (serialize, SERIALIZE, false),
> -  SUBARCH (rdpru, RDPRU, false),
> -  SUBARCH (mcommit, MCOMMIT, false),
> -  SUBARCH (sev_es, SEV_ES, false),
> -  SUBARCH (tsxldtrk, TSXLDTRK, false),
> -  SUBARCH (kl, KL, false),
> -  SUBARCH (widekl, WIDEKL, false),
> -  SUBARCH (uintr, UINTR, false),
> -  SUBARCH (hreset, HRESET, false),
> -  SUBARCH (avx512_fp16, AVX512_FP16, false),
> +  SUBARCH (8087, 8087, ANY_X87, false),
> +  SUBARCH (87, NONE, ANY_X87, false), /* Disable only!  */
> +  SUBARCH (287, 287, ANY_287, false),
> +  SUBARCH (387, 387, ANY_387, false),
> +  SUBARCH (687, 687, ANY_687, false),
> +  SUBARCH (cmov, CMOV, ANY_CMOV, false),
> +  SUBARCH (fxsr, FXSR, ANY_FXSR, false),
> +  SUBARCH (mmx, MMX, ANY_MMX, false),
> +  SUBARCH (sse, SSE, ANY_SSE, false),
> +  SUBARCH (sse2, SSE2, ANY_SSE2, false),
> +  SUBARCH (sse3, SSE3, ANY_SSE3, false),
> +  SUBARCH (sse4a, SSE4A, ANY_SSE4A, false),
> +  SUBARCH (ssse3, SSSE3, ANY_SSSE3, false),
> +  SUBARCH (sse4.1, SSE4_1, ANY_SSE4_1, false),
> +  SUBARCH (sse4.2, SSE4_2, ANY_SSE4_2, false),
> +  SUBARCH (sse4, SSE4_2, ANY_SSE4_1, false),
> +  SUBARCH (avx, AVX, ANY_AVX, false),
> +  SUBARCH (avx2, AVX2, ANY_AVX2, false),
> +  SUBARCH (avx512f, AVX512F, ANY_AVX512F, false),
> +  SUBARCH (avx512cd, AVX512CD, ANY_AVX512CD, false),
> +  SUBARCH (avx512er, AVX512ER, ANY_AVX512ER, false),
> +  SUBARCH (avx512pf, AVX512PF, ANY_AVX512PF, false),
> +  SUBARCH (avx512dq, AVX512DQ, ANY_AVX512DQ, false),
> +  SUBARCH (avx512bw, AVX512BW, ANY_AVX512BW, false),
> +  SUBARCH (avx512vl, AVX512VL, ANY_AVX512VL, false),
> +  SUBARCH (vmx, VMX, VMX, false),
> +  SUBARCH (vmfunc, VMFUNC, VMFUNC, false),
> +  SUBARCH (smx, SMX, SMX, false),
> +  SUBARCH (xsave, XSAVE, XSAVE, false),
> +  SUBARCH (xsaveopt, XSAVEOPT, XSAVEOPT, false),
> +  SUBARCH (xsavec, XSAVEC, XSAVEC, false),
> +  SUBARCH (xsaves, XSAVES, XSAVES, false),
> +  SUBARCH (aes, AES, AES, false),
> +  SUBARCH (pclmul, PCLMUL, PCLMUL, false),
> +  SUBARCH (clmul, PCLMUL, PCLMUL, true),
> +  SUBARCH (fsgsbase, FSGSBASE, FSGSBASE, false),
> +  SUBARCH (rdrnd, RDRND, RDRND, false),
> +  SUBARCH (f16c, F16C, F16C, false),
> +  SUBARCH (bmi2, BMI2, BMI2, false),
> +  SUBARCH (fma, FMA, FMA, false),
> +  SUBARCH (fma4, FMA4, FMA4, false),
> +  SUBARCH (xop, XOP, XOP, false),
> +  SUBARCH (lwp, LWP, LWP, false),
> +  SUBARCH (movbe, MOVBE, MOVBE, false),
> +  SUBARCH (cx16, CX16, CX16, false),
> +  SUBARCH (ept, EPT, EPT, false),
> +  SUBARCH (lzcnt, LZCNT, LZCNT, false),
> +  SUBARCH (popcnt, POPCNT, POPCNT, false),
> +  SUBARCH (hle, HLE, HLE, false),
> +  SUBARCH (rtm, RTM, RTM, false),
> +  SUBARCH (invpcid, INVPCID, INVPCID, false),
> +  SUBARCH (clflush, CLFLUSH, CLFLUSH, false),
> +  SUBARCH (nop, NOP, NOP, false),
> +  SUBARCH (syscall, SYSCALL, SYSCALL, false),
> +  SUBARCH (rdtscp, RDTSCP, RDTSCP, false),
> +  SUBARCH (3dnow, 3DNOW, 3DNOW, false),
> +  SUBARCH (3dnowa, 3DNOWA, 3DNOWA, false),
> +  SUBARCH (padlock, PADLOCK, PADLOCK, false),
> +  SUBARCH (pacifica, SVME, SVME, true),
> +  SUBARCH (svme, SVME, SVME, false),
> +  SUBARCH (sse4a, SSE4A, SSE4A, false),
> +  SUBARCH (abm, ABM, ABM, false),
> +  SUBARCH (bmi, BMI, BMI, false),
> +  SUBARCH (tbm, TBM, TBM, false),
> +  SUBARCH (adx, ADX, ADX, false),
> +  SUBARCH (rdseed, RDSEED, RDSEED, false),
> +  SUBARCH (prfchw, PRFCHW, PRFCHW, false),
> +  SUBARCH (smap, SMAP, SMAP, false),
> +  SUBARCH (mpx, MPX, MPX, false),
> +  SUBARCH (sha, SHA, SHA, false),
> +  SUBARCH (clflushopt, CLFLUSHOPT, CLFLUSHOPT, false),
> +  SUBARCH (prefetchwt1, PREFETCHWT1, PREFETCHWT1, false),
> +  SUBARCH (se1, SE1, SE1, false),
> +  SUBARCH (clwb, CLWB, CLWB, false),
> +  SUBARCH (avx512ifma, AVX512IFMA, ANY_AVX512IFMA, false),
> +  SUBARCH (avx512vbmi, AVX512VBMI, ANY_AVX512VBMI, false),
> +  SUBARCH (avx512_4fmaps, AVX512_4FMAPS, ANY_AVX512_4FMAPS, false),
> +  SUBARCH (avx512_4vnniw, AVX512_4VNNIW, ANY_AVX512_4VNNIW, false),
> +  SUBARCH (avx512_vpopcntdq, AVX512_VPOPCNTDQ, ANY_AVX512_VPOPCNTDQ, false),
> +  SUBARCH (avx512_vbmi2, AVX512_VBMI2, ANY_AVX512_VBMI2, false),
> +  SUBARCH (avx512_vnni, AVX512_VNNI, ANY_AVX512_VNNI, false),
> +  SUBARCH (avx512_bitalg, AVX512_BITALG, ANY_AVX512_BITALG, false),
> +  SUBARCH (avx_vnni, AVX_VNNI, ANY_AVX_VNNI, false),
> +  SUBARCH (clzero, CLZERO, CLZERO, false),
> +  SUBARCH (mwaitx, MWAITX, MWAITX, false),
> +  SUBARCH (ospke, OSPKE, OSPKE, false),
> +  SUBARCH (rdpid, RDPID, RDPID, false),
> +  SUBARCH (ptwrite, PTWRITE, PTWRITE, false),
> +  SUBARCH (ibt, IBT, ANY_IBT, false),
> +  SUBARCH (shstk, SHSTK, ANY_SHSTK, false),
> +  SUBARCH (gfni, GFNI, GFNI, false),
> +  SUBARCH (vaes, VAES, VAES, false),
> +  SUBARCH (vpclmulqdq, VPCLMULQDQ, VPCLMULQDQ, false),
> +  SUBARCH (wbnoinvd, WBNOINVD, WBNOINVD, false),
> +  SUBARCH (pconfig, PCONFIG, PCONFIG, false),
> +  SUBARCH (waitpkg, WAITPKG, WAITPKG, false),
> +  SUBARCH (cldemote, CLDEMOTE, CLDEMOTE, false),
> +  SUBARCH (amx_int8, AMX_INT8, ANY_AMX_INT8, false),
> +  SUBARCH (amx_bf16, AMX_BF16, ANY_AMX_BF16, false),
> +  SUBARCH (amx_tile, AMX_TILE, ANY_AMX_TILE, false),
> +  SUBARCH (movdiri, MOVDIRI, ANY_MOVDIRI, false),
> +  SUBARCH (movdir64b, MOVDIR64B, ANY_MOVDIR64B, false),
> +  SUBARCH (avx512_bf16, AVX512_BF16, ANY_AVX512_BF16, false),
> +  SUBARCH (avx512_vp2intersect, AVX512_VP2INTERSECT,
> +          ANY_AVX512_VP2INTERSECT, false),
> +  SUBARCH (tdx, TDX, ANY_TDX, false),
> +  SUBARCH (enqcmd, ENQCMD, ANY_ENQCMD, false),
> +  SUBARCH (serialize, SERIALIZE, ANY_SERIALIZE, false),
> +  SUBARCH (rdpru, RDPRU, RDPRU, false),
> +  SUBARCH (mcommit, MCOMMIT, MCOMMIT, false),
> +  SUBARCH (sev_es, SEV_ES, SEV_ES, false),
> +  SUBARCH (tsxldtrk, TSXLDTRK, ANY_TSXLDTRK, false),
> +  SUBARCH (kl, KL, ANY_KL, false),
> +  SUBARCH (widekl, WIDEKL, ANY_WIDEKL, false),
> +  SUBARCH (uintr, UINTR, ANY_UINTR, false),
> +  SUBARCH (hreset, HRESET, ANY_HRESET, false),
> +  SUBARCH (avx512_fp16, AVX512_FP16, ANY_AVX512_FP16, false),
>  };
>
>  #undef SUBARCH
>  #undef ARCH
>
> -static const noarch_entry cpu_noarch[] =
> -{
> -  { STRING_COMMA_LEN ("no87"),  CPU_ANY_X87_FLAGS },
> -  { STRING_COMMA_LEN ("no287"),  CPU_ANY_287_FLAGS },
> -  { STRING_COMMA_LEN ("no387"),  CPU_ANY_387_FLAGS },
> -  { STRING_COMMA_LEN ("no687"),  CPU_ANY_687_FLAGS },
> -  { STRING_COMMA_LEN ("nocmov"),  CPU_ANY_CMOV_FLAGS },
> -  { STRING_COMMA_LEN ("nofxsr"),  CPU_ANY_FXSR_FLAGS },
> -  { STRING_COMMA_LEN ("nommx"),  CPU_ANY_MMX_FLAGS },
> -  { STRING_COMMA_LEN ("nosse"),  CPU_ANY_SSE_FLAGS },
> -  { STRING_COMMA_LEN ("nosse2"),  CPU_ANY_SSE2_FLAGS },
> -  { STRING_COMMA_LEN ("nosse3"),  CPU_ANY_SSE3_FLAGS },
> -  { STRING_COMMA_LEN ("nosse4a"),  CPU_ANY_SSE4A_FLAGS },
> -  { STRING_COMMA_LEN ("nossse3"),  CPU_ANY_SSSE3_FLAGS },
> -  { STRING_COMMA_LEN ("nosse4.1"),  CPU_ANY_SSE4_1_FLAGS },
> -  { STRING_COMMA_LEN ("nosse4.2"),  CPU_ANY_SSE4_2_FLAGS },
> -  { STRING_COMMA_LEN ("nosse4"),  CPU_ANY_SSE4_1_FLAGS },
> -  { STRING_COMMA_LEN ("noavx"),  CPU_ANY_AVX_FLAGS },
> -  { STRING_COMMA_LEN ("noavx2"),  CPU_ANY_AVX2_FLAGS },
> -  { STRING_COMMA_LEN ("noavx512f"), CPU_ANY_AVX512F_FLAGS },
> -  { STRING_COMMA_LEN ("noavx512cd"), CPU_ANY_AVX512CD_FLAGS },
> -  { STRING_COMMA_LEN ("noavx512er"), CPU_ANY_AVX512ER_FLAGS },
> -  { STRING_COMMA_LEN ("noavx512pf"), CPU_ANY_AVX512PF_FLAGS },
> -  { STRING_COMMA_LEN ("noavx512dq"), CPU_ANY_AVX512DQ_FLAGS },
> -  { STRING_COMMA_LEN ("noavx512bw"), CPU_ANY_AVX512BW_FLAGS },
> -  { STRING_COMMA_LEN ("noavx512vl"), CPU_ANY_AVX512VL_FLAGS },
> -  { STRING_COMMA_LEN ("noavx512ifma"), CPU_ANY_AVX512IFMA_FLAGS },
> -  { STRING_COMMA_LEN ("noavx512vbmi"), CPU_ANY_AVX512VBMI_FLAGS },
> -  { STRING_COMMA_LEN ("noavx512_4fmaps"), CPU_ANY_AVX512_4FMAPS_FLAGS },
> -  { STRING_COMMA_LEN ("noavx512_4vnniw"), CPU_ANY_AVX512_4VNNIW_FLAGS },
> -  { STRING_COMMA_LEN ("noavx512_vpopcntdq"), CPU_ANY_AVX512_VPOPCNTDQ_FLAGS },
> -  { STRING_COMMA_LEN ("noavx512_vbmi2"), CPU_ANY_AVX512_VBMI2_FLAGS },
> -  { STRING_COMMA_LEN ("noavx512_vnni"), CPU_ANY_AVX512_VNNI_FLAGS },
> -  { STRING_COMMA_LEN ("noavx512_bitalg"), CPU_ANY_AVX512_BITALG_FLAGS },
> -  { STRING_COMMA_LEN ("noavx_vnni"), CPU_ANY_AVX_VNNI_FLAGS },
> -  { STRING_COMMA_LEN ("noibt"), CPU_ANY_IBT_FLAGS },
> -  { STRING_COMMA_LEN ("noshstk"), CPU_ANY_SHSTK_FLAGS },
> -  { STRING_COMMA_LEN ("noamx_int8"), CPU_ANY_AMX_INT8_FLAGS },
> -  { STRING_COMMA_LEN ("noamx_bf16"), CPU_ANY_AMX_BF16_FLAGS },
> -  { STRING_COMMA_LEN ("noamx_tile"), CPU_ANY_AMX_TILE_FLAGS },
> -  { STRING_COMMA_LEN ("nomovdiri"), CPU_ANY_MOVDIRI_FLAGS },
> -  { STRING_COMMA_LEN ("nomovdir64b"), CPU_ANY_MOVDIR64B_FLAGS },
> -  { STRING_COMMA_LEN ("noavx512_bf16"), CPU_ANY_AVX512_BF16_FLAGS },
> -  { STRING_COMMA_LEN ("noavx512_vp2intersect"),
> -    CPU_ANY_AVX512_VP2INTERSECT_FLAGS },
> -  { STRING_COMMA_LEN ("notdx"), CPU_ANY_TDX_FLAGS },
> -  { STRING_COMMA_LEN ("noenqcmd"), CPU_ANY_ENQCMD_FLAGS },
> -  { STRING_COMMA_LEN ("noserialize"), CPU_ANY_SERIALIZE_FLAGS },
> -  { STRING_COMMA_LEN ("notsxldtrk"), CPU_ANY_TSXLDTRK_FLAGS },
> -  { STRING_COMMA_LEN ("nokl"), CPU_ANY_KL_FLAGS },
> -  { STRING_COMMA_LEN ("nowidekl"), CPU_ANY_WIDEKL_FLAGS },
> -  { STRING_COMMA_LEN ("nouintr"), CPU_ANY_UINTR_FLAGS },
> -  { STRING_COMMA_LEN ("nohreset"), CPU_ANY_HRESET_FLAGS },
> -  { STRING_COMMA_LEN ("noavx512_fp16"), CPU_ANY_AVX512_FP16_FLAGS },
> -};
> -
>  #ifdef I386COFF
>  /* Like s_lcomm_internal in gas/read.c but the alignment string
>     is allowed to be optional.  */
> @@ -2715,9 +2655,9 @@ extend_cpu_sub_arch_name (const char *na
>  {
>    if (cpu_sub_arch_name)
>      cpu_sub_arch_name = reconcat (cpu_sub_arch_name, cpu_sub_arch_name,
> -                                 name, (const char *) NULL);
> +                                 ".", name, (const char *) NULL);
>    else
> -    cpu_sub_arch_name = xstrdup (name);
> +    cpu_sub_arch_name = concat (".", name, (const char *) NULL);
>  }
>
>  static void
> @@ -2756,7 +2696,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
>                   cpu_arch_flags.bitfield.cpuno64 = 1;
>                 }
>               cpu_arch_isa = PROCESSOR_UNKNOWN;
> -             cpu_arch_isa_flags = cpu_arch[flag_code == CODE_64BIT].flags;
> +             cpu_arch_isa_flags = cpu_arch[flag_code == CODE_64BIT].enable;
>               if (!cpu_arch_tune_set)
>                 {
>                   cpu_arch_tune = cpu_arch_isa;
> @@ -2769,16 +2709,17 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
>
>        for (; j < ARRAY_SIZE (cpu_arch); j++)
>         {
> -         if (strcmp (string, cpu_arch[j].name) == 0)
> +         if (strcmp (string + (*string == '.'), cpu_arch[j].name) == 0
> +            && (*string == '.') == (cpu_arch[j].type == PROCESSOR_NONE))
>             {
>               if (*string != '.')
>                 {
> -                 check_cpu_arch_compatible (string, cpu_arch[j].flags);
> +                 check_cpu_arch_compatible (string, cpu_arch[j].enable);
>
>                   cpu_arch_name = cpu_arch[j].name;
>                   xfree (cpu_sub_arch_name);
>                   cpu_sub_arch_name = NULL;
> -                 cpu_arch_flags = cpu_arch[j].flags;
> +                 cpu_arch_flags = cpu_arch[j].enable;
>                   if (flag_code == CODE_64BIT)
>                     {
>                       cpu_arch_flags.bitfield.cpu64 = 1;
> @@ -2790,7 +2731,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
>                       cpu_arch_flags.bitfield.cpuno64 = 1;
>                     }
>                   cpu_arch_isa = cpu_arch[j].type;
> -                 cpu_arch_isa_flags = cpu_arch[j].flags;
> +                 cpu_arch_isa_flags = cpu_arch[j].enable;
>                   if (!cpu_arch_tune_set)
>                     {
>                       cpu_arch_tune = cpu_arch_isa;
> @@ -2799,36 +2740,40 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
>                   break;
>                 }
>
> +             if (cpu_flags_all_zero (&cpu_arch[j].enable))
> +               continue;
> +
>               flags = cpu_flags_or (cpu_arch_flags,
> -                                   cpu_arch[j].flags);
> +                                   cpu_arch[j].enable);
>
>               if (!cpu_flags_equal (&flags, &cpu_arch_flags))
>                 {
> -                 extend_cpu_sub_arch_name (string);
> +                 extend_cpu_sub_arch_name (string + 1);
>                   cpu_arch_flags = flags;
>                   cpu_arch_isa_flags = flags;
>                 }
>               else
>                 cpu_arch_isa_flags
>                   = cpu_flags_or (cpu_arch_isa_flags,
> -                                 cpu_arch[j].flags);
> +                                 cpu_arch[j].enable);
>               (void) restore_line_pointer (e);
>               demand_empty_rest_of_line ();
>               return;
>             }
>         }
>
> -      if (*string == '.' && j >= ARRAY_SIZE (cpu_arch))
> +      if (startswith (string, ".no") && j >= ARRAY_SIZE (cpu_arch))
>         {
>           /* Disable an ISA extension.  */
> -         for (j = 0; j < ARRAY_SIZE (cpu_noarch); j++)
> -           if (strcmp (string + 1, cpu_noarch [j].name) == 0)
> +         for (j = 0; j < ARRAY_SIZE (cpu_arch); j++)
> +           if (cpu_arch[j].type == PROCESSOR_NONE
> +               && strcmp (string + 3, cpu_arch[j].name) == 0)
>               {
>                 flags = cpu_flags_and_not (cpu_arch_flags,
> -                                          cpu_noarch[j].flags);
> +                                          cpu_arch[j].disable);
>                 if (!cpu_flags_equal (&flags, &cpu_arch_flags))
>                   {
> -                   extend_cpu_sub_arch_name (string);
> +                   extend_cpu_sub_arch_name (string + 1);
>                     cpu_arch_flags = flags;
>                     cpu_arch_isa_flags = flags;
>                   }
> @@ -2836,8 +2781,6 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
>                 demand_empty_rest_of_line ();
>                 return;
>               }
> -
> -         j = ARRAY_SIZE (cpu_arch);
>         }
>
>        if (j == ARRAY_SIZE (cpu_arch))
> @@ -13288,18 +13231,19 @@ md_parse_option (int c, const char *arg)
>             *next++ = '\0';
>           for (j = 0; j < ARRAY_SIZE (cpu_arch); j++)
>             {
> -             if (arch == saved && strcmp (arch, cpu_arch [j].name) == 0)
> +             if (arch == saved && cpu_arch[j].type != PROCESSOR_NONE
> +                 && strcmp (arch, cpu_arch[j].name) == 0)
>                 {
>                   /* Processor.  */
> -                 if (! cpu_arch[j].flags.bitfield.cpui386)
> +                 if (! cpu_arch[j].enable.bitfield.cpui386)
>                     continue;
>
>                   cpu_arch_name = cpu_arch[j].name;
>                   xfree (cpu_sub_arch_name);
>                   cpu_sub_arch_name = NULL;
> -                 cpu_arch_flags = cpu_arch[j].flags;
> +                 cpu_arch_flags = cpu_arch[j].enable;
>                   cpu_arch_isa = cpu_arch[j].type;
> -                 cpu_arch_isa_flags = cpu_arch[j].flags;
> +                 cpu_arch_isa_flags = cpu_arch[j].enable;
>                   if (!cpu_arch_tune_set)
>                     {
>                       cpu_arch_tune = cpu_arch_isa;
> @@ -13307,39 +13251,41 @@ md_parse_option (int c, const char *arg)
>                     }
>                   break;
>                 }
> -             else if (*cpu_arch [j].name == '.'
> -                      && strcmp (arch, cpu_arch [j].name + 1) == 0)
> +             else if (cpu_arch[j].type == PROCESSOR_NONE
> +                      && strcmp (arch, cpu_arch[j].name) == 0
> +                      && !cpu_flags_all_zero (&cpu_arch[j].enable))
>                 {
>                   /* ISA extension.  */
>                   i386_cpu_flags flags;
>
>                   flags = cpu_flags_or (cpu_arch_flags,
> -                                       cpu_arch[j].flags);
> +                                       cpu_arch[j].enable);
>
>                   if (!cpu_flags_equal (&flags, &cpu_arch_flags))
>                     {
> -                     extend_cpu_sub_arch_name (cpu_arch[j].name);
> +                     extend_cpu_sub_arch_name (arch);
>                       cpu_arch_flags = flags;
>                       cpu_arch_isa_flags = flags;
>                     }
>                   else
>                     cpu_arch_isa_flags
>                       = cpu_flags_or (cpu_arch_isa_flags,
> -                                     cpu_arch[j].flags);
> +                                     cpu_arch[j].enable);
>                   break;
>                 }
>             }
>
> -         if (j >= ARRAY_SIZE (cpu_arch))
> +         if (j >= ARRAY_SIZE (cpu_arch) && startswith (arch, "no"))
>             {
>               /* Disable an ISA extension.  */
> -             for (j = 0; j < ARRAY_SIZE (cpu_noarch); j++)
> -               if (strcmp (arch, cpu_noarch [j].name) == 0)
> +             for (j = 0; j < ARRAY_SIZE (cpu_arch); j++)
> +               if (cpu_arch[j].type == PROCESSOR_NONE
> +                   && strcmp (arch + 2, cpu_arch[j].name) == 0)
>                   {
>                     i386_cpu_flags flags;
>
>                     flags = cpu_flags_and_not (cpu_arch_flags,
> -                                              cpu_noarch[j].flags);
> +                                              cpu_arch[j].disable);
>                     if (!cpu_flags_equal (&flags, &cpu_arch_flags))
>                       {
>                         extend_cpu_sub_arch_name (arch);
> @@ -13348,9 +13294,6 @@ md_parse_option (int c, const char *arg)
>                       }
>                     break;
>                   }
> -
> -             if (j >= ARRAY_SIZE (cpu_noarch))
> -               j = ARRAY_SIZE (cpu_arch);
>             }
>
>           if (j >= ARRAY_SIZE (cpu_arch))
> @@ -13367,11 +13310,12 @@ md_parse_option (int c, const char *arg)
>         as_fatal (_("invalid -mtune= option: `%s'"), arg);
>        for (j = 0; j < ARRAY_SIZE (cpu_arch); j++)
>         {
> -         if (strcmp (arg, cpu_arch [j].name) == 0)
> +         if (cpu_arch[j].type != PROCESSOR_NONE
> +             && strcmp (arg, cpu_arch[j].name) == 0)
>             {
>               cpu_arch_tune_set = 1;
>               cpu_arch_tune = cpu_arch [j].type;
> -             cpu_arch_tune_flags = cpu_arch[j].flags;
> +             cpu_arch_tune_flags = cpu_arch[j].enable;
>               break;
>             }
>         }
> @@ -13751,15 +13695,10 @@ show_arch (FILE *stream, int ext, int ch
>
>        name = cpu_arch [j].name;
>        len = cpu_arch [j].len;
> -      if (*name == '.')
> +      if (cpu_arch[j].type == PROCESSOR_NONE)
>         {
>           /* It is an extension.  Skip if we aren't asked to show it.  */
> -         if (ext)
> -           {
> -             name++;
> -             len--;
> -           }
> -         else
> +         if (!ext || cpu_flags_all_zero (&cpu_arch[j].enable))
>             continue;
>         }
>        else if (ext)
> @@ -13767,7 +13706,7 @@ show_arch (FILE *stream, int ext, int ch
>           /* It is an processor.  Skip if we show only extension.  */
>           continue;
>         }
> -      else if (check && ! cpu_arch[j].flags.bitfield.cpui386)
> +      else if (check && ! cpu_arch[j].enable.bitfield.cpui386)
>         {
>           /* It is an impossible processor - skip.  */
>           continue;
> @@ -13778,12 +13717,17 @@ show_arch (FILE *stream, int ext, int ch
>
>    /* Display disabled extensions.  */
>    if (ext)
> -    for (j = 0; j < ARRAY_SIZE (cpu_noarch); j++)
> +    for (j = 0; j < ARRAY_SIZE (cpu_arch); j++)
>        {
> -       name = cpu_noarch [j].name;
> -       len = cpu_noarch [j].len;
> -       p = output_message (stream, p, message, start, &left, name,
> -                           len);
> +       char *str;
> +
> +       if (cpu_arch[j].type != PROCESSOR_NONE
> +           || !cpu_flags_all_zero (&cpu_arch[j].enable))
> +         continue;
> +       str = xasprintf ("no%s", cpu_arch[j].name);
> +       p = output_message (stream, p, message, start, &left, str,
> +                           strlen (str));
> +       xfree (str);
>        }
>
>    *p = '\0';
> @@ -13827,7 +13771,7 @@ md_show_usage (FILE *stream)
>                            generate code for CPU and EXTENSION, CPU is one of:\n"));
>    show_arch (stream, 0, 1);
>    fprintf (stream, _("\
> -                          EXTENSION is combination of:\n"));
> +                          EXTENSION is combination of (possibly \"no\"-prefixed):\n"));
>    show_arch (stream, 1, 0);
>    fprintf (stream, _("\
>    -mtune=CPU              optimize for CPU, CPU is one of:\n"));
> @@ -13985,9 +13929,9 @@ i386_target_format (void)
>      as_fatal (_("unknown architecture"));
>
>    if (cpu_flags_all_zero (&cpu_arch_isa_flags))
> -    cpu_arch_isa_flags = cpu_arch[flag_code == CODE_64BIT].flags;
> +    cpu_arch_isa_flags = cpu_arch[flag_code == CODE_64BIT].enable;
>    if (cpu_flags_all_zero (&cpu_arch_tune_flags))
> -    cpu_arch_tune_flags = cpu_arch[flag_code == CODE_64BIT].flags;
> +    cpu_arch_tune_flags = cpu_arch[flag_code == CODE_64BIT].enable;
>
>    switch (OUTPUT_FLAVOR)
>      {
>

OK.

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 7/7] x86: introduce a state stack for .arch
  2022-06-30 12:55 ` [PATCH 7/7] x86: introduce a state stack for .arch Jan Beulich
@ 2022-06-30 23:15   ` H.J. Lu
  0 siblings, 0 replies; 17+ messages in thread
From: H.J. Lu @ 2022-06-30 23:15 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Binutils

On Thu, Jun 30, 2022 at 5:55 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> When using just slightly non-trivial combinations of .arch, it can be
> quite useful to be able to go back to prior state without needing to
> re-invoke perhaps many earlier directives and without needing to invoke
> perhaps many "negative" ones. Like some other architectures allow
> saving (pushing) and restoring (popping) present/prior state.
>
> For now require the same .code<N> to be in effect for ".arch pop" that
> was in effect for the corresponding ".arch push".
>
> Also change the global "no_cond_jump_promotion" to be bool, to match the
> new struct field.
>
> --- a/gas/config/tc-i386.c
> +++ b/gas/config/tc-i386.c
> @@ -788,7 +788,7 @@ i386_cpu_flags cpu_arch_isa_flags;
>
>  /* If set, conditional jumps are not automatically promoted to handle
>     larger than a byte offset.  */
> -static unsigned int no_cond_jump_promotion = 0;
> +static bool no_cond_jump_promotion = false;
>
>  /* Encode SSE instructions with VEX prefix.  */
>  static unsigned int sse2avx;
> @@ -2663,6 +2663,20 @@ extend_cpu_sub_arch_name (const char *na
>  static void
>  set_cpu_arch (int dummy ATTRIBUTE_UNUSED)
>  {
> +  typedef struct arch_stack_entry
> +  {
> +    const struct arch_stack_entry *prev;
> +    const char *name;
> +    char *sub_name;
> +    i386_cpu_flags flags;
> +    i386_cpu_flags isa_flags;
> +    enum processor_type isa;
> +    enum flag_code flag_code;
> +    char stackop_size;
> +    bool no_cond_jump_promotion;
> +  } arch_stack_entry;
> +  static const arch_stack_entry *arch_stack_top;
> +
>    SKIP_WHITESPACE ();
>
>    if (!is_end_of_line[(unsigned char) *input_line_pointer])
> @@ -2706,6 +2720,67 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
>               j = ARRAY_SIZE (cpu_arch) + 1;
>             }
>         }
> +      else if (strcmp (string, "push") == 0)
> +       {
> +         arch_stack_entry *top = XNEW (arch_stack_entry);
> +
> +         top->name = cpu_arch_name;
> +         if (cpu_sub_arch_name)
> +           top->sub_name = xstrdup (cpu_sub_arch_name);
> +         else
> +           top->sub_name = NULL;
> +         top->flags = cpu_arch_flags;
> +         top->isa = cpu_arch_isa;
> +         top->isa_flags = cpu_arch_isa_flags;
> +         top->flag_code = flag_code;
> +         top->stackop_size = stackop_size;
> +         top->no_cond_jump_promotion = no_cond_jump_promotion;
> +
> +         top->prev = arch_stack_top;
> +         arch_stack_top = top;
> +
> +         (void) restore_line_pointer (e);
> +         demand_empty_rest_of_line ();
> +         return;
> +       }
> +      else if (strcmp (string, "pop") == 0)
> +       {
> +         const arch_stack_entry *top = arch_stack_top;
> +
> +         if (!top)
> +           as_bad (_(".arch stack is empty"));
> +         else if (top->flag_code != flag_code
> +                  || top->stackop_size != stackop_size)
> +           {
> +             static const unsigned int bits[] = {
> +               [CODE_16BIT] = 16,
> +               [CODE_32BIT] = 32,
> +               [CODE_64BIT] = 64,
> +             };
> +
> +             as_bad (_("this `.arch pop' requires `.code%u%s' to be in effect"),
> +                     bits[top->flag_code],
> +                     top->stackop_size == LONG_MNEM_SUFFIX ? "gcc" : "");
> +           }
> +         else
> +           {
> +             arch_stack_top = top->prev;
> +
> +             cpu_arch_name = top->name;
> +             xfree (cpu_sub_arch_name);

Can we just use free?

> +             cpu_sub_arch_name = top->sub_name;
> +             cpu_arch_flags = top->flags;
> +             cpu_arch_isa = top->isa;
> +             cpu_arch_isa_flags = top->isa_flags;
> +             no_cond_jump_promotion = top->no_cond_jump_promotion;
> +
> +             XDELETE (top);
> +           }
> +
> +         (void) restore_line_pointer (e);
> +         demand_empty_rest_of_line ();
> +         return;
> +       }
>
>        for (; j < ARRAY_SIZE (cpu_arch); j++)
>         {
> @@ -13685,6 +13760,10 @@ show_arch (FILE *stream, int ext, int ch
>      {
>        p = output_message (stream, p, message, start, &left,
>                           STRING_COMMA_LEN ("default"));
> +      p = output_message (stream, p, message, start, &left,
> +                         STRING_COMMA_LEN ("push"));
> +      p = output_message (stream, p, message, start, &left,
> +                         STRING_COMMA_LEN ("pop"));
>      }
>
>    for (j = 0; j < ARRAY_SIZE (cpu_arch); j++)
> --- a/gas/doc/c-i386.texi
> +++ b/gas/doc/c-i386.texi
> @@ -1504,7 +1504,7 @@ directive enables a warning when gas det
>  supported on the CPU specified.  The choices for @var{cpu_type} are:
>
>  @multitable @columnfractions .20 .20 .20 .20
> -@item @samp{default}
> +@item @samp{default} @tab @samp{push} @tab @samp{pop}
>  @item @samp{i8086} @tab @samp{i186} @tab @samp{i286} @tab @samp{i386}
>  @item @samp{i486} @tab @samp{i586} @tab @samp{i686} @tab @samp{pentium}
>  @item @samp{pentiumpro} @tab @samp{pentiumii} @tab @samp{pentiumiii} @tab @samp{pentium4}
> --- /dev/null
> +++ b/gas/testsuite/gas/i386/arch-stk.l
> @@ -0,0 +1,43 @@
> +.*: Assembler messages:
> +.*:3: Error:.*`cmovl'.*
> +.*:10: Error:.*`cmovg'.*
> +.*:17: Error:.*`cmovz'.*
> +.*:21: Error:.*`\.arch pop'.*`\.code32'.*
> +.*:28: Error:.*`\.arch pop'.*`\.code16gcc'.*
> +.*:32: Error:.*\.arch.*empty.*
> +GAS LISTING .*
> +
> +
> +[      ]*[0-9]*[       ]+\.text
> +[      ]*[0-9]*[       ]+start:
> +[      ]*[0-9]*[       ]+cmovl %eax, %ecx
> +[      ]*[0-9]*[       ]*
> +[      ]*[0-9]*[       ]+\.arch push
> +[      ]*[0-9]*[       ]+\.arch default
> +[      ]*[0-9]*[       ]+\?\?\?\? 0F4DC8[      ]+cmovnl        %eax, %ecx
> +[      ]*[0-9]*[       ]*
> +[      ]*[0-9]*[       ]+\.arch pop
> +[      ]*[0-9]*[       ]+cmovg %eax, %ecx
> +[      ]*[0-9]*[       ]*
> +[      ]*[0-9]*[       ]+\.arch push
> +[      ]*[0-9]*[       ]+\.arch \.cmov
> +[      ]*[0-9]*[       ]+\?\?\?\? 0F4EC8[      ]+cmovng        %eax, %ecx
> +[      ]*[0-9]*[       ]*
> +[      ]*[0-9]*[       ]+\.arch pop
> +[      ]*[0-9]*[       ]+cmovz %eax, %ecx
> +[      ]*[0-9]*[       ]*
> +[      ]*[0-9]*[       ]+\.arch push
> +[      ]*[0-9]*[       ]+\.code16
> +[      ]*[0-9]*[       ]+\.arch pop
> +[      ]*[0-9]*[       ]+\.code32
> +[      ]*[0-9]*[       ]+\.arch pop
> +[      ]*[0-9]*[       ]*
> +[      ]*[0-9]*[       ]+\.code16gcc
> +[      ]*[0-9]*[       ]+\.arch push
> +[      ]*[0-9]*[       ]+\.code32
> +[      ]*[0-9]*[       ]+\.arch pop
> +[      ]*[0-9]*[       ]+\.code16gcc
> +[      ]*[0-9]*[       ]+\.arch pop
> +[      ]*[0-9]*[       ]*
> +[      ]*[0-9]*[       ]+\.arch pop
> +#pass
> --- /dev/null
> +++ b/gas/testsuite/gas/i386/arch-stk.s
> @@ -0,0 +1,34 @@
> +       .text
> +start:
> +       cmovl   %eax, %ecx
> +
> +       .arch push
> +       .arch default
> +       cmovnl  %eax, %ecx
> +
> +       .arch pop
> +       cmovg   %eax, %ecx
> +
> +       .arch push
> +       .arch .cmov
> +       cmovng  %eax, %ecx
> +
> +       .arch pop
> +       cmovz   %eax, %ecx
> +
> +       .arch push
> +       .code16
> +       .arch pop
> +       .code32
> +       .arch pop
> +
> +       .code16gcc
> +       .arch push
> +       .code32
> +       .arch pop
> +       .code16gcc
> +       .arch pop
> +
> +       .arch pop
> +
> +       .end
> --- a/gas/testsuite/gas/i386/i386.exp
> +++ b/gas/testsuite/gas/i386/i386.exp
> @@ -206,6 +206,7 @@ if [gas_32_check] then {
>      run_dump_test "arch-13"
>      run_dump_test "arch-14"
>      run_list_test "arch-dflt" "-march=generic32 -al"
> +    run_list_test "arch-stk" "-march=generic32 -al"
>      run_dump_test "8087"
>      run_dump_test "287"
>      run_dump_test "387"
>


-- 
H.J.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/7] x86: don't leak sub-architecture accumulated strings
  2022-06-30 22:54   ` H.J. Lu
@ 2022-07-01 10:18     ` Jan Beulich
  2022-07-01 19:44       ` H.J. Lu
  0 siblings, 1 reply; 17+ messages in thread
From: Jan Beulich @ 2022-07-01 10:18 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Binutils

On 01.07.2022 00:54, H.J. Lu wrote:
> On Thu, Jun 30, 2022 at 5:53 AM Jan Beulich <jbeulich@suse.com> wrote:
>> --- a/gas/config/tc-i386.c
>> +++ b/gas/config/tc-i386.c
>> @@ -2871,6 +2871,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
>>                   check_cpu_arch_compatible (string, cpu_arch[j].flags);
>>
>>                   cpu_arch_name = cpu_arch[j].name;
>> +                 xfree (cpu_sub_arch_name);
>>                   cpu_sub_arch_name = NULL;
>>                   cpu_arch_flags = cpu_arch[j].flags;
>>                   if (flag_code == CODE_64BIT)
>> @@ -13406,6 +13407,7 @@ md_parse_option (int c, const char *arg)
>>                     continue;
>>
>>                   cpu_arch_name = cpu_arch[j].name;
>> +                 xfree (cpu_sub_arch_name);
>>                   cpu_sub_arch_name = NULL;
>>                   cpu_arch_flags = cpu_arch[j].flags;
>>                   cpu_arch_isa = cpu_arch[j].type;
>> @@ -14086,6 +14088,7 @@ i386_target_format (void)
>>         {
>>           static const i386_cpu_flags iamcu_flags = CPU_IAMCU_FLAGS;
>>           cpu_arch_name = "iamcu";
>> +         xfree (cpu_sub_arch_name);
>>           cpu_sub_arch_name = NULL;
>>           cpu_arch_flags = iamcu_flags;
>>           cpu_arch_isa = PROCESSOR_IAMCU;
>>
> 
> Can we just use free?

In principle yes, but I view using free() as inconsistent when the
allocation used xmalloc() or alike. These should pair, even if right
now xfree() simply aliases to free() - this could change down the
road, and then cause unnecessary code churn just to update all such
instances.

Jan

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/7] x86: don't leak sub-architecture accumulated strings
  2022-07-01 10:18     ` Jan Beulich
@ 2022-07-01 19:44       ` H.J. Lu
  0 siblings, 0 replies; 17+ messages in thread
From: H.J. Lu @ 2022-07-01 19:44 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Binutils

On Fri, Jul 1, 2022 at 3:18 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 01.07.2022 00:54, H.J. Lu wrote:
> > On Thu, Jun 30, 2022 at 5:53 AM Jan Beulich <jbeulich@suse.com> wrote:
> >> --- a/gas/config/tc-i386.c
> >> +++ b/gas/config/tc-i386.c
> >> @@ -2871,6 +2871,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
> >>                   check_cpu_arch_compatible (string, cpu_arch[j].flags);
> >>
> >>                   cpu_arch_name = cpu_arch[j].name;
> >> +                 xfree (cpu_sub_arch_name);
> >>                   cpu_sub_arch_name = NULL;
> >>                   cpu_arch_flags = cpu_arch[j].flags;
> >>                   if (flag_code == CODE_64BIT)
> >> @@ -13406,6 +13407,7 @@ md_parse_option (int c, const char *arg)
> >>                     continue;
> >>
> >>                   cpu_arch_name = cpu_arch[j].name;
> >> +                 xfree (cpu_sub_arch_name);
> >>                   cpu_sub_arch_name = NULL;
> >>                   cpu_arch_flags = cpu_arch[j].flags;
> >>                   cpu_arch_isa = cpu_arch[j].type;
> >> @@ -14086,6 +14088,7 @@ i386_target_format (void)
> >>         {
> >>           static const i386_cpu_flags iamcu_flags = CPU_IAMCU_FLAGS;
> >>           cpu_arch_name = "iamcu";
> >> +         xfree (cpu_sub_arch_name);
> >>           cpu_sub_arch_name = NULL;
> >>           cpu_arch_flags = iamcu_flags;
> >>           cpu_arch_isa = PROCESSOR_IAMCU;
> >>
> >
> > Can we just use free?
>
> In principle yes, but I view using free() as inconsistent when the
> allocation used xmalloc() or alike. These should pair, even if right
> now xfree() simply aliases to free() - this could change down the
> road, and then cause unnecessary code churn just to update all such
> instances.
>

I don't think we will change xfree.  Just use free directly.

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-07-01 19:45 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-30 12:52 [PATCH] gas/x86: .arch / -march= enhancements Jan Beulich
2022-06-30 12:53 ` [PATCH 1/7] x86: don't leak sub-architecture accumulated strings Jan Beulich
2022-06-30 22:54   ` H.J. Lu
2022-07-01 10:18     ` Jan Beulich
2022-07-01 19:44       ` H.J. Lu
2022-06-30 12:53 ` [PATCH 2/7] x86: de-duplicate sub-architecture strings accumulation Jan Beulich
2022-06-30 22:55   ` H.J. Lu
2022-06-30 12:53 ` [PATCH 3/7] x86: permit "default" with .arch Jan Beulich
2022-06-30 22:58   ` H.J. Lu
2022-06-30 12:54 ` [PATCH 4/7] x86: macro-ize cpu_arch[] entries Jan Beulich
2022-06-30 23:00   ` H.J. Lu
2022-06-30 12:54 ` [PATCH 5/7] x86: introduce fake processor type to mark sub-arch entries in cpu_arch[] Jan Beulich
2022-06-30 23:03   ` H.J. Lu
2022-06-30 12:55 ` [PATCH 6/7] x86: generalize disabling of sub-architectures Jan Beulich
2022-06-30 23:11   ` H.J. Lu
2022-06-30 12:55 ` [PATCH 7/7] x86: introduce a state stack for .arch Jan Beulich
2022-06-30 23:15   ` H.J. Lu

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).