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?");
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?");
78 indexList.
push_back(createEntry(
nullptr, index));
83 SlotIndex blockStartIndex(&indexList.back(), SlotIndex::Slot_Block);
86 if (
MI.isDebugInstr())
93 mi2iMap.
insert(std::make_pair(
94 &
MI,
SlotIndex(&indexList.back(), SlotIndex::Slot_Block)));
100 MBBRanges[MBB.getNumber()].first = blockStartIndex;
101 MBBRanges[MBB.getNumber()].second =
SlotIndex(&indexList.back(),
102 SlotIndex::Slot_Block);
117 "Use removeSingleMachineInstrFromMaps() instread");
119 if (mi2iItr == mi2iMap.
end())
124 assert(MIEntry.
getInstr() == &MI &&
"Instruction indexes broken.");
125 mi2iMap.
erase(mi2iItr);
132 if (mi2iItr == mi2iMap.
end())
137 assert(MIEntry.
getInstr() == &MI &&
"Instruction indexes broken.");
138 mi2iMap.
erase(mi2iItr);
149 mi2iMap.
insert(std::make_pair(&NextMI, MIIndex));
162 static_assert((Space & 3) == 0,
"InstrDist must be a multiple of 2*NUM");
165 unsigned index = startItr->getIndex();
167 curItr->setIndex(index += Space);
170 }
while (curItr != indexList.end() && curItr->getIndex() <= index);
172 LLVM_DEBUG(
dbgs() <<
"\n*** Renumbered SlotIndexes " << startItr->getIndex()
173 <<
'-' << index <<
" ***\n");
190 bool includeStart = (Begin == MBB->
begin());
198 if (End == MBB->
end())
210 bool pastStart =
false;
211 while (ListI != ListB || MBBI != Begin || (includeStart && !pastStart)) {
212 assert(ListI->getIndex() >= startIdx.getIndex() &&
213 (includeStart || !pastStart) &&
214 "Decremented past the beginning of region to repair.");
218 bool MBBIAtBegin = MBBI == Begin && (!includeStart || pastStart);
220 if (SlotMI == MI && !MBBIAtBegin) {
226 }
else if (MI && mi2iMap.
find(MI) == mi2iMap.
end()) {
248 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 251 itr != indexList.end(); ++itr) {
252 dbgs() << itr->getIndex() <<
" ";
254 if (itr->getInstr()) {
255 dbgs() << *itr->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) The default distance between instructions as returned by distance().
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class represents lattice values for constants.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
void removeSingleMachineInstrFromMaps(MachineInstr &MI)
Removes a single machine instruction MI from the mapping.
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
bool isBundledWithPred() const
Return true if this instruction is part of a bundle, and it is not the first instruction in the bundl...
void push_back(const T &Elt)
void removeMachineInstrFromMaps(MachineInstr &MI)
Removes machine instruction (bundle) MI from the mapping.
STATISTIC(NumFunctions, "Total number of functions")
void reserve(size_type N)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void Reset()
Deallocate all but the current slab and reset the current pointer to the beginning of it...
bool isBundledWithSucc() const
Return true if this instruction is part of a bundle, and it is not the last instruction in the bundle...
SlotIndex getInstructionIndex(const MachineInstr &MI) const
Returns the base index for the given instruction.
iterator find(const_arg_type_t< KeyT > Val)
void dump() const
Dump this index to stderr.
SlotIndex insertMachineInstrInMaps(MachineInstr &MI, bool Late=false)
Insert the given machine instruction into the mapping.
MachineInstr * getInstr() const
bool erase(const KeyT &Val)
void initializeSlotIndexesPass(PassRegistry &)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
bool hasIndex(const MachineInstr &instr) const
Returns true if the given machine instr is mapped to an index, otherwise returns false.
SlotIndex getMBBStartIdx(unsigned Num) const
Returns the first index in the given basic block number.
Represent the analysis usage information of a pass.
std::pair< SlotIndex, MachineBasicBlock * > IdxMBBPair
self_iterator getIterator()
void setInstr(MachineInstr *mi)
void dump() const
Dump the indexes.
SlotIndex getMBBEndIdx(unsigned Num) const
Returns the last index in the given basic block number.
bool isDebugInstr() const
void sort(IteratorTy Start, IteratorTy End)
Iterator for intrusive lists based on ilist_node.
base_list_type::iterator iterator
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void push_back(pointer val)
void repairIndexesInRange(MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End)
Repair indexes after adding and removing instructions.
void getAnalysisUsage(AnalysisUsage &au) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Representation of each machine instruction.
This class represents an entry in the slot index list held in the SlotIndexes pass.
bool runOnMachineFunction(MachineFunction &fn) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
LLVM_NODISCARD bool empty() const
virtual void print(raw_ostream &OS, const Module *M) const
print - Print out the internal state of the pass.
INITIALIZE_PASS(SlotIndexes, DEBUG_TYPE, "Slot index numbering", false, false) STATISTIC(NumLocalRenum
LLVM_NODISCARD bool empty() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void clearAndLeakNodesUnsafely()
Remove all nodes from the list like clear(), but do not call removeNodeFromList() or deleteNode()...
This class implements an extremely fast bulk output stream that can only output to a stream...
void print(raw_ostream &os) const
Print this index to the given raw_ostream.
SlotIndex - An opaque wrapper around machine indexes.
Function object to check whether the first component of a std::pair compares less than the first comp...
Number of local renumberings