LLVM  8.0.1
Public Member Functions | List of all members
llvm::HexagonFrameLowering Class Reference

#include "Target/Hexagon/HexagonFrameLowering.h"

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

Public Member Functions

 HexagonFrameLowering ()
 
void emitPrologue (MachineFunction &MF, MachineBasicBlock &MBB) const override
 Perform most of the PEI work here: More...
 
void emitEpilogue (MachineFunction &MF, MachineBasicBlock &MBB) const override
 
bool enableCalleeSaveSkip (const MachineFunction &MF) const override
 Returns true if the target can safely skip saving callee-saved registers for noreturn nounwind functions. 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 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 - When possible, it's best to simplify the call frame pseudo ops before doing frame index elimination. More...
 
MachineBasicBlock::iterator eliminateCallFramePseudoInstr (MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) 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...
 
void processFunctionBeforeFrameFinalized (MachineFunction &MF, RegScavenger *RS=nullptr) const override
 processFunctionBeforeFrameFinalized - This method is called immediately before the specified function's frame layout (MF.getFrameInfo()) is finalized. More...
 
void determineCalleeSaves (MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const override
 This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() should actually get saved. More...
 
bool targetHandlesStackFrameRounding () const override
 targetHandlesStackFrameRounding - Returns true if the target is responsible for rounding up the stack frame (probably at emitPrologue time). More...
 
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...
 
bool hasFP (const MachineFunction &MF) const override
 hasFP - Return true if the specified function should have a dedicated frame pointer register. More...
 
const SpillSlotgetCalleeSavedSpillSlots (unsigned &NumEntries) const override
 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...
 
bool assignCalleeSavedSpillSlots (MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const override
 assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic. More...
 
bool needsAligna (const MachineFunction &MF) const
 
const MachineInstrgetAlignaInstr (const MachineFunction &MF) const
 
void insertCFIInstructions (MachineFunction &MF) const
 
- 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 bool enableShrinkWrapping (const MachineFunction &MF) const
 Returns true if the target will correctly handle shrink wrapping. 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 void inlineStackProbe (MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
 Replace a StackProbe stub (if any) with the actual probe code inline. More...
 
virtual void adjustForSegmentedStacks (MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
 Adjust the prologue to have the function use segmented stacks. More...
 
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. More...
 
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". More...
 
virtual bool needsFrameIndexResolution (const MachineFunction &MF) const
 
virtual int getFrameIndexReferencePreferSP (const MachineFunction &MF, int FI, unsigned &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. More...
 
virtual unsigned getWinEHParentFrameOffset (const MachineFunction &MF) const
 
virtual void orderFrameObjects (const MachineFunction &MF, SmallVectorImpl< int > &objectsToAllocate) const
 Order the symbols in the local stack frame. More...
 
virtual bool canUseAsPrologue (const MachineBasicBlock &MBB) const
 Check whether or not the given MBB can be used as a prologue for the target. More...
 
virtual bool canUseAsEpilogue (const MachineBasicBlock &MBB) const
 Check whether or not the given MBB can be used as a epilogue for the target. More...
 
virtual int getInitialCFAOffset (const MachineFunction &MF) const
 Return initial CFA offset value i.e. More...
 
virtual unsigned getInitialCFARegister (const MachineFunction &MF) const
 Return initial CFA register value i.e. More...
 

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 31 of file HexagonFrameLowering.h.

Constructor & Destructor Documentation

◆ HexagonFrameLowering()

llvm::HexagonFrameLowering::HexagonFrameLowering ( )
inlineexplicit

Definition at line 33 of file HexagonFrameLowering.h.

References emitPrologue().

Member Function Documentation

◆ assignCalleeSavedSpillSlots()

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

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

Definition at line 1428 of file HexagonFrameLowering.cpp.

References llvm::ARM_AM::add, llvm::MachineInstrBuilder::addImm(), llvm::LivePhysRegs::addLiveIns(), llvm::MachineInstrBuilder::addReg(), llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Align, assert(), B, llvm::MachineBasicBlock::begin(), llvm::BuildMI(), llvm::SmallVectorImpl< T >::clear(), llvm::MachineInstrBuilder::cloneMemRefs(), llvm::LivePhysRegs::contains(), contains(), llvm::MachineRegisterInfo::createVirtualRegister(), llvm::dbgs(), dump_registers(), E, llvm::MachineBasicBlock::end(), llvm::MachineBasicBlock::erase(), llvm::BitVector::find_first(), llvm::BitVector::find_next(), llvm::MachineInstr::getDebugLoc(), llvm::MachineFunction::getFrameInfo(), llvm::MachineOperand::getIndex(), llvm::getKillRegState(), llvm::TargetRegisterInfo::getMinimalPhysRegClass(), llvm::MachineFunction::getName(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineBasicBlock::getParent(), llvm::MachineOperand::getReg(), getReg(), llvm::MachineFunction::getRegInfo(), llvm::TargetRegisterInfo::getReservedRegs(), llvm::TargetRegisterInfo::getSpillAlignment(), llvm::TargetRegisterInfo::getSpillSize(), llvm::MachineFunction::getSubtarget(), I, llvm::MachineOperand::isFI(), llvm::MachineOperand::isKill(), llvm::isPowerOf2_32(), llvm::MCRegisterInfo::DiffListIterator::isValid(), llvm::RegState::Kill, LLVM_DEBUG, llvm_unreachable, llvm::HexagonInstrInfo::loadRegFromStackSlot(), MI, llvm::MinAlign(), MRI, llvm::printReg(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), Size, llvm::LivePhysRegs::stepForward(), and llvm::HexagonInstrInfo::storeRegToStackSlot().

Referenced by getCalleeSavedSpillSlots().

◆ canSimplifyCallFramePseudos()

bool llvm::HexagonFrameLowering::canSimplifyCallFramePseudos ( const MachineFunction MF) const
inlineoverridevirtual

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

Definition at line 63 of file HexagonFrameLowering.h.

References determineCalleeSaves(), eliminateCallFramePseudoInstr(), I, and processFunctionBeforeFrameFinalized().

◆ determineCalleeSaves()

void HexagonFrameLowering::determineCalleeSaves ( MachineFunction MF,
BitVector SavedRegs,
RegScavenger RS 
) 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 1930 of file HexagonFrameLowering.cpp.

References llvm::ARM_AM::add, llvm::HexagonBlockRanges::RangeList::add(), llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), llvm::RegScavenger::addScavengingFrameIndex(), assert(), B, llvm::HexagonII::BaseImmOffset, llvm::BuildMI(), llvm::HexagonBlockRanges::computeDeadMap(), llvm::HexagonBlockRanges::computeLiveMap(), llvm::SmallSet< T, N, C >::count(), llvm::MachineFrameInfo::CreateSpillStackObject(), llvm::dbgs(), llvm::RegState::Dead, llvm::TargetFrameLowering::determineCalleeSaves(), llvm::SmallVectorBase::empty(), llvm::HexagonBlockRanges::expandToSubRegs(), F(), llvm::HexagonRegisterInfo::getCalleeSavedRegs(), llvm::MachineInstr::getDebugLoc(), llvm::MachineInstr::getDesc(), llvm::MachineFunction::getFrameInfo(), llvm::MachineOperand::getImm(), llvm::HexagonBlockRanges::InstrIndexMap::getIndex(), llvm::MachineOperand::getIndex(), llvm::MachineFunction::getInfo(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::getKillRegState(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::getParent(), llvm::TargetRegisterClass::getRawAllocationOrder(), llvm::MachineOperand::getReg(), llvm::MachineRegisterInfo::getRegClass(), llvm::MachineFunction::getRegInfo(), llvm::MachineOperand::getSubReg(), llvm::MachineFunction::getSubtarget(), llvm::HexagonMachineFunctionInfo::hasEHReturn(), llvm::TargetRegisterClass::hasSubClassEq(), I, llvm::tgtok::In, llvm::SetVector< T, Vector, Set >::insert(), llvm::SmallSet< T, N, C >::insert(), IR, llvm::MachineOperand::isFI(), isOptNone(), LLVM_DEBUG, llvm::SPII::Load, llvm::AArch64CC::LS, llvm::MachineInstr::mayLoad(), llvm::MachineInstr::mayStore(), MI, MRI, needToReserveScavengingSpillSlots(), llvm::None, NumberScavengerSlots, OptimizeSpillSlots, P, llvm::printMBBReference(), llvm::printReg(), llvm::HexagonBlockRanges::RegisterRef::Reg, Reg, llvm::BitVector::resize(), llvm::BitVector::set(), SI, Size, SpillOptMax, llvm::HexagonBlockRanges::IndexRange::start(), llvm::SPII::Store, and llvm::HexagonBlockRanges::RegisterRef::Sub.

Referenced by canSimplifyCallFramePseudos().

◆ eliminateCallFramePseudoInstr()

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

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

Definition at line 1343 of file HexagonFrameLowering.cpp.

References assert(), llvm::MachineBasicBlock::erase(), llvm::MachineInstr::getOpcode(), I, and MI.

Referenced by canSimplifyCallFramePseudos().

◆ emitEpilogue()

void llvm::HexagonFrameLowering::emitEpilogue ( MachineFunction MF,
MachineBasicBlock MBB 
) const
inlineoverridevirtual

Implements llvm::TargetFrameLowering.

Definition at line 41 of file HexagonFrameLowering.h.

References enableCalleeSaveSkip().

◆ emitPrologue()

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

Perform most of the PEI work here:

  • saving/restoring of the callee-saved registers,
  • stack frame creation and destruction. Normally, this work is distributed among various functions, but doing it in one place allows shrink-wrapping of the stack frame.

Implements llvm::TargetFrameLowering.

Definition at line 504 of file HexagonFrameLowering.cpp.

References llvm::MachineInstr::addOperand(), B, llvm::MachineOperand::CreateReg(), EnableShrinkWrapping, llvm::MachineFunction::front(), llvm::MachineFrameInfo::getCalleeSavedInfo(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getNumBlockIDs(), llvm::MachineInstr::getOpcode(), getReturn(), llvm::MachineFunction::getSubtarget(), and isRestoreCall().

Referenced by HexagonFrameLowering().

◆ enableCalleeSaveSkip()

bool HexagonFrameLowering::enableCalleeSaveSkip ( const MachineFunction MF) const
overridevirtual

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

Reimplemented from llvm::TargetFrameLowering.

Definition at line 555 of file HexagonFrameLowering.cpp.

References assert(), F(), llvm::MachineFunction::getFunction(), llvm::MachineFunction::getSubtarget(), llvm::Attribute::NoReturn, llvm::Attribute::NoUnwind, and llvm::Attribute::UWTable.

Referenced by emitEpilogue().

◆ getAlignaInstr()

const MachineInstr * HexagonFrameLowering::getAlignaInstr ( const MachineFunction MF) const

◆ getCalleeSavedSpillSlots()

const SpillSlot* llvm::HexagonFrameLowering::getCalleeSavedSpillSlots ( unsigned NumEntries) const
inlineoverridevirtual

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

Definition at line 85 of file HexagonFrameLowering.h.

References llvm::array_lengthof(), assignCalleeSavedSpillSlots(), B, getAlignaInstr(), insertCFIInstructions(), MI, MRI, needsAligna(), TII, and TRI.

◆ getFrameIndexReference()

int HexagonFrameLowering::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 1111 of file HexagonFrameLowering.cpp.

References llvm::MachineBasicBlock::addLiveIn(), assert(), llvm::MachineBasicBlock::begin(), llvm::BuildMI(), llvm::MachineInstr::copyImplicitOps(), EnableSaveRestoreLong, EnableStackOVFSanitizer, llvm::MachineBasicBlock::end(), llvm::MachineBasicBlock::findDebugLoc(), llvm::MachineBasicBlock::getFirstTerminator(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getInfo(), llvm::HexagonSubtarget::getInstrInfo(), getMaxCalleeSavedReg(), llvm::TargetMachine::getOptLevel(), llvm::MachineBasicBlock::getParent(), getSpillFunctionFor(), llvm::MachineFunction::getSubtarget(), llvm::MachineFunction::getTarget(), hasReturn(), hasTailCall(), I, llvm::HexagonRegisterInfo::isEHReturnCalleeSaveReg(), llvm::TargetMachine::isPositionIndependent(), Kind, MI, llvm::CodeGenOpt::None, Reg, SK_FromMem, SK_FromMemTailcall, and SK_ToMem.

Referenced by targetHandlesStackFrameRounding().

◆ hasFP()

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

◆ hasReservedCallFrame()

bool llvm::HexagonFrameLowering::hasReservedCallFrame ( const MachineFunction MF) const
inlineoverridevirtual

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 58 of file HexagonFrameLowering.h.

◆ insertCFIInstructions()

void HexagonFrameLowering::insertCFIInstructions ( MachineFunction MF) const

◆ needsAligna()

bool HexagonFrameLowering::needsAligna ( const MachineFunction MF) const

◆ processFunctionBeforeFrameFinalized()

void HexagonFrameLowering::processFunctionBeforeFrameFinalized ( MachineFunction MF,
RegScavenger RS = nullptr 
) const
overridevirtual

◆ restoreCalleeSavedRegisters()

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

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 52 of file HexagonFrameLowering.h.

◆ spillCalleeSavedRegisters()

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

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

Definition at line 46 of file HexagonFrameLowering.h.

◆ targetHandlesStackFrameRounding()

bool llvm::HexagonFrameLowering::targetHandlesStackFrameRounding ( ) const
inlineoverridevirtual

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

Reimplemented from llvm::TargetFrameLowering.

Definition at line 77 of file HexagonFrameLowering.h.

References getFrameIndexReference(), and hasFP().


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