10 #define DEBUG_TYPE "slotindexes"
23 "Slot index numbering",
false,
false)
26 STATISTIC(NumGlobalRenum, "Number of global renumberings");
57 assert(indexList.
empty() &&
"Index list non-empty at initial numbering?");
58 assert(idx2MBBMap.
empty() &&
59 "Index -> MBB mapping non-empty at initial numbering?");
60 assert(MBBRanges.empty() &&
61 "MBB -> Index mapping non-empty at initial numbering?");
62 assert(mi2iMap.
empty() &&
63 "MachineInstr -> Index mapping non-empty at initial numbering?");
69 indexList.
push_back(createEntry(0, index));
73 mbbItr != mbbEnd; ++mbbItr) {
77 SlotIndex blockStartIndex(&indexList.
back(), SlotIndex::Slot_Block);
80 miItr != miEnd; ++miItr) {
90 SlotIndex::Slot_Block)));
96 MBBRanges[mbb->
getNumber()].first = blockStartIndex;
98 SlotIndex::Slot_Block);
113 DEBUG(
dbgs() <<
"\n*** Renumbering SlotIndexes ***\n");
130 assert((Space & 3) == 0 &&
"InstrDist must be a multiple of 2*NUM");
133 unsigned index = startItr->getIndex();
135 curItr->setIndex(index += Space);
138 }
while (curItr != indexList.
end() && curItr->getIndex() <= index);
140 DEBUG(
dbgs() <<
"\n*** Renumbered SlotIndexes " << startItr->getIndex() <<
'-'
141 << index <<
" ***\n");
158 bool includeStart = (Begin == MBB->
begin());
166 if (End == MBB->
end())
178 bool pastStart =
false;
179 while (ListI != ListB || MBBI != Begin || (includeStart && !pastStart)) {
180 assert(ListI->getIndex() >= startIdx.getIndex() &&
181 (includeStart || !pastStart) &&
182 "Decremented past the beginning of region to repair.");
186 bool MBBIAtBegin = MBBI == Begin && (!includeStart || pastStart);
188 if (SlotMI == MI && !MBBIAtBegin) {
194 }
else if (MI && mi2iMap.
find(MI) == mi2iMap.
end()) {
216 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
219 itr != indexList.
end(); ++itr) {
220 dbgs() << itr->getIndex() <<
" ";
222 if (itr->getInstr() != 0) {
223 dbgs() << *itr->getInstr();
229 for (
unsigned i = 0, e = MBBRanges.size(); i != e; ++i)
230 dbgs() <<
"BB#" << i <<
"\t[" << MBBRanges[i].first <<
';'
231 << MBBRanges[i].second <<
")\n";
238 os << listEntry()->
getIndex() <<
"Berd"[getSlot()];
243 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void push_back(const T &Elt)
void renumberIndexes()
Renumber the index list, providing space for new instructions.
std::pair< SlotIndex, MachineBasicBlock * > IdxMBBPair
iplist< IndexListEntry >::iterator iterator
virtual bool runOnMachineFunction(MachineFunction &fn)
void print(raw_ostream &OS, SlotIndexes *=0) const
unsigned getNumBlockIDs() const
virtual void releaseMemory()
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
bool isDebugValue() const
bundle_iterator< MachineInstr, instr_iterator > iterator
unsigned getIndex() const
void dump() const
Dump the indexes.
SlotIndex getInstructionIndex(const MachineInstr *MI) const
Returns the base index for the given instruction.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
bool hasIndex(const MachineInstr *instr) const
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
raw_ostream & dbgs()
dbgs - Return a circular-buffered debug stream.
SlotIndex getMBBEndIdx(unsigned Num) const
Returns the last index in the given basic block number.
void repairIndexesInRange(MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End)
Repair indexes after adding and removing instructions.
void print(raw_ostream &os) const
Print this index to the given raw_ostream.
virtual void getAnalysisUsage(AnalysisUsage &AU) const
void dump() const
Dump this index to stderr.
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
STATISTIC(NumGlobalRenum,"Number of global renumberings")
void removeMachineInstrFromMaps(MachineInstr *mi)
Remove the given machine instruction from the mapping.
SlotIndex getMBBStartIdx(unsigned Num) const
Returns the first index in the given basic block number.
BasicBlockListType::iterator iterator
ItTy prior(ItTy it, Dist n)
INITIALIZE_PASS(SlotIndexes,"slotindexes","Slot index numbering", false, false) STATISTIC(NumLocalRenum
iterator find(const KeyT &Val)
SlotIndex - An opaque wrapper around machine indexes.
SlotIndex insertMachineInstrInMaps(MachineInstr *mi, bool Late=false)
Number of local renumberings
void push_back(const NodeTy &val)