class RegBankSelect

Declaration

class RegBankSelect : public MachineFunctionPass { /* full declaration omitted */ };

Description

This pass implements the reg bank selector pass used in the GlobalISel pipeline. At the end of this pass, all register operands have been assigned

Declared at: llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h:91

Inherits from: MachineFunctionPass

Member Variables

private const llvm::RegisterBankInfo* RBI = nullptr
Interface to the target lowering info related to register banks.
private llvm::MachineRegisterInfo* MRI = nullptr
MRI contains all the register class/bank information that this pass uses and updates.
private const llvm::TargetRegisterInfo* TRI = nullptr
Information on the register classes for the current function.
private llvm::MachineBlockFrequencyInfo* MBFI = nullptr
Get the frequency of blocks. This is required for non-fast mode.
private llvm::MachineBranchProbabilityInfo* MBPI = nullptr
Get the frequency of the edges. This is required for non-fast mode.
private std::unique_ptr<MachineOptimizationRemarkEmitter> MORE
Current optimization remark emitter. Used to report failures.
private llvm::MachineIRBuilder MIRBuilder
Helper class used for every code morphing.
private llvm::RegBankSelect::Mode OptMode
Optimization mode of the pass.
private const llvm::TargetPassConfig* TPC
Current target configuration. Controls how the pass handles errors.
public static char ID

Method Overview

  • public RegBankSelect(llvm::RegBankSelect::Mode RunningMode = Fast)
  • private bool applyMapping(llvm::MachineInstr & MI, const RegisterBankInfo::InstructionMapping & InstrMapping, SmallVectorImpl<llvm::RegBankSelect::RepairingPlacement> & RepairPts)
  • private bool assignInstr(llvm::MachineInstr & MI)
  • private bool assignmentMatch(llvm::Register Reg, const RegisterBankInfo::ValueMapping & ValMapping, bool & OnlyAssign) const
  • private llvm::RegBankSelect::MappingCost computeMapping(llvm::MachineInstr & MI, const RegisterBankInfo::InstructionMapping & InstrMapping, SmallVectorImpl<llvm::RegBankSelect::RepairingPlacement> & RepairPts, const llvm::RegBankSelect::MappingCost * BestCost = nullptr)
  • private const RegisterBankInfo::InstructionMapping & findBestMapping(llvm::MachineInstr & MI, RegisterBankInfo::InstructionMappings & PossibleMappings, SmallVectorImpl<llvm::RegBankSelect::RepairingPlacement> & RepairPts)
  • public void getAnalysisUsage(llvm::AnalysisUsage & AU) const
  • public llvm::MachineFunctionProperties getClearedProperties() const
  • public llvm::StringRef getPassName() const
  • private uint64_t getRepairCost(const llvm::MachineOperand & MO, const RegisterBankInfo::ValueMapping & ValMapping) const
  • public llvm::MachineFunctionProperties getRequiredProperties() const
  • public llvm::MachineFunctionProperties getSetProperties() const
  • private void init(llvm::MachineFunction & MF)
  • private bool repairReg(llvm::MachineOperand & MO, const RegisterBankInfo::ValueMapping & ValMapping, RegBankSelect::RepairingPlacement & RepairPt, const iterator_range<SmallVectorImpl<Register>::const_iterator> & NewVRegs)
  • public bool runOnMachineFunction(llvm::MachineFunction & MF)
  • private void tryAvoidingSplit(RegBankSelect::RepairingPlacement & RepairPt, const llvm::MachineOperand & MO, const RegisterBankInfo::ValueMapping & ValMapping) const

Inherited from MachineFunctionPass:

Inherited from FunctionPass:

Inherited from Pass:

Methods

RegBankSelect(
    llvm::RegBankSelect::Mode RunningMode = Fast)

Description

Create a RegBankSelect pass with the specified \p RunningMode.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h:620

Parameters

llvm::RegBankSelect::Mode RunningMode = Fast

bool applyMapping(
    llvm::MachineInstr& MI,
    const RegisterBankInfo::InstructionMapping&
        InstrMapping,
    SmallVectorImpl<
        llvm::RegBankSelect::RepairingPlacement>&
        RepairPts)

Description

Apply \p Mapping to \p MI. \p RepairPts represents the different mapping action that need to happen for the mapping to be applied.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h:614

Parameters

llvm::MachineInstr& MI
const RegisterBankInfo::InstructionMapping& InstrMapping
SmallVectorImpl< llvm::RegBankSelect::RepairingPlacement>& RepairPts

Returns

True if the mapping was applied sucessfully, false otherwise.

bool assignInstr(llvm::MachineInstr& MI)

Description

Assign the register bank of each operand of \p MI.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h:518

Parameters

llvm::MachineInstr& MI

Returns

True on success, false otherwise.

bool assignmentMatch(
    llvm::Register Reg,
    const RegisterBankInfo::ValueMapping&
        ValMapping,
    bool& OnlyAssign) const

Description

Check if \p Reg is already assigned what is described by \p ValMapping. \p OnlyAssign == true means that \p Reg just needs to be assigned a register bank. I.e., no repairing is necessary to have the assignment match.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h:527

Parameters

llvm::Register Reg
const RegisterBankInfo::ValueMapping& ValMapping
bool& OnlyAssign

llvm::RegBankSelect::MappingCost computeMapping(
    llvm::MachineInstr& MI,
    const RegisterBankInfo::InstructionMapping&
        InstrMapping,
    SmallVectorImpl<
        llvm::RegBankSelect::RepairingPlacement>&
        RepairPts,
    const llvm::RegBankSelect::MappingCost*
        BestCost = nullptr)

Description

Compute the cost of mapping \p MI with \p InstrMapping and compute the repairing placement for such mapping in \p RepairPts. \p BestCost is used to specify when the cost becomes too high and thus it is not worth computing the RepairPts. Moreover if\p BestCost == nullptr, the mapping cost is actually not computed.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h:593

Parameters

llvm::MachineInstr& MI
const RegisterBankInfo::InstructionMapping& InstrMapping
SmallVectorImpl< llvm::RegBankSelect::RepairingPlacement>& RepairPts
const llvm::RegBankSelect::MappingCost* BestCost = nullptr

const RegisterBankInfo::InstructionMapping&
findBestMapping(
    llvm::MachineInstr& MI,
    RegisterBankInfo::InstructionMappings&
        PossibleMappings,
    SmallVectorImpl<
        llvm::RegBankSelect::RepairingPlacement>&
        RepairPts)

Description

Find the best mapping for \p MI from \p PossibleMappings.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h:581

Parameters

llvm::MachineInstr& MI
RegisterBankInfo::InstructionMappings& PossibleMappings
SmallVectorImpl< llvm::RegBankSelect::RepairingPlacement>& RepairPts

Returns

a reference on the best mapping in \p PossibleMappings.

void getAnalysisUsage(
    llvm::AnalysisUsage& AU) const

Description

getAnalysisUsage - Subclasses that override getAnalysisUsage must call this. For MachineFunctionPasses, calling AU.preservesCFG() indicates that the pass does not modify the MachineBasicBlock CFG.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h:624

Parameters

llvm::AnalysisUsage& AU

llvm::MachineFunctionProperties
getClearedProperties() const

Declared at: llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h:637

llvm::StringRef getPassName() const

Description

getPassName - Return a nice clean name for a pass. This usually implemented in terms of the name that is registered by one of the Registration templates, but can be overloaded directly.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h:622

uint64_t getRepairCost(
    const llvm::MachineOperand& MO,
    const RegisterBankInfo::ValueMapping&
        ValMapping) const

Description

Return the cost of the instruction needed to map \p MO to \p ValMapping. The cost is free of basic block frequencies.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h:575

Parameters

const llvm::MachineOperand& MO
const RegisterBankInfo::ValueMapping& ValMapping

llvm::MachineFunctionProperties
getRequiredProperties() const

Declared at: llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h:626

llvm::MachineFunctionProperties getSetProperties()
    const

Declared at: llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h:632

void init(llvm::MachineFunction& MF)

Description

Initialize the field members using \p MF.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h:521

Parameters

llvm::MachineFunction& MF

bool repairReg(
    llvm::MachineOperand& MO,
    const RegisterBankInfo::ValueMapping&
        ValMapping,
    RegBankSelect::RepairingPlacement& RepairPt,
    const iterator_range<SmallVectorImpl<
        Register>::const_iterator>& NewVRegs)

Description

Insert repairing code for \p Reg as specified by \p ValMapping. The repairing placement is specified by \p RepairPt. \p NewVRegs contains all the registers required to remap \p Reg. In other words, the number of registers in NewVRegs must be equal to ValMapping.BreakDown.size(). The transformation could be sketched as: Becomes and Becomes

Declared at: llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h:563

Parameters

llvm::MachineOperand& MO
const RegisterBankInfo::ValueMapping& ValMapping
RegBankSelect::RepairingPlacement& RepairPt
const iterator_range< SmallVectorImpl<Register>::const_iterator>& NewVRegs

Returns

True if the repairing worked, false otherwise.

bool runOnMachineFunction(
    llvm::MachineFunction& MF)

Description

Walk through \p MF and assign a register bank to every virtual register that are still mapped to nothing. The target needs to provide a RegisterBankInfo and in particular override RegisterBankInfo::getInstrMapping. Simplified algo:

Declared at: llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h:665

Parameters

llvm::MachineFunction& MF

void tryAvoidingSplit(
    RegBankSelect::RepairingPlacement& RepairPt,
    const llvm::MachineOperand& MO,
    const RegisterBankInfo::ValueMapping&
        ValMapping) const

Description

When \p RepairPt involves splitting to repair \p MO for the given \p ValMapping, try to change the way we repair such that the splitting is not required anymore.

Declared at: llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h:606

Parameters

RegBankSelect::RepairingPlacement& RepairPt
const llvm::MachineOperand& MO
const RegisterBankInfo::ValueMapping& ValMapping