diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2010-11-27 23:05:03 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2010-11-27 23:05:03 +0000 |
commit | cd775ceff0b25a0b026f643a7990c2924bd310a3 (patch) | |
tree | bb545e378cb72e81202fbf3573790ffd18fa621d /lib/Target/ARM/ARMBaseInstrInfo.cpp | |
parent | 055942529bbc8487f86b47940dbd6a790516573e (diff) | |
download | external_llvm-cd775ceff0b25a0b026f643a7990c2924bd310a3.tar.gz external_llvm-cd775ceff0b25a0b026f643a7990c2924bd310a3.tar.bz2 external_llvm-cd775ceff0b25a0b026f643a7990c2924bd310a3.zip |
Move callee-saved regs spills / reloads to TFI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120228 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/ARMBaseInstrInfo.cpp')
-rw-r--r-- | lib/Target/ARM/ARMBaseInstrInfo.cpp | 122 |
1 files changed, 0 insertions, 122 deletions
diff --git a/lib/Target/ARM/ARMBaseInstrInfo.cpp b/lib/Target/ARM/ARMBaseInstrInfo.cpp index cb9c11295b..22fed76e92 100644 --- a/lib/Target/ARM/ARMBaseInstrInfo.cpp +++ b/lib/Target/ARM/ARMBaseInstrInfo.cpp @@ -197,128 +197,6 @@ ARMBaseInstrInfo::convertToThreeAddress(MachineFunction::iterator &MFI, return NewMIs[0]; } -void -ARMBaseInstrInfo::emitPushInst(MachineBasicBlock &MBB, - MachineBasicBlock::iterator MI, - const std::vector<CalleeSavedInfo> &CSI, unsigned Opc, - bool(*Func)(unsigned, bool)) const { - MachineFunction &MF = *MBB.getParent(); - DebugLoc DL; - if (MI != MBB.end()) DL = MI->getDebugLoc(); - - MachineInstrBuilder MIB = BuildMI(MF, DL, get(Opc)); - MIB.addReg(ARM::SP, getDefRegState(true)); - MIB.addReg(ARM::SP); - AddDefaultPred(MIB); - bool NumRegs = false; - for (unsigned i = CSI.size(); i != 0; --i) { - unsigned Reg = CSI[i-1].getReg(); - if (!(Func)(Reg, Subtarget.isTargetDarwin())) continue; - - // Add the callee-saved register as live-in unless it's LR and - // @llvm.returnaddress is called. If LR is returned for @llvm.returnaddress - // then it's already added to the function and entry block live-in sets. - bool isKill = true; - if (Reg == ARM::LR) { - if (MF.getFrameInfo()->isReturnAddressTaken() && - MF.getRegInfo().isLiveIn(Reg)) - isKill = false; - } - - if (isKill) - MBB.addLiveIn(Reg); - - NumRegs = true; - MIB.addReg(Reg, getKillRegState(isKill)); - } - - // It's illegal to emit push instruction without operands. - if (NumRegs) - MBB.insert(MI, &*MIB); - else - MF.DeleteMachineInstr(MIB); -} - -bool -ARMBaseInstrInfo::spillCalleeSavedRegisters(MachineBasicBlock &MBB, - MachineBasicBlock::iterator MI, - const std::vector<CalleeSavedInfo> &CSI, - const TargetRegisterInfo *TRI) const { - if (CSI.empty()) - return false; - - MachineFunction &MF = *MBB.getParent(); - ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>(); - DebugLoc DL = MI->getDebugLoc(); - - unsigned PushOpc = AFI->isThumbFunction() ? ARM::t2STMDB_UPD : ARM::STMDB_UPD; - unsigned FltOpc = ARM::VSTMDDB_UPD; - emitPushInst(MBB, MI, CSI, PushOpc, &isARMArea1Register); - emitPushInst(MBB, MI, CSI, PushOpc, &isARMArea2Register); - emitPushInst(MBB, MI, CSI, FltOpc, &isARMArea3Register); - - return true; -} - -void -ARMBaseInstrInfo::emitPopInst(MachineBasicBlock &MBB, - MachineBasicBlock::iterator MI, - const std::vector<CalleeSavedInfo> &CSI, unsigned Opc, - bool isVarArg, bool(*Func)(unsigned, bool)) const { - - MachineFunction &MF = *MBB.getParent(); - ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>(); - DebugLoc DL = MI->getDebugLoc(); - - MachineInstrBuilder MIB = BuildMI(MF, DL, get(Opc)); - MIB.addReg(ARM::SP, getDefRegState(true)); - MIB.addReg(ARM::SP); - AddDefaultPred(MIB); - bool NumRegs = false; - for (unsigned i = CSI.size(); i != 0; --i) { - unsigned Reg = CSI[i-1].getReg(); - if (!(Func)(Reg, Subtarget.isTargetDarwin())) continue; - - if (Reg == ARM::LR && !isVarArg) { - Reg = ARM::PC; - unsigned Opc = AFI->isThumbFunction() ? ARM::t2LDMIA_RET : ARM::LDMIA_RET; - (*MIB).setDesc(get(Opc)); - MI = MBB.erase(MI); - } - - MIB.addReg(Reg, RegState::Define); - NumRegs = true; - } - - // It's illegal to emit pop instruction without operands. - if (NumRegs) - MBB.insert(MI, &*MIB); - else - MF.DeleteMachineInstr(MIB); -} - -bool -ARMBaseInstrInfo::restoreCalleeSavedRegisters(MachineBasicBlock &MBB, - MachineBasicBlock::iterator MI, - const std::vector<CalleeSavedInfo> &CSI, - const TargetRegisterInfo *TRI) const { - if (CSI.empty()) - return false; - - MachineFunction &MF = *MBB.getParent(); - ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>(); - bool isVarArg = AFI->getVarArgsRegSaveSize() > 0; - DebugLoc DL = MI->getDebugLoc(); - - unsigned PopOpc = AFI->isThumbFunction() ? ARM::t2LDMIA_UPD : ARM::LDMIA_UPD; - unsigned FltOpc = ARM::VLDMDIA_UPD; - emitPopInst(MBB, MI, CSI, FltOpc, isVarArg, &isARMArea3Register); - emitPopInst(MBB, MI, CSI, PopOpc, isVarArg, &isARMArea2Register); - emitPopInst(MBB, MI, CSI, PopOpc, isVarArg, &isARMArea1Register); - - return true; -} - // Branch analysis. bool |