diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2010-11-18 21:19:35 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2010-11-18 21:19:35 +0000 |
commit | d0c38176690e9602a93a20a43f1bd084564a8116 (patch) | |
tree | d4c7a39ff5665d4adb34f193c2256f1c6d033181 /lib/Target/Mips/MipsFrameInfo.cpp | |
parent | b9064bb96458ab48a878e1a7e678cada2e22ab7a (diff) | |
download | external_llvm-d0c38176690e9602a93a20a43f1bd084564a8116.tar.gz external_llvm-d0c38176690e9602a93a20a43f1bd084564a8116.tar.bz2 external_llvm-d0c38176690e9602a93a20a43f1bd084564a8116.zip |
Move hasFP() and few related hooks to TargetFrameInfo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119740 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Mips/MipsFrameInfo.cpp')
-rw-r--r-- | lib/Target/Mips/MipsFrameInfo.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/Target/Mips/MipsFrameInfo.cpp b/lib/Target/Mips/MipsFrameInfo.cpp index 29e8bc50bb..c062b6b05c 100644 --- a/lib/Target/Mips/MipsFrameInfo.cpp +++ b/lib/Target/Mips/MipsFrameInfo.cpp @@ -79,11 +79,17 @@ using namespace llvm; // //===----------------------------------------------------------------------===// +// hasFP - Return true if the specified function should have a dedicated frame +// pointer register. This is true if the function has variable sized allocas or +// if frame pointer elimination is disabled. +bool MipsFrameInfo::hasFP(const MachineFunction &MF) const { + const MachineFrameInfo *MFI = MF.getFrameInfo(); + return DisableFramePointerElim(MF) || MFI->hasVarSizedObjects(); +} + void MipsFrameInfo::adjustMipsStackFrame(MachineFunction &MF) const { MachineFrameInfo *MFI = MF.getFrameInfo(); MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>(); - const MipsRegisterInfo *RegInfo = - static_cast<const MipsRegisterInfo*>(MF.getTarget().getRegisterInfo()); const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo(); unsigned StackAlign = MF.getTarget().getFrameInfo()->getStackAlignment(); unsigned RegSize = STI.isGP32bit() ? 4 : 8; @@ -152,7 +158,7 @@ void MipsFrameInfo::adjustMipsStackFrame(MachineFunction &MF) const { // Stack locations for FP and RA. If only one of them is used, // the space must be allocated for both, otherwise no space at all. - if (RegInfo->hasFP(MF) || MFI->adjustsStack()) { + if (hasFP(MF) || MFI->adjustsStack()) { // FP stack location MFI->setObjectOffset(MFI->CreateStackObject(RegSize, RegSize, true), StackOffset); @@ -242,7 +248,7 @@ void MipsFrameInfo::emitPrologue(MachineFunction &MF) const { // if framepointer enabled, save it and set it // to point to the stack pointer - if (RegInfo->hasFP(MF)) { + if (hasFP(MF)) { // sw $fp,stack_loc($sp) BuildMI(MBB, MBBI, dl, TII.get(Mips::SW)) .addReg(Mips::FP).addImm(FPOffset).addReg(Mips::SP); @@ -263,8 +269,6 @@ void MipsFrameInfo::emitEpilogue(MachineFunction &MF, MachineBasicBlock::iterator MBBI = prior(MBB.end()); MachineFrameInfo *MFI = MF.getFrameInfo(); MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>(); - const MipsRegisterInfo *RegInfo = - static_cast<const MipsRegisterInfo*>(MF.getTarget().getRegisterInfo()); const MipsInstrInfo &TII = *static_cast<const MipsInstrInfo*>(MF.getTarget().getInstrInfo()); DebugLoc dl = MBBI->getDebugLoc(); @@ -278,7 +282,7 @@ void MipsFrameInfo::emitEpilogue(MachineFunction &MF, // if framepointer enabled, restore it and restore the // stack pointer - if (RegInfo->hasFP(MF)) { + if (hasFP(MF)) { // move $sp, $fp BuildMI(MBB, MBBI, dl, TII.get(Mips::ADDu), Mips::SP) .addReg(Mips::FP).addReg(Mips::ZERO); |