LLVM API Documentation

Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
llvm::FastISel Class Reference

This is a fast-path instruction selection class that generates poor code and doesn't support illegal types or non-trivial lowering, but runs quickly. More...

#include <FastISel.h>

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

List of all members.

Classes

struct  ArgListEntry
struct  CallLoweringInfo
struct  SavePoint

Public Types

typedef std::vector< ArgListEntryArgListTy

Public Member Functions

MachineInstrgetLastLocalValue ()
 Return the position of the last instruction emitted for materializing constants for use in the current block.
void setLastLocalValue (MachineInstr *I)
 Update the position of the last instruction emitted for materializing constants for use in the current block.
void startNewBlock ()
 Set the current block to which generated machine instructions will be appended, and clear the local CSE map.
DebugLoc getCurDebugLoc () const
 Return current debug location information.
bool lowerArguments ()
 Do "fast" instruction selection for function arguments and append the machine instructions to the current block. Returns true when successful.
bool selectInstruction (const Instruction *I)
 Do "fast" instruction selection for the given LLVM IR instruction and append the generated machine instructions to the current block. Returns true if selection was successful.
bool selectOperator (const User *I, unsigned Opcode)
 Do "fast" instruction selection for the given LLVM IR operator (Instruction or ConstantExpr), and append generated machine instructions to the current block. Return true if selection was successful.
unsigned getRegForValue (const Value *V)
 Create a virtual register and arrange for it to be assigned the value for the given LLVM value.
unsigned lookUpRegForValue (const Value *V)
 Look up the value to see if its value is already cached in a register. It may be defined by instructions across blocks or defined locally.
std::pair< unsigned, boolgetRegForGEPIndex (const Value *V)
 This is a wrapper around getRegForValue that also takes care of truncating or sign-extending the given getelementptr index value.
bool tryToFoldLoad (const LoadInst *LI, const Instruction *FoldInst)
 We're checking to see if we can fold LI into FoldInst. Note that we could have a sequence where multiple LLVM IR instructions are folded into the same machineinstr. For example we could have:
virtual bool tryToFoldLoadIntoMI (MachineInstr *, unsigned, const LoadInst *)
 The specified machine instr operand is a vreg, and that vreg is being provided by the specified load instruction. If possible, try to fold the load as an operand to the instruction, returning true if possible.
void recomputeInsertPt ()
 Reset InsertPt to prepare for inserting instructions into the current block.
void removeDeadCode (MachineBasicBlock::iterator I, MachineBasicBlock::iterator E)
 Remove all dead instructions between the I and E.
SavePoint enterLocalValueArea ()
 Prepare InsertPt to begin inserting instructions into the local value area and return the old insert position.
void leaveLocalValueArea (SavePoint Old)
 Reset InsertPt to the given old insert position.
virtual ~FastISel ()

Protected Member Functions

 FastISel (FunctionLoweringInfo &FuncInfo, const TargetLibraryInfo *LibInfo, bool SkipTargetIndependentISel=false)
virtual bool fastSelectInstruction (const Instruction *I)=0
 This method is called by target-independent code when the normal FastISel process fails to select an instruction. This gives targets a chance to emit code for anything that doesn't fit into FastISel's framework. It returns true if it was successful.
virtual bool fastLowerArguments ()
 This method is called by target-independent code to do target- specific argument lowering. It returns true if it was successful.
virtual bool fastLowerCall (CallLoweringInfo &CLI)
 This method is called by target-independent code to do target- specific call lowering. It returns true if it was successful.
virtual bool fastLowerIntrinsicCall (const IntrinsicInst *II)
 This method is called by target-independent code to do target- specific intrinsic lowering. It returns true if it was successful.
virtual unsigned fastEmit_ (MVT VT, MVT RetVT, unsigned Opcode)
 This method is called by target-independent code to request that an instruction with the given type and opcode be emitted.
virtual unsigned fastEmit_r (MVT VT, MVT RetVT, unsigned Opcode, unsigned Op0, bool Op0IsKill)
 This method is called by target-independent code to request that an instruction with the given type, opcode, and register operand be emitted.
virtual unsigned fastEmit_rr (MVT VT, MVT RetVT, unsigned Opcode, unsigned Op0, bool Op0IsKill, unsigned Op1, bool Op1IsKill)
 This method is called by target-independent code to request that an instruction with the given type, opcode, and register operands be emitted.
virtual unsigned fastEmit_ri (MVT VT, MVT RetVT, unsigned Opcode, unsigned Op0, bool Op0IsKill, uint64_t Imm)
 This method is called by target-independent code to request that an instruction with the given type, opcode, and register and immediate.
virtual unsigned fastEmit_rf (MVT VT, MVT RetVT, unsigned Opcode, unsigned Op0, bool Op0IsKill, const ConstantFP *FPImm)
 This method is called by target-independent code to request that an instruction with the given type, opcode, and register and floating-point immediate operands be emitted.
virtual unsigned fastEmit_rri (MVT VT, MVT RetVT, unsigned Opcode, unsigned Op0, bool Op0IsKill, unsigned Op1, bool Op1IsKill, uint64_t Imm)
 This method is called by target-independent code to request that an instruction with the given type, opcode, and register and immediate operands be emitted.
unsigned fastEmit_ri_ (MVT VT, unsigned Opcode, unsigned Op0, bool Op0IsKill, uint64_t Imm, MVT ImmType)
 This method is a wrapper of fastEmit_ri.
virtual unsigned fastEmit_i (MVT VT, MVT RetVT, unsigned Opcode, uint64_t Imm)
 This method is called by target-independent code to request that an instruction with the given type, opcode, and immediate operand be emitted.
virtual unsigned fastEmit_f (MVT VT, MVT RetVT, unsigned Opcode, const ConstantFP *FPImm)
 This method is called by target-independent code to request that an instruction with the given type, opcode, and floating-point immediate operand be emitted.
unsigned fastEmitInst_ (unsigned MachineInstOpcode, const TargetRegisterClass *RC)
 Emit a MachineInstr with no operands and a result register in the given register class.
unsigned fastEmitInst_r (unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill)
 Emit a MachineInstr with one register operand and a result register in the given register class.
unsigned fastEmitInst_rr (unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, unsigned Op1, bool Op1IsKill)
 Emit a MachineInstr with two register operands and a result register in the given register class.
unsigned fastEmitInst_rrr (unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, unsigned Op1, bool Op1IsKill, unsigned Op2, bool Op2IsKill)
 Emit a MachineInstr with three register operands and a result register in the given register class.
unsigned fastEmitInst_ri (unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, uint64_t Imm)
 Emit a MachineInstr with a register operand, an immediate, and a result register in the given register class.
unsigned fastEmitInst_rii (unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, uint64_t Imm1, uint64_t Imm2)
 Emit a MachineInstr with one register operand and two immediate operands.
unsigned fastEmitInst_rf (unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, const ConstantFP *FPImm)
 Emit a MachineInstr with two register operands and a result register in the given register class.
unsigned fastEmitInst_rri (unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, unsigned Op1, bool Op1IsKill, uint64_t Imm)
 Emit a MachineInstr with two register operands, an immediate, and a result register in the given register class.
unsigned fastEmitInst_rrii (unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, unsigned Op1, bool Op1IsKill, uint64_t Imm1, uint64_t Imm2)
 Emit a MachineInstr with two register operands, two immediates operands, and a result register in the given register class.
unsigned fastEmitInst_i (unsigned MachineInstrOpcode, const TargetRegisterClass *RC, uint64_t Imm)
 Emit a MachineInstr with a single immediate operand, and a result register in the given register class.
unsigned fastEmitInst_ii (unsigned MachineInstrOpcode, const TargetRegisterClass *RC, uint64_t Imm1, uint64_t Imm2)
 Emit a MachineInstr with a two immediate operands.
unsigned fastEmitInst_extractsubreg (MVT RetVT, unsigned Op0, bool Op0IsKill, uint32_t Idx)
 Emit a MachineInstr for an extract_subreg from a specified index of a superregister to a specified type.
unsigned fastEmitZExtFromI1 (MVT VT, unsigned Op0, bool Op0IsKill)
 Emit MachineInstrs to compute the value of Op with all but the least significant bit set to zero.
void fastEmitBranch (MachineBasicBlock *MBB, DebugLoc DL)
 Emit an unconditional branch to the given block, unless it is the immediate (fall-through) successor, and update the CFG.
void updateValueMap (const Value *I, unsigned Reg, unsigned NumRegs=1)
 Update the value map to include the new mapping for this instruction, or insert an extra copy to get the result in a previous determined register.
unsigned createResultReg (const TargetRegisterClass *RC)
unsigned constrainOperandRegClass (const MCInstrDesc &II, unsigned Op, unsigned OpNum)
 Try to constrain Op so that it is usable by argument OpNum of the provided MCInstrDesc. If this fails, create a new virtual register in the correct class and COPY the value there.
virtual unsigned fastMaterializeConstant (const Constant *C)
 Emit a constant in a register using target-specific logic, such as constant pool loads.
virtual unsigned fastMaterializeAlloca (const AllocaInst *C)
 Emit an alloca address in a register using target-specific logic.
virtual unsigned fastMaterializeFloatZero (const ConstantFP *CF)
 Emit the floating-point constant +0.0 in a register using target- specific logic.
bool canFoldAddIntoGEP (const User *GEP, const Value *Add)
 Check if Add is an add that can be safely folded into GEP.
bool hasTrivialKill (const Value *V)
 Test whether the given value has exactly one use.
MachineMemOperandcreateMachineMemOperandFor (const Instruction *I) const
 Create a machine mem operand from the given instruction.
CmpInst::Predicate optimizeCmpPredicate (const CmpInst *CI) const
bool lowerCallTo (const CallInst *CI, const char *SymName, unsigned NumArgs)
bool lowerCallTo (CallLoweringInfo &CLI)
bool isCommutativeIntrinsic (IntrinsicInst const *II)
bool lowerCall (const CallInst *I)
bool selectBinaryOp (const User *I, unsigned ISDOpcode)
 Select and emit code for a binary operator instruction, which has an opcode which directly corresponds to the given ISD opcode.
bool selectFNeg (const User *I)
 Emit an FNeg operation.
bool selectGetElementPtr (const User *I)
bool selectStackmap (const CallInst *I)
bool selectPatchpoint (const CallInst *I)
bool selectCall (const User *Call)
bool selectIntrinsicCall (const IntrinsicInst *II)
bool selectBitCast (const User *I)
bool selectCast (const User *I, unsigned Opcode)
bool selectExtractValue (const User *I)
bool selectInsertValue (const User *I)

Protected Attributes

DenseMap< const Value *, unsignedLocalValueMap
FunctionLoweringInfoFuncInfo
MachineFunctionMF
MachineRegisterInfoMRI
MachineFrameInfoMFI
MachineConstantPoolMCP
DebugLoc DbgLoc
const TargetMachineTM
const DataLayoutDL
const TargetInstrInfoTII
const TargetLoweringTLI
const TargetRegisterInfoTRI
const TargetLibraryInfoLibInfo
bool SkipTargetIndependentISel
MachineInstrLastLocalValue
 The position of the last instruction for materializing constants for use in the current block. It resets to EmitStartPt when it makes sense (for example, it's usually profitable to avoid function calls between the definition and the use)
MachineInstrEmitStartPt
 The top most instruction in the current block that is allowed for emitting local variables. LastLocalValue resets to EmitStartPt when it makes sense (for example, on function calls)

Detailed Description

This is a fast-path instruction selection class that generates poor code and doesn't support illegal types or non-trivial lowering, but runs quickly.

Definition at line 30 of file FastISel.h.


Member Typedef Documentation

Definition at line 54 of file FastISel.h.


Constructor & Destructor Documentation

FastISel::~FastISel ( ) [virtual]

Definition at line 1583 of file FastISel.cpp.

FastISel::FastISel ( FunctionLoweringInfo FuncInfo,
const TargetLibraryInfo LibInfo,
bool  SkipTargetIndependentISel = false 
) [explicit, protected]

Definition at line 1572 of file FastISel.cpp.


Member Function Documentation

bool FastISel::canFoldAddIntoGEP ( const User GEP,
const Value Add 
) [protected]

Check if Add is an add that can be safely folded into GEP.

Add can be folded into GEP if:

  • Add is an add,
  • Add's size matches GEP's,
  • Add is in the same basic block as GEP, and
  • Add has a constant operand.

Definition at line 2083 of file FastISel.cpp.

References DL, FuncInfo, getParent(), llvm::Value::getType(), llvm::DataLayout::getTypeSizeInBits(), llvm::FunctionLoweringInfo::MBB, and llvm::FunctionLoweringInfo::MBBMap.

Prepare InsertPt to begin inserting instructions into the local value area and return the old insert position.

Definition at line 362 of file FastISel.cpp.

References DbgLoc, FuncInfo, llvm::FunctionLoweringInfo::InsertPt, and recomputeInsertPt().

Referenced by getRegForValue().

unsigned FastISel::fastEmit_ ( MVT  VT,
MVT  RetVT,
unsigned  Opcode 
) [protected, virtual]

This method is called by target-independent code to request that an instruction with the given type and opcode be emitted.

Definition at line 1593 of file FastISel.cpp.

Referenced by selectOperator().

unsigned FastISel::fastEmit_f ( MVT  VT,
MVT  RetVT,
unsigned  Opcode,
const ConstantFP FPImm 
) [protected, virtual]

This method is called by target-independent code to request that an instruction with the given type, opcode, and floating-point immediate operand be emitted.

Definition at line 1610 of file FastISel.cpp.

unsigned FastISel::fastEmit_i ( MVT  VT,
MVT  RetVT,
unsigned  Opcode,
uint64_t  Imm 
) [protected, virtual]

This method is called by target-independent code to request that an instruction with the given type, opcode, and immediate operand be emitted.

Definition at line 1606 of file FastISel.cpp.

Referenced by fastEmit_ri_().

unsigned FastISel::fastEmit_r ( MVT  VT,
MVT  RetVT,
unsigned  Opcode,
unsigned  Op0,
bool  Op0IsKill 
) [protected, virtual]

This method is called by target-independent code to request that an instruction with the given type, opcode, and register operand be emitted.

Definition at line 1595 of file FastISel.cpp.

Referenced by getRegForGEPIndex(), selectBitCast(), selectCast(), and selectFNeg().

unsigned FastISel::fastEmit_rf ( MVT  VT,
MVT  RetVT,
unsigned  Opcode,
unsigned  Op0,
bool  Op0IsKill,
const ConstantFP FPImm 
) [protected, virtual]

This method is called by target-independent code to request that an instruction with the given type, opcode, and register and floating-point immediate operands be emitted.

Definition at line 1620 of file FastISel.cpp.

Referenced by selectBinaryOp().

unsigned FastISel::fastEmit_ri ( MVT  VT,
MVT  RetVT,
unsigned  Opcode,
unsigned  Op0,
bool  Op0IsKill,
uint64_t  Imm 
) [protected, virtual]

This method is called by target-independent code to request that an instruction with the given type, opcode, and register and immediate.

Definition at line 1615 of file FastISel.cpp.

Referenced by fastEmit_ri_(), and fastEmitZExtFromI1().

unsigned FastISel::fastEmit_ri_ ( MVT  VT,
unsigned  Opcode,
unsigned  Op0,
bool  Op0IsKill,
uint64_t  Imm,
MVT  ImmType 
) [protected]

This method is a wrapper of fastEmit_ri.

It first tries to emit an instruction with an immediate operand using fastEmit_ri. If that fails, it materializes the immediate into a register and try fastEmit_rr instead.

This method is a wrapper of fastEmit_ri. It first tries to emit an instruction with an immediate operand using fastEmit_ri. If that fails, it materializes the immediate into a register and try fastEmit_rr instead.

Definition at line 1636 of file FastISel.cpp.

References llvm::ISD::Constant, fastEmit_i(), fastEmit_ri(), fastEmit_rr(), llvm::FunctionLoweringInfo::Fn, FuncInfo, llvm::IntegerType::get(), llvm::ConstantInt::get(), llvm::Function::getContext(), getRegForValue(), llvm::MVT::getSizeInBits(), llvm::isPowerOf2_64(), llvm::Log2_64(), llvm::ISD::MUL, llvm::ISD::SHL, llvm::ISD::SRA, llvm::ISD::SRL, and llvm::ISD::UDIV.

Referenced by selectBinaryOp(), selectFNeg(), and selectGetElementPtr().

unsigned FastISel::fastEmit_rr ( MVT  VT,
MVT  RetVT,
unsigned  Opcode,
unsigned  Op0,
bool  Op0IsKill,
unsigned  Op1,
bool  Op1IsKill 
) [protected, virtual]

This method is called by target-independent code to request that an instruction with the given type, opcode, and register operands be emitted.

Definition at line 1600 of file FastISel.cpp.

Referenced by fastEmit_ri_(), selectBinaryOp(), and selectGetElementPtr().

unsigned FastISel::fastEmit_rri ( MVT  VT,
MVT  RetVT,
unsigned  Opcode,
unsigned  Op0,
bool  Op0IsKill,
unsigned  Op1,
bool  Op1IsKill,
uint64_t  Imm 
) [protected, virtual]

This method is called by target-independent code to request that an instruction with the given type, opcode, and register and immediate operands be emitted.

Definition at line 1626 of file FastISel.cpp.

void FastISel::fastEmitBranch ( MachineBasicBlock MSucc,
DebugLoc  DbgLoc 
) [protected]
unsigned FastISel::fastEmitInst_ ( unsigned  MachineInstOpcode,
const TargetRegisterClass RC 
) [protected]

Emit a MachineInstr with no operands and a result register in the given register class.

Definition at line 1693 of file FastISel.cpp.

References llvm::BuildMI(), createResultReg(), DbgLoc, FuncInfo, llvm::MCInstrInfo::get(), llvm::FunctionLoweringInfo::InsertPt, llvm::FunctionLoweringInfo::MBB, and TII.

unsigned FastISel::fastEmitInst_extractsubreg ( MVT  RetVT,
unsigned  Op0,
bool  Op0IsKill,
uint32_t  Idx 
) [protected]
unsigned FastISel::fastEmitInst_i ( unsigned  MachineInstrOpcode,
const TargetRegisterClass RC,
uint64_t  Imm 
) [protected]
unsigned FastISel::fastEmitInst_ii ( unsigned  MachineInstrOpcode,
const TargetRegisterClass RC,
uint64_t  Imm1,
uint64_t  Imm2 
) [protected]
unsigned FastISel::fastEmitInst_r ( unsigned  MachineInstOpcode,
const TargetRegisterClass RC,
unsigned  Op0,
bool  Op0IsKill 
) [protected]
unsigned FastISel::fastEmitInst_rf ( unsigned  MachineInstOpcode,
const TargetRegisterClass RC,
unsigned  Op0,
bool  Op0IsKill,
const ConstantFP FPImm 
) [protected]
unsigned FastISel::fastEmitInst_ri ( unsigned  MachineInstOpcode,
const TargetRegisterClass RC,
unsigned  Op0,
bool  Op0IsKill,
uint64_t  Imm 
) [protected]
unsigned FastISel::fastEmitInst_rii ( unsigned  MachineInstOpcode,
const TargetRegisterClass RC,
unsigned  Op0,
bool  Op0IsKill,
uint64_t  Imm1,
uint64_t  Imm2 
) [protected]
unsigned FastISel::fastEmitInst_rr ( unsigned  MachineInstOpcode,
const TargetRegisterClass RC,
unsigned  Op0,
bool  Op0IsKill,
unsigned  Op1,
bool  Op1IsKill 
) [protected]
unsigned FastISel::fastEmitInst_rri ( unsigned  MachineInstOpcode,
const TargetRegisterClass RC,
unsigned  Op0,
bool  Op0IsKill,
unsigned  Op1,
bool  Op1IsKill,
uint64_t  Imm 
) [protected]
unsigned FastISel::fastEmitInst_rrii ( unsigned  MachineInstOpcode,
const TargetRegisterClass RC,
unsigned  Op0,
bool  Op0IsKill,
unsigned  Op1,
bool  Op1IsKill,
uint64_t  Imm1,
uint64_t  Imm2 
) [protected]
unsigned FastISel::fastEmitInst_rrr ( unsigned  MachineInstOpcode,
const TargetRegisterClass RC,
unsigned  Op0,
bool  Op0IsKill,
unsigned  Op1,
bool  Op1IsKill,
unsigned  Op2,
bool  Op2IsKill 
) [protected]
unsigned FastISel::fastEmitZExtFromI1 ( MVT  VT,
unsigned  Op0,
bool  Op0IsKill 
) [protected]

Emit MachineInstrs to compute the value of Op with all but the least significant bit set to zero.

Definition at line 1948 of file FastISel.cpp.

References llvm::ISD::AND, and fastEmit_ri().

bool FastISel::fastLowerArguments ( ) [protected, virtual]

This method is called by target-independent code to do target- specific argument lowering. It returns true if it was successful.

Definition at line 1585 of file FastISel.cpp.

Referenced by lowerArguments().

bool FastISel::fastLowerCall ( CallLoweringInfo CLI) [protected, virtual]

This method is called by target-independent code to do target- specific call lowering. It returns true if it was successful.

Definition at line 1587 of file FastISel.cpp.

Referenced by lowerCallTo().

bool FastISel::fastLowerIntrinsicCall ( const IntrinsicInst II) [protected, virtual]

This method is called by target-independent code to do target- specific intrinsic lowering. It returns true if it was successful.

Definition at line 1589 of file FastISel.cpp.

Referenced by selectIntrinsicCall().

virtual unsigned llvm::FastISel::fastMaterializeAlloca ( const AllocaInst C) [inline, protected, virtual]

Emit an alloca address in a register using target-specific logic.

Definition at line 475 of file FastISel.h.

virtual unsigned llvm::FastISel::fastMaterializeConstant ( const Constant C) [inline, protected, virtual]

Emit a constant in a register using target-specific logic, such as constant pool loads.

Definition at line 472 of file FastISel.h.

virtual unsigned llvm::FastISel::fastMaterializeFloatZero ( const ConstantFP CF) [inline, protected, virtual]

Emit the floating-point constant +0.0 in a register using target- specific logic.

Definition at line 479 of file FastISel.h.

virtual bool llvm::FastISel::fastSelectInstruction ( const Instruction I) [protected, pure virtual]

This method is called by target-independent code when the normal FastISel process fails to select an instruction. This gives targets a chance to emit code for anything that doesn't fit into FastISel's framework. It returns true if it was successful.

Referenced by selectInstruction().

Return current debug location information.

Definition at line 223 of file FastISel.h.

References DbgLoc.

Return the position of the last instruction emitted for materializing constants for use in the current block.

Definition at line 209 of file FastISel.h.

References LastLocalValue.

Referenced by recomputeInsertPt().

This is a wrapper around getRegForValue that also takes care of truncating or sign-extending the given getelementptr index value.

Definition at line 313 of file FastISel.cpp.

References llvm::EVT::bitsGT(), llvm::EVT::bitsLT(), fastEmit_r(), llvm::EVT::getEVT(), llvm::TargetLoweringBase::getPointerTy(), getRegForValue(), llvm::EVT::getSimpleVT(), llvm::Value::getType(), hasTrivialKill(), llvm::ISD::SIGN_EXTEND, TLI, and llvm::ISD::TRUNCATE.

Referenced by selectGetElementPtr().

bool FastISel::hasTrivialKill ( const Value V) [protected]

Definition at line 503 of file FastISel.h.

References llvm::IntrinsicInst::getIntrinsicID().

Look up the value to see if its value is already cached in a register. It may be defined by instructions across blocks or defined locally.

Definition at line 283 of file FastISel.cpp.

References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::find(), FuncInfo, I, LocalValueMap, and llvm::FunctionLoweringInfo::ValueMap.

Referenced by getRegForValue(), hasTrivialKill(), and selectIntrinsicCall().

bool FastISel::lowerCall ( const CallInst I) [protected]
bool FastISel::lowerCallTo ( const CallInst CI,
const char *  SymName,
unsigned  NumArgs 
) [protected]

Definition at line 883 of file FastISel.cpp.

References llvm::ISD::InputArg::ArgVT, llvm::FastISel::CallLoweringInfo::Call, llvm::FastISel::CallLoweringInfo::CallConv, llvm::TargetLowering::CanLowerReturn(), llvm::FastISel::CallLoweringInfo::clearIns(), llvm::FastISel::CallLoweringInfo::clearOuts(), llvm::ComputeValueVTs(), llvm::FastISel::CallLoweringInfo::CS, DL, fastLowerCall(), llvm::ISD::InputArg::Flags, FuncInfo, llvm::TargetLowering::functionArgumentNeedsConsecutiveRegisters(), llvm::DataLayout::getABITypeAlignment(), llvm::FastISel::CallLoweringInfo::getArgs(), llvm::TargetLoweringBase::getByValTypeAlignment(), llvm::Type::getContext(), llvm::SequentialType::getElementType(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getInstruction(), llvm::TargetLoweringBase::getNumRegisters(), llvm::TargetLoweringBase::getRegisterType(), getReturnAttrs(), llvm::GetReturnInfo(), llvm::DataLayout::getTypeAllocSize(), I, llvm::FastISel::CallLoweringInfo::InRegs, llvm::FastISel::CallLoweringInfo::Ins, llvm::FastISel::CallLoweringInfo::IsInReg, llvm::FastISel::CallLoweringInfo::IsReturnValueUsed, llvm::FastISel::CallLoweringInfo::IsVarArg, llvm::FunctionLoweringInfo::MF, llvm::FastISel::CallLoweringInfo::NumResultRegs, llvm::FastISel::CallLoweringInfo::OutFlags, llvm::FastISel::CallLoweringInfo::OutVals, llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::FastISel::CallLoweringInfo::ResultReg, llvm::FastISel::CallLoweringInfo::RetSExt, llvm::FastISel::CallLoweringInfo::RetTy, llvm::FastISel::CallLoweringInfo::RetZExt, llvm::ISD::ArgFlagsTy::setByVal(), llvm::ISD::ArgFlagsTy::setByValAlign(), llvm::ISD::ArgFlagsTy::setByValSize(), llvm::ISD::ArgFlagsTy::setInAlloca(), llvm::ISD::ArgFlagsTy::setInConsecutiveRegs(), llvm::ISD::ArgFlagsTy::setInReg(), llvm::ISD::ArgFlagsTy::setNest(), llvm::ISD::ArgFlagsTy::setOrigAlign(), llvm::MachineInstr::setPhysRegsDeadExcept(), llvm::ISD::ArgFlagsTy::setSExt(), llvm::ISD::ArgFlagsTy::setSRet(), llvm::ISD::ArgFlagsTy::setZExt(), llvm::SmallVectorTemplateCommon< T >::size(), TLI, TRI, updateValueMap(), llvm::ISD::InputArg::Used, and llvm::ISD::InputArg::VT.

Remove all dead instructions between the I and E.

Definition at line 350 of file FastISel.cpp.

References llvm::RegState::Dead, llvm::MachineInstr::eraseFromParent(), I, and recomputeInsertPt().

Referenced by selectInstruction().

bool FastISel::selectBinaryOp ( const User I,
unsigned  ISDOpcode 
) [protected]
bool FastISel::selectBitCast ( const User I) [protected]
bool FastISel::selectCall ( const User Call) [protected]
bool FastISel::selectCast ( const User I,
unsigned  Opcode 
) [protected]
bool FastISel::selectFNeg ( const User I) [protected]

Do "fast" instruction selection for the given LLVM IR operator (Instruction or ConstantExpr), and append generated machine instructions to the current block. Return true if selection was successful.

Definition at line 1454 of file FastISel.cpp.

References llvm::ISD::ADD, llvm::Alloca, llvm::ISD::AND, llvm::APIntOps::And(), llvm::EVT::bitsGT(), llvm::EVT::bitsLT(), llvm::Call, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::count(), llvm::ExtractValue, llvm::ISD::FADD, fastEmit_(), fastEmitBranch(), llvm::ISD::FDIV, llvm::ISD::FMUL, llvm::ISD::FP_TO_SINT, llvm::FPToSI, llvm::ISD::FREM, llvm::ISD::FSUB, FuncInfo, llvm::Instruction::getDebugLoc(), llvm::User::getOperand(), getRegForValue(), llvm::BranchInst::getSuccessor(), llvm::Value::getType(), llvm::TargetLoweringBase::getValueType(), I, llvm::IntToPtr, llvm::BinaryOperator::isFNeg(), llvm::BranchInst::isUnconditional(), llvm_unreachable, llvm::LShr, llvm::FunctionLoweringInfo::MBBMap, llvm::ISD::MUL, llvm::TargetMachine::Options, llvm::ISD::OR, llvm::APIntOps::Or(), llvm::MVT::Other, llvm::TargetOpcode::PHI, llvm::ISD::SDIV, selectBinaryOp(), selectBitCast(), selectCall(), selectCast(), selectExtractValue(), selectFNeg(), selectGetElementPtr(), llvm::SExt, llvm::ISD::SHL, llvm::ISD::SIGN_EXTEND, llvm::ISD::SINT_TO_FP, llvm::SIToFP, llvm::ISD::SRA, llvm::ISD::SREM, llvm::ISD::SRL, llvm::FunctionLoweringInfo::StaticAllocaMap, llvm::ISD::SUB, TLI, TM, llvm::ISD::TRAP, llvm::TargetOptions::TrapUnreachable, llvm::Trunc, llvm::ISD::TRUNCATE, llvm::ISD::UDIV, updateValueMap(), llvm::ISD::UREM, llvm::ISD::XOR, llvm::APIntOps::Xor(), and llvm::ISD::ZERO_EXTEND.

Referenced by selectInstruction().

Definition at line 703 of file FastISel.cpp.

References llvm::MachineInstrBuilder::addOperand(), llvm::CallingConv::AnyReg, llvm::BuildMI(), llvm::CallingConv::C, llvm::FastISel::CallLoweringInfo::Call, llvm::PatchPointOpers::CCPos, llvm::MachineOperand::CreateImm(), llvm::MachineOperand::CreateReg(), llvm::MachineOperand::CreateRegMask(), createResultReg(), DbgLoc, llvm::MachineInstr::eraseFromParent(), FuncInfo, llvm::MCInstrInfo::get(), llvm::CallInst::getArgOperand(), llvm::CallInst::getCallingConv(), llvm::TargetRegisterInfo::getCallPreservedMask(), llvm::MachineFunction::getFrameInfo(), llvm::CallInst::getNumArgOperands(), llvm::User::getOperand(), llvm::TargetLoweringBase::getRegClassFor(), getRegForValue(), llvm::TargetLowering::getScratchRegisters(), llvm::Value::getType(), llvm::MVT::i64, llvm::PatchPointOpers::IDPos, llvm::FastISel::CallLoweringInfo::InRegs, llvm::IntToPtr, llvm::Type::isVoidTy(), llvm_unreachable, llvm::FunctionLoweringInfo::MBB, llvm::FunctionLoweringInfo::MF, llvm::PatchPointOpers::NArgPos, llvm::PatchPointOpers::NBytesPos, llvm::FastISel::CallLoweringInfo::NumResultRegs, llvm::FastISel::CallLoweringInfo::OutRegs, llvm::TargetOpcode::PATCHPOINT, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::FastISel::CallLoweringInfo::ResultReg, llvm::MachineFrameInfo::setHasPatchPoint(), llvm::MachineInstr::setPhysRegsDeadExcept(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::PatchPointOpers::TargetPos, TII, TLI, TRI, and updateValueMap().

Referenced by selectIntrinsicCall().

Update the position of the last instruction emitted for materializing constants for use in the current block.

Definition at line 213 of file FastISel.h.

References EmitStartPt, I, and LastLocalValue.

Set the current block to which generated machine instructions will be appended, and clear the local CSE map.

Definition at line 94 of file FastISel.cpp.

References llvm::MachineBasicBlock::back(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::clear(), EmitStartPt, llvm::MachineBasicBlock::empty(), FuncInfo, LastLocalValue, LocalValueMap, and llvm::FunctionLoweringInfo::MBB.

We're checking to see if we can fold LI into FoldInst. Note that we could have a sequence where multiple LLVM IR instructions are folded into the same machineinstr. For example we could have:

A: x = load i32 *P B: y = icmp A, 42 C: br y, ...

In this scenario, LI is "A", and FoldInst is "C". We know about "B" (and any other folded instructions) because it is between A and C.

If we succeed folding, return true.

Definition at line 2027 of file FastISel.cpp.

References FuncInfo, llvm::MachineRegisterInfo::defusechain_iterator< ReturnUses, ReturnDefs, SkipDebug, ByOperand, ByInstr, ByBundle >::getOperandNo(), llvm::Instruction::getParent(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getParent(), getRegForValue(), llvm::Value::hasOneUse(), llvm::MachineRegisterInfo::hasOneUse(), llvm::FunctionLoweringInfo::InsertPt, llvm::LoadInst::isVolatile(), LI, llvm::FunctionLoweringInfo::MBB, MRI, llvm::MachineRegisterInfo::reg_begin(), tryToFoldLoadIntoMI(), and llvm::Instruction::user_back().

virtual bool llvm::FastISel::tryToFoldLoadIntoMI ( MachineInstr ,
unsigned  ,
const LoadInst  
) [inline, virtual]

The specified machine instr operand is a vreg, and that vreg is being provided by the specified load instruction. If possible, try to fold the load as an operand to the instruction, returning true if possible.

This method should be implemented by targets.

Definition at line 273 of file FastISel.h.

Referenced by tryToFoldLoad().

void FastISel::updateValueMap ( const Value I,
unsigned  Reg,
unsigned  NumRegs = 1 
) [protected]

Update the value map to include the new mapping for this instruction, or insert an extra copy to get the result in a previous determined register.

NOTE: This is only necessary because we might select a block that uses a value before we select the block that defines the value. It might be possible to fix this by selecting blocks in reverse postorder.

Definition at line 294 of file FastISel.cpp.

References FuncInfo, I, LocalValueMap, llvm::FunctionLoweringInfo::RegFixups, and llvm::FunctionLoweringInfo::ValueMap.

Referenced by lowerCallTo(), selectBinaryOp(), selectBitCast(), selectCast(), selectExtractValue(), selectFNeg(), selectGetElementPtr(), selectIntrinsicCall(), selectOperator(), and selectPatchpoint().


Member Data Documentation

The top most instruction in the current block that is allowed for emitting local variables. LastLocalValue resets to EmitStartPt when it makes sense (for example, on function calls)

Definition at line 204 of file FastISel.h.

Referenced by setLastLocalValue(), and startNewBlock().

The position of the last instruction for materializing constants for use in the current block. It resets to EmitStartPt when it makes sense (for example, it's usually profitable to avoid function calls between the definition and the use)

Definition at line 199 of file FastISel.h.

Referenced by getLastLocalValue(), leaveLocalValueArea(), setLastLocalValue(), and startNewBlock().

Definition at line 192 of file FastISel.h.

Referenced by selectInstruction().

Definition at line 180 of file FastISel.h.

Referenced by lookUpRegForValue(), lowerArguments(), startNewBlock(), and updateValueMap().

Definition at line 185 of file FastISel.h.

Definition at line 182 of file FastISel.h.

Definition at line 184 of file FastISel.h.

Definition at line 193 of file FastISel.h.

Referenced by selectInstruction().


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