[3/4] x86: don't play with cpu_arch_flags.cpu{,no}64

Message ID 3fbfc683-d536-76e7-a66f-5b5d83459684@suse.com
State New
Headers
Series x86: Cpu64 / CpuNo64 adjustments |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Testing passed

Commit Message

Jan Beulich Sept. 8, 2023, 12:54 p.m. UTC
  A total four places exists where we set the two bits from flag_code, but
these values are never used. The two bits are evaluated only when coming
from insn templates.

Drop these assignments. Also make obvious that cpu_flags_check_cpu64()
is only ever used against insn templates.
  

Patch

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -1785,10 +1785,11 @@  cpu_flags_equal (const union i386_cpu_fl
 }
 
 static INLINE int
-cpu_flags_check_cpu64 (i386_cpu_attr a)
+cpu_flags_check_cpu64 (const insn_template *t)
 {
-  return !((flag_code == CODE_64BIT && a.bitfield.cpuno64)
-	   || (flag_code != CODE_64BIT && a.bitfield.cpu64));
+  return flag_code == CODE_64BIT
+	 ? !t->cpu.bitfield.cpuno64
+	 : !t->cpu.bitfield.cpu64;
 }
 
 static INLINE i386_cpu_flags
@@ -1883,7 +1884,7 @@  static int
 cpu_flags_match (const insn_template *t)
 {
   i386_cpu_flags x = cpu_flags_from_attr (t->cpu);
-  int match = cpu_flags_check_cpu64 (t->cpu) ? CPU_FLAGS_64BIT_MATCH : 0;
+  int match = cpu_flags_check_cpu64 (t) ? CPU_FLAGS_64BIT_MATCH : 0;
 
   x.bitfield.cpu64 = 0;
   x.bitfield.cpuno64 = 0;
@@ -2626,16 +2627,6 @@  update_code_flag (int value, int check)
     }
 
   flag_code = (enum flag_code) value;
-  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;
-    }
 
   stackop_size = '\0';
 }
@@ -2652,8 +2643,6 @@  set_16bit_gcc_code_flag (int new_code_fl
   flag_code = (enum flag_code) new_code_flag;
   if (flag_code != CODE_16BIT)
     abort ();
-  cpu_arch_flags.bitfield.cpu64 = 0;
-  cpu_arch_flags.bitfield.cpuno64 = 1;
   stackop_size = LONG_MNEM_SUFFIX;
 }
 
@@ -2895,16 +2884,6 @@  set_cpu_arch (int dummy ATTRIBUTE_UNUSED
 	  free (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].enable;
 	  if (!cpu_arch_tune_set)
@@ -2950,16 +2929,6 @@  set_cpu_arch (int dummy ATTRIBUTE_UNUSED
 	      free (cpu_sub_arch_name);
 	      cpu_sub_arch_name = NULL;
 	      cpu_arch_flags = cpu_arch[j].enable;
-	      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 = cpu_arch[j].type;
 	      cpu_arch_isa_flags = cpu_arch[j].enable;
 	      if (!cpu_arch_tune_set)
@@ -5741,7 +5710,7 @@  parse_insn (const char *line, char *mnem
 	  && current_templates
 	  && current_templates->start->opcode_modifier.isprefix)
 	{
-	  if (!cpu_flags_check_cpu64 (current_templates->start->cpu))
+	  if (!cpu_flags_check_cpu64 (current_templates->start))
 	    {
 	      as_bad ((flag_code != CODE_64BIT
 		       ? _("`%s' is only supported in 64-bit mode")