LLVM 20.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::TargetFrameLowering Class Referenceabstract

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

#include "llvm/CodeGen/TargetFrameLowering.h"

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

Classes

struct  DwarfFrameBase
 
struct  SpillSlot
 

Public Types

enum  StackDirection { StackGrowsUp , StackGrowsDown }
 

Public Member Functions

 TargetFrameLowering (StackDirection D, Align StackAl, int LAO, Align TransAl=Align(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.
 
Align getStackAlign () const
 getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligned on entry to a function.
 
virtual uint64_t getStackThreshold () const
 getStackThreshold - Return the maximum stack size
 
int alignSPAdjust (int SPAdj) const
 alignSPAdjust - This method aligns the stack adjustment to the correct alignment.
 
Align getTransientStackAlign () 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 bool isStackIdSafeForLocalArea (unsigned StackId) const
 This method returns whether or not it is safe for an object with the given stack id to be bundled into the local area.
 
int getOffsetOfLocalArea () const
 getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on entrance to a function.
 
virtual bool allocateScavengingFrameIndexesNearIncomingSP (const MachineFunction &MF) const
 Control the placement of special register scavenging spill slots when allocating a stack frame.
 
virtual bool assignCalleeSavedSpillSlots (MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI, unsigned &MinCSFrameIndex, unsigned &MaxCSFrameIndex) const
 assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic.
 
virtual bool assignCalleeSavedSpillSlots (MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const
 
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 bool enableStackSlotScavenging (const MachineFunction &MF) const
 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.
 
virtual bool enableCalleeSaveSkip (const MachineFunction &MF) const
 Returns true if the target can safely skip saving callee-saved registers for noreturn nounwind functions.
 
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 emitZeroCallUsedRegs (BitVector RegsToZero, MachineBasicBlock &MBB) const
 emitZeroCallUsedRegs - Zeros out call used registers.
 
virtual void emitCalleeSavedFrameMovesFullCFA (MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI) const
 With basic block sections, emit callee saved frame moves for basic blocks that are in a different section.
 
virtual bool enableCFIFixup (MachineFunction &MF) const
 Returns true if we may need to fix the unwind information for the function.
 
virtual void resetCFIToInitialState (MachineBasicBlock &MBB) const
 Emit CFI instructions that recreate the state of the unwind information upon fucntion entry.
 
virtual void inlineStackProbe (MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
 Replace a StackProbe stub (if any) with the actual probe code inline.
 
virtual bool stackProbeFunctionModifiesSP () const
 Does the stack probe function call return with a modified stack pointer?
 
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 bool spillCalleeSavedRegisters (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, ArrayRef< 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, MutableArrayRef< 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 keepFramePointer (const MachineFunction &MF) const
 Return true if the target wants to keep the frame pointer regardless of the function attribute "frame-pointer".
 
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 StackOffset getFrameIndexReference (const MachineFunction &MF, int FI, Register &FrameReg) const
 getFrameIndexReference - This method should return the base register and offset used to reference a frame index location.
 
virtual StackOffset getFrameIndexReferencePreferSP (const MachineFunction &MF, int FI, Register &FrameReg, bool IgnoreSPUpdates) const
 Same as getFrameIndexReference, except that the stack pointer (as opposed to the frame pointer) will be the preferred value for FrameReg.
 
virtual StackOffset getNonLocalFrameIndexReference (const MachineFunction &MF, int FI) const
 getNonLocalFrameIndexReference - This method returns the offset used to reference a frame index location.
 
virtual StackOffset getFrameIndexReferenceFromSP (const MachineFunction &MF, int FI) const
 getFrameIndexReferenceFromSP - This method returns the offset from the stack pointer to the slot of the specified index.
 
virtual void getCalleeSaves (const MachineFunction &MF, BitVector &SavedRegs) const
 Returns the callee-saved registers as computed by determineCalleeSaves in the BitVector SavedRegs.
 
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 void processFunctionBeforeFrameIndicesReplaced (MachineFunction &MF, RegScavenger *RS=nullptr) const
 processFunctionBeforeFrameIndicesReplaced - This method is called immediately before MO_FrameIndex operands are eliminated, but after the frame is finalized.
 
virtual unsigned getWinEHParentFrameOffset (const MachineFunction &MF) const
 
virtual MachineBasicBlock::iterator eliminateCallFramePseudoInstr (MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const
 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 void orderFrameObjects (const MachineFunction &MF, SmallVectorImpl< int > &objectsToAllocate) const
 Order the symbols in the local stack frame.
 
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.
 
virtual TargetStackID::Value getStackIDForScalableVectors () const
 Returns the StackID that scalable vectors should be associated with.
 
virtual bool isSupportedStackID (TargetStackID::Value ID) const
 
virtual bool isProfitableForNoCSROpt (const Function &F) const
 Check if the no-CSR optimisation is profitable for the given function.
 
virtual int getInitialCFAOffset (const MachineFunction &MF) const
 Return initial CFA offset value i.e.
 
virtual Register getInitialCFARegister (const MachineFunction &MF) const
 Return initial CFA register value i.e.
 
virtual DwarfFrameBase getDwarfFrameBase (const MachineFunction &MF) const
 Return the frame base information to be encoded in the DWARF subprogram debug info.
 
virtual void spillFPBP (MachineFunction &MF) const
 If frame pointer or base pointer is clobbered by an instruction, we should spill/restore it around that instruction.
 
virtual void emitRemarks (const MachineFunction &MF, MachineOptimizationRemarkEmitter *ORE) const
 This method is called at the end of prolog/epilog code insertion, so targets can emit remarks based on the final frame layout.
 

Static Public Member Functions

static bool isSafeForNoCSROpt (const Function &F)
 Check if given function is safe for not having callee saved registers.
 

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 45 of file TargetFrameLowering.h.

Member Enumeration Documentation

◆ StackDirection

Enumerator
StackGrowsUp 
StackGrowsDown 

Definition at line 47 of file TargetFrameLowering.h.

Constructor & Destructor Documentation

◆ TargetFrameLowering()

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

Definition at line 82 of file TargetFrameLowering.h.

◆ ~TargetFrameLowering()

TargetFrameLowering::~TargetFrameLowering ( )
virtualdefault

Member Function Documentation

◆ adjustForHiPEPrologue()

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

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 252 of file TargetFrameLowering.h.

◆ adjustForSegmentedStacks()

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

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::ARMFrameLowering, and llvm::X86FrameLowering.

Definition at line 247 of file TargetFrameLowering.h.

◆ alignSPAdjust()

int llvm::TargetFrameLowering::alignSPAdjust ( int  SPAdj) const
inline

◆ allocateScavengingFrameIndexesNearIncomingSP()

bool TargetFrameLowering::allocateScavengingFrameIndexesNearIncomingSP ( const MachineFunction MF) const
virtual

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.

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

Definition at line 147 of file TargetFrameLoweringImpl.cpp.

References llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MachineFunction::getSubtarget(), hasFP(), llvm::TargetRegisterInfo::hasStackRealignment(), and llvm::TargetRegisterInfo::useFPForScavengingIndex().

◆ assignCalleeSavedSpillSlots() [1/2]

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

◆ assignCalleeSavedSpillSlots() [2/2]

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

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::AArch64FrameLowering, and llvm::RISCVFrameLowering.

Definition at line 160 of file TargetFrameLowering.h.

References assignCalleeSavedSpillSlots(), and TRI.

Referenced by assignCalleeSavedSpillSlots(), and assignCalleeSavedSpillSlots().

◆ canSimplifyCallFramePseudos()

virtual bool llvm::TargetFrameLowering::canSimplifyCallFramePseudos ( const MachineFunction MF) const
inlinevirtual

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::ARMFrameLowering, llvm::AVRFrameLowering, llvm::HexagonFrameLowering, llvm::M68kFrameLowering, and llvm::X86FrameLowering.

Definition at line 307 of file TargetFrameLowering.h.

References hasFP(), and hasReservedCallFrame().

◆ canUseAsEpilogue()

virtual bool llvm::TargetFrameLowering::canUseAsEpilogue ( const MachineBasicBlock MBB) const
inlinevirtual

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::Thumb1FrameLowering, llvm::PPCFrameLowering, llvm::RISCVFrameLowering, and llvm::X86FrameLowering.

Definition at line 438 of file TargetFrameLowering.h.

◆ canUseAsPrologue()

virtual bool llvm::TargetFrameLowering::canUseAsPrologue ( const MachineBasicBlock MBB) const
inlinevirtual

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::AArch64FrameLowering, llvm::PPCFrameLowering, llvm::RISCVFrameLowering, and llvm::X86FrameLowering.

Definition at line 426 of file TargetFrameLowering.h.

◆ determineCalleeSaves()

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

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. This method should not be called by any passes outside of PEI, because it may change state passed in by MF and RS. The preferred interface outside PEI is getCalleeSaves.

Reimplemented in llvm::AArch64FrameLowering, llvm::ARCFrameLowering, llvm::ARMFrameLowering, llvm::BPFFrameLowering, llvm::CSKYFrameLowering, llvm::HexagonFrameLowering, llvm::LoongArchFrameLowering, llvm::Mips16FrameLowering, llvm::MipsSEFrameLowering, llvm::RISCVFrameLowering, llvm::SystemZELFFrameLowering, llvm::SystemZXPLINKFrameLowering, llvm::XtensaFrameLowering, llvm::SIFrameLowering, llvm::AVRFrameLowering, llvm::LanaiFrameLowering, llvm::M68kFrameLowering, llvm::PPCFrameLowering, llvm::SparcFrameLowering, llvm::VEFrameLowering, llvm::X86FrameLowering, and llvm::XCoreFrameLowering.

Definition at line 96 of file TargetFrameLoweringImpl.cpp.

References llvm::MachineFunction::callsUnwindInit(), enableCalleeSaveSkip(), llvm::TargetOptions::EnableIPRA, llvm::MachineRegisterInfo::getCalleeSavedRegs(), llvm::MachineFunction::getFunction(), llvm::MachineFunction::getRegInfo(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MachineFunction::getSubtarget(), llvm::MachineFunction::getTarget(), llvm::Function::hasFnAttribute(), isProfitableForNoCSROpt(), isSafeForNoCSROpt(), MRI, llvm::TargetMachine::Options, llvm::BitVector::resize(), llvm::BitVector::set(), and TRI.

Referenced by llvm::AArch64FrameLowering::determineCalleeSaves(), llvm::ARCFrameLowering::determineCalleeSaves(), llvm::ARMFrameLowering::determineCalleeSaves(), llvm::BPFFrameLowering::determineCalleeSaves(), llvm::CSKYFrameLowering::determineCalleeSaves(), llvm::HexagonFrameLowering::determineCalleeSaves(), llvm::LoongArchFrameLowering::determineCalleeSaves(), llvm::Mips16FrameLowering::determineCalleeSaves(), llvm::MipsSEFrameLowering::determineCalleeSaves(), llvm::RISCVFrameLowering::determineCalleeSaves(), llvm::SystemZELFFrameLowering::determineCalleeSaves(), llvm::SystemZXPLINKFrameLowering::determineCalleeSaves(), llvm::XtensaFrameLowering::determineCalleeSaves(), llvm::SIFrameLowering::determineCalleeSaves(), llvm::AVRFrameLowering::determineCalleeSaves(), llvm::LanaiFrameLowering::determineCalleeSaves(), llvm::M68kFrameLowering::determineCalleeSaves(), llvm::PPCFrameLowering::determineCalleeSaves(), llvm::SparcFrameLowering::determineCalleeSaves(), llvm::VEFrameLowering::determineCalleeSaves(), llvm::X86FrameLowering::determineCalleeSaves(), llvm::XCoreFrameLowering::determineCalleeSaves(), and llvm::SIFrameLowering::determineCalleeSavesSGPR().

◆ eliminateCallFramePseudoInstr()

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

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.

Reimplemented in llvm::AArch64FrameLowering, llvm::ARCFrameLowering, llvm::HexagonFrameLowering, llvm::LanaiFrameLowering, llvm::MipsFrameLowering, llvm::MSP430FrameLowering, llvm::NVPTXFrameLowering, llvm::PPCFrameLowering, llvm::SparcFrameLowering, llvm::VEFrameLowering, llvm::WebAssemblyFrameLowering, llvm::XCoreFrameLowering, llvm::XtensaFrameLowering, llvm::SIFrameLowering, llvm::Thumb1FrameLowering, llvm::AVRFrameLowering, llvm::BPFFrameLowering, llvm::CSKYFrameLowering, llvm::LoongArchFrameLowering, llvm::M68kFrameLowering, llvm::RISCVFrameLowering, and llvm::X86FrameLowering.

Definition at line 399 of file TargetFrameLowering.h.

References llvm_unreachable.

◆ emitCalleeSavedFrameMovesFullCFA()

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

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

Reimplemented in llvm::X86FrameLowering.

Definition at line 227 of file TargetFrameLowering.h.

◆ emitEpilogue()

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

◆ emitPrologue()

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

◆ emitRemarks()

virtual void llvm::TargetFrameLowering::emitRemarks ( const MachineFunction MF,
MachineOptimizationRemarkEmitter ORE 
) const
inlinevirtual

This method is called at the end of prolog/epilog code insertion, so targets can emit remarks based on the final frame layout.

Definition at line 484 of file TargetFrameLowering.h.

◆ emitZeroCallUsedRegs()

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

emitZeroCallUsedRegs - Zeros out call used registers.

Definition at line 221 of file TargetFrameLowering.h.

◆ enableCalleeSaveSkip()

bool TargetFrameLowering::enableCalleeSaveSkip ( const MachineFunction MF) const
virtual

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

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

Definition at line 32 of file TargetFrameLoweringImpl.cpp.

References assert(), llvm::MachineFunction::getFunction(), and llvm::Function::hasFnAttribute().

Referenced by determineCalleeSaves().

◆ enableCFIFixup()

bool TargetFrameLowering::enableCFIFixup ( MachineFunction MF) const
virtual

◆ enableShrinkWrapping()

virtual bool llvm::TargetFrameLowering::enableShrinkWrapping ( const MachineFunction MF) const
inlinevirtual

◆ enableStackSlotScavenging()

virtual bool llvm::TargetFrameLowering::enableStackSlotScavenging ( const MachineFunction MF) const
inlinevirtual

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.

Reimplemented in llvm::AArch64FrameLowering.

Definition at line 205 of file TargetFrameLowering.h.

◆ getCalleeSavedSpillSlots()

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

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::ARMFrameLowering, llvm::HexagonFrameLowering, llvm::PPCFrameLowering, and llvm::VEFrameLowering.

Definition at line 185 of file TargetFrameLowering.h.

Referenced by assignCalleeSavedSpillSlots().

◆ getCalleeSaves()

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

◆ getDwarfFrameBase()

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

◆ getFrameIndexReference()

StackOffset TargetFrameLowering::getFrameIndexReference ( const MachineFunction MF,
int  FI,
Register 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::AArch64FrameLowering, llvm::R600FrameLowering, llvm::SIFrameLowering, llvm::ARMFrameLowering, llvm::CSKYFrameLowering, llvm::HexagonFrameLowering, llvm::LoongArchFrameLowering, llvm::M68kFrameLowering, llvm::MipsSEFrameLowering, llvm::NVPTXFrameLowering, llvm::RISCVFrameLowering, llvm::SparcFrameLowering, llvm::SystemZELFFrameLowering, llvm::VEFrameLowering, and llvm::X86FrameLowering.

Definition at line 49 of file TargetFrameLoweringImpl.cpp.

References llvm::StackOffset::getFixed(), 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 canSpillOnFrameIndexAccess(), llvm::SystemZRegisterInfo::eliminateFrameIndex(), llvm::LoongArchRegisterInfo::eliminateFrameIndex(), emitDebugValueComment(), llvm::SystemZELFFrameLowering::getFrameIndexReference(), getFrameIndexReferencePreferSP(), and getNonLocalFrameIndexReference().

◆ getFrameIndexReferenceFromSP()

StackOffset TargetFrameLowering::getFrameIndexReferenceFromSP ( const MachineFunction MF,
int  FI 
) const
virtual

getFrameIndexReferenceFromSP - This method returns the offset from the stack pointer to the slot of the specified index.

Returns the offset from the stack pointer to the slot of the specified index.

This function serves to provide a comparable offset from a single reference point (the value of the stack-pointer at function entry) that can be used for analysis.

This function serves to provide a comparable offset from a single reference point (the value of the stack-pointer at function entry) that can be used for analysis. This is the default implementation using MachineFrameInfo offsets.

Reimplemented in llvm::AArch64FrameLowering.

Definition at line 70 of file TargetFrameLoweringImpl.cpp.

References llvm::StackOffset::getFixed(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFrameInfo::getObjectOffset(), and getOffsetOfLocalArea().

◆ getFrameIndexReferencePreferSP()

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

Same as getFrameIndexReference, except that the stack pointer (as opposed to the frame pointer) will be the preferred value for FrameReg.

This is generally used for emitting statepoint or EH tables that use offsets from RSP. If 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.

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

Definition at line 329 of file TargetFrameLowering.h.

References getFrameIndexReference().

◆ getInitialCFAOffset()

int TargetFrameLowering::getInitialCFAOffset ( const MachineFunction MF) const
virtual

Return initial CFA offset value i.e.

the one valid at the beginning of the function (before any stack operations).

Reimplemented in llvm::X86FrameLowering.

Definition at line 169 of file TargetFrameLoweringImpl.cpp.

References llvm_unreachable.

◆ getInitialCFARegister()

Register TargetFrameLowering::getInitialCFARegister ( const MachineFunction MF) const
virtual

Return initial CFA register value i.e.

the one valid at the beginning of the function (before any stack operations).

Reimplemented in llvm::X86FrameLowering.

Definition at line 174 of file TargetFrameLoweringImpl.cpp.

References llvm_unreachable.

◆ getNonLocalFrameIndexReference()

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

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.

Reimplemented in llvm::AArch64FrameLowering.

Definition at line 339 of file TargetFrameLowering.h.

References getFrameIndexReference().

◆ getOffsetOfLocalArea()

int llvm::TargetFrameLowering::getOffsetOfLocalArea ( ) const
inline

◆ getStackAlign()

Align llvm::TargetFrameLowering::getStackAlign ( ) const
inline

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.

Definition at line 105 of file TargetFrameLowering.h.

Referenced by llvm::PPCFrameLowering::addScavengingSpillSlot(), assignCalleeSavedSpillSlots(), llvm::HexagonFrameLowering::assignCalleeSavedSpillSlots(), llvm::SystemZXPLINKFrameLowering::assignCalleeSavedSpillSlots(), llvm::RISCVFrameLowering::assignCalleeSavedSpillSlots(), checkNumAlignedDPRCS2Regs(), computeFPBPAlignmentGap(), llvm::ARMFrameLowering::determineCalleeSaves(), llvm::PPCFrameLowering::determineFrameLayout(), llvm::AArch64FrameLowering::eliminateCallFramePseudoInstr(), llvm::MSP430FrameLowering::eliminateCallFramePseudoInstr(), llvm::XCoreFrameLowering::eliminateCallFramePseudoInstr(), llvm::SIFrameLowering::eliminateCallFramePseudoInstr(), llvm::Thumb1FrameLowering::eliminateCallFramePseudoInstr(), llvm::AVRFrameLowering::eliminateCallFramePseudoInstr(), llvm::RISCVFrameLowering::eliminateCallFramePseudoInstr(), llvm::X86FrameLowering::eliminateCallFramePseudoInstr(), llvm::RISCVFrameLowering::emitEpilogue(), llvm::ARMFrameLowering::emitPrologue(), llvm::RISCVFrameLowering::emitPrologue(), llvm::XCoreFrameLowering::emitPrologue(), llvm::MachineFrameInfo::estimateStackSize(), llvm::X86InstrInfo::foldMemoryOperandImpl(), llvm::VESubtarget::getAdjustedFrameSize(), llvm::LoongArchFrameLowering::getFirstSPAdjustAmount(), llvm::RISCVFrameLowering::getFirstSPAdjustAmount(), getFnStackAlignment(), llvm::SelectionDAG::getReducedAlign(), llvm::X86InstrInfo::getSPAdjust(), llvm::RISCVFrameLowering::getStackSizeWithRVVPadding(), llvm::X86FrameLowering::getWin64EHFrameIndexRef(), llvm::AArch64FrameLowering::getWinEHFuncletFrameSize(), llvm::MipsTargetLowering::HandleByVal(), llvm::X86InstrInfo::loadRegFromStackSlot(), llvm::XtensaTargetLowering::LowerCall(), llvm::VETargetLowering::lowerDYNAMIC_STACKALLOC(), LowerDYNAMIC_STACKALLOC(), llvm::SITargetLowering::lowerDYNAMIC_STACKALLOCImpl(), llvm::ARMBaseRegisterInfo::needsFrameBaseReg(), llvm::PPCRegisterInfo::prepareDynamicAlloca(), llvm::HexagonFrameLowering::processFunctionBeforeFrameFinalized(), llvm::HexagonDAGToDAGISel::SelectFrameIndex(), llvm::FunctionLoweringInfo::set(), and llvm::X86InstrInfo::storeRegToStackSlot().

◆ getStackAlignment()

unsigned llvm::TargetFrameLowering::getStackAlignment ( ) const
inline

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.

Definition at line 100 of file TargetFrameLowering.h.

References llvm::Align::value().

Referenced by llvm::M68kFrameLowering::eliminateCallFramePseudoInstr(), llvm::PPCTargetLowering::getStackProbeSize(), llvm::SystemZTargetLowering::getStackProbeSize(), llvm::MipsSEFrameLowering::hasReservedCallFrame(), and llvm::MipsCallLowering::lowerCall().

◆ getStackGrowthDirection()

StackDirection llvm::TargetFrameLowering::getStackGrowthDirection ( ) const
inline

getStackGrowthDirection - Return the direction the stack grows

Definition at line 94 of file TargetFrameLowering.h.

Referenced by llvm::TargetInstrInfo::getSPAdjust(), llvm::SITargetLowering::lowerDYNAMIC_STACKALLOCImpl(), and llvm::AArch64FrameLowering::processFunctionBeforeFrameFinalized().

◆ getStackIDForScalableVectors()

virtual TargetStackID::Value llvm::TargetFrameLowering::getStackIDForScalableVectors ( ) const
inlinevirtual

Returns the StackID that scalable vectors should be associated with.

Reimplemented in llvm::AArch64FrameLowering, and llvm::RISCVFrameLowering.

Definition at line 443 of file TargetFrameLowering.h.

References llvm::TargetStackID::Default.

Referenced by llvm::SelectionDAG::CreateStackTemporary(), getAddressForMemoryInput(), and llvm::FunctionLoweringInfo::set().

◆ getStackThreshold()

virtual uint64_t llvm::TargetFrameLowering::getStackThreshold ( ) const
inlinevirtual

getStackThreshold - Return the maximum stack size

Reimplemented in llvm::PPCFrameLowering.

Definition at line 109 of file TargetFrameLowering.h.

Referenced by llvm::PPCFrameLowering::getStackThreshold().

◆ getTransientStackAlign()

Align llvm::TargetFrameLowering::getTransientStackAlign ( ) const
inline

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 127 of file TargetFrameLowering.h.

Referenced by llvm::AArch64FunctionInfo::AArch64FunctionInfo(), llvm::MachineFrameInfo::estimateStackSize(), and mayCombineMisaligned().

◆ getWinEHParentFrameOffset()

virtual unsigned llvm::TargetFrameLowering::getWinEHParentFrameOffset ( const MachineFunction MF) const
inlinevirtual

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

Definition at line 388 of file TargetFrameLowering.h.

References llvm::report_fatal_error().

◆ hasFP()

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

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.

Implemented in llvm::DirectXFrameLowering, llvm::LanaiFrameLowering, llvm::AArch64FrameLowering, llvm::R600FrameLowering, llvm::SIFrameLowering, llvm::ARCFrameLowering, llvm::ARMFrameLowering, llvm::AVRFrameLowering, llvm::BPFFrameLowering, llvm::CSKYFrameLowering, llvm::HexagonFrameLowering, llvm::LoongArchFrameLowering, llvm::M68kFrameLowering, llvm::MipsFrameLowering, llvm::MSP430FrameLowering, llvm::NVPTXFrameLowering, llvm::PPCFrameLowering, llvm::RISCVFrameLowering, llvm::SparcFrameLowering, llvm::SPIRVFrameLowering, llvm::SystemZELFFrameLowering, llvm::SystemZXPLINKFrameLowering, llvm::VEFrameLowering, llvm::WebAssemblyFrameLowering, llvm::X86FrameLowering, llvm::XCoreFrameLowering, and llvm::XtensaFrameLowering.

Referenced by allocateScavengingFrameIndexesNearIncomingSP(), llvm::CodeViewDebug::beginFunctionImpl(), canSimplifyCallFramePseudos(), llvm::LanaiRegisterInfo::eliminateFrameIndex(), estimateRSStackSizeLimit(), llvm::AVRRegisterInfo::getFrameRegister(), llvm::CSKYRegisterInfo::getFrameRegister(), llvm::LoongArchRegisterInfo::getFrameRegister(), llvm::M68kRegisterInfo::getFrameRegister(), llvm::RISCVRegisterInfo::getFrameRegister(), llvm::SystemZRegisterInfo::getFrameRegister(), llvm::XtensaRegisterInfo::getFrameRegister(), llvm::X86TargetLowering::getRegisterByName(), llvm::MipsRegisterInfo::getRegPressureLimit(), llvm::MipsRegisterInfo::getReservedRegs(), llvm::SystemZRegisterInfo::getReservedRegs(), llvm::XtensaRegisterInfo::getReservedRegs(), hasReservedCallFrame(), and llvm::X86FrameLowering::spillFPBP().

◆ hasReservedCallFrame()

virtual bool llvm::TargetFrameLowering::hasReservedCallFrame ( const MachineFunction MF) const
inlinevirtual

◆ inlineStackProbe()

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

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

Reimplemented in llvm::PPCFrameLowering, llvm::SystemZELFFrameLowering, llvm::SystemZXPLINKFrameLowering, and llvm::X86FrameLowering.

Definition at line 239 of file TargetFrameLowering.h.

◆ isProfitableForNoCSROpt()

virtual bool llvm::TargetFrameLowering::isProfitableForNoCSROpt ( const Function F) const
inlinevirtual

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

Reimplemented in llvm::ARMFrameLowering.

Definition at line 462 of file TargetFrameLowering.h.

Referenced by determineCalleeSaves().

◆ isSafeForNoCSROpt()

bool TargetFrameLowering::isSafeForNoCSROpt ( const Function F)
static

Check if given function is safe for not having callee saved registers.

This is used when interprocedural register allocation is enabled.

Definition at line 157 of file TargetFrameLoweringImpl.cpp.

References F.

Referenced by determineCalleeSaves().

◆ isStackIdSafeForLocalArea()

virtual bool llvm::TargetFrameLowering::isStackIdSafeForLocalArea ( unsigned  StackId) const
inlinevirtual

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

Reimplemented in llvm::AArch64FrameLowering, and llvm::RISCVFrameLowering.

Definition at line 137 of file TargetFrameLowering.h.

◆ isStackRealignable()

bool llvm::TargetFrameLowering::isStackRealignable ( ) const
inline

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

Definition at line 131 of file TargetFrameLowering.h.

Referenced by llvm::FunctionLoweringInfo::set().

◆ isSupportedStackID()

virtual bool llvm::TargetFrameLowering::isSupportedStackID ( TargetStackID::Value  ID) const
inlinevirtual

◆ keepFramePointer()

virtual bool llvm::TargetFrameLowering::keepFramePointer ( const MachineFunction MF) const
inlinevirtual

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

Reimplemented in llvm::ARMFrameLowering.

Definition at line 282 of file TargetFrameLowering.h.

Referenced by llvm::TargetOptions::DisableFramePointerElim(), and llvm::TargetOptions::FramePointerIsReserved().

◆ needsFrameIndexResolution()

bool TargetFrameLowering::needsFrameIndexResolution ( const MachineFunction MF) const
virtual

◆ orderFrameObjects()

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

Order the symbols in the local stack frame.

The list of objects that we want to order is in 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.

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

Definition at line 414 of file TargetFrameLowering.h.

◆ processFunctionBeforeFrameFinalized()

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

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::AArch64FrameLowering, llvm::ARCFrameLowering, llvm::LoongArchFrameLowering, llvm::RISCVFrameLowering, llvm::SystemZELFFrameLowering, llvm::SystemZXPLINKFrameLowering, llvm::X86FrameLowering, llvm::XtensaFrameLowering, llvm::SIFrameLowering, llvm::ARMFrameLowering, llvm::HexagonFrameLowering, llvm::MSP430FrameLowering, llvm::PPCFrameLowering, and llvm::XCoreFrameLowering.

Definition at line 377 of file TargetFrameLowering.h.

Referenced by llvm::ARMFrameLowering::processFunctionBeforeFrameFinalized().

◆ processFunctionBeforeFrameIndicesReplaced()

virtual void llvm::TargetFrameLowering::processFunctionBeforeFrameIndicesReplaced ( MachineFunction MF,
RegScavenger RS = nullptr 
) const
inlinevirtual

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

This method is optional.

Reimplemented in llvm::AArch64FrameLowering, llvm::X86FrameLowering, and llvm::SIFrameLowering.

Definition at line 385 of file TargetFrameLowering.h.

◆ resetCFIToInitialState()

virtual void llvm::TargetFrameLowering::resetCFIToInitialState ( MachineBasicBlock MBB) const
inlinevirtual

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

Reimplemented in llvm::AArch64FrameLowering.

Definition at line 236 of file TargetFrameLowering.h.

Referenced by llvm::CFIFixup::runOnMachineFunction().

◆ restoreCalleeSavedRegisters()

virtual bool llvm::TargetFrameLowering::restoreCalleeSavedRegisters ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MI,
MutableArrayRef< CalleeSavedInfo CSI,
const TargetRegisterInfo TRI 
) const
inlinevirtual

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.

Reimplemented in llvm::SystemZELFFrameLowering, llvm::SystemZXPLINKFrameLowering, llvm::AArch64FrameLowering, llvm::ARCFrameLowering, llvm::ARMFrameLowering, llvm::Thumb1FrameLowering, llvm::AVRFrameLowering, llvm::CSKYFrameLowering, llvm::HexagonFrameLowering, llvm::M68kFrameLowering, llvm::Mips16FrameLowering, llvm::MSP430FrameLowering, llvm::PPCFrameLowering, llvm::RISCVFrameLowering, llvm::X86FrameLowering, llvm::XCoreFrameLowering, and llvm::XtensaFrameLowering.

Definition at line 273 of file TargetFrameLowering.h.

Referenced by insertCSRRestores(), and llvm::XtensaFrameLowering::restoreCalleeSavedRegisters().

◆ spillCalleeSavedRegisters()

virtual bool llvm::TargetFrameLowering::spillCalleeSavedRegisters ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MI,
ArrayRef< CalleeSavedInfo CSI,
const TargetRegisterInfo TRI 
) const
inlinevirtual

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::SystemZELFFrameLowering, llvm::SystemZXPLINKFrameLowering, llvm::AArch64FrameLowering, llvm::ARCFrameLowering, llvm::ARMFrameLowering, llvm::Thumb1FrameLowering, llvm::AVRFrameLowering, llvm::CSKYFrameLowering, llvm::HexagonFrameLowering, llvm::LoongArchFrameLowering, llvm::M68kFrameLowering, llvm::Mips16FrameLowering, llvm::MipsSEFrameLowering, llvm::MSP430FrameLowering, llvm::PPCFrameLowering, llvm::RISCVFrameLowering, llvm::X86FrameLowering, llvm::XCoreFrameLowering, and llvm::XtensaFrameLowering.

Definition at line 259 of file TargetFrameLowering.h.

Referenced by insertCSRSaves().

◆ spillFPBP()

virtual void llvm::TargetFrameLowering::spillFPBP ( MachineFunction MF) const
inlinevirtual

If frame pointer or base pointer is clobbered by an instruction, we should spill/restore it around that instruction.

Reimplemented in llvm::X86FrameLowering.

Definition at line 480 of file TargetFrameLowering.h.

◆ stackProbeFunctionModifiesSP()

virtual bool llvm::TargetFrameLowering::stackProbeFunctionModifiesSP ( ) const
inlinevirtual

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

Reimplemented in llvm::X86FrameLowering.

Definition at line 243 of file TargetFrameLowering.h.

◆ targetHandlesStackFrameRounding()

virtual bool llvm::TargetFrameLowering::targetHandlesStackFrameRounding ( ) const
inlinevirtual

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

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

Definition at line 193 of file TargetFrameLowering.h.


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