LLVM 20.0.0git
Public Types | Public Member Functions | Friends | List of all members
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)
 
 ~SlotIndexes ()
 
void reanalyze (MachineFunction &MF)
 
void print (raw_ostream &OS) const
 
void dump () const
 Dump the indexes.
 
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.
 
void removeMachineInstrFromMaps (MachineInstr &MI, bool AllowBundled=false)
 Removes machine instruction (bundle) MI from the mapping.
 
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.
 
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 297 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 481 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 342 of file SlotIndexes.h.

◆ ~SlotIndexes()

SlotIndexes::~SlotIndexes ( )

Definition at line 42 of file SlotIndexes.cpp.

References llvm::simple_ilist< T, Options >::clear().

Member Function Documentation

◆ dump()

LLVM_DUMP_METHOD void SlotIndexes::dump ( ) const

Dump the indexes.

Definition at line 273 of file SlotIndexes.cpp.

References llvm::dbgs(), 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 433 of file SlotIndexes.h.

References assert(), E, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), 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 416 of file SlotIndexes.h.

References assert(), B, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), 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 397 of file SlotIndexes.h.

References llvm::IndexListEntry::getInstr().

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

◆ getInstructionIndex()

SlotIndex llvm::SlotIndexes::getInstructionIndex ( const MachineInstr MI,
bool  IgnoreBundle = false 
) const
inline

◆ getLastIndex()

SlotIndex llvm::SlotIndexes::getLastIndex ( )
inline

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

Definition at line 368 of file SlotIndexes.h.

References llvm::simple_ilist< T, Options >::back().

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 475 of file SlotIndexes.h.

References getMBBRange().

◆ getMBBEndIdx() [2/2]

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

◆ getMBBFromIndex()

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

◆ 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 486 of file SlotIndexes.h.

References Idx, and MBBIndexEnd().

Referenced by getMBBLowerBound().

◆ getMBBLowerBound() [2/2]

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

Definition at line 492 of file SlotIndexes.h.

References getMBBLowerBound(), Idx, 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 455 of file SlotIndexes.h.

References getMBBRange(), and MBB.

◆ getMBBRange() [2/2]

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

◆ getMBBStartIdx() [1/2]

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

Returns the first index in the given basic block.

Definition at line 465 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 498 of file SlotIndexes.h.

References Idx, 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 403 of file SlotIndexes.h.

References E, llvm::simple_ilist< T, Options >::end(), getLastIndex(), I, and Index.

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

◆ getZeroIndex()

SlotIndex llvm::SlotIndexes::getZeroIndex ( )
inline

Returns the zero index for this analysis.

Definition at line 362 of file SlotIndexes.h.

References assert(), and llvm::simple_ilist< T, Options >::front().

◆ hasIndex()

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

◆ insertMachineInstrInMaps()

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

◆ insertMBBInMaps()

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

◆ MBBIndexBegin()

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

Returns an iterator for the begin of the idx2MBBMap.

Definition at line 505 of file SlotIndexes.h.

References llvm::SmallVectorTemplateCommon< T, typename >::begin().

Referenced by getMBBLowerBound(), and getMBBUpperBound().

◆ MBBIndexEnd()

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

Return an iterator for the end of the idx2MBBMap.

Definition at line 510 of file SlotIndexes.h.

References llvm::SmallVectorTemplateCommon< T, typename >::end().

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

◆ packIndexes()

void SlotIndexes::packIndexes ( )

Renumber all indexes using the default instruction distance.

Definition at line 252 of file SlotIndexes.cpp.

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

Referenced by llvm::RAGreedy::runOnMachineFunction().

◆ print()

void SlotIndexes::print ( raw_ostream OS) const

Definition at line 257 of file SlotIndexes.cpp.

References OS.

Referenced by dump().

◆ reanalyze()

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

Definition at line 346 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::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::erase(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::IndexListEntry::getInstr(), MI, and llvm::IndexListEntry::setInstr().

Referenced by llvm::WindowScheduler::backupMBB(), llvm::LiveIntervals::handleMove(), llvm::LiveIntervals::handleMoveIntoNewBundle(), SlotIndexUpdateDelegate::MF_HandleRemoval(), llvm::LiveIntervals::RemoveMachineInstrFromMaps(), repairIndexesInRange(), and llvm::WindowScheduler::restoreMBB().

◆ removeSingleMachineInstrFromMaps()

void SlotIndexes::removeSingleMachineInstrFromMaps ( MachineInstr MI)

◆ repairIndexesInRange()

void SlotIndexes::repairIndexesInRange ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  Begin,
MachineBasicBlock::iterator  End 
)

◆ replaceMachineInstrInMaps()

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

Friends And Related Function Documentation

◆ SlotIndexesWrapperPass

friend class SlotIndexesWrapperPass
friend

Definition at line 298 of file SlotIndexes.h.


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