LLVM 22.0.0git
llvm::SlotIndexes Class Reference

SlotIndexes pass. More...

#include "llvm/CodeGen/SlotIndexes.h"

Public Types

using MBBIndexIterator = SmallVectorImpl<IdxMBBPair>::const_iterator
 Iterator over the idx2MBBMap (sorted pairs of slot index of basic block begin and basic block)

Public Member Functions

 SlotIndexes (SlotIndexes &&)=default
 SlotIndexes (MachineFunction &MF)
LLVM_ABI ~SlotIndexes ()
void reanalyze (MachineFunction &MF)
LLVM_ABI void print (raw_ostream &OS) const
LLVM_ABI void dump () const
 Dump the indexes.
LLVM_ABI void repairIndexesInRange (MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End)
 Repair indexes after adding and removing instructions.
SlotIndex getZeroIndex ()
 Returns the zero index for this analysis.
SlotIndex getLastIndex ()
 Returns the base index of the last slot in this analysis.
bool hasIndex (const MachineInstr &instr) const
 Returns true if the given machine instr is mapped to an index, otherwise returns false.
SlotIndex getInstructionIndex (const MachineInstr &MI, bool IgnoreBundle=false) const
 Returns the base index for the given instruction.
MachineInstrgetInstructionFromIndex (SlotIndex index) const
 Returns the instruction for the given index, or null if the given index has no instruction associated with it.
SlotIndex getNextNonNullIndex (SlotIndex Index)
 Returns the next non-null index, if one exists.
SlotIndex getIndexBefore (const MachineInstr &MI) const
 getIndexBefore - Returns the index of the last indexed instruction before MI, or the start index of its basic block.
SlotIndex getIndexAfter (const MachineInstr &MI) const
 getIndexAfter - Returns the index of the first indexed instruction after MI, or the end index of its basic block.
const std::pair< SlotIndex, SlotIndex > & getMBBRange (unsigned Num) const
 Return the (start,end) range of the given basic block number.
const std::pair< SlotIndex, SlotIndex > & getMBBRange (const MachineBasicBlock *MBB) const
 Return the (start,end) range of the given basic block.
SlotIndex getMBBStartIdx (unsigned Num) const
 Returns the first index in the given basic block number.
SlotIndex getMBBStartIdx (const MachineBasicBlock *mbb) const
 Returns the first index in the given basic block.
SlotIndex getMBBEndIdx (unsigned Num) const
 Returns the last index in the given basic block number.
SlotIndex getMBBEndIdx (const MachineBasicBlock *mbb) const
 Returns the last index in the given basic block.
MBBIndexIterator getMBBLowerBound (MBBIndexIterator Start, SlotIndex Idx) const
 Get an iterator pointing to the first IdxMBBPair with SlotIndex greater than or equal to Idx.
MBBIndexIterator getMBBLowerBound (SlotIndex Idx) const
MBBIndexIterator getMBBUpperBound (SlotIndex Idx) const
 Get an iterator pointing to the first IdxMBBPair with SlotIndex greater than Idx.
MBBIndexIterator MBBIndexBegin () const
 Returns an iterator for the begin of the idx2MBBMap.
MBBIndexIterator MBBIndexEnd () const
 Return an iterator for the end of the idx2MBBMap.
MachineBasicBlockgetMBBFromIndex (SlotIndex index) const
 Returns the basic block which the given index falls in.
SlotIndex insertMachineInstrInMaps (MachineInstr &MI, bool Late=false)
 Insert the given machine instruction into the mapping.
LLVM_ABI void removeMachineInstrFromMaps (MachineInstr &MI, bool AllowBundled=false)
 Removes machine instruction (bundle) MI from the mapping.
LLVM_ABI void removeSingleMachineInstrFromMaps (MachineInstr &MI)
 Removes a single machine instruction MI from the mapping.
SlotIndex replaceMachineInstrInMaps (MachineInstr &MI, MachineInstr &NewMI)
 ReplaceMachineInstrInMaps - Replacing a machine instr with a new one in maps used by register allocator.
void insertMBBInMaps (MachineBasicBlock *mbb)
 Add the given MachineBasicBlock into the maps.
LLVM_ABI void packIndexes ()
 Renumber all indexes using the default instruction distance.

Friends

class SlotIndexesWrapperPass

Detailed Description

SlotIndexes pass.

This pass assigns indexes to each instruction.

Definition at line 298 of file SlotIndexes.h.

Member Typedef Documentation

โ—† MBBIndexIterator

Iterator over the idx2MBBMap (sorted pairs of slot index of basic block begin and basic block)

Definition at line 482 of file SlotIndexes.h.

Constructor & Destructor Documentation

โ—† SlotIndexes() [1/2]

llvm::SlotIndexes::SlotIndexes ( SlotIndexes && )
default

โ—† SlotIndexes() [2/2]

llvm::SlotIndexes::SlotIndexes ( MachineFunction & MF)
inline

Definition at line 343 of file SlotIndexes.h.

โ—† ~SlotIndexes()

SlotIndexes::~SlotIndexes ( )

Definition at line 42 of file SlotIndexes.cpp.

Member Function Documentation

โ—† dump()

LLVM_DUMP_METHOD void SlotIndexes::dump ( ) const

Dump the indexes.

Definition at line 282 of file SlotIndexes.cpp.

References llvm::dbgs(), LLVM_DUMP_METHOD, and print().

โ—† getIndexAfter()

SlotIndex llvm::SlotIndexes::getIndexAfter ( const MachineInstr & MI) const
inline

getIndexAfter - Returns the index of the first indexed instruction after MI, or the end index of its basic block.

MI is not required to have an index.

Definition at line 434 of file SlotIndexes.h.

References assert(), E(), getMBBEndIdx(), I, MBB, and MI.

Referenced by insertMachineInstrInMaps().

โ—† getIndexBefore()

SlotIndex llvm::SlotIndexes::getIndexBefore ( const MachineInstr & MI) const
inline

getIndexBefore - Returns the index of the last indexed instruction before MI, or the start index of its basic block.

MI is not required to have an index.

Definition at line 417 of file SlotIndexes.h.

References assert(), B(), getMBBStartIdx(), I, MBB, and MI.

Referenced by insertMachineInstrInMaps().

โ—† getInstructionFromIndex()

MachineInstr * llvm::SlotIndexes::getInstructionFromIndex ( SlotIndex index) const
inline

Returns the instruction for the given index, or null if the given index has no instruction associated with it.

Definition at line 398 of file SlotIndexes.h.

References llvm::IndexListEntry::getInstr().

Referenced by getMBBFromIndex(), llvm::LiveRange::overlaps(), llvm::HexagonRegisterInfo::shouldCoalesce(), and stripValuesNotDefiningMask().

โ—† getInstructionIndex()

โ—† getLastIndex()

SlotIndex llvm::SlotIndexes::getLastIndex ( )
inline

Returns the base index of the last slot in this analysis.

Definition at line 369 of file SlotIndexes.h.

Referenced by getNextNonNullIndex().

โ—† getMBBEndIdx() [1/2]

SlotIndex llvm::SlotIndexes::getMBBEndIdx ( const MachineBasicBlock * mbb) const
inline

Returns the last index in the given basic block.

Definition at line 476 of file SlotIndexes.h.

References getMBBRange().

โ—† getMBBEndIdx() [2/2]

SlotIndex llvm::SlotIndexes::getMBBEndIdx ( unsigned Num) const
inline

Returns the last index in the given basic block number.

Definition at line 471 of file SlotIndexes.h.

References getMBBRange().

Referenced by buildVRegToDbgValueMap(), getIndexAfter(), getMBBFromIndex(), insertMBBInMaps(), repairIndexesInRange(), and llvm::GCNRegPressurePrinter::runOnMachineFunction().

โ—† getMBBFromIndex()

MachineBasicBlock * llvm::SlotIndexes::getMBBFromIndex ( SlotIndex index) const
inline

Returns the basic block which the given index falls in.

Definition at line 516 of file SlotIndexes.h.

References assert(), getInstructionFromIndex(), getMBBEndIdx(), getMBBUpperBound(), I, MBBIndexEnd(), and MI.

โ—† getMBBLowerBound() [1/2]

MBBIndexIterator llvm::SlotIndexes::getMBBLowerBound ( MBBIndexIterator Start,
SlotIndex Idx ) const
inline

Get an iterator pointing to the first IdxMBBPair with SlotIndex greater than or equal to Idx.

If Start is provided, only search the range from Start to the end of the function.

Definition at line 487 of file SlotIndexes.h.

References MBBIndexEnd().

Referenced by getMBBLowerBound().

โ—† getMBBLowerBound() [2/2]

MBBIndexIterator llvm::SlotIndexes::getMBBLowerBound ( SlotIndex Idx) const
inline

Definition at line 493 of file SlotIndexes.h.

References getMBBLowerBound(), and MBBIndexBegin().

โ—† getMBBRange() [1/2]

const std::pair< SlotIndex, SlotIndex > & llvm::SlotIndexes::getMBBRange ( const MachineBasicBlock * MBB) const
inline

Return the (start,end) range of the given basic block.

Definition at line 456 of file SlotIndexes.h.

References getMBBRange(), and MBB.

โ—† getMBBRange() [2/2]

const std::pair< SlotIndex, SlotIndex > & llvm::SlotIndexes::getMBBRange ( unsigned Num) const
inline

Return the (start,end) range of the given basic block number.

Definition at line 450 of file SlotIndexes.h.

Referenced by getMBBEndIdx(), getMBBEndIdx(), getMBBRange(), getMBBStartIdx(), and getMBBStartIdx().

โ—† getMBBStartIdx() [1/2]

SlotIndex llvm::SlotIndexes::getMBBStartIdx ( const MachineBasicBlock * mbb) const
inline

Returns the first index in the given basic block.

Definition at line 466 of file SlotIndexes.h.

References getMBBRange().

โ—† getMBBStartIdx() [2/2]

SlotIndex llvm::SlotIndexes::getMBBStartIdx ( unsigned Num) const
inline

โ—† getMBBUpperBound()

MBBIndexIterator llvm::SlotIndexes::getMBBUpperBound ( SlotIndex Idx) const
inline

Get an iterator pointing to the first IdxMBBPair with SlotIndex greater than Idx.

Definition at line 499 of file SlotIndexes.h.

References MBBIndexBegin(), and MBBIndexEnd().

Referenced by getMBBFromIndex().

โ—† getNextNonNullIndex()

SlotIndex llvm::SlotIndexes::getNextNonNullIndex ( SlotIndex Index)
inline

Returns the next non-null index, if one exists.

Otherwise returns getLastIndex().

Definition at line 404 of file SlotIndexes.h.

References E(), getLastIndex(), and I.

Referenced by llvm::LiveRange::isZeroLength().

โ—† getZeroIndex()

SlotIndex llvm::SlotIndexes::getZeroIndex ( )
inline

Returns the zero index for this analysis.

Definition at line 363 of file SlotIndexes.h.

References assert().

โ—† hasIndex()

bool llvm::SlotIndexes::hasIndex ( const MachineInstr & instr) const
inline

Returns true if the given machine instr is mapped to an index, otherwise returns false.

Definition at line 375 of file SlotIndexes.h.

References instr.

Referenced by llvm::MachineBasicBlock::print().

โ—† insertMachineInstrInMaps()

SlotIndex llvm::SlotIndexes::insertMachineInstrInMaps ( MachineInstr & MI,
bool Late = false )
inline

Insert the given machine instruction into the mapping.

Returns the assigned index. If Late is set and there are null indexes between mi's neighboring instructions, create the new index after the null indexes instead of before them.

Definition at line 532 of file SlotIndexes.h.

References assert(), getIndexAfter(), getIndexBefore(), llvm::ilist_node_impl< OptionsT >::getIterator(), and MI.

Referenced by insertCSRRestores(), insertCSRSaves(), llvm::SIInstrInfo::insertScratchExecCopy(), repairIndexesInRange(), llvm::SIInstrInfo::restoreExec(), llvm::SIRegisterInfo::restoreSGPR(), and llvm::SIRegisterInfo::spillSGPR().

โ—† insertMBBInMaps()

void llvm::SlotIndexes::insertMBBInMaps ( MachineBasicBlock * mbb)
inline

Add the given MachineBasicBlock into the maps.

If it contains any instructions then they must already be in the maps. This is used after a block has been split by moving some suffix of its instructions into a newly created block.

Definition at line 607 of file SlotIndexes.h.

References assert(), llvm::MachineBasicBlock::empty(), llvm::MachineBasicBlock::front(), llvm::MachineFunction::front(), getInstructionIndex(), llvm::ilist_node_impl< OptionsT >::getIterator(), getMBBEndIdx(), llvm::MachineBasicBlock::getNumber(), llvm::MachineBasicBlock::getParent(), and llvm::sort().

Referenced by llvm::MachineBasicBlock::SplitCriticalEdge().

โ—† MBBIndexBegin()

MBBIndexIterator llvm::SlotIndexes::MBBIndexBegin ( ) const
inline

Returns an iterator for the begin of the idx2MBBMap.

Definition at line 506 of file SlotIndexes.h.

Referenced by getMBBLowerBound(), and getMBBUpperBound().

โ—† MBBIndexEnd()

MBBIndexIterator llvm::SlotIndexes::MBBIndexEnd ( ) const
inline

Return an iterator for the end of the idx2MBBMap.

Definition at line 511 of file SlotIndexes.h.

Referenced by getMBBFromIndex(), getMBBLowerBound(), and getMBBUpperBound().

โ—† packIndexes()

void SlotIndexes::packIndexes ( )

Renumber all indexes using the default instruction distance.

Definition at line 261 of file SlotIndexes.cpp.

References llvm::enumerate(), and llvm::SlotIndex::InstrDist.

โ—† print()

void SlotIndexes::print ( raw_ostream & OS) const

Definition at line 266 of file SlotIndexes.cpp.

Referenced by dump().

โ—† reanalyze()

void llvm::SlotIndexes::reanalyze ( MachineFunction & MF)
inline

Definition at line 347 of file SlotIndexes.h.

โ—† removeMachineInstrFromMaps()

void SlotIndexes::removeMachineInstrFromMaps ( MachineInstr & MI,
bool AllowBundled = false )

Removes machine instruction (bundle) MI from the mapping.

This should be called before MachineInstr::eraseFromParent() is used to remove a whole bundle or an unbundled instruction. If AllowBundled is set then this can be used on a bundled instruction; however, this exists to support handleMoveIntoBundle, and in general removeSingleMachineInstrFromMaps should be used instead.

Definition at line 127 of file SlotIndexes.cpp.

References assert(), llvm::IndexListEntry::getInstr(), MI, and llvm::IndexListEntry::setInstr().

Referenced by repairIndexesInRange().

โ—† removeSingleMachineInstrFromMaps()

void SlotIndexes::removeSingleMachineInstrFromMaps ( MachineInstr & MI)

Removes a single machine instruction MI from the mapping.

This should be called before MachineInstr::eraseFromBundle() is used to remove a single instruction (out of a bundle).

Definition at line 143 of file SlotIndexes.cpp.

References assert(), llvm::IndexListEntry::getInstr(), MI, llvm::Next, and llvm::IndexListEntry::setInstr().

โ—† repairIndexesInRange()

โ—† replaceMachineInstrInMaps()

SlotIndex llvm::SlotIndexes::replaceMachineInstrInMaps ( MachineInstr & MI,
MachineInstr & NewMI )
inline

ReplaceMachineInstrInMaps - Replacing a machine instr with a new one in maps used by register allocator.

Returns
the index where the new instruction was inserted.

Definition at line 589 of file SlotIndexes.h.

References assert(), llvm::IndexListEntry::getInstr(), MI, and llvm::IndexListEntry::setInstr().

Referenced by llvm::SIRegisterInfo::restoreSGPR(), and llvm::SIRegisterInfo::spillSGPR().

โ—† SlotIndexesWrapperPass

friend class SlotIndexesWrapperPass
friend

Definition at line 299 of file SlotIndexes.h.

References LLVM_ABI, and SlotIndexesWrapperPass.

Referenced by SlotIndexesWrapperPass.


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