Skip to content

Commit 1298252

Browse files
committed
[X86] Move 'int $3' -> 'int3' handling in the assembler to processInstruction.
Instead of handling before parsing, just fix it after parsing.
1 parent 702aae3 commit 1298252

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3305,18 +3305,6 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
33053305
return HadVerifyError;
33063306
}
33073307

3308-
// Transforms "int $3" into "int3" as a size optimization. We can't write an
3309-
// instalias with an immediate operand yet.
3310-
if (Name == "int" && Operands.size() == 2) {
3311-
X86Operand &Op1 = static_cast<X86Operand &>(*Operands[1]);
3312-
if (Op1.isImm())
3313-
if (auto *CE = dyn_cast<MCConstantExpr>(Op1.getImm()))
3314-
if (CE->getValue() == 3) {
3315-
Operands.erase(Operands.begin() + 1);
3316-
static_cast<X86Operand &>(*Operands[0]).setTokenValue("int3");
3317-
}
3318-
}
3319-
33203308
// Transforms "xlat mem8" into "xlatb"
33213309
if ((Name == "xlat" || Name == "xlatb") && Operands.size() == 2) {
33223310
X86Operand &Op1 = static_cast<X86Operand &>(*Operands[1]);
@@ -3521,6 +3509,17 @@ bool X86AsmParser::processInstruction(MCInst &Inst, const OperandVector &Ops) {
35213509
Inst = TmpInst;
35223510
return true;
35233511
}
3512+
case X86::INT: {
3513+
// Transforms "int $3" into "int3" as a size optimization. We can't write an
3514+
// instalias with an immediate operand yet.
3515+
if (!Inst.getOperand(0).isImm() || Inst.getOperand(0).getImm() != 3)
3516+
return false;
3517+
3518+
MCInst TmpInst;
3519+
TmpInst.setOpcode(X86::INT3);
3520+
Inst = TmpInst;
3521+
return true;
3522+
}
35243523
}
35253524
}
35263525

0 commit comments

Comments
 (0)