LLVM  3.7.0
Public Member Functions | Protected Attributes | List of all members
llvm::ARMFrameLowering Class Reference

#include <ARMFrameLowering.h>

Inheritance diagram for llvm::ARMFrameLowering:
[legend]
Collaboration diagram for llvm::ARMFrameLowering:
[legend]

Public Member Functions

 ARMFrameLowering (const ARMSubtarget &sti)
 
void emitPrologue (MachineFunction &MF, MachineBasicBlock &MBB) const override
 emitProlog/emitEpilog - These methods insert prolog and epilog code into the function. More...
 
void emitEpilogue (MachineFunction &MF, MachineBasicBlock &MBB) const override
 
void fixTCReturn (MachineFunction &MF, MachineBasicBlock &MBB) const
 
bool spillCalleeSavedRegisters (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const override
 spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns true if it isn't possible / profitable to do so by issuing a series of store instructions via storeRegToStackSlot(). More...
 
bool restoreCalleeSavedRegisters (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const override
 restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns true if it isn't possible / profitable to do so by issuing a series of load instructions via loadRegToStackSlot(). More...
 
bool noFramePointerElim (const MachineFunction &MF) const override
 Return true if the target needs to disable frame pointer elimination. More...
 
bool hasFP (const MachineFunction &MF) const override
 hasFP - Return true if the specified function should have a dedicated frame pointer register. More...
 
bool hasReservedCallFrame (const MachineFunction &MF) const override
 hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required, we reserve argument space for call sites in the function immediately on entry to the current function. More...
 
bool canSimplifyCallFramePseudos (const MachineFunction &MF) const override
 canSimplifyCallFramePseudos - If there is a reserved call frame, the call frame pseudos can be simplified. More...
 
int getFrameIndexReference (const MachineFunction &MF, int FI, unsigned &FrameReg) const override
 getFrameIndexReference - Provide a base+offset reference to an FI slot for debug info. More...
 
int ResolveFrameIndexReference (const MachineFunction &MF, int FI, unsigned &FrameReg, int SPAdj) const
 
int getFrameIndexOffset (const MachineFunction &MF, int FI) const override
 getFrameIndexOffset - Returns the displacement from the frame register to the stack frame of the specified index. More...
 
void determineCalleeSaves (MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const override
 This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() should actually get saved. More...
 
void adjustForSegmentedStacks (MachineFunction &MF, MachineBasicBlock &MBB) const override
 Adjust the prologue to have the function use segmented stacks. More...
 
- Public Member Functions inherited from llvm::TargetFrameLowering
 TargetFrameLowering (StackDirection D, unsigned StackAl, int LAO, unsigned TransAl=1, bool StackReal=true)
 
virtual ~TargetFrameLowering ()
 
StackDirection getStackGrowthDirection () const
 getStackGrowthDirection - Return the direction the stack grows More...
 
unsigned getStackAlignment () const
 getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligned on entry to a function. More...
 
unsigned getTransientStackAlignment () const
 getTransientStackAlignment - This method returns the number of bytes to which the stack pointer must be aligned at all times, even between calls. More...
 
bool isStackRealignable () const
 isStackRealignable - This method returns whether the stack can be realigned. More...
 
int getOffsetOfLocalArea () const
 getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on entrance to a function. More...
 
virtual bool isFPCloseToIncomingSP () const
 isFPCloseToIncomingSP - Return true if the frame pointer is close to the incoming stack pointer, false if it is close to the post-prologue stack pointer. More...
 
virtual bool assignCalleeSavedSpillSlots (MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const
 assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic. More...
 
virtual const SpillSlotgetCalleeSavedSpillSlots (unsigned &NumEntries) const
 getCalleeSavedSpillSlots - This method returns a pointer to an array of pairs, that contains an entry for each callee saved register that must be spilled to a particular stack location if it is spilled. More...
 
virtual bool targetHandlesStackFrameRounding () const
 targetHandlesStackFrameRounding - Returns true if the target is responsible for rounding up the stack frame (probably at emitPrologue time). More...
 
virtual void adjustForHiPEPrologue (MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
 Adjust the prologue to add Erlang Run-Time System (ERTS) specific code in the assembly prologue to explicitly handle the stack. More...
 
virtual void adjustForFrameAllocatePrologue (MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
 Adjust the prologue to add an allocation at a fixed offset from the frame pointer. More...
 
virtual bool needsFrameIndexResolution (const MachineFunction &MF) const
 
virtual int getFrameIndexReferenceFromSP (const MachineFunction &MF, int FI, unsigned &FrameReg) const
 Same as above, except that the 'base register' will always be RSP, not RBP on x86. More...
 
virtual void processFunctionBeforeFrameFinalized (MachineFunction &MF, RegScavenger *RS=nullptr) const
 processFunctionBeforeFrameFinalized - This method is called immediately before the specified function's frame layout (MF.getFrameInfo()) is finalized. More...
 
virtual bool canUseAsPrologue (const MachineBasicBlock &MBB) const
 Check whether or not the given MBB can be used as a prologue for the target. More...
 
virtual bool canUseAsEpilogue (const MachineBasicBlock &MBB) const
 Check whether or not the given MBB can be used as a epilogue for the target. More...
 

Protected Attributes

const ARMSubtargetSTI
 

Additional Inherited Members

- Public Types inherited from llvm::TargetFrameLowering
enum  StackDirection { StackGrowsUp, StackGrowsDown }
 

Detailed Description

Definition at line 22 of file ARMFrameLowering.h.

Constructor & Destructor Documentation

ARMFrameLowering::ARMFrameLowering ( const ARMSubtarget sti)
explicit

Definition at line 42 of file ARMFrameLowering.cpp.

Member Function Documentation

void ARMFrameLowering::adjustForSegmentedStacks ( MachineFunction MF,
MachineBasicBlock PrologueMBB 
) const
overridevirtual

Adjust the prologue to have the function use segmented stacks.

This works by adding a check even before the "normal" function prologue.

Reimplemented from llvm::TargetFrameLowering.

Definition at line 1874 of file ARMFrameLowering.cpp.

References llvm::AddDefaultCC(), llvm::AddDefaultPred(), llvm::MachineInstrBuilder::addExternalSymbol(), llvm::MachineModuleInfo::addFrameInst(), llvm::MachineInstrBuilder::addImm(), llvm::MachineBasicBlock::addLiveIn(), llvm::MachineInstrBuilder::addReg(), llvm::MachineBasicBlock::addSuccessor(), alignToARMConstant(), llvm::BuildMI(), llvm::TargetOpcode::CFI_INSTRUCTION, llvm::ARMConstantPoolSymbol::Create(), llvm::MCCFIInstruction::createDefCfaOffset(), llvm::MachineFunction::CreateMachineBasicBlock(), llvm::MCCFIInstruction::createOffset(), llvm::ARMFunctionInfo::createPICLabelUId(), llvm::MCCFIInstruction::createSameValue(), llvm::RegState::Define, llvm::DL, llvm::MachineFunction::front(), llvm::MachineFunction::getAlignment(), llvm::ARMFunctionInfo::getArgumentStackSize(), llvm::MachineFunction::getConstantPool(), llvm::MachineConstantPool::getConstantPoolIndex(), llvm::Function::getContext(), llvm::MachineModuleInfo::getContext(), llvm::MCRegisterInfo::getDwarfRegNum(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getFunction(), llvm::MachineFunction::getInfo(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MachineFunction::getMMI(), llvm::MCContext::getRegisterInfo(), llvm::MachineFunction::getSubtarget(), llvm::ARMSubtarget::isTargetAndroid(), llvm::ARMSubtarget::isTargetLinux(), llvm::ARMSubtarget::isThumb(), llvm::ARMSubtarget::isThumb1Only(), llvm::Function::isVarArg(), kSplitStackAvailable, llvm::MachineBasicBlock::livein_begin(), llvm::MachineBasicBlock::livein_end(), llvm::ARMCC::LO, llvm::MachineFunction::push_front(), R4, llvm::report_fatal_error(), llvm::AArch64DB::ST, llvm::Thumb, and llvm::MachineFunction::verify().

bool ARMFrameLowering::canSimplifyCallFramePseudos ( const MachineFunction MF) const
overridevirtual

canSimplifyCallFramePseudos - If there is a reserved call frame, the call frame pseudos can be simplified.

Unlike most targets, having a FP is not sufficient here since we still may reference some objects via SP even when FP is available in Thumb2 mode.

Reimplemented from llvm::TargetFrameLowering.

Definition at line 96 of file ARMFrameLowering.cpp.

References llvm::MachineFunction::getFrameInfo(), hasReservedCallFrame(), and llvm::MachineFrameInfo::hasVarSizedObjects().

Referenced by determineCalleeSaves().

void ARMFrameLowering::determineCalleeSaves ( MachineFunction MF,
BitVector SavedRegs,
RegScavenger RS 
) const
overridevirtual

This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() should actually get saved.

The default implementation checks populates the SavedRegs bitset with all registers which are modified in the function, targets may override this function to save additional registers. This method also sets up the register scavenger ensuring there is a free register or a frameindex available.

Reimplemented from llvm::TargetFrameLowering.

Definition at line 1517 of file ARMFrameLowering.cpp.

References llvm::RegScavenger::addScavengingFrameIndex(), llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::ARMBaseRegisterInfo::cannotEliminateFrame(), canSimplifyCallFramePseudos(), checkNumAlignedDPRCS2Regs(), contains(), llvm::TargetFrameLowering::determineCalleeSaves(), llvm::SmallVectorBase::empty(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::SmallVectorImpl< T >::erase(), estimateRSStackSizeLimit(), llvm::HexagonII::FPPos, FramePtr, llvm::SmallVectorTemplateCommon< T, typename >::front(), llvm::TargetRegisterClass::getAlignment(), llvm::ARMFunctionInfo::getArgRegsSaveSize(), llvm::ARMBaseRegisterInfo::getBaseRegister(), llvm::ARMBaseRegisterInfo::getCalleeSavedRegs(), llvm::MachineFunction::getFrameInfo(), llvm::ARMBaseRegisterInfo::getFrameRegister(), GetFunctionSizeInBytes(), llvm::MachineFunction::getInfo(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MachineFunction::getRegInfo(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::TargetRegisterClass::getSize(), llvm::TargetFrameLowering::getStackAlignment(), llvm::MachineFunction::getSubtarget(), llvm::ARMBaseRegisterInfo::hasBasePointer(), hasFP(), llvm::ARMFunctionInfo::hasStackFrame(), llvm::isARMLowRegister(), llvm::MachineRegisterInfo::isReserved(), llvm::ARMSubtarget::isTargetDarwin(), llvm::ARMFunctionInfo::isThumb1OnlyFunction(), llvm::ARMFunctionInfo::isThumb2Function(), llvm::ARMFunctionInfo::isThumbFunction(), llvm::ARMBaseRegisterInfo::needsStackRealignment(), llvm::SmallVectorTemplateBase< T, isPodLike >::pop_back(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), R2, R4, R6, llvm::BitVector::set(), llvm::ARMFunctionInfo::setHasStackFrame(), llvm::ARMFunctionInfo::setLRIsSpilledForFarJump(), llvm::SmallVectorTemplateCommon< T, typename >::size(), STI, and llvm::BitVector::test().

void ARMFrameLowering::emitEpilogue ( MachineFunction MF,
MachineBasicBlock MBB 
) const
overridevirtual
void ARMFrameLowering::emitPrologue ( MachineFunction MF,
MachineBasicBlock MBB 
) const
overridevirtual

emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.

Implements llvm::TargetFrameLowering.

Reimplemented in llvm::Thumb1FrameLowering.

Definition at line 289 of file ARMFrameLowering.cpp.

References llvm::AddDefaultCC(), llvm::AddDefaultPred(), llvm::MachineInstrBuilder::addExternalSymbol(), llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), llvm::ARMCC::AL, Align(), llvm::MachineBasicBlock::begin(), llvm::BuildMI(), llvm::TargetOpcode::CFI_INSTRUCTION, llvm::MCCFIInstruction::createDefCfa(), llvm::MCCFIInstruction::createDefCfaRegister(), llvm::MCCFIInstruction::createOffset(), llvm::CodeModel::Default, llvm::RegState::Define, emitAligningInstructions(), emitRegPlusImmediate(), emitSPUpdate(), llvm::MachineBasicBlock::end(), FramePtr, llvm::MachineInstr::FrameSetup, llvm::MachineFunction::front(), llvm::ARMFunctionInfo::getArgRegsSaveSize(), llvm::ARMBaseRegisterInfo::getBaseRegister(), llvm::MachineFrameInfo::getCalleeSavedInfo(), llvm::Function::getCallingConv(), llvm::TargetMachine::getCodeModel(), llvm::MCRegisterInfo::getDwarfRegNum(), llvm::MachineFunction::getFrameInfo(), llvm::ARMSubtarget::getFrameLowering(), llvm::ARMFunctionInfo::getFramePtrSpillOffset(), llvm::ARMBaseRegisterInfo::getFrameRegister(), llvm::MachineFunction::getFunction(), llvm::MachineFunction::getInfo(), llvm::ARMSubtarget::getInstrInfo(), llvm::MachineFrameInfo::getMaxAlignment(), llvm::MachineFunction::getMMI(), llvm::ARMFunctionInfo::getNumAlignedDPRCS2Regs(), llvm::MachineFrameInfo::getObjectOffset(), llvm::MachineFrameInfo::getOffsetAdjustment(), llvm::MCContext::getRegisterInfo(), llvm::ARMSubtarget::getRegisterInfo(), llvm::TargetFrameLowering::getStackAlignment(), llvm::MachineFrameInfo::getStackSize(), llvm::MachineFunction::getTarget(), llvm::CallingConv::GHC, llvm::ARMBaseRegisterInfo::hasBasePointer(), hasFP(), llvm::ARMFunctionInfo::hasStackFrame(), llvm::MachineFrameInfo::hasVarSizedObjects(), llvm::RegState::Implicit, llvm::ARMSubtarget::isTargetDarwin(), llvm::ARMSubtarget::isTargetELF(), llvm::ARMSubtarget::isTargetWindows(), llvm::ARMFunctionInfo::isThumb1OnlyFunction(), llvm::ARMFunctionInfo::isThumbFunction(), llvm::CodeModel::JITDefault, llvm::CodeModel::Kernel, llvm::RegState::Kill, llvm::CodeModel::Large, llvm::CodeModel::Medium, fuzzer::min(), llvm::ARMBaseRegisterInfo::needsStackRealignment(), R2, R4, R6, llvm::ARMFunctionInfo::setDPRCalleeSavedAreaOffset(), llvm::ARMFunctionInfo::setDPRCalleeSavedAreaSize(), llvm::ARMFunctionInfo::setDPRCalleeSavedGapSize(), llvm::ARMFunctionInfo::setFramePtrSpillOffset(), llvm::ARMFunctionInfo::setGPRCalleeSavedArea1Offset(), llvm::ARMFunctionInfo::setGPRCalleeSavedArea1Size(), llvm::ARMFunctionInfo::setGPRCalleeSavedArea2Offset(), llvm::ARMFunctionInfo::setGPRCalleeSavedArea2Size(), llvm::MachineInstrBuilder::setMIFlags(), llvm::MachineFrameInfo::setOffsetAdjustment(), llvm::ARMFunctionInfo::setShouldRestoreSPFromFP(), sizeOfSPAdjustment(), skipAlignedDPRCS2Spills(), llvm::CodeModel::Small, STI, TII, llvm::SystemZISD::TM, llvm::tryFoldSPUpdateIntoPushPop(), and WindowsRequiresStackProbe().

void ARMFrameLowering::fixTCReturn ( MachineFunction MF,
MachineBasicBlock MBB 
) const
int ARMFrameLowering::getFrameIndexOffset ( const MachineFunction MF,
int  FI 
) const
overridevirtual

getFrameIndexOffset - Returns the displacement from the frame register to the stack frame of the specified index.

This is the default implementation which is overridden for some targets.

Reimplemented from llvm::TargetFrameLowering.

Definition at line 935 of file ARMFrameLowering.cpp.

References getFrameIndexReference().

int ARMFrameLowering::getFrameIndexReference ( const MachineFunction MF,
int  FI,
unsigned FrameReg 
) const
overridevirtual

getFrameIndexReference - Provide a base+offset reference to an FI slot for debug info.

It's the same as what we use for resolving the code-gen references for now. FIXME: This can go wrong when references are SP-relative and simple call frames aren't used.

Reimplemented from llvm::TargetFrameLowering.

Definition at line 854 of file ARMFrameLowering.cpp.

References ResolveFrameIndexReference().

Referenced by getFrameIndexOffset().

bool ARMFrameLowering::hasFP ( const MachineFunction MF) const
overridevirtual
bool ARMFrameLowering::hasReservedCallFrame ( const MachineFunction MF) const
overridevirtual

hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required, we reserve argument space for call sites in the function immediately on entry to the current function.

This eliminates the need for add/sub sp brackets around call sites. Returns true if the call frame is included as part of the stack frame.

Reimplemented from llvm::TargetFrameLowering.

Reimplemented in llvm::Thumb1FrameLowering.

Definition at line 78 of file ARMFrameLowering.cpp.

References llvm::MachineFunction::getFrameInfo(), llvm::MachineFrameInfo::getMaxCallFrameSize(), and llvm::MachineFrameInfo::hasVarSizedObjects().

Referenced by canSimplifyCallFramePseudos(), llvm::ThumbRegisterInfo::eliminateFrameIndex(), llvm::ARMBaseRegisterInfo::eliminateFrameIndex(), and ResolveFrameIndexReference().

bool ARMFrameLowering::noFramePointerElim ( const MachineFunction MF) const
overridevirtual

Return true if the target needs to disable frame pointer elimination.

The default implementation just looks at attribute "no-frame-pointer-elim".

Reimplemented from llvm::TargetFrameLowering.

Definition at line 46 of file ARMFrameLowering.cpp.

References llvm::MachineFunction::getSubtarget(), and llvm::TargetFrameLowering::noFramePointerElim().

int ARMFrameLowering::ResolveFrameIndexReference ( const MachineFunction MF,
int  FI,
unsigned FrameReg,
int  SPAdj 
) const
bool ARMFrameLowering::restoreCalleeSavedRegisters ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MI,
const std::vector< CalleeSavedInfo > &  CSI,
const TargetRegisterInfo TRI 
) const
overridevirtual

restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns true if it isn't possible / profitable to do so by issuing a series of load instructions via loadRegToStackSlot().

Returns false otherwise.

Reimplemented from llvm::TargetFrameLowering.

Reimplemented in llvm::Thumb1FrameLowering.

Definition at line 1375 of file ARMFrameLowering.cpp.

References emitAlignedDPRCS2Restores(), llvm::ARMFunctionInfo::getArgRegsSaveSize(), llvm::MachineFunction::getInfo(), llvm::ARMFunctionInfo::getNumAlignedDPRCS2Regs(), llvm::MachineBasicBlock::getParent(), llvm::isARMArea1Register(), llvm::isARMArea2Register(), llvm::isARMArea3Register(), and llvm::ARMFunctionInfo::isThumbFunction().

bool ARMFrameLowering::spillCalleeSavedRegisters ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MI,
const std::vector< CalleeSavedInfo > &  CSI,
const TargetRegisterInfo TRI 
) const
overridevirtual

spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns true if it isn't possible / profitable to do so by issuing a series of store instructions via storeRegToStackSlot().

Returns false otherwise.

Reimplemented from llvm::TargetFrameLowering.

Reimplemented in llvm::Thumb1FrameLowering.

Definition at line 1344 of file ARMFrameLowering.cpp.

References emitAlignedDPRCS2Spills(), llvm::MachineInstr::FrameSetup, llvm::MachineFunction::getInfo(), llvm::ARMFunctionInfo::getNumAlignedDPRCS2Regs(), llvm::MachineBasicBlock::getParent(), llvm::isARMArea1Register(), llvm::isARMArea2Register(), llvm::isARMArea3Register(), and llvm::ARMFunctionInfo::isThumbFunction().

Member Data Documentation

const ARMSubtarget& llvm::ARMFrameLowering::STI
protected

The documentation for this class was generated from the following files: