LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SlotIndexes.h
Go to the documentation of this file.
1 //===- llvm/CodeGen/SlotIndexes.h - Slot indexes representation -*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements SlotIndex and related classes. The purpose of SlotIndex
11 // is to describe a position at which a register can become live, or cease to
12 // be live.
13 //
14 // SlotIndex is mostly a proxy for entries of the SlotIndexList, a class which
15 // is held is LiveIntervals and provides the real numbering. This allows
16 // LiveIntervals to perform largely transparent renumbering.
17 //===----------------------------------------------------------------------===//
18 
19 #ifndef LLVM_CODEGEN_SLOTINDEXES_H
20 #define LLVM_CODEGEN_SLOTINDEXES_H
21 
22 #include "llvm/ADT/DenseMap.h"
23 #include "llvm/ADT/IntervalMap.h"
25 #include "llvm/ADT/SmallVector.h"
26 #include "llvm/ADT/ilist.h"
30 #include "llvm/Support/Allocator.h"
31 
32 namespace llvm {
33 
34  /// This class represents an entry in the slot index list held in the
35  /// SlotIndexes pass. It should not be used directly. See the
36  /// SlotIndex & SlotIndexes classes for the public interface to this
37  /// information.
38  class IndexListEntry : public ilist_node<IndexListEntry> {
39  MachineInstr *mi;
40  unsigned index;
41 
42  public:
43 
44  IndexListEntry(MachineInstr *mi, unsigned index) : mi(mi), index(index) {}
45 
46  MachineInstr* getInstr() const { return mi; }
47  void setInstr(MachineInstr *mi) {
48  this->mi = mi;
49  }
50 
51  unsigned getIndex() const { return index; }
52  void setIndex(unsigned index) {
53  this->index = index;
54  }
55 
56 #ifdef EXPENSIVE_CHECKS
57  // When EXPENSIVE_CHECKS is defined, "erased" index list entries will
58  // actually be moved to a "graveyard" list, and have their pointers
59  // poisoned, so that dangling SlotIndex access can be reliably detected.
60  void setPoison() {
61  intptr_t tmp = reinterpret_cast<intptr_t>(mi);
62  assert(((tmp & 0x1) == 0x0) && "Pointer already poisoned?");
63  tmp |= 0x1;
64  mi = reinterpret_cast<MachineInstr*>(tmp);
65  }
66 
67  bool isPoisoned() const { return (reinterpret_cast<intptr_t>(mi) & 0x1) == 0x1; }
68 #endif // EXPENSIVE_CHECKS
69 
70  };
71 
72  template <>
73  struct ilist_traits<IndexListEntry> : public ilist_default_traits<IndexListEntry> {
74  private:
75  mutable ilist_half_node<IndexListEntry> Sentinel;
76  public:
78  return static_cast<IndexListEntry*>(&Sentinel);
79  }
81 
86 
87  private:
88  void createNode(const IndexListEntry &);
89  };
90 
91  /// SlotIndex - An opaque wrapper around machine indexes.
92  class SlotIndex {
93  friend class SlotIndexes;
94 
95  enum Slot {
96  /// Basic block boundary. Used for live ranges entering and leaving a
97  /// block without being live in the layout neighbor. Also used as the
98  /// def slot of PHI-defs.
99  Slot_Block,
100 
101  /// Early-clobber register use/def slot. A live range defined at
102  /// Slot_EarlyCLobber interferes with normal live ranges killed at
103  /// Slot_Register. Also used as the kill slot for live ranges tied to an
104  /// early-clobber def.
105  Slot_EarlyClobber,
106 
107  /// Normal register use/def slot. Normal instructions kill and define
108  /// register live ranges at this slot.
109  Slot_Register,
110 
111  /// Dead def kill point. Kill slot for a live range that is defined by
112  /// the same instruction (Slot_Register or Slot_EarlyClobber), but isn't
113  /// used anywhere.
114  Slot_Dead,
115 
116  Slot_Count
117  };
118 
120 
121  SlotIndex(IndexListEntry *entry, unsigned slot)
122  : lie(entry, slot) {}
123 
124  IndexListEntry* listEntry() const {
125  assert(isValid() && "Attempt to compare reserved index.");
126 #ifdef EXPENSIVE_CHECKS
127  assert(!lie.getPointer()->isPoisoned() &&
128  "Attempt to access deleted list-entry.");
129 #endif // EXPENSIVE_CHECKS
130  return lie.getPointer();
131  }
132 
133  unsigned getIndex() const {
134  return listEntry()->getIndex() | getSlot();
135  }
136 
137  /// Returns the slot for this SlotIndex.
138  Slot getSlot() const {
139  return static_cast<Slot>(lie.getInt());
140  }
141 
142  public:
143  enum {
144  /// The default distance between instructions as returned by distance().
145  /// This may vary as instructions are inserted and removed.
146  InstrDist = 4 * Slot_Count
147  };
148 
149  /// Construct an invalid index.
150  SlotIndex() : lie(0, 0) {}
151 
152  // Construct a new slot index from the given one, and set the slot.
153  SlotIndex(const SlotIndex &li, Slot s) : lie(li.listEntry(), unsigned(s)) {
154  assert(lie.getPointer() != 0 &&
155  "Attempt to construct index with 0 pointer.");
156  }
157 
158  /// Returns true if this is a valid index. Invalid indicies do
159  /// not point into an index table, and cannot be compared.
160  bool isValid() const {
161  return lie.getPointer();
162  }
163 
164  /// Return true for a valid index.
165  LLVM_EXPLICIT operator bool() const { return isValid(); }
166 
167  /// Print this index to the given raw_ostream.
168  void print(raw_ostream &os) const;
169 
170  /// Dump this index to stderr.
171  void dump() const;
172 
173  /// Compare two SlotIndex objects for equality.
174  bool operator==(SlotIndex other) const {
175  return lie == other.lie;
176  }
177  /// Compare two SlotIndex objects for inequality.
178  bool operator!=(SlotIndex other) const {
179  return lie != other.lie;
180  }
181 
182  /// Compare two SlotIndex objects. Return true if the first index
183  /// is strictly lower than the second.
184  bool operator<(SlotIndex other) const {
185  return getIndex() < other.getIndex();
186  }
187  /// Compare two SlotIndex objects. Return true if the first index
188  /// is lower than, or equal to, the second.
189  bool operator<=(SlotIndex other) const {
190  return getIndex() <= other.getIndex();
191  }
192 
193  /// Compare two SlotIndex objects. Return true if the first index
194  /// is greater than the second.
195  bool operator>(SlotIndex other) const {
196  return getIndex() > other.getIndex();
197  }
198 
199  /// Compare two SlotIndex objects. Return true if the first index
200  /// is greater than, or equal to, the second.
201  bool operator>=(SlotIndex other) const {
202  return getIndex() >= other.getIndex();
203  }
204 
205  /// isSameInstr - Return true if A and B refer to the same instruction.
206  static bool isSameInstr(SlotIndex A, SlotIndex B) {
207  return A.lie.getPointer() == B.lie.getPointer();
208  }
209 
210  /// isEarlierInstr - Return true if A refers to an instruction earlier than
211  /// B. This is equivalent to A < B && !isSameInstr(A, B).
213  return A.listEntry()->getIndex() < B.listEntry()->getIndex();
214  }
215 
216  /// Return the distance from this index to the given one.
217  int distance(SlotIndex other) const {
218  return other.getIndex() - getIndex();
219  }
220 
221  /// Return the scaled distance from this index to the given one, where all
222  /// slots on the same instruction have zero distance.
223  int getInstrDistance(SlotIndex other) const {
224  return (other.listEntry()->getIndex() - listEntry()->getIndex())
225  / Slot_Count;
226  }
227 
228  /// isBlock - Returns true if this is a block boundary slot.
229  bool isBlock() const { return getSlot() == Slot_Block; }
230 
231  /// isEarlyClobber - Returns true if this is an early-clobber slot.
232  bool isEarlyClobber() const { return getSlot() == Slot_EarlyClobber; }
233 
234  /// isRegister - Returns true if this is a normal register use/def slot.
235  /// Note that early-clobber slots may also be used for uses and defs.
236  bool isRegister() const { return getSlot() == Slot_Register; }
237 
238  /// isDead - Returns true if this is a dead def kill slot.
239  bool isDead() const { return getSlot() == Slot_Dead; }
240 
241  /// Returns the base index for associated with this index. The base index
242  /// is the one associated with the Slot_Block slot for the instruction
243  /// pointed to by this index.
245  return SlotIndex(listEntry(), Slot_Block);
246  }
247 
248  /// Returns the boundary index for associated with this index. The boundary
249  /// index is the one associated with the Slot_Block slot for the instruction
250  /// pointed to by this index.
252  return SlotIndex(listEntry(), Slot_Dead);
253  }
254 
255  /// Returns the register use/def slot in the current instruction for a
256  /// normal or early-clobber def.
257  SlotIndex getRegSlot(bool EC = false) const {
258  return SlotIndex(listEntry(), EC ? Slot_EarlyClobber : Slot_Register);
259  }
260 
261  /// Returns the dead def kill slot for the current instruction.
263  return SlotIndex(listEntry(), Slot_Dead);
264  }
265 
266  /// Returns the next slot in the index list. This could be either the
267  /// next slot for the instruction pointed to by this index or, if this
268  /// index is a STORE, the first slot for the next instruction.
269  /// WARNING: This method is considerably more expensive than the methods
270  /// that return specific slots (getUseIndex(), etc). If you can - please
271  /// use one of those methods.
273  Slot s = getSlot();
274  if (s == Slot_Dead) {
275  return SlotIndex(listEntry()->getNextNode(), Slot_Block);
276  }
277  return SlotIndex(listEntry(), s + 1);
278  }
279 
280  /// Returns the next index. This is the index corresponding to the this
281  /// index's slot, but for the next instruction.
283  return SlotIndex(listEntry()->getNextNode(), getSlot());
284  }
285 
286  /// Returns the previous slot in the index list. This could be either the
287  /// previous slot for the instruction pointed to by this index or, if this
288  /// index is a Slot_Block, the last slot for the previous instruction.
289  /// WARNING: This method is considerably more expensive than the methods
290  /// that return specific slots (getUseIndex(), etc). If you can - please
291  /// use one of those methods.
293  Slot s = getSlot();
294  if (s == Slot_Block) {
295  return SlotIndex(listEntry()->getPrevNode(), Slot_Dead);
296  }
297  return SlotIndex(listEntry(), s - 1);
298  }
299 
300  /// Returns the previous index. This is the index corresponding to this
301  /// index's slot, but for the previous instruction.
303  return SlotIndex(listEntry()->getPrevNode(), getSlot());
304  }
305 
306  };
307 
308  template <> struct isPodLike<SlotIndex> { static const bool value = true; };
309 
311  li.print(os);
312  return os;
313  }
314 
315  typedef std::pair<SlotIndex, MachineBasicBlock*> IdxMBBPair;
316 
317  inline bool operator<(SlotIndex V, const IdxMBBPair &IM) {
318  return V < IM.first;
319  }
320 
321  inline bool operator<(const IdxMBBPair &IM, SlotIndex V) {
322  return IM.first < V;
323  }
324 
325  struct Idx2MBBCompare {
326  bool operator()(const IdxMBBPair &LHS, const IdxMBBPair &RHS) const {
327  return LHS.first < RHS.first;
328  }
329  };
330 
331  /// SlotIndexes pass.
332  ///
333  /// This pass assigns indexes to each instruction.
335  private:
336 
338  IndexList indexList;
339 
340 #ifdef EXPENSIVE_CHECKS
341  IndexList graveyardList;
342 #endif // EXPENSIVE_CHECKS
343 
344  MachineFunction *mf;
345 
347  Mi2IndexMap mi2iMap;
348 
349  /// MBBRanges - Map MBB number to (start, stop) indexes.
351 
352  /// Idx2MBBMap - Sorted list of pairs of index of first instruction
353  /// and MBB id.
354  SmallVector<IdxMBBPair, 8> idx2MBBMap;
355 
356  // IndexListEntry allocator.
357  BumpPtrAllocator ileAllocator;
358 
359  IndexListEntry* createEntry(MachineInstr *mi, unsigned index) {
360  IndexListEntry *entry =
361  static_cast<IndexListEntry*>(
362  ileAllocator.Allocate(sizeof(IndexListEntry),
363  alignOf<IndexListEntry>()));
364 
365  new (entry) IndexListEntry(mi, index);
366 
367  return entry;
368  }
369 
370  /// Renumber locally after inserting curItr.
372 
373  public:
374  static char ID;
375 
378  }
379 
380  virtual void getAnalysisUsage(AnalysisUsage &au) const;
381  virtual void releaseMemory();
382 
383  virtual bool runOnMachineFunction(MachineFunction &fn);
384 
385  /// Dump the indexes.
386  void dump() const;
387 
388  /// Renumber the index list, providing space for new instructions.
389  void renumberIndexes();
390 
391  /// Repair indexes after adding and removing instructions.
395 
396  /// Returns the zero index for this analysis.
398  assert(indexList.front().getIndex() == 0 && "First index is not 0?");
399  return SlotIndex(&indexList.front(), 0);
400  }
401 
402  /// Returns the base index of the last slot in this analysis.
404  return SlotIndex(&indexList.back(), 0);
405  }
406 
407  /// Returns true if the given machine instr is mapped to an index,
408  /// otherwise returns false.
409  bool hasIndex(const MachineInstr *instr) const {
410  return mi2iMap.count(instr);
411  }
412 
413  /// Returns the base index for the given instruction.
415  // Instructions inside a bundle have the same number as the bundle itself.
417  assert(itr != mi2iMap.end() && "Instruction not found in maps.");
418  return itr->second;
419  }
420 
421  /// Returns the instruction for the given index, or null if the given
422  /// index has no instruction associated with it.
424  return index.isValid() ? index.listEntry()->getInstr() : 0;
425  }
426 
427  /// Returns the next non-null index, if one exists.
428  /// Otherwise returns getLastIndex().
430  IndexList::iterator I = Index.listEntry();
431  IndexList::iterator E = indexList.end();
432  while (++I != E)
433  if (I->getInstr())
434  return SlotIndex(I, Index.getSlot());
435  // We reached the end of the function.
436  return getLastIndex();
437  }
438 
439  /// getIndexBefore - Returns the index of the last indexed instruction
440  /// before MI, or the start index of its basic block.
441  /// MI is not required to have an index.
443  const MachineBasicBlock *MBB = MI->getParent();
444  assert(MBB && "MI must be inserted inna basic block");
446  for (;;) {
447  if (I == B)
448  return getMBBStartIdx(MBB);
449  --I;
450  Mi2IndexMap::const_iterator MapItr = mi2iMap.find(I);
451  if (MapItr != mi2iMap.end())
452  return MapItr->second;
453  }
454  }
455 
456  /// getIndexAfter - Returns the index of the first indexed instruction
457  /// after MI, or the end index of its basic block.
458  /// MI is not required to have an index.
460  const MachineBasicBlock *MBB = MI->getParent();
461  assert(MBB && "MI must be inserted inna basic block");
463  for (;;) {
464  ++I;
465  if (I == E)
466  return getMBBEndIdx(MBB);
467  Mi2IndexMap::const_iterator MapItr = mi2iMap.find(I);
468  if (MapItr != mi2iMap.end())
469  return MapItr->second;
470  }
471  }
472 
473  /// Return the (start,end) range of the given basic block number.
474  const std::pair<SlotIndex, SlotIndex> &
475  getMBBRange(unsigned Num) const {
476  return MBBRanges[Num];
477  }
478 
479  /// Return the (start,end) range of the given basic block.
480  const std::pair<SlotIndex, SlotIndex> &
481  getMBBRange(const MachineBasicBlock *MBB) const {
482  return getMBBRange(MBB->getNumber());
483  }
484 
485  /// Returns the first index in the given basic block number.
486  SlotIndex getMBBStartIdx(unsigned Num) const {
487  return getMBBRange(Num).first;
488  }
489 
490  /// Returns the first index in the given basic block.
492  return getMBBRange(mbb).first;
493  }
494 
495  /// Returns the last index in the given basic block number.
496  SlotIndex getMBBEndIdx(unsigned Num) const {
497  return getMBBRange(Num).second;
498  }
499 
500  /// Returns the last index in the given basic block.
502  return getMBBRange(mbb).second;
503  }
504 
505  /// Returns the basic block which the given index falls in.
508  return MI->getParent();
510  std::lower_bound(idx2MBBMap.begin(), idx2MBBMap.end(), index);
511  // Take the pair containing the index
513  ((I != idx2MBBMap.end() && I->first > index) ||
514  (I == idx2MBBMap.end() && idx2MBBMap.size()>0)) ? (I-1): I;
515 
516  assert(J != idx2MBBMap.end() && J->first <= index &&
517  index < getMBBEndIdx(J->second) &&
518  "index does not correspond to an MBB");
519  return J->second;
520  }
521 
525  std::lower_bound(idx2MBBMap.begin(), idx2MBBMap.end(), start);
526  bool resVal = false;
527 
528  while (itr != idx2MBBMap.end()) {
529  if (itr->first >= end)
530  break;
531  mbbs.push_back(itr->second);
532  resVal = true;
533  ++itr;
534  }
535  return resVal;
536  }
537 
538  /// Returns the MBB covering the given range, or null if the range covers
539  /// more than one basic block.
541 
542  assert(start < end && "Backwards ranges not allowed.");
543 
545  std::lower_bound(idx2MBBMap.begin(), idx2MBBMap.end(), start);
546 
547  if (itr == idx2MBBMap.end()) {
548  itr = prior(itr);
549  return itr->second;
550  }
551 
552  // Check that we don't cross the boundary into this block.
553  if (itr->first < end)
554  return 0;
555 
556  itr = prior(itr);
557 
558  if (itr->first <= start)
559  return itr->second;
560 
561  return 0;
562  }
563 
564  /// Insert the given machine instruction into the mapping. Returns the
565  /// assigned index.
566  /// If Late is set and there are null indexes between mi's neighboring
567  /// instructions, create the new index after the null indexes instead of
568  /// before them.
570  assert(!mi->isInsideBundle() &&
571  "Instructions inside bundles should use bundle start's slot.");
572  assert(mi2iMap.find(mi) == mi2iMap.end() && "Instr already indexed.");
573  // Numbering DBG_VALUE instructions could cause code generation to be
574  // affected by debug information.
575  assert(!mi->isDebugValue() && "Cannot number DBG_VALUE instructions.");
576 
577  assert(mi->getParent() != 0 && "Instr must be added to function.");
578 
579  // Get the entries where mi should be inserted.
580  IndexList::iterator prevItr, nextItr;
581  if (Late) {
582  // Insert mi's index immediately before the following instruction.
583  nextItr = getIndexAfter(mi).listEntry();
584  prevItr = prior(nextItr);
585  } else {
586  // Insert mi's index immediately after the preceding instruction.
587  prevItr = getIndexBefore(mi).listEntry();
588  nextItr = llvm::next(prevItr);
589  }
590 
591  // Get a number for the new instr, or 0 if there's no room currently.
592  // In the latter case we'll force a renumber later.
593  unsigned dist = ((nextItr->getIndex() - prevItr->getIndex())/2) & ~3u;
594  unsigned newNumber = prevItr->getIndex() + dist;
595 
596  // Insert a new list entry for mi.
597  IndexList::iterator newItr =
598  indexList.insert(nextItr, createEntry(mi, newNumber));
599 
600  // Renumber locally if we need to.
601  if (dist == 0)
602  renumberIndexes(newItr);
603 
604  SlotIndex newIndex(&*newItr, SlotIndex::Slot_Block);
605  mi2iMap.insert(std::make_pair(mi, newIndex));
606  return newIndex;
607  }
608 
609  /// Remove the given machine instruction from the mapping.
611  // remove index -> MachineInstr and
612  // MachineInstr -> index mappings
613  Mi2IndexMap::iterator mi2iItr = mi2iMap.find(mi);
614  if (mi2iItr != mi2iMap.end()) {
615  IndexListEntry *miEntry(mi2iItr->second.listEntry());
616  assert(miEntry->getInstr() == mi && "Instruction indexes broken.");
617  // FIXME: Eventually we want to actually delete these indexes.
618  miEntry->setInstr(0);
619  mi2iMap.erase(mi2iItr);
620  }
621  }
622 
623  /// ReplaceMachineInstrInMaps - Replacing a machine instr with a new one in
624  /// maps used by register allocator.
626  Mi2IndexMap::iterator mi2iItr = mi2iMap.find(mi);
627  if (mi2iItr == mi2iMap.end())
628  return;
629  SlotIndex replaceBaseIndex = mi2iItr->second;
630  IndexListEntry *miEntry(replaceBaseIndex.listEntry());
631  assert(miEntry->getInstr() == mi &&
632  "Mismatched instruction in index tables.");
633  miEntry->setInstr(newMI);
634  mi2iMap.erase(mi2iItr);
635  mi2iMap.insert(std::make_pair(newMI, replaceBaseIndex));
636  }
637 
638  /// Add the given MachineBasicBlock into the maps.
640  MachineFunction::iterator nextMBB =
642 
643  IndexListEntry *startEntry = 0;
644  IndexListEntry *endEntry = 0;
645  IndexList::iterator newItr;
646  if (nextMBB == mbb->getParent()->end()) {
647  startEntry = &indexList.back();
648  endEntry = createEntry(0, 0);
649  newItr = indexList.insertAfter(startEntry, endEntry);
650  } else {
651  startEntry = createEntry(0, 0);
652  endEntry = getMBBStartIdx(nextMBB).listEntry();
653  newItr = indexList.insert(endEntry, startEntry);
654  }
655 
656  SlotIndex startIdx(startEntry, SlotIndex::Slot_Block);
657  SlotIndex endIdx(endEntry, SlotIndex::Slot_Block);
658 
659  MachineFunction::iterator prevMBB(mbb);
660  assert(prevMBB != mbb->getParent()->end() &&
661  "Can't insert a new block at the beginning of a function.");
662  --prevMBB;
663  MBBRanges[prevMBB->getNumber()].second = startIdx;
664 
665  assert(unsigned(mbb->getNumber()) == MBBRanges.size() &&
666  "Blocks must be added in order");
667  MBBRanges.push_back(std::make_pair(startIdx, endIdx));
668  idx2MBBMap.push_back(IdxMBBPair(startIdx, mbb));
669 
670  renumberIndexes(newItr);
671  std::sort(idx2MBBMap.begin(), idx2MBBMap.end(), Idx2MBBCompare());
672  }
673 
674  /// \brief Free the resources that were required to maintain a SlotIndex.
675  ///
676  /// Once an index is no longer needed (for instance because the instruction
677  /// at that index has been moved), the resources required to maintain the
678  /// index can be relinquished to reduce memory use and improve renumbering
679  /// performance. Any remaining SlotIndex objects that point to the same
680  /// index are left 'dangling' (much the same as a dangling pointer to a
681  /// freed object) and should not be accessed, except to destruct them.
682  ///
683  /// Like dangling pointers, access to dangling SlotIndexes can cause
684  /// painful-to-track-down bugs, especially if the memory for the index
685  /// previously pointed to has been re-used. To detect dangling SlotIndex
686  /// bugs, build with EXPENSIVE_CHECKS=1. This will cause "erased" indexes to
687  /// be retained in a graveyard instead of being freed. Operations on indexes
688  /// in the graveyard will trigger an assertion.
689  void eraseIndex(SlotIndex index) {
690  IndexListEntry *entry = index.listEntry();
691 #ifdef EXPENSIVE_CHECKS
692  indexList.remove(entry);
693  graveyardList.push_back(entry);
694  entry->setPoison();
695 #else
696  indexList.erase(entry);
697 #endif
698  }
699 
700  };
701 
702 
703  // Specialize IntervalMapInfo for half-open slot index intervals.
704  template <>
706  };
707 
708 }
709 
710 #endif // LLVM_CODEGEN_SLOTINDEXES_H
bool isInsideBundle() const
Definition: MachineInstr.h:210
const MachineFunction * getParent() const
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:181
void renumberIndexes()
Renumber the index list, providing space for new instructions.
static PassRegistry * getPassRegistry()
std::pair< SlotIndex, MachineBasicBlock * > IdxMBBPair
Definition: SlotIndexes.h:315
iplist< IndexListEntry >::iterator iterator
Definition: ilist.h:642
static NodeTy * createNode(const NodeTy &V)
Definition: ilist.h:112
SlotIndex getBoundaryIndex() const
Definition: SlotIndexes.h:251
int getInstrDistance(SlotIndex other) const
Definition: SlotIndexes.h:223
virtual bool runOnMachineFunction(MachineFunction &fn)
Definition: SlotIndexes.cpp:41
void destroySentinel(IndexListEntry *) const
Definition: SlotIndexes.h:80
SlotIndex getBaseIndex() const
Definition: SlotIndexes.h:244
int distance(SlotIndex other) const
Return the distance from this index to the given one.
Definition: SlotIndexes.h:217
MachineInstr * getInstr() const
Definition: SlotIndexes.h:46
bool operator==(SlotIndex other) const
Compare two SlotIndex objects for equality.
Definition: SlotIndexes.h:174
void deleteNode(IndexListEntry *N)
Definition: SlotIndexes.h:85
void operator<(const Optional< T > &X, const Optional< U > &Y)
Poison comparison between two Optional objects. Clients needs to explicitly compare the underlying va...
static const bool value
Definition: type_traits.h:74
bool isRegister() const
Definition: SlotIndexes.h:236
SlotIndex getIndexAfter(const MachineInstr *MI) const
Definition: SlotIndexes.h:459
bool isEarlyClobber() const
isEarlyClobber - Returns true if this is an early-clobber slot.
Definition: SlotIndexes.h:232
static bool isEarlierInstr(SlotIndex A, SlotIndex B)
Definition: SlotIndexes.h:212
SlotIndex getLastIndex()
Returns the base index of the last slot in this analysis.
Definition: SlotIndexes.h:403
bool operator>=(SlotIndex other) const
Definition: SlotIndexes.h:201
bool operator>(SlotIndex other) const
Definition: SlotIndexes.h:195
virtual void releaseMemory()
Definition: SlotIndexes.cpp:33
static void noteHead(IndexListEntry *, IndexListEntry *)
Definition: SlotIndexes.h:84
bool isBlock() const
isBlock - Returns true if this is a block boundary slot.
Definition: SlotIndexes.h:229
SlotIndex getDeadSlot() const
Returns the dead def kill slot for the current instruction.
Definition: SlotIndexes.h:262
SlotIndex getNextNonNullIndex(SlotIndex Index)
Definition: SlotIndexes.h:429
bool isDead() const
isDead - Returns true if this is a dead def kill slot.
Definition: SlotIndexes.h:239
void eraseIndex(SlotIndex index)
Free the resources that were required to maintain a SlotIndex.
Definition: SlotIndexes.h:689
bool operator!=(SlotIndex other) const
Compare two SlotIndex objects for inequality.
Definition: SlotIndexes.h:178
IndexListEntry * provideInitialHead() const
Definition: SlotIndexes.h:82
SlotIndex getPrevIndex() const
Definition: SlotIndexes.h:302
void setIndex(unsigned index)
Definition: SlotIndexes.h:52
SlotIndex getPrevSlot() const
Definition: SlotIndexes.h:292
const MachineBasicBlock * getParent() const
Definition: MachineInstr.h:119
bool isDebugValue() const
Definition: MachineInstr.h:639
unsigned getIndex() const
Definition: SlotIndexes.h:51
bool operator<=(SlotIndex other) const
Definition: SlotIndexes.h:189
void initializeSlotIndexesPass(PassRegistry &)
bool isValid() const
Definition: SlotIndexes.h:160
SlotIndex(const SlotIndex &li, Slot s)
Definition: SlotIndexes.h:153
bool operator<(SlotIndex other) const
Definition: SlotIndexes.h:184
void insertMBBInMaps(MachineBasicBlock *mbb)
Add the given MachineBasicBlock into the maps.
Definition: SlotIndexes.h:639
bool findLiveInMBBs(SlotIndex start, SlotIndex end, SmallVectorImpl< MachineBasicBlock * > &mbbs) const
Definition: SlotIndexes.h:522
iterator insertAfter(iterator where, NodeTy *New)
Definition: ilist.h:428
bool operator()(const IdxMBBPair &LHS, const IdxMBBPair &RHS) const
Definition: SlotIndexes.h:326
iterator insert(iterator where, const NodeTy &val)
Definition: ilist.h:664
ItTy next(ItTy it, Dist n)
Definition: STLExtras.h:154
void dump() const
Dump the indexes.
SlotIndex getZeroIndex()
Returns the zero index for this analysis.
Definition: SlotIndexes.h:397
iterator end()
Definition: DenseMap.h:57
void setInstr(MachineInstr *mi)
Definition: SlotIndexes.h:47
bool count(const KeyT &Val) const
count - Return true if the specified key is in the map.
Definition: DenseMap.h:103
SlotIndex getInstructionIndex(const MachineInstr *MI) const
Returns the base index for the given instruction.
Definition: SlotIndexes.h:414
iterator erase(iterator where)
Definition: ilist.h:465
MachineInstr * getInstructionFromIndex(SlotIndex index) const
Definition: SlotIndexes.h:423
SlotIndex getIndexBefore(const MachineInstr *MI) const
Definition: SlotIndexes.h:442
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition: DenseMap.h:153
static bool isSameInstr(SlotIndex A, SlotIndex B)
isSameInstr - Return true if A and B refer to the same instruction.
Definition: SlotIndexes.h:206
bool hasIndex(const MachineInstr *instr) const
Definition: SlotIndexes.h:409
MachineBasicBlock * getMBBFromIndex(SlotIndex index) const
Returns the basic block which the given index falls in.
Definition: SlotIndexes.h:506
SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const
Returns the last index in the given basic block.
Definition: SlotIndexes.h:501
bool erase(const KeyT &Val)
Definition: DenseMap.h:190
MachineBasicBlock * getMBBCoveringRange(SlotIndex start, SlotIndex end) const
Definition: SlotIndexes.h:540
SlotIndex getMBBEndIdx(unsigned Num) const
Returns the last index in the given basic block number.
Definition: SlotIndexes.h:496
void * Allocate(size_t Size, size_t Alignment)
Definition: Allocator.cpp:95
IndexListEntry(MachineInstr *mi, unsigned index)
Definition: SlotIndexes.h:44
void repairIndexesInRange(MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End)
Repair indexes after adding and removing instructions.
MachineInstr * getBundleStart(MachineInstr *MI)
reference front()
Definition: ilist.h:390
SlotIndex getNextIndex() const
Definition: SlotIndexes.h:282
void print(raw_ostream &os) const
Print this index to the given raw_ostream.
bundle_iterator< const MachineInstr, const_instr_iterator > const_iterator
static char ID
Definition: SlotIndexes.h:374
void replaceMachineInstrInMaps(MachineInstr *mi, MachineInstr *newMI)
Definition: SlotIndexes.h:625
#define LLVM_EXPLICIT
Expands to explicit on compilers which support explicit conversion operators. Otherwise expands to no...
Definition: Compiler.h:381
IndexListEntry * ensureHead(IndexListEntry *) const
Definition: SlotIndexes.h:83
void dump() const
Dump this index to stderr.
#define I(x, y, z)
Definition: MD5.cpp:54
#define N
SlotIndex()
Construct an invalid index.
Definition: SlotIndexes.h:150
void removeMachineInstrFromMaps(MachineInstr *mi)
Remove the given machine instruction from the mapping.
Definition: SlotIndexes.h:610
SlotIndex getMBBStartIdx(unsigned Num) const
Returns the first index in the given basic block number.
Definition: SlotIndexes.h:486
virtual void getAnalysisUsage(AnalysisUsage &au) const
Definition: SlotIndexes.cpp:28
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
Definition: APInt.h:1688
reference back()
Definition: ilist.h:398
SlotIndex getRegSlot(bool EC=false) const
Definition: SlotIndexes.h:257
static NodeTy * createSentinel()
createSentinel - create the dynamic sentinel
Definition: ilist.h:78
IndexListEntry * createSentinel() const
Definition: SlotIndexes.h:77
iterator end()
Definition: ilist.h:367
const std::pair< SlotIndex, SlotIndex > & getMBBRange(const MachineBasicBlock *MBB) const
Return the (start,end) range of the given basic block.
Definition: SlotIndexes.h:481
BasicBlockListType::iterator iterator
ItTy prior(ItTy it, Dist n)
Definition: STLExtras.h:167
SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const
Returns the first index in the given basic block.
Definition: SlotIndexes.h:491
SlotIndex getNextSlot() const
Definition: SlotIndexes.h:272
iterator find(const KeyT &Val)
Definition: DenseMap.h:108
SlotIndex - An opaque wrapper around machine indexes.
Definition: SlotIndexes.h:92
SlotIndex insertMachineInstrInMaps(MachineInstr *mi, bool Late=false)
Definition: SlotIndexes.h:569
NodeTy * remove(iterator &IT)
Definition: ilist.h:435
const std::pair< SlotIndex, SlotIndex > & getMBBRange(unsigned Num) const
Return the (start,end) range of the given basic block number.
Definition: SlotIndexes.h:475