From 8d1db4634f6ed478f7ece0f307bc70800ce690d9 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 20 Oct 2020 14:31:47 -0700 Subject: [PATCH] [X86] Move 'int $3' -> 'int3' handling in the assembler to processInstruction. Instead of handling before parsing, just fix it after parsing. --- lib/Target/X86/AsmParser/X86AsmParser.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index 4d85e5d379f..a077179cfd8 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/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(*Operands[1]); - if (Op1.isImm()) - if (auto *CE = dyn_cast(Op1.getImm())) - if (CE->getValue() == 3) { - Operands.erase(Operands.begin() + 1); - static_cast(*Operands[0]).setTokenValue("int3"); - } - } - // Transforms "xlat mem8" into "xlatb" if ((Name == "xlat" || Name == "xlatb") && Operands.size() == 2) { X86Operand &Op1 = static_cast(*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; + } } }