Add XCore intrinsic for setpsc.
[oota-llvm.git] / lib / Target / XCore / XCoreFrameLowering.cpp
index 1b91d4231477d4bb44c06a3a80df62daef9bb0ab..057822074e5469cdb9bdd29a98efc36c49102d23 100644 (file)
@@ -100,6 +100,11 @@ void XCoreFrameLowering::emitPrologue(MachineFunction &MF) const {
   DebugLoc dl = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc();
 
   bool FP = hasFP(MF);
+  bool Nested = MF.getFunction()->getAttributes().hasAttrSomewhere(Attribute::Nest);
+
+  if (Nested) {
+    loadFromStack(MBB, MBBI, XCore::R11, 0, dl, TII);
+  }
 
   // Work out frame sizes.
   int FrameSize = MFI->getStackSize();
@@ -208,7 +213,7 @@ void XCoreFrameLowering::emitPrologue(MachineFunction &MF) const {
 void XCoreFrameLowering::emitEpilogue(MachineFunction &MF,
                                      MachineBasicBlock &MBB) const {
   MachineFrameInfo *MFI            = MF.getFrameInfo();
-  MachineBasicBlock::iterator MBBI = prior(MBB.end());
+  MachineBasicBlock::iterator MBBI = MBB.getLastNonDebugInstr();
   const XCoreInstrInfo &TII =
     *static_cast<const XCoreInstrInfo*>(MF.getTarget().getInstrInfo());
   DebugLoc dl = MBBI->getDebugLoc();