LLVM API Documentation

llvm::MachineFrameInfo Class Reference

Abstract Stack Frame Information. More...

#include <MachineFrameInfo.h>

Collaboration diagram for llvm::MachineFrameInfo:
[legend]

List of all members.

Public Member Functions

 MachineFrameInfo (const TargetFrameInfo &tfi)
bool hasStackObjects () const
bool hasVarSizedObjects () const
int getStackProtectorIndex () const
void setStackProtectorIndex (int I)
bool isFrameAddressTaken () const
void setFrameAddressIsTaken (bool T)
int getObjectIndexBegin () const
int getObjectIndexEnd () const
unsigned getNumFixedObjects () const
 getNumFixedObjects() - Return the number of fixed objects.
unsigned getNumObjects () const
int64_t getObjectSize (int ObjectIdx) const
void setObjectSize (int ObjectIdx, int64_t Size)
 setObjectSize - Change the size of the specified stack object.
unsigned getObjectAlignment (int ObjectIdx) const
 getObjectAlignment - Return the alignment of the specified stack object.
void setObjectAlignment (int ObjectIdx, unsigned Align)
 setObjectAlignment - Change the alignment of the specified stack object.
int64_t getObjectOffset (int ObjectIdx) const
void setObjectOffset (int ObjectIdx, int64_t SPOffset)
uint64_t getStackSize () const
void setStackSize (uint64_t Size)
int getOffsetAdjustment () const
void setOffsetAdjustment (int Adj)
unsigned getMaxAlignment () const
void setMaxAlignment (unsigned Align)
bool hasCalls () const
void setHasCalls (bool V)
unsigned getMaxCallFrameSize () const
void setMaxCallFrameSize (unsigned S)
int CreateFixedObject (uint64_t Size, int64_t SPOffset, bool Immutable=true)
bool isFixedObjectIndex (int ObjectIdx) const
bool isImmutableObjectIndex (int ObjectIdx) const
bool isDeadObjectIndex (int ObjectIdx) const
int CreateStackObject (uint64_t Size, unsigned Alignment)
void RemoveStackObject (int ObjectIdx)
int CreateVariableSizedObject ()
const std::vector
< CalleeSavedInfo > & 
getCalleeSavedInfo () const
void setCalleeSavedInfo (const std::vector< CalleeSavedInfo > &CSI)
MachineModuleInfo * getMachineModuleInfo () const
void setMachineModuleInfo (MachineModuleInfo *mmi)
void print (const MachineFunction &MF, std::ostream &OS) const
void dump (const MachineFunction &MF) const
 dump - Call print(MF, std::cerr) to be called from the debugger.

Classes

struct  StackObject


Detailed Description

Abstract Stack Frame Information.

The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted. This class is key to allowing stack frame representation optimizations, such as frame pointer elimination. It also allows more mundane (but still important) optimizations, such as reordering of abstract objects on the stack frame.

To support this, the class assigns unique integer identifiers to stack objects requested clients. These identifiers are negative integers for fixed stack objects (such as arguments passed on the stack) or nonnegative for objects that may be reordered. Instructions which refer to stack objects use a special MO_FrameIndex operand to represent these frame indexes.

Because this class keeps track of all references to the stack frame, it knows when a variable sized object is allocated on the stack. This is the sole condition which prevents frame pointer elimination, which is an important optimization on register-poor architectures. Because original variable sized alloca's in the source program are the only source of variable sized stack objects, it is safe to decide whether there will be any variable sized objects before all stack objects are known (for example, register allocator spill code never needs variable sized objects).

When prolog/epilog code emission is performed, the final stack frame is built and the machine instructions are modified to refer to the actual stack offsets of the object, eliminating all MO_FrameIndex operands from the program.

Definition at line 82 of file MachineFrameInfo.h.


Constructor & Destructor Documentation

llvm::MachineFrameInfo::MachineFrameInfo ( const TargetFrameInfo &  tfi  )  [inline, explicit]

Definition at line 181 of file MachineFrameInfo.h.


Member Function Documentation

bool llvm::MachineFrameInfo::hasStackObjects (  )  const [inline]

hasStackObjects - Return true if there are any stack objects in this function.

Definition at line 194 of file MachineFrameInfo.h.

bool llvm::MachineFrameInfo::hasVarSizedObjects (  )  const [inline]

int llvm::MachineFrameInfo::getStackProtectorIndex (  )  const [inline]

getStackProtectorIndex/setStackProtectorIndex - Return the index for the stack protector object.

Definition at line 205 of file MachineFrameInfo.h.

void llvm::MachineFrameInfo::setStackProtectorIndex ( int  I  )  [inline]

Definition at line 206 of file MachineFrameInfo.h.

bool llvm::MachineFrameInfo::isFrameAddressTaken (  )  const [inline]

isFrameAddressTaken - This method may be called any time after instruction selection is complete to determine if there is a call to .frameaddress in this function.

Definition at line 211 of file MachineFrameInfo.h.

Referenced by llvm::X86RegisterInfo::hasFP().

void llvm::MachineFrameInfo::setFrameAddressIsTaken ( bool  T  )  [inline]

Definition at line 212 of file MachineFrameInfo.h.

int llvm::MachineFrameInfo::getObjectIndexBegin (  )  const [inline]

getObjectIndexBegin - Return the minimum frame object index.

Definition at line 216 of file MachineFrameInfo.h.

Referenced by llvm::VirtRegMap::assignVirt2StackSlot(), calculateMaxStackAlignment(), estimateStackSize(), and llvm::X86RegisterInfo::processFunctionBeforeFrameFinalized().

int llvm::MachineFrameInfo::getObjectIndexEnd (  )  const [inline]

getObjectIndexEnd - Return one past the maximum frame object index.

Definition at line 220 of file MachineFrameInfo.h.

Referenced by llvm::MipsRegisterInfo::adjustMipsStackFrame(), calculateMaxStackAlignment(), and estimateStackSize().

unsigned llvm::MachineFrameInfo::getNumFixedObjects (  )  const [inline]

getNumFixedObjects() - Return the number of fixed objects.

Definition at line 223 of file MachineFrameInfo.h.

unsigned llvm::MachineFrameInfo::getNumObjects (  )  const [inline]

getNumObjects() - Return the number of objects.

Definition at line 227 of file MachineFrameInfo.h.

int64_t llvm::MachineFrameInfo::getObjectSize ( int  ObjectIdx  )  const [inline]

getObjectSize - Return the size of the specified object.

Definition at line 231 of file MachineFrameInfo.h.

Referenced by llvm::addFrameReference(), AdjustStackOffset(), estimateStackSize(), llvm::TargetInstrInfo::foldMemoryOperand(), and llvm::TargetLowering::isConsecutiveLoad().

void llvm::MachineFrameInfo::setObjectSize ( int  ObjectIdx,
int64_t  Size 
) [inline]

setObjectSize - Change the size of the specified stack object.

Definition at line 238 of file MachineFrameInfo.h.

unsigned llvm::MachineFrameInfo::getObjectAlignment ( int  ObjectIdx  )  const [inline]

void llvm::MachineFrameInfo::setObjectAlignment ( int  ObjectIdx,
unsigned  Align 
) [inline]

setObjectAlignment - Change the alignment of the specified stack object.

Definition at line 252 of file MachineFrameInfo.h.

Referenced by MeetsMaxMemopRequirement().

int64_t llvm::MachineFrameInfo::getObjectOffset ( int  ObjectIdx  )  const [inline]

void llvm::MachineFrameInfo::setObjectOffset ( int  ObjectIdx,
int64_t  SPOffset 
) [inline]

setObjectOffset - Set the stack frame offset of the specified object. The offset is relative to the stack pointer on entry to the function.

Definition at line 272 of file MachineFrameInfo.h.

References isDeadObjectIndex().

Referenced by llvm::MipsFunctionInfo::adjustLoadArgsFI(), llvm::MipsRegisterInfo::adjustMipsStackFrame(), AdjustStackOffset(), llvm::MipsFunctionInfo::adjustStoreVarArgsFI(), and llvm::MipsRegisterInfo::processFunctionBeforeFrameFinalized().

uint64_t llvm::MachineFrameInfo::getStackSize (  )  const [inline]

getStackSize - Return the number of bytes that must be allocated to hold all of the fixed size frame objects. This is only valid after Prolog/Epilog code insertion has finalized the stack frame layout.

Definition at line 284 of file MachineFrameInfo.h.

Referenced by llvm::SPURegisterInfo::determineFrameLayout(), llvm::PPCRegisterInfo::determineFrameLayout(), llvm::XCoreRegisterInfo::eliminateFrameIndex(), llvm::SPURegisterInfo::eliminateFrameIndex(), llvm::PPCRegisterInfo::eliminateFrameIndex(), llvm::MipsRegisterInfo::eliminateFrameIndex(), llvm::IA64RegisterInfo::eliminateFrameIndex(), llvm::ARMRegisterInfo::eliminateFrameIndex(), llvm::AlphaRegisterInfo::eliminateFrameIndex(), llvm::XCoreRegisterInfo::emitEpilogue(), llvm::X86RegisterInfo::emitEpilogue(), llvm::SPURegisterInfo::emitEpilogue(), llvm::PPCRegisterInfo::emitEpilogue(), llvm::IA64RegisterInfo::emitEpilogue(), llvm::ARMRegisterInfo::emitEpilogue(), llvm::AlphaRegisterInfo::emitEpilogue(), llvm::X86RegisterInfo::emitFrameMoves(), llvm::XCoreRegisterInfo::emitPrologue(), llvm::X86RegisterInfo::emitPrologue(), llvm::SPURegisterInfo::emitPrologue(), llvm::SparcRegisterInfo::emitPrologue(), llvm::PPCRegisterInfo::emitPrologue(), llvm::MipsRegisterInfo::emitPrologue(), llvm::IA64RegisterInfo::emitPrologue(), llvm::ARMRegisterInfo::emitPrologue(), llvm::AlphaRegisterInfo::emitPrologue(), llvm::X86RegisterInfo::getFrameIndexOffset(), llvm::TargetRegisterInfo::getFrameIndexOffset(), llvm::SPURegisterInfo::hasFP(), llvm::PPCRegisterInfo::hasFP(), and llvm::PPCRegisterInfo::lowerDynamicAlloc().

void llvm::MachineFrameInfo::setStackSize ( uint64_t  Size  )  [inline]

int llvm::MachineFrameInfo::getOffsetAdjustment (  )  const [inline]

getOffsetAdjustment - Return the correction for frame offsets.

Definition at line 292 of file MachineFrameInfo.h.

Referenced by llvm::ARMRegisterInfo::emitPrologue(), and llvm::TargetRegisterInfo::getFrameIndexOffset().

void llvm::MachineFrameInfo::setOffsetAdjustment ( int  Adj  )  [inline]

setOffsetAdjustment - Set the correction for frame offsets.

Definition at line 296 of file MachineFrameInfo.h.

Referenced by llvm::X86RegisterInfo::emitPrologue(), and llvm::ARMRegisterInfo::emitPrologue().

unsigned llvm::MachineFrameInfo::getMaxAlignment (  )  const [inline]

void llvm::MachineFrameInfo::setMaxAlignment ( unsigned  Align  )  [inline]

setMaxAlignment - Set the preferred alignment.

Definition at line 306 of file MachineFrameInfo.h.

Referenced by llvm::X86RegisterInfo::processFunctionBeforeCalleeSavedScan().

bool llvm::MachineFrameInfo::hasCalls (  )  const [inline]

hasCalls - Return true if the current function has no function calls. This is only valid during or after prolog/epilog code emission.

Definition at line 311 of file MachineFrameInfo.h.

Referenced by llvm::MipsRegisterInfo::adjustMipsStackFrame(), llvm::PPCRegisterInfo::determineFrameLayout(), llvm::X86RegisterInfo::emitPrologue(), llvm::SPURegisterInfo::emitPrologue(), llvm::MipsRegisterInfo::emitPrologue(), and llvm::MipsRegisterInfo::processFunctionBeforeFrameFinalized().

void llvm::MachineFrameInfo::setHasCalls ( bool  V  )  [inline]

Definition at line 312 of file MachineFrameInfo.h.

unsigned llvm::MachineFrameInfo::getMaxCallFrameSize (  )  const [inline]

getMaxCallFrameSize - Return the maximum size of a call frame that must be allocated for an outgoing function call. This is only available if CallFrameSetup/Destroy pseudo instructions are used by the target, and then only during or after prolog/epilog code insertion.

Definition at line 319 of file MachineFrameInfo.h.

Referenced by llvm::SPURegisterInfo::determineFrameLayout(), llvm::PPCRegisterInfo::determineFrameLayout(), llvm::ARMRegisterInfo::hasReservedCallFrame(), and llvm::PPCRegisterInfo::lowerDynamicAlloc().

void llvm::MachineFrameInfo::setMaxCallFrameSize ( unsigned  S  )  [inline]

int MachineFrameInfo::CreateFixedObject ( uint64_t  Size,
int64_t  SPOffset,
bool  Immutable = true 
)

CreateFixedObject - Create a new object at a fixed location on the stack. All fixed objects should be created before other objects are created for efficiency. By default, fixed objects are immutable. This returns an index with a negative value.

CreateFixedObject - Create a new object at a fixed location on the stack. All fixed objects should be created before other objects are created for efficiency. By default, fixed objects are immutable. This returns an index with a negative value.

Definition at line 408 of file MachineFunction.cpp.

References Objects.

Referenced by CalculateTailCallArgDest(), EmitTailCallStoreFPAndRetAddr(), EmitTailCallStoreRetAddr(), llvm::X86TargetLowering::getReturnAddressFrameIndex(), llvm::SparcTargetLowering::LowerArguments(), llvm::IA64TargetLowering::LowerArguments(), LowerFORMAL_ARGUMENT(), LowerFORMAL_ARGUMENTS(), llvm::XCoreRegisterInfo::processFunctionBeforeCalleeSavedScan(), llvm::PPCRegisterInfo::processFunctionBeforeCalleeSavedScan(), and llvm::X86RegisterInfo::processFunctionBeforeFrameFinalized().

bool llvm::MachineFrameInfo::isFixedObjectIndex ( int  ObjectIdx  )  const [inline]

bool llvm::MachineFrameInfo::isImmutableObjectIndex ( int  ObjectIdx  )  const [inline]

isImmutableObjectIndex - Returns true if the specified index corresponds to an immutable object.

Definition at line 339 of file MachineFrameInfo.h.

Referenced by llvm::XCoreInstrInfo::isInvariantLoad(), and llvm::X86InstrInfo::isInvariantLoad().

bool llvm::MachineFrameInfo::isDeadObjectIndex ( int  ObjectIdx  )  const [inline]

isDeadObjectIndex - Returns true if the specified index corresponds to a dead object.

Definition at line 347 of file MachineFrameInfo.h.

Referenced by llvm::MipsRegisterInfo::adjustMipsStackFrame(), calculateMaxStackAlignment(), estimateStackSize(), getObjectOffset(), and setObjectOffset().

int llvm::MachineFrameInfo::CreateStackObject ( uint64_t  Size,
unsigned  Alignment 
) [inline]

void llvm::MachineFrameInfo::RemoveStackObject ( int  ObjectIdx  )  [inline]

RemoveStackObject - Remove or mark dead a statically sized stack object.

Definition at line 364 of file MachineFrameInfo.h.

int llvm::MachineFrameInfo::CreateVariableSizedObject (  )  [inline]

CreateVariableSizedObject - Notify the MachineFrameInfo object that a variable sized object has been created. This must be created whenever a variable sized object is created, whether or not the index returned is actually used.

Definition at line 374 of file MachineFrameInfo.h.

const std::vector<CalleeSavedInfo>& llvm::MachineFrameInfo::getCalleeSavedInfo (  )  const [inline]

getCalleeSavedInfo - Returns a reference to call saved info vector for the current function.

Definition at line 382 of file MachineFrameInfo.h.

Referenced by llvm::MipsRegisterInfo::adjustMipsStackFrame(), llvm::X86RegisterInfo::emitFrameMoves(), llvm::SPURegisterInfo::emitPrologue(), llvm::PPCRegisterInfo::emitPrologue(), and llvm::ARMRegisterInfo::emitPrologue().

void llvm::MachineFrameInfo::setCalleeSavedInfo ( const std::vector< CalleeSavedInfo > &  CSI  )  [inline]

setCalleeSavedInfo - Used by prolog/epilog inserter to set the function's callee saved information.

Definition at line 388 of file MachineFrameInfo.h.

MachineModuleInfo* llvm::MachineFrameInfo::getMachineModuleInfo (  )  const [inline]

void llvm::MachineFrameInfo::setMachineModuleInfo ( MachineModuleInfo *  mmi  )  [inline]

setMachineModuleInfo - Used by a meta info consumer (DwarfWriter) to indicate that frame layout information should be gathered.

Definition at line 398 of file MachineFrameInfo.h.

void MachineFrameInfo::print ( const MachineFunction &  MF,
std::ostream &  OS 
) const

print - Used by the MachineFunction printer to print information about stack objects. Implemented in MachineFunction.cpp

Definition at line 416 of file MachineFunction.cpp.

References FI, llvm::TargetMachine::getFrameInfo(), llvm::TargetFrameInfo::getOffsetOfLocalArea(), llvm::MachineFunction::getTarget(), and Objects.

Referenced by dump(), and llvm::MachineFunction::print().

void MachineFrameInfo::dump ( const MachineFunction &  MF  )  const

dump - Call print(MF, std::cerr) to be called from the debugger.

Definition at line 452 of file MachineFunction.cpp.

References llvm::cerr(), and print().


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