From d0c38176690e9602a93a20a43f1bd084564a8116 Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Thu, 18 Nov 2010 21:19:35 +0000 Subject: 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 --- lib/Target/Alpha/AlphaFrameInfo.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'lib/Target/Alpha/AlphaFrameInfo.cpp') diff --git a/lib/Target/Alpha/AlphaFrameInfo.cpp b/lib/Target/Alpha/AlphaFrameInfo.cpp index 601e5dbd35..0b25b4849d 100644 --- a/lib/Target/Alpha/AlphaFrameInfo.cpp +++ b/lib/Target/Alpha/AlphaFrameInfo.cpp @@ -34,17 +34,23 @@ static long getLower16(long l) { return l - h * Alpha::IMM_MULT; } +// 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 AlphaFrameInfo::hasFP(const MachineFunction &MF) const { + const MachineFrameInfo *MFI = MF.getFrameInfo(); + return MFI->hasVarSizedObjects(); +} + void AlphaFrameInfo::emitPrologue(MachineFunction &MF) const { MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB MachineBasicBlock::iterator MBBI = MBB.begin(); MachineFrameInfo *MFI = MF.getFrameInfo(); - const AlphaRegisterInfo *RegInfo = - static_cast(MF.getTarget().getRegisterInfo()); - const AlphaInstrInfo &TII = - *static_cast(MF.getTarget().getInstrInfo()); + const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); DebugLoc dl = (MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc()); - bool FP = RegInfo->hasFP(MF); + bool FP = hasFP(MF); // Handle GOP offset BuildMI(MBB, MBBI, dl, TII.get(Alpha::LDAHg), Alpha::R29) @@ -99,17 +105,14 @@ void AlphaFrameInfo::emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const { const MachineFrameInfo *MFI = MF.getFrameInfo(); MachineBasicBlock::iterator MBBI = prior(MBB.end()); - const AlphaRegisterInfo *RegInfo = - static_cast(MF.getTarget().getRegisterInfo()); - const AlphaInstrInfo &TII = - *static_cast(MF.getTarget().getInstrInfo()); + const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); assert((MBBI->getOpcode() == Alpha::RETDAG || MBBI->getOpcode() == Alpha::RETDAGp) && "Can only insert epilog into returning blocks"); DebugLoc dl = MBBI->getDebugLoc(); - bool FP = RegInfo->hasFP(MF); + bool FP = hasFP(MF); // Get the number of bytes allocated from the FrameInfo... long NumBytes = MFI->getStackSize(); -- cgit v1.2.3