LLVM 22.0.0git
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"

Classes

struct  CallLoweringInfo

Public Types

using ArgListEntry = TargetLoweringBase::ArgListEntry
using ArgListTy = TargetLoweringBase::ArgListTy
using SavePoint = MachineBasicBlock::iterator

Public Member Functions

virtual ~FastISel ()
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.
void finishBasicBlock ()
 Flush the local value 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.
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.
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.
Register getRegForValue (const Value *V)
 Create a virtual register and arrange for it to be assigned the value for the given LLVM value.
Register lookUpRegForValue (const Value *V)
 Look up the value to see if its value is already cached in a register.
Register getRegForGEPIndex (MVT PtrVT, const Value *Idx)
 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.
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.
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.
void handleDbgInfo (const Instruction *II)
 Target-independent lowering of non-instruction debug info associated with this instruction.

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.
virtual bool fastLowerArguments ()
 This method is called by target-independent code to do target- specific argument lowering.
virtual bool fastLowerCall (CallLoweringInfo &CLI)
 This method is called by target-independent code to do target- specific call lowering.
virtual bool fastLowerIntrinsicCall (const IntrinsicInst *II)
 This method is called by target-independent code to do target- specific intrinsic lowering.
virtual Register 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 Register fastEmit_r (MVT VT, MVT RetVT, unsigned Opcode, Register Op0)
 This method is called by target-independent code to request that an instruction with the given type, opcode, and register operand be emitted.
virtual Register fastEmit_rr (MVT VT, MVT RetVT, unsigned Opcode, Register Op0, Register Op1)
 This method is called by target-independent code to request that an instruction with the given type, opcode, and register operands be emitted.
virtual Register fastEmit_ri (MVT VT, MVT RetVT, unsigned Opcode, Register Op0, 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.
Register fastEmit_ri_ (MVT VT, unsigned Opcode, Register Op0, uint64_t Imm, MVT ImmType)
 This method is a wrapper of fastEmit_ri.
virtual Register 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 Register 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.
Register fastEmitInst_ (unsigned MachineInstOpcode, const TargetRegisterClass *RC)
 Emit a MachineInstr with no operands and a result register in the given register class.
Register fastEmitInst_r (unsigned MachineInstOpcode, const TargetRegisterClass *RC, Register Op0)
 Emit a MachineInstr with one register operand and a result register in the given register class.
Register fastEmitInst_rr (unsigned MachineInstOpcode, const TargetRegisterClass *RC, Register Op0, Register Op1)
 Emit a MachineInstr with two register operands and a result register in the given register class.
Register fastEmitInst_rrr (unsigned MachineInstOpcode, const TargetRegisterClass *RC, Register Op0, Register Op1, Register Op2)
 Emit a MachineInstr with three register operands and a result register in the given register class.
Register fastEmitInst_ri (unsigned MachineInstOpcode, const TargetRegisterClass *RC, Register Op0, uint64_t Imm)
 Emit a MachineInstr with a register operand, an immediate, and a result register in the given register class.
Register fastEmitInst_rii (unsigned MachineInstOpcode, const TargetRegisterClass *RC, Register Op0, uint64_t Imm1, uint64_t Imm2)
 Emit a MachineInstr with one register operand and two immediate operands.
Register 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.
Register fastEmitInst_rri (unsigned MachineInstOpcode, const TargetRegisterClass *RC, Register Op0, Register Op1, uint64_t Imm)
 Emit a MachineInstr with two register operands, an immediate, and a result register in the given register class.
Register fastEmitInst_i (unsigned MachineInstOpcode, const TargetRegisterClass *RC, uint64_t Imm)
 Emit a MachineInstr with a single immediate operand, and a result register in the given register class.
Register fastEmitInst_extractsubreg (MVT RetVT, Register Op0, uint32_t Idx)
 Emit a MachineInstr for an extract_subreg from a specified index of a superregister to a specified type.
Register fastEmitZExtFromI1 (MVT VT, Register Op0)
 Emit MachineInstrs to compute the value of Op with all but the least significant bit set to zero.
void fastEmitBranch (MachineBasicBlock *MSucc, const DebugLoc &DbgLoc)
 Emit an unconditional branch to the given block, unless it is the immediate (fall-through) successor, and update the CFG.
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.
void updateValueMap (const Value *I, Register 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.
Register createResultReg (const TargetRegisterClass *RC)
Register constrainOperandRegClass (const MCInstrDesc &II, Register Op, unsigned OpNum)
 Try to constrain Op so that it is usable by argument OpNum of the provided MCInstrDesc.
virtual Register fastMaterializeConstant (const Constant *C)
 Emit a constant in a register using target-specific logic, such as constant pool loads.
virtual Register fastMaterializeAlloca (const AllocaInst *C)
 Emit an alloca address in a register using target-specific logic.
virtual Register 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.
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, MCSymbol *Symbol, unsigned NumArgs)
bool lowerCallTo (const CallInst *CI, const char *SymName, unsigned NumArgs)
bool lowerCallTo (CallLoweringInfo &CLI)
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, const Value *In)
 Emit an FNeg operation.
bool selectGetElementPtr (const User *I)
bool selectStackmap (const CallInst *I)
bool selectPatchpoint (const CallInst *I)
bool selectCall (const User *I)
bool selectIntrinsicCall (const IntrinsicInst *II)
bool selectBitCast (const User *I)
bool selectFreeze (const User *I)
bool selectCast (const User *I, unsigned Opcode)
bool selectExtractValue (const User *U)
bool selectXRayCustomEvent (const CallInst *II)
bool selectXRayTypedEvent (const CallInst *II)
bool shouldOptForSize (const MachineFunction *MF) const
virtual bool lowerDbgValue (const Value *V, DIExpression *Expr, DILocalVariable *Var, const DebugLoc &DL)
 Target-independent lowering of debug information.
virtual bool lowerDbgDeclare (const Value *V, DIExpression *Expr, DILocalVariable *Var, const DebugLoc &DL)
 Target-independent lowering of debug information.

Protected Attributes

DenseMap< const Value *, RegisterLocalValueMap
FunctionLoweringInfoFuncInfo
MachineFunctionMF
MachineRegisterInfoMRI
MachineFrameInfoMFI
MachineConstantPoolMCP
MIMetadata MIMD
const TargetMachineTM
const DataLayoutDL
const TargetInstrInfoTII
const TargetLoweringTLI
const TargetRegisterInfoTRI
const TargetLibraryInfoLibInfo
bool SkipTargetIndependentISel
MachineInstrLastLocalValue = nullptr
 The position of the last instruction for materializing constants for use in the current block.
MachineInstrEmitStartPt = nullptr
 The top most instruction in the current block that is allowed for emitting local variables.

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

Member Typedef Documentation

◆ ArgListEntry

◆ ArgListTy

◆ SavePoint

Constructor & Destructor Documentation

◆ ~FastISel()

FastISel::~FastISel ( )
virtualdefault

◆ FastISel()

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

Definition at line 1875 of file FastISel.cpp.

References DL, FuncInfo, LibInfo, MCP, MF, MFI, MRI, SkipTargetIndependentISel, TII, TLI, TM, and TRI.

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

References llvm::Add, llvm::cast(), DL, FuncInfo, GEP, and llvm::isa().

◆ constrainOperandRegClass()

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

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.

Definition at line 1964 of file FastISel.cpp.

References llvm::MachineInstrBuilder::addReg(), llvm::BuildMI(), createResultReg(), FuncInfo, II, MIMD, MRI, TII, and TRI.

Referenced by fastEmitInst_r(), fastEmitInst_ri(), fastEmitInst_rii(), fastEmitInst_rr(), fastEmitInst_rri(), and fastEmitInst_rrr().

◆ createMachineMemOperandFor()

◆ createResultReg()

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

References FuncInfo, and recomputeInsertPt().

Referenced by getRegForValue().

◆ fastEmit_()

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

References Register.

Referenced by selectOperator().

◆ fastEmit_f()

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

References Register.

◆ fastEmit_i()

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

References Register.

Referenced by fastEmit_ri_().

◆ fastEmit_r()

Register FastISel::fastEmit_r ( MVT VT,
MVT RetVT,
unsigned Opcode,
Register Op0 )
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 1898 of file FastISel.cpp.

References Register.

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

◆ fastEmit_ri()

Register FastISel::fastEmit_ri ( MVT VT,
MVT RetVT,
unsigned Opcode,
Register Op0,
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 1916 of file FastISel.cpp.

References Register.

Referenced by fastEmit_ri_(), and fastEmitZExtFromI1().

◆ fastEmit_ri_()

Register FastISel::fastEmit_ri_ ( MVT VT,
unsigned Opcode,
Register Op0,
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 1925 of file FastISel.cpp.

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

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

◆ fastEmit_rr()

Register FastISel::fastEmit_rr ( MVT VT,
MVT RetVT,
unsigned Opcode,
Register Op0,
Register Op1 )
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 1902 of file FastISel.cpp.

References Register.

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

◆ fastEmitBranch()

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

Emit an unconditional branch to the given block, unless it is the immediate (fall-through) successor, and update the CFG.

Definition at line 1620 of file FastISel.cpp.

References llvm::BasicBlock::back(), llvm::BasicBlock::front(), FuncInfo, llvm::MachineBasicBlock::getBasicBlock(), and TII.

Referenced by finishCondBranch(), and selectOperator().

◆ fastEmitInst_()

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

References llvm::BuildMI(), createResultReg(), FuncInfo, II, MIMD, and TII.

◆ fastEmitInst_extractsubreg()

Register FastISel::fastEmitInst_extractsubreg ( MVT RetVT,
Register Op0,
uint32_t Idx )
protected

Emit a MachineInstr for an extract_subreg from a specified index of a superregister to a specified type.

Definition at line 2172 of file FastISel.cpp.

References llvm::MachineInstrBuilder::addReg(), assert(), llvm::BuildMI(), createResultReg(), FuncInfo, llvm::Register::isVirtual(), MIMD, MRI, TII, TLI, and TRI.

◆ fastEmitInst_f()

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

Emit a MachineInstr with a floating point immediate, and a result register in the given register class.

Definition at line 2109 of file FastISel.cpp.

References llvm::MachineInstrBuilder::addFPImm(), llvm::MachineInstrBuilder::addReg(), llvm::BuildMI(), createResultReg(), FuncInfo, II, MIMD, and TII.

◆ fastEmitInst_i()

Register FastISel::fastEmitInst_i ( unsigned MachineInstOpcode,
const TargetRegisterClass * RC,
uint64_t Imm )
protected

Emit a MachineInstr with a single immediate operand, and a result register in the given register class.

Definition at line 2155 of file FastISel.cpp.

References llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), llvm::BuildMI(), createResultReg(), FuncInfo, II, MIMD, and TII.

◆ fastEmitInst_r()

Register FastISel::fastEmitInst_r ( unsigned MachineInstOpcode,
const TargetRegisterClass * RC,
Register Op0 )
protected

Emit a MachineInstr with one register operand and a result register in the given register class.

Definition at line 1989 of file FastISel.cpp.

References llvm::MachineInstrBuilder::addReg(), llvm::BuildMI(), constrainOperandRegClass(), createResultReg(), FuncInfo, II, MIMD, and TII.

◆ fastEmitInst_ri()

Register FastISel::fastEmitInst_ri ( unsigned MachineInstOpcode,
const TargetRegisterClass * RC,
Register Op0,
uint64_t Imm )
protected

Emit a MachineInstr with a register operand, an immediate, and a result register in the given register class.

Definition at line 2061 of file FastISel.cpp.

References llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), llvm::BuildMI(), constrainOperandRegClass(), createResultReg(), FuncInfo, II, MIMD, and TII.

◆ fastEmitInst_rii()

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

Emit a MachineInstr with one register operand and two immediate operands.

Definition at line 2084 of file FastISel.cpp.

References llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), llvm::BuildMI(), constrainOperandRegClass(), createResultReg(), FuncInfo, II, MIMD, and TII.

◆ fastEmitInst_rr()

Register FastISel::fastEmitInst_rr ( unsigned MachineInstOpcode,
const TargetRegisterClass * RC,
Register Op0,
Register Op1 )
protected

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

Definition at line 2010 of file FastISel.cpp.

References llvm::MachineInstrBuilder::addReg(), llvm::BuildMI(), constrainOperandRegClass(), createResultReg(), FuncInfo, II, MIMD, and TII.

◆ fastEmitInst_rri()

Register FastISel::fastEmitInst_rri ( unsigned MachineInstOpcode,
const TargetRegisterClass * RC,
Register Op0,
Register Op1,
uint64_t Imm )
protected

Emit a MachineInstr with two register operands, an immediate, and a result register in the given register class.

Definition at line 2129 of file FastISel.cpp.

References llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), llvm::BuildMI(), constrainOperandRegClass(), createResultReg(), FuncInfo, II, MIMD, and TII.

◆ fastEmitInst_rrr()

Register FastISel::fastEmitInst_rrr ( unsigned MachineInstOpcode,
const TargetRegisterClass * RC,
Register Op0,
Register Op1,
Register Op2 )
protected

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

Definition at line 2034 of file FastISel.cpp.

References llvm::MachineInstrBuilder::addReg(), llvm::BuildMI(), constrainOperandRegClass(), createResultReg(), FuncInfo, II, MIMD, and TII.

◆ fastEmitZExtFromI1()

Register FastISel::fastEmitZExtFromI1 ( MVT VT,
Register Op0 )
protected

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

Definition at line 2185 of file FastISel.cpp.

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

◆ 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 1888 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 1890 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 1892 of file FastISel.cpp.

Referenced by selectIntrinsicCall().

◆ fastMaterializeAlloca()

virtual Register 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.

References llvm::CallingConv::C, and Register.

◆ fastMaterializeConstant()

virtual Register 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 473 of file FastISel.h.

References llvm::CallingConv::C, and Register.

◆ fastMaterializeFloatZero()

virtual Register llvm::FastISel::fastMaterializeFloatZero ( const ConstantFP * CF)
inlineprotectedvirtual

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

Definition at line 484 of file FastISel.h.

References Register.

◆ 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.

References I, II, and Reg.

Referenced by selectInstruction().

◆ finishBasicBlock()

void FastISel::finishBasicBlock ( )

Flush the local value map.

Definition at line 136 of file FastISel.cpp.

◆ finishCondBranch()

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

Emit an unconditional branch to FalseMBB, obtains the branch weight and adds TrueMBB and FalseMBB to the successor list.

Definition at line 1641 of file FastISel.cpp.

References fastEmitBranch(), FuncInfo, llvm::MachineBasicBlock::getBasicBlock(), and MIMD.

◆ getCurDebugLoc()

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

Return current debug location information.

Definition at line 250 of file FastISel.h.

References MIMD.

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

References LastLocalValue.

Referenced by recomputeInsertPt(), and selectInstruction().

◆ getRegForGEPIndex()

Register FastISel::getRegForGEPIndex ( MVT PtrVT,
const Value * Idx )

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

Definition at line 384 of file FastISel.cpp.

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

Referenced by selectGetElementPtr().

◆ getRegForValue()

◆ handleDbgInfo()

◆ leaveLocalValueArea()

void FastISel::leaveLocalValueArea ( SavePoint Old)

Reset InsertPt to the given old insert position.

Definition at line 436 of file FastISel.cpp.

References FuncInfo, and LastLocalValue.

Referenced by getRegForValue().

◆ lookUpRegForValue()

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

References FuncInfo, I, and LocalValueMap.

Referenced by getRegForValue(), lowerDbgDeclare(), and lowerDbgValue().

◆ lowerArguments()

bool FastISel::lowerArguments ( )

Do "fast" instruction selection for function arguments and append the machine instructions to the current block.

Returns true when successful.

Definition at line 138 of file FastISel.cpp.

References assert(), fastLowerArguments(), FuncInfo, I, and LocalValueMap.

◆ lowerCall()

◆ lowerCallTo() [1/3]

◆ lowerCallTo() [2/3]

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

Definition at line 955 of file FastISel.cpp.

References DL, llvm::Mangler::getNameWithPrefix(), lowerCallTo(), and MF.

◆ lowerCallTo() [3/3]

◆ lowerDbgDeclare()

bool FastISel::lowerDbgDeclare ( const Value * V,
DIExpression * Expr,
DILocalVariable * Var,
const DebugLoc & DL )
protectedvirtual

Target-independent lowering of debug information.

Returns false if the debug information couldn't be lowered and was instead discarded.

Definition at line 1318 of file FastISel.cpp.

References AbstractManglingParser< Derived, Alloc >::Ops, llvm::Address, assert(), llvm::BuildMI(), llvm::cast(), llvm::MachineOperand::CreateReg(), llvm::dbgs(), DL, llvm::dwarf::DW_OP_LLVM_arg, FuncInfo, llvm::isa(), llvm::DILocalVariable::isValidLocationForIntrinsic(), LLVM_DEBUG, lookUpRegForValue(), llvm::DIExpression::prependOpcodes(), and TII.

Referenced by handleDbgInfo().

◆ lowerDbgValue()

◆ optimizeCmpPredicate()

◆ recomputeInsertPt()

void FastISel::recomputeInsertPt ( )

Reset InsertPt to prepare for inserting instructions into the current block.

Definition at line 401 of file FastISel.cpp.

References FuncInfo, and getLastLocalValue().

Referenced by enterLocalValueArea(), handleDbgInfo(), removeDeadCode(), and selectInstruction().

◆ removeDeadCode()

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

Remove all dead instructions between the I and E.

Definition at line 410 of file FastISel.cpp.

References assert(), EmitStartPt, I, LastLocalValue, and recomputeInsertPt().

Referenced by selectInstruction().

◆ selectBinaryOp()

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

Select and emit code for a binary operator instruction, which has an opcode which directly corresponds to the given ISD opcode.

Definition at line 444 of file FastISel.cpp.

References llvm::ISD::AND, llvm::cast(), llvm::dyn_cast(), fastEmit_ri_(), fastEmit_rr(), llvm::EVT::getEVT(), getRegForValue(), llvm::EVT::getSimpleVT(), I, llvm::isa(), llvm::ISD::isBitwiseLogicOp(), isCommutative(), llvm::isPowerOf2_64(), llvm::EVT::isSimple(), llvm::Log2_64(), llvm::ISD::SDIV, llvm::ISD::SRA, TLI, updateValueMap(), and llvm::ISD::UREM.

Referenced by selectOperator().

◆ selectBitCast()

bool FastISel::selectBitCast ( const User * I)
protected

Definition at line 1467 of file FastISel.cpp.

References DL, fastEmit_r(), getRegForValue(), llvm::EVT::getSimpleVT(), I, TLI, and updateValueMap().

Referenced by selectOperator().

◆ selectCall()

◆ selectCast()

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

◆ selectExtractValue()

◆ selectFNeg()

bool FastISel::selectFNeg ( const User * I,
const Value * In )
protected

◆ selectFreeze()

bool FastISel::selectFreeze ( const User * I)
protected

◆ selectGetElementPtr()

◆ selectInstruction()

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

Definition at line 1536 of file FastISel.cpp.

References Call, llvm::dyn_cast(), F, fastSelectInstruction(), FuncInfo, getLastLocalValue(), I, LibInfo, MIMD, llvm::LLVMContext::OB_funclet, recomputeInsertPt(), removeDeadCode(), selectOperator(), and SkipTargetIndependentISel.

◆ selectIntrinsicCall()

◆ selectOperator()

◆ selectPatchpoint()

◆ selectStackmap()

◆ selectXRayCustomEvent()

◆ selectXRayTypedEvent()

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

References EmitStartPt, I, and LastLocalValue.

◆ shouldOptForSize()

bool llvm::FastISel::shouldOptForSize ( const MachineFunction * MF) const
inlineprotected

Definition at line 524 of file FastISel.h.

References MF.

◆ startNewBlock()

void FastISel::startNewBlock ( )

Set the current block to which generated machine instructions will be appended.

Definition at line 123 of file FastISel.cpp.

References assert(), EmitStartPt, FuncInfo, LastLocalValue, and LocalValueMap.

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

References assert(), FuncInfo, llvm::MachineRegisterInfo::defusechain_iterator< ReturnUses, ReturnDefs, SkipDebug, ByOperand, ByInstr >::getOperandNo(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::MachineOperand::getParent(), getRegForValue(), llvm::Value::hasOneUse(), llvm::LoadInst::isVolatile(), MRI, tryToFoldLoadIntoMI(), and llvm::Instruction::user_back().

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

Referenced by tryToFoldLoad().

◆ updateValueMap()

void FastISel::updateValueMap ( const Value * I,
Register 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 363 of file FastISel.cpp.

References FuncInfo, I, llvm::isa(), and LocalValueMap.

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

Member Data Documentation

◆ DL

◆ EmitStartPt

MachineInstr* llvm::FastISel::EmitStartPt = nullptr
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 226 of file FastISel.h.

Referenced by removeDeadCode(), setLastLocalValue(), and startNewBlock().

◆ FuncInfo

◆ LastLocalValue

MachineInstr* llvm::FastISel::LastLocalValue = nullptr
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 221 of file FastISel.h.

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

◆ LibInfo

const TargetLibraryInfo* llvm::FastISel::LibInfo
protected

Definition at line 214 of file FastISel.h.

Referenced by FastISel(), and selectInstruction().

◆ LocalValueMap

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

Definition at line 202 of file FastISel.h.

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

◆ MCP

MachineConstantPool& llvm::FastISel::MCP
protected

Definition at line 207 of file FastISel.h.

Referenced by FastISel().

◆ MF

MachineFunction* llvm::FastISel::MF
protected

Definition at line 204 of file FastISel.h.

Referenced by FastISel(), lowerCall(), lowerCallTo(), lowerCallTo(), lowerCallTo(), and shouldOptForSize().

◆ MFI

MachineFrameInfo& llvm::FastISel::MFI
protected

Definition at line 206 of file FastISel.h.

Referenced by FastISel().

◆ MIMD

◆ MRI

MachineRegisterInfo& llvm::FastISel::MRI
protected

◆ SkipTargetIndependentISel

bool llvm::FastISel::SkipTargetIndependentISel
protected

Definition at line 215 of file FastISel.h.

Referenced by FastISel(), and selectInstruction().

◆ TII

◆ TLI

◆ TM

const TargetMachine& llvm::FastISel::TM
protected

◆ TRI

const TargetRegisterInfo& llvm::FastISel::TRI
protected

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