diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2009-05-03 13:11:04 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2009-05-03 13:11:04 +0000 |
commit | d5047cb9f7f207798e1729911daa6d3752b668e3 (patch) | |
tree | 091355d8617d7bae8103cc8c0d40d5d797e9700a /lib/Target/MSP430/MSP430InstrInfo.cpp | |
parent | 875e1eb8ab7c6210f3d6d55d358e2c6a751f2cbb (diff) | |
download | llvm-d5047cb9f7f207798e1729911daa6d3752b668e3.tar.gz llvm-d5047cb9f7f207798e1729911daa6d3752b668e3.tar.bz2 llvm-d5047cb9f7f207798e1729911daa6d3752b668e3.tar.xz |
Add code for save/restore of callee-saved registers
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70739 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/MSP430/MSP430InstrInfo.cpp')
-rw-r--r-- | lib/Target/MSP430/MSP430InstrInfo.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/Target/MSP430/MSP430InstrInfo.cpp b/lib/Target/MSP430/MSP430InstrInfo.cpp index c32dbdca2e..199a323bf2 100644 --- a/lib/Target/MSP430/MSP430InstrInfo.cpp +++ b/lib/Target/MSP430/MSP430InstrInfo.cpp @@ -13,6 +13,7 @@ #include "MSP430.h" #include "MSP430InstrInfo.h" +#include "MSP430MachineFunctionInfo.h" #include "MSP430TargetMachine.h" #include "MSP430GenInstrInfo.inc" #include "llvm/Function.h" @@ -108,3 +109,43 @@ MSP430InstrInfo::isMoveInstr(const MachineInstr& MI, return true; } } + +bool +MSP430InstrInfo::spillCalleeSavedRegisters(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MI, + const std::vector<CalleeSavedInfo> &CSI) const { + if (CSI.empty()) + return false; + + DebugLoc DL = DebugLoc::getUnknownLoc(); + if (MI != MBB.end()) DL = MI->getDebugLoc(); + + MachineFunction &MF = *MBB.getParent(); + MSP430MachineFunctionInfo *MFI = MF.getInfo<MSP430MachineFunctionInfo>(); + MFI->setCalleeSavedFrameSize(CSI.size() * 2); + + for (unsigned i = CSI.size(); i != 0; --i) { + unsigned Reg = CSI[i-1].getReg(); + // Add the callee-saved register as live-in. It's killed at the spill. + MBB.addLiveIn(Reg); + BuildMI(MBB, MI, DL, get(MSP430::PUSH16r)) + .addReg(Reg, /*isDef=*/false, /*isImp=*/false, /*isKill=*/true); + } + return true; +} + +bool +MSP430InstrInfo::restoreCalleeSavedRegisters(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MI, + const std::vector<CalleeSavedInfo> &CSI) const { + if (CSI.empty()) + return false; + + DebugLoc DL = DebugLoc::getUnknownLoc(); + if (MI != MBB.end()) DL = MI->getDebugLoc(); + + for (unsigned i = 0, e = CSI.size(); i != e; ++i) + BuildMI(MBB, MI, DL, get(MSP430::POP16r), CSI[i].getReg()); + + return true; +} |