1 //===---- ScheduleDAG.cpp - Implement the ScheduleDAG class ---------------===//
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 implements the ScheduleDAG class, which is a base class used by
11 // scheduling implementation classes.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "llvm/CodeGen/ScheduleDAG.h"
16 #include "llvm/CodeGen/ScheduleHazardRecognizer.h"
17 #include "llvm/CodeGen/SelectionDAGNodes.h"
18 #include "llvm/Support/CommandLine.h"
19 #include "llvm/Support/Debug.h"
20 #include "llvm/Support/raw_ostream.h"
21 #include "llvm/Target/TargetInstrInfo.h"
22 #include "llvm/Target/TargetMachine.h"
23 #include "llvm/Target/TargetRegisterInfo.h"
24 #include "llvm/Target/TargetSubtargetInfo.h"
25 #include <climits>
26 using namespace llvm;
27 
28 #define DEBUG_TYPE "pre-RA-sched"
29 
30 #ifndef NDEBUG
31 static cl::opt<bool> StressSchedOpt(
32   "stress-sched", cl::Hidden, cl::init(false),
33   cl::desc("Stress test instruction scheduling"));
34 #endif
35 
36 void SchedulingPriorityQueue::anchor() { }
37 
38 ScheduleDAG::ScheduleDAG(MachineFunction &mf)
39     : TM(mf.getTarget()), TII(mf.getSubtarget().getInstrInfo()),
40       TRI(mf.getSubtarget().getRegisterInfo()), MF(mf),
41       MRI(mf.getRegInfo()), EntrySU(), ExitSU() {
42 #ifndef NDEBUG
43   StressSched = StressSchedOpt;
44 #endif
45 }
46 
47 ScheduleDAG::~ScheduleDAG() {}
48 
49 /// Clear the DAG state (e.g. between scheduling regions).
50 void ScheduleDAG::clearDAG() {
51   SUnits.clear();
52   EntrySU = SUnit();
53   ExitSU = SUnit();
54 }
55 
56 /// getInstrDesc helper to handle SDNodes.
57 const MCInstrDesc *ScheduleDAG::getNodeDesc(const SDNode *Node) const {
58   if (!Node || !Node->isMachineOpcode()) return nullptr;
59   return &TII->get(Node->getMachineOpcode());
60 }
61 
62 /// addPred - This adds the specified edge as a pred of the current node if
63 /// not already.  It also adds the current node as a successor of the
64 /// specified node.
65 bool SUnit::addPred(const SDep &D, bool Required) {
66   // If this node already has this dependence, don't add a redundant one.
67   for (SmallVectorImpl<SDep>::iterator I = Preds.begin(), E = Preds.end();
68          I != E; ++I) {
69     // Zero-latency weak edges may be added purely for heuristic ordering. Don't
70     // add them if another kind of edge already exists.
71     if (!Required && I->getSUnit() == D.getSUnit())
72       return false;
73     if (I->overlaps(D)) {
74       // Extend the latency if needed. Equivalent to removePred(I) + addPred(D).
75       if (I->getLatency() < D.getLatency()) {
76         SUnit *PredSU = I->getSUnit();
77         // Find the corresponding successor in N.
78         SDep ForwardD = *I;
79         ForwardD.setSUnit(this);
80         for (SmallVectorImpl<SDep>::iterator II = PredSU->Succs.begin(),
81                EE = PredSU->Succs.end(); II != EE; ++II) {
82           if (*II == ForwardD) {
83             II->setLatency(D.getLatency());
84             break;
85           }
86         }
87         I->setLatency(D.getLatency());
88       }
89       return false;
90     }
91   }
92   // Now add a corresponding succ to N.
93   SDep P = D;
94   P.setSUnit(this);
95   SUnit *N = D.getSUnit();
96   // Update the bookkeeping.
97   if (D.getKind() == SDep::Data) {
98     assert(NumPreds < UINT_MAX && "NumPreds will overflow!");
99     assert(N->NumSuccs < UINT_MAX && "NumSuccs will overflow!");
100     ++NumPreds;
101     ++N->NumSuccs;
102   }
103   if (!N->isScheduled) {
104     if (D.isWeak()) {
105       ++WeakPredsLeft;
106     }
107     else {
108       assert(NumPredsLeft < UINT_MAX && "NumPredsLeft will overflow!");
109       ++NumPredsLeft;
110     }
111   }
112   if (!isScheduled) {
113     if (D.isWeak()) {
114       ++N->WeakSuccsLeft;
115     }
116     else {
117       assert(N->NumSuccsLeft < UINT_MAX && "NumSuccsLeft will overflow!");
118       ++N->NumSuccsLeft;
119     }
120   }
121   Preds.push_back(D);
122   N->Succs.push_back(P);
123   if (P.getLatency() != 0) {
124     this->setDepthDirty();
125     N->setHeightDirty();
126   }
127   return true;
128 }
129 
130 /// removePred - This removes the specified edge as a pred of the current
131 /// node if it exists.  It also removes the current node as a successor of
132 /// the specified node.
133 void SUnit::removePred(const SDep &D) {
134   // Find the matching predecessor.
135   for (SmallVectorImpl<SDep>::iterator I = Preds.begin(), E = Preds.end();
136          I != E; ++I)
137     if (*I == D) {
138       // Find the corresponding successor in N.
139       SDep P = D;
140       P.setSUnit(this);
141       SUnit *N = D.getSUnit();
142       SmallVectorImpl<SDep>::iterator Succ = find(N->Succs, P);
143       assert(Succ != N->Succs.end() && "Mismatching preds / succs lists!");
144       N->Succs.erase(Succ);
145       Preds.erase(I);
146       // Update the bookkeeping.
147       if (P.getKind() == SDep::Data) {
148         assert(NumPreds > 0 && "NumPreds will underflow!");
149         assert(N->NumSuccs > 0 && "NumSuccs will underflow!");
150         --NumPreds;
151         --N->NumSuccs;
152       }
153       if (!N->isScheduled) {
154         if (D.isWeak())
155           --WeakPredsLeft;
156         else {
157           assert(NumPredsLeft > 0 && "NumPredsLeft will underflow!");
158           --NumPredsLeft;
159         }
160       }
161       if (!isScheduled) {
162         if (D.isWeak())
163           --N->WeakSuccsLeft;
164         else {
165           assert(N->NumSuccsLeft > 0 && "NumSuccsLeft will underflow!");
166           --N->NumSuccsLeft;
167         }
168       }
169       if (P.getLatency() != 0) {
170         this->setDepthDirty();
171         N->setHeightDirty();
172       }
173       return;
174     }
175 }
176 
177 void SUnit::setDepthDirty() {
178   if (!isDepthCurrent) return;
179   SmallVector<SUnit*, 8> WorkList;
180   WorkList.push_back(this);
181   do {
182     SUnit *SU = WorkList.pop_back_val();
183     SU->isDepthCurrent = false;
184     for (SUnit::const_succ_iterator I = SU->Succs.begin(),
185          E = SU->Succs.end(); I != E; ++I) {
186       SUnit *SuccSU = I->getSUnit();
187       if (SuccSU->isDepthCurrent)
188         WorkList.push_back(SuccSU);
189     }
190   } while (!WorkList.empty());
191 }
192 
193 void SUnit::setHeightDirty() {
194   if (!isHeightCurrent) return;
195   SmallVector<SUnit*, 8> WorkList;
196   WorkList.push_back(this);
197   do {
198     SUnit *SU = WorkList.pop_back_val();
199     SU->isHeightCurrent = false;
200     for (SUnit::const_pred_iterator I = SU->Preds.begin(),
201          E = SU->Preds.end(); I != E; ++I) {
202       SUnit *PredSU = I->getSUnit();
203       if (PredSU->isHeightCurrent)
204         WorkList.push_back(PredSU);
205     }
206   } while (!WorkList.empty());
207 }
208 
209 /// setDepthToAtLeast - Update this node's successors to reflect the
210 /// fact that this node's depth just increased.
211 ///
212 void SUnit::setDepthToAtLeast(unsigned NewDepth) {
213   if (NewDepth <= getDepth())
214     return;
215   setDepthDirty();
216   Depth = NewDepth;
217   isDepthCurrent = true;
218 }
219 
220 /// setHeightToAtLeast - Update this node's predecessors to reflect the
221 /// fact that this node's height just increased.
222 ///
223 void SUnit::setHeightToAtLeast(unsigned NewHeight) {
224   if (NewHeight <= getHeight())
225     return;
226   setHeightDirty();
227   Height = NewHeight;
228   isHeightCurrent = true;
229 }
230 
231 /// ComputeDepth - Calculate the maximal path from the node to the exit.
232 ///
233 void SUnit::ComputeDepth() {
234   SmallVector<SUnit*, 8> WorkList;
235   WorkList.push_back(this);
236   do {
237     SUnit *Cur = WorkList.back();
238 
239     bool Done = true;
240     unsigned MaxPredDepth = 0;
241     for (SUnit::const_pred_iterator I = Cur->Preds.begin(),
242          E = Cur->Preds.end(); I != E; ++I) {
243       SUnit *PredSU = I->getSUnit();
244       if (PredSU->isDepthCurrent)
245         MaxPredDepth = std::max(MaxPredDepth,
246                                 PredSU->Depth + I->getLatency());
247       else {
248         Done = false;
249         WorkList.push_back(PredSU);
250       }
251     }
252 
253     if (Done) {
254       WorkList.pop_back();
255       if (MaxPredDepth != Cur->Depth) {
256         Cur->setDepthDirty();
257         Cur->Depth = MaxPredDepth;
258       }
259       Cur->isDepthCurrent = true;
260     }
261   } while (!WorkList.empty());
262 }
263 
264 /// ComputeHeight - Calculate the maximal path from the node to the entry.
265 ///
266 void SUnit::ComputeHeight() {
267   SmallVector<SUnit*, 8> WorkList;
268   WorkList.push_back(this);
269   do {
270     SUnit *Cur = WorkList.back();
271 
272     bool Done = true;
273     unsigned MaxSuccHeight = 0;
274     for (SUnit::const_succ_iterator I = Cur->Succs.begin(),
275          E = Cur->Succs.end(); I != E; ++I) {
276       SUnit *SuccSU = I->getSUnit();
277       if (SuccSU->isHeightCurrent)
278         MaxSuccHeight = std::max(MaxSuccHeight,
279                                  SuccSU->Height + I->getLatency());
280       else {
281         Done = false;
282         WorkList.push_back(SuccSU);
283       }
284     }
285 
286     if (Done) {
287       WorkList.pop_back();
288       if (MaxSuccHeight != Cur->Height) {
289         Cur->setHeightDirty();
290         Cur->Height = MaxSuccHeight;
291       }
292       Cur->isHeightCurrent = true;
293     }
294   } while (!WorkList.empty());
295 }
296 
297 void SUnit::biasCriticalPath() {
298   if (NumPreds < 2)
299     return;
300 
301   SUnit::pred_iterator BestI = Preds.begin();
302   unsigned MaxDepth = BestI->getSUnit()->getDepth();
303   for (SUnit::pred_iterator I = std::next(BestI), E = Preds.end(); I != E;
304        ++I) {
305     if (I->getKind() == SDep::Data && I->getSUnit()->getDepth() > MaxDepth)
306       BestI = I;
307   }
308   if (BestI != Preds.begin())
309     std::swap(*Preds.begin(), *BestI);
310 }
311 
312 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
313 /// SUnit - Scheduling unit. It's an wrapper around either a single SDNode or
314 /// a group of nodes flagged together.
315 void SUnit::dump(const ScheduleDAG *G) const {
316   dbgs() << "SU(" << NodeNum << "): ";
317   G->dumpNode(this);
318 }
319 
320 void SUnit::dumpAll(const ScheduleDAG *G) const {
321   dump(G);
322 
323   dbgs() << "  # preds left       : " << NumPredsLeft << "\n";
324   dbgs() << "  # succs left       : " << NumSuccsLeft << "\n";
325   if (WeakPredsLeft)
326     dbgs() << "  # weak preds left  : " << WeakPredsLeft << "\n";
327   if (WeakSuccsLeft)
328     dbgs() << "  # weak succs left  : " << WeakSuccsLeft << "\n";
329   dbgs() << "  # rdefs left       : " << NumRegDefsLeft << "\n";
330   dbgs() << "  Latency            : " << Latency << "\n";
331   dbgs() << "  Depth              : " << getDepth() << "\n";
332   dbgs() << "  Height             : " << getHeight() << "\n";
333 
334   if (Preds.size() != 0) {
335     dbgs() << "  Predecessors:\n";
336     for (SUnit::const_succ_iterator I = Preds.begin(), E = Preds.end();
337          I != E; ++I) {
338       dbgs() << "   ";
339       switch (I->getKind()) {
340       case SDep::Data:   dbgs() << "data "; break;
341       case SDep::Anti:   dbgs() << "anti "; break;
342       case SDep::Output: dbgs() << "out  "; break;
343       case SDep::Order:  dbgs() << "ord  "; break;
344       }
345       dbgs() << "SU(" << I->getSUnit()->NodeNum << ")";
346       if (I->isArtificial())
347         dbgs() << " *";
348       dbgs() << ": Latency=" << I->getLatency();
349       if (I->isAssignedRegDep())
350         dbgs() << " Reg=" << PrintReg(I->getReg(), G->TRI);
351       dbgs() << "\n";
352     }
353   }
354   if (Succs.size() != 0) {
355     dbgs() << "  Successors:\n";
356     for (SUnit::const_succ_iterator I = Succs.begin(), E = Succs.end();
357          I != E; ++I) {
358       dbgs() << "   ";
359       switch (I->getKind()) {
360       case SDep::Data:   dbgs() << "data "; break;
361       case SDep::Anti:   dbgs() << "anti "; break;
362       case SDep::Output: dbgs() << "out  "; break;
363       case SDep::Order:  dbgs() << "ord  "; break;
364       }
365       dbgs() << "SU(" << I->getSUnit()->NodeNum << ")";
366       if (I->isArtificial())
367         dbgs() << " *";
368       dbgs() << ": Latency=" << I->getLatency();
369       if (I->isAssignedRegDep())
370         dbgs() << " Reg=" << PrintReg(I->getReg(), G->TRI);
371       dbgs() << "\n";
372     }
373   }
374 }
375 #endif
376 
377 #ifndef NDEBUG
378 /// VerifyScheduledDAG - Verify that all SUnits were scheduled and that
379 /// their state is consistent. Return the number of scheduled nodes.
380 ///
381 unsigned ScheduleDAG::VerifyScheduledDAG(bool isBottomUp) {
382   bool AnyNotSched = false;
383   unsigned DeadNodes = 0;
384   for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
385     if (!SUnits[i].isScheduled) {
386       if (SUnits[i].NumPreds == 0 && SUnits[i].NumSuccs == 0) {
387         ++DeadNodes;
388         continue;
389       }
390       if (!AnyNotSched)
391         dbgs() << "*** Scheduling failed! ***\n";
392       SUnits[i].dump(this);
393       dbgs() << "has not been scheduled!\n";
394       AnyNotSched = true;
395     }
396     if (SUnits[i].isScheduled &&
397         (isBottomUp ? SUnits[i].getHeight() : SUnits[i].getDepth()) >
398           unsigned(INT_MAX)) {
399       if (!AnyNotSched)
400         dbgs() << "*** Scheduling failed! ***\n";
401       SUnits[i].dump(this);
402       dbgs() << "has an unexpected "
403            << (isBottomUp ? "Height" : "Depth") << " value!\n";
404       AnyNotSched = true;
405     }
406     if (isBottomUp) {
407       if (SUnits[i].NumSuccsLeft != 0) {
408         if (!AnyNotSched)
409           dbgs() << "*** Scheduling failed! ***\n";
410         SUnits[i].dump(this);
411         dbgs() << "has successors left!\n";
412         AnyNotSched = true;
413       }
414     } else {
415       if (SUnits[i].NumPredsLeft != 0) {
416         if (!AnyNotSched)
417           dbgs() << "*** Scheduling failed! ***\n";
418         SUnits[i].dump(this);
419         dbgs() << "has predecessors left!\n";
420         AnyNotSched = true;
421       }
422     }
423   }
424   assert(!AnyNotSched);
425   return SUnits.size() - DeadNodes;
426 }
427 #endif
428 
429 /// InitDAGTopologicalSorting - create the initial topological
430 /// ordering from the DAG to be scheduled.
431 ///
432 /// The idea of the algorithm is taken from
433 /// "Online algorithms for managing the topological order of
434 /// a directed acyclic graph" by David J. Pearce and Paul H.J. Kelly
435 /// This is the MNR algorithm, which was first introduced by
436 /// A. Marchetti-Spaccamela, U. Nanni and H. Rohnert in
437 /// "Maintaining a topological order under edge insertions".
438 ///
439 /// Short description of the algorithm:
440 ///
441 /// Topological ordering, ord, of a DAG maps each node to a topological
442 /// index so that for all edges X->Y it is the case that ord(X) < ord(Y).
443 ///
444 /// This means that if there is a path from the node X to the node Z,
445 /// then ord(X) < ord(Z).
446 ///
447 /// This property can be used to check for reachability of nodes:
448 /// if Z is reachable from X, then an insertion of the edge Z->X would
449 /// create a cycle.
450 ///
451 /// The algorithm first computes a topological ordering for the DAG by
452 /// initializing the Index2Node and Node2Index arrays and then tries to keep
453 /// the ordering up-to-date after edge insertions by reordering the DAG.
454 ///
455 /// On insertion of the edge X->Y, the algorithm first marks by calling DFS
456 /// the nodes reachable from Y, and then shifts them using Shift to lie
457 /// immediately after X in Index2Node.
458 void ScheduleDAGTopologicalSort::InitDAGTopologicalSorting() {
459   unsigned DAGSize = SUnits.size();
460   std::vector<SUnit*> WorkList;
461   WorkList.reserve(DAGSize);
462 
463   Index2Node.resize(DAGSize);
464   Node2Index.resize(DAGSize);
465 
466   // Initialize the data structures.
467   if (ExitSU)
468     WorkList.push_back(ExitSU);
469   for (unsigned i = 0, e = DAGSize; i != e; ++i) {
470     SUnit *SU = &SUnits[i];
471     int NodeNum = SU->NodeNum;
472     unsigned Degree = SU->Succs.size();
473     // Temporarily use the Node2Index array as scratch space for degree counts.
474     Node2Index[NodeNum] = Degree;
475 
476     // Is it a node without dependencies?
477     if (Degree == 0) {
478       assert(SU->Succs.empty() && "SUnit should have no successors");
479       // Collect leaf nodes.
480       WorkList.push_back(SU);
481     }
482   }
483 
484   int Id = DAGSize;
485   while (!WorkList.empty()) {
486     SUnit *SU = WorkList.back();
487     WorkList.pop_back();
488     if (SU->NodeNum < DAGSize)
489       Allocate(SU->NodeNum, --Id);
490     for (SUnit::const_pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
491          I != E; ++I) {
492       SUnit *SU = I->getSUnit();
493       if (SU->NodeNum < DAGSize && !--Node2Index[SU->NodeNum])
494         // If all dependencies of the node are processed already,
495         // then the node can be computed now.
496         WorkList.push_back(SU);
497     }
498   }
499 
500   Visited.resize(DAGSize);
501 
502 #ifndef NDEBUG
503   // Check correctness of the ordering
504   for (unsigned i = 0, e = DAGSize; i != e; ++i) {
505     SUnit *SU = &SUnits[i];
506     for (SUnit::const_pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
507          I != E; ++I) {
508       assert(Node2Index[SU->NodeNum] > Node2Index[I->getSUnit()->NodeNum] &&
509       "Wrong topological sorting");
510     }
511   }
512 #endif
513 }
514 
515 /// AddPred - Updates the topological ordering to accommodate an edge
516 /// to be added from SUnit X to SUnit Y.
517 void ScheduleDAGTopologicalSort::AddPred(SUnit *Y, SUnit *X) {
518   int UpperBound, LowerBound;
519   LowerBound = Node2Index[Y->NodeNum];
520   UpperBound = Node2Index[X->NodeNum];
521   bool HasLoop = false;
522   // Is Ord(X) < Ord(Y) ?
523   if (LowerBound < UpperBound) {
524     // Update the topological order.
525     Visited.reset();
526     DFS(Y, UpperBound, HasLoop);
527     assert(!HasLoop && "Inserted edge creates a loop!");
528     // Recompute topological indexes.
529     Shift(Visited, LowerBound, UpperBound);
530   }
531 }
532 
533 /// RemovePred - Updates the topological ordering to accommodate an
534 /// an edge to be removed from the specified node N from the predecessors
535 /// of the current node M.
536 void ScheduleDAGTopologicalSort::RemovePred(SUnit *M, SUnit *N) {
537   // InitDAGTopologicalSorting();
538 }
539 
540 /// DFS - Make a DFS traversal to mark all nodes reachable from SU and mark
541 /// all nodes affected by the edge insertion. These nodes will later get new
542 /// topological indexes by means of the Shift method.
543 void ScheduleDAGTopologicalSort::DFS(const SUnit *SU, int UpperBound,
544                                      bool &HasLoop) {
545   std::vector<const SUnit*> WorkList;
546   WorkList.reserve(SUnits.size());
547 
548   WorkList.push_back(SU);
549   do {
550     SU = WorkList.back();
551     WorkList.pop_back();
552     Visited.set(SU->NodeNum);
553     for (int I = SU->Succs.size()-1; I >= 0; --I) {
554       unsigned s = SU->Succs[I].getSUnit()->NodeNum;
555       // Edges to non-SUnits are allowed but ignored (e.g. ExitSU).
556       if (s >= Node2Index.size())
557         continue;
558       if (Node2Index[s] == UpperBound) {
559         HasLoop = true;
560         return;
561       }
562       // Visit successors if not already and in affected region.
563       if (!Visited.test(s) && Node2Index[s] < UpperBound) {
564         WorkList.push_back(SU->Succs[I].getSUnit());
565       }
566     }
567   } while (!WorkList.empty());
568 }
569 
570 /// Shift - Renumber the nodes so that the topological ordering is
571 /// preserved.
572 void ScheduleDAGTopologicalSort::Shift(BitVector& Visited, int LowerBound,
573                                        int UpperBound) {
574   std::vector<int> L;
575   int shift = 0;
576   int i;
577 
578   for (i = LowerBound; i <= UpperBound; ++i) {
579     // w is node at topological index i.
580     int w = Index2Node[i];
581     if (Visited.test(w)) {
582       // Unmark.
583       Visited.reset(w);
584       L.push_back(w);
585       shift = shift + 1;
586     } else {
587       Allocate(w, i - shift);
588     }
589   }
590 
591   for (unsigned j = 0; j < L.size(); ++j) {
592     Allocate(L[j], i - shift);
593     i = i + 1;
594   }
595 }
596 
597 
598 /// WillCreateCycle - Returns true if adding an edge to TargetSU from SU will
599 /// create a cycle. If so, it is not safe to call AddPred(TargetSU, SU).
600 bool ScheduleDAGTopologicalSort::WillCreateCycle(SUnit *TargetSU, SUnit *SU) {
601   // Is SU reachable from TargetSU via successor edges?
602   if (IsReachable(SU, TargetSU))
603     return true;
604   for (SUnit::pred_iterator
605          I = TargetSU->Preds.begin(), E = TargetSU->Preds.end(); I != E; ++I)
606     if (I->isAssignedRegDep() &&
607         IsReachable(SU, I->getSUnit()))
608       return true;
609   return false;
610 }
611 
612 /// IsReachable - Checks if SU is reachable from TargetSU.
613 bool ScheduleDAGTopologicalSort::IsReachable(const SUnit *SU,
614                                              const SUnit *TargetSU) {
615   // If insertion of the edge SU->TargetSU would create a cycle
616   // then there is a path from TargetSU to SU.
617   int UpperBound, LowerBound;
618   LowerBound = Node2Index[TargetSU->NodeNum];
619   UpperBound = Node2Index[SU->NodeNum];
620   bool HasLoop = false;
621   // Is Ord(TargetSU) < Ord(SU) ?
622   if (LowerBound < UpperBound) {
623     Visited.reset();
624     // There may be a path from TargetSU to SU. Check for it.
625     DFS(TargetSU, UpperBound, HasLoop);
626   }
627   return HasLoop;
628 }
629 
630 /// Allocate - assign the topological index to the node n.
631 void ScheduleDAGTopologicalSort::Allocate(int n, int index) {
632   Node2Index[n] = index;
633   Index2Node[index] = n;
634 }
635 
636 ScheduleDAGTopologicalSort::
637 ScheduleDAGTopologicalSort(std::vector<SUnit> &sunits, SUnit *exitsu)
638   : SUnits(sunits), ExitSU(exitsu) {}
639 
640 ScheduleHazardRecognizer::~ScheduleHazardRecognizer() {}
641