mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-27 21:50:40 +00:00
[X86] Remove special validation for INT immediate operand from AsmParser. Instead mark its operand type as u8imm which will cause it to fail to match. This is more consistent with other instruction behavior.
This also fixes a bug where negative immediates below -128 were not being reported as errors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249989 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6bb2edf33a
commit
a9d6f4a14a
@ -718,7 +718,6 @@ private:
|
||||
bool ParseDirectiveWord(unsigned Size, SMLoc L);
|
||||
bool ParseDirectiveCode(StringRef IDVal, SMLoc L);
|
||||
|
||||
bool validateInstruction(MCInst &Inst, const OperandVector &Ops);
|
||||
bool processInstruction(MCInst &Inst, const OperandVector &Ops);
|
||||
|
||||
/// Wrapper around MCStreamer::EmitInstruction(). Possibly adds
|
||||
@ -2401,22 +2400,6 @@ static bool convert64i32to64ri8(MCInst &Inst, unsigned Opcode,
|
||||
return convertToSExti8(Inst, Opcode, X86::RAX, isCmp);
|
||||
}
|
||||
|
||||
bool X86AsmParser::validateInstruction(MCInst &Inst, const OperandVector &Ops) {
|
||||
switch (Inst.getOpcode()) {
|
||||
default: return true;
|
||||
case X86::INT:
|
||||
X86Operand &Op = static_cast<X86Operand &>(*Ops[1]);
|
||||
assert(Op.isImm() && "expected immediate");
|
||||
int64_t Res;
|
||||
if (!Op.getImm()->evaluateAsAbsolute(Res) || Res > 255) {
|
||||
Error(Op.getStartLoc(), "interrupt vector must be in range [0-255]");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
llvm_unreachable("handle the instruction appropriately");
|
||||
}
|
||||
|
||||
bool X86AsmParser::processInstruction(MCInst &Inst, const OperandVector &Ops) {
|
||||
switch (Inst.getOpcode()) {
|
||||
default: return false;
|
||||
@ -2579,9 +2562,6 @@ bool X86AsmParser::MatchAndEmitATTInstruction(SMLoc IDLoc, unsigned &Opcode,
|
||||
isParsingIntelSyntax())) {
|
||||
default: llvm_unreachable("Unexpected match result!");
|
||||
case Match_Success:
|
||||
if (!validateInstruction(Inst, Operands))
|
||||
return true;
|
||||
|
||||
// Some instructions need post-processing to, for example, tweak which
|
||||
// encoding is selected. Loop on it while changes happen so the
|
||||
// individual transformations can chain off each other.
|
||||
@ -2825,9 +2805,6 @@ bool X86AsmParser::MatchAndEmitIntelInstruction(SMLoc IDLoc, unsigned &Opcode,
|
||||
unsigned NumSuccessfulMatches =
|
||||
std::count(std::begin(Match), std::end(Match), Match_Success);
|
||||
if (NumSuccessfulMatches == 1) {
|
||||
if (!validateInstruction(Inst, Operands))
|
||||
return true;
|
||||
|
||||
// Some instructions need post-processing to, for example, tweak which
|
||||
// encoding is selected. Loop on it while changes happen so the individual
|
||||
// transformations can chain off each other.
|
||||
|
@ -44,7 +44,7 @@ def INT3 : I<0xcc, RawFrm, (outs), (ins), "int3",
|
||||
|
||||
let SchedRW = [WriteSystem] in {
|
||||
|
||||
def INT : Ii8<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap",
|
||||
def INT : Ii8<0xcd, RawFrm, (outs), (ins u8imm:$trap), "int\t$trap",
|
||||
[(int_x86_int imm:$trap)], IIC_INT>;
|
||||
|
||||
|
||||
|
@ -11,7 +11,7 @@ bb.entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: int $-128
|
||||
; CHECK: int $128
|
||||
; CHECK: ret
|
||||
define void @primitive_int128 () {
|
||||
bb.entry:
|
||||
|
@ -2,6 +2,11 @@
|
||||
|
||||
.text
|
||||
int $65535
|
||||
# CHECK: error: interrupt vector must be in range [0-255]
|
||||
# CHECK: error: invalid operand for instruction
|
||||
# CHECK: int $65535
|
||||
# CHECK: ^
|
||||
|
||||
int $-129
|
||||
# CHECK: error: invalid operand for instruction
|
||||
# CHECK: int $-129
|
||||
# CHECK: ^
|
||||
|
@ -3,7 +3,13 @@
|
||||
|
||||
.text
|
||||
int 65535
|
||||
# CHECK: error: interrupt vector must be in range [0-255]
|
||||
# CHECK: error: invalid operand for instruction
|
||||
# CHECK: int 65535
|
||||
# CHECK: ^
|
||||
|
||||
.text
|
||||
int -129
|
||||
# CHECK: error: invalid operand for instruction
|
||||
# CHECK: int -129
|
||||
# CHECK: ^
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user