[clang] [llvm] [X86][MC] Added support for -msse2avx option in llvm-mc (PR #96860)

Shengchen Kan via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 11 19:25:09 PDT 2024


================
@@ -3745,7 +3749,27 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
   return false;
 }
 
+static void replaceSSE2AVXOpcode(MCInst &Inst) {
+  ArrayRef<X86TableEntry> Table{X86SSE2AVXTable};
+  unsigned Opcode = Inst.getOpcode();
+  const auto I = llvm::lower_bound(Table, Opcode);
+  if (I != Table.end() && I->OldOpc == Opcode)
+    Inst.setOpcode(I->NewOpc);
+
+  if (X86::isBLENDVPD(Opcode) || X86::isBLENDVPS(Opcode) ||
+      X86::isPBLENDVB(Opcode)) {
+    unsigned RegNo = Inst.getOperand(2).getReg();
+    Inst.addOperand(MCOperand::createReg(RegNo));
+  }
+}
+
 bool X86AsmParser::processInstruction(MCInst &Inst, const OperandVector &Ops) {
+  // When "-msse2avx" option is enabled replaceSSE2AVXOpcode method will
+  // replace SSE instruction with equivalent AVX instruction using mapping given
+  // in table GET_X86_SSE2AVX_TABLE
----------------
KanRobert wrote:

Drop this comment. The code is self-explained and the comment is confusing. (We have different options names for the sse2avx opt, so it's strange to mention the driver option only. And the table name is not called GET_X86_SSE2AVX_TABLE.)

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


More information about the cfe-commits mailing list