LLVM  6.0.0svn
Public Member Functions | Public Attributes | List of all members
llvm::X86FrameLowering Class Reference

#include "Target/X86/X86FrameLowering.h"

Inheritance diagram for llvm::X86FrameLowering:
Inheritance graph
[legend]
Collaboration diagram for llvm::X86FrameLowering:
Collaboration graph
[legend]

Public Member Functions

 X86FrameLowering (const X86Subtarget &STI, unsigned StackAlignOverride)
 
void emitStackProbe (MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, bool InProlog) const
 Emit target stack probe code. More...
 
void inlineStackProbe (MachineFunction &MF, MachineBasicBlock &PrologMBB) const override
 Replace a StackProbe inline-stub with the actual probe code inline. More...
 
void emitCalleeSavedFrameMoves (MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL) const
 
void emitPrologue (MachineFunction &MF, MachineBasicBlock &MBB) const override
 emitProlog/emitEpilog - These methods insert prolog and epilog code into the function. More...
 
void emitEpilogue (MachineFunction &MF, MachineBasicBlock &MBB) const override
 
void adjustForSegmentedStacks (MachineFunction &MF, MachineBasicBlock &PrologueMBB) const override
 Adjust the prologue to have the function use segmented stacks. More...
 
void adjustForHiPEPrologue (MachineFunction &MF, MachineBasicBlock &PrologueMBB) const override
 Erlang programs may need a special prologue to handle the stack size they might need at runtime. More...
 
void determineCalleeSaves (MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const override
 This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() should actually get saved. More...
 
bool assignCalleeSavedSpillSlots (MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const override
 assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic. More...
 
bool spillCalleeSavedRegisters (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const override
 spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns true if it isn't possible / profitable to do so by issuing a series of store instructions via storeRegToStackSlot(). More...
 
bool restoreCalleeSavedRegisters (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const override
 restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns true if it isn't possible / profitable to do so by issuing a series of load instructions via loadRegToStackSlot(). More...
 
bool hasFP (const MachineFunction &MF) const override
 hasFP - Return true if the specified function should have a dedicated frame pointer register. More...
 
bool hasReservedCallFrame (const MachineFunction &MF) const override
 hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required, we reserve argument space for call sites in the function immediately on entry to the current function. More...
 
bool canSimplifyCallFramePseudos (const MachineFunction &MF) const override
 canSimplifyCallFramePseudos - If there is a reserved call frame, the call frame pseudos can be simplified. More...
 
bool needsFrameIndexResolution (const MachineFunction &MF) const override
 
int getFrameIndexReference (const MachineFunction &MF, int FI, unsigned &FrameReg) const override
 getFrameIndexReference - This method should return the base register and offset used to reference a frame index location. More...
 
int getFrameIndexReferenceSP (const MachineFunction &MF, int FI, unsigned &SPReg, int Adjustment) const
 
int getFrameIndexReferencePreferSP (const MachineFunction &MF, int FI, unsigned &FrameReg, bool IgnoreSPUpdates) const override
 Same as getFrameIndexReference, except that the stack pointer (as opposed to the frame pointer) will be the preferred value for FrameReg. More...
 
MachineBasicBlock::iterator eliminateCallFramePseudoInstr (MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
 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). More...
 
unsigned getWinEHParentFrameOffset (const MachineFunction &MF) const override
 
void processFunctionBeforeFrameFinalized (MachineFunction &MF, RegScavenger *RS) const override
 processFunctionBeforeFrameFinalized - This method is called immediately before the specified function's frame layout (MF.getFrameInfo()) is finalized. More...
 
int mergeSPUpdates (MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, bool doMergeWithPrevious) const
 Check the instruction before/after the passed instruction. More...
 
void emitSPUpdate (MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, int64_t NumBytes, bool InEpilogue) const
 Emit a series of instructions to increment / decrement the stack pointer by a constant value. More...
 
bool canUseLEAForSPInEpilogue (const MachineFunction &MF) const
 Check that LEA can be used on SP in an epilogue sequence for MF. More...
 
bool canUseAsPrologue (const MachineBasicBlock &MBB) const override
 Check whether or not the given MBB can be used as a prologue for the target. More...
 
bool canUseAsEpilogue (const MachineBasicBlock &MBB) const override
 Check whether or not the given MBB can be used as a epilogue for the target. More...
 
bool enableShrinkWrapping (const MachineFunction &MF) const override
 Returns true if the target will correctly handle shrink wrapping. More...
 
void orderFrameObjects (const MachineFunction &MF, SmallVectorImpl< int > &ObjectsToAllocate) const override
 Order the symbols in the local stack. More...
 
void BuildCFI (MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, const MCCFIInstruction &CFIInst) const
 Wraps up getting a CFI index and building a MachineInstr for it. More...
 
MachineBasicBlock::iterator restoreWin32EHStackPointers (MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, bool RestoreSP=false) const
 Sets up EBP and optionally ESI based on the incoming EBP value. More...
 
- Public Member Functions inherited from llvm::TargetFrameLowering
 TargetFrameLowering (StackDirection D, unsigned StackAl, int LAO, unsigned TransAl=1, bool StackReal=true)
 
virtual ~TargetFrameLowering ()
 
StackDirection getStackGrowthDirection () const
 getStackGrowthDirection - Return the direction the stack grows More...
 
unsigned getStackAlignment () const
 getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligned on entry to a function. More...
 
int alignSPAdjust (int SPAdj) const
 alignSPAdjust - This method aligns the stack adjustment to the correct alignment. More...
 
unsigned getTransientStackAlignment () const
 getTransientStackAlignment - This method returns the number of bytes to which the stack pointer must be aligned at all times, even between calls. More...
 
bool isStackRealignable () const
 isStackRealignable - This method returns whether the stack can be realigned. More...
 
virtual unsigned getStackAlignmentSkew (const MachineFunction &MF) const
 Return the skew that has to be applied to stack alignment under certain conditions (e.g. More...
 
int getOffsetOfLocalArea () const
 getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on entrance to a function. More...
 
virtual bool isFPCloseToIncomingSP () const
 isFPCloseToIncomingSP - Return true if the frame pointer is close to the incoming stack pointer, false if it is close to the post-prologue stack pointer. More...
 
virtual const SpillSlotgetCalleeSavedSpillSlots (unsigned &NumEntries) const
 getCalleeSavedSpillSlots - This method returns a pointer to an array of pairs, that contains an entry for each callee saved register that must be spilled to a particular stack location if it is spilled. More...
 
virtual bool targetHandlesStackFrameRounding () const
 targetHandlesStackFrameRounding - Returns true if the target is responsible for rounding up the stack frame (probably at emitPrologue time). More...
 
virtual 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. More...
 
virtual bool noFramePointerElim (const MachineFunction &MF) const
 Return true if the target needs to disable frame pointer elimination. More...
 

Public Attributes

const X86SubtargetSTI
 
const X86InstrInfoTII
 
const X86RegisterInfoTRI
 
unsigned SlotSize
 
bool Is64Bit
 Is64Bit implies that x86_64 instructions are available. More...
 
bool IsLP64
 
bool Uses64BitFramePtr
 True if the 64-bit frame or stack pointer should be used. More...
 
unsigned StackPtr
 

Additional Inherited Members

- Public Types inherited from llvm::TargetFrameLowering
enum  StackDirection { StackGrowsUp, StackGrowsDown }
 
- Static Public Member Functions inherited from llvm::TargetFrameLowering
static bool isSafeForNoCSROpt (const Function *F)
 Check if given function is safe for not having callee saved registers. More...
 

Detailed Description

Definition at line 27 of file X86FrameLowering.h.

Constructor & Destructor Documentation

◆ X86FrameLowering()

X86FrameLowering::X86FrameLowering ( const X86Subtarget STI,
unsigned  StackAlignOverride 
)

Member Function Documentation

◆ adjustForHiPEPrologue()

void X86FrameLowering::adjustForHiPEPrologue ( MachineFunction MF,
MachineBasicBlock PrologueMBB 
) const
overridevirtual

Erlang programs may need a special prologue to handle the stack size they might need at runtime.

That is because Erlang/OTP does not implement a C stack but uses a custom implementation of hybrid stack/heap architecture. (for more information see Eric Stenman's Ph.D. thesis: http://publications.uu.se/uu/fulltext/nbn_se_uu_diva-2688.pdf)

CheckStack: temp0 = sp - MaxStack if( temp0 < SP_LIMIT(P) ) goto IncStack else goto OldStart OldStart: ... IncStack: call inc_stack # doubles the stack space temp0 = sp - MaxStack if( temp0 < SP_LIMIT(P) ) goto IncStack else goto OldStart

Reimplemented from llvm::TargetFrameLowering.

Definition at line 2417 of file X86FrameLowering.cpp.

References llvm::MachineBasicBlock::addLiveIn(), llvm::addRegOffset(), llvm::MachineBasicBlock::addSuccessor(), llvm::Function::arg_size(), assert(), llvm::MachineBasicBlock::begin(), llvm::MachineFunction::begin(), llvm::BuildMI(), llvm::MachineFunction::CreateMachineBasicBlock(), llvm::dyn_cast(), eliminateCallFramePseudoInstr(), llvm::N86::ESP, F(), llvm::StringRef::find(), llvm::StringRef::find_first_of(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getFunction(), llvm::MachineOperand::getGlobal(), getHiPELiteral(), llvm::MachineFunction::getMMI(), llvm::MachineModuleInfo::getModule(), llvm::Value::getName(), llvm::Module::getNamedMetadata(), llvm::MachineBasicBlock::getParent(), llvm::MachineFunction::getRegInfo(), GetScratchRegister(), llvm::MachineFrameInfo::getStackSize(), llvm::MachineFrameInfo::hasCalls(), Is64Bit, llvm::X86Subtarget::is64Bit(), llvm::MachineOperand::isGlobal(), llvm::MachineRegisterInfo::isLiveIn(), IsLP64, llvm::X86Subtarget::isTargetLinux(), llvm::MachineBasicBlock::liveins(), llvm::max(), MI, MRI, llvm::StringRef::npos, llvm::MachineFunction::push_front(), Regs, llvm::report_fatal_error(), SlotSize, STI, TII, TRI, and llvm::MachineFunction::verify().

◆ adjustForSegmentedStacks()

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

Adjust the prologue to have the function use segmented stacks.

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

Reimplemented from llvm::TargetFrameLowering.

Definition at line 2148 of file X86FrameLowering.cpp.

References llvm::MachineInstrBuilder::addExternalSymbol(), llvm::MachineInstrBuilder::addImm(), llvm::MachineBasicBlock::addLiveIn(), llvm::MachineInstrBuilder::addReg(), llvm::MachineBasicBlock::addSuccessor(), assert(), llvm::MachineFunction::begin(), llvm::BuildMI(), llvm::MachineFunction::CreateMachineBasicBlock(), llvm::N86::EAX, llvm::N86::ESP, llvm::X86MachineFunctionInfo::getArgumentStackSize(), llvm::TargetMachine::getCodeModel(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getFunction(), llvm::MachineFunction::getInfo(), llvm::MachineFunction::getMMI(), llvm::MachineFunction::getRegInfo(), GetScratchRegister(), llvm::MachineFrameInfo::getStackSize(), llvm::MachineFunction::getTarget(), HasNestArgument(), Is64Bit, llvm::MachineRegisterInfo::isLiveIn(), IsLP64, llvm::X86Subtarget::isTargetDarwin(), llvm::X86Subtarget::isTargetDragonFly(), llvm::X86Subtarget::isTargetFreeBSD(), llvm::X86Subtarget::isTargetLinux(), llvm::X86Subtarget::isTargetWin32(), llvm::X86Subtarget::isTargetWin64(), llvm::Function::isVarArg(), llvm::RegState::Kill, kSplitStackAvailable, llvm::CodeModel::Large, llvm::MachineBasicBlock::liveins(), llvm::MachineFunction::push_front(), llvm::report_fatal_error(), llvm::MachineModuleInfo::setUsesMorestackAddr(), STI, TII, and llvm::MachineFunction::verify().

◆ assignCalleeSavedSpillSlots()

bool X86FrameLowering::assignCalleeSavedSpillSlots ( MachineFunction MF,
const TargetRegisterInfo TRI,
std::vector< CalleeSavedInfo > &  CSI 
) const
overridevirtual

◆ BuildCFI()

void X86FrameLowering::BuildCFI ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MBBI,
const DebugLoc DL,
const MCCFIInstruction CFIInst 
) const

◆ canSimplifyCallFramePseudos()

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

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

Having a FP, as in the default implementation, is not sufficient here since we can't always use it. Use a more nuanced condition.

Reimplemented from llvm::TargetFrameLowering.

Definition at line 62 of file X86FrameLowering.cpp.

References llvm::X86RegisterInfo::hasBasePointer(), hasFP(), hasReservedCallFrame(), and TRI.

◆ canUseAsEpilogue()

bool X86FrameLowering::canUseAsEpilogue ( const MachineBasicBlock MBB) const
overridevirtual

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.

Reimplemented from llvm::TargetFrameLowering.

Definition at line 2747 of file X86FrameLowering.cpp.

References assert(), canUseLEAForSPInEpilogue(), flagsNeedToBePreservedBeforeTheTerminators(), llvm::MachineBasicBlock::getParent(), llvm::MachineBasicBlock::isReturnBlock(), llvm::X86Subtarget::isTargetWin64(), STI, and llvm::MachineBasicBlock::succ_empty().

◆ canUseAsPrologue()

bool X86FrameLowering::canUseAsPrologue ( const MachineBasicBlock MBB) const
overridevirtual

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 from llvm::TargetFrameLowering.

Definition at line 2741 of file X86FrameLowering.cpp.

References assert(), llvm::MachineBasicBlock::getParent(), llvm::MachineBasicBlock::isLiveIn(), and TRI.

◆ canUseLEAForSPInEpilogue()

bool X86FrameLowering::canUseLEAForSPInEpilogue ( const MachineFunction MF) const

Check that LEA can be used on SP in an epilogue sequence for MF.

Definition at line 1458 of file X86FrameLowering.cpp.

References llvm::TargetMachine::getMCAsmInfo(), llvm::MachineFunction::getTarget(), hasFP(), and llvm::MCAsmInfo::usesWindowsCFI().

Referenced by canUseAsEpilogue(), and emitSPUpdate().

◆ determineCalleeSaves()

void X86FrameLowering::determineCalleeSaves ( MachineFunction MF,
BitVector SavedRegs,
RegScavenger RS = nullptr 
) const
overridevirtual

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

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

Reimplemented from llvm::TargetFrameLowering.

Definition at line 2059 of file X86FrameLowering.cpp.

References llvm::MachineFrameInfo::CreateFixedObject(), llvm::MachineFrameInfo::CreateSpillStackObject(), llvm::TargetFrameLowering::determineCalleeSaves(), llvm::X86RegisterInfo::getBaseRegister(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getInfo(), llvm::X86MachineFunctionInfo::getTCReturnAddrDelta(), llvm::X86RegisterInfo::hasBasePointer(), llvm::MachineFunction::hasEHFunclets(), llvm::BitVector::set(), llvm::X86MachineFunctionInfo::setHasSEHFramePtrSave(), llvm::X86MachineFunctionInfo::setSEHFramePtrSaveIndex(), SlotSize, and TRI.

◆ eliminateCallFramePseudoInstr()

MachineBasicBlock::iterator X86FrameLowering::eliminateCallFramePseudoInstr ( MachineFunction MF,
MachineBasicBlock MBB,
MachineBasicBlock::iterator  MI 
) const
overridevirtual

◆ emitCalleeSavedFrameMoves()

void X86FrameLowering::emitCalleeSavedFrameMoves ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MBBI,
const DebugLoc DL 
) const

◆ emitEpilogue()

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

◆ emitPrologue()

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

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

emitPrologue - Push callee-saved registers onto the stack, which automatically adjust the stack pointer.

Adjust the stack pointer to allocate space for local variables. Also emit labels used by the exception handler to generate the exception handling frames.

Implements llvm::TargetFrameLowering.

Definition at line 932 of file X86FrameLowering.cpp.

References llvm::MachineInstrBuilder::addImm(), llvm::MachineBasicBlock::addLiveIn(), llvm::MachineInstrBuilder::addMemOperand(), llvm::MachineInstrBuilder::addReg(), llvm::addRegOffset(), llvm::MachineFrameInfo::adjustsStack(), llvm::alignTo(), llvm::Function::arg_size(), assert(), llvm::MachineBasicBlock::begin(), BuildCFI(), llvm::BuildMI(), calculateSetFPREG(), llvm::classifyEHPersonality(), contains(), llvm::CoreCLR, llvm::MCCFIInstruction::createDefCfaOffset(), llvm::MCCFIInstruction::createDefCfaRegister(), llvm::MCCFIInstruction::createOffset(), llvm::N86::EAX, llvm::N86::ECX, llvm::N86::EDX, llvm::WinEHFuncInfo::EHRegNodeFrameIndex, emitCalleeSavedFrameMoves(), emitSPUpdate(), emitStackProbe(), llvm::StringRef::empty(), llvm::MachineBasicBlock::end(), llvm::N86::ESP, FramePtr, llvm::MachineInstr::FrameSetup, llvm::StringRef::getAsInteger(), llvm::X86RegisterInfo::getBaseRegister(), llvm::X86MachineFunctionInfo::getCalleeSavedFrameSize(), llvm::Function::getCallingConv(), llvm::Module::getCodeViewFlag(), llvm::MachinePointerInfo::getFixedStack(), llvm::Function::getFnAttribute(), getFrameIndexReference(), llvm::MachineFunction::getFrameInfo(), llvm::X86RegisterInfo::getFrameRegister(), llvm::MachineFunction::getFunction(), llvm::X86MachineFunctionInfo::getHasSEHFramePtrSave(), llvm::MachineFunction::getInfo(), llvm::MachineFunction::getMachineMemOperand(), llvm::TargetMachine::getMCAsmInfo(), llvm::MachineFunction::getMMI(), llvm::MachineModuleInfo::getModule(), llvm::MachineFrameInfo::getOffsetAdjustment(), llvm::Function::getPersonalityFn(), llvm::MachineFunction::getRegInfo(), llvm::X86MachineFunctionInfo::getRestoreBasePointer(), llvm::X86MachineFunctionInfo::getRestoreBasePointerOffset(), llvm::X86MachineFunctionInfo::getSEHFramePtrSaveIndex(), llvm::X86TargetLowering::getStackProbeSymbolName(), llvm::MachineFrameInfo::getStackSize(), llvm::MachineFunction::getSubtarget(), llvm::MachineFunction::getTarget(), llvm::X86Subtarget::getTargetLowering(), llvm::X86MachineFunctionInfo::getTCReturnAddrDelta(), llvm::X86MachineFunctionInfo::getUsesRedZone(), llvm::Attribute::getValueAsString(), llvm::MachineFunction::getWinEHFuncInfo(), llvm::getX86SubSuperRegister(), llvm::X86RegisterInfo::hasBasePointer(), llvm::MachineFrameInfo::hasCopyImplyingStackAdjustment(), llvm::MachineModuleInfo::hasDebugInfo(), llvm::MachineFunction::hasEHFunclets(), llvm::Function::hasFnAttribute(), hasFP(), llvm::Function::hasPersonalityFn(), llvm::MachineFrameInfo::hasVarSizedObjects(), llvm::MachineBasicBlock::insert(), llvm::X86Subtarget::is32Bit(), Is64Bit, llvm::isAsynchronousEHPersonality(), llvm::X86Subtarget::isCallingConvWin64(), llvm::MachineBasicBlock::isCleanupFuncletEntry(), isEAXLiveIn(), llvm::MachineBasicBlock::isEHFuncletEntry(), llvm::isInt< 32 >(), llvm::MachineRegisterInfo::isReserved(), llvm::X86InstrInfo::isStoreToStackSlot(), llvm::X86Subtarget::isTarget64BitILP32(), llvm::X86Subtarget::isTargetWin32(), llvm::isUInt< 32 >(), llvm::RegState::Kill, llvm::max(), mergeSPUpdates(), MI, llvm::MachineMemOperand::MOLoad, llvm::MachineMemOperand::MOStore, llvm::MachineMemOperand::MOVolatile, llvm::MSVC_CXX, llvm::Function::needsUnwindTableEntry(), llvm::WinEHFuncInfo::PSPSymFrameIdx, llvm::report_fatal_error(), restoreWin32EHStackPointers(), llvm::WinEHFuncInfo::SEHSetFrameOffset, llvm::X86MachineFunctionInfo::setCalleeSavedFrameSize(), llvm::MachineInstr::setFlag(), llvm::MachineFunction::setHasWinCFI(), llvm::MachineInstrBuilder::setMIFlag(), llvm::MachineFrameInfo::setOffsetAdjustment(), llvm::MachineFrameInfo::setStackSize(), llvm::X86MachineFunctionInfo::setUsesRedZone(), llvm::MachineFunction::shouldSplitStack(), SlotSize, StackPtr, STI, TII, TRI, llvm::Unknown, Uses64BitFramePtr, llvm::MCAsmInfo::usesWindowsCFI(), and llvm::CallingConv::X86_INTR.

◆ emitSPUpdate()

void X86FrameLowering::emitSPUpdate ( MachineBasicBlock MBB,
MachineBasicBlock::iterator MBBI,
int64_t  NumBytes,
bool  InEpilogue 
) const

◆ emitStackProbe()

void X86FrameLowering::emitStackProbe ( MachineFunction MF,
MachineBasicBlock MBB,
MachineBasicBlock::iterator  MBBI,
const DebugLoc DL,
bool  InProlog 
) const

Emit target stack probe code.

This is required for all large stack allocations on Windows. The caller is required to materialize the number of bytes to probe in RAX/EAX.

Definition at line 481 of file X86FrameLowering.cpp.

References llvm::MachineFunction::getSubtarget(), llvm::X86Subtarget::isTargetWindowsCoreCLR(), and STI.

Referenced by emitPrologue().

◆ enableShrinkWrapping()

bool X86FrameLowering::enableShrinkWrapping ( const MachineFunction MF) const
overridevirtual

◆ getFrameIndexReference()

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

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 from llvm::TargetFrameLowering.

Definition at line 1673 of file X86FrameLowering.cpp.

References assert(), calculateSetFPREG(), llvm::X86RegisterInfo::getBaseRegister(), llvm::X86MachineFunctionInfo::getCalleeSavedFrameSize(), llvm::X86MachineFunctionInfo::getFAIndex(), llvm::MachineFunction::getFrameInfo(), llvm::X86RegisterInfo::getFramePtr(), llvm::X86RegisterInfo::getFrameRegister(), llvm::MachineFunction::getInfo(), llvm::TargetMachine::getMCAsmInfo(), llvm::MachineFrameInfo::getObjectAlignment(), llvm::MachineFrameInfo::getObjectOffset(), llvm::TargetFrameLowering::getOffsetOfLocalArea(), llvm::X86MachineFunctionInfo::getRestoreBasePointer(), llvm::X86RegisterInfo::getStackRegister(), llvm::MachineFrameInfo::getStackSize(), llvm::MachineFunction::getTarget(), llvm::X86MachineFunctionInfo::getTCReturnAddrDelta(), llvm::X86RegisterInfo::hasBasePointer(), llvm::MachineFrameInfo::hasCalls(), hasFP(), llvm::MachineFrameInfo::isFixedObjectIndex(), SlotSize, TRI, and llvm::MCAsmInfo::usesWindowsCFI().

Referenced by llvm::X86RegisterInfo::eliminateFrameIndex(), emitPrologue(), getFrameIndexReferencePreferSP(), and restoreWin32EHStackPointers().

◆ getFrameIndexReferencePreferSP()

int X86FrameLowering::getFrameIndexReferencePreferSP ( const MachineFunction MF,
int  FI,
unsigned FrameReg,
bool  IgnoreSPUpdates 
) const
overridevirtual

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 from llvm::TargetFrameLowering.

Definition at line 1767 of file X86FrameLowering.cpp.

References assert(), getFrameIndexReference(), getFrameIndexReferenceSP(), llvm::MachineFunction::getFrameInfo(), llvm::TargetSubtargetInfo::getFrameLowering(), llvm::MachineFunction::getInfo(), llvm::MachineFrameInfo::getStackSize(), llvm::MachineFunction::getSubtarget(), llvm::X86MachineFunctionInfo::getTCReturnAddrDelta(), llvm::TargetFrameLowering::hasReservedCallFrame(), llvm::MachineFrameInfo::isFixedObjectIndex(), llvm::X86Subtarget::isTargetWin64(), STI, and TRI.

Referenced by isFuncletReturnInstr().

◆ getFrameIndexReferenceSP()

int X86FrameLowering::getFrameIndexReferenceSP ( const MachineFunction MF,
int  FI,
unsigned SPReg,
int  Adjustment 
) const

◆ getWinEHParentFrameOffset()

unsigned X86FrameLowering::getWinEHParentFrameOffset ( const MachineFunction MF) const
overridevirtual

Reimplemented from llvm::TargetFrameLowering.

Definition at line 2986 of file X86FrameLowering.cpp.

References llvm::MachineFunction::getInfo(), and SlotSize.

◆ hasFP()

bool X86FrameLowering::hasFP ( const MachineFunction MF) const
overridevirtual

◆ hasReservedCallFrame()

bool X86FrameLowering::hasReservedCallFrame ( const MachineFunction MF) const
overridevirtual

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

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

Reimplemented from llvm::TargetFrameLowering.

Definition at line 52 of file X86FrameLowering.cpp.

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

Referenced by canSimplifyCallFramePseudos(), and eliminateCallFramePseudoInstr().

◆ inlineStackProbe()

void X86FrameLowering::inlineStackProbe ( MachineFunction MF,
MachineBasicBlock PrologMBB 
) const
overridevirtual

Replace a StackProbe inline-stub with the actual probe code inline.

Reimplemented from llvm::TargetFrameLowering.

Definition at line 497 of file X86FrameLowering.cpp.

References llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addMBB(), llvm::MachineInstrBuilder::addReg(), llvm::addRegOffset(), llvm::MachineBasicBlock::addSuccessor(), assert(), llvm::MachineBasicBlock::begin(), llvm::BuildMI(), llvm::MachineFunction::createExternalSymbolName(), llvm::MachineFunction::CreateMachineBasicBlock(), llvm::MachineRegisterInfo::createVirtualRegister(), llvm::RegState::Define, llvm::N86::EAX, llvm::MachineBasicBlock::end(), llvm::MachineInstr::eraseFromParent(), llvm::N86::ESP, llvm::MachineInstr::FrameSetup, llvm::DebugLoc::get(), llvm::MachineBasicBlock::getBasicBlock(), llvm::X86MachineFunctionInfo::getCalleeSavedFrameSize(), llvm::TargetMachine::getCodeModel(), llvm::MachineBasicBlock::getFirstNonPHI(), llvm::MachineFunction::getInfo(), llvm::X86Subtarget::getInstrInfo(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::MachineFunction::getRegInfo(), llvm::X86TargetLowering::getStackProbeSymbolName(), getSUBrrOpcode(), llvm::MachineFunction::getSubtarget(), llvm::MachineFunction::getTarget(), llvm::X86Subtarget::getTargetLowering(), hasFP(), llvm::RegState::Implicit, llvm::MachineFunction::insert(), Is64Bit, llvm::X86Subtarget::is64Bit(), llvm::MachineInstr::isBundled(), llvm::X86Subtarget::isOSWindows(), llvm::X86Subtarget::isTargetWin64(), llvm::X86Subtarget::isTargetWindowsCoreCLR(), llvm::CodeModel::Large, MI, MRI, PageSize, llvm::MachineBasicBlock::splice(), STI, llvm::ARMBuildAttrs::Symbol, TII, llvm::MachineBasicBlock::transferSuccessorsAndUpdatePHIs(), and llvm::RegState::Undef.

◆ mergeSPUpdates()

int X86FrameLowering::mergeSPUpdates ( MachineBasicBlock MBB,
MachineBasicBlock::iterator MBBI,
bool  doMergeWithPrevious 
) const

Check the instruction before/after the passed instruction.

If it is an ADD/SUB/LEA instruction it is deleted argument and the stack adjustment is returned as a positive value for ADD/LEA and a negative for SUB.

Definition at line 395 of file X86FrameLowering.cpp.

References assert(), llvm::MachineBasicBlock::begin(), llvm::MachineBasicBlock::end(), llvm::MachineBasicBlock::erase(), llvm::skipDebugInstructionsBackward(), llvm::skipDebugInstructionsForward(), and StackPtr.

Referenced by eliminateCallFramePseudoInstr(), emitEpilogue(), and emitPrologue().

◆ needsFrameIndexResolution()

bool X86FrameLowering::needsFrameIndexResolution ( const MachineFunction MF) const
overridevirtual

◆ orderFrameObjects()

void X86FrameLowering::orderFrameObjects ( const MachineFunction MF,
SmallVectorImpl< int > &  ObjectsToAllocate 
) const
overridevirtual

Order the symbols in the local stack.

We want to place the local stack objects in some sort of sensible order. The heuristic we use is to try and pack them according to static number of uses and size in order to minimize code size.

Reimplemented from llvm::TargetFrameLowering.

Definition at line 2913 of file X86FrameLowering.cpp.

References llvm::SmallVectorBase::empty(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFrameInfo::getObjectAlignment(), llvm::MachineFrameInfo::getObjectIndexEnd(), llvm::MachineFrameInfo::getObjectSize(), hasFP(), MI, llvm::reverse(), and TRI.

◆ processFunctionBeforeFrameFinalized()

void X86FrameLowering::processFunctionBeforeFrameFinalized ( MachineFunction MF,
RegScavenger RS 
) const
overridevirtual

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 from llvm::TargetFrameLowering.

Definition at line 2998 of file X86FrameLowering.cpp.

References llvm::abs(), llvm::addFrameReference(), llvm::MachineInstrBuilder::addImm(), llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Align, llvm::MachineBasicBlock::begin(), llvm::BuildMI(), llvm::WinEHHandlerType::CatchObj, llvm::classifyEHPersonality(), llvm::MachineFrameInfo::CreateFixedObject(), llvm::MachineBasicBlock::end(), llvm::MachineBasicBlock::findDebugLoc(), llvm::ISD::FrameIndex, llvm::WinEHHandlerType::FrameIndex, llvm::MachineInstr::FrameSetup, llvm::MachineFunction::front(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getFunction(), llvm::MachineFrameInfo::getObjectAlignment(), llvm::MachineFrameInfo::getObjectIndexBegin(), llvm::MachineFrameInfo::getObjectOffset(), llvm::MachineFrameInfo::getObjectSize(), llvm::Function::getPersonalityFn(), llvm::MachineFunction::getWinEHFuncInfo(), H, llvm::WinEHTryBlockMapEntry::HandlerArray, llvm::MachineFunction::hasEHFunclets(), I, llvm::X86Subtarget::is64Bit(), llvm::MSVC_CXX, llvm::MachineFunction::setHasWinCFI(), llvm::MachineFrameInfo::setObjectOffset(), SlotSize, STI, TII, llvm::WinEHFuncInfo::TryBlockMap, and llvm::WinEHFuncInfo::UnwindHelpFrameIdx.

◆ restoreCalleeSavedRegisters()

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

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

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 from llvm::TargetFrameLowering.

Definition at line 2009 of file X86FrameLowering.cpp.

References llvm::BuildMI(), llvm::ISD::CATCHRET, llvm::classifyEHPersonality(), contains(), llvm::MachineBasicBlock::end(), llvm::MachineBasicBlock::findDebugLoc(), llvm::MachineInstr::FrameDestroy, llvm::MachineFunction::getFunction(), llvm::TargetRegisterInfo::getMinimalPhysRegClass(), llvm::MachineBasicBlock::getParent(), llvm::Function::getPersonalityFn(), llvm::X86Subtarget::is32Bit(), llvm::X86Subtarget::is64Bit(), llvm::isAsynchronousEHPersonality(), isFuncletReturnInstr(), llvm::X86Subtarget::isOSWindows(), llvm::X86InstrInfo::loadRegFromStackSlot(), STI, and TII.

◆ restoreWin32EHStackPointers()

MachineBasicBlock::iterator X86FrameLowering::restoreWin32EHStackPointers ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MBBI,
const DebugLoc DL,
bool  RestoreSP = false 
) const

◆ spillCalleeSavedRegisters()

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

Member Data Documentation

◆ Is64Bit

bool llvm::X86FrameLowering::Is64Bit

Is64Bit implies that x86_64 instructions are available.

Definition at line 40 of file X86FrameLowering.h.

Referenced by adjustForHiPEPrologue(), adjustForSegmentedStacks(), emitEpilogue(), emitPrologue(), emitSPUpdate(), inlineStackProbe(), and X86FrameLowering().

◆ IsLP64

bool llvm::X86FrameLowering::IsLP64

◆ SlotSize

unsigned llvm::X86FrameLowering::SlotSize

◆ StackPtr

unsigned llvm::X86FrameLowering::StackPtr

◆ STI

const X86Subtarget& llvm::X86FrameLowering::STI

◆ TII

const X86InstrInfo& llvm::X86FrameLowering::TII

◆ TRI

const X86RegisterInfo* llvm::X86FrameLowering::TRI

◆ Uses64BitFramePtr

bool llvm::X86FrameLowering::Uses64BitFramePtr

True if the 64-bit frame or stack pointer should be used.

True for most 64-bit targets with the exception of x32. If this is false, 32-bit instruction operands should be used to manipulate StackPtr and FramePtr.

Definition at line 47 of file X86FrameLowering.h.

Referenced by calculateSetFPREG(), emitEpilogue(), emitPrologue(), emitSPUpdate(), llvm::X86RegisterInfo::getPointerRegClass(), restoreWin32EHStackPointers(), and X86FrameLowering().


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