LLVM API Documentation

llvm::FastISel Class Reference

#include <FastISel.h>

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

List of all members.

Public Member Functions

void startNewBlock (MachineBasicBlock *mbb)
void setCurrentBlock (MachineBasicBlock *mbb)
void setCurDebugLoc (DebugLoc dl)
bool SelectInstruction (Instruction *I)
bool SelectOperator (User *I, unsigned Opcode)
virtual bool TargetSelectInstruction (Instruction *I)=0
unsigned getRegForValue (Value *V)
unsigned lookUpRegForValue (Value *V)
unsigned getRegForGEPIndex (Value *V)
virtual ~FastISel ()

Protected Member Functions

 FastISel (MachineFunction &mf, MachineModuleInfo *mmi, DwarfWriter *dw, DenseMap< const Value *, unsigned > &vm, DenseMap< const BasicBlock *, MachineBasicBlock * > &bm, DenseMap< const AllocaInst *, int > &am, SmallSet< Instruction *, 8 > &cil)
virtual unsigned FastEmit_ (MVT::SimpleValueType VT, MVT::SimpleValueType RetVT, ISD::NodeType Opcode)
virtual unsigned FastEmit_r (MVT::SimpleValueType VT, MVT::SimpleValueType RetVT, ISD::NodeType Opcode, unsigned Op0)
virtual unsigned FastEmit_rr (MVT::SimpleValueType VT, MVT::SimpleValueType RetVT, ISD::NodeType Opcode, unsigned Op0, unsigned Op1)
virtual unsigned FastEmit_ri (MVT::SimpleValueType VT, MVT::SimpleValueType RetVT, ISD::NodeType Opcode, unsigned Op0, uint64_t Imm)
virtual unsigned FastEmit_rf (MVT::SimpleValueType VT, MVT::SimpleValueType RetVT, ISD::NodeType Opcode, unsigned Op0, ConstantFP *FPImm)
virtual unsigned FastEmit_rri (MVT::SimpleValueType VT, MVT::SimpleValueType RetVT, ISD::NodeType Opcode, unsigned Op0, unsigned Op1, uint64_t Imm)
unsigned FastEmit_ri_ (MVT::SimpleValueType VT, ISD::NodeType Opcode, unsigned Op0, uint64_t Imm, MVT::SimpleValueType ImmType)
unsigned FastEmit_rf_ (MVT::SimpleValueType VT, ISD::NodeType Opcode, unsigned Op0, ConstantFP *FPImm, MVT::SimpleValueType ImmType)
virtual unsigned FastEmit_i (MVT::SimpleValueType VT, MVT::SimpleValueType RetVT, ISD::NodeType Opcode, uint64_t Imm)
virtual unsigned FastEmit_f (MVT::SimpleValueType VT, MVT::SimpleValueType RetVT, ISD::NodeType Opcode, ConstantFP *FPImm)
unsigned FastEmitInst_ (unsigned MachineInstOpcode, const TargetRegisterClass *RC)
unsigned FastEmitInst_r (unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0)
unsigned FastEmitInst_rr (unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, unsigned Op1)
unsigned FastEmitInst_ri (unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, uint64_t Imm)
unsigned FastEmitInst_rf (unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, ConstantFP *FPImm)
unsigned FastEmitInst_rri (unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, unsigned Op1, uint64_t Imm)
unsigned FastEmitInst_i (unsigned MachineInstrOpcode, const TargetRegisterClass *RC, uint64_t Imm)
unsigned FastEmitInst_extractsubreg (MVT::SimpleValueType RetVT, unsigned Op0, uint32_t Idx)
void FastEmitBranch (MachineBasicBlock *MBB)
void UpdateValueMap (Value *I, unsigned Reg)
unsigned createResultReg (const TargetRegisterClass *RC)
virtual unsigned TargetMaterializeConstant (Constant *C)
virtual unsigned TargetMaterializeAlloca (AllocaInst *C)

Protected Attributes

MachineBasicBlock * MBB
DenseMap< const Value *, unsigned > LocalValueMap
DenseMap< const Value
*, unsigned > & 
ValueMap
DenseMap< const BasicBlock
*, MachineBasicBlock * > & 
MBBMap
DenseMap< const AllocaInst
*, int > & 
StaticAllocaMap
SmallSet< Instruction *, 8 > & CatchInfoLost
MachineFunction & MF
MachineModuleInfo * MMI
DwarfWriter * DW
MachineRegisterInfo & MRI
MachineFrameInfo & MFI
MachineConstantPool & MCP
DebugLoc DL
const TargetMachine & TM
const TargetData & TD
const TargetInstrInfo & TII
const TargetLowering & TLI


Detailed Description

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


Constructor & Destructor Documentation

FastISel::~FastISel (  )  [virtual]

Definition at line 722 of file FastISel.cpp.

FastISel::FastISel ( MachineFunction &  mf,
MachineModuleInfo *  mmi,
DwarfWriter *  dw,
DenseMap< const Value *, unsigned > &  vm,
DenseMap< const BasicBlock *, MachineBasicBlock * > &  bm,
DenseMap< const AllocaInst *, int > &  am,
SmallSet< Instruction *, 8 > &  cil 
) [protected]

Definition at line 693 of file FastISel.cpp.


Member Function Documentation

void llvm::FastISel::startNewBlock ( MachineBasicBlock *  mbb  )  [inline]

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

Definition at line 69 of file FastISel.h.

References LocalValueMap, and setCurrentBlock().

void llvm::FastISel::setCurrentBlock ( MachineBasicBlock *  mbb  )  [inline]

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

Definition at line 77 of file FastISel.h.

References MBB.

Referenced by startNewBlock().

void llvm::FastISel::setCurDebugLoc ( DebugLoc  dl  )  [inline]

setCurDebugLoc - Set the current debug location information, which is used when creating a machine instruction.

Definition at line 84 of file FastISel.h.

References DL.

bool FastISel::SelectInstruction ( Instruction *  I  ) 

SelectInstruction - Do "fast" instruction selection for the given LLVM IR instruction, and append generated machine instructions to the current block. Return true if selection was successful.

Definition at line 561 of file FastISel.cpp.

References llvm::Instruction::getOpcode(), and SelectOperator().

bool FastISel::SelectOperator ( User *  I,
unsigned  Opcode 
)

virtual bool llvm::FastISel::TargetSelectInstruction ( Instruction *  I  )  [pure virtual]

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

Implemented in X86FastISel.

unsigned FastISel::getRegForValue ( Value *  V  ) 

unsigned FastISel::lookUpRegForValue ( Value *  V  ) 

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

References LocalValueMap.

unsigned FastISel::getRegForGEPIndex ( Value *  V  ) 

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

Definition at line 160 of file FastISel.cpp.

References llvm::MVT::bitsGT(), llvm::MVT::bitsLT(), FastEmit_r(), llvm::MVT::getMVT(), llvm::TargetLowering::getPointerTy(), getRegForValue(), llvm::MVT::getSimpleVT(), llvm::Value::getType(), llvm::ISD::SIGN_EXTEND, TLI, and llvm::ISD::TRUNCATE.

unsigned FastISel::FastEmit_ ( MVT::SimpleValueType  VT,
MVT::SimpleValueType  RetVT,
ISD::NodeType  Opcode 
) [protected, virtual]

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

Definition at line 724 of file FastISel.cpp.

unsigned FastISel::FastEmit_r ( MVT::SimpleValueType  VT,
MVT::SimpleValueType  RetVT,
ISD::NodeType  Opcode,
unsigned  Op0 
) [protected, virtual]

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

Referenced by FastEmit_rf_(), getRegForGEPIndex(), and getRegForValue().

unsigned FastISel::FastEmit_rr ( MVT::SimpleValueType  VT,
MVT::SimpleValueType  RetVT,
ISD::NodeType  Opcode,
unsigned  Op0,
unsigned  Op1 
) [protected, virtual]

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

Referenced by FastEmit_rf_(), and FastEmit_ri_().

unsigned FastISel::FastEmit_ri ( MVT::SimpleValueType  VT,
MVT::SimpleValueType  RetVT,
ISD::NodeType  Opcode,
unsigned  Op0,
uint64_t  Imm 
) [protected, virtual]

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

Referenced by FastEmit_ri_().

unsigned FastISel::FastEmit_rf ( MVT::SimpleValueType  VT,
MVT::SimpleValueType  RetVT,
ISD::NodeType  Opcode,
unsigned  Op0,
ConstantFP *  FPImm 
) [protected, virtual]

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

Referenced by FastEmit_rf_().

unsigned FastISel::FastEmit_rri ( MVT::SimpleValueType  VT,
MVT::SimpleValueType  RetVT,
ISD::NodeType  Opcode,
unsigned  Op0,
unsigned  Op1,
uint64_t  Imm 
) [protected, virtual]

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

unsigned FastISel::FastEmit_ri_ ( MVT::SimpleValueType  VT,
ISD::NodeType  Opcode,
unsigned  Op0,
uint64_t  Imm,
MVT::SimpleValueType  ImmType 
) [protected]

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

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

References llvm::ISD::Constant, FastEmit_i(), FastEmit_ri(), and FastEmit_rr().

unsigned FastISel::FastEmit_rf_ ( MVT::SimpleValueType  VT,
ISD::NodeType  Opcode,
unsigned  Op0,
ConstantFP *  FPImm,
MVT::SimpleValueType  ImmType 
) [protected]

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

FastEmit_rf_ - This method is a wrapper of FastEmit_ri. It first tries to emit an instruction with a floating-point immediate operand using FastEmit_rf. If that fails, it materializes the immediate into a register and try FastEmit_rr instead.

Definition at line 790 of file FastISel.cpp.

References llvm::ISD::Constant, llvm::ISD::ConstantFP, llvm::APFloat::convertToInteger(), FastEmit_f(), FastEmit_i(), FastEmit_r(), FastEmit_rf(), FastEmit_rr(), llvm::TargetLowering::getPointerTy(), llvm::MVT::getSimpleVT(), llvm::MVT::getSizeInBits(), llvm::ConstantFP::getValueAPF(), llvm::APInt::getZExtValue(), llvm::APFloat::rmTowardZero, llvm::ISD::SINT_TO_FP, and TLI.

unsigned FastISel::FastEmit_i ( MVT::SimpleValueType  VT,
MVT::SimpleValueType  RetVT,
ISD::NodeType  Opcode,
uint64_t  Imm 
) [protected, virtual]

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

Referenced by FastEmit_rf_(), FastEmit_ri_(), and getRegForValue().

unsigned FastISel::FastEmit_f ( MVT::SimpleValueType  VT,
MVT::SimpleValueType  RetVT,
ISD::NodeType  Opcode,
ConstantFP *  FPImm 
) [protected, virtual]

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

Referenced by FastEmit_rf_(), and getRegForValue().

unsigned FastISel::FastEmitInst_ ( unsigned  MachineInstOpcode,
const TargetRegisterClass *  RC 
) [protected]

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

Definition at line 835 of file FastISel.cpp.

References llvm::BuildMI(), createResultReg(), DL, llvm::TargetInstrInfo::get(), MBB, and TII.

unsigned FastISel::FastEmitInst_r ( unsigned  MachineInstOpcode,
const TargetRegisterClass *  RC,
unsigned  Op0 
) [protected]

unsigned FastISel::FastEmitInst_rr ( unsigned  MachineInstOpcode,
const TargetRegisterClass *  RC,
unsigned  Op0,
unsigned  Op1 
) [protected]

unsigned FastISel::FastEmitInst_ri ( unsigned  MachineInstOpcode,
const TargetRegisterClass *  RC,
unsigned  Op0,
uint64_t  Imm 
) [protected]

unsigned FastISel::FastEmitInst_rf ( unsigned  MachineInstOpcode,
const TargetRegisterClass *  RC,
unsigned  Op0,
ConstantFP *  FPImm 
) [protected]

unsigned FastISel::FastEmitInst_rri ( unsigned  MachineInstOpcode,
const TargetRegisterClass *  RC,
unsigned  Op0,
unsigned  Op1,
uint64_t  Imm 
) [protected]

unsigned FastISel::FastEmitInst_i ( unsigned  MachineInstrOpcode,
const TargetRegisterClass *  RC,
uint64_t  Imm 
) [protected]

unsigned FastISel::FastEmitInst_extractsubreg ( MVT::SimpleValueType  RetVT,
unsigned  Op0,
uint32_t  Idx 
) [protected]

void FastISel::FastEmitBranch ( MachineBasicBlock *  MSucc  )  [protected]

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

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

Definition at line 569 of file FastISel.cpp.

References llvm::MachineBasicBlock::addSuccessor(), llvm::TargetInstrInfo::InsertBranch(), llvm::MachineBasicBlock::isLayoutSuccessor(), MBB, llvm::next(), and TII.

Referenced by SelectOperator().

void FastISel::UpdateValueMap ( Value *  I,
unsigned  Reg 
) [protected]

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

References llvm::TargetInstrInfo::copyRegToReg(), llvm::MachineBasicBlock::end(), llvm::MachineRegisterInfo::getRegClass(), LocalValueMap, MBB, MRI, and TII.

Referenced by SelectOperator().

unsigned FastISel::createResultReg ( const TargetRegisterClass *  RC  )  [protected]

virtual unsigned llvm::FastISel::TargetMaterializeConstant ( Constant *  C  )  [inline, protected, virtual]

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

Definition at line 283 of file FastISel.h.

Referenced by getRegForValue().

virtual unsigned llvm::FastISel::TargetMaterializeAlloca ( AllocaInst *  C  )  [inline, protected, virtual]

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

Definition at line 289 of file FastISel.h.

Referenced by getRegForValue().


Member Data Documentation

Definition at line 46 of file FastISel.h.

Referenced by getRegForValue(), lookUpRegForValue(), startNewBlock(), and UpdateValueMap().

Definition at line 47 of file FastISel.h.

Definition at line 48 of file FastISel.h.

Referenced by SelectOperator().

Definition at line 49 of file FastISel.h.

Referenced by SelectOperator().

Definition at line 51 of file FastISel.h.

Definition at line 53 of file FastISel.h.

Definition at line 54 of file FastISel.h.

Definition at line 55 of file FastISel.h.

Definition at line 56 of file FastISel.h.

Referenced by createResultReg(), FastEmitInst_extractsubreg(), and UpdateValueMap().

Definition at line 57 of file FastISel.h.

Definition at line 58 of file FastISel.h.

const TargetMachine& llvm::FastISel::TM [protected]

Definition at line 60 of file FastISel.h.

Referenced by X86FastISel::X86FastISel().

const TargetData& llvm::FastISel::TD [protected]

Definition at line 61 of file FastISel.h.

Referenced by getRegForValue().

const TargetLowering& llvm::FastISel::TLI [protected]


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