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

Method Overview

Methods

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

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

Parameters

llvm::TargetFrameLowering::StackDirection D
llvm::Align StackAl
int LAO
llvm::Align TransAl = Align::None()
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:192

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:187

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:85

Parameters

int SPAdj

virtual bool assignCalleeSavedSpillSlots(
    llvm::MachineFunction& MF,
    const llvm::TargetRegisterInfo* TRI,
    int& CSI) const

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

Parameters

llvm::MachineFunction& MF
const llvm::TargetRegisterInfo* TRI
int& CSI

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:246

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:362

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:350

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:300

Parameters

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

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

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

Parameters

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

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

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

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:176

Parameters

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

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:172

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:159

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:166

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:146

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:287

Parameters

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

virtual int getFrameIndexReference(
    const llvm::MachineFunction& MF,
    int FI,
    unsigned int& 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:258

Parameters

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

virtual int getFrameIndexReferencePreferSP(
    const llvm::MachineFunction& MF,
    int FI,
    unsigned int& 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:267

Parameters

const llvm::MachineFunction& MF
int FI
unsigned int& 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:392

Parameters

const llvm::MachineFunction& MF

virtual unsigned int 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:396

Parameters

const llvm::MachineFunction& MF

virtual int 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:277

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:116

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:80

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:111

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:74

virtual TargetStackID::Value
getStackIDForScalableVectors() const

Description

Returns the StackID that scalable vectors should be associated with.

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

unsigned int getTransientStackAlignment() 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:98

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

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

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:228

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:235

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:182

Parameters

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

virtual bool isFPCloseToIncomingSP() const

Description

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.

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

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:386

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:383

Parameters

const llvm::Function& F

bool isStackRealignable() const

Description

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

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

virtual bool isSupportedStackID(
    TargetStackID::Value ID) const

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

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:221

Parameters

const llvm::MachineFunction& MF

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

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

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:338

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:308

Parameters

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

virtual bool restoreCalleeSavedRegisters(
    llvm::MachineBasicBlock& MBB,
    int MI,
    int& CSI,
    const llvm::TargetRegisterInfo* TRI) const

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

Parameters

llvm::MachineBasicBlock& MBB
int MI
int& CSI
const llvm::TargetRegisterInfo* TRI

virtual bool spillCalleeSavedRegisters(
    llvm::MachineBasicBlock& MBB,
    int MI,
    const int& CSI,
    const llvm::TargetRegisterInfo* TRI) const

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

Parameters

llvm::MachineBasicBlock& MBB
int MI
const int& CSI
const llvm::TargetRegisterInfo* TRI

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:154

virtual ~TargetFrameLowering()

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