LLVM  mainline
Classes | Public Types | Public Member Functions
llvm::TargetFrameLowering Class Reference

Information about stack frame layout on the target. More...

#include <TargetFrameLowering.h>

Inheritance diagram for llvm::TargetFrameLowering:
Inheritance graph
[legend]

List of all members.

Classes

struct  SpillSlot

Public Types

enum  StackDirection { StackGrowsUp, StackGrowsDown }

Public Member Functions

 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
unsigned getStackAlignment () const
 getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligned on entry to a function.
int alignSPAdjust (int SPAdj) const
 alignSPAdjust - This method aligns the stack adjustment to the correct alignment.
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.
bool isStackRealignable () const
 isStackRealignable - This method returns whether the stack can be realigned.
virtual unsigned getStackAlignmentSkew (const MachineFunction &MF) const
 Return the skew that has to be applied to stack alignment under certain conditions (e.g.
int getOffsetOfLocalArea () const
 getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on entrance to a function.
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.
virtual bool assignCalleeSavedSpillSlots (MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const
 assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic.
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.
virtual bool targetHandlesStackFrameRounding () const
 targetHandlesStackFrameRounding - Returns true if the target is responsible for rounding up the stack frame (probably at emitPrologue time).
virtual bool enableShrinkWrapping (const MachineFunction &MF) const
 Returns true if the target will correctly handle shrink wrapping.
virtual void emitPrologue (MachineFunction &MF, MachineBasicBlock &MBB) const =0
 emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
virtual void emitEpilogue (MachineFunction &MF, MachineBasicBlock &MBB) const =0
virtual void inlineStackProbe (MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
 Replace a StackProbe stub (if any) with the actual probe code inline.
virtual void adjustForSegmentedStacks (MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
 Adjust the prologue to have the function use segmented stacks.
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.
virtual void adjustForFrameAllocatePrologue (MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
 Adjust the prologue to add an allocation at a fixed offset from the frame pointer.
virtual bool spillCalleeSavedRegisters (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const
 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().
virtual bool restoreCalleeSavedRegisters (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const
 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().
virtual bool noFramePointerElim (const MachineFunction &MF) const
 Return true if the target needs to disable frame pointer elimination.
virtual bool hasFP (const MachineFunction &MF) const =0
 hasFP - Return true if the specified function should have a dedicated frame pointer register.
virtual bool hasReservedCallFrame (const MachineFunction &MF) const
 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.
virtual bool canSimplifyCallFramePseudos (const MachineFunction &MF) const
 canSimplifyCallFramePseudos - When possible, it's best to simplify the call frame pseudo ops before doing frame index elimination.
virtual bool needsFrameIndexResolution (const MachineFunction &MF) const
virtual int getFrameIndexReference (const MachineFunction &MF, int FI, unsigned &FrameReg) const
 getFrameIndexReference - This method should return the base register and offset used to reference a frame index location.
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.
virtual void determineCalleeSaves (MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
 This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() should actually get saved.
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.
virtual unsigned getWinEHParentFrameOffset (const MachineFunction &MF) const
virtual void eliminateCallFramePseudoInstr (MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const
 eliminateCallFramePseudoInstr - This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy pseudo instructions (but only if the Target is using them).
virtual bool canUseAsPrologue (const MachineBasicBlock &MBB) const
 Check whether or not the given MBB can be used as a prologue for the target.
virtual bool canUseAsEpilogue (const MachineBasicBlock &MBB) const
 Check whether or not the given MBB can be used as a epilogue for the target.

Detailed Description

Information about stack frame layout on the target.

It holds the direction of stack growth, the known stack alignment on entry to each function, and the offset to the locals area.

The offset to the local area is the offset from the stack pointer on function entry to the first location where function data (local variables, spill locations) can be stored.

Definition at line 34 of file TargetFrameLowering.h.


Member Enumeration Documentation

Enumerator:
StackGrowsUp 
StackGrowsDown 

Definition at line 36 of file TargetFrameLowering.h.


Constructor & Destructor Documentation

llvm::TargetFrameLowering::TargetFrameLowering ( StackDirection  D,
unsigned  StackAl,
int  LAO,
unsigned  TransAl = 1,
bool  StackReal = true 
) [inline]

Definition at line 53 of file TargetFrameLowering.h.

Definition at line 27 of file TargetFrameLoweringImpl.cpp.


Member Function Documentation

virtual void llvm::TargetFrameLowering::adjustForFrameAllocatePrologue ( MachineFunction MF,
MachineBasicBlock PrologueMBB 
) const [inline, virtual]

Adjust the prologue to add an allocation at a fixed offset from the frame pointer.

Definition at line 178 of file TargetFrameLowering.h.

virtual void llvm::TargetFrameLowering::adjustForHiPEPrologue ( MachineFunction MF,
MachineBasicBlock PrologueMBB 
) const [inline, virtual]

Adjust the prologue to add Erlang Run-Time System (ERTS) specific code in the assembly prologue to explicitly handle the stack.

Reimplemented in llvm::X86FrameLowering.

Definition at line 172 of file TargetFrameLowering.h.

virtual void llvm::TargetFrameLowering::adjustForSegmentedStacks ( MachineFunction MF,
MachineBasicBlock PrologueMBB 
) const [inline, virtual]

Adjust the prologue to have the function use segmented stacks.

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

Reimplemented in llvm::X86FrameLowering, and llvm::ARMFrameLowering.

Definition at line 167 of file TargetFrameLowering.h.

alignSPAdjust - This method aligns the stack adjustment to the correct alignment.

Definition at line 76 of file TargetFrameLowering.h.

References llvm::alignTo().

Referenced by llvm::TargetInstrInfo::getSPAdjust().

virtual bool llvm::TargetFrameLowering::assignCalleeSavedSpillSlots ( MachineFunction MF,
const TargetRegisterInfo TRI,
std::vector< CalleeSavedInfo > &  CSI 
) const [inline, virtual]

assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic.

If implemented, assignCalleeSavedSpillSlots() should assign frame slots to all CSI entries and return true. If this method returns false, spill slots will be assigned using generic implementation. assignCalleeSavedSpillSlots() may add, delete or rearrange elements of CSI.

Reimplemented in llvm::X86FrameLowering, and llvm::HexagonFrameLowering.

Definition at line 121 of file TargetFrameLowering.h.

canSimplifyCallFramePseudos - When possible, it's best to simplify the call frame pseudo ops before doing frame index elimination.

This is possible only when frame index references between the pseudos won't need adjusting for the call frame adjustments. Normally, that's true if the function has a reserved call frame or a frame pointer. Some targets (Thumb2, for example) may have more complicated criteria, however, and can override this behavior.

Reimplemented in llvm::X86FrameLowering, and llvm::ARMFrameLowering.

Definition at line 227 of file TargetFrameLowering.h.

References hasFP(), and hasReservedCallFrame().

virtual bool llvm::TargetFrameLowering::canUseAsEpilogue ( const MachineBasicBlock MBB) const [inline, virtual]

Check whether or not the given MBB can be used as a epilogue for the target.

The epilogue will be inserted before the first terminator of that block. This method is used by the shrink-wrapping pass to decide if MBB will be correctly handled by the target. As soon as the target enable shrink-wrapping without overriding this method, we assume that each basic block is a valid epilogue.

Reimplemented in llvm::X86FrameLowering, llvm::PPCFrameLowering, and llvm::Thumb1FrameLowering.

Definition at line 311 of file TargetFrameLowering.h.

virtual bool llvm::TargetFrameLowering::canUseAsPrologue ( const MachineBasicBlock MBB) const [inline, virtual]

Check whether or not the given MBB can be used as a prologue for the target.

The prologue will be inserted first in this basic block. This method is used by the shrink-wrapping pass to decide if MBB will be correctly handled by the target. As soon as the target enable shrink-wrapping without overriding this method, we assume that each basic block is a valid prologue.

Reimplemented in llvm::PPCFrameLowering.

Definition at line 299 of file TargetFrameLowering.h.

void TargetFrameLowering::determineCalleeSaves ( MachineFunction MF,
BitVector SavedRegs,
RegScavenger RS = nullptr 
) const [virtual]

eliminateCallFramePseudoInstr - This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy pseudo instructions (but only if the Target is using them).

It is responsible for eliminating these instructions, replacing them with concrete instructions. This method need only be implemented if using call frame setup/destroy pseudo instructions.

Reimplemented in llvm::X86FrameLowering, llvm::PPCFrameLowering, llvm::SystemZFrameLowering, llvm::Thumb1FrameLowering, llvm::XCoreFrameLowering, llvm::HexagonFrameLowering, llvm::MipsFrameLowering, llvm::BPFFrameLowering, llvm::MSP430FrameLowering, llvm::SparcFrameLowering, llvm::AArch64FrameLowering, llvm::final< T >, and llvm::NVPTXFrameLowering.

Definition at line 284 of file TargetFrameLowering.h.

References llvm_unreachable.

virtual void llvm::TargetFrameLowering::emitEpilogue ( MachineFunction MF,
MachineBasicBlock MBB 
) const [pure virtual]
virtual void llvm::TargetFrameLowering::emitPrologue ( MachineFunction MF,
MachineBasicBlock MBB 
) const [pure virtual]

Returns true if the target will correctly handle shrink wrapping.

Reimplemented in llvm::X86FrameLowering, llvm::PPCFrameLowering, llvm::AArch64FrameLowering, llvm::ARMFrameLowering, and llvm::Thumb1FrameLowering.

Definition at line 150 of file TargetFrameLowering.h.

virtual const SpillSlot* llvm::TargetFrameLowering::getCalleeSavedSpillSlots ( unsigned NumEntries) const [inline, virtual]

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.

Each entry in this array contains a <register,offset> pair, indicating the fixed offset from the incoming stack pointer that each register should be spilled at. If a register is not listed here, the code generator is allowed to spill it anywhere it chooses.

Reimplemented in llvm::PPCFrameLowering, llvm::HexagonFrameLowering, llvm::AMDGPUFrameLowering, and llvm::SystemZFrameLowering.

Definition at line 137 of file TargetFrameLowering.h.

int TargetFrameLowering::getFrameIndexReference ( const MachineFunction MF,
int  FI,
unsigned FrameReg 
) const [virtual]

getFrameIndexReference - This method should return the base register and offset used to reference a frame index location.

Returns the displacement from the frame register to the stack frame of the specified index, along with the frame register used (in output arg FrameReg).

The offset is returned directly, and the base register is returned via FrameReg.

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

Reimplemented in llvm::X86FrameLowering, llvm::HexagonFrameLowering, llvm::ARMFrameLowering, llvm::SystemZFrameLowering, llvm::SparcFrameLowering, llvm::AArch64FrameLowering, llvm::AMDGPUFrameLowering, and llvm::MipsSEFrameLowering.

Definition at line 40 of file TargetFrameLoweringImpl.cpp.

References llvm::MachineFunction::getFrameInfo(), llvm::TargetRegisterInfo::getFrameRegister(), llvm::MachineFrameInfo::getObjectOffset(), llvm::MachineFrameInfo::getOffsetAdjustment(), getOffsetOfLocalArea(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MachineFrameInfo::getStackSize(), and llvm::MachineFunction::getSubtarget().

Referenced by emitDebugValueComment(), and llvm::AMDGPUInstrInfo::getIndirectIndexEnd().

virtual int llvm::TargetFrameLowering::getFrameIndexReferenceFromSP ( const MachineFunction MF,
int  FI,
unsigned FrameReg 
) const [inline, virtual]

Same as above, except that the 'base register' will always be RSP, not RBP on x86.

This is generally used for emitting statepoint or EH tables that use offsets from RSP. TODO: This should really be a parameterizable choice.

Reimplemented in llvm::X86FrameLowering.

Definition at line 246 of file TargetFrameLowering.h.

References llvm_unreachable.

getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligned on entry to a function.

Typically, this is the largest alignment for any data object in the target.

Reimplemented in llvm::final< T >, and llvm::final< T >.

Definition at line 71 of file TargetFrameLowering.h.

Referenced by llvm::PPCFrameLowering::addScavengingSpillSlot(), llvm::HexagonFrameLowering::assignCalleeSavedSpillSlots(), checkNumAlignedDPRCS2Regs(), llvm::ARMFrameLowering::determineCalleeSaves(), llvm::PPCFrameLowering::determineFrameLayout(), llvm::AArch64FrameLowering::eliminateCallFramePseudoInstr(), llvm::MSP430FrameLowering::eliminateCallFramePseudoInstr(), llvm::XCoreFrameLowering::eliminateCallFramePseudoInstr(), llvm::Thumb1FrameLowering::eliminateCallFramePseudoInstr(), llvm::X86FrameLowering::eliminateCallFramePseudoInstr(), llvm::SparcFrameLowering::emitPrologue(), llvm::ARMFrameLowering::emitPrologue(), llvm::XCoreFrameLowering::emitPrologue(), EnsureStackAlignment(), llvm::MipsFrameLowering::estimateStackSize(), llvm::MachineFrameInfo::estimateStackSize(), llvm::MipsTargetLowering::HandleByVal(), llvm::MipsSEFrameLowering::hasReservedCallFrame(), llvm::PPCRegisterInfo::lowerDynamicAlloc(), llvm::MachineFunction::MachineFunction(), llvm::HexagonFrameLowering::needsAligna(), llvm::ARMBaseRegisterInfo::needsFrameBaseReg(), llvm::TargetRegisterInfo::needsStackRealignment(), llvm::HexagonFrameLowering::processFunctionBeforeFrameFinalized(), and llvm::FunctionLoweringInfo::set().

Return the skew that has to be applied to stack alignment under certain conditions (e.g.

stack was adjusted before function MF was called).

Definition at line 86 of file TargetFrameLoweringImpl.cpp.

References llvm::Function::getCallingConv(), llvm::MachineFunction::getFunction(), llvm::TargetMachine::getPointerSize(), llvm::MachineFunction::getTarget(), llvm::CallingConv::HHVM, and LLVM_UNLIKELY.

getStackGrowthDirection - Return the direction the stack grows

Definition at line 65 of file TargetFrameLowering.h.

Referenced by llvm::TargetInstrInfo::getSPAdjust().

getTransientStackAlignment - This method returns the number of bytes to which the stack pointer must be aligned at all times, even between calls.

Definition at line 89 of file TargetFrameLowering.h.

Referenced by llvm::MachineFrameInfo::estimateStackSize().

Reimplemented in llvm::X86FrameLowering.

Definition at line 272 of file TargetFrameLowering.h.

References llvm::report_fatal_error().

virtual bool llvm::TargetFrameLowering::hasFP ( const MachineFunction MF) const [pure virtual]

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 in llvm::X86FrameLowering, llvm::AArch64FrameLowering, llvm::SystemZFrameLowering, llvm::ARMFrameLowering, llvm::MSP430FrameLowering, llvm::Thumb1FrameLowering, llvm::final< T >, llvm::Mips16FrameLowering, llvm::MipsSEFrameLowering, and llvm::SparcFrameLowering.

Definition at line 216 of file TargetFrameLowering.h.

References hasFP().

Referenced by llvm::MipsRegisterInfo::canRealignStack(), canSimplifyCallFramePseudos(), llvm::AArch64FrameLowering::eliminateCallFramePseudoInstr(), llvm::MipsFrameLowering::eliminateCallFramePseudoInstr(), llvm::XCoreFrameLowering::eliminateCallFramePseudoInstr(), llvm::MipsFrameLowering::estimateStackSize(), and llvm::MachineFrameInfo::estimateStackSize().

virtual void llvm::TargetFrameLowering::inlineStackProbe ( MachineFunction MF,
MachineBasicBlock PrologueMBB 
) const [inline, virtual]

Replace a StackProbe stub (if any) with the actual probe code inline.

Reimplemented in llvm::X86FrameLowering.

Definition at line 162 of file TargetFrameLowering.h.

virtual bool llvm::TargetFrameLowering::isFPCloseToIncomingSP ( ) const [inline, virtual]

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.

Reimplemented in llvm::MipsFrameLowering, and llvm::SystemZFrameLowering.

Definition at line 112 of file TargetFrameLowering.h.

isStackRealignable - This method returns whether the stack can be realigned.

Definition at line 95 of file TargetFrameLowering.h.

Referenced by llvm::MachineFunction::MachineFunction(), and llvm::FunctionLoweringInfo::set().

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

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

Reimplemented in llvm::ARMFrameLowering.

Definition at line 31 of file TargetFrameLoweringImpl.cpp.

References llvm::Function::getFnAttribute(), llvm::MachineFunction::getFunction(), and llvm::Attribute::getValueAsString().

Referenced by llvm::TargetOptions::DisableFramePointerElim().

virtual void llvm::TargetFrameLowering::processFunctionBeforeFrameFinalized ( MachineFunction MF,
RegScavenger RS = nullptr 
) const [inline, virtual]

processFunctionBeforeFrameFinalized - This method is called immediately before the specified function's frame layout (MF.getFrameInfo()) is finalized.

Once the frame is finalized, MO_FrameIndex operands are replaced with direct constants. This method is optional.

Reimplemented in llvm::X86FrameLowering, llvm::PPCFrameLowering, llvm::XCoreFrameLowering, llvm::MSP430FrameLowering, llvm::HexagonFrameLowering, llvm::SystemZFrameLowering, and llvm::final< T >.

Definition at line 268 of file TargetFrameLowering.h.

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 in llvm::X86FrameLowering, llvm::PPCFrameLowering, llvm::AArch64FrameLowering, llvm::MSP430FrameLowering, llvm::ARMFrameLowering, llvm::XCoreFrameLowering, llvm::Thumb1FrameLowering, llvm::HexagonFrameLowering, llvm::SystemZFrameLowering, and llvm::Mips16FrameLowering.

Definition at line 196 of file TargetFrameLowering.h.

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 in llvm::X86FrameLowering, llvm::PPCFrameLowering, llvm::AArch64FrameLowering, llvm::MSP430FrameLowering, llvm::XCoreFrameLowering, llvm::ARMFrameLowering, llvm::Thumb1FrameLowering, llvm::MipsSEFrameLowering, llvm::HexagonFrameLowering, llvm::SystemZFrameLowering, and llvm::Mips16FrameLowering.

Definition at line 185 of file TargetFrameLowering.h.

targetHandlesStackFrameRounding - Returns true if the target is responsible for rounding up the stack frame (probably at emitPrologue time).

Reimplemented in llvm::PPCFrameLowering, llvm::HexagonFrameLowering, and llvm::SparcFrameLowering.

Definition at line 145 of file TargetFrameLowering.h.


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