LLVM API Documentation

llvm::MachineFunction Class Reference

#include <MachineFunction.h>

Inheritance diagram for llvm::MachineFunction:

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

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::vector< std::pair<
unsigned, unsigned > >::const_iterator 
livein_iterator
typedef std::vector< unsigned
>::const_iterator 
liveout_iterator
typedef ilist< MachineBasicBlockBasicBlockListType
typedef BasicBlockListType::iterator iterator
typedef BasicBlockListType::const_iterator const_iterator
typedef std::reverse_iterator<
const_iterator
const_reverse_iterator
typedef std::reverse_iterator<
iterator
reverse_iterator

Public Member Functions

 MachineFunction (const Function *Fn, const TargetMachine &TM)
 ~MachineFunction ()
const FunctiongetFunction () const
const TargetMachinegetTarget () const
SSARegMapgetSSARegMap () const
void clearSSARegMap ()
MachineFrameInfogetFrameInfo () const
MachineConstantPoolgetConstantPool () const
template<typename Ty>
TygetInfo ()
void setUsedPhysRegs (bool *UPR)
bool * getUsedPhysregs ()
const bool * getUsedPhysregs () const
bool isPhysRegUsed (unsigned Reg)
void changePhyRegUsed (unsigned Reg, bool State)
void addLiveIn (unsigned Reg, unsigned vreg=0)
void addLiveOut (unsigned Reg)
livein_iterator livein_begin () const
livein_iterator livein_end () const
bool livein_empty () const
liveout_iterator liveout_begin () const
liveout_iterator liveout_end () const
bool liveout_empty () const
MachineBasicBlockgetBlockNumbered (unsigned N)
MachineBasicBlockgetLastBlock ()
 getLastBlock - Returns the MachineBasicBlock with the greatest number
const MachineBasicBlockgetLastBlock () const
void print (std::ostream &OS) const
void viewCFG () const
void viewCFGOnly () const
void dump () const
const BasicBlockListTypegetBasicBlockList () const
BasicBlockListTypegetBasicBlockList ()
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
reverse_iterator rbegin ()
const_reverse_iterator rbegin () const
reverse_iterator rend ()
const_reverse_iterator rend () const
unsigned size () const
bool empty () const
const MachineBasicBlockfront () const
MachineBasicBlockfront ()
const MachineBasicBlockback () const
MachineBasicBlockback ()
unsigned addToMBBNumbering (MachineBasicBlock *MBB)
void removeFromMBBNumbering (unsigned N)

Static Public Member Functions

static MachineFunctionconstruct (const Function *F, const TargetMachine &TM)
static void destruct (const Function *F)
static MachineFunctionget (const Function *F)

Detailed Description

Definition at line 77 of file MachineFunction.h.


Member Typedef Documentation

typedef ilist<MachineBasicBlock> llvm::MachineFunction::BasicBlockListType

Definition at line 259 of file MachineFunction.h.

typedef BasicBlockListType::const_iterator llvm::MachineFunction::const_iterator

Definition at line 261 of file MachineFunction.h.

typedef std::reverse_iterator<const_iterator> llvm::MachineFunction::const_reverse_iterator

Definition at line 262 of file MachineFunction.h.

typedef BasicBlockListType::iterator llvm::MachineFunction::iterator

Definition at line 260 of file MachineFunction.h.

typedef std::vector<std::pair<unsigned,unsigned> >::const_iterator llvm::MachineFunction::livein_iterator

Definition at line 191 of file MachineFunction.h.

typedef std::vector<unsigned>::const_iterator llvm::MachineFunction::liveout_iterator

Definition at line 192 of file MachineFunction.h.

typedef std::reverse_iterator<iterator> llvm::MachineFunction::reverse_iterator

Definition at line 263 of file MachineFunction.h.


Constructor & Destructor Documentation

MachineFunction::MachineFunction ( const Function Fn,
const TargetMachine TM 
)

Definition at line 109 of file MachineFunction.cpp.

References llvm::TargetMachine::getTargetData(), and TM.

Referenced by construct().

MachineFunction::~MachineFunction (  ) 

Definition at line 119 of file MachineFunction.cpp.


Member Function Documentation

void llvm::MachineFunction::addLiveIn ( unsigned  Reg,
unsigned  vreg = 0 
) [inline]

addLiveIn/Out - Add the specified register as a live in/out. Note that it is an error to add the same register to the same set more than once.

Definition at line 183 of file MachineFunction.h.

Referenced by AddLiveIn(), llvm::PPCTargetLowering::LowerArguments(), and llvm::IA64TargetLowering::LowerArguments().

void llvm::MachineFunction::addLiveOut ( unsigned  Reg  )  [inline]

Definition at line 186 of file MachineFunction.h.

Referenced by llvm::IA64TargetLowering::LowerArguments(), llvm::AlphaTargetLowering::LowerArguments(), and llvm::PPCTargetLowering::LowerOperation().

unsigned llvm::MachineFunction::addToMBBNumbering ( MachineBasicBlock MBB  )  [inline]

getNextMBBNumber - Returns the next unique number to be assigned to a MachineBasicBlock in this MachineFunction.

Definition at line 296 of file MachineFunction.h.

References MBB.

MachineBasicBlock& llvm::MachineFunction::back (  )  [inline]

Definition at line 287 of file MachineFunction.h.

const MachineBasicBlock& llvm::MachineFunction::back (  )  const [inline]

Definition at line 286 of file MachineFunction.h.

const_iterator llvm::MachineFunction::begin (  )  const [inline]

Definition at line 273 of file MachineFunction.h.

iterator llvm::MachineFunction::begin (  )  [inline]

Definition at line 272 of file MachineFunction.h.

Referenced by llvm::LiveRangeInfo::coalesceLRs(), llvm::LiveRangeInfo::constructLiveRanges(), print(), llvm::LiveIntervals::print(), llvm::PeepholeOpts::runOnBasicBlock(), llvm::X86IntelAsmPrinter::runOnMachineFunction(), llvm::X86ATTAsmPrinter::runOnMachineFunction(), llvm::SparcV9CodeEmitter::runOnMachineFunction(), llvm::LiveVariables::runOnMachineFunction(), and llvm::LiveIntervals::runOnMachineFunction().

void llvm::MachineFunction::changePhyRegUsed ( unsigned  Reg,
bool  State 
) [inline]

changePhyRegUsed - This method allows code that runs after register allocation to keep the PhysRegsUsed array up-to-date.

Definition at line 176 of file MachineFunction.h.

void MachineFunction::clearSSARegMap (  ) 

Definition at line 291 of file MachineFunction.cpp.

MachineFunction & MachineFunction::construct ( const Function F,
const TargetMachine TM 
) [static]

construct - Allocate and initialize a MachineFunction for a given Function and Target

Definition at line 270 of file MachineFunction.cpp.

References llvm::Annotable::addAnnotation(), llvm::Annotable::getAnnotation(), MachineFunction(), and MF_AID().

Referenced by llvm::SelectionDAGISel::runOnFunction().

void MachineFunction::destruct ( const Function F  )  [static]

destruct - Destroy the MachineFunction corresponding to a given Function

Definition at line 279 of file MachineFunction.cpp.

References llvm::Annotable::deleteAnnotation(), and MF_AID().

void MachineFunction::dump (  )  const

dump - Print the current MachineFunction to cerr, useful for debugger use.

Definition at line 128 of file MachineFunction.cpp.

References print().

Referenced by llvm::PhyRegAlloc::runOnFunction().

bool llvm::MachineFunction::empty (  )  const [inline]

Definition at line 283 of file MachineFunction.h.

const_iterator llvm::MachineFunction::end (  )  const [inline]

Definition at line 275 of file MachineFunction.h.

iterator llvm::MachineFunction::end (  )  [inline]

Definition at line 274 of file MachineFunction.h.

Referenced by llvm::LiveRangeInfo::coalesceLRs(), llvm::LiveRangeInfo::constructLiveRanges(), print(), llvm::LiveIntervals::print(), llvm::PeepholeOpts::runOnBasicBlock(), llvm::X86IntelAsmPrinter::runOnMachineFunction(), llvm::X86ATTAsmPrinter::runOnMachineFunction(), llvm::SparcV9CodeEmitter::runOnMachineFunction(), llvm::LiveVariables::runOnMachineFunction(), llvm::LiveIntervals::runOnMachineFunction(), llvm::SelectionDAGLowering::visitBr(), llvm::SelectionDAGLowering::visitSwitch(), and llvm::SelectionDAGLowering::visitSwitchCase().

MachineBasicBlock& llvm::MachineFunction::front (  )  [inline]

Definition at line 285 of file MachineFunction.h.

const MachineBasicBlock& llvm::MachineFunction::front (  )  const [inline]

Definition at line 284 of file MachineFunction.h.

Referenced by llvm::X86RegisterInfo::emitPrologue(), llvm::SparcRegisterInfo::emitPrologue(), llvm::PPCRegisterInfo::emitPrologue(), llvm::IA64RegisterInfo::emitPrologue(), llvm::AlphaRegisterInfo::emitPrologue(), llvm::PPCTargetLowering::LowerArguments(), llvm::IA64TargetLowering::LowerArguments(), and llvm::AlphaTargetLowering::LowerArguments().

MachineFunction & MachineFunction::get ( const Function F  )  [static]

get - Return a handle to a MachineFunction corresponding to the given Function. This should not be called before "construct()" for a given Function.

Definition at line 284 of file MachineFunction.cpp.

References F, and MF_AID().

Referenced by llvm::LiveRangeInfo::coalesceLRs(), llvm::SparcV9RegInfo::colorMethodArgs(), llvm::LiveRangeInfo::constructLiveRanges(), llvm::MachineCodeForInstruction::destroy(), llvm::MachineCodeForInstruction::get(), llvm::PeepholeOpts::runOnBasicBlock(), llvm::PhyRegAlloc::runOnFunction(), llvm::ModuloSchedulingSBPass::runOnFunction(), llvm::ModuloSchedulingPass::runOnFunction(), and llvm::MachineFunctionPass::runOnFunction().

BasicBlockListType& llvm::MachineFunction::getBasicBlockList (  )  [inline]

Definition at line 267 of file MachineFunction.h.

const BasicBlockListType& llvm::MachineFunction::getBasicBlockList (  )  const [inline]

Definition at line 266 of file MachineFunction.h.

Referenced by llvm::FunctionLoweringInfo::FunctionLoweringInfo(), and llvm::SelectionDAGLowering::visitSwitch().

MachineBasicBlock* llvm::MachineFunction::getBlockNumbered ( unsigned  N  )  [inline]

getBlockNumbered - MachineBasicBlocks are automatically numbered when they are inserted into the machine function. The block number for a machine basic block can be found by using the MBB::getBlockNumber method, this method provides the inverse mapping.

Definition at line 205 of file MachineFunction.h.

MachineConstantPool* llvm::MachineFunction::getConstantPool (  )  const [inline]

getConstantPool - Return the constant pool object for the current function.

Definition at line 144 of file MachineFunction.h.

Referenced by print(), llvm::ScheduleDAG::Run(), llvm::X86IntelAsmPrinter::runOnMachineFunction(), llvm::X86ATTAsmPrinter::runOnMachineFunction(), and llvm::SparcV9CodeEmitter::runOnMachineFunction().

MachineFrameInfo* llvm::MachineFunction::getFrameInfo (  )  const [inline]

getFrameInfo - Return the frame info object for the current function. This object contains information about objects allocated on the stack frame of the current function in an abstract way.

Definition at line 139 of file MachineFunction.h.

Referenced by llvm::VirtRegMap::assignVirt2StackSlot(), llvm::X86RegisterInfo::eliminateFrameIndex(), llvm::SparcRegisterInfo::eliminateFrameIndex(), llvm::PPCRegisterInfo::eliminateFrameIndex(), llvm::IA64RegisterInfo::eliminateFrameIndex(), llvm::AlphaRegisterInfo::eliminateFrameIndex(), llvm::X86RegisterInfo::emitEpilogue(), llvm::PPCRegisterInfo::emitEpilogue(), llvm::IA64RegisterInfo::emitEpilogue(), llvm::AlphaRegisterInfo::emitEpilogue(), llvm::X86RegisterInfo::emitPrologue(), llvm::SparcRegisterInfo::emitPrologue(), llvm::PPCRegisterInfo::emitPrologue(), llvm::IA64RegisterInfo::emitPrologue(), llvm::AlphaRegisterInfo::emitPrologue(), llvm::FunctionLoweringInfo::FunctionLoweringInfo(), llvm::MRegisterInfo::getLocation(), llvm::X86TargetLowering::getReturnAddressFrameIndex(), hasFP(), llvm::PPCTargetLowering::LowerArguments(), llvm::IA64TargetLowering::LowerArguments(), llvm::AlphaTargetLowering::LowerArguments(), llvm::X86TargetLowering::LowerOperation(), llvm::PPCTargetLowering::LowerOperation(), llvm::AlphaTargetLowering::LowerOperation(), print(), llvm::X86RegisterInfo::processFunctionBeforeFrameFinalized(), and llvm::SelectionDAGLowering::visitAlloca().

const Function* llvm::MachineFunction::getFunction (  )  const [inline]

getFunction - Return the LLVM function that this machine code represents

Definition at line 123 of file MachineFunction.h.

Referenced by llvm::SparcV9FunctionInfo::CalculateArgSize(), llvm::AlphaRegisterInfo::emitPrologue(), llvm::X86IntelAsmPrinter::printOp(), llvm::X86ATTAsmPrinter::printOperand(), llvm::X86IntelAsmPrinter::runOnMachineFunction(), llvm::X86ATTAsmPrinter::runOnMachineFunction(), llvm::SparcV9CodeEmitter::runOnMachineFunction(), llvm::AsmPrinter::SetupMachineFunction(), and viewCFG().

template<typename Ty>
Ty* llvm::MachineFunction::getInfo (  )  [inline]

MachineFunctionInfo - Keep track of various per-function pieces of information for backends that would like to do so.

Definition at line 150 of file MachineFunction.h.

References Ty.

Referenced by llvm::SparcV9RegInfo::colorMethodArgs(), llvm::MachineCodeForInstruction::destroy(), llvm::IA64RegisterInfo::emitPrologue(), llvm::MachineCodeForInstruction::get(), llvm::SparcV9FrameInfo::getDynamicAreaOffset(), llvm::SparcV9FrameInfo::getRegSpillAreaOffset(), llvm::getStaticStackSize(), llvm::SparcV9FrameInfo::getTmpAreaOffset(), llvm::IA64TargetLowering::LowerCallTo(), and llvm::PhyRegAlloc::runOnFunction().

const MachineBasicBlock* llvm::MachineFunction::getLastBlock (  )  const [inline]

Definition at line 215 of file MachineFunction.h.

MachineBasicBlock* llvm::MachineFunction::getLastBlock (  )  [inline]

getLastBlock - Returns the MachineBasicBlock with the greatest number

Definition at line 212 of file MachineFunction.h.

SSARegMap* llvm::MachineFunction::getSSARegMap (  )  const [inline]

SSARegMap Interface... Keep track of information about each SSA virtual register, such as which register class it belongs to.

Definition at line 132 of file MachineFunction.h.

Referenced by llvm::LiveIntervals::addIntervalsForSpills(), AddLiveIn(), llvm::VirtRegMap::assignVirt2StackSlot(), llvm::VirtRegMap::grow(), llvm::PPCTargetLowering::LowerArguments(), llvm::IA64TargetLowering::LowerArguments(), llvm::VirtRegMap::print(), llvm::ScheduleDAG::Run(), llvm::SelectionDAGISel::runOnFunction(), and llvm::LiveIntervals::runOnMachineFunction().

const TargetMachine& llvm::MachineFunction::getTarget (  )  const [inline]

getTarget - Return the target machine this machine code is compiled with

Definition at line 127 of file MachineFunction.h.

Referenced by llvm::SparcV9FunctionInfo::allocateSpilledValue(), llvm::SparcV9FunctionInfo::CalculateArgSize(), llvm::SparcV9FunctionInfo::computeOffsetforLocalVar(), llvm::X86RegisterInfo::eliminateCallFramePseudoInstr(), llvm::PPCRegisterInfo::eliminateCallFramePseudoInstr(), llvm::IA64RegisterInfo::eliminateCallFramePseudoInstr(), llvm::AlphaRegisterInfo::eliminateCallFramePseudoInstr(), llvm::PPCRegisterInfo::emitEpilogue(), llvm::X86RegisterInfo::emitPrologue(), llvm::PPCRegisterInfo::emitPrologue(), llvm::IA64RegisterInfo::emitPrologue(), llvm::AlphaRegisterInfo::emitPrologue(), llvm::MachineBasicBlock::getFirstTerminator(), llvm::getStaticStackSize(), hasFP(), llvm::operator<<(), llvm::VirtRegMap::print(), llvm::MachineFrameInfo::print(), print(), llvm::SparcV9FunctionInfo::pushTempValue(), llvm::LiveVariables::runOnMachineFunction(), and llvm::LiveIntervals::runOnMachineFunction().

const bool* llvm::MachineFunction::getUsedPhysregs (  )  const [inline]

Definition at line 168 of file MachineFunction.h.

bool* llvm::MachineFunction::getUsedPhysregs (  )  [inline]

getUsedPhysregs - This returns the UsedPhysRegs array. This returns null before register allocation.

Definition at line 167 of file MachineFunction.h.

Referenced by llvm::PPCRegisterInfo::emitPrologue().

bool llvm::MachineFunction::isPhysRegUsed ( unsigned  Reg  )  [inline]

isPhysRegUsed - Return true if the specified register is used in this function. This only works after register allocation.

Definition at line 172 of file MachineFunction.h.

Referenced by llvm::IA64RegisterInfo::emitPrologue().

livein_iterator llvm::MachineFunction::livein_begin (  )  const [inline]

Definition at line 193 of file MachineFunction.h.

Referenced by print(), llvm::LiveVariables::runOnMachineFunction(), and llvm::LiveIntervals::runOnMachineFunction().

bool llvm::MachineFunction::livein_empty (  )  const [inline]

Definition at line 195 of file MachineFunction.h.

livein_iterator llvm::MachineFunction::livein_end (  )  const [inline]

Definition at line 194 of file MachineFunction.h.

Referenced by print(), llvm::LiveVariables::runOnMachineFunction(), and llvm::LiveIntervals::runOnMachineFunction().

liveout_iterator llvm::MachineFunction::liveout_begin (  )  const [inline]

Definition at line 196 of file MachineFunction.h.

Referenced by print(), and llvm::LiveVariables::runOnMachineFunction().

bool llvm::MachineFunction::liveout_empty (  )  const [inline]

Definition at line 198 of file MachineFunction.h.

Referenced by llvm::PPCTargetLowering::LowerOperation().

liveout_iterator llvm::MachineFunction::liveout_end (  )  const [inline]

Definition at line 197 of file MachineFunction.h.

Referenced by print(), and llvm::LiveVariables::runOnMachineFunction().

void MachineFunction::print ( std::ostream &  OS  )  const

print - Print out the MachineFunction in a format suitable for debugging to the specified stream.

Definition at line 130 of file MachineFunction.cpp.

References BB, begin(), E, end(), getConstantPool(), getFrameInfo(), llvm::MRegisterInfo::getName(), llvm::Value::getName(), llvm::TargetMachine::getRegisterInfo(), getTarget(), I, livein_begin(), livein_end(), liveout_begin(), liveout_end(), MRI, llvm::BasicBlock::print(), llvm::MachineConstantPool::print(), and llvm::MachineFrameInfo::print().

Referenced by dump().

const_reverse_iterator llvm::MachineFunction::rbegin (  )  const [inline]

Definition at line 278 of file MachineFunction.h.

reverse_iterator llvm::MachineFunction::rbegin (  )  [inline]

Definition at line 277 of file MachineFunction.h.

void llvm::MachineFunction::removeFromMBBNumbering ( unsigned  N  )  [inline]

removeFromMBBNumbering - Remove the specific machine basic block from our tracker, this is only really to be used by the MachineBasicBlock implementation.

Definition at line 304 of file MachineFunction.h.

const_reverse_iterator llvm::MachineFunction::rend (  )  const [inline]

Definition at line 280 of file MachineFunction.h.

reverse_iterator llvm::MachineFunction::rend (  )  [inline]

Definition at line 279 of file MachineFunction.h.

void llvm::MachineFunction::setUsedPhysRegs ( bool *  UPR  )  [inline]

setUsedPhysRegs - The register allocator should call this to initialized the UsedPhysRegs set. This should be passed a new[]'d array with entries for all of the physical registers that the target supports. Each array entry should be set to true iff the physical register is used within the function.

Definition at line 163 of file MachineFunction.h.

unsigned llvm::MachineFunction::size (  )  const [inline]

Definition at line 282 of file MachineFunction.h.

void MachineFunction::viewCFG (  )  const

viewCFG - This function is meant for use from the debugger. You can just say 'call F->viewCFG()' and a ghostview window should pop up from the program, displaying the CFG of the current function with the code for each basic block inside. This depends on there being a 'dot' and 'gv' program in your path.

Definition at line 208 of file MachineFunction.cpp.

References F, Filename, getFunction(), llvm::Value::getName(), and llvm::WriteGraph().

Referenced by viewCFGOnly().

void MachineFunction::viewCFGOnly (  )  const

viewCFGOnly - This function is meant for use from the debugger. It works just like viewCFG, but it does not include the contents of basic blocks into the nodes, just the label. If you are only interested in the CFG this can make the graph smaller.

Definition at line 255 of file MachineFunction.cpp.

References viewCFG().


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