LLVM  6.0.0svn
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::FastISel Class Referenceabstract

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 "llvm/CodeGen/FastISel.h"

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

Classes

struct  CallLoweringInfo
 
struct  SavePoint
 

Public Types

using ArgListEntry = TargetLoweringBase::ArgListEntry
 
using ArgListTy = TargetLoweringBase::ArgListTy
 

Public Member Functions

virtual ~FastISel ()
 
MachineInstrgetLastLocalValue ()
 Return the position of the last instruction emitted for materializing constants for use in the current block. More...
 
void setLastLocalValue (MachineInstr *I)
 Update the position of the last instruction emitted for materializing constants for use in the current block. More...
 
void startNewBlock ()
 Set the current block to which generated machine instructions will be appended, and clear the local CSE map. More...
 
DebugLoc getCurDebugLoc () const
 Return current debug location information. More...
 
bool lowerArguments ()
 Do "fast" instruction selection for function arguments and append the machine instructions to the current block. More...
 
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. More...
 
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. More...
 
unsigned getRegForValue (const Value *V)
 Create a virtual register and arrange for it to be assigned the value for the given LLVM value. More...
 
unsigned lookUpRegForValue (const Value *V)
 Look up the value to see if its value is already cached in a register. More...
 
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. More...
 
bool tryToFoldLoad (const LoadInst *LI, const Instruction *FoldInst)
 We're checking to see if we can fold LI into FoldInst. More...
 
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. More...
 
void recomputeInsertPt ()
 Reset InsertPt to prepare for inserting instructions into the current block. More...
 
void removeDeadCode (MachineBasicBlock::iterator I, MachineBasicBlock::iterator E)
 Remove all dead instructions between the I and E. More...
 
SavePoint enterLocalValueArea ()
 Prepare InsertPt to begin inserting instructions into the local value area and return the old insert position. More...
 
void leaveLocalValueArea (SavePoint Old)
 Reset InsertPt to the given old insert position. More...
 

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. More...
 
virtual bool fastLowerArguments ()
 This method is called by target-independent code to do target- specific argument lowering. More...
 
virtual bool fastLowerCall (CallLoweringInfo &CLI)
 This method is called by target-independent code to do target- specific call lowering. More...
 
virtual bool fastLowerIntrinsicCall (const IntrinsicInst *II)
 This method is called by target-independent code to do target- specific intrinsic lowering. More...
 
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. More...
 
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. More...
 
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. More...
 
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 operands be emitted. More...
 
unsigned fastEmit_ri_ (MVT VT, unsigned Opcode, unsigned Op0, bool Op0IsKill, uint64_t Imm, MVT ImmType)
 This method is a wrapper of fastEmit_ri. More...
 
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. More...
 
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. More...
 
unsigned fastEmitInst_ (unsigned MachineInstOpcode, const TargetRegisterClass *RC)
 Emit a MachineInstr with no operands and a result register in the given register class. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
unsigned fastEmitInst_f (unsigned MachineInstOpcode, const TargetRegisterClass *RC, const ConstantFP *FPImm)
 Emit a MachineInstr with a floating point immediate, and a result register in the given register class. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
void fastEmitBranch (MachineBasicBlock *MBB, const DebugLoc &DL)
 Emit an unconditional branch to the given block, unless it is the immediate (fall-through) successor, and update the CFG. More...
 
void finishCondBranch (const BasicBlock *BranchBB, MachineBasicBlock *TrueMBB, MachineBasicBlock *FalseMBB)
 Emit an unconditional branch to FalseMBB, obtains the branch weight and adds TrueMBB and FalseMBB to the successor list. More...
 
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. More...
 
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. More...
 
virtual unsigned fastMaterializeConstant (const Constant *C)
 Emit a constant in a register using target-specific logic, such as constant pool loads. More...
 
virtual unsigned fastMaterializeAlloca (const AllocaInst *C)
 Emit an alloca address in a register using target-specific logic. More...
 
virtual unsigned fastMaterializeFloatZero (const ConstantFP *CF)
 Emit the floating-point constant +0.0 in a register using target- specific logic. More...
 
bool canFoldAddIntoGEP (const User *GEP, const Value *Add)
 Check if Add is an add that can be safely folded into GEP. More...
 
bool hasTrivialKill (const Value *V)
 Test whether the given value has exactly one use. More...
 
MachineMemOperandcreateMachineMemOperandFor (const Instruction *I) const
 Create a machine mem operand from the given instruction. More...
 
CmpInst::Predicate optimizeCmpPredicate (const CmpInst *CI) const
 
bool lowerCallTo (const CallInst *CI, MCSymbol *Symbol, unsigned NumArgs)
 
bool lowerCallTo (const CallInst *CI, const char *SymbolName, 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. More...
 
bool selectFNeg (const User *I)
 Emit an FNeg operation. More...
 
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)
 
bool selectXRayCustomEvent (const CallInst *II)
 

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. More...
 
MachineInstrEmitStartPt
 The top most instruction in the current block that is allowed for emitting local variables. More...
 

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 67 of file FastISel.h.

Member Typedef Documentation

◆ ArgListEntry

Definition at line 69 of file FastISel.h.

◆ ArgListTy

Definition at line 70 of file FastISel.h.

Constructor & Destructor Documentation

◆ ~FastISel()

FastISel::~FastISel ( )
virtualdefault

Referenced by FastISel().

◆ FastISel()

FastISel::FastISel ( FunctionLoweringInfo FuncInfo,
const TargetLibraryInfo LibInfo,
bool  SkipTargetIndependentISel = false 
)
explicitprotected

Definition at line 1698 of file FastISel.cpp.

References ~FastISel().

Member Function Documentation

◆ canFoldAddIntoGEP()

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 2151 of file FastISel.cpp.

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

Referenced by fastMaterializeFloatZero().

◆ constrainOperandRegClass()

unsigned FastISel::constrainOperandRegClass ( const MCInstrDesc II,
unsigned  Op,
unsigned  OpNum 
)
protected

◆ createMachineMemOperandFor()

MachineMemOperand * FastISel::createMachineMemOperandFor ( const Instruction I) const
protected

◆ createResultReg()

unsigned FastISel::createResultReg ( const TargetRegisterClass RC)
protected

◆ enterLocalValueArea()

FastISel::SavePoint FastISel::enterLocalValueArea ( )

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

Definition at line 388 of file FastISel.cpp.

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

Referenced by getRegForValue().

◆ fastEmit_()

unsigned FastISel::fastEmit_ ( MVT  VT,
MVT  RetVT,
unsigned  Opcode 
)
protectedvirtual

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

Definition at line 1719 of file FastISel.cpp.

Referenced by selectOperator().

◆ fastEmit_f()

unsigned FastISel::fastEmit_f ( MVT  VT,
MVT  RetVT,
unsigned  Opcode,
const ConstantFP FPImm 
)
protectedvirtual

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 1736 of file FastISel.cpp.

Referenced by getRegForValue().

◆ fastEmit_i()

unsigned FastISel::fastEmit_i ( MVT  VT,
MVT  RetVT,
unsigned  Opcode,
uint64_t  Imm 
)
protectedvirtual

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 1732 of file FastISel.cpp.

Referenced by fastEmit_ri_(), and getRegForValue().

◆ fastEmit_r()

unsigned FastISel::fastEmit_r ( MVT  VT,
MVT  RetVT,
unsigned  Opcode,
unsigned  Op0,
bool  Op0IsKill 
)
protectedvirtual

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 1721 of file FastISel.cpp.

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

◆ fastEmit_ri()

unsigned FastISel::fastEmit_ri ( MVT  VT,
MVT  RetVT,
unsigned  Opcode,
unsigned  Op0,
bool  Op0IsKill,
uint64_t  Imm 
)
protectedvirtual

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 1741 of file FastISel.cpp.

Referenced by fastEmit_ri_(), and fastEmitZExtFromI1().

◆ fastEmit_ri_()

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.

Definition at line 1750 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().

◆ fastEmit_rr()

unsigned FastISel::fastEmit_rr ( MVT  VT,
MVT  RetVT,
unsigned  Opcode,
unsigned  Op0,
bool  Op0IsKill,
unsigned  Op1,
bool  Op1IsKill 
)
protectedvirtual

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 1726 of file FastISel.cpp.

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

◆ fastEmitBranch()

void FastISel::fastEmitBranch ( MachineBasicBlock MSucc,
const DebugLoc DbgLoc 
)
protected

◆ fastEmitInst_()

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 1814 of file FastISel.cpp.

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

◆ fastEmitInst_extractsubreg()

unsigned FastISel::fastEmitInst_extractsubreg ( MVT  RetVT,
unsigned  Op0,
bool  Op0IsKill,
uint32_t  Idx 
)
protected

◆ fastEmitInst_f()

unsigned FastISel::fastEmitInst_f ( unsigned  MachineInstOpcode,
const TargetRegisterClass RC,
const ConstantFP FPImm 
)
protected

◆ fastEmitInst_i()

unsigned FastISel::fastEmitInst_i ( unsigned  MachineInstrOpcode,
const TargetRegisterClass RC,
uint64_t  Imm 
)
protected

◆ fastEmitInst_r()

unsigned FastISel::fastEmitInst_r ( unsigned  MachineInstOpcode,
const TargetRegisterClass RC,
unsigned  Op0,
bool  Op0IsKill 
)
protected

◆ fastEmitInst_ri()

unsigned FastISel::fastEmitInst_ri ( unsigned  MachineInstOpcode,
const TargetRegisterClass RC,
unsigned  Op0,
bool  Op0IsKill,
uint64_t  Imm 
)
protected

◆ fastEmitInst_rii()

unsigned FastISel::fastEmitInst_rii ( unsigned  MachineInstOpcode,
const TargetRegisterClass RC,
unsigned  Op0,
bool  Op0IsKill,
uint64_t  Imm1,
uint64_t  Imm2 
)
protected

◆ fastEmitInst_rr()

unsigned FastISel::fastEmitInst_rr ( unsigned  MachineInstOpcode,
const TargetRegisterClass RC,
unsigned  Op0,
bool  Op0IsKill,
unsigned  Op1,
bool  Op1IsKill 
)
protected

◆ fastEmitInst_rri()

unsigned FastISel::fastEmitInst_rri ( unsigned  MachineInstOpcode,
const TargetRegisterClass RC,
unsigned  Op0,
bool  Op0IsKill,
unsigned  Op1,
bool  Op1IsKill,
uint64_t  Imm 
)
protected

◆ fastEmitInst_rrr()

unsigned FastISel::fastEmitInst_rrr ( unsigned  MachineInstOpcode,
const TargetRegisterClass RC,
unsigned  Op0,
bool  Op0IsKill,
unsigned  Op1,
bool  Op1IsKill,
unsigned  Op2,
bool  Op2IsKill 
)
protected

◆ fastEmitZExtFromI1()

unsigned FastISel::fastEmitZExtFromI1 ( MVT  VT,
unsigned  Op0,
bool  Op0IsKill 
)
protected

◆ fastLowerArguments()

bool FastISel::fastLowerArguments ( )
protectedvirtual

This method is called by target-independent code to do target- specific argument lowering.

It returns true if it was successful.

Definition at line 1711 of file FastISel.cpp.

Referenced by lowerArguments().

◆ fastLowerCall()

bool FastISel::fastLowerCall ( CallLoweringInfo CLI)
protectedvirtual

This method is called by target-independent code to do target- specific call lowering.

It returns true if it was successful.

Definition at line 1713 of file FastISel.cpp.

Referenced by lowerCallTo().

◆ fastLowerIntrinsicCall()

bool FastISel::fastLowerIntrinsicCall ( const IntrinsicInst II)
protectedvirtual

This method is called by target-independent code to do target- specific intrinsic lowering.

It returns true if it was successful.

Definition at line 1715 of file FastISel.cpp.

Referenced by selectIntrinsicCall().

◆ fastMaterializeAlloca()

virtual unsigned llvm::FastISel::fastMaterializeAlloca ( const AllocaInst C)
inlineprotectedvirtual

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

Definition at line 478 of file FastISel.h.

Referenced by getRegForValue().

◆ fastMaterializeConstant()

virtual unsigned llvm::FastISel::fastMaterializeConstant ( const Constant C)
inlineprotectedvirtual

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

Definition at line 475 of file FastISel.h.

Referenced by getRegForValue().

◆ fastMaterializeFloatZero()

virtual unsigned llvm::FastISel::fastMaterializeFloatZero ( const ConstantFP CF)
inlineprotectedvirtual

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

Definition at line 482 of file FastISel.h.

References llvm::MCID::Add, canFoldAddIntoGEP(), createMachineMemOperandFor(), GEP, hasTrivialKill(), lowerCallTo(), optimizeCmpPredicate(), llvm::FastISel::CallLoweringInfo::Symbol, and llvm::AMDGPU::HSAMD::Kernel::Key::SymbolName.

Referenced by getRegForValue().

◆ fastSelectInstruction()

virtual bool llvm::FastISel::fastSelectInstruction ( const Instruction I)
protectedpure 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 getRegForValue(), and selectInstruction().

◆ finishCondBranch()

void FastISel::finishCondBranch ( const BasicBlock BranchBB,
MachineBasicBlock TrueMBB,
MachineBasicBlock FalseMBB 
)
protected

◆ getCurDebugLoc()

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

Return current debug location information.

Definition at line 248 of file FastISel.h.

References DbgLoc, getRegForGEPIndex(), getRegForValue(), I, lookUpRegForValue(), lowerArguments(), selectInstruction(), selectOperator(), and tryToFoldLoad().

◆ getLastLocalValue()

MachineInstr* llvm::FastISel::getLastLocalValue ( )
inline

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

Definition at line 234 of file FastISel.h.

References LastLocalValue.

Referenced by recomputeInsertPt(), selectBitCast(), and selectInstruction().

◆ getRegForGEPIndex()

std::pair< unsigned, bool > FastISel::getRegForGEPIndex ( const Value V)

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

Definition at line 338 of file FastISel.cpp.

References llvm::EVT::bitsGT(), llvm::EVT::bitsLT(), DL, 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 getCurDebugLoc(), and selectGetElementPtr().

◆ getRegForValue()

unsigned FastISel::getRegForValue ( const Value V)

Create a virtual register and arrange for it to be assigned the value for the given LLVM value.

Definition at line 195 of file FastISel.cpp.

References llvm::BuildMI(), llvm::ISD::Constant, llvm::ISD::ConstantFP, llvm::APFloat::convertToInteger(), createResultReg(), DbgLoc, DL, enterLocalValueArea(), fastEmit_f(), fastEmit_i(), fastEmit_r(), fastMaterializeAlloca(), fastMaterializeConstant(), fastMaterializeFloatZero(), fastSelectInstruction(), FuncInfo, llvm::MCInstrInfo::get(), llvm::ConstantInt::get(), llvm::Value::getContext(), llvm::DataLayout::getIntPtrType(), llvm::Constant::getNullValue(), llvm::TargetLoweringBase::getPointerTy(), llvm::TargetLoweringBase::getRegClassFor(), llvm::EVT::getSimpleVT(), llvm::EVT::getSizeInBits(), llvm::Value::getType(), llvm::TargetLoweringBase::getTypeToTransformTo(), llvm::TargetLoweringBase::getValueType(), llvm::MachineRegisterInfo::getVRegDef(), llvm::MVT::i1, llvm::MVT::i16, llvm::MVT::i8, llvm::FunctionLoweringInfo::InitializeRegForValue(), llvm::FunctionLoweringInfo::InsertPt, llvm::EVT::isSimple(), llvm::TargetLoweringBase::isTypeLegal(), LastLocalValue, leaveLocalValueArea(), LocalValueMap, lookUpRegForValue(), llvm::FunctionLoweringInfo::MBB, MRI, llvm::APFloatBase::rmTowardZero, selectOperator(), llvm::ISD::SINT_TO_FP, llvm::FunctionLoweringInfo::StaticAllocaMap, TII, and TLI.

Referenced by fastEmit_ri_(), fastEmitZExtFromI1(), getCurDebugLoc(), getRegForGEPIndex(), selectBinaryOp(), selectBitCast(), selectCast(), selectFNeg(), selectGetElementPtr(), selectIntrinsicCall(), selectOperator(), selectPatchpoint(), selectXRayCustomEvent(), and tryToFoldLoad().

◆ hasTrivialKill()

bool FastISel::hasTrivialKill ( const Value V)
protected

◆ isCommutativeIntrinsic()

bool llvm::FastISel::isCommutativeIntrinsic ( IntrinsicInst const II)
inlineprotected

◆ leaveLocalValueArea()

void FastISel::leaveLocalValueArea ( SavePoint  Old)

◆ lookUpRegForValue()

unsigned FastISel::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.

Definition at line 308 of file FastISel.cpp.

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

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

◆ lowerArguments()

bool FastISel::lowerArguments ( )

◆ lowerCall()

bool FastISel::lowerCall ( const CallInst I)
protected

◆ lowerCallTo() [1/3]

bool FastISel::lowerCallTo ( const CallInst CI,
MCSymbol Symbol,
unsigned  NumArgs 
)
protected

◆ lowerCallTo() [2/3]

bool FastISel::lowerCallTo ( const CallInst CI,
const char SymbolName,
unsigned  NumArgs 
)
protected

◆ lowerCallTo() [3/3]

bool FastISel::lowerCallTo ( CallLoweringInfo CLI)
protected

Definition at line 937 of file FastISel.cpp.

References Arg, llvm::ISD::InputArg::ArgVT, assert(), 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, E, fastLowerCall(), llvm::ISD::InputArg::Flags, FuncInfo, llvm::TargetLowering::functionArgumentNeedsConsecutiveRegisters(), llvm::DataLayout::getABITypeAlignment(), llvm::FastISel::CallLoweringInfo::getArgs(), llvm::TargetLoweringBase::getByValTypeAlignment(), llvm::Type::getContext(), llvm::PointerType::getElementType(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, 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::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::setSwiftError(), llvm::ISD::ArgFlagsTy::setSwiftSelf(), llvm::ISD::ArgFlagsTy::setZExt(), llvm::SmallVectorTemplateCommon< T >::size(), TLI, TRI, updateValueMap(), llvm::ISD::InputArg::Used, and llvm::ISD::InputArg::VT.

◆ optimizeCmpPredicate()

CmpInst::Predicate FastISel::optimizeCmpPredicate ( const CmpInst CI) const
protected

◆ recomputeInsertPt()

void FastISel::recomputeInsertPt ( )

◆ removeDeadCode()

void FastISel::removeDeadCode ( MachineBasicBlock::iterator  I,
MachineBasicBlock::iterator  E 
)

◆ selectBinaryOp()

bool FastISel::selectBinaryOp ( const User I,
unsigned  ISDOpcode 
)
protected

◆ selectBitCast()

bool FastISel::selectBitCast ( const User I)
protected

◆ selectCall()

bool FastISel::selectCall ( const User Call)
protected

◆ selectCast()

bool FastISel::selectCast ( const User I,
unsigned  Opcode 
)
protected

◆ selectExtractValue()

bool FastISel::selectExtractValue ( const User I)
protected

◆ selectFNeg()

bool FastISel::selectFNeg ( const User I)
protected

◆ selectGetElementPtr()

bool FastISel::selectGetElementPtr ( const User I)
protected

◆ selectInsertValue()

bool llvm::FastISel::selectInsertValue ( const User I)
protected

Referenced by isCommutativeIntrinsic().

◆ selectInstruction()

bool FastISel::selectInstruction ( const Instruction I)

◆ selectIntrinsicCall()

bool FastISel::selectIntrinsicCall ( const IntrinsicInst II)
protected

◆ selectOperator()

bool FastISel::selectOperator ( const User I,
unsigned  Opcode 
)

◆ selectPatchpoint()

bool FastISel::selectPatchpoint ( const CallInst I)
protected

Definition at line 725 of file FastISel.cpp.

References llvm::MachineInstrBuilder::add(), llvm::CallingConv::AnyReg, assert(), llvm::BuildMI(), C, llvm::FastISel::CallLoweringInfo::Call, llvm::PatchPointOpers::CCPos, llvm::MachineOperand::CreateGA(), 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::Instruction::getOpcode(), llvm::User::getOperand(), llvm::TargetLoweringBase::getRegClassFor(), getRegForValue(), llvm::TargetLowering::getScratchRegisters(), llvm::Value::getType(), llvm::MVT::i64, llvm::PatchPointOpers::IDPos, llvm::FastISel::CallLoweringInfo::InRegs, 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::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::FastISel::CallLoweringInfo::ResultReg, llvm::MachineFrameInfo::setHasPatchPoint(), llvm::FastISel::CallLoweringInfo::setIsPatchPoint(), llvm::MachineInstr::setPhysRegsDeadExcept(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::Value::stripPointerCasts(), llvm::PatchPointOpers::TargetPos, TII, TLI, TRI, and updateValueMap().

Referenced by isCommutativeIntrinsic(), and selectIntrinsicCall().

◆ selectStackmap()

bool FastISel::selectStackmap ( const CallInst I)
protected

◆ selectXRayCustomEvent()

bool FastISel::selectXRayCustomEvent ( const CallInst II)
protected

◆ setLastLocalValue()

void llvm::FastISel::setLastLocalValue ( MachineInstr I)
inline

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

Definition at line 238 of file FastISel.h.

References I, and startNewBlock().

Referenced by createSwiftErrorEntriesInEntryBlock(), preassignSwiftErrorRegs(), and selectBitCast().

◆ startNewBlock()

void FastISel::startNewBlock ( )

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

Definition at line 124 of file FastISel.cpp.

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

Referenced by preassignSwiftErrorRegs(), and setLastLocalValue().

◆ tryToFoldLoad()

bool FastISel::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:

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 2095 of file FastISel.cpp.

References assert(), 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(), llvm::FunctionLoweringInfo::MBB, MRI, llvm::MachineRegisterInfo::reg_begin(), tryToFoldLoadIntoMI(), and llvm::Instruction::user_back().

Referenced by getCurDebugLoc(), and preassignSwiftErrorRegs().

◆ tryToFoldLoadIntoMI()

virtual bool llvm::FastISel::tryToFoldLoadIntoMI ( MachineInstr ,
unsigned  ,
const LoadInst  
)
inlinevirtual

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 298 of file FastISel.h.

References E, recomputeInsertPt(), and removeDeadCode().

Referenced by tryToFoldLoad().

◆ updateValueMap()

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 319 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

◆ DbgLoc

DebugLoc llvm::FastISel::DbgLoc
protected

◆ DL

const DataLayout& llvm::FastISel::DL
protected

◆ EmitStartPt

MachineInstr* llvm::FastISel::EmitStartPt
protected

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 227 of file FastISel.h.

Referenced by lowerArguments(), and startNewBlock().

◆ FuncInfo

FunctionLoweringInfo& llvm::FastISel::FuncInfo
protected

◆ LastLocalValue

MachineInstr* llvm::FastISel::LastLocalValue
protected

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 222 of file FastISel.h.

Referenced by getLastLocalValue(), getRegForValue(), leaveLocalValueArea(), lowerArguments(), and startNewBlock().

◆ LibInfo

const TargetLibraryInfo* llvm::FastISel::LibInfo
protected

Definition at line 215 of file FastISel.h.

Referenced by selectInstruction().

◆ LocalValueMap

DenseMap<const Value *, unsigned> llvm::FastISel::LocalValueMap
protected

◆ MCP

MachineConstantPool& llvm::FastISel::MCP
protected

Definition at line 208 of file FastISel.h.

◆ MF

MachineFunction* llvm::FastISel::MF
protected

Definition at line 205 of file FastISel.h.

Referenced by lowerCallTo().

◆ MFI

MachineFrameInfo& llvm::FastISel::MFI
protected

Definition at line 207 of file FastISel.h.

◆ MRI

MachineRegisterInfo& llvm::FastISel::MRI
protected

◆ SkipTargetIndependentISel

bool llvm::FastISel::SkipTargetIndependentISel
protected

Definition at line 216 of file FastISel.h.

Referenced by selectInstruction().

◆ TII

const TargetInstrInfo& llvm::FastISel::TII
protected

◆ TLI

const TargetLowering& llvm::FastISel::TLI
protected

◆ TM

const TargetMachine& llvm::FastISel::TM
protected

Definition at line 210 of file FastISel.h.

Referenced by lowerCall(), selectOperator(), and selectXRayCustomEvent().

◆ TRI

const TargetRegisterInfo& llvm::FastISel::TRI
protected

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