LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
llvm::X86FrameLowering Class Reference

#include <X86FrameLowering.h>

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

Public Member Functions

 X86FrameLowering (const X86TargetMachine &tm, const X86Subtarget &sti)
 
void emitCalleeSavedFrameMoves (MachineFunction &MF, MCSymbol *Label, unsigned FramePtr) const
 
void emitPrologue (MachineFunction &MF) const
 
void emitEpilogue (MachineFunction &MF, MachineBasicBlock &MBB) const
 
void adjustForSegmentedStacks (MachineFunction &MF) const
 
void adjustForHiPEPrologue (MachineFunction &MF) const
 
void processFunctionBeforeCalleeSavedScan (MachineFunction &MF, RegScavenger *RS=NULL) const
 
bool spillCalleeSavedRegisters (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const
 
bool restoreCalleeSavedRegisters (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const
 
bool hasFP (const MachineFunction &MF) const
 
bool hasReservedCallFrame (const MachineFunction &MF) const
 
int getFrameIndexOffset (const MachineFunction &MF, int FI) const
 
int getFrameIndexReference (const MachineFunction &MF, int FI, unsigned &FrameReg) const
 
void eliminateCallFramePseudoInstr (MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) 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
 
unsigned getStackAlignment () const
 
unsigned getTransientStackAlignment () const
 
bool isStackRealignable () const
 
int getOffsetOfLocalArea () const
 
virtual bool isFPCloseToIncomingSP () const
 
virtual const SpillSlotgetCalleeSavedSpillSlots (unsigned &NumEntries) const
 
virtual bool targetHandlesStackFrameRounding () const
 
virtual bool canSimplifyCallFramePseudos (const MachineFunction &MF) const
 
virtual void processFunctionBeforeFrameFinalized (MachineFunction &MF, RegScavenger *RS=NULL) const
 

Additional Inherited Members

- Public Types inherited from llvm::TargetFrameLowering
enum  StackDirection { StackGrowsUp, StackGrowsDown }
 

Detailed Description

Definition at line 26 of file X86FrameLowering.h.

Constructor & Destructor Documentation

llvm::X86FrameLowering::X86FrameLowering ( const X86TargetMachine tm,
const X86Subtarget sti 
)
inlineexplicit

Definition at line 30 of file X86FrameLowering.h.

Member Function Documentation

void X86FrameLowering::adjustForHiPEPrologue ( MachineFunction MF) const
virtual

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 1352 of file X86FrameLowering.cpp.

References llvm::MachineBasicBlock::addLiveIn(), llvm::addRegOffset(), llvm::MachineBasicBlock::addSuccessor(), llvm::Function::arg_size(), llvm::MachineFunction::begin(), llvm::BuildMI(), llvm::MachineFunction::CreateMachineBasicBlock(), llvm::dyn_cast(), llvm::N86::EBP, llvm::MachineFunction::end(), llvm::N86::ESP, F(), llvm::StringRef::find(), llvm::StringRef::find_first_of(), llvm::MachineFunction::front(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getFunction(), llvm::MachineOperand::getGlobal(), llvm::X86TargetMachine::getInstrInfo(), llvm::Value::getName(), llvm::MachineFunction::getRegInfo(), llvm::X86TargetMachine::getRegisterInfo(), GetScratchRegister(), llvm::X86RegisterInfo::getSlotSize(), llvm::MachineFrameInfo::getStackSize(), llvm::MachineFrameInfo::hasCalls(), I, llvm::X86Subtarget::is64Bit(), llvm::MachineOperand::isGlobal(), llvm::MachineRegisterInfo::isLiveIn(), llvm::X86Subtarget::isTargetLinux(), llvm::MachineBasicBlock::livein_begin(), llvm::MachineBasicBlock::livein_end(), llvm::A64CC::MI, llvm::StringRef::npos, llvm::MachineFunction::push_front(), TII, and llvm::MachineFunction::verify().

void X86FrameLowering::adjustForSegmentedStacks ( MachineFunction MF) const
virtual
void X86FrameLowering::eliminateCallFramePseudoInstr ( MachineFunction MF,
MachineBasicBlock MBB,
MachineBasicBlock::iterator  MI 
) const
virtual

eliminateCallFramePseudoInstr - 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.

Reimplemented from llvm::TargetFrameLowering.

Definition at line 1482 of file X86FrameLowering.cpp.

References llvm::MachineInstrBuilder::addImm(), llvm::MachineBasicBlock::begin(), llvm::BuildMI(), llvm::MachineBasicBlock::erase(), getADDriOpcode(), llvm::X86TargetMachine::getFrameLowering(), llvm::X86TargetMachine::getInstrInfo(), llvm::MachineInstr::getOperand(), llvm::X86TargetMachine::getRegisterInfo(), llvm::TargetFrameLowering::getStackAlignment(), llvm::X86RegisterInfo::getStackRegister(), getSUBriOpcode(), hasReservedCallFrame(), I, llvm::MachineBasicBlock::insert(), llvm::X86Subtarget::isTarget64BitLP64(), llvm::prior(), llvm::MachineOperand::setIsDead(), and TII.

void X86FrameLowering::emitCalleeSavedFrameMoves ( MachineFunction MF,
MCSymbol Label,
unsigned  FramePtr 
) const
void X86FrameLowering::emitEpilogue ( MachineFunction MF,
MachineBasicBlock MBB 
) const
virtual

Implements llvm::TargetFrameLowering.

Definition at line 712 of file X86FrameLowering.cpp.

References llvm::MachineInstrBuilder::addExternalSymbol(), llvm::MachineInstrBuilder::addGlobalAddress(), llvm::MachineInstrBuilder::addOperand(), llvm::addRegOffset(), llvm::MachineBasicBlock::begin(), llvm::BuildMI(), llvm::MachineInstr::copyImplicitOps(), llvm::TargetOpcode::DBG_VALUE, llvm::ISD::EH_RETURN, llvm::emitSPUpdate(), llvm::MachineBasicBlock::end(), llvm::MachineBasicBlock::erase(), ForceStackAlign, llvm::X86MachineFunctionInfo::getCalleeSavedFrameSize(), llvm::MachineFunction::getFrameInfo(), llvm::MachineOperand::getGlobal(), llvm::MachineOperand::getImm(), llvm::MachineFunction::getInfo(), llvm::X86TargetMachine::getInstrInfo(), llvm::MachineBasicBlock::getLastNonDebugInstr(), getLEArOpcode(), llvm::MachineFrameInfo::getMaxAlignment(), llvm::MachineOperand::getOffset(), llvm::MachineOperand::getReg(), llvm::X86TargetMachine::getRegisterInfo(), llvm::TargetFrameLowering::getStackAlignment(), llvm::MachineFrameInfo::getStackSize(), llvm::MachineOperand::getSymbolName(), llvm::MachineOperand::getTargetFlags(), llvm::X86MachineFunctionInfo::getTCReturnAddrDelta(), llvm::MachineFrameInfo::hasCalls(), hasFP(), llvm::MachineFrameInfo::hasVarSizedObjects(), llvm::X86Subtarget::is64Bit(), llvm::MachineOperand::isGlobal(), llvm::MachineOperand::isImm(), llvm::isMem(), llvm::MachineOperand::isReg(), llvm::MachineOperand::isSymbol(), llvm::X86Subtarget::isTarget64BitLP64(), llvm::RegState::Kill, llvm_unreachable, mergeSPUpdates(), mergeSPUpdatesUp(), llvm::prior(), TII, and llvm::X86Subtarget::useLeaForSP().

void X86FrameLowering::emitPrologue ( MachineFunction MF) const
virtual

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 388 of file X86FrameLowering.cpp.

References llvm::MachineModuleInfo::addFrameInst(), llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), llvm::addRegOffset(), llvm::MachineFrameInfo::adjustsStack(), llvm::MachineBasicBlock::begin(), llvm::MachineFunction::begin(), llvm::BuildMI(), llvm::MCCFIInstruction::createDefCfaOffset(), llvm::MCCFIInstruction::createDefCfaRegister(), llvm::MCCFIInstruction::createOffset(), llvm::MCContext::CreateTempSymbol(), llvm::RegState::Define, llvm::N86::EAX, emitCalleeSavedFrameMoves(), llvm::emitSPUpdate(), llvm::TargetOptions::EnableSegmentedStacks, llvm::MachineBasicBlock::end(), llvm::MachineFunction::end(), ForceStackAlign, llvm::MachineInstr::FrameSetup, llvm::MachineFunction::front(), llvm::Function::getAttributes(), llvm::X86RegisterInfo::getBaseRegister(), llvm::X86MachineFunctionInfo::getCalleeSavedFrameSize(), llvm::MachineModuleInfo::getContext(), llvm::MachineFunction::getFrameInfo(), llvm::X86RegisterInfo::getFrameRegister(), llvm::MachineFunction::getFunction(), llvm::MachineFunction::getInfo(), llvm::X86TargetMachine::getInstrInfo(), llvm::MachineFrameInfo::getMaxAlignment(), llvm::MachineFunction::getMMI(), llvm::MachineInstr::getOperand(), llvm::X86TargetMachine::getRegisterInfo(), llvm::X86RegisterInfo::getSlotSize(), llvm::TargetFrameLowering::getStackAlignment(), llvm::X86RegisterInfo::getStackRegister(), llvm::MachineFrameInfo::getStackSize(), getSUBriOpcode(), llvm::MachineFunction::getTarget(), llvm::X86MachineFunctionInfo::getTCReturnAddrDelta(), llvm::AttributeSet::hasAttribute(), llvm::X86RegisterInfo::hasBasePointer(), llvm::MachineFrameInfo::hasCalls(), llvm::MachineModuleInfo::hasDebugInfo(), hasFP(), llvm::MachineFrameInfo::hasVarSizedObjects(), I, llvm::RegState::Implicit, llvm::MachineBasicBlock::insert(), llvm::X86Subtarget::is64Bit(), isEAXLiveIn(), llvm::X86Subtarget::isOSWindows(), llvm::X86Subtarget::isTarget64BitLP64(), llvm::X86Subtarget::isTargetCygMing(), llvm::X86Subtarget::isTargetEnvMacho(), llvm::X86Subtarget::isTargetWin64(), llvm::RegState::Kill, mergeSPUpdates(), mergeSPUpdatesDown(), llvm::A64CC::MI, llvm::X86RegisterInfo::needsStackRealignment(), llvm::Function::needsUnwindTableEntry(), llvm::next(), llvm::Attribute::NoRedZone, llvm::TargetMachine::Options, llvm::TargetOpcode::PROLOG_LABEL, llvm::X86MachineFunctionInfo::setCalleeSavedFrameSize(), llvm::MachineInstr::setFlag(), llvm::MachineOperand::setIsDead(), llvm::MachineInstrBuilder::setMIFlag(), llvm::MachineFrameInfo::setOffsetAdjustment(), llvm::MachineFrameInfo::setStackSize(), TII, llvm::X86Subtarget::useLeaForSP(), and usesTheStack().

int X86FrameLowering::getFrameIndexOffset ( const MachineFunction MF,
int  FI 
) const
virtual

getFrameIndexOffset - Returns the displacement from the frame register to the stack frame of the specified index.

getFrameIndexOffset - Returns the displacement from the frame register to the stack frame of the specified index. This is the default implementation which is overridden for some targets.

Reimplemented from llvm::TargetFrameLowering.

Definition at line 904 of file X86FrameLowering.cpp.

References llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getInfo(), llvm::MachineFrameInfo::getObjectAlignment(), llvm::MachineFrameInfo::getObjectOffset(), llvm::TargetFrameLowering::getOffsetOfLocalArea(), llvm::TargetMachine::getRegisterInfo(), llvm::X86RegisterInfo::getSlotSize(), llvm::MachineFrameInfo::getStackSize(), llvm::MachineFunction::getTarget(), llvm::X86MachineFunctionInfo::getTCReturnAddrDelta(), llvm::X86RegisterInfo::hasBasePointer(), hasFP(), and llvm::X86RegisterInfo::needsStackRealignment().

Referenced by getFrameIndexReference().

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

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

Reimplemented from llvm::TargetFrameLowering.

Definition at line 946 of file X86FrameLowering.cpp.

References llvm::X86RegisterInfo::getBaseRegister(), getFrameIndexOffset(), llvm::X86RegisterInfo::getFrameRegister(), llvm::TargetMachine::getRegisterInfo(), llvm::X86RegisterInfo::getStackRegister(), llvm::MachineFunction::getTarget(), llvm::X86RegisterInfo::hasBasePointer(), and llvm::X86RegisterInfo::needsStackRealignment().

bool X86FrameLowering::hasFP ( const MachineFunction MF) const
virtual
bool X86FrameLowering::hasReservedCallFrame ( const MachineFunction MF) const
virtual

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 38 of file X86FrameLowering.cpp.

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

Referenced by eliminateCallFramePseudoInstr().

void X86FrameLowering::processFunctionBeforeCalleeSavedScan ( MachineFunction MF,
RegScavenger RS = NULL 
) const
virtual
bool X86FrameLowering::restoreCalleeSavedRegisters ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MI,
const std::vector< CalleeSavedInfo > &  CSI,
const TargetRegisterInfo TRI 
) const
virtual

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(). Returns false otherwise.

Reimplemented from llvm::TargetFrameLowering.

Definition at line 1017 of file X86FrameLowering.cpp.

References llvm::BuildMI(), llvm::MachineBasicBlock::findDebugLoc(), llvm::MCInstrInfo::get(), llvm::TargetRegisterInfo::getFrameRegister(), llvm::TargetMachine::getInstrInfo(), llvm::TargetRegisterInfo::getMinimalPhysRegClass(), llvm::MachineBasicBlock::getParent(), llvm::MachineFunction::getTarget(), llvm::X86Subtarget::is64Bit(), llvm::TargetInstrInfo::loadRegFromStackSlot(), and TII.

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

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