class InstructionSelector

Declaration

class InstructionSelector { /* full declaration omitted */ };

Description

Provides the logic to select generic machine instructions.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h:381

Member Variables

public llvm::CodeGenCoverage* CoverageInfo = nullptr
public llvm::GISelKnownBits* KnownBits = nullptr
public llvm::MachineFunction* MF = nullptr

Method Overview

  • protected InstructionSelector()
  • protected bool constrainOperandRegToRegClass(llvm::MachineInstr & I, unsigned int OpIdx, const llvm::TargetRegisterClass & RC, const llvm::TargetInstrInfo & TII, const llvm::TargetRegisterInfo & TRI, const llvm::RegisterBankInfo & RBI) const
  • protected template <class TgtInstructionSelector, class PredicateBitset, class ComplexMatcherMemFn, class CustomRendererFn>bool executeMatchTable(TgtInstructionSelector & ISel, llvm::InstructionSelector::NewMIVector & OutMIs, llvm::InstructionSelector::MatcherState & State, const ISelInfoTy<PredicateBitset, ComplexMatcherMemFn, CustomRendererFn> & ISelInfo, const int64_t * MatchTable, const llvm::TargetInstrInfo & TII, llvm::MachineRegisterInfo & MRI, const llvm::TargetRegisterInfo & TRI, const llvm::RegisterBankInfo & RBI, const PredicateBitset & AvailableFeatures, llvm::CodeGenCoverage & CoverageInfo) const
  • protected virtual const int64_t * getMatchTable() const
  • protected bool isBaseWithConstantOffset(const llvm::MachineOperand & Root, const llvm::MachineRegisterInfo & MRI) const
  • protected bool isObviouslySafeToFold(llvm::MachineInstr & MI, llvm::MachineInstr & IntoMI) const
  • protected bool isOperandImmEqual(const llvm::MachineOperand & MO, int64_t Value, const llvm::MachineRegisterInfo & MRI) const
  • public virtual bool select(llvm::MachineInstr & I)
  • public virtual void setupGeneratedPerFunctionState(llvm::MachineFunction & MF)
  • public virtual void setupMF(llvm::MachineFunction & mf, llvm::GISelKnownBits & KB, llvm::CodeGenCoverage & covinfo)
  • protected virtual bool testImmPredicate_APFloat(unsigned int, const llvm::APFloat &) const
  • protected virtual bool testImmPredicate_APInt(unsigned int, const llvm::APInt &) const
  • protected virtual bool testImmPredicate_I64(unsigned int, int64_t) const
  • protected virtual bool testMIPredicate_MI(unsigned int, const llvm::MachineInstr &) const
  • public virtual ~InstructionSelector()

Methods

InstructionSelector()

Declared at: llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h:454

bool constrainOperandRegToRegClass(
    llvm::MachineInstr& I,
    unsigned int OpIdx,
    const llvm::TargetRegisterClass& RC,
    const llvm::TargetInstrInfo& TII,
    const llvm::TargetRegisterInfo& TRI,
    const llvm::RegisterBankInfo& RBI) const

Description

Constrain a register operand of an instruction \p I to a specified register class. This could involve inserting COPYs before (for uses) or after (for defs) and may replace the operand of \p I.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h:494

Parameters

llvm::MachineInstr& I
unsigned int OpIdx
const llvm::TargetRegisterClass& RC
const llvm::TargetInstrInfo& TII
const llvm::TargetRegisterInfo& TRI
const llvm::RegisterBankInfo& RBI

Returns

whether operand regclass constraining succeeded.

template <class TgtInstructionSelector,
          class PredicateBitset,
          class ComplexMatcherMemFn,
          class CustomRendererFn>
bool executeMatchTable(
    TgtInstructionSelector& ISel,
    llvm::InstructionSelector::NewMIVector&
        OutMIs,
    llvm::InstructionSelector::MatcherState&
        State,
    const ISelInfoTy<PredicateBitset,
                     ComplexMatcherMemFn,
                     CustomRendererFn>& ISelInfo,
    const int64_t* MatchTable,
    const llvm::TargetInstrInfo& TII,
    llvm::MachineRegisterInfo& MRI,
    const llvm::TargetRegisterInfo& TRI,
    const llvm::RegisterBankInfo& RBI,
    const PredicateBitset& AvailableFeatures,
    llvm::CodeGenCoverage& CoverageInfo) const

Description

Execute a given matcher table and return true if the match was successful and false otherwise.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h:460

Templates

TgtInstructionSelector
PredicateBitset
ComplexMatcherMemFn
CustomRendererFn

Parameters

TgtInstructionSelector& ISel
llvm::InstructionSelector::NewMIVector& OutMIs
llvm::InstructionSelector::MatcherState& State
const ISelInfoTy<PredicateBitset, ComplexMatcherMemFn, CustomRendererFn>& ISelInfo
const int64_t* MatchTable
const llvm::TargetInstrInfo& TII
llvm::MachineRegisterInfo& MRI
const llvm::TargetRegisterInfo& TRI
const llvm::RegisterBankInfo& RBI
const PredicateBitset& AvailableFeatures
llvm::CodeGenCoverage& CoverageInfo

virtual const int64_t* getMatchTable() const

Declared at: llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h:469

bool isBaseWithConstantOffset(
    const llvm::MachineOperand& Root,
    const llvm::MachineRegisterInfo& MRI) const

Description

Return true if the specified operand is a G_PTR_ADD with a G_CONSTANT on the right-hand side. GlobalISel's separation of pointer and integer types means that we don't need to worry about G_OR with equivalent semantics.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h:506

Parameters

const llvm::MachineOperand& Root
const llvm::MachineRegisterInfo& MRI

bool isObviouslySafeToFold(
    llvm::MachineInstr& MI,
    llvm::MachineInstr& IntoMI) const

Description

Return true if MI can obviously be folded into IntoMI. MI and IntoMI do not need to be in the same basic blocks, but MI must preceed IntoMI.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h:512

Parameters

llvm::MachineInstr& MI
llvm::MachineInstr& IntoMI

bool isOperandImmEqual(
    const llvm::MachineOperand& MO,
    int64_t Value,
    const llvm::MachineRegisterInfo& MRI) const

Declared at: llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h:500

Parameters

const llvm::MachineOperand& MO
int64_t Value
const llvm::MachineRegisterInfo& MRI

virtual bool select(llvm::MachineInstr& I)

Description

Select the (possibly generic) instruction \p I to only use target-specific opcodes. It is OK to insert multiple instructions, but they cannot be generic pre-isel instructions.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h:395

Parameters

llvm::MachineInstr& I

Returns

whether selection succeeded.

virtual void setupGeneratedPerFunctionState(
    llvm::MachineFunction& MF)

Declared at: llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h:401

Parameters

llvm::MachineFunction& MF

virtual void setupMF(
    llvm::MachineFunction& mf,
    llvm::GISelKnownBits& KB,
    llvm::CodeGenCoverage& covinfo)

Description

Setup per-MF selector state.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h:406

Parameters

llvm::MachineFunction& mf
llvm::GISelKnownBits& KB
llvm::CodeGenCoverage& covinfo

virtual bool testImmPredicate_APFloat(
    unsigned int,
    const llvm::APFloat&) const

Declared at: llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h:481

Parameters

unsigned int
const llvm::APFloat&

virtual bool testImmPredicate_APInt(
    unsigned int,
    const llvm::APInt&) const

Declared at: llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h:477

Parameters

unsigned int
const llvm::APInt&

virtual bool testImmPredicate_I64(unsigned int,
                                  int64_t) const

Declared at: llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h:473

Parameters

unsigned int
int64_t

virtual bool testMIPredicate_MI(
    unsigned int,
    const llvm::MachineInstr&) const

Declared at: llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h:485

Parameters

unsigned int
const llvm::MachineInstr&

virtual ~InstructionSelector()

Declared at: llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h:383