1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

ARM range checking for so_imm operands in assembly parsing.

llvm-svn: 135489
This commit is contained in:
Jim Grosbach 2011-07-19 16:50:30 +00:00
parent 7c9092c9aa
commit 31cda4ed6d
2 changed files with 15 additions and 0 deletions

View File

@ -443,10 +443,12 @@ def shift_so_reg : Operand<i32>, // reg reg imm
// so_imm - Match a 32-bit shifter_operand immediate operand, which is an
// 8-bit immediate rotated by an arbitrary number of bits.
def SOImmAsmOperand: AsmOperandClass { let Name = "ARMSOImm"; }
def so_imm : Operand<i32>, ImmLeaf<i32, [{
return ARM_AM::getSOImmVal(Imm) != -1;
}]> {
let EncoderMethod = "getSOImmOpValue";
let ParserMatchClass = SOImmAsmOperand;
}
// Break so_imm's up into two pieces. This handles immediates with up to 16

View File

@ -407,6 +407,14 @@ public:
int64_t Value = CE->getValue();
return Value >= 0 && Value < 65536;
}
bool isARMSOImm() const {
if (Kind != Immediate)
return false;
const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getImm());
if (!CE) return false;
int64_t Value = CE->getValue();
return ARM_AM::getSOImmVal(Value) != -1;
}
bool isT2SOImm() const {
if (Kind != Immediate)
return false;
@ -613,6 +621,11 @@ public:
addExpr(Inst, getImm());
}
void addARMSOImmOperands(MCInst &Inst, unsigned N) const {
assert(N == 1 && "Invalid number of operands!");
addExpr(Inst, getImm());
}
void addT2SOImmOperands(MCInst &Inst, unsigned N) const {
assert(N == 1 && "Invalid number of operands!");
addExpr(Inst, getImm());