summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2010-08-17 18:13:53 +0000
committerJim Grosbach <grosbach@apple.com>2010-08-17 18:13:53 +0000
commitc252ee23752bf777f0ac8e36694c0d88a2d9f36f (patch)
tree519fcc2926a337d07e643c0bec48af34e0927c94 /llvm/lib/Target/ARM
parentb1e20869a27fb50cae57ea3904ccdd6cba2ada58 (diff)
downloadbcm5719-llvm-c252ee23752bf777f0ac8e36694c0d88a2d9f36f.tar.gz
bcm5719-llvm-c252ee23752bf777f0ac8e36694c0d88a2d9f36f.zip
Add hook to examine an instruction referencing a frame index to determine
whether to allocate a virtual frame base register to resolve the frame index reference in it. Implement a simple version for ARM to aid debugging. In LocalStackSlotAllocation, scan the function for frame index references to local frame indices and ask the target whether to allocate virtual frame base registers for any it encounters. Purely infrastructural for debug output. Next step is to actually allocate base registers, then add intelligent re-use of them. rdar://8277890 llvm-svn: 111262
Diffstat (limited to 'llvm/lib/Target/ARM')
-rw-r--r--llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp41
-rw-r--r--llvm/lib/Target/ARM/ARMBaseRegisterInfo.h1
2 files changed, 42 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp b/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
index 12308c43404..5612f04c5f2 100644
--- a/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
@@ -1367,6 +1367,47 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
MBB.erase(I);
}
+/// needsFrameBaseReg - Returns true if the instruction's frame index
+/// reference would be better served by a base register other than FP
+/// or SP. Used by LocalStackFrameAllocation to determine which frame index
+/// references it should create new base registers for.
+bool ARMBaseRegisterInfo::
+needsFrameBaseReg(MachineInstr *MI, unsigned operand) const {
+ assert (MI->getOperand(operand).isFI() &&
+ "needsFrameBaseReg() called on non Frame Index operand!");
+
+ // It's the load/store FI references that cause issues, as it can be difficult
+ // to materialize the offset if it won't fit in the literal field. Estimate
+ // based on the size of the local frame and some conservative assumptions
+ // about the rest of the stack frame (note, this is pre-regalloc, so
+ // we don't know everything for certain yet) whether this offset is likely
+ // to be out of range of the immediate. Return true if so.
+
+ // FIXME: For testing, return true for all loads/stores and false for
+ // everything else. We want to create lots of base regs to shake out bugs.
+ //
+ // FIXME: This is Thumb2/ARM only for now to keep it simpler.
+ ARMFunctionInfo *AFI =
+ MI->getParent()->getParent()->getInfo<ARMFunctionInfo>();
+ if (AFI->isThumb1OnlyFunction())
+ return false;
+
+ unsigned Opc = MI->getOpcode();
+
+ switch (Opc) {
+ case ARM::LDR: case ARM::LDRH: case ARM::LDRB:
+ case ARM::STR: case ARM::STRH: case ARM::STRB:
+ case ARM::t2LDRi12: case ARM::t2LDRi8:
+ case ARM::t2STRi12: case ARM::t2STRi8:
+ case ARM::VLDRS: case ARM::VLDRD:
+ case ARM::VSTRS: case ARM::VSTRD:
+ return true;
+ default:
+ return false;
+ }
+}
+
+
unsigned
ARMBaseRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
int SPAdj, FrameIndexValue *Value,
diff --git a/llvm/lib/Target/ARM/ARMBaseRegisterInfo.h b/llvm/lib/Target/ARM/ARMBaseRegisterInfo.h
index d644ecc1ab0..f3ccfb4cc40 100644
--- a/llvm/lib/Target/ARM/ARMBaseRegisterInfo.h
+++ b/llvm/lib/Target/ARM/ARMBaseRegisterInfo.h
@@ -105,6 +105,7 @@ public:
bool canRealignStack(const MachineFunction &MF) const;
bool needsStackRealignment(const MachineFunction &MF) const;
+ bool needsFrameBaseReg(MachineInstr *MI, unsigned operand) const;
bool cannotEliminateFrame(const MachineFunction &MF) const;
OpenPOWER on IntegriCloud