aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/ARM
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-01-18 05:55:15 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-01-18 05:55:15 +0000
commit2637dc9a252f25fd1c63acfe0606860ee7c8cfdf (patch)
treeb13cd5e2e681eca47ca6e43a64f5ca8b930d7d22 /lib/Target/ARM
parent5d2cf40c40d8c2763a0e5b53481063becdce6e30 (diff)
downloadexternal_llvm-2637dc9a252f25fd1c63acfe0606860ee7c8cfdf.zip
external_llvm-2637dc9a252f25fd1c63acfe0606860ee7c8cfdf.tar.gz
external_llvm-2637dc9a252f25fd1c63acfe0606860ee7c8cfdf.tar.bz2
McARM: Make ARMOperand use a union where appropriate.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123744 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM')
-rw-r--r--lib/Target/ARM/AsmParser/ARMAsmParser.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
index c2e8442..e010d18 100644
--- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -145,8 +145,10 @@ class ARMOperand : public MCParsedAsmOperand {
/// Combined record for all forms of ARM address expressions.
struct {
unsigned BaseRegNum;
- unsigned OffsetRegNum; // used when OffsetIsReg is true
- const MCExpr *Offset; // used when OffsetIsReg is false
+ union {
+ unsigned RegNum; ///< Offset register num, when OffsetIsReg.
+ const MCExpr *Value; ///< Offset value, when !OffsetIsReg.
+ } Offset;
const MCExpr *ShiftAmount; // used when OffsetRegShifted is true
enum ShiftType ShiftType; // used when OffsetRegShifted is true
unsigned OffsetRegShifted : 1; // only used when OffsetIsReg is true
@@ -234,7 +236,7 @@ public:
Mem.Writeback || Mem.Negative)
return false;
- const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(Mem.Offset);
+ const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(Mem.Offset.Value);
if (!CE) return false;
// The offset must be a multiple of 4 in the range 0-1020.
@@ -250,7 +252,7 @@ public:
if (!isMemory() || Mem.OffsetIsReg || Mem.Writeback)
return false;
- const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(Mem.Offset);
+ const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(Mem.Offset.Value);
if (!CE) return false;
// The offset must be a multiple of 4 in the range 0-124.
@@ -314,7 +316,7 @@ public:
// FIXME: #-0 is encoded differently than #0. Does the parser preserve
// the difference?
- const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(Mem.Offset);
+ const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(Mem.Offset.Value);
assert(CE && "Non-constant mode 5 offset operand!");
// The MCInst offset operand doesn't include the low two bits (like
@@ -331,13 +333,13 @@ public:
void addMemModeRegThumbOperands(MCInst &Inst, unsigned N) const {
assert(N == 2 && isMemModeRegThumb() && "Invalid number of operands!");
Inst.addOperand(MCOperand::CreateReg(Mem.BaseRegNum));
- Inst.addOperand(MCOperand::CreateReg(Mem.OffsetRegNum));
+ Inst.addOperand(MCOperand::CreateReg(Mem.Offset.RegNum));
}
void addMemModeImmThumbOperands(MCInst &Inst, unsigned N) const {
assert(N == 2 && isMemModeImmThumb() && "Invalid number of operands!");
Inst.addOperand(MCOperand::CreateReg(Mem.BaseRegNum));
- const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(Mem.Offset);
+ const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(Mem.Offset.Value);
assert(CE && "Non-constant mode offset operand!");
Inst.addOperand(MCOperand::CreateImm(CE->getValue()));
}
@@ -425,8 +427,10 @@ public:
ARMOperand *Op = new ARMOperand(Memory);
Op->Mem.BaseRegNum = BaseRegNum;
Op->Mem.OffsetIsReg = OffsetIsReg;
- Op->Mem.Offset = Offset;
- Op->Mem.OffsetRegNum = OffsetRegNum;
+ if (OffsetIsReg)
+ Op->Mem.Offset.RegNum = OffsetRegNum;
+ else
+ Op->Mem.Offset.Value = Offset;
Op->Mem.OffsetRegShifted = OffsetRegShifted;
Op->Mem.ShiftType = ShiftType;
Op->Mem.ShiftAmount = ShiftAmount;