summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/XCore/XCoreFrameInfo.cpp
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2010-11-27 23:05:03 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2010-11-27 23:05:03 +0000
commitd08fbd19f5b05b8dfff5ae13726301618c62a4d0 (patch)
tree71b65a3ebf6940e12b4dcf1ab09847711cf620bb /llvm/lib/Target/XCore/XCoreFrameInfo.cpp
parent056356d50204f035c381b8004a3a66c60e314115 (diff)
downloadbcm5719-llvm-d08fbd19f5b05b8dfff5ae13726301618c62a4d0.tar.gz
bcm5719-llvm-d08fbd19f5b05b8dfff5ae13726301618c62a4d0.zip
Move callee-saved regs spills / reloads to TFI
llvm-svn: 120228
Diffstat (limited to 'llvm/lib/Target/XCore/XCoreFrameInfo.cpp')
-rw-r--r--llvm/lib/Target/XCore/XCoreFrameInfo.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/llvm/lib/Target/XCore/XCoreFrameInfo.cpp b/llvm/lib/Target/XCore/XCoreFrameInfo.cpp
index 5359abb98c9..cf957a7ed45 100644
--- a/llvm/lib/Target/XCore/XCoreFrameInfo.cpp
+++ b/llvm/lib/Target/XCore/XCoreFrameInfo.cpp
@@ -271,3 +271,68 @@ void XCoreFrameInfo::getInitialFrameState(std::vector<MachineMove> &Moves)
MachineLocation Src(XCore::SP, 0);
Moves.push_back(MachineMove(0, Dst, Src));
}
+
+bool XCoreFrameInfo::spillCalleeSavedRegisters(MachineBasicBlock &MBB,
+ MachineBasicBlock::iterator MI,
+ const std::vector<CalleeSavedInfo> &CSI,
+ const TargetRegisterInfo *TRI) const {
+ if (CSI.empty())
+ return true;
+
+ MachineFunction *MF = MBB.getParent();
+ const TargetInstrInfo &TII = *MF->getTarget().getInstrInfo();
+
+ XCoreFunctionInfo *XFI = MF->getInfo<XCoreFunctionInfo>();
+ bool emitFrameMoves = XCoreRegisterInfo::needsFrameMoves(*MF);
+
+ DebugLoc DL;
+ if (MI != MBB.end()) DL = MI->getDebugLoc();
+
+ for (std::vector<CalleeSavedInfo>::const_iterator it = CSI.begin();
+ it != CSI.end(); ++it) {
+ // Add the callee-saved register as live-in. It's killed at the spill.
+ MBB.addLiveIn(it->getReg());
+
+ unsigned Reg = it->getReg();
+ const TargetRegisterClass *RC = TRI->getMinimalPhysRegClass(Reg);
+ TII.storeRegToStackSlot(MBB, MI, Reg, true,
+ it->getFrameIdx(), RC, TRI);
+ if (emitFrameMoves) {
+ MCSymbol *SaveLabel = MF->getContext().CreateTempSymbol();
+ BuildMI(MBB, MI, DL, TII.get(XCore::PROLOG_LABEL)).addSym(SaveLabel);
+ XFI->getSpillLabels().push_back(std::make_pair(SaveLabel, *it));
+ }
+ }
+ return true;
+}
+
+bool XCoreFrameInfo::restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
+ MachineBasicBlock::iterator MI,
+ const std::vector<CalleeSavedInfo> &CSI,
+ const TargetRegisterInfo *TRI) const{
+ MachineFunction *MF = MBB.getParent();
+ const TargetInstrInfo &TII = *MF->getTarget().getInstrInfo();
+
+ bool AtStart = MI == MBB.begin();
+ MachineBasicBlock::iterator BeforeI = MI;
+ if (!AtStart)
+ --BeforeI;
+ for (std::vector<CalleeSavedInfo>::const_iterator it = CSI.begin();
+ it != CSI.end(); ++it) {
+ unsigned Reg = it->getReg();
+ const TargetRegisterClass *RC = TRI->getMinimalPhysRegClass(Reg);
+ TII.loadRegFromStackSlot(MBB, MI, it->getReg(), it->getFrameIdx(),
+ RC, TRI);
+ assert(MI != MBB.begin() &&
+ "loadRegFromStackSlot didn't insert any code!");
+ // Insert in reverse order. loadRegFromStackSlot can insert multiple
+ // instructions.
+ if (AtStart)
+ MI = MBB.begin();
+ else {
+ MI = BeforeI;
+ ++MI;
+ }
+ }
+ return true;
+}
OpenPOWER on IntegriCloud