From 09176e10dbe575b0f4c68803695c47ccb4b81f81 Mon Sep 17 00:00:00 2001 From: Jim Grosbach Date: Mon, 8 Aug 2011 20:59:31 +0000 Subject: [PATCH] ARM load/store label parsing. Allow labels for load/store instructions when parsing. There's encoding issues, still, so this doesn't work all the way through, yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137064 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index 7cfed1de6da..4bae82467bf 100644 --- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -566,6 +566,12 @@ public: return Val > -256 && Val < 256; } bool isMemImm12Offset() const { + // If we have an immediate that's not a constant, treat it as a label + // reference needing a fixup. If it is a constant, it's something else + // and we reject it. + if (Kind == Immediate && !isa(getImm())) + return true; + if (Kind != Memory || Mem.OffsetRegNum != 0) return false; // Immediate offset in range [-4095, 4095]. @@ -830,6 +836,14 @@ public: void addMemImm12OffsetOperands(MCInst &Inst, unsigned N) const { assert(N == 2 && "Invalid number of operands!"); + // If this is an immediate, it's a label reference. + if (Kind == Immediate) { + addExpr(Inst, getImm()); + Inst.addOperand(MCOperand::CreateImm(0)); + return; + } + + // Otherwise, it's a normal memory reg+offset. int64_t Val = Mem.OffsetImm ? Mem.OffsetImm->getValue() : 0; Inst.addOperand(MCOperand::CreateReg(Mem.BaseRegNum)); Inst.addOperand(MCOperand::CreateImm(Val));