1 //===- MachineScheduler.cpp - Machine Instruction Scheduler ---------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // MachineScheduler schedules machine instructions after phi elimination. It
11 // preserves LiveIntervals so it can be invoked before register allocation.
13 //===----------------------------------------------------------------------===//
15 #define DEBUG_TYPE "misched"
17 #include "RegisterPressure.h"
18 #include "llvm/CodeGen/LiveIntervalAnalysis.h"
19 #include "llvm/CodeGen/MachineScheduler.h"
20 #include "llvm/CodeGen/Passes.h"
21 #include "llvm/CodeGen/ScheduleDAGInstrs.h"
22 #include "llvm/Analysis/AliasAnalysis.h"
23 #include "llvm/Target/TargetInstrInfo.h"
24 #include "llvm/Support/CommandLine.h"
25 #include "llvm/Support/Debug.h"
26 #include "llvm/Support/ErrorHandling.h"
27 #include "llvm/Support/raw_ostream.h"
28 #include "llvm/ADT/OwningPtr.h"
29 #include "llvm/ADT/PriorityQueue.h"
35 static cl::opt<bool> ForceTopDown("misched-topdown", cl::Hidden,
36 cl::desc("Force top-down list scheduling"));
37 static cl::opt<bool> ForceBottomUp("misched-bottomup", cl::Hidden,
38 cl::desc("Force bottom-up list scheduling"));
41 static cl::opt<bool> ViewMISchedDAGs("view-misched-dags", cl::Hidden,
42 cl::desc("Pop up a window to show MISched dags after they are processed"));
44 static cl::opt<unsigned> MISchedCutoff("misched-cutoff", cl::Hidden,
45 cl::desc("Stop scheduling after N instructions"), cl::init(~0U));
47 static bool ViewMISchedDAGs = false;
50 //===----------------------------------------------------------------------===//
51 // Machine Instruction Scheduling Pass and Registry
52 //===----------------------------------------------------------------------===//
55 /// MachineScheduler runs after coalescing and before register allocation.
56 class MachineScheduler : public MachineSchedContext,
57 public MachineFunctionPass {
61 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
63 virtual void releaseMemory() {}
65 virtual bool runOnMachineFunction(MachineFunction&);
67 virtual void print(raw_ostream &O, const Module* = 0) const;
69 static char ID; // Class identification, replacement for typeinfo
73 char MachineScheduler::ID = 0;
75 char &llvm::MachineSchedulerID = MachineScheduler::ID;
77 INITIALIZE_PASS_BEGIN(MachineScheduler, "misched",
78 "Machine Instruction Scheduler", false, false)
79 INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
80 INITIALIZE_PASS_DEPENDENCY(SlotIndexes)
81 INITIALIZE_PASS_DEPENDENCY(LiveIntervals)
82 INITIALIZE_PASS_END(MachineScheduler, "misched",
83 "Machine Instruction Scheduler", false, false)
85 MachineScheduler::MachineScheduler()
86 : MachineFunctionPass(ID) {
87 initializeMachineSchedulerPass(*PassRegistry::getPassRegistry());
90 void MachineScheduler::getAnalysisUsage(AnalysisUsage &AU) const {
92 AU.addRequiredID(MachineDominatorsID);
93 AU.addRequired<MachineLoopInfo>();
94 AU.addRequired<AliasAnalysis>();
95 AU.addRequired<TargetPassConfig>();
96 AU.addRequired<SlotIndexes>();
97 AU.addPreserved<SlotIndexes>();
98 AU.addRequired<LiveIntervals>();
99 AU.addPreserved<LiveIntervals>();
100 MachineFunctionPass::getAnalysisUsage(AU);
103 MachinePassRegistry MachineSchedRegistry::Registry;
105 /// A dummy default scheduler factory indicates whether the scheduler
106 /// is overridden on the command line.
107 static ScheduleDAGInstrs *useDefaultMachineSched(MachineSchedContext *C) {
111 /// MachineSchedOpt allows command line selection of the scheduler.
112 static cl::opt<MachineSchedRegistry::ScheduleDAGCtor, false,
113 RegisterPassParser<MachineSchedRegistry> >
114 MachineSchedOpt("misched",
115 cl::init(&useDefaultMachineSched), cl::Hidden,
116 cl::desc("Machine instruction scheduler to use"));
118 static MachineSchedRegistry
119 DefaultSchedRegistry("default", "Use the target's default scheduler choice.",
120 useDefaultMachineSched);
122 /// Forward declare the standard machine scheduler. This will be used as the
123 /// default scheduler if the target does not set a default.
124 static ScheduleDAGInstrs *createConvergingSched(MachineSchedContext *C);
127 /// Decrement this iterator until reaching the top or a non-debug instr.
128 static MachineBasicBlock::iterator
129 priorNonDebug(MachineBasicBlock::iterator I, MachineBasicBlock::iterator Beg) {
130 assert(I != Beg && "reached the top of the region, cannot decrement");
132 if (!I->isDebugValue())
138 /// If this iterator is a debug value, increment until reaching the End or a
139 /// non-debug instruction.
140 static MachineBasicBlock::iterator
141 nextIfDebug(MachineBasicBlock::iterator I, MachineBasicBlock::iterator End) {
143 if (!I->isDebugValue())
149 /// Top-level MachineScheduler pass driver.
151 /// Visit blocks in function order. Divide each block into scheduling regions
152 /// and visit them bottom-up. Visiting regions bottom-up is not required, but is
153 /// consistent with the DAG builder, which traverses the interior of the
154 /// scheduling regions bottom-up.
156 /// This design avoids exposing scheduling boundaries to the DAG builder,
157 /// simplifying the DAG builder's support for "special" target instructions.
158 /// At the same time the design allows target schedulers to operate across
159 /// scheduling boundaries, for example to bundle the boudary instructions
160 /// without reordering them. This creates complexity, because the target
161 /// scheduler must update the RegionBegin and RegionEnd positions cached by
162 /// ScheduleDAGInstrs whenever adding or removing instructions. A much simpler
163 /// design would be to split blocks at scheduling boundaries, but LLVM has a
164 /// general bias against block splitting purely for implementation simplicity.
165 bool MachineScheduler::runOnMachineFunction(MachineFunction &mf) {
166 // Initialize the context of the pass.
168 MLI = &getAnalysis<MachineLoopInfo>();
169 MDT = &getAnalysis<MachineDominatorTree>();
170 PassConfig = &getAnalysis<TargetPassConfig>();
171 AA = &getAnalysis<AliasAnalysis>();
173 LIS = &getAnalysis<LiveIntervals>();
174 const TargetInstrInfo *TII = MF->getTarget().getInstrInfo();
176 RegClassInfo.runOnMachineFunction(*MF);
178 // Select the scheduler, or set the default.
179 MachineSchedRegistry::ScheduleDAGCtor Ctor = MachineSchedOpt;
180 if (Ctor == useDefaultMachineSched) {
181 // Get the default scheduler set by the target.
182 Ctor = MachineSchedRegistry::getDefault();
184 Ctor = createConvergingSched;
185 MachineSchedRegistry::setDefault(Ctor);
188 // Instantiate the selected scheduler.
189 OwningPtr<ScheduleDAGInstrs> Scheduler(Ctor(this));
191 // Visit all machine basic blocks.
193 // TODO: Visit blocks in global postorder or postorder within the bottom-up
194 // loop tree. Then we can optionally compute global RegPressure.
195 for (MachineFunction::iterator MBB = MF->begin(), MBBEnd = MF->end();
196 MBB != MBBEnd; ++MBB) {
198 Scheduler->startBlock(MBB);
200 // Break the block into scheduling regions [I, RegionEnd), and schedule each
201 // region as soon as it is discovered. RegionEnd points the the scheduling
202 // boundary at the bottom of the region. The DAG does not include RegionEnd,
203 // but the region does (i.e. the next RegionEnd is above the previous
204 // RegionBegin). If the current block has no terminator then RegionEnd ==
205 // MBB->end() for the bottom region.
207 // The Scheduler may insert instructions during either schedule() or
208 // exitRegion(), even for empty regions. So the local iterators 'I' and
209 // 'RegionEnd' are invalid across these calls.
210 unsigned RemainingCount = MBB->size();
211 for(MachineBasicBlock::iterator RegionEnd = MBB->end();
212 RegionEnd != MBB->begin(); RegionEnd = Scheduler->begin()) {
214 // Avoid decrementing RegionEnd for blocks with no terminator.
215 if (RegionEnd != MBB->end()
216 || TII->isSchedulingBoundary(llvm::prior(RegionEnd), MBB, *MF)) {
218 // Count the boundary instruction.
222 // The next region starts above the previous region. Look backward in the
223 // instruction stream until we find the nearest boundary.
224 MachineBasicBlock::iterator I = RegionEnd;
225 for(;I != MBB->begin(); --I, --RemainingCount) {
226 if (TII->isSchedulingBoundary(llvm::prior(I), MBB, *MF))
229 // Notify the scheduler of the region, even if we may skip scheduling
230 // it. Perhaps it still needs to be bundled.
231 Scheduler->enterRegion(MBB, I, RegionEnd, RemainingCount);
233 // Skip empty scheduling regions (0 or 1 schedulable instructions).
234 if (I == RegionEnd || I == llvm::prior(RegionEnd)) {
235 // Close the current region. Bundle the terminator if needed.
236 // This invalidates 'RegionEnd' and 'I'.
237 Scheduler->exitRegion();
240 DEBUG(dbgs() << "MachineScheduling " << MF->getFunction()->getName()
241 << ":BB#" << MBB->getNumber() << "\n From: " << *I << " To: ";
242 if (RegionEnd != MBB->end()) dbgs() << *RegionEnd;
243 else dbgs() << "End";
244 dbgs() << " Remaining: " << RemainingCount << "\n");
246 // Schedule a region: possibly reorder instructions.
247 // This invalidates 'RegionEnd' and 'I'.
248 Scheduler->schedule();
250 // Close the current region.
251 Scheduler->exitRegion();
253 // Scheduling has invalidated the current iterator 'I'. Ask the
254 // scheduler for the top of it's scheduled region.
255 RegionEnd = Scheduler->begin();
257 assert(RemainingCount == 0 && "Instruction count mismatch!");
258 Scheduler->finishBlock();
260 Scheduler->finalizeSchedule();
261 DEBUG(LIS->print(dbgs()));
265 void MachineScheduler::print(raw_ostream &O, const Module* m) const {
269 //===----------------------------------------------------------------------===//
270 // MachineSchedStrategy - Interface to a machine scheduling algorithm.
271 //===----------------------------------------------------------------------===//
276 /// MachineSchedStrategy - Interface used by ScheduleDAGMI to drive the selected
277 /// scheduling algorithm.
279 /// If this works well and targets wish to reuse ScheduleDAGMI, we may expose it
280 /// in ScheduleDAGInstrs.h
281 class MachineSchedStrategy {
283 virtual ~MachineSchedStrategy() {}
285 /// Initialize the strategy after building the DAG for a new region.
286 virtual void initialize(ScheduleDAGMI *DAG) = 0;
288 /// Pick the next node to schedule, or return NULL. Set IsTopNode to true to
289 /// schedule the node at the top of the unscheduled region. Otherwise it will
290 /// be scheduled at the bottom.
291 virtual SUnit *pickNode(bool &IsTopNode) = 0;
293 /// When all predecessor dependencies have been resolved, free this node for
294 /// top-down scheduling.
295 virtual void releaseTopNode(SUnit *SU) = 0;
296 /// When all successor dependencies have been resolved, free this node for
297 /// bottom-up scheduling.
298 virtual void releaseBottomNode(SUnit *SU) = 0;
302 //===----------------------------------------------------------------------===//
303 // ScheduleDAGMI - Base class for MachineInstr scheduling with LiveIntervals
305 //===----------------------------------------------------------------------===//
308 /// ScheduleDAGMI is an implementation of ScheduleDAGInstrs that schedules
309 /// machine instructions while updating LiveIntervals.
310 class ScheduleDAGMI : public ScheduleDAGInstrs {
312 RegisterClassInfo *RegClassInfo;
313 MachineSchedStrategy *SchedImpl;
315 // Register pressure in this region computed by buildSchedGraph.
316 IntervalPressure RegPressure;
317 RegPressureTracker RPTracker;
319 /// The top of the unscheduled zone.
320 MachineBasicBlock::iterator CurrentTop;
322 /// The bottom of the unscheduled zone.
323 MachineBasicBlock::iterator CurrentBottom;
325 /// The number of instructions scheduled so far. Used to cut off the
326 /// scheduler at the point determined by misched-cutoff.
327 unsigned NumInstrsScheduled;
329 ScheduleDAGMI(MachineSchedContext *C, MachineSchedStrategy *S):
330 ScheduleDAGInstrs(*C->MF, *C->MLI, *C->MDT, /*IsPostRA=*/false, C->LIS),
331 AA(C->AA), RegClassInfo(&C->RegClassInfo), SchedImpl(S),
332 RPTracker(RegPressure), CurrentTop(), CurrentBottom(),
333 NumInstrsScheduled(0) {}
339 MachineBasicBlock::iterator top() const { return CurrentTop; }
340 MachineBasicBlock::iterator bottom() const { return CurrentBottom; }
342 /// Implement the ScheduleDAGInstrs interface for handling the next scheduling
343 /// region. This covers all instructions in a block, while schedule() may only
345 void enterRegion(MachineBasicBlock *bb,
346 MachineBasicBlock::iterator begin,
347 MachineBasicBlock::iterator end,
350 /// Implement ScheduleDAGInstrs interface for scheduling a sequence of
351 /// reorderable instructions.
355 void moveInstruction(MachineInstr *MI, MachineBasicBlock::iterator InsertPos);
356 bool checkSchedLimit();
358 void releaseSucc(SUnit *SU, SDep *SuccEdge);
359 void releaseSuccessors(SUnit *SU);
360 void releasePred(SUnit *SU, SDep *PredEdge);
361 void releasePredecessors(SUnit *SU);
363 void placeDebugValues();
367 /// ReleaseSucc - Decrement the NumPredsLeft count of a successor. When
368 /// NumPredsLeft reaches zero, release the successor node.
369 void ScheduleDAGMI::releaseSucc(SUnit *SU, SDep *SuccEdge) {
370 SUnit *SuccSU = SuccEdge->getSUnit();
373 if (SuccSU->NumPredsLeft == 0) {
374 dbgs() << "*** Scheduling failed! ***\n";
376 dbgs() << " has been released too many times!\n";
380 --SuccSU->NumPredsLeft;
381 if (SuccSU->NumPredsLeft == 0 && SuccSU != &ExitSU)
382 SchedImpl->releaseTopNode(SuccSU);
385 /// releaseSuccessors - Call releaseSucc on each of SU's successors.
386 void ScheduleDAGMI::releaseSuccessors(SUnit *SU) {
387 for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
389 releaseSucc(SU, &*I);
393 /// ReleasePred - Decrement the NumSuccsLeft count of a predecessor. When
394 /// NumSuccsLeft reaches zero, release the predecessor node.
395 void ScheduleDAGMI::releasePred(SUnit *SU, SDep *PredEdge) {
396 SUnit *PredSU = PredEdge->getSUnit();
399 if (PredSU->NumSuccsLeft == 0) {
400 dbgs() << "*** Scheduling failed! ***\n";
402 dbgs() << " has been released too many times!\n";
406 --PredSU->NumSuccsLeft;
407 if (PredSU->NumSuccsLeft == 0 && PredSU != &EntrySU)
408 SchedImpl->releaseBottomNode(PredSU);
411 /// releasePredecessors - Call releasePred on each of SU's predecessors.
412 void ScheduleDAGMI::releasePredecessors(SUnit *SU) {
413 for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
415 releasePred(SU, &*I);
419 void ScheduleDAGMI::moveInstruction(MachineInstr *MI,
420 MachineBasicBlock::iterator InsertPos) {
421 // Fix RegionBegin if the first instruction moves down.
422 if (&*RegionBegin == MI)
423 RegionBegin = llvm::next(RegionBegin);
424 BB->splice(InsertPos, BB, MI);
426 // Fix RegionBegin if another instruction moves above the first instruction.
427 if (RegionBegin == InsertPos)
431 bool ScheduleDAGMI::checkSchedLimit() {
433 if (NumInstrsScheduled == MISchedCutoff && MISchedCutoff != ~0U) {
434 CurrentTop = CurrentBottom;
437 ++NumInstrsScheduled;
442 /// enterRegion - Called back from MachineScheduler::runOnMachineFunction after
443 /// crossing a scheduling boundary. [begin, end) includes all instructions in
444 /// the region, including the boundary itself and single-instruction regions
445 /// that don't get scheduled.
446 void ScheduleDAGMI::enterRegion(MachineBasicBlock *bb,
447 MachineBasicBlock::iterator begin,
448 MachineBasicBlock::iterator end,
451 ScheduleDAGInstrs::enterRegion(bb, begin, end, endcount);
452 // Setup the register pressure tracker to begin tracking at the end of this
454 RPTracker.init(&MF, RegClassInfo, LIS, BB, end);
457 /// schedule - Called back from MachineScheduler::runOnMachineFunction
458 /// after setting up the current scheduling region. [RegionBegin, RegionEnd)
459 /// only includes instructions that have DAG nodes, not scheduling boundaries.
460 void ScheduleDAGMI::schedule() {
461 while(RPTracker.getPos() != RegionEnd) {
462 bool Moved = RPTracker.recede();
463 assert(Moved && "Regpressure tracker cannot find RegionEnd"); (void)Moved;
467 buildSchedGraph(AA, &RPTracker);
469 DEBUG(dbgs() << "********** MI Scheduling **********\n");
470 DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su)
471 SUnits[su].dumpAll(this));
473 if (ViewMISchedDAGs) viewGraph();
475 SchedImpl->initialize(this);
477 // Release edges from the special Entry node or to the special Exit node.
478 releaseSuccessors(&EntrySU);
479 releasePredecessors(&ExitSU);
481 // Release all DAG roots for scheduling.
482 for (std::vector<SUnit>::iterator I = SUnits.begin(), E = SUnits.end();
484 // A SUnit is ready to top schedule if it has no predecessors.
485 if (I->Preds.empty())
486 SchedImpl->releaseTopNode(&(*I));
487 // A SUnit is ready to bottom schedule if it has no successors.
488 if (I->Succs.empty())
489 SchedImpl->releaseBottomNode(&(*I));
492 CurrentTop = nextIfDebug(RegionBegin, RegionEnd);
493 CurrentBottom = RegionEnd;
494 bool IsTopNode = false;
495 while (SUnit *SU = SchedImpl->pickNode(IsTopNode)) {
496 DEBUG(dbgs() << "*** " << (IsTopNode ? "Top" : "Bottom")
497 << " Scheduling Instruction:\n"; SU->dump(this));
498 if (!checkSchedLimit())
501 // Move the instruction to its new location in the instruction stream.
502 MachineInstr *MI = SU->getInstr();
505 assert(SU->isTopReady() && "node still has unscheduled dependencies");
506 if (&*CurrentTop == MI)
507 CurrentTop = nextIfDebug(++CurrentTop, CurrentBottom);
509 moveInstruction(MI, CurrentTop);
510 // Release dependent instructions for scheduling.
511 releaseSuccessors(SU);
514 assert(SU->isBottomReady() && "node still has unscheduled dependencies");
515 MachineBasicBlock::iterator priorII =
516 priorNonDebug(CurrentBottom, CurrentTop);
518 CurrentBottom = priorII;
520 if (&*CurrentTop == MI)
521 CurrentTop = nextIfDebug(++CurrentTop, CurrentBottom);
522 moveInstruction(MI, CurrentBottom);
525 // Release dependent instructions for scheduling.
526 releasePredecessors(SU);
528 SU->isScheduled = true;
530 assert(CurrentTop == CurrentBottom && "Nonempty unscheduled zone.");
535 /// Reinsert any remaining debug_values, just like the PostRA scheduler.
536 void ScheduleDAGMI::placeDebugValues() {
537 // If first instruction was a DBG_VALUE then put it back.
539 BB->splice(RegionBegin, BB, FirstDbgValue);
540 RegionBegin = FirstDbgValue;
543 for (std::vector<std::pair<MachineInstr *, MachineInstr *> >::iterator
544 DI = DbgValues.end(), DE = DbgValues.begin(); DI != DE; --DI) {
545 std::pair<MachineInstr *, MachineInstr *> P = *prior(DI);
546 MachineInstr *DbgValue = P.first;
547 MachineBasicBlock::iterator OrigPrevMI = P.second;
548 BB->splice(++OrigPrevMI, BB, DbgValue);
549 if (OrigPrevMI == llvm::prior(RegionEnd))
550 RegionEnd = DbgValue;
553 FirstDbgValue = NULL;
556 //===----------------------------------------------------------------------===//
557 // ConvergingScheduler - Implementation of the standard MachineSchedStrategy.
558 //===----------------------------------------------------------------------===//
561 /// ConvergingScheduler shrinks the unscheduled zone using heuristics to balance
563 class ConvergingScheduler : public MachineSchedStrategy {
566 unsigned NumTopReady;
567 unsigned NumBottomReady;
570 virtual void initialize(ScheduleDAGMI *dag) {
573 assert((!ForceTopDown || !ForceBottomUp) &&
574 "-misched-topdown incompatible with -misched-bottomup");
577 virtual SUnit *pickNode(bool &IsTopNode) {
578 if (DAG->top() == DAG->bottom())
581 // As an initial placeholder heuristic, schedule in the direction that has
582 // the fewest choices.
584 if (ForceTopDown || (!ForceBottomUp && NumTopReady <= NumBottomReady)) {
585 SU = DAG->getSUnit(DAG->top());
589 SU = DAG->getSUnit(priorNonDebug(DAG->bottom(), DAG->top()));
592 if (SU->isTopReady()) {
593 assert(NumTopReady > 0 && "bad ready count");
596 if (SU->isBottomReady()) {
597 assert(NumBottomReady > 0 && "bad ready count");
603 virtual void releaseTopNode(SUnit *SU) {
606 virtual void releaseBottomNode(SUnit *SU) {
612 /// Create the standard converging machine scheduler. This will be used as the
613 /// default scheduler if the target does not set a default.
614 static ScheduleDAGInstrs *createConvergingSched(MachineSchedContext *C) {
615 assert((!ForceTopDown || !ForceBottomUp) &&
616 "-misched-topdown incompatible with -misched-bottomup");
617 return new ScheduleDAGMI(C, new ConvergingScheduler());
619 static MachineSchedRegistry
620 ConvergingSchedRegistry("converge", "Standard converging scheduler.",
621 createConvergingSched);
623 //===----------------------------------------------------------------------===//
624 // Machine Instruction Shuffler for Correctness Testing
625 //===----------------------------------------------------------------------===//
629 /// Apply a less-than relation on the node order, which corresponds to the
630 /// instruction order prior to scheduling. IsReverse implements greater-than.
631 template<bool IsReverse>
633 bool operator()(SUnit *A, SUnit *B) const {
635 return A->NodeNum > B->NodeNum;
637 return A->NodeNum < B->NodeNum;
641 /// Reorder instructions as much as possible.
642 class InstructionShuffler : public MachineSchedStrategy {
646 // Using a less-than relation (SUnitOrder<false>) for the TopQ priority
647 // gives nodes with a higher number higher priority causing the latest
648 // instructions to be scheduled first.
649 PriorityQueue<SUnit*, std::vector<SUnit*>, SUnitOrder<false> >
651 // When scheduling bottom-up, use greater-than as the queue priority.
652 PriorityQueue<SUnit*, std::vector<SUnit*>, SUnitOrder<true> >
655 InstructionShuffler(bool alternate, bool topdown)
656 : IsAlternating(alternate), IsTopDown(topdown) {}
658 virtual void initialize(ScheduleDAGMI *) {
663 /// Implement MachineSchedStrategy interface.
664 /// -----------------------------------------
666 virtual SUnit *pickNode(bool &IsTopNode) {
670 if (TopQ.empty()) return NULL;
673 } while (SU->isScheduled);
678 if (BottomQ.empty()) return NULL;
681 } while (SU->isScheduled);
685 IsTopDown = !IsTopDown;
689 virtual void releaseTopNode(SUnit *SU) {
692 virtual void releaseBottomNode(SUnit *SU) {
698 static ScheduleDAGInstrs *createInstructionShuffler(MachineSchedContext *C) {
699 bool Alternate = !ForceTopDown && !ForceBottomUp;
700 bool TopDown = !ForceBottomUp;
701 assert((TopDown || !ForceTopDown) &&
702 "-misched-topdown incompatible with -misched-bottomup");
703 return new ScheduleDAGMI(C, new InstructionShuffler(Alternate, TopDown));
705 static MachineSchedRegistry ShufflerRegistry(
706 "shuffle", "Shuffle machine instructions alternating directions",
707 createInstructionShuffler);