]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
MIPS/opcodes: Factor out ISA matching against flags
authorMaciej W. Rozycki <macro@orcam.me.uk>
Sat, 29 May 2021 01:26:32 +0000 (03:26 +0200)
committerMaciej W. Rozycki <macro@orcam.me.uk>
Sat, 29 May 2021 01:26:32 +0000 (03:26 +0200)
In preparation for the next change factor out code for ISA matching
against instruction flags used in MIPS opcode tables, similarly to how
CPU matching is already done.  No functional change, though for clarity
split the single `if' statement into multiple ones and use temporaries
rather than repeated expressions.

include/
* opcode/mips.h (isa_is_member): New inline function, factored
out from...
(opcode_is_member): ... here.

include/ChangeLog
include/opcode/mips.h

index d0cc5c419ec525bd6aa23b198903387b8697156b..b51782f5093372922391a12114d340c4f1e46877 100644 (file)
@@ -1,3 +1,9 @@
+2021-05-29  Maciej W. Rozycki  <macro@orcam.me.uk>
+
+       * opcode/mips.h (isa_is_member): New inline function, factored
+       out from...
+       (opcode_is_member): ... here.
+
 2021-05-29  Maciej W. Rozycki  <macro@orcam.me.uk>
 
        * opcode/mips.h: Document `g' and `y' operand codes.
index e0a644734441a1af217e93c412f41b9f7636d40c..aa6e9d7cee988ae8b99e568be340c5b03ccff0d8 100644 (file)
@@ -1471,6 +1471,26 @@ cpu_is_member (int cpu, unsigned int mask)
     }
 }
 
+/* Return true if the given ISA is included in INSN_* mask MASK.  */
+
+static inline bool
+isa_is_member (int isa, unsigned int mask)
+{
+  isa &= INSN_ISA_MASK;
+  mask &= INSN_ISA_MASK;
+
+  if (isa == 0)
+    return false;
+
+  if (mask == 0)
+    return false;
+
+  if (((mips_isa_table[isa - 1] >> (mask - 1)) & 1) == 0)
+    return false;
+
+  return true;
+}
+
 /* Test for membership in an ISA including chip specific ISAs.  INSN
    is pointer to an element of the opcode table; ISA is the specified
    ISA/ASE bitmask to test against; and CPU is the CPU specific ISA to
@@ -1483,10 +1503,7 @@ opcode_is_member (const struct mips_opcode *insn, int isa, int ase, int cpu)
   if (!cpu_is_member (cpu, insn->exclusions))
     {
       /* Test for ISA level compatibility.  */
-      if ((isa & INSN_ISA_MASK) != 0
-         && (insn->membership & INSN_ISA_MASK) != 0
-         && ((mips_isa_table[(isa & INSN_ISA_MASK) - 1]
-              >> ((insn->membership & INSN_ISA_MASK) - 1)) & 1) != 0)
+      if (isa_is_member (isa, insn->membership))
        return true;
 
       /* Test for ASE compatibility.  */