LLVM API Documentation

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

#include <SelectionDAGBuilder.h>

Collaboration diagram for llvm::SelectionDAGBuilder:
Collaboration graph
[legend]

Public Member Functions

 SelectionDAGBuilder (SelectionDAG &dag, FunctionLoweringInfo &funcinfo, CodeGenOpt::Level ol)
 
void init (GCFunctionInfo *gfi, AliasAnalysis &aa, const TargetLibraryInfo *li)
 
void clear ()
 
void clearDanglingDebugInfo ()
 
SDValue getRoot ()
 
SDValue getControlRoot ()
 
SDLoc getCurSDLoc () const
 
DebugLoc getCurDebugLoc () const
 
unsigned getSDNodeOrder () const
 
void CopyValueToVirtualRegister (const Value *V, unsigned Reg)
 
void visit (const Instruction &I)
 
void visit (unsigned Opcode, const User &I)
 
void resolveDanglingDebugInfo (const Value *V, SDValue Val)
 
SDValue getValue (const Value *V)
 getValue - Return an SDValue for the given Value. More...
 
SDValue getNonRegisterValue (const Value *V)
 
SDValue getValueImpl (const Value *V)
 
void setValue (const Value *V, SDValue NewN)
 
void setUnusedArgValue (const Value *V, SDValue NewN)
 
void FindMergedConditions (const Value *Cond, MachineBasicBlock *TBB, MachineBasicBlock *FBB, MachineBasicBlock *CurBB, MachineBasicBlock *SwitchBB, unsigned Opc)
 FindMergedConditions - If Cond is an expression like. More...
 
void EmitBranchForMergedCondition (const Value *Cond, MachineBasicBlock *TBB, MachineBasicBlock *FBB, MachineBasicBlock *CurBB, MachineBasicBlock *SwitchBB)
 
bool ShouldEmitAsBranches (const std::vector< CaseBlock > &Cases)
 
bool isExportableFromCurrentBlock (const Value *V, const BasicBlock *FromBB)
 
void CopyToExportRegsIfNeeded (const Value *V)
 
void ExportFromCurrentBlock (const Value *V)
 
void LowerCallTo (ImmutableCallSite CS, SDValue Callee, bool IsTailCall, MachineBasicBlock *LandingPad=NULL)
 
std::pair< SDValue, SDValueLowerCallOperands (const CallInst &CI, unsigned ArgIdx, unsigned NumArgs, SDValue Callee, bool useVoidTy=false)
 Lower an argument list according to the target calling convention. More...
 
void UpdateSplitBlock (MachineBasicBlock *First, MachineBasicBlock *Last)
 
void visitSwitchCase (CaseBlock &CB, MachineBasicBlock *SwitchBB)
 
void visitSPDescriptorParent (StackProtectorDescriptor &SPD, MachineBasicBlock *ParentBB)
 
void visitSPDescriptorFailure (StackProtectorDescriptor &SPD)
 
void visitBitTestHeader (BitTestBlock &B, MachineBasicBlock *SwitchBB)
 
void visitBitTestCase (BitTestBlock &BB, MachineBasicBlock *NextMBB, uint32_t BranchWeightToNext, unsigned Reg, BitTestCase &B, MachineBasicBlock *SwitchBB)
 visitBitTestCase - this function produces one "bit test" More...
 
void visitJumpTable (JumpTable &JT)
 visitJumpTable - Emit JumpTable node in the current MBB More...
 
void visitJumpTableHeader (JumpTable &JT, JumpTableHeader &JTH, MachineBasicBlock *SwitchBB)
 

Public Attributes

SmallVector< SDValue, 8 > PendingLoads
 
SelectionDAGDAG
 
const DataLayoutTD
 
AliasAnalysisAA
 
const TargetLibraryInfoLibInfo
 
std::vector< CaseBlock > SwitchCases
 
std::vector< JumpTableBlock > JTCases
 
std::vector< BitTestBlock > BitTestCases
 
StackProtectorDescriptor SPDescriptor
 
DenseMap< const Constant
*, unsigned
ConstantsOut
 
FunctionLoweringInfoFuncInfo
 
CodeGenOpt::Level OptLevel
 
GCFunctionInfoGFI
 GFI - Garbage collection metadata for the function. More...
 
DenseMap< MachineBasicBlock
*, SmallVector< unsigned, 4 > > 
LPadToCallSiteMap
 LPadToCallSiteMap - Map a landing pad to the call site indexes. More...
 
bool HasTailCall
 
LLVMContextContext
 

Detailed Description

SelectionDAGBuilder - This is the common target-independent lowering implementation that is parameterized by a TargetLowering object.

Definition at line 83 of file SelectionDAGBuilder.h.

Constructor & Destructor Documentation

llvm::SelectionDAGBuilder::SelectionDAGBuilder ( SelectionDAG dag,
FunctionLoweringInfo funcinfo,
CodeGenOpt::Level  ol 
)
inline

Definition at line 535 of file SelectionDAGBuilder.h.

Member Function Documentation

void SelectionDAGBuilder::clear ( )

clear - Clear out the current SelectionDAG and the associated state and prepare this SelectionDAGBuilder object to be used for a new block. This doesn't clear out information about additional blocks that are needed to complete switch lowering or PHI node updating; that information is cleared out as it is consumed.

Definition at line 880 of file SelectionDAGBuilder.cpp.

References HasTailCall, and PendingLoads.

void SelectionDAGBuilder::clearDanglingDebugInfo ( )

clearDanglingDebugInfo - Clear the dangling debug information map. This function is separated from the clear so that debug information that is dangling in a basic block can be properly resolved in a different basic block. This allows the SelectionDAG to resolve dangling debug information attached to PHI nodes.

Definition at line 895 of file SelectionDAGBuilder.cpp.

void SelectionDAGBuilder::CopyToExportRegsIfNeeded ( const Value V)

CopyToExportRegsIfNeeded - If the given value has virtual registers created for it, emit nodes to copy the value into the virtual registers.

Definition at line 1299 of file SelectionDAGBuilder.cpp.

References CopyValueToVirtualRegister(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::find(), llvm::Value::getType(), llvm::Type::isEmptyTy(), llvm::Value::use_empty(), and llvm::FunctionLoweringInfo::ValueMap.

Referenced by visit().

void SelectionDAGBuilder::CopyValueToVirtualRegister ( const Value V,
unsigned  Reg 
)
void SelectionDAGBuilder::EmitBranchForMergedCondition ( const Value Cond,
MachineBasicBlock TBB,
MachineBasicBlock FBB,
MachineBasicBlock CurBB,
MachineBasicBlock SwitchBB 
)
void SelectionDAGBuilder::ExportFromCurrentBlock ( const Value V)

ExportFromCurrentBlock - If this condition isn't known to be exported from the current basic block, add it to ValueMap now so that we'll get a CopyTo/FromReg.

Definition at line 1314 of file SelectionDAGBuilder.cpp.

References CopyValueToVirtualRegister(), llvm::FunctionLoweringInfo::InitializeRegForValue(), and llvm::FunctionLoweringInfo::isExportedInst().

void SelectionDAGBuilder::FindMergedConditions ( const Value Cond,
MachineBasicBlock TBB,
MachineBasicBlock FBB,
MachineBasicBlock CurBB,
MachineBasicBlock SwitchBB,
unsigned  Opc 
)
SDValue SelectionDAGBuilder::getControlRoot ( )

getControlRoot - Similar to getRoot, but instead of flushing all the PendingLoad items, flush all the PendingExports items. It is necessary to do this before emitting a terminator instruction.

Definition at line 927 of file SelectionDAGBuilder.cpp.

References llvm::ISD::EntryToken, getCurSDLoc(), llvm::SelectionDAG::getNode(), llvm::SDValue::getOpcode(), llvm::SelectionDAG::getRoot(), llvm::MVT::Other, llvm::SelectionDAG::setRoot(), and llvm::ISD::TokenFactor.

Referenced by LowerCallTo(), visitBitTestCase(), visitBitTestHeader(), visitJumpTable(), visitJumpTableHeader(), and visitSwitchCase().

DebugLoc llvm::SelectionDAGBuilder::getCurDebugLoc ( ) const
inline

Definition at line 578 of file SelectionDAGBuilder.h.

References llvm::Instruction::getDebugLoc().

SDLoc llvm::SelectionDAGBuilder::getCurSDLoc ( ) const
inline
SDValue SelectionDAGBuilder::getNonRegisterValue ( const Value V)

getNonRegisterValue - Return an SDValue for the given Value, but don't look in FuncInfo.ValueMap for a virtual register.

Definition at line 1041 of file SelectionDAGBuilder.cpp.

References llvm::SDValue::getNode(), getValueImpl(), N, and resolveDanglingDebugInfo().

Referenced by CopyValueToVirtualRegister().

SDValue SelectionDAGBuilder::getRoot ( )

getRoot - Return the current virtual root of the Selection DAG, flushing any PendingLoad items. This must be done before emitting a store or any other node that may need to be ordered after any prior load instructions.

Definition at line 904 of file SelectionDAGBuilder.cpp.

References getCurSDLoc(), llvm::SelectionDAG::getNode(), llvm::SelectionDAG::getRoot(), llvm::MVT::Other, PendingLoads, llvm::SelectionDAG::setRoot(), and llvm::ISD::TokenFactor.

Referenced by LowerCallOperands(), and LowerCallTo().

unsigned llvm::SelectionDAGBuilder::getSDNodeOrder ( ) const
inline

Definition at line 582 of file SelectionDAGBuilder.h.

SDValue SelectionDAGBuilder::getValue ( const Value V)
SDValue SelectionDAGBuilder::getValueImpl ( const Value V)
void SelectionDAGBuilder::init ( GCFunctionInfo gfi,
AliasAnalysis aa,
const TargetLibraryInfo li 
)
bool SelectionDAGBuilder::isExportableFromCurrentBlock ( const Value V,
const BasicBlock FromBB 
)
std::pair< SDValue, SDValue > SelectionDAGBuilder::LowerCallOperands ( const CallInst CI,
unsigned  ArgIdx,
unsigned  NumArgs,
SDValue  Callee,
bool  useVoidTy = false 
)

Lower an argument list according to the target calling convention.

Returns
A tuple of <return-value, token-chain>

This is a helper for lowering intrinsics that follow a target calling convention or require stack pointer adjustment. Only a subset of the intrinsic's operands need to participate in the calling convention.

Definition at line 6752 of file SelectionDAGBuilder.cpp.

References DAG, llvm::CallInst::getCallingConv(), llvm::SelectionDAG::getContext(), getCurSDLoc(), llvm::User::getOperand(), getRoot(), llvm::TargetMachine::getTargetLowering(), llvm::Value::getType(), getValue(), llvm::Type::getVoidTy(), llvm::Type::isEmptyTy(), llvm::TargetLowering::LowerCallTo(), llvm::TargetLowering::ArgListEntry::Node, and llvm::Value::use_empty().

void SelectionDAGBuilder::LowerCallTo ( ImmutableCallSite  CS,
SDValue  Callee,
bool  IsTailCall,
MachineBasicBlock LandingPad = NULL 
)

Definition at line 5342 of file SelectionDAGBuilder.cpp.

References llvm::ISD::ADD, llvm::MachineModuleInfo::addInvoke(), Align(), llvm::TargetLowering::ArgListEntry::Alignment, llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_begin(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_end(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_size(), llvm::TargetLowering::CanLowerReturn(), llvm::ComputeValueVTs(), llvm::MachineFrameInfo::CreateStackObject(), llvm::MCContext::CreateTempSymbol(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getAttributes(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledValue(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getCallingConv(), llvm::SelectionDAG::getConstant(), llvm::MachineModuleInfo::getContext(), getControlRoot(), llvm::MachineModuleInfo::getCurrentCallSite(), getCurSDLoc(), llvm::TargetLoweringBase::getDataLayout(), llvm::SelectionDAG::getEHLabel(), llvm::SequentialType::getElementType(), llvm::MachinePointerInfo::getFixedStack(), llvm::SelectionDAG::getFrameIndex(), llvm::MachineFunction::getFrameInfo(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getInstruction(), llvm::SelectionDAG::getLoad(), llvm::SelectionDAG::getMachineFunction(), llvm::MachineFunction::getMMI(), llvm::SelectionDAG::getNode(), llvm::TargetLoweringBase::getPointerTy(), llvm::DataLayout::getPrefTypeAlignment(), llvm::GetReturnInfo(), getRoot(), llvm::TargetMachine::getTargetLowering(), llvm::Value::getType(), llvm::DataLayout::getTypeAllocSize(), llvm::PointerType::getUnqual(), llvm::SDValue::getValue(), getValue(), llvm::Type::getVoidTy(), llvm::SelectionDAG::getVTList(), HasTailCall, llvm::TargetLowering::ArgListEntry::isByVal, llvm::Type::isEmptyTy(), llvm::TargetLowering::ArgListEntry::isInReg, llvm::isInTailCallPosition(), llvm::TargetLowering::ArgListEntry::isNest, llvm::TargetLowering::ArgListEntry::isReturned, llvm::TargetLowering::ArgListEntry::isSExt, llvm::TargetLowering::ArgListEntry::isSRet, llvm::TargetLowering::ArgListEntry::isZExt, llvm::TargetLowering::LowerCallTo(), LPadToCallSiteMap, llvm::ISD::MERGE_VALUES, llvm::TargetLowering::ArgListEntry::Node, llvm::MVT::Other, PendingLoads, llvm::TargetLowering::ArgListEntry::setAttributes(), llvm::MachineModuleInfo::setCallSiteBeginLabel(), llvm::MachineModuleInfo::setCurrentCallSite(), llvm::SelectionDAG::setRoot(), setValue(), llvm::SmallVectorTemplateCommon< T >::size(), llvm::ISD::TokenFactor, and llvm::TargetLowering::ArgListEntry::Ty.

void SelectionDAGBuilder::resolveDanglingDebugInfo ( const Value V,
SDValue  Val 
)
void llvm::SelectionDAGBuilder::setUnusedArgValue ( const Value V,
SDValue  NewN 
)
inline

Definition at line 603 of file SelectionDAGBuilder.h.

References llvm::SDValue::getNode(), and N.

void llvm::SelectionDAGBuilder::setValue ( const Value V,
SDValue  NewN 
)
inline

Definition at line 597 of file SelectionDAGBuilder.h.

References llvm::SDValue::getNode(), and N.

Referenced by LowerCallTo().

bool SelectionDAGBuilder::ShouldEmitAsBranches ( const std::vector< CaseBlock > &  Cases)

If the set of cases should be emitted as a series of branches, return true. If we should emit this as a bunch of and/or'd together conditions, return false.

Definition at line 1485 of file SelectionDAGBuilder.cpp.

References llvm::ISD::SETEQ, and llvm::ISD::SETNE.

void SelectionDAGBuilder::UpdateSplitBlock ( MachineBasicBlock First,
MachineBasicBlock Last 
)

UpdateSplitBlock - When an MBB was split during scheduling, update the references that ned to refer to the last resulting block.

Definition at line 2620 of file SelectionDAGBuilder.cpp.

References BitTestCases, and JTCases.

void SelectionDAGBuilder::visit ( const Instruction I)
void SelectionDAGBuilder::visit ( unsigned  Opcode,
const User I 
)

Definition at line 975 of file SelectionDAGBuilder.cpp.

References llvm_unreachable.

void SelectionDAGBuilder::visitBitTestCase ( BitTestBlock &  BB,
MachineBasicBlock NextMBB,
uint32_t  BranchWeightToNext,
unsigned  Reg,
BitTestCase &  B,
MachineBasicBlock SwitchBB 
)
void SelectionDAGBuilder::visitBitTestHeader ( BitTestBlock &  B,
MachineBasicBlock SwitchBB 
)
void SelectionDAGBuilder::visitJumpTable ( JumpTable &  JT)
void SelectionDAGBuilder::visitJumpTableHeader ( JumpTable &  JT,
JumpTableHeader &  JTH,
MachineBasicBlock SwitchBB 
)
void SelectionDAGBuilder::visitSPDescriptorFailure ( StackProtectorDescriptor &  SPD)

Codegen the failure basic block for a stack protector check.

A failure stack protector machine basic block consists simply of a call to __stack_chk_fail().

For a high level explanation of how this fits into the stack protector generation see the comment on the declaration of class StackProtectorDescriptor.

Definition at line 1809 of file SelectionDAGBuilder.cpp.

References getCurSDLoc(), llvm::TargetMachine::getTargetLowering(), llvm::MVT::isVoid, llvm::TargetLowering::makeLibCall(), llvm::SelectionDAG::setRoot(), and llvm::RTLIB::STACKPROTECTOR_CHECK_FAIL.

void SelectionDAGBuilder::visitSPDescriptorParent ( StackProtectorDescriptor &  SPD,
MachineBasicBlock ParentBB 
)
void SelectionDAGBuilder::visitSwitchCase ( CaseBlock &  CB,
MachineBasicBlock SwitchBB 
)

Member Data Documentation

AliasAnalysis* llvm::SelectionDAGBuilder::AA

Definition at line 493 of file SelectionDAGBuilder.h.

Referenced by getMemCmpLoad(), and init().

std::vector<BitTestBlock> llvm::SelectionDAGBuilder::BitTestCases

BitTestCases - Vector of BitTestBlock structures used to communicate SwitchInst code generation information.

Definition at line 504 of file SelectionDAGBuilder.h.

Referenced by UpdateSplitBlock().

DenseMap<const Constant *, unsigned> llvm::SelectionDAGBuilder::ConstantsOut

Definition at line 511 of file SelectionDAGBuilder.h.

LLVMContext* llvm::SelectionDAGBuilder::Context

Definition at line 533 of file SelectionDAGBuilder.h.

SelectionDAG& llvm::SelectionDAGBuilder::DAG

Definition at line 491 of file SelectionDAGBuilder.h.

Referenced by getMemCmpLoad(), and LowerCallOperands().

FunctionLoweringInfo& llvm::SelectionDAGBuilder::FuncInfo

FuncInfo - Information about the function as a whole.

Definition at line 515 of file SelectionDAGBuilder.h.

GCFunctionInfo* llvm::SelectionDAGBuilder::GFI

GFI - Garbage collection metadata for the function.

Definition at line 522 of file SelectionDAGBuilder.h.

Referenced by init().

bool llvm::SelectionDAGBuilder::HasTailCall

HasTailCall - This is set to true if a call in the current block has been translated as a tail call. In this case, no subsequent DAG nodes should be created.

Definition at line 531 of file SelectionDAGBuilder.h.

Referenced by clear(), LowerCallTo(), and visit().

std::vector<JumpTableBlock> llvm::SelectionDAGBuilder::JTCases

JTCases - Vector of JumpTable structures used to communicate SwitchInst code generation information.

Definition at line 501 of file SelectionDAGBuilder.h.

Referenced by UpdateSplitBlock().

const TargetLibraryInfo* llvm::SelectionDAGBuilder::LibInfo

Definition at line 494 of file SelectionDAGBuilder.h.

Referenced by init().

DenseMap<MachineBasicBlock*, SmallVector<unsigned, 4> > llvm::SelectionDAGBuilder::LPadToCallSiteMap

LPadToCallSiteMap - Map a landing pad to the call site indexes.

Definition at line 525 of file SelectionDAGBuilder.h.

Referenced by init(), and LowerCallTo().

CodeGenOpt::Level llvm::SelectionDAGBuilder::OptLevel

OptLevel - What optimization level we're generating code for.

Definition at line 519 of file SelectionDAGBuilder.h.

SmallVector<SDValue, 8> llvm::SelectionDAGBuilder::PendingLoads

PendingLoads - Loads are not emitted to the program immediately. We bunch them up and then emit token factor nodes when possible. This allows us to get simple disambiguation between loads without worrying about alias analysis.

Definition at line 116 of file SelectionDAGBuilder.h.

Referenced by clear(), getMemCmpLoad(), getRoot(), and LowerCallTo().

StackProtectorDescriptor llvm::SelectionDAGBuilder::SPDescriptor

A StackProtectorDescriptor structure used to communicate stack protector information in between SelectBasicBlock and FinishBasicBlock.

Definition at line 507 of file SelectionDAGBuilder.h.

std::vector<CaseBlock> llvm::SelectionDAGBuilder::SwitchCases

SwitchCases - Vector of CaseBlock structures used to communicate SwitchInst code generation information.

Definition at line 498 of file SelectionDAGBuilder.h.

Referenced by EmitBranchForMergedCondition().

const DataLayout* llvm::SelectionDAGBuilder::TD

Definition at line 492 of file SelectionDAGBuilder.h.

Referenced by getMemCmpLoad(), and init().


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