class TargetFrameLowering

Declaration

class TargetFrameLowering { /* full declaration omitted */ };

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.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:43

Member Variables

private llvm::TargetFrameLowering::StackDirection StackDir
private llvm::Align StackAlignment
private llvm::Align TransientStackAlignment
private int LocalAreaOffset
private bool StackRealignable

Method Overview

Methods

TargetFrameLowering(
    llvm::TargetFrameLowering::StackDirection D,
    llvm::Align StackAl,
    int LAO,
    llvm::Align TransAl = llvm::Align(1),
    bool StackReal = true)

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:77

Parameters

llvm::TargetFrameLowering::StackDirection D
llvm::Align StackAl
int LAO
llvm::Align TransAl = llvm::Align(1)
bool StackReal = true

virtual void adjustForHiPEPrologue(
    llvm::MachineFunction& MF,
    llvm::MachineBasicBlock& PrologueMBB) const

Description

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

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:248

Parameters

llvm::MachineFunction& MF
llvm::MachineBasicBlock& PrologueMBB

virtual void adjustForSegmentedStacks(
    llvm::MachineFunction& MF,
    llvm::MachineBasicBlock& PrologueMBB) const

Description

Adjust the prologue to have the function use segmented stacks. This works by adding a check even before the "normal" function prologue.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:243

Parameters

llvm::MachineFunction& MF
llvm::MachineBasicBlock& PrologueMBB

int alignSPAdjust(int SPAdj) const

Description

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

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:105

Parameters

int SPAdj

virtual bool
allocateScavengingFrameIndexesNearIncomingSP(
    const llvm::MachineFunction& MF) const

Description

Control the placement of special register scavenging spill slots when allocating a stack frame. If this returns true, the frame indexes used by the RegScavenger will be allocated closest to the incoming stack pointer.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:147

Parameters

const llvm::MachineFunction& MF

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

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:165

Parameters

llvm::MachineFunction& MF
const llvm::TargetRegisterInfo* TRI
std::vector<CalleeSavedInfo>& CSI

virtual bool assignCalleeSavedSpillSlots(
    llvm::MachineFunction& MF,
    const llvm::TargetRegisterInfo* TRI,
    std::vector<CalleeSavedInfo>& CSI,
    unsigned int& MinCSFrameIndex,
    unsigned int& MaxCSFrameIndex) const

Description

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.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:156

Parameters

llvm::MachineFunction& MF
const llvm::TargetRegisterInfo* TRI
std::vector<CalleeSavedInfo>& CSI
unsigned int& MinCSFrameIndex
unsigned int& MaxCSFrameIndex

virtual bool canSimplifyCallFramePseudos(
    const llvm::MachineFunction& MF) const

Description

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.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:303

Parameters

const llvm::MachineFunction& MF

virtual bool canUseAsEpilogue(
    const llvm::MachineBasicBlock& MBB) const

Description

Check whether or not the given \p 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\p 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.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:427

Parameters

const llvm::MachineBasicBlock& MBB

virtual bool canUseAsPrologue(
    const llvm::MachineBasicBlock& MBB) const

Description

Check whether or not the given \p 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\p 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.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:415

Parameters

const llvm::MachineBasicBlock& MBB

virtual void determineCalleeSaves(
    llvm::MachineFunction& MF,
    llvm::BitVector& SavedRegs,
    llvm::RegScavenger* RS = nullptr) const

Description

This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() should actually get saved. The default implementation checks populates the \p 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. This method should not be called by any passes outside of PEI, because it may change state passed in by \p MF and \p RS. The preferred interface outside PEI is getCalleeSaves.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:358

Parameters

llvm::MachineFunction& MF
llvm::BitVector& SavedRegs
llvm::RegScavenger* RS = nullptr

virtual MachineBasicBlock::iterator
eliminateCallFramePseudoInstr(
    llvm::MachineFunction& MF,
    llvm::MachineBasicBlock& MBB,
    MachineBasicBlock::iterator MI) const

Description

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. Returns an iterator pointing to the instruction after the replaced one.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:388

Parameters

llvm::MachineFunction& MF
llvm::MachineBasicBlock& MBB
MachineBasicBlock::iterator MI

virtual void emitCalleeSavedFrameMovesFullCFA(
    llvm::MachineBasicBlock& MBB,
    MachineBasicBlock::iterator MBBI) const

Description

With basic block sections, emit callee saved frame moves for basic blocks that are in a different section.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:223

Parameters

llvm::MachineBasicBlock& MBB
MachineBasicBlock::iterator MBBI

virtual void emitEpilogue(
    llvm::MachineFunction& MF,
    llvm::MachineBasicBlock& MBB) const

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:213

Parameters

llvm::MachineFunction& MF
llvm::MachineBasicBlock& MBB

virtual void emitPrologue(
    llvm::MachineFunction& MF,
    llvm::MachineBasicBlock& MBB) const

Description

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

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:211

Parameters

llvm::MachineFunction& MF
llvm::MachineBasicBlock& MBB

virtual void emitZeroCallUsedRegs(
    llvm::BitVector RegsToZero,
    llvm::MachineBasicBlock& MBB) const

Description

emitZeroCallUsedRegs - Zeros out call used registers.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:217

Parameters

llvm::BitVector RegsToZero
llvm::MachineBasicBlock& MBB

virtual bool enableCFIFixup(
    llvm::MachineFunction& MF) const

Description

Returns true if we may need to fix the unwind information for the function.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:228

Parameters

llvm::MachineFunction& MF

virtual bool enableCalleeSaveSkip(
    const llvm::MachineFunction& MF) const

Description

Returns true if the target can safely skip saving callee-saved registers for noreturn nounwind functions.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:207

Parameters

const llvm::MachineFunction& MF

virtual bool enableShrinkWrapping(
    const llvm::MachineFunction& MF) const

Description

Returns true if the target will correctly handle shrink wrapping.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:194

Parameters

const llvm::MachineFunction& MF

virtual bool enableStackSlotScavenging(
    const llvm::MachineFunction& MF) const

Description

Returns true if the stack slot holes in the fixed and callee-save stack area should be used when allocating other stack locations to reduce stack size.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:201

Parameters

const llvm::MachineFunction& MF

virtual const llvm::TargetFrameLowering::
    SpillSlot*
    getCalleeSavedSpillSlots(
        unsigned int& NumEntries) const

Description

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.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:181

Parameters

unsigned int& NumEntries

virtual void getCalleeSaves(
    const llvm::MachineFunction& MF,
    llvm::BitVector& SavedRegs) const

Description

Returns the callee-saved registers as computed by determineCalleeSaves in the BitVector \p SavedRegs.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:345

Parameters

const llvm::MachineFunction& MF
llvm::BitVector& SavedRegs

virtual llvm::TargetFrameLowering::DwarfFrameBase
getDwarfFrameBase(
    const llvm::MachineFunction& MF) const

Description

Return the frame base information to be encoded in the DWARF subprogram debug info.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:465

Parameters

const llvm::MachineFunction& MF

virtual llvm::StackOffset getFrameIndexReference(
    const llvm::MachineFunction& MF,
    int FI,
    llvm::Register& FrameReg) const

Description

getFrameIndexReference - This method should return the base register and offset used to reference a frame index location. The offset is returned directly, and the base register is returned via FrameReg.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:315

Parameters

const llvm::MachineFunction& MF
int FI
llvm::Register& FrameReg

virtual llvm::StackOffset
getFrameIndexReferencePreferSP(
    const llvm::MachineFunction& MF,
    int FI,
    llvm::Register& FrameReg,
    bool IgnoreSPUpdates) const

Description

Same as \c getFrameIndexReference, except that the stack pointer (as opposed to the frame pointer) will be the preferred value for \p FrameReg. This is generally used for emitting statepoint or EH tables that use offsets from RSP. If \p IgnoreSPUpdates is true, the returned offset is only guaranteed to be valid with respect to the value of SP at the end of the prologue.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:325

Parameters

const llvm::MachineFunction& MF
int FI
llvm::Register& FrameReg
bool IgnoreSPUpdates

virtual int getInitialCFAOffset(
    const llvm::MachineFunction& MF) const

Description

Return initial CFA offset value i.e. the one valid at the beginning of the function (before any stack operations).

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:457

Parameters

const llvm::MachineFunction& MF

virtual llvm::Register getInitialCFARegister(
    const llvm::MachineFunction& MF) const

Description

Return initial CFA register value i.e. the one valid at the beginning of the function (before any stack operations).

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:461

Parameters

const llvm::MachineFunction& MF

virtual llvm::StackOffset
getNonLocalFrameIndexReference(
    const llvm::MachineFunction& MF,
    int FI) const

Description

getNonLocalFrameIndexReference - This method returns the offset used to reference a frame index location. The offset can be from either FP/BP/SP based on which base register is returned by llvm.localaddress.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:335

Parameters

const llvm::MachineFunction& MF
int FI

int getOffsetOfLocalArea() const

Description

getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on entrance to a function.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:140

llvm::Align getStackAlign() const

Description

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.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:100

unsigned int getStackAlignment() const

Description

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.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:95

virtual unsigned int getStackAlignmentSkew(
    const llvm::MachineFunction& MF) const

Description

Return the skew that has to be applied to stack alignment under certain conditions (e.g. stack was adjusted before function \p MF was called).

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:129

Parameters

const llvm::MachineFunction& MF

llvm::TargetFrameLowering::StackDirection
getStackGrowthDirection() const

Description

getStackGrowthDirection - Return the direction the stack grows

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:89

virtual TargetStackID::Value
getStackIDForScalableVectors() const

Description

Returns the StackID that scalable vectors should be associated with.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:432

llvm::Align getTransientStackAlign() const

Description

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

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:118

virtual unsigned int getWinEHParentFrameOffset(
    const llvm::MachineFunction& MF) const

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:377

Parameters

const llvm::MachineFunction& MF

virtual bool hasFP(
    const llvm::MachineFunction& MF) const

Description

hasFP - Return true if the specified function should have a dedicated frame pointer register. For most targets this is true only if the function has variable sized allocas or if frame pointer elimination is disabled.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:285

Parameters

const llvm::MachineFunction& MF

virtual bool hasReservedCallFrame(
    const llvm::MachineFunction& MF) const

Description

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.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:292

Parameters

const llvm::MachineFunction& MF

virtual void inlineStackProbe(
    llvm::MachineFunction& MF,
    llvm::MachineBasicBlock& PrologueMBB) const

Description

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

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:235

Parameters

llvm::MachineFunction& MF
llvm::MachineBasicBlock& PrologueMBB

virtual bool isProfitableForNoCSROpt(
    const llvm::Function& F) const

Description

Check if the no-CSR optimisation is profitable for the given function.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:451

Parameters

const llvm::Function& F

static bool isSafeForNoCSROpt(
    const llvm::Function& F)

Description

Check if given function is safe for not having callee saved registers. This is used when interprocedural register allocation is enabled.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:448

Parameters

const llvm::Function& F

virtual bool isStackIdSafeForLocalArea(
    unsigned int StackId) const

Description

This method returns whether or not it is safe for an object with the given stack id to be bundled into the local area.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:133

Parameters

unsigned int StackId

bool isStackRealignable() const

Description

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

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:122

virtual bool isSupportedStackID(
    TargetStackID::Value ID) const

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:436

Parameters

TargetStackID::Value ID

virtual bool keepFramePointer(
    const llvm::MachineFunction& MF) const

Description

Return true if the target wants to keep the frame pointer regardless of the function attribute "frame-pointer".

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:278

Parameters

const llvm::MachineFunction& MF

virtual bool needsFrameIndexResolution(
    const llvm::MachineFunction& MF) const

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:310

Parameters

const llvm::MachineFunction& MF

virtual void orderFrameObjects(
    const llvm::MachineFunction& MF,
    SmallVectorImpl<int>& objectsToAllocate) const

Description

Order the symbols in the local stack frame. The list of objects that we want to order is in \p objectsToAllocate as indices into the MachineFrameInfo. The array can be reordered in any way upon return. The contents of the array, however, may not be modified (i.e. only their order may be changed). By default, just maintain the original order.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:403

Parameters

const llvm::MachineFunction& MF
SmallVectorImpl<int>& objectsToAllocate

virtual void processFunctionBeforeFrameFinalized(
    llvm::MachineFunction& MF,
    llvm::RegScavenger* RS = nullptr) const

Description

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.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:366

Parameters

llvm::MachineFunction& MF
llvm::RegScavenger* RS = nullptr

virtual void
processFunctionBeforeFrameIndicesReplaced(
    llvm::MachineFunction& MF,
    llvm::RegScavenger* RS = nullptr) const

Description

processFunctionBeforeFrameIndicesReplaced - This method is called immediately before MO_FrameIndex operands are eliminated, but after the frame is finalized. This method is optional.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:374

Parameters

llvm::MachineFunction& MF
llvm::RegScavenger* RS = nullptr

virtual void resetCFIToInitialState(
    llvm::MachineBasicBlock& MBB) const

Description

Emit CFI instructions that recreate the state of the unwind information upon fucntion entry.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:232

Parameters

llvm::MachineBasicBlock& MBB

virtual bool restoreCalleeSavedRegisters(
    llvm::MachineBasicBlock& MBB,
    MachineBasicBlock::iterator MI,
    MutableArrayRef<llvm::CalleeSavedInfo> CSI,
    const llvm::TargetRegisterInfo* TRI) const

Description

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(). If it returns true, and any of the registers in CSI is not restored, it sets the corresponding Restored flag in CSI to false. Returns false otherwise.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:269

Parameters

llvm::MachineBasicBlock& MBB
MachineBasicBlock::iterator MI
MutableArrayRef<llvm::CalleeSavedInfo> CSI
const llvm::TargetRegisterInfo* TRI

virtual bool spillCalleeSavedRegisters(
    llvm::MachineBasicBlock& MBB,
    MachineBasicBlock::iterator MI,
    ArrayRef<llvm::CalleeSavedInfo> CSI,
    const llvm::TargetRegisterInfo* TRI) const

Description

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.

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:255

Parameters

llvm::MachineBasicBlock& MBB
MachineBasicBlock::iterator MI
ArrayRef<llvm::CalleeSavedInfo> CSI
const llvm::TargetRegisterInfo* TRI

virtual bool stackProbeFunctionModifiesSP() const

Description

Does the stack probe function call return with a modified stack pointer?

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:239

virtual bool targetHandlesStackFrameRounding()
    const

Description

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

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:189

virtual ~TargetFrameLowering()

Declared at: llvm/include/llvm/CodeGen/TargetFrameLowering.h:82