public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] x86: avoid strcmp() in a few places
@ 2023-01-20  9:19 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2023-01-20  9:19 UTC (permalink / raw)
  To: bfd-cvs

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

commit 6d86a54595d80b93baaaafe0b4db3dea6a5d451e
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Jan 20 10:17:23 2023 +0100

    x86: avoid strcmp() in a few places
    
    Now that we have identifiers for the mnemonic strings we can avoid
    strcmp() in a number of places, comparing the offsets into the mnemonic
    string table instead. While doing this also
    - convert a leftover strncmp() to startswith() (apparently an oversight
      when rebasing the original patch introducing the startswith() uses),
    - use the new shorthand for current_templates->start also elsewhere in
      md_assemble() (valid up to the point where match_template() is
      called).

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

diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 6929ffa57a7..b4e5a95a280 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -4550,7 +4550,7 @@ load_insn_p (void)
 	return 0;
 
       /* pop.   */
-      if (strcmp (insn_name (&i.tm), "pop") == 0)
+      if (i.tm.mnem_off == MN_pop)
 	return 1;
     }
 
@@ -4919,7 +4919,8 @@ md_assemble (char *line)
 	}
       return;
     }
-  if (may_need_pass2 (current_templates->start))
+  t = current_templates->start;
+  if (may_need_pass2 (t))
     {
       /* Make a copy of the full line in case we need to retry.  */
       copy = xstrdup (line);
@@ -4946,14 +4947,14 @@ md_assemble (char *line)
      AT&T modes.  */
   if (intel_syntax
       && i.operands > 1
-      && (strcmp (mnemonic, "bound") != 0)
-      && (strncmp (mnemonic, "invlpg", 6) != 0)
+      && (t->mnem_off != MN_bound)
+      && !startswith (mnemonic, "invlpg")
       && !startswith (mnemonic, "monitor")
       && !startswith (mnemonic, "mwait")
-      && (strcmp (mnemonic, "pvalidate") != 0)
+      && (t->mnem_off != MN_pvalidate)
       && !startswith (mnemonic, "rmp")
-      && (strcmp (mnemonic, "tpause") != 0)
-      && (strcmp (mnemonic, "umwait") != 0)
+      && (t->mnem_off != MN_tpause)
+      && (t->mnem_off != MN_umwait)
       && !(i.operands == 2
 	   && operand_type_check (i.types[0], imm)
 	   && operand_type_check (i.types[1], imm)))
@@ -4962,15 +4963,14 @@ md_assemble (char *line)
   /* The order of the immediates should be reversed
      for 2 immediates extrq and insertq instructions */
   if (i.imm_operands == 2
-      && (strcmp (mnemonic, "extrq") == 0
-	  || strcmp (mnemonic, "insertq") == 0))
+      && (t->mnem_off == MN_extrq || t->mnem_off == MN_insertq))
       swap_2_operands (0, 1);
 
   if (i.imm_operands)
     optimize_imm ();
 
-  if (i.disp_operands && !want_disp32 (current_templates->start)
-      && (!current_templates->start->opcode_modifier.jump
+  if (i.disp_operands && !want_disp32 (t)
+      && (!t->opcode_modifier.jump
 	  || i.jumpabsolute || i.types[0].bitfield.baseindex))
     {
       for (j = 0; j < i.operands; ++j)

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

only message in thread, other threads:[~2023-01-20  9:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-20  9:19 [binutils-gdb] x86: avoid strcmp() in a few places 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).