public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] x86: don't play with cpu_arch_flags.cpu{,no}64
@ 2023-09-15  7:57 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2023-09-15  7:57 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c0260ac61915b053c1a2539797ed5fd06eb99ac6

commit c0260ac61915b053c1a2539797ed5fd06eb99ac6
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Sep 15 09:56:33 2023 +0200

    x86: don't play with cpu_arch_flags.cpu{,no}64
    
    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.

Diff:
---
 gas/config/tc-i386.c | 43 ++++++-------------------------------------
 1 file changed, 6 insertions(+), 37 deletions(-)

diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 72e5729ce1c..f8d51afd2e4 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -1785,10 +1785,11 @@ cpu_flags_equal (const union i386_cpu_flags *x,
 }
 
 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_flag)
   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 *mnemonic, bool prefix_only)
 	  && 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")

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-15  7:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-15  7:57 [binutils-gdb] x86: don't play with cpu_arch_flags.cpu{,no}64 Jan Beulich

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