[llvm] 1298252 - [X86] Move 'int $3' -> 'int3' handling in the assembler to processInstruction.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 20 15:24:20 PDT 2020
Author: Craig Topper
Date: 2020-10-20T15:22:00-07:00
New Revision: 1298252f80fec0cd77aabef5cb133e7b030852e4
URL: https://github.com/llvm/llvm-project/commit/1298252f80fec0cd77aabef5cb133e7b030852e4
DIFF: https://github.com/llvm/llvm-project/commit/1298252f80fec0cd77aabef5cb133e7b030852e4.diff
LOG: [X86] Move 'int $3' -> 'int3' handling in the assembler to processInstruction.
Instead of handling before parsing, just fix it after parsing.
Added:
Modified:
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 4d85e5d379fa..a077179cfd81 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -3305,18 +3305,6 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
return HadVerifyError;
}
- // Transforms "int $3" into "int3" as a size optimization. We can't write an
- // instalias with an immediate operand yet.
- if (Name == "int" && Operands.size() == 2) {
- X86Operand &Op1 = static_cast<X86Operand &>(*Operands[1]);
- if (Op1.isImm())
- if (auto *CE = dyn_cast<MCConstantExpr>(Op1.getImm()))
- if (CE->getValue() == 3) {
- Operands.erase(Operands.begin() + 1);
- static_cast<X86Operand &>(*Operands[0]).setTokenValue("int3");
- }
- }
-
// Transforms "xlat mem8" into "xlatb"
if ((Name == "xlat" || Name == "xlatb") && Operands.size() == 2) {
X86Operand &Op1 = static_cast<X86Operand &>(*Operands[1]);
@@ -3521,6 +3509,17 @@ bool X86AsmParser::processInstruction(MCInst &Inst, const OperandVector &Ops) {
Inst = TmpInst;
return true;
}
+ case X86::INT: {
+ // Transforms "int $3" into "int3" as a size optimization. We can't write an
+ // instalias with an immediate operand yet.
+ if (!Inst.getOperand(0).isImm() || Inst.getOperand(0).getImm() != 3)
+ return false;
+
+ MCInst TmpInst;
+ TmpInst.setOpcode(X86::INT3);
+ Inst = TmpInst;
+ return true;
+ }
}
}
More information about the llvm-commits
mailing list