blob: 982a2a500e5c1fdc3237361f7df93246ae3504dc [file] [log] [blame]
Dale Johannesen72f15962007-07-13 17:31:29 +00001//===----- SchedulePostRAList.cpp - list scheduler ------------------------===//
Dale Johannesene7e7d0d2007-07-13 17:13:54 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dale Johannesene7e7d0d2007-07-13 17:13:54 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This implements a top-down list scheduler, using standard algorithms.
11// The basic approach uses a priority queue of available nodes to schedule.
12// One at a time, nodes are taken from the priority queue (thus in priority
13// order), checked for legality to schedule, and emitted if legal.
14//
15// Nodes may not be legal to schedule either due to structural hazards (e.g.
16// pipeline or resource constraints) or because an input to the instruction has
17// not completed execution.
18//
19//===----------------------------------------------------------------------===//
20
21#define DEBUG_TYPE "post-RA-sched"
David Goodwin82c72482009-10-28 18:29:54 +000022#include "AntiDepBreaker.h"
David Goodwin34877712009-10-26 19:32:42 +000023#include "AggressiveAntiDepBreaker.h"
David Goodwin2e7be612009-10-26 16:59:04 +000024#include "CriticalAntiDepBreaker.h"
Jakob Stoklund Olesenfa796dd2011-06-16 21:56:21 +000025#include "RegisterClassInfo.h"
Dan Gohman6dc75fe2009-02-06 17:12:10 +000026#include "ScheduleDAGInstrs.h"
Dale Johannesene7e7d0d2007-07-13 17:13:54 +000027#include "llvm/CodeGen/Passes.h"
Dan Gohman343f0c02008-11-19 23:18:57 +000028#include "llvm/CodeGen/LatencyPriorityQueue.h"
29#include "llvm/CodeGen/SchedulerRegistry.h"
Dan Gohman3f237442008-12-16 03:25:46 +000030#include "llvm/CodeGen/MachineDominators.h"
David Goodwinc7951f82009-10-01 19:45:32 +000031#include "llvm/CodeGen/MachineFrameInfo.h"
Dale Johannesene7e7d0d2007-07-13 17:13:54 +000032#include "llvm/CodeGen/MachineFunctionPass.h"
Dan Gohman3f237442008-12-16 03:25:46 +000033#include "llvm/CodeGen/MachineLoopInfo.h"
Dan Gohman21d90032008-11-25 00:52:40 +000034#include "llvm/CodeGen/MachineRegisterInfo.h"
Dan Gohman2836c282009-01-16 01:33:36 +000035#include "llvm/CodeGen/ScheduleHazardRecognizer.h"
Dan Gohmana70dca12009-10-09 23:27:56 +000036#include "llvm/Analysis/AliasAnalysis.h"
Dan Gohmanbed353d2009-02-10 23:29:38 +000037#include "llvm/Target/TargetLowering.h"
Dan Gohman79ce2762009-01-15 19:20:50 +000038#include "llvm/Target/TargetMachine.h"
Dan Gohman21d90032008-11-25 00:52:40 +000039#include "llvm/Target/TargetInstrInfo.h"
40#include "llvm/Target/TargetRegisterInfo.h"
David Goodwin0dad89f2009-09-30 00:10:16 +000041#include "llvm/Target/TargetSubtarget.h"
David Goodwine10deca2009-10-26 22:31:16 +000042#include "llvm/Support/CommandLine.h"
Dale Johannesene7e7d0d2007-07-13 17:13:54 +000043#include "llvm/Support/Debug.h"
Torok Edwinc25e7582009-07-11 20:10:48 +000044#include "llvm/Support/ErrorHandling.h"
David Goodwin3a5f0d42009-08-11 01:44:26 +000045#include "llvm/Support/raw_ostream.h"
David Goodwin2e7be612009-10-26 16:59:04 +000046#include "llvm/ADT/BitVector.h"
Dan Gohman343f0c02008-11-19 23:18:57 +000047#include "llvm/ADT/Statistic.h"
David Goodwin88a589c2009-08-25 17:03:05 +000048#include <set>
Dale Johannesene7e7d0d2007-07-13 17:13:54 +000049using namespace llvm;
50
Dan Gohman2836c282009-01-16 01:33:36 +000051STATISTIC(NumNoops, "Number of noops inserted");
Dan Gohman343f0c02008-11-19 23:18:57 +000052STATISTIC(NumStalls, "Number of pipeline stalls");
David Goodwin2e7be612009-10-26 16:59:04 +000053STATISTIC(NumFixedAnti, "Number of fixed anti-dependencies");
Dan Gohman343f0c02008-11-19 23:18:57 +000054
David Goodwin471850a2009-10-01 21:46:35 +000055// Post-RA scheduling is enabled with
56// TargetSubtarget.enablePostRAScheduler(). This flag can be used to
57// override the target.
58static cl::opt<bool>
59EnablePostRAScheduler("post-RA-scheduler",
60 cl::desc("Enable scheduling after register allocation"),
David Goodwin9843a932009-10-01 22:19:57 +000061 cl::init(false), cl::Hidden);
David Goodwin2e7be612009-10-26 16:59:04 +000062static cl::opt<std::string>
Dan Gohman21d90032008-11-25 00:52:40 +000063EnableAntiDepBreaking("break-anti-dependencies",
David Goodwin2e7be612009-10-26 16:59:04 +000064 cl::desc("Break post-RA scheduling anti-dependencies: "
65 "\"critical\", \"all\", or \"none\""),
66 cl::init("none"), cl::Hidden);
Dan Gohman2836c282009-01-16 01:33:36 +000067
David Goodwin1f152282009-09-01 18:34:03 +000068// If DebugDiv > 0 then only schedule MBB with (ID % DebugDiv) == DebugMod
69static cl::opt<int>
70DebugDiv("postra-sched-debugdiv",
71 cl::desc("Debug control MBBs that are scheduled"),
72 cl::init(0), cl::Hidden);
73static cl::opt<int>
74DebugMod("postra-sched-debugmod",
75 cl::desc("Debug control MBBs that are scheduled"),
76 cl::init(0), cl::Hidden);
77
David Goodwinada0ef82009-10-26 19:41:00 +000078AntiDepBreaker::~AntiDepBreaker() { }
79
Dale Johannesene7e7d0d2007-07-13 17:13:54 +000080namespace {
Nick Lewycky6726b6d2009-10-25 06:33:48 +000081 class PostRAScheduler : public MachineFunctionPass {
Dan Gohmana70dca12009-10-09 23:27:56 +000082 AliasAnalysis *AA;
Evan Cheng86050dc2010-06-18 23:09:54 +000083 const TargetInstrInfo *TII;
Jakob Stoklund Olesenfa796dd2011-06-16 21:56:21 +000084 RegisterClassInfo RegClassInfo;
Evan Chengfa163542009-10-16 21:06:15 +000085 CodeGenOpt::Level OptLevel;
Dan Gohmana70dca12009-10-09 23:27:56 +000086
Dale Johannesene7e7d0d2007-07-13 17:13:54 +000087 public:
88 static char ID;
Evan Chengfa163542009-10-16 21:06:15 +000089 PostRAScheduler(CodeGenOpt::Level ol) :
Owen Anderson90c579d2010-08-06 18:33:48 +000090 MachineFunctionPass(ID), OptLevel(ol) {}
Dan Gohman21d90032008-11-25 00:52:40 +000091
Dan Gohman3f237442008-12-16 03:25:46 +000092 void getAnalysisUsage(AnalysisUsage &AU) const {
Dan Gohman845012e2009-07-31 23:37:33 +000093 AU.setPreservesCFG();
Dan Gohmana70dca12009-10-09 23:27:56 +000094 AU.addRequired<AliasAnalysis>();
Dan Gohman3f237442008-12-16 03:25:46 +000095 AU.addRequired<MachineDominatorTree>();
96 AU.addPreserved<MachineDominatorTree>();
97 AU.addRequired<MachineLoopInfo>();
98 AU.addPreserved<MachineLoopInfo>();
99 MachineFunctionPass::getAnalysisUsage(AU);
100 }
101
Dale Johannesene7e7d0d2007-07-13 17:13:54 +0000102 const char *getPassName() const {
Dan Gohman21d90032008-11-25 00:52:40 +0000103 return "Post RA top-down list latency scheduler";
Dale Johannesene7e7d0d2007-07-13 17:13:54 +0000104 }
105
106 bool runOnMachineFunction(MachineFunction &Fn);
107 };
Dan Gohman343f0c02008-11-19 23:18:57 +0000108 char PostRAScheduler::ID = 0;
109
Nick Lewycky6726b6d2009-10-25 06:33:48 +0000110 class SchedulePostRATDList : public ScheduleDAGInstrs {
Dan Gohman343f0c02008-11-19 23:18:57 +0000111 /// AvailableQueue - The priority queue to use for the available SUnits.
Dan Gohmanc1ae8c92009-10-21 01:44:44 +0000112 ///
Dan Gohman343f0c02008-11-19 23:18:57 +0000113 LatencyPriorityQueue AvailableQueue;
Jim Grosbach90013032010-05-14 21:19:48 +0000114
Dan Gohman343f0c02008-11-19 23:18:57 +0000115 /// PendingQueue - This contains all of the instructions whose operands have
116 /// been issued, but their results are not ready yet (due to the latency of
117 /// the operation). Once the operands becomes available, the instruction is
118 /// added to the AvailableQueue.
119 std::vector<SUnit*> PendingQueue;
120
Dan Gohman21d90032008-11-25 00:52:40 +0000121 /// Topo - A topological ordering for SUnits.
122 ScheduleDAGTopologicalSort Topo;
Dan Gohman343f0c02008-11-19 23:18:57 +0000123
Dan Gohman2836c282009-01-16 01:33:36 +0000124 /// HazardRec - The hazard recognizer to use.
125 ScheduleHazardRecognizer *HazardRec;
126
David Goodwin2e7be612009-10-26 16:59:04 +0000127 /// AntiDepBreak - Anti-dependence breaking object, or NULL if none
128 AntiDepBreaker *AntiDepBreak;
129
Dan Gohmana70dca12009-10-09 23:27:56 +0000130 /// AA - AliasAnalysis for making memory reference queries.
131 AliasAnalysis *AA;
132
Dan Gohmanc1ae8c92009-10-21 01:44:44 +0000133 /// KillIndices - The index of the most recent kill (proceding bottom-up),
134 /// or ~0u if the register is not live.
Bill Wendling24173da2010-07-15 20:01:02 +0000135 std::vector<unsigned> KillIndices;
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000136
Dan Gohman21d90032008-11-25 00:52:40 +0000137 public:
Andrew Trick2da8bc82010-12-24 05:03:26 +0000138 SchedulePostRATDList(
139 MachineFunction &MF, MachineLoopInfo &MLI, MachineDominatorTree &MDT,
Jakob Stoklund Olesenfa796dd2011-06-16 21:56:21 +0000140 AliasAnalysis *AA, const RegisterClassInfo&,
141 TargetSubtarget::AntiDepBreakMode AntiDepMode,
Andrew Trick2da8bc82010-12-24 05:03:26 +0000142 SmallVectorImpl<TargetRegisterClass*> &CriticalPathRCs);
Dan Gohman2836c282009-01-16 01:33:36 +0000143
Andrew Trick2da8bc82010-12-24 05:03:26 +0000144 ~SchedulePostRATDList();
Dan Gohman343f0c02008-11-19 23:18:57 +0000145
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000146 /// StartBlock - Initialize register live-range state for scheduling in
147 /// this block.
148 ///
149 void StartBlock(MachineBasicBlock *BB);
150
151 /// Schedule - Schedule the instruction range using list scheduling.
152 ///
Dan Gohman343f0c02008-11-19 23:18:57 +0000153 void Schedule();
Jim Grosbach90013032010-05-14 21:19:48 +0000154
Dan Gohmanc1ae8c92009-10-21 01:44:44 +0000155 /// Observe - Update liveness information to account for the current
156 /// instruction, which will not be scheduled.
157 ///
158 void Observe(MachineInstr *MI, unsigned Count);
159
160 /// FinishBlock - Clean up register live-range state.
161 ///
162 void FinishBlock();
163
David Goodwin2e7be612009-10-26 16:59:04 +0000164 /// FixupKills - Fix register kill flags that have been made
165 /// invalid due to scheduling
166 ///
167 void FixupKills(MachineBasicBlock *MBB);
168
Dan Gohman343f0c02008-11-19 23:18:57 +0000169 private:
David Goodwin557bbe62009-11-20 19:32:48 +0000170 void ReleaseSucc(SUnit *SU, SDep *SuccEdge);
171 void ReleaseSuccessors(SUnit *SU);
172 void ScheduleNodeTopDown(SUnit *SU, unsigned CurCycle);
173 void ListScheduleTopDown();
David Goodwin5e411782009-09-03 22:15:25 +0000174 void StartBlockForKills(MachineBasicBlock *BB);
Jim Grosbach90013032010-05-14 21:19:48 +0000175
David Goodwin8f909342009-09-23 16:35:25 +0000176 // ToggleKillFlag - Toggle a register operand kill flag. Other
177 // adjustments may be made to the instruction if necessary. Return
178 // true if the operand has been deleted, false if not.
179 bool ToggleKillFlag(MachineInstr *MI, MachineOperand &MO);
Dan Gohman343f0c02008-11-19 23:18:57 +0000180 };
Dale Johannesene7e7d0d2007-07-13 17:13:54 +0000181}
182
Andrew Trick2da8bc82010-12-24 05:03:26 +0000183SchedulePostRATDList::SchedulePostRATDList(
184 MachineFunction &MF, MachineLoopInfo &MLI, MachineDominatorTree &MDT,
Jakob Stoklund Olesenfa796dd2011-06-16 21:56:21 +0000185 AliasAnalysis *AA, const RegisterClassInfo &RCI,
186 TargetSubtarget::AntiDepBreakMode AntiDepMode,
Andrew Trick2da8bc82010-12-24 05:03:26 +0000187 SmallVectorImpl<TargetRegisterClass*> &CriticalPathRCs)
188 : ScheduleDAGInstrs(MF, MLI, MDT), Topo(SUnits), AA(AA),
189 KillIndices(TRI->getNumRegs())
190{
191 const TargetMachine &TM = MF.getTarget();
192 const InstrItineraryData *InstrItins = TM.getInstrItineraryData();
193 HazardRec =
194 TM.getInstrInfo()->CreateTargetPostRAHazardRecognizer(InstrItins, this);
195 AntiDepBreak =
196 ((AntiDepMode == TargetSubtarget::ANTIDEP_ALL) ?
Jakob Stoklund Olesenfa796dd2011-06-16 21:56:21 +0000197 (AntiDepBreaker *)new AggressiveAntiDepBreaker(MF, RCI, CriticalPathRCs) :
Andrew Trick2da8bc82010-12-24 05:03:26 +0000198 ((AntiDepMode == TargetSubtarget::ANTIDEP_CRITICAL) ?
Jakob Stoklund Olesenfa796dd2011-06-16 21:56:21 +0000199 (AntiDepBreaker *)new CriticalAntiDepBreaker(MF, RCI) : NULL));
Andrew Trick2da8bc82010-12-24 05:03:26 +0000200}
201
202SchedulePostRATDList::~SchedulePostRATDList() {
203 delete HazardRec;
204 delete AntiDepBreak;
205}
206
Dan Gohman343f0c02008-11-19 23:18:57 +0000207bool PostRAScheduler::runOnMachineFunction(MachineFunction &Fn) {
Evan Cheng86050dc2010-06-18 23:09:54 +0000208 TII = Fn.getTarget().getInstrInfo();
Andrew Trick2da8bc82010-12-24 05:03:26 +0000209 MachineLoopInfo &MLI = getAnalysis<MachineLoopInfo>();
210 MachineDominatorTree &MDT = getAnalysis<MachineDominatorTree>();
211 AliasAnalysis *AA = &getAnalysis<AliasAnalysis>();
Jakob Stoklund Olesenfa796dd2011-06-16 21:56:21 +0000212 RegClassInfo.runOnMachineFunction(Fn);
Dan Gohman5bf7c2a2009-10-10 00:15:38 +0000213
David Goodwin471850a2009-10-01 21:46:35 +0000214 // Check for explicit enable/disable of post-ra scheduling.
David Goodwin4c3715c2009-10-22 23:19:17 +0000215 TargetSubtarget::AntiDepBreakMode AntiDepMode = TargetSubtarget::ANTIDEP_NONE;
David Goodwin87d21b92009-11-13 19:52:48 +0000216 SmallVector<TargetRegisterClass*, 4> CriticalPathRCs;
David Goodwin471850a2009-10-01 21:46:35 +0000217 if (EnablePostRAScheduler.getPosition() > 0) {
218 if (!EnablePostRAScheduler)
Evan Chengc83da2f92009-10-16 06:10:34 +0000219 return false;
David Goodwin471850a2009-10-01 21:46:35 +0000220 } else {
Evan Chengc83da2f92009-10-16 06:10:34 +0000221 // Check that post-RA scheduling is enabled for this target.
Andrew Trick2da8bc82010-12-24 05:03:26 +0000222 // This may upgrade the AntiDepMode.
David Goodwin471850a2009-10-01 21:46:35 +0000223 const TargetSubtarget &ST = Fn.getTarget().getSubtarget<TargetSubtarget>();
David Goodwin87d21b92009-11-13 19:52:48 +0000224 if (!ST.enablePostRAScheduler(OptLevel, AntiDepMode, CriticalPathRCs))
Evan Chengc83da2f92009-10-16 06:10:34 +0000225 return false;
David Goodwin471850a2009-10-01 21:46:35 +0000226 }
David Goodwin0dad89f2009-09-30 00:10:16 +0000227
David Goodwin4c3715c2009-10-22 23:19:17 +0000228 // Check for antidep breaking override...
229 if (EnableAntiDepBreaking.getPosition() > 0) {
Jim Grosbach90013032010-05-14 21:19:48 +0000230 AntiDepMode = (EnableAntiDepBreaking == "all") ?
231 TargetSubtarget::ANTIDEP_ALL :
232 (EnableAntiDepBreaking == "critical")
233 ? TargetSubtarget::ANTIDEP_CRITICAL : TargetSubtarget::ANTIDEP_NONE;
David Goodwin4c3715c2009-10-22 23:19:17 +0000234 }
235
David Greenee1b21292010-01-05 01:26:01 +0000236 DEBUG(dbgs() << "PostRAScheduler\n");
Dale Johannesene7e7d0d2007-07-13 17:13:54 +0000237
Jakob Stoklund Olesenfa796dd2011-06-16 21:56:21 +0000238 SchedulePostRATDList Scheduler(Fn, MLI, MDT, AA, RegClassInfo, AntiDepMode,
Andrew Trick2da8bc82010-12-24 05:03:26 +0000239 CriticalPathRCs);
Dan Gohman79ce2762009-01-15 19:20:50 +0000240
Dale Johannesene7e7d0d2007-07-13 17:13:54 +0000241 // Loop over all of the basic blocks
242 for (MachineFunction::iterator MBB = Fn.begin(), MBBe = Fn.end();
Dan Gohman343f0c02008-11-19 23:18:57 +0000243 MBB != MBBe; ++MBB) {
David Goodwin1f152282009-09-01 18:34:03 +0000244#ifndef NDEBUG
245 // If DebugDiv > 0 then only schedule MBB with (ID % DebugDiv) == DebugMod
246 if (DebugDiv > 0) {
247 static int bbcnt = 0;
248 if (bbcnt++ % DebugDiv != DebugMod)
249 continue;
David Greenee1b21292010-01-05 01:26:01 +0000250 dbgs() << "*** DEBUG scheduling " << Fn.getFunction()->getNameStr() <<
Dan Gohman0ba90f32009-10-31 20:19:03 +0000251 ":BB#" << MBB->getNumber() << " ***\n";
David Goodwin1f152282009-09-01 18:34:03 +0000252 }
253#endif
254
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000255 // Initialize register live-range state for scheduling in this block.
256 Scheduler.StartBlock(MBB);
257
Dan Gohmanf7119392009-01-16 22:10:20 +0000258 // Schedule each sequence of instructions not interrupted by a label
259 // or anything else that effectively needs to shut down scheduling.
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000260 MachineBasicBlock::iterator Current = MBB->end();
Dan Gohman47ac0f02009-02-11 04:27:20 +0000261 unsigned Count = MBB->size(), CurrentCount = Count;
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000262 for (MachineBasicBlock::iterator I = Current; I != MBB->begin(); ) {
Evan Cheng86050dc2010-06-18 23:09:54 +0000263 MachineInstr *MI = llvm::prior(I);
264 if (TII->isSchedulingBoundary(MI, MBB, Fn)) {
Dan Gohman1274ced2009-03-10 18:10:43 +0000265 Scheduler.Run(MBB, I, Current, CurrentCount);
Dan Gohmanaf1d8ca2010-05-01 00:01:06 +0000266 Scheduler.EmitSchedule();
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000267 Current = MI;
Dan Gohman47ac0f02009-02-11 04:27:20 +0000268 CurrentCount = Count - 1;
Dan Gohman1274ced2009-03-10 18:10:43 +0000269 Scheduler.Observe(MI, CurrentCount);
Dan Gohmanf7119392009-01-16 22:10:20 +0000270 }
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000271 I = MI;
Dan Gohman47ac0f02009-02-11 04:27:20 +0000272 --Count;
Dan Gohman43f07fb2009-02-03 18:57:45 +0000273 }
Dan Gohman47ac0f02009-02-11 04:27:20 +0000274 assert(Count == 0 && "Instruction count mismatch!");
Duncan Sands9e8bd0b2009-03-11 09:04:34 +0000275 assert((MBB->begin() == Current || CurrentCount != 0) &&
Dan Gohman1274ced2009-03-10 18:10:43 +0000276 "Instruction count mismatch!");
277 Scheduler.Run(MBB, MBB->begin(), Current, CurrentCount);
Dan Gohmanaf1d8ca2010-05-01 00:01:06 +0000278 Scheduler.EmitSchedule();
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000279
280 // Clean up register live-range state.
281 Scheduler.FinishBlock();
David Goodwin88a589c2009-08-25 17:03:05 +0000282
David Goodwin5e411782009-09-03 22:15:25 +0000283 // Update register kills
David Goodwin88a589c2009-08-25 17:03:05 +0000284 Scheduler.FixupKills(MBB);
Dan Gohman343f0c02008-11-19 23:18:57 +0000285 }
Dale Johannesene7e7d0d2007-07-13 17:13:54 +0000286
287 return true;
288}
Jim Grosbach90013032010-05-14 21:19:48 +0000289
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000290/// StartBlock - Initialize register live-range state for scheduling in
291/// this block.
Dan Gohman21d90032008-11-25 00:52:40 +0000292///
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000293void SchedulePostRATDList::StartBlock(MachineBasicBlock *BB) {
294 // Call the superclass.
295 ScheduleDAGInstrs::StartBlock(BB);
Dan Gohman21d90032008-11-25 00:52:40 +0000296
David Goodwin2e7be612009-10-26 16:59:04 +0000297 // Reset the hazard recognizer and anti-dep breaker.
David Goodwind94a4e52009-08-10 15:55:25 +0000298 HazardRec->Reset();
David Goodwin2e7be612009-10-26 16:59:04 +0000299 if (AntiDepBreak != NULL)
300 AntiDepBreak->StartBlock(BB);
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000301}
302
303/// Schedule - Schedule the instruction range using list scheduling.
304///
305void SchedulePostRATDList::Schedule() {
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000306 // Build the scheduling graph.
Dan Gohmana70dca12009-10-09 23:27:56 +0000307 BuildSchedGraph(AA);
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000308
David Goodwin2e7be612009-10-26 16:59:04 +0000309 if (AntiDepBreak != NULL) {
Jim Grosbach90013032010-05-14 21:19:48 +0000310 unsigned Broken =
David Goodwin557bbe62009-11-20 19:32:48 +0000311 AntiDepBreak->BreakAntiDependencies(SUnits, Begin, InsertPos,
Devang Patele29e8e12011-06-02 21:26:52 +0000312 InsertPosIndex, DbgValues);
Jim Grosbach90013032010-05-14 21:19:48 +0000313
David Goodwin557bbe62009-11-20 19:32:48 +0000314 if (Broken != 0) {
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000315 // We made changes. Update the dependency graph.
316 // Theoretically we could update the graph in place:
317 // When a live range is changed to use a different register, remove
318 // the def's anti-dependence *and* output-dependence edges due to
319 // that register, and add new anti-dependence and output-dependence
320 // edges based on the next live range of the register.
David Goodwin557bbe62009-11-20 19:32:48 +0000321 SUnits.clear();
322 Sequence.clear();
323 EntrySU = SUnit();
324 ExitSU = SUnit();
325 BuildSchedGraph(AA);
Jim Grosbach90013032010-05-14 21:19:48 +0000326
David Goodwin2e7be612009-10-26 16:59:04 +0000327 NumFixedAnti += Broken;
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000328 }
329 }
330
David Greenee1b21292010-01-05 01:26:01 +0000331 DEBUG(dbgs() << "********** List Scheduling **********\n");
David Goodwind94a4e52009-08-10 15:55:25 +0000332 DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su)
333 SUnits[su].dumpAll(this));
334
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000335 AvailableQueue.initNodes(SUnits);
David Goodwin557bbe62009-11-20 19:32:48 +0000336 ListScheduleTopDown();
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000337 AvailableQueue.releaseState();
338}
339
340/// Observe - Update liveness information to account for the current
341/// instruction, which will not be scheduled.
342///
Dan Gohman47ac0f02009-02-11 04:27:20 +0000343void SchedulePostRATDList::Observe(MachineInstr *MI, unsigned Count) {
David Goodwin2e7be612009-10-26 16:59:04 +0000344 if (AntiDepBreak != NULL)
345 AntiDepBreak->Observe(MI, Count, InsertPosIndex);
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000346}
347
348/// FinishBlock - Clean up register live-range state.
349///
350void SchedulePostRATDList::FinishBlock() {
David Goodwin2e7be612009-10-26 16:59:04 +0000351 if (AntiDepBreak != NULL)
352 AntiDepBreak->FinishBlock();
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000353
354 // Call the superclass.
355 ScheduleDAGInstrs::FinishBlock();
356}
357
David Goodwin5e411782009-09-03 22:15:25 +0000358/// StartBlockForKills - Initialize register live-range state for updating kills
359///
360void SchedulePostRATDList::StartBlockForKills(MachineBasicBlock *BB) {
361 // Initialize the indices to indicate that no registers are live.
David Goodwin990d2852009-12-09 17:18:22 +0000362 for (unsigned i = 0; i < TRI->getNumRegs(); ++i)
363 KillIndices[i] = ~0u;
David Goodwin5e411782009-09-03 22:15:25 +0000364
365 // Determine the live-out physregs for this block.
366 if (!BB->empty() && BB->back().getDesc().isReturn()) {
367 // In a return block, examine the function live-out regs.
368 for (MachineRegisterInfo::liveout_iterator I = MRI.liveout_begin(),
369 E = MRI.liveout_end(); I != E; ++I) {
370 unsigned Reg = *I;
371 KillIndices[Reg] = BB->size();
372 // Repeat, for all subregs.
373 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
374 *Subreg; ++Subreg) {
375 KillIndices[*Subreg] = BB->size();
376 }
377 }
378 }
379 else {
380 // In a non-return block, examine the live-in regs of all successors.
381 for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(),
382 SE = BB->succ_end(); SI != SE; ++SI) {
383 for (MachineBasicBlock::livein_iterator I = (*SI)->livein_begin(),
384 E = (*SI)->livein_end(); I != E; ++I) {
385 unsigned Reg = *I;
386 KillIndices[Reg] = BB->size();
387 // Repeat, for all subregs.
388 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
389 *Subreg; ++Subreg) {
390 KillIndices[*Subreg] = BB->size();
391 }
392 }
393 }
394 }
395}
396
David Goodwin8f909342009-09-23 16:35:25 +0000397bool SchedulePostRATDList::ToggleKillFlag(MachineInstr *MI,
398 MachineOperand &MO) {
399 // Setting kill flag...
400 if (!MO.isKill()) {
401 MO.setIsKill(true);
402 return false;
403 }
Jim Grosbach90013032010-05-14 21:19:48 +0000404
David Goodwin8f909342009-09-23 16:35:25 +0000405 // If MO itself is live, clear the kill flag...
406 if (KillIndices[MO.getReg()] != ~0u) {
407 MO.setIsKill(false);
408 return false;
409 }
410
411 // If any subreg of MO is live, then create an imp-def for that
412 // subreg and keep MO marked as killed.
Benjamin Kramer8bff4af2009-10-02 15:59:52 +0000413 MO.setIsKill(false);
David Goodwin8f909342009-09-23 16:35:25 +0000414 bool AllDead = true;
415 const unsigned SuperReg = MO.getReg();
416 for (const unsigned *Subreg = TRI->getSubRegisters(SuperReg);
417 *Subreg; ++Subreg) {
418 if (KillIndices[*Subreg] != ~0u) {
419 MI->addOperand(MachineOperand::CreateReg(*Subreg,
420 true /*IsDef*/,
421 true /*IsImp*/,
422 false /*IsKill*/,
423 false /*IsDead*/));
424 AllDead = false;
425 }
426 }
427
Dan Gohmanc1ae8c92009-10-21 01:44:44 +0000428 if(AllDead)
Benjamin Kramer8bff4af2009-10-02 15:59:52 +0000429 MO.setIsKill(true);
David Goodwin8f909342009-09-23 16:35:25 +0000430 return false;
431}
432
David Goodwin88a589c2009-08-25 17:03:05 +0000433/// FixupKills - Fix the register kill flags, they may have been made
434/// incorrect by instruction reordering.
435///
436void SchedulePostRATDList::FixupKills(MachineBasicBlock *MBB) {
David Greenee1b21292010-01-05 01:26:01 +0000437 DEBUG(dbgs() << "Fixup kills for BB#" << MBB->getNumber() << '\n');
David Goodwin88a589c2009-08-25 17:03:05 +0000438
439 std::set<unsigned> killedRegs;
440 BitVector ReservedRegs = TRI->getReservedRegs(MF);
David Goodwin5e411782009-09-03 22:15:25 +0000441
442 StartBlockForKills(MBB);
Jim Grosbach90013032010-05-14 21:19:48 +0000443
David Goodwin7886cd82009-08-29 00:11:13 +0000444 // Examine block from end to start...
David Goodwin88a589c2009-08-25 17:03:05 +0000445 unsigned Count = MBB->size();
446 for (MachineBasicBlock::iterator I = MBB->end(), E = MBB->begin();
447 I != E; --Count) {
448 MachineInstr *MI = --I;
Dale Johannesenb0812f12010-03-05 00:02:59 +0000449 if (MI->isDebugValue())
450 continue;
David Goodwin88a589c2009-08-25 17:03:05 +0000451
David Goodwin7886cd82009-08-29 00:11:13 +0000452 // Update liveness. Registers that are defed but not used in this
453 // instruction are now dead. Mark register and all subregs as they
454 // are completely defined.
455 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
456 MachineOperand &MO = MI->getOperand(i);
457 if (!MO.isReg()) continue;
458 unsigned Reg = MO.getReg();
459 if (Reg == 0) continue;
460 if (!MO.isDef()) continue;
461 // Ignore two-addr defs.
462 if (MI->isRegTiedToUseOperand(i)) continue;
Jim Grosbach90013032010-05-14 21:19:48 +0000463
David Goodwin7886cd82009-08-29 00:11:13 +0000464 KillIndices[Reg] = ~0u;
Jim Grosbach90013032010-05-14 21:19:48 +0000465
David Goodwin7886cd82009-08-29 00:11:13 +0000466 // Repeat for all subregs.
467 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
468 *Subreg; ++Subreg) {
469 KillIndices[*Subreg] = ~0u;
470 }
471 }
David Goodwin88a589c2009-08-25 17:03:05 +0000472
David Goodwin8f909342009-09-23 16:35:25 +0000473 // Examine all used registers and set/clear kill flag. When a
474 // register is used multiple times we only set the kill flag on
475 // the first use.
David Goodwin88a589c2009-08-25 17:03:05 +0000476 killedRegs.clear();
477 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
478 MachineOperand &MO = MI->getOperand(i);
479 if (!MO.isReg() || !MO.isUse()) continue;
480 unsigned Reg = MO.getReg();
481 if ((Reg == 0) || ReservedRegs.test(Reg)) continue;
482
David Goodwin7886cd82009-08-29 00:11:13 +0000483 bool kill = false;
484 if (killedRegs.find(Reg) == killedRegs.end()) {
485 kill = true;
486 // A register is not killed if any subregs are live...
487 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
488 *Subreg; ++Subreg) {
489 if (KillIndices[*Subreg] != ~0u) {
490 kill = false;
491 break;
492 }
493 }
494
495 // If subreg is not live, then register is killed if it became
496 // live in this instruction
497 if (kill)
498 kill = (KillIndices[Reg] == ~0u);
499 }
Jim Grosbach90013032010-05-14 21:19:48 +0000500
David Goodwin88a589c2009-08-25 17:03:05 +0000501 if (MO.isKill() != kill) {
David Greenee1b21292010-01-05 01:26:01 +0000502 DEBUG(dbgs() << "Fixing " << MO << " in ");
Jakob Stoklund Olesen15d75d92009-12-03 01:49:56 +0000503 // Warning: ToggleKillFlag may invalidate MO.
504 ToggleKillFlag(MI, MO);
David Goodwin88a589c2009-08-25 17:03:05 +0000505 DEBUG(MI->dump());
506 }
Jim Grosbach90013032010-05-14 21:19:48 +0000507
David Goodwin88a589c2009-08-25 17:03:05 +0000508 killedRegs.insert(Reg);
509 }
Jim Grosbach90013032010-05-14 21:19:48 +0000510
David Goodwina3251db2009-08-31 20:47:02 +0000511 // Mark any used register (that is not using undef) and subregs as
512 // now live...
David Goodwin7886cd82009-08-29 00:11:13 +0000513 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
514 MachineOperand &MO = MI->getOperand(i);
David Goodwina3251db2009-08-31 20:47:02 +0000515 if (!MO.isReg() || !MO.isUse() || MO.isUndef()) continue;
David Goodwin7886cd82009-08-29 00:11:13 +0000516 unsigned Reg = MO.getReg();
517 if ((Reg == 0) || ReservedRegs.test(Reg)) continue;
518
David Goodwin7886cd82009-08-29 00:11:13 +0000519 KillIndices[Reg] = Count;
Jim Grosbach90013032010-05-14 21:19:48 +0000520
David Goodwin7886cd82009-08-29 00:11:13 +0000521 for (const unsigned *Subreg = TRI->getSubRegisters(Reg);
522 *Subreg; ++Subreg) {
523 KillIndices[*Subreg] = Count;
524 }
525 }
David Goodwin88a589c2009-08-25 17:03:05 +0000526 }
527}
528
Dan Gohman343f0c02008-11-19 23:18:57 +0000529//===----------------------------------------------------------------------===//
530// Top-Down Scheduling
531//===----------------------------------------------------------------------===//
532
533/// ReleaseSucc - Decrement the NumPredsLeft count of a successor. Add it to
534/// the PendingQueue if the count reaches zero. Also update its cycle bound.
David Goodwin557bbe62009-11-20 19:32:48 +0000535void SchedulePostRATDList::ReleaseSucc(SUnit *SU, SDep *SuccEdge) {
Dan Gohman54e4c362008-12-09 22:54:47 +0000536 SUnit *SuccSU = SuccEdge->getSUnit();
Reid Klecknerc277ab02009-09-30 20:15:38 +0000537
Dan Gohman343f0c02008-11-19 23:18:57 +0000538#ifndef NDEBUG
Reid Klecknerc277ab02009-09-30 20:15:38 +0000539 if (SuccSU->NumPredsLeft == 0) {
David Greenee1b21292010-01-05 01:26:01 +0000540 dbgs() << "*** Scheduling failed! ***\n";
Dan Gohman343f0c02008-11-19 23:18:57 +0000541 SuccSU->dump(this);
David Greenee1b21292010-01-05 01:26:01 +0000542 dbgs() << " has been released too many times!\n";
Torok Edwinc23197a2009-07-14 16:55:14 +0000543 llvm_unreachable(0);
Dan Gohman343f0c02008-11-19 23:18:57 +0000544 }
545#endif
Reid Klecknerc277ab02009-09-30 20:15:38 +0000546 --SuccSU->NumPredsLeft;
547
Andrew Trick89fd4372011-05-06 18:14:32 +0000548 // Standard scheduler algorithms will recompute the depth of the successor
Andrew Trick15ab3592011-05-06 17:09:08 +0000549 // here as such:
550 // SuccSU->setDepthToAtLeast(SU->getDepth() + SuccEdge->getLatency());
551 //
552 // However, we lazily compute node depth instead. Note that
553 // ScheduleNodeTopDown has already updated the depth of this node which causes
554 // all descendents to be marked dirty. Setting the successor depth explicitly
555 // here would cause depth to be recomputed for all its ancestors. If the
556 // successor is not yet ready (because of a transitively redundant edge) then
557 // this causes depth computation to be quadratic in the size of the DAG.
Jim Grosbach90013032010-05-14 21:19:48 +0000558
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000559 // If all the node's predecessors are scheduled, this node is ready
560 // to be scheduled. Ignore the special ExitSU node.
561 if (SuccSU->NumPredsLeft == 0 && SuccSU != &ExitSU)
Dan Gohman343f0c02008-11-19 23:18:57 +0000562 PendingQueue.push_back(SuccSU);
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000563}
564
565/// ReleaseSuccessors - Call ReleaseSucc on each of SU's successors.
David Goodwin557bbe62009-11-20 19:32:48 +0000566void SchedulePostRATDList::ReleaseSuccessors(SUnit *SU) {
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000567 for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
David Goodwin4de099d2009-11-03 20:57:50 +0000568 I != E; ++I) {
David Goodwin557bbe62009-11-20 19:32:48 +0000569 ReleaseSucc(SU, &*I);
David Goodwin4de099d2009-11-03 20:57:50 +0000570 }
Dan Gohman343f0c02008-11-19 23:18:57 +0000571}
572
573/// ScheduleNodeTopDown - Add the node to the schedule. Decrement the pending
574/// count of its successors. If a successor pending count is zero, add it to
575/// the Available queue.
David Goodwin557bbe62009-11-20 19:32:48 +0000576void SchedulePostRATDList::ScheduleNodeTopDown(SUnit *SU, unsigned CurCycle) {
David Greenee1b21292010-01-05 01:26:01 +0000577 DEBUG(dbgs() << "*** Scheduling [" << CurCycle << "]: ");
Dan Gohman343f0c02008-11-19 23:18:57 +0000578 DEBUG(SU->dump(this));
Jim Grosbach90013032010-05-14 21:19:48 +0000579
Dan Gohman343f0c02008-11-19 23:18:57 +0000580 Sequence.push_back(SU);
Jim Grosbach90013032010-05-14 21:19:48 +0000581 assert(CurCycle >= SU->getDepth() &&
David Goodwin4de099d2009-11-03 20:57:50 +0000582 "Node scheduled above its depth!");
David Goodwin557bbe62009-11-20 19:32:48 +0000583 SU->setDepthToAtLeast(CurCycle);
Dan Gohman343f0c02008-11-19 23:18:57 +0000584
David Goodwin557bbe62009-11-20 19:32:48 +0000585 ReleaseSuccessors(SU);
Dan Gohman343f0c02008-11-19 23:18:57 +0000586 SU->isScheduled = true;
587 AvailableQueue.ScheduledNode(SU);
588}
589
590/// ListScheduleTopDown - The main loop of list scheduling for top-down
591/// schedulers.
David Goodwin557bbe62009-11-20 19:32:48 +0000592void SchedulePostRATDList::ListScheduleTopDown() {
Dan Gohman343f0c02008-11-19 23:18:57 +0000593 unsigned CurCycle = 0;
Jim Grosbach90013032010-05-14 21:19:48 +0000594
David Goodwin4de099d2009-11-03 20:57:50 +0000595 // We're scheduling top-down but we're visiting the regions in
596 // bottom-up order, so we don't know the hazards at the start of a
597 // region. So assume no hazards (this should usually be ok as most
598 // blocks are a single region).
599 HazardRec->Reset();
600
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000601 // Release any successors of the special Entry node.
David Goodwin557bbe62009-11-20 19:32:48 +0000602 ReleaseSuccessors(&EntrySU);
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000603
David Goodwin557bbe62009-11-20 19:32:48 +0000604 // Add all leaves to Available queue.
Dan Gohman343f0c02008-11-19 23:18:57 +0000605 for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
606 // It is available if it has no predecessors.
David Goodwin4de099d2009-11-03 20:57:50 +0000607 bool available = SUnits[i].Preds.empty();
David Goodwin4de099d2009-11-03 20:57:50 +0000608 if (available) {
Dan Gohman343f0c02008-11-19 23:18:57 +0000609 AvailableQueue.push(&SUnits[i]);
610 SUnits[i].isAvailable = true;
611 }
612 }
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000613
David Goodwin2ffb0ce2009-08-12 21:47:46 +0000614 // In any cycle where we can't schedule any instructions, we must
615 // stall or emit a noop, depending on the target.
Benjamin Kramerbe441c02009-09-06 12:10:17 +0000616 bool CycleHasInsts = false;
David Goodwin2ffb0ce2009-08-12 21:47:46 +0000617
Dan Gohman343f0c02008-11-19 23:18:57 +0000618 // While Available queue is not empty, grab the node with the highest
619 // priority. If it is not ready put it back. Schedule the node.
Dan Gohman2836c282009-01-16 01:33:36 +0000620 std::vector<SUnit*> NotReady;
Dan Gohman343f0c02008-11-19 23:18:57 +0000621 Sequence.reserve(SUnits.size());
622 while (!AvailableQueue.empty() || !PendingQueue.empty()) {
623 // Check to see if any of the pending instructions are ready to issue. If
624 // so, add them to the available queue.
Dan Gohman3f237442008-12-16 03:25:46 +0000625 unsigned MinDepth = ~0u;
Dan Gohman343f0c02008-11-19 23:18:57 +0000626 for (unsigned i = 0, e = PendingQueue.size(); i != e; ++i) {
David Goodwin557bbe62009-11-20 19:32:48 +0000627 if (PendingQueue[i]->getDepth() <= CurCycle) {
Dan Gohman343f0c02008-11-19 23:18:57 +0000628 AvailableQueue.push(PendingQueue[i]);
629 PendingQueue[i]->isAvailable = true;
630 PendingQueue[i] = PendingQueue.back();
631 PendingQueue.pop_back();
632 --i; --e;
David Goodwin557bbe62009-11-20 19:32:48 +0000633 } else if (PendingQueue[i]->getDepth() < MinDepth)
634 MinDepth = PendingQueue[i]->getDepth();
Dan Gohman343f0c02008-11-19 23:18:57 +0000635 }
David Goodwinc93d8372009-08-11 17:35:23 +0000636
Andrew Trick2da8bc82010-12-24 05:03:26 +0000637 DEBUG(dbgs() << "\n*** Examining Available\n"; AvailableQueue.dump(this));
David Goodwinc93d8372009-08-11 17:35:23 +0000638
Dan Gohman2836c282009-01-16 01:33:36 +0000639 SUnit *FoundSUnit = 0;
Dan Gohman2836c282009-01-16 01:33:36 +0000640 bool HasNoopHazards = false;
641 while (!AvailableQueue.empty()) {
642 SUnit *CurSUnit = AvailableQueue.pop();
643
644 ScheduleHazardRecognizer::HazardType HT =
Andrew Trick2da8bc82010-12-24 05:03:26 +0000645 HazardRec->getHazardType(CurSUnit, 0/*no stalls*/);
Dan Gohman2836c282009-01-16 01:33:36 +0000646 if (HT == ScheduleHazardRecognizer::NoHazard) {
647 FoundSUnit = CurSUnit;
648 break;
649 }
650
651 // Remember if this is a noop hazard.
652 HasNoopHazards |= HT == ScheduleHazardRecognizer::NoopHazard;
653
654 NotReady.push_back(CurSUnit);
655 }
656
657 // Add the nodes that aren't ready back onto the available list.
658 if (!NotReady.empty()) {
659 AvailableQueue.push_all(NotReady);
660 NotReady.clear();
661 }
662
David Goodwin4de099d2009-11-03 20:57:50 +0000663 // If we found a node to schedule...
Dan Gohman343f0c02008-11-19 23:18:57 +0000664 if (FoundSUnit) {
David Goodwin4de099d2009-11-03 20:57:50 +0000665 // ... schedule the node...
David Goodwin557bbe62009-11-20 19:32:48 +0000666 ScheduleNodeTopDown(FoundSUnit, CurCycle);
Dan Gohman2836c282009-01-16 01:33:36 +0000667 HazardRec->EmitInstruction(FoundSUnit);
Benjamin Kramerbe441c02009-09-06 12:10:17 +0000668 CycleHasInsts = true;
Andrew Trickcf9aa282011-06-01 03:27:56 +0000669 if (HazardRec->atIssueLimit()) {
670 DEBUG(dbgs() << "*** Max instructions per cycle " << CurCycle << '\n');
671 HazardRec->AdvanceCycle();
672 ++CurCycle;
673 CycleHasInsts = false;
674 }
Dan Gohman2836c282009-01-16 01:33:36 +0000675 } else {
Benjamin Kramerbe441c02009-09-06 12:10:17 +0000676 if (CycleHasInsts) {
David Greenee1b21292010-01-05 01:26:01 +0000677 DEBUG(dbgs() << "*** Finished cycle " << CurCycle << '\n');
David Goodwin2ffb0ce2009-08-12 21:47:46 +0000678 HazardRec->AdvanceCycle();
679 } else if (!HasNoopHazards) {
680 // Otherwise, we have a pipeline stall, but no other problem,
681 // just advance the current cycle and try again.
David Greenee1b21292010-01-05 01:26:01 +0000682 DEBUG(dbgs() << "*** Stall in cycle " << CurCycle << '\n');
David Goodwin2ffb0ce2009-08-12 21:47:46 +0000683 HazardRec->AdvanceCycle();
David Goodwin557bbe62009-11-20 19:32:48 +0000684 ++NumStalls;
David Goodwin2ffb0ce2009-08-12 21:47:46 +0000685 } else {
686 // Otherwise, we have no instructions to issue and we have instructions
687 // that will fault if we don't do this right. This is the case for
688 // processors without pipeline interlocks and other cases.
David Greenee1b21292010-01-05 01:26:01 +0000689 DEBUG(dbgs() << "*** Emitting noop in cycle " << CurCycle << '\n');
David Goodwin2ffb0ce2009-08-12 21:47:46 +0000690 HazardRec->EmitNoop();
691 Sequence.push_back(0); // NULL here means noop
David Goodwin557bbe62009-11-20 19:32:48 +0000692 ++NumNoops;
David Goodwin2ffb0ce2009-08-12 21:47:46 +0000693 }
694
Dan Gohman2836c282009-01-16 01:33:36 +0000695 ++CurCycle;
Benjamin Kramerbe441c02009-09-06 12:10:17 +0000696 CycleHasInsts = false;
Dan Gohman343f0c02008-11-19 23:18:57 +0000697 }
698 }
699
700#ifndef NDEBUG
Dan Gohmana1e6d362008-11-20 01:26:25 +0000701 VerifySchedule(/*isBottomUp=*/false);
Dan Gohman343f0c02008-11-19 23:18:57 +0000702#endif
703}
Dale Johannesene7e7d0d2007-07-13 17:13:54 +0000704
705//===----------------------------------------------------------------------===//
706// Public Constructor Functions
707//===----------------------------------------------------------------------===//
708
Evan Chengfa163542009-10-16 21:06:15 +0000709FunctionPass *llvm::createPostRAScheduler(CodeGenOpt::Level OptLevel) {
710 return new PostRAScheduler(OptLevel);
Dale Johannesene7e7d0d2007-07-13 17:13:54 +0000711}