ARM Asm parser range checking for [0,31] immediates.

llvm-svn: 135719
This commit is contained in:
Jim Grosbach 2011-07-21 23:26:25 +00:00
parent 3354674b48
commit 72e7c4f9ac
2 changed files with 14 additions and 0 deletions

View File

@ -497,6 +497,7 @@ def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
}
/// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
def Imm0_31AsmOperand: AsmOperandClass { let Name = "Imm0_31"; }
def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
return Imm >= 0 && Imm < 32;
}]>;

View File

@ -418,6 +418,14 @@ public:
int64_t Value = CE->getValue();
return Value >= 0 && Value < 16;
}
bool isImm0_31() const {
if (Kind != Immediate)
return false;
const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getImm());
if (!CE) return false;
int64_t Value = CE->getValue();
return Value >= 0 && Value < 32;
}
bool isImm0_65535() const {
if (Kind != Immediate)
return false;
@ -672,6 +680,11 @@ public:
addExpr(Inst, getImm());
}
void addImm0_31Operands(MCInst &Inst, unsigned N) const {
assert(N == 1 && "Invalid number of operands!");
addExpr(Inst, getImm());
}
void addImm0_65535Operands(MCInst &Inst, unsigned N) const {
assert(N == 1 && "Invalid number of operands!");
addExpr(Inst, getImm());