public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] x86/Intel: improve special casing of certain insns
@ 2023-01-27  8:21 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2023-01-27  8:21 UTC (permalink / raw)
  To: bfd-cvs

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

commit c47b4d71203e8f53d998b891c4c1beaecd43c728
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Jan 27 09:21:24 2023 +0100

    x86/Intel: improve special casing of certain insns
    
    Now that we have identifiers for the mnemonic strings we can avoid
    opcode based comparisons, for (in many cases) being more expensive and
    (in a few cases) being a little fragile and not self-documenting.

Diff:
---
 gas/config/tc-i386-intel.c | 36 +++++++++++++++---------------------
 1 file changed, 15 insertions(+), 21 deletions(-)

diff --git a/gas/config/tc-i386-intel.c b/gas/config/tc-i386-intel.c
index a830caa8010..7ee63efd2de 100644
--- a/gas/config/tc-i386-intel.c
+++ b/gas/config/tc-i386-intel.c
@@ -341,13 +341,10 @@ i386_intel_simplify_register (expressionS *e)
       const insn_template *t = current_templates->start;
 
       if (intel_state.in_scale
-	  || (t->opcode_modifier.opcodeprefix == PREFIX_0XF3
-	      && t->opcode_modifier.opcodespace == SPACE_0F
-	      && t->base_opcode == 0x1b /* bndmk */)
-	  || (t->opcode_modifier.opcodeprefix == PREFIX_NONE
-	      && t->opcode_modifier.opcodespace == SPACE_0F
-	      && (t->base_opcode & ~1) == 0x1a /* bnd{ld,st}x */)
-	  || i386_regtab[reg_num].reg_type.bitfield.baseindex)
+	  || i386_regtab[reg_num].reg_type.bitfield.baseindex
+	  || t->mnem_off == MN_bndmk
+	  || t->mnem_off == MN_bndldx
+	  || t->mnem_off == MN_bndstx)
 	intel_state.index = i386_regtab + reg_num;
       else
 	{
@@ -681,8 +678,7 @@ i386_intel_operand (char *operand_string, int got_a_float)
     return 0;
 
   if (intel_state.op_modifier != O_absent
-      && (current_templates->start->opcode_modifier.opcodespace != SPACE_BASE
-          || current_templates->start->base_opcode != 0x8d /* lea */))
+      && current_templates->start->mnem_off != MN_lea)
     {
       i.types[this_operand].bitfield.unspecified = 0;
 
@@ -697,9 +693,8 @@ i386_intel_operand (char *operand_string, int got_a_float)
 	  i.types[this_operand].bitfield.word = 1;
 	  if (got_a_float == 2)	/* "fi..." */
 	    suffix = SHORT_MNEM_SUFFIX;
-	  else if ((current_templates->start->base_opcode | 1) != 0x03
-		   || (current_templates->start->opcode_modifier.opcodespace
-		       != SPACE_0F)) /* lar, lsl */
+	  else if (current_templates->start->mnem_off != MN_lar
+		   && current_templates->start->mnem_off != MN_lsl)
 	    suffix = WORD_MNEM_SUFFIX;
 	  break;
 
@@ -708,8 +703,7 @@ i386_intel_operand (char *operand_string, int got_a_float)
 	  if ((insn_name (current_templates->start)[0] == 'l'
 	       && insn_name (current_templates->start)[2] == 's'
 	       && insn_name (current_templates->start)[3] == 0)
-	      || (current_templates->start->opcode_modifier.opcodespace == SPACE_BASE
-		  && current_templates->start->base_opcode == 0x62 /* bound */))
+	      || current_templates->start->mnem_off == MN_bound)
 	    suffix = WORD_MNEM_SUFFIX;
 	  else if (flag_code != CODE_32BIT
 		   && (current_templates->start->opcode_modifier.jump == JUMP
@@ -727,9 +721,11 @@ i386_intel_operand (char *operand_string, int got_a_float)
 
 	case O_fword_ptr:
 	  i.types[this_operand].bitfield.fword = 1;
-	  if (insn_name (current_templates->start)[0] == 'l'
-	      && insn_name (current_templates->start)[2] == 's'
-	      && insn_name (current_templates->start)[3] == 0)
+	  if (current_templates->start->mnem_off == MN_les
+	      || current_templates->start->mnem_off == MN_lds
+	      || current_templates->start->mnem_off == MN_lss
+	      || current_templates->start->mnem_off == MN_lfs
+	      || current_templates->start->mnem_off == MN_lgs)
 	    suffix = LONG_MNEM_SUFFIX;
 	  else if (!got_a_float)
 	    {
@@ -741,8 +737,7 @@ i386_intel_operand (char *operand_string, int got_a_float)
 
 	case O_qword_ptr: /* O_mmword_ptr */
 	  i.types[this_operand].bitfield.qword = 1;
-	  if ((current_templates->start->opcode_modifier.opcodespace == SPACE_BASE
-	       && current_templates->start->base_opcode == 0x62 /* bound */)
+	  if (current_templates->start->mnem_off == MN_bound
 	      || got_a_float == 1)	/* "f..." */
 	    suffix = LONG_MNEM_SUFFIX;
 	  else
@@ -799,8 +794,7 @@ i386_intel_operand (char *operand_string, int got_a_float)
 	 REX.W) is going to be derived from it.  For this we check whether the
 	 given suffix is valid for any of the candidate templates.  */
       if (suffix && suffix != i.suffix
-	  && (current_templates->start->opcode_modifier.opcodespace != SPACE_BASE
-	      || current_templates->start->base_opcode != 0x62 /* bound */))
+	  && current_templates->start->mnem_off != MN_bound)
 	{
 	  const insn_template *t;

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

only message in thread, other threads:[~2023-01-27  8:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-27  8:21 [binutils-gdb] x86/Intel: improve special casing of certain insns 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).