summaryrefslogtreecommitdiff
path: root/lib/Target/XCore/XCoreMachineFunctionInfo.cpp
diff options
context:
space:
mode:
authorRobert Lytton <robert@xmos.com>2014-01-06 14:20:41 +0000
committerRobert Lytton <robert@xmos.com>2014-01-06 14:20:41 +0000
commit7d2dd96694fc1fd29120a01a7f180445c7aabede (patch)
treef87a54aeb665c9bb021ce2416a3498667610bd06 /lib/Target/XCore/XCoreMachineFunctionInfo.cpp
parente2d3dc8b817028c1724810c6e80a609cd4f888bf (diff)
downloadllvm-7d2dd96694fc1fd29120a01a7f180445c7aabede.tar.gz
llvm-7d2dd96694fc1fd29120a01a7f180445c7aabede.tar.bz2
llvm-7d2dd96694fc1fd29120a01a7f180445c7aabede.tar.xz
XCore target: Refactor LR handling
We also narrow the liveness of FP & LR during the prologue to reflect the actual usage of the registers. I have been unable to construct a test to prove the previous live range was too large. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198611 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/XCore/XCoreMachineFunctionInfo.cpp')
-rw-r--r--lib/Target/XCore/XCoreMachineFunctionInfo.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/Target/XCore/XCoreMachineFunctionInfo.cpp b/lib/Target/XCore/XCoreMachineFunctionInfo.cpp
index 91b2976008..c41a3d5f92 100644
--- a/lib/Target/XCore/XCoreMachineFunctionInfo.cpp
+++ b/lib/Target/XCore/XCoreMachineFunctionInfo.cpp
@@ -8,6 +8,8 @@
//===----------------------------------------------------------------------===//
#include "XCoreMachineFunctionInfo.h"
+#include "XCoreInstrInfo.h"
+#include "llvm/IR/Function.h"
using namespace llvm;
@@ -28,3 +30,31 @@ bool XCoreFunctionInfo::isLargeFrame(const MachineFunction &MF) const {
// 16KB of function arguments.
return CachedEStackSize > 0xf000;
}
+
+int XCoreFunctionInfo::createLRSpillSlot(MachineFunction &MF) {
+ if (LRSpillSlotSet) {
+ return LRSpillSlot;
+ }
+ const TargetRegisterClass *RC = &XCore::GRRegsRegClass;
+ MachineFrameInfo *MFI = MF.getFrameInfo();
+ if (! MF.getFunction()->isVarArg()) {
+ // A fixed offset of 0 allows us to save / restore LR using entsp / retsp.
+ LRSpillSlot = MFI->CreateFixedObject(RC->getSize(), 0, true);
+ } else {
+ LRSpillSlot = MFI->CreateStackObject(RC->getSize(), RC->getAlignment(), true);
+ }
+ LRSpillSlotSet = true;
+ return LRSpillSlot;
+}
+
+int XCoreFunctionInfo::createFPSpillSlot(MachineFunction &MF) {
+ if (FPSpillSlotSet) {
+ return FPSpillSlot;
+ }
+ const TargetRegisterClass *RC = &XCore::GRRegsRegClass;
+ MachineFrameInfo *MFI = MF.getFrameInfo();
+ FPSpillSlot = MFI->CreateStackObject(RC->getSize(), RC->getAlignment(), true);
+ FPSpillSlotSet = true;
+ return FPSpillSlot;
+}
+