[llvm] [X86][MC] Support Enc/Dec for NF BMI instructions (PR #76709)

Shengchen Kan via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 10 20:39:04 PST 2024


================
@@ -1134,6 +1134,27 @@ static int getInstructionIDWithAttrMask(uint16_t *instructionID,
   return 0;
 }
 
+static bool isNF(InternalInstruction *insn) {
+  if (!nfFromEVEX4of4(insn->vectorExtensionPrefix[3]))
+    return false;
+  if (insn->opcodeType == MAP4)
+    return true;
+  // Below NF instructions are not in map4.
+  if (insn->opcodeType == THREEBYTE_38 &&
+      ppFromEVEX3of4(insn->vectorExtensionPrefix[2]) == VEX_PREFIX_NONE) {
+    switch (insn->opcode) {
+    case 0xf2: // ANDN
+    case 0xf3: // BLSI, BLSR, BLSMSK
+    case 0xf5: // BZHI
+    case 0xf7: // BEXTR
+      return true;
+    default:
+      break;
+    }
+  }
+  return false;
+}
+
----------------
KanRobert wrote:

```suggestion
  if (!nfFromEVEX4of4(insn->vectorExtensionPrefix[3]) || ppFromEVEX3of4(insn->vectorExtensionPrefix[2]))
    return false;
  if (insn->opcodeType == MAP4)
    return true;
  // Below NF instructions are not in map4.
  if (insn->opcodeType == THREEBYTE_38) {
    switch (insn->opcode) {
    case 0xf2: // ANDN
    case 0xf3: // BLSI, BLSR, BLSMSK
    case 0xf5: // BZHI
    case 0xf7: // BEXTR
      return true;
    default:
       return false;
    }
  }
}

```

https://github.com/llvm/llvm-project/pull/76709


More information about the llvm-commits mailing list