Go to the documentation of this file.
12 #include "llvm/Config/llvm-config.h"
19 #define DEBUG_TYPE "slotindexes"
33 "Slot index numbering",
false,
false)
66 assert(indexList.empty() &&
"Index list non-empty at initial numbering?");
67 assert(idx2MBBMap.empty() &&
68 "Index -> MBB mapping non-empty at initial numbering?");
69 assert(MBBRanges.empty() &&
70 "MBB -> Index mapping non-empty at initial numbering?");
72 "MachineInstr -> Index mapping non-empty at initial numbering?");
83 SlotIndex blockStartIndex(&indexList.back(), SlotIndex::Slot_Block);
86 if (
MI.isDebugOrPseudoInstr())
93 mi2iMap.
insert(std::make_pair(
94 &
MI,
SlotIndex(&indexList.back(), SlotIndex::Slot_Block)));
102 SlotIndex::Slot_Block);
117 assert((AllowBundled || !
MI.isBundledWithPred()) &&
118 "Use removeSingleMachineInstrFromMaps() instead");
120 if (mi2iItr == mi2iMap.
end())
126 mi2iMap.
erase(mi2iItr);
133 if (mi2iItr == mi2iMap.
end())
139 mi2iMap.
erase(mi2iItr);
143 if (
MI.isBundledWithSucc()) {
145 assert(!
MI.isBundledWithPred() &&
"Should be first bundle instruction");
150 mi2iMap.
insert(std::make_pair(&NextMI, MIIndex));
160 void SlotIndexes::renumberIndexes(IndexList::iterator curItr) {
163 static_assert((Space & 3) == 0,
"InstrDist must be a multiple of 2*NUM");
166 unsigned index = startItr->getIndex();
168 curItr->setIndex(
index += Space);
171 }
while (curItr != indexList.end() && curItr->getIndex() <=
index);
173 LLVM_DEBUG(
dbgs() <<
"\n*** Renumbered SlotIndexes " << startItr->getIndex()
174 <<
'-' <<
index <<
" ***\n");
191 bool includeStart = (Begin ==
MBB->
begin());
211 bool pastStart =
false;
212 while (ListI != ListB ||
MBBI != Begin || (includeStart && !pastStart)) {
213 assert(ListI->getIndex() >= startIdx.getIndex() &&
214 (includeStart || !pastStart) &&
215 "Decremented past the beginning of region to repair.");
219 bool MBBIAtBegin =
MBBI == Begin && (!includeStart || pastStart);
221 if (SlotMI ==
MI && !MBBIAtBegin) {
227 }
else if (
MI && mi2iMap.
find(
MI) == mi2iMap.
end()) {
244 if (!
MI.isDebugOrPseudoInstr() && mi2iMap.
find(&
MI) == mi2iMap.
end())
249 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
252 dbgs() << ILE.getIndex() <<
" ";
254 if (ILE.getInstr()) {
255 dbgs() << *ILE.getInstr();
261 for (
unsigned i = 0,
e = MBBRanges.size();
i !=
e; ++
i)
262 dbgs() <<
"%bb." <<
i <<
"\t[" << MBBRanges[
i].first <<
';'
263 << MBBRanges[
i].second <<
")\n";
270 os << listEntry()->
getIndex() <<
"Berd"[getSlot()];
275 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void dump() const
Dump this index to stderr.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
This is an optimization pass for GlobalISel generic memory operations.
void Reset()
Deallocate all but the current slab and reset the current pointer to the beginning of it,...
void push_back(pointer val)
bool isValid() const
Returns true if this is a valid index.
void setInstr(MachineInstr *mi)
void clearAndLeakNodesUnsafely()
Remove all nodes from the list like clear(), but do not call removeNodeFromList() or deleteNode().
MachineInstr * getInstr() const
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
bool erase(const KeyT &Val)
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
void repairIndexesInRange(MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End)
Repair indexes after adding and removing instructions.
SlotIndex getMBBEndIdx(unsigned Num) const
Returns the last index in the given basic block number.
void initializeSlotIndexesPass(PassRegistry &)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
INITIALIZE_PASS(SlotIndexes, DEBUG_TYPE, "Slot index numbering", false, false) STATISTIC(NumLocalRenum
bool hasIndex(const MachineInstr &instr) const
Returns true if the given machine instr is mapped to an index, otherwise returns false.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Function object to check whether the first component of a std::pair compares less than the first comp...
Represent the analysis usage information of a pass.
STATISTIC(NumFunctions, "Total number of functions")
This class implements an extremely fast bulk output stream that can only output to a stream.
SlotIndex getInstructionIndex(const MachineInstr &MI, bool IgnoreBundle=false) const
Returns the base index for the given instruction.
This class represents an entry in the slot index list held in the SlotIndexes pass.
void dump() const
Dump the indexes.
@ InstrDist
The default distance between instructions as returned by distance().
void removeSingleMachineInstrFromMaps(MachineInstr &MI)
Removes a single machine instruction MI from the mapping.
SlotIndex - An opaque wrapper around machine indexes.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
SlotIndex insertMachineInstrInMaps(MachineInstr &MI, bool Late=false)
Insert the given machine instruction into the mapping.
SlotIndex getMBBStartIdx(unsigned Num) const
Returns the first index in the given basic block number.
Representation of each machine instruction.
base_list_type::iterator iterator
iterator find(const_arg_type_t< KeyT > Val)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
MachineBasicBlock MachineBasicBlock::iterator MBBI
void print(raw_ostream &os) const
Print this index to the given raw_ostream.
self_iterator getIterator()
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
LLVM_NODISCARD bool empty() const
std::pair< SlotIndex, MachineBasicBlock * > IdxMBBPair
Iterator for intrusive lists based on ilist_node.
void sort(IteratorTy Start, IteratorTy End)
unsigned getIndex() const
bool runOnMachineFunction(MachineFunction &fn) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
void reserve(size_type N)
void removeMachineInstrFromMaps(MachineInstr &MI, bool AllowBundled=false)
Removes machine instruction (bundle) MI from the mapping.
Add support for conditional and other related patterns Instead of