diff options
author | Jim Grosbach <grosbach@apple.com> | 2011-08-19 17:55:24 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2011-08-19 17:55:24 +0000 |
commit | 60f91a3d9518617e29da18477ae433b8f0069304 (patch) | |
tree | f7351a63587300f63eb8f29899fbec3132ff21a1 /lib | |
parent | e865c035fd5db0daee1807b2c5b6d79c9dd4062b (diff) |
Thumb assembly parsing and encoding for LDR(immediate) form T1.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138047 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/ARM/ARMInstrThumb.td | 2 | ||||
-rw-r--r-- | lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/Target/ARM/ARMInstrThumb.td b/lib/Target/ARM/ARMInstrThumb.td index a6e0ed737b..8d4fa19d9f 100644 --- a/lib/Target/ARM/ARMInstrThumb.td +++ b/lib/Target/ARM/ARMInstrThumb.td @@ -157,11 +157,13 @@ def t_addrmode_rrs4 : Operand<i32>, // t_addrmode_is4 := reg + imm5 * 4 // +def t_addrmode_is4_asm_operand : AsmOperandClass { let Name = "MemThumbRIs4"; } def t_addrmode_is4 : Operand<i32>, ComplexPattern<i32, 2, "SelectThumbAddrModeImm5S4", []> { let EncoderMethod = "getAddrModeISOpValue"; let DecoderMethod = "DecodeThumbAddrModeIS"; let PrintMethod = "printThumbAddrModeImm5S4Operand"; + let ParserMatchClass = t_addrmode_is4_asm_operand; let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm); } diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index 6977545511..9658e0801d 100644 --- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -616,7 +616,17 @@ public: if (Kind != Memory || !Mem.OffsetRegNum || Mem.isNegative || Mem.ShiftType != ARM_AM::no_shift) return false; - return true; + return isARMLowRegister(Mem.BaseRegNum) && + (!Mem.OffsetRegNum || isARMLowRegister(Mem.OffsetRegNum)); + } + bool isMemThumbRIs4() const { + if (Kind != Memory || Mem.OffsetRegNum != 0 || + !isARMLowRegister(Mem.BaseRegNum)) + return false; + // Immediate offset, multiple of 4 in range [0, 124]. + if (!Mem.OffsetImm) return true; + int64_t Val = Mem.OffsetImm->getValue(); + return Val >= 0 && Val < 125 && (Val % 4) == 0; } bool isMemImm8Offset() const { if (Kind != Memory || Mem.OffsetRegNum != 0) @@ -975,6 +985,13 @@ public: Inst.addOperand(MCOperand::CreateReg(Mem.OffsetRegNum)); } + void addMemThumbRIs4Operands(MCInst &Inst, unsigned N) const { + assert(N == 2 && "Invalid number of operands!"); + int64_t Val = Mem.OffsetImm ? (Mem.OffsetImm->getValue() / 4) : 0; + Inst.addOperand(MCOperand::CreateReg(Mem.BaseRegNum)); + Inst.addOperand(MCOperand::CreateImm(Val)); + } + void addPostIdxImm8Operands(MCInst &Inst, unsigned N) const { assert(N == 1 && "Invalid number of operands!"); const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getImm()); |