blob: 81e3ff6afe4e8aa2848f3abee029ad8bc13b60a3 [file] [log] [blame]
Dan Gohmanee2e4032008-09-18 16:26:26 +00001//===----- ScheduleDAGFast.cpp - Fast poor list scheduler -----------------===//
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 a fast scheduler.
11//
12//===----------------------------------------------------------------------===//
13
14#define DEBUG_TYPE "pre-RA-sched"
Dan Gohman84fbac52009-02-06 17:22:58 +000015#include "ScheduleDAGSDNodes.h"
Evan Chengd4f75962012-10-17 19:39:36 +000016#include "InstrEmitter.h"
Dale Johannesen6cf64a62010-08-17 22:17:24 +000017#include "llvm/InlineAsm.h"
Dan Gohmanee2e4032008-09-18 16:26:26 +000018#include "llvm/CodeGen/SchedulerRegistry.h"
Dan Gohman79ce2762009-01-15 19:20:50 +000019#include "llvm/CodeGen/SelectionDAGISel.h"
Dan Gohmanee2e4032008-09-18 16:26:26 +000020#include "llvm/Target/TargetRegisterInfo.h"
Micah Villmow3574eca2012-10-08 16:38:25 +000021#include "llvm/DataLayout.h"
Dan Gohmanee2e4032008-09-18 16:26:26 +000022#include "llvm/Target/TargetInstrInfo.h"
23#include "llvm/Support/Debug.h"
Dan Gohmanee2e4032008-09-18 16:26:26 +000024#include "llvm/ADT/SmallSet.h"
25#include "llvm/ADT/Statistic.h"
26#include "llvm/ADT/STLExtras.h"
Torok Edwin7d696d82009-07-11 13:10:19 +000027#include "llvm/Support/ErrorHandling.h"
Chris Lattnerbbbfa992009-08-23 06:35:02 +000028#include "llvm/Support/raw_ostream.h"
Dan Gohmanee2e4032008-09-18 16:26:26 +000029using namespace llvm;
30
31STATISTIC(NumUnfolds, "Number of nodes unfolded");
32STATISTIC(NumDups, "Number of duplicated nodes");
Evan Chengc29a56d2009-01-12 03:19:55 +000033STATISTIC(NumPRCopies, "Number of physical copies");
Dan Gohmanee2e4032008-09-18 16:26:26 +000034
35static RegisterScheduler
Dan Gohmanb8cab922008-10-14 20:25:08 +000036 fastDAGScheduler("fast", "Fast suboptimal list scheduling",
Dan Gohmanee2e4032008-09-18 16:26:26 +000037 createFastDAGScheduler);
Evan Chengd4f75962012-10-17 19:39:36 +000038static RegisterScheduler
39 linearizeDAGScheduler("linearize", "Linearize DAG, no scheduling",
40 createDAGLinearizer);
41
Dan Gohmanee2e4032008-09-18 16:26:26 +000042
43namespace {
44 /// FastPriorityQueue - A degenerate priority queue that considers
45 /// all nodes to have the same priority.
46 ///
Nick Lewycky6726b6d2009-10-25 06:33:48 +000047 struct FastPriorityQueue {
Dan Gohman086ec992008-09-23 18:50:48 +000048 SmallVector<SUnit *, 16> Queue;
Dan Gohmanee2e4032008-09-18 16:26:26 +000049
50 bool empty() const { return Queue.empty(); }
Andrew Trickdbdca362012-03-07 05:21:32 +000051
Dan Gohmanee2e4032008-09-18 16:26:26 +000052 void push(SUnit *U) {
53 Queue.push_back(U);
54 }
55
56 SUnit *pop() {
57 if (empty()) return NULL;
58 SUnit *V = Queue.back();
59 Queue.pop_back();
60 return V;
61 }
62 };
63
64//===----------------------------------------------------------------------===//
65/// ScheduleDAGFast - The actual "fast" list scheduler implementation.
66///
Nick Lewycky6726b6d2009-10-25 06:33:48 +000067class ScheduleDAGFast : public ScheduleDAGSDNodes {
Dan Gohmanee2e4032008-09-18 16:26:26 +000068private:
69 /// AvailableQueue - The priority queue to use for the available SUnits.
70 FastPriorityQueue AvailableQueue;
71
Dan Gohman086ec992008-09-23 18:50:48 +000072 /// LiveRegDefs - A set of physical registers and their definition
Dan Gohmanee2e4032008-09-18 16:26:26 +000073 /// that are "live". These nodes must be scheduled before any other nodes that
74 /// modifies the registers can be scheduled.
Dan Gohman086ec992008-09-23 18:50:48 +000075 unsigned NumLiveRegs;
Dan Gohmanee2e4032008-09-18 16:26:26 +000076 std::vector<SUnit*> LiveRegDefs;
77 std::vector<unsigned> LiveRegCycles;
78
79public:
Dan Gohman79ce2762009-01-15 19:20:50 +000080 ScheduleDAGFast(MachineFunction &mf)
81 : ScheduleDAGSDNodes(mf) {}
Dan Gohmanee2e4032008-09-18 16:26:26 +000082
83 void Schedule();
84
Dan Gohman54e4c362008-12-09 22:54:47 +000085 /// AddPred - adds a predecessor edge to SUnit SU.
Dan Gohmanee2e4032008-09-18 16:26:26 +000086 /// This returns true if this is a new predecessor.
Dan Gohmanffa39122008-12-16 01:00:55 +000087 void AddPred(SUnit *SU, const SDep &D) {
88 SU->addPred(D);
Dan Gohman54e4c362008-12-09 22:54:47 +000089 }
Dan Gohmanee2e4032008-09-18 16:26:26 +000090
Dan Gohman54e4c362008-12-09 22:54:47 +000091 /// RemovePred - removes a predecessor edge from SUnit SU.
92 /// This returns true if an edge was removed.
Dan Gohmanffa39122008-12-16 01:00:55 +000093 void RemovePred(SUnit *SU, const SDep &D) {
94 SU->removePred(D);
Dan Gohman54e4c362008-12-09 22:54:47 +000095 }
Dan Gohmanee2e4032008-09-18 16:26:26 +000096
97private:
Dan Gohman54e4c362008-12-09 22:54:47 +000098 void ReleasePred(SUnit *SU, SDep *PredEdge);
Dan Gohman9e64bbb2009-02-10 23:27:53 +000099 void ReleasePredecessors(SUnit *SU, unsigned CurCycle);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000100 void ScheduleNodeBottomUp(SUnit*, unsigned);
101 SUnit *CopyAndMoveSuccessors(SUnit*);
Evan Chengc29a56d2009-01-12 03:19:55 +0000102 void InsertCopiesAndMoveSuccs(SUnit*, unsigned,
103 const TargetRegisterClass*,
104 const TargetRegisterClass*,
105 SmallVector<SUnit*, 2>&);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000106 bool DelayForLiveRegsBottomUp(SUnit*, SmallVector<unsigned, 4>&);
107 void ListScheduleBottomUp();
Dan Gohman3f237442008-12-16 03:25:46 +0000108
Andrew Trick953be892012-03-07 23:00:49 +0000109 /// forceUnitLatencies - The fast scheduler doesn't care about real latencies.
110 bool forceUnitLatencies() const { return true; }
Dan Gohmanee2e4032008-09-18 16:26:26 +0000111};
112} // end anonymous namespace
113
114
115/// Schedule - Schedule the DAG using list scheduling.
116void ScheduleDAGFast::Schedule() {
David Greene33db62c2010-01-05 01:25:09 +0000117 DEBUG(dbgs() << "********** List Scheduling **********\n");
Dan Gohmanee2e4032008-09-18 16:26:26 +0000118
Dan Gohman086ec992008-09-23 18:50:48 +0000119 NumLiveRegs = 0;
Andrew Trickdbdca362012-03-07 05:21:32 +0000120 LiveRegDefs.resize(TRI->getNumRegs(), NULL);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000121 LiveRegCycles.resize(TRI->getNumRegs(), 0);
122
Dan Gohmanc9a5b9e2008-12-23 18:36:58 +0000123 // Build the scheduling graph.
Dan Gohman98976e42009-10-09 23:33:48 +0000124 BuildSchedGraph(NULL);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000125
126 DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su)
Dan Gohman3cc62432008-11-18 02:06:40 +0000127 SUnits[su].dumpAll(this));
Dan Gohmanee2e4032008-09-18 16:26:26 +0000128
129 // Execute the actual scheduling loop.
130 ListScheduleBottomUp();
131}
132
133//===----------------------------------------------------------------------===//
134// Bottom-Up Scheduling
135//===----------------------------------------------------------------------===//
136
137/// ReleasePred - Decrement the NumSuccsLeft count of a predecessor. Add it to
138/// the AvailableQueue if the count reaches zero. Also update its cycle bound.
Dan Gohman54e4c362008-12-09 22:54:47 +0000139void ScheduleDAGFast::ReleasePred(SUnit *SU, SDep *PredEdge) {
140 SUnit *PredSU = PredEdge->getSUnit();
Reid Klecknerc277ab02009-09-30 20:15:38 +0000141
Dan Gohmanee2e4032008-09-18 16:26:26 +0000142#ifndef NDEBUG
Reid Klecknerc277ab02009-09-30 20:15:38 +0000143 if (PredSU->NumSuccsLeft == 0) {
David Greene33db62c2010-01-05 01:25:09 +0000144 dbgs() << "*** Scheduling failed! ***\n";
Dan Gohman3cc62432008-11-18 02:06:40 +0000145 PredSU->dump(this);
David Greene33db62c2010-01-05 01:25:09 +0000146 dbgs() << " has been released too many times!\n";
Torok Edwinc23197a2009-07-14 16:55:14 +0000147 llvm_unreachable(0);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000148 }
149#endif
Reid Klecknerc277ab02009-09-30 20:15:38 +0000150 --PredSU->NumSuccsLeft;
151
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000152 // If all the node's successors are scheduled, this node is ready
153 // to be scheduled. Ignore the special EntrySU node.
154 if (PredSU->NumSuccsLeft == 0 && PredSU != &EntrySU) {
Dan Gohmanee2e4032008-09-18 16:26:26 +0000155 PredSU->isAvailable = true;
156 AvailableQueue.push(PredSU);
157 }
158}
159
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000160void ScheduleDAGFast::ReleasePredecessors(SUnit *SU, unsigned CurCycle) {
Dan Gohmanee2e4032008-09-18 16:26:26 +0000161 // Bottom up: release predecessors
162 for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
163 I != E; ++I) {
Dan Gohman54e4c362008-12-09 22:54:47 +0000164 ReleasePred(SU, &*I);
165 if (I->isAssignedRegDep()) {
Dan Gohmanee2e4032008-09-18 16:26:26 +0000166 // This is a physical register dependency and it's impossible or
Andrew Trickdbdca362012-03-07 05:21:32 +0000167 // expensive to copy the register. Make sure nothing that can
Dan Gohmanee2e4032008-09-18 16:26:26 +0000168 // clobber the register is scheduled between the predecessor and
169 // this node.
Dan Gohman54e4c362008-12-09 22:54:47 +0000170 if (!LiveRegDefs[I->getReg()]) {
Dan Gohman086ec992008-09-23 18:50:48 +0000171 ++NumLiveRegs;
Dan Gohman54e4c362008-12-09 22:54:47 +0000172 LiveRegDefs[I->getReg()] = I->getSUnit();
173 LiveRegCycles[I->getReg()] = CurCycle;
Dan Gohmanee2e4032008-09-18 16:26:26 +0000174 }
175 }
176 }
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000177}
178
179/// ScheduleNodeBottomUp - Add the node to the schedule. Decrement the pending
180/// count of its predecessors. If a predecessor pending count is zero, add it to
181/// the Available queue.
182void ScheduleDAGFast::ScheduleNodeBottomUp(SUnit *SU, unsigned CurCycle) {
David Greene33db62c2010-01-05 01:25:09 +0000183 DEBUG(dbgs() << "*** Scheduling [" << CurCycle << "]: ");
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000184 DEBUG(SU->dump(this));
185
186 assert(CurCycle >= SU->getHeight() && "Node scheduled below its height!");
187 SU->setHeightToAtLeast(CurCycle);
188 Sequence.push_back(SU);
189
190 ReleasePredecessors(SU, CurCycle);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000191
192 // Release all the implicit physical register defs that are live.
193 for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
194 I != E; ++I) {
Dan Gohman54e4c362008-12-09 22:54:47 +0000195 if (I->isAssignedRegDep()) {
Dan Gohman3f237442008-12-16 03:25:46 +0000196 if (LiveRegCycles[I->getReg()] == I->getSUnit()->getHeight()) {
Dan Gohman086ec992008-09-23 18:50:48 +0000197 assert(NumLiveRegs > 0 && "NumLiveRegs is already zero!");
Dan Gohman54e4c362008-12-09 22:54:47 +0000198 assert(LiveRegDefs[I->getReg()] == SU &&
Dan Gohmanee2e4032008-09-18 16:26:26 +0000199 "Physical register dependency violated?");
Dan Gohman086ec992008-09-23 18:50:48 +0000200 --NumLiveRegs;
Dan Gohman54e4c362008-12-09 22:54:47 +0000201 LiveRegDefs[I->getReg()] = NULL;
202 LiveRegCycles[I->getReg()] = 0;
Dan Gohmanee2e4032008-09-18 16:26:26 +0000203 }
204 }
205 }
206
207 SU->isScheduled = true;
208}
209
Dan Gohmanee2e4032008-09-18 16:26:26 +0000210/// CopyAndMoveSuccessors - Clone the specified node and move its scheduled
211/// successors to the newly created node.
212SUnit *ScheduleDAGFast::CopyAndMoveSuccessors(SUnit *SU) {
Chris Lattner29d8f0c2010-12-23 17:24:32 +0000213 if (SU->getNode()->getGluedNode())
Dan Gohmanee2e4032008-09-18 16:26:26 +0000214 return NULL;
215
Dan Gohman550f5af2008-11-13 21:36:12 +0000216 SDNode *N = SU->getNode();
Dan Gohmanee2e4032008-09-18 16:26:26 +0000217 if (!N)
218 return NULL;
219
220 SUnit *NewSU;
221 bool TryUnfold = false;
222 for (unsigned i = 0, e = N->getNumValues(); i != e; ++i) {
Owen Andersone50ed302009-08-10 22:56:29 +0000223 EVT VT = N->getValueType(i);
Chris Lattnerf1b4eaf2010-12-21 02:38:05 +0000224 if (VT == MVT::Glue)
Dan Gohmanee2e4032008-09-18 16:26:26 +0000225 return NULL;
Owen Anderson825b72b2009-08-11 20:47:22 +0000226 else if (VT == MVT::Other)
Dan Gohmanee2e4032008-09-18 16:26:26 +0000227 TryUnfold = true;
228 }
229 for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
230 const SDValue &Op = N->getOperand(i);
Owen Andersone50ed302009-08-10 22:56:29 +0000231 EVT VT = Op.getNode()->getValueType(Op.getResNo());
Chris Lattnerf1b4eaf2010-12-21 02:38:05 +0000232 if (VT == MVT::Glue)
Dan Gohmanee2e4032008-09-18 16:26:26 +0000233 return NULL;
234 }
235
236 if (TryUnfold) {
237 SmallVector<SDNode*, 2> NewNodes;
Dan Gohmana23b3b82008-11-13 21:21:28 +0000238 if (!TII->unfoldMemoryOperand(*DAG, N, NewNodes))
Dan Gohmanee2e4032008-09-18 16:26:26 +0000239 return NULL;
240
David Greene33db62c2010-01-05 01:25:09 +0000241 DEBUG(dbgs() << "Unfolding SU # " << SU->NodeNum << "\n");
Dan Gohmanee2e4032008-09-18 16:26:26 +0000242 assert(NewNodes.size() == 2 && "Expected a load folding node!");
243
244 N = NewNodes[1];
245 SDNode *LoadNode = NewNodes[0];
246 unsigned NumVals = N->getNumValues();
Dan Gohman550f5af2008-11-13 21:36:12 +0000247 unsigned OldNumVals = SU->getNode()->getNumValues();
Dan Gohmanee2e4032008-09-18 16:26:26 +0000248 for (unsigned i = 0; i != NumVals; ++i)
Dan Gohman550f5af2008-11-13 21:36:12 +0000249 DAG->ReplaceAllUsesOfValueWith(SDValue(SU->getNode(), i), SDValue(N, i));
250 DAG->ReplaceAllUsesOfValueWith(SDValue(SU->getNode(), OldNumVals-1),
Dan Gohmana23b3b82008-11-13 21:21:28 +0000251 SDValue(LoadNode, 1));
Dan Gohmanee2e4032008-09-18 16:26:26 +0000252
Andrew Trick953be892012-03-07 23:00:49 +0000253 SUnit *NewSU = newSUnit(N);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000254 assert(N->getNodeId() == -1 && "Node already inserted!");
255 N->setNodeId(NewSU->NodeNum);
Andrew Trickdbdca362012-03-07 05:21:32 +0000256
Evan Chenge837dea2011-06-28 19:10:37 +0000257 const MCInstrDesc &MCID = TII->get(N->getMachineOpcode());
258 for (unsigned i = 0; i != MCID.getNumOperands(); ++i) {
259 if (MCID.getOperandConstraint(i, MCOI::TIED_TO) != -1) {
Dan Gohmanee2e4032008-09-18 16:26:26 +0000260 NewSU->isTwoAddress = true;
261 break;
262 }
263 }
Evan Chenge837dea2011-06-28 19:10:37 +0000264 if (MCID.isCommutable())
Dan Gohmanee2e4032008-09-18 16:26:26 +0000265 NewSU->isCommutable = true;
Dan Gohmanee2e4032008-09-18 16:26:26 +0000266
267 // LoadNode may already exist. This can happen when there is another
268 // load from the same location and producing the same type of value
269 // but it has different alignment or volatileness.
270 bool isNewLoad = true;
271 SUnit *LoadSU;
272 if (LoadNode->getNodeId() != -1) {
273 LoadSU = &SUnits[LoadNode->getNodeId()];
274 isNewLoad = false;
275 } else {
Andrew Trick953be892012-03-07 23:00:49 +0000276 LoadSU = newSUnit(LoadNode);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000277 LoadNode->setNodeId(LoadSU->NodeNum);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000278 }
279
Dan Gohman54e4c362008-12-09 22:54:47 +0000280 SDep ChainPred;
Dan Gohmanee2e4032008-09-18 16:26:26 +0000281 SmallVector<SDep, 4> ChainSuccs;
282 SmallVector<SDep, 4> LoadPreds;
283 SmallVector<SDep, 4> NodePreds;
284 SmallVector<SDep, 4> NodeSuccs;
285 for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
286 I != E; ++I) {
Dan Gohman54e4c362008-12-09 22:54:47 +0000287 if (I->isCtrl())
288 ChainPred = *I;
289 else if (I->getSUnit()->getNode() &&
290 I->getSUnit()->getNode()->isOperandOf(LoadNode))
291 LoadPreds.push_back(*I);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000292 else
Dan Gohman54e4c362008-12-09 22:54:47 +0000293 NodePreds.push_back(*I);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000294 }
295 for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
296 I != E; ++I) {
Dan Gohman54e4c362008-12-09 22:54:47 +0000297 if (I->isCtrl())
298 ChainSuccs.push_back(*I);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000299 else
Dan Gohman54e4c362008-12-09 22:54:47 +0000300 NodeSuccs.push_back(*I);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000301 }
302
Dan Gohman54e4c362008-12-09 22:54:47 +0000303 if (ChainPred.getSUnit()) {
304 RemovePred(SU, ChainPred);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000305 if (isNewLoad)
Dan Gohman54e4c362008-12-09 22:54:47 +0000306 AddPred(LoadSU, ChainPred);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000307 }
308 for (unsigned i = 0, e = LoadPreds.size(); i != e; ++i) {
Dan Gohman54e4c362008-12-09 22:54:47 +0000309 const SDep &Pred = LoadPreds[i];
310 RemovePred(SU, Pred);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000311 if (isNewLoad) {
Dan Gohman54e4c362008-12-09 22:54:47 +0000312 AddPred(LoadSU, Pred);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000313 }
314 }
315 for (unsigned i = 0, e = NodePreds.size(); i != e; ++i) {
Dan Gohman54e4c362008-12-09 22:54:47 +0000316 const SDep &Pred = NodePreds[i];
317 RemovePred(SU, Pred);
318 AddPred(NewSU, Pred);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000319 }
320 for (unsigned i = 0, e = NodeSuccs.size(); i != e; ++i) {
Dan Gohman54e4c362008-12-09 22:54:47 +0000321 SDep D = NodeSuccs[i];
322 SUnit *SuccDep = D.getSUnit();
323 D.setSUnit(SU);
324 RemovePred(SuccDep, D);
325 D.setSUnit(NewSU);
326 AddPred(SuccDep, D);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000327 }
328 for (unsigned i = 0, e = ChainSuccs.size(); i != e; ++i) {
Dan Gohman54e4c362008-12-09 22:54:47 +0000329 SDep D = ChainSuccs[i];
330 SUnit *SuccDep = D.getSUnit();
331 D.setSUnit(SU);
332 RemovePred(SuccDep, D);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000333 if (isNewLoad) {
Dan Gohman54e4c362008-12-09 22:54:47 +0000334 D.setSUnit(LoadSU);
335 AddPred(SuccDep, D);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000336 }
Andrew Trickdbdca362012-03-07 05:21:32 +0000337 }
Dan Gohmanee2e4032008-09-18 16:26:26 +0000338 if (isNewLoad) {
Dan Gohman54e4c362008-12-09 22:54:47 +0000339 AddPred(NewSU, SDep(LoadSU, SDep::Order, LoadSU->Latency));
Dan Gohmanee2e4032008-09-18 16:26:26 +0000340 }
341
342 ++NumUnfolds;
343
344 if (NewSU->NumSuccsLeft == 0) {
345 NewSU->isAvailable = true;
346 return NewSU;
347 }
348 SU = NewSU;
349 }
350
David Greene33db62c2010-01-05 01:25:09 +0000351 DEBUG(dbgs() << "Duplicating SU # " << SU->NodeNum << "\n");
Dan Gohmancdb260d2008-11-19 23:39:02 +0000352 NewSU = Clone(SU);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000353
354 // New SUnit has the exact same predecessors.
355 for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
356 I != E; ++I)
Dan Gohman3f237442008-12-16 03:25:46 +0000357 if (!I->isArtificial())
Dan Gohman54e4c362008-12-09 22:54:47 +0000358 AddPred(NewSU, *I);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000359
360 // Only copy scheduled successors. Cut them from old node's successor
361 // list and move them over.
Dan Gohman54e4c362008-12-09 22:54:47 +0000362 SmallVector<std::pair<SUnit *, SDep>, 4> DelDeps;
Dan Gohmanee2e4032008-09-18 16:26:26 +0000363 for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
364 I != E; ++I) {
Dan Gohman54e4c362008-12-09 22:54:47 +0000365 if (I->isArtificial())
Dan Gohmanee2e4032008-09-18 16:26:26 +0000366 continue;
Dan Gohman54e4c362008-12-09 22:54:47 +0000367 SUnit *SuccSU = I->getSUnit();
368 if (SuccSU->isScheduled) {
Dan Gohman54e4c362008-12-09 22:54:47 +0000369 SDep D = *I;
370 D.setSUnit(NewSU);
371 AddPred(SuccSU, D);
372 D.setSUnit(SU);
373 DelDeps.push_back(std::make_pair(SuccSU, D));
Dan Gohmanee2e4032008-09-18 16:26:26 +0000374 }
375 }
Evan Chengc29a56d2009-01-12 03:19:55 +0000376 for (unsigned i = 0, e = DelDeps.size(); i != e; ++i)
Dan Gohman54e4c362008-12-09 22:54:47 +0000377 RemovePred(DelDeps[i].first, DelDeps[i].second);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000378
379 ++NumDups;
380 return NewSU;
381}
382
Evan Chengc29a56d2009-01-12 03:19:55 +0000383/// InsertCopiesAndMoveSuccs - Insert register copies and move all
384/// scheduled successors of the given SUnit to the last copy.
385void ScheduleDAGFast::InsertCopiesAndMoveSuccs(SUnit *SU, unsigned Reg,
Dan Gohmanee2e4032008-09-18 16:26:26 +0000386 const TargetRegisterClass *DestRC,
387 const TargetRegisterClass *SrcRC,
388 SmallVector<SUnit*, 2> &Copies) {
Andrew Trick953be892012-03-07 23:00:49 +0000389 SUnit *CopyFromSU = newSUnit(static_cast<SDNode *>(NULL));
Dan Gohmanee2e4032008-09-18 16:26:26 +0000390 CopyFromSU->CopySrcRC = SrcRC;
391 CopyFromSU->CopyDstRC = DestRC;
392
Andrew Trick953be892012-03-07 23:00:49 +0000393 SUnit *CopyToSU = newSUnit(static_cast<SDNode *>(NULL));
Dan Gohmanee2e4032008-09-18 16:26:26 +0000394 CopyToSU->CopySrcRC = DestRC;
395 CopyToSU->CopyDstRC = SrcRC;
396
397 // Only copy scheduled successors. Cut them from old node's successor
398 // list and move them over.
Dan Gohman54e4c362008-12-09 22:54:47 +0000399 SmallVector<std::pair<SUnit *, SDep>, 4> DelDeps;
Dan Gohmanee2e4032008-09-18 16:26:26 +0000400 for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
401 I != E; ++I) {
Dan Gohman54e4c362008-12-09 22:54:47 +0000402 if (I->isArtificial())
Dan Gohmanee2e4032008-09-18 16:26:26 +0000403 continue;
Dan Gohman54e4c362008-12-09 22:54:47 +0000404 SUnit *SuccSU = I->getSUnit();
405 if (SuccSU->isScheduled) {
406 SDep D = *I;
407 D.setSUnit(CopyToSU);
408 AddPred(SuccSU, D);
409 DelDeps.push_back(std::make_pair(SuccSU, *I));
Dan Gohmanee2e4032008-09-18 16:26:26 +0000410 }
411 }
412 for (unsigned i = 0, e = DelDeps.size(); i != e; ++i) {
Dan Gohman54e4c362008-12-09 22:54:47 +0000413 RemovePred(DelDeps[i].first, DelDeps[i].second);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000414 }
415
Dan Gohman54e4c362008-12-09 22:54:47 +0000416 AddPred(CopyFromSU, SDep(SU, SDep::Data, SU->Latency, Reg));
417 AddPred(CopyToSU, SDep(CopyFromSU, SDep::Data, CopyFromSU->Latency, 0));
Dan Gohmanee2e4032008-09-18 16:26:26 +0000418
419 Copies.push_back(CopyFromSU);
420 Copies.push_back(CopyToSU);
421
Evan Chengc29a56d2009-01-12 03:19:55 +0000422 ++NumPRCopies;
Dan Gohmanee2e4032008-09-18 16:26:26 +0000423}
424
425/// getPhysicalRegisterVT - Returns the ValueType of the physical register
426/// definition of the specified node.
427/// FIXME: Move to SelectionDAG?
Owen Andersone50ed302009-08-10 22:56:29 +0000428static EVT getPhysicalRegisterVT(SDNode *N, unsigned Reg,
Dan Gohmanee2e4032008-09-18 16:26:26 +0000429 const TargetInstrInfo *TII) {
Evan Chenge837dea2011-06-28 19:10:37 +0000430 const MCInstrDesc &MCID = TII->get(N->getMachineOpcode());
431 assert(MCID.ImplicitDefs && "Physical reg def must be in implicit def list!");
432 unsigned NumRes = MCID.getNumDefs();
Craig Topperfac25982012-03-08 08:22:45 +0000433 for (const uint16_t *ImpDef = MCID.getImplicitDefs(); *ImpDef; ++ImpDef) {
Dan Gohmanee2e4032008-09-18 16:26:26 +0000434 if (Reg == *ImpDef)
435 break;
436 ++NumRes;
437 }
438 return N->getValueType(NumRes);
439}
440
Dale Johannesen6cf64a62010-08-17 22:17:24 +0000441/// CheckForLiveRegDef - Return true and update live register vector if the
442/// specified register def of the specified SUnit clobbers any "live" registers.
443static bool CheckForLiveRegDef(SUnit *SU, unsigned Reg,
444 std::vector<SUnit*> &LiveRegDefs,
445 SmallSet<unsigned, 4> &RegAdded,
446 SmallVector<unsigned, 4> &LRegs,
447 const TargetRegisterInfo *TRI) {
448 bool Added = false;
Jakob Stoklund Olesen8c70ea42012-06-01 22:38:17 +0000449 for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI) {
450 if (LiveRegDefs[*AI] && LiveRegDefs[*AI] != SU) {
451 if (RegAdded.insert(*AI)) {
452 LRegs.push_back(*AI);
Dale Johannesen6cf64a62010-08-17 22:17:24 +0000453 Added = true;
454 }
455 }
Jakob Stoklund Olesen8c70ea42012-06-01 22:38:17 +0000456 }
Dale Johannesen6cf64a62010-08-17 22:17:24 +0000457 return Added;
458}
459
Dan Gohmanee2e4032008-09-18 16:26:26 +0000460/// DelayForLiveRegsBottomUp - Returns true if it is necessary to delay
461/// scheduling of the given node to satisfy live physical register dependencies.
462/// If the specific node is the last one that's available to schedule, do
463/// whatever is necessary (i.e. backtracking or cloning) to make it possible.
464bool ScheduleDAGFast::DelayForLiveRegsBottomUp(SUnit *SU,
465 SmallVector<unsigned, 4> &LRegs){
Dan Gohman086ec992008-09-23 18:50:48 +0000466 if (NumLiveRegs == 0)
Dan Gohmanee2e4032008-09-18 16:26:26 +0000467 return false;
468
469 SmallSet<unsigned, 4> RegAdded;
470 // If this node would clobber any "live" register, then it's not ready.
471 for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
472 I != E; ++I) {
Dan Gohman54e4c362008-12-09 22:54:47 +0000473 if (I->isAssignedRegDep()) {
Dale Johannesen6cf64a62010-08-17 22:17:24 +0000474 CheckForLiveRegDef(I->getSUnit(), I->getReg(), LiveRegDefs,
475 RegAdded, LRegs, TRI);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000476 }
477 }
478
Chris Lattner29d8f0c2010-12-23 17:24:32 +0000479 for (SDNode *Node = SU->getNode(); Node; Node = Node->getGluedNode()) {
Dale Johannesen6cf64a62010-08-17 22:17:24 +0000480 if (Node->getOpcode() == ISD::INLINEASM) {
481 // Inline asm can clobber physical defs.
482 unsigned NumOps = Node->getNumOperands();
Chris Lattnerf1b4eaf2010-12-21 02:38:05 +0000483 if (Node->getOperand(NumOps-1).getValueType() == MVT::Glue)
Chris Lattner29d8f0c2010-12-23 17:24:32 +0000484 --NumOps; // Ignore the glue operand.
Dale Johannesen6cf64a62010-08-17 22:17:24 +0000485
486 for (unsigned i = InlineAsm::Op_FirstOperand; i != NumOps;) {
487 unsigned Flags =
488 cast<ConstantSDNode>(Node->getOperand(i))->getZExtValue();
489 unsigned NumVals = InlineAsm::getNumOperandRegisters(Flags);
490
491 ++i; // Skip the ID value.
492 if (InlineAsm::isRegDefKind(Flags) ||
Jakob Stoklund Olesenf792fa92011-06-27 04:08:33 +0000493 InlineAsm::isRegDefEarlyClobberKind(Flags) ||
494 InlineAsm::isClobberKind(Flags)) {
Dale Johannesen6cf64a62010-08-17 22:17:24 +0000495 // Check for def of register or earlyclobber register.
496 for (; NumVals; --NumVals, ++i) {
497 unsigned Reg = cast<RegisterSDNode>(Node->getOperand(i))->getReg();
498 if (TargetRegisterInfo::isPhysicalRegister(Reg))
499 CheckForLiveRegDef(SU, Reg, LiveRegDefs, RegAdded, LRegs, TRI);
500 }
501 } else
502 i += NumVals;
503 }
504 continue;
505 }
Dan Gohmand23e0f82008-11-13 23:24:17 +0000506 if (!Node->isMachineOpcode())
Dan Gohmanee2e4032008-09-18 16:26:26 +0000507 continue;
Evan Chenge837dea2011-06-28 19:10:37 +0000508 const MCInstrDesc &MCID = TII->get(Node->getMachineOpcode());
509 if (!MCID.ImplicitDefs)
Dan Gohmanee2e4032008-09-18 16:26:26 +0000510 continue;
Craig Topperfac25982012-03-08 08:22:45 +0000511 for (const uint16_t *Reg = MCID.getImplicitDefs(); *Reg; ++Reg) {
Dale Johannesen6cf64a62010-08-17 22:17:24 +0000512 CheckForLiveRegDef(SU, *Reg, LiveRegDefs, RegAdded, LRegs, TRI);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000513 }
514 }
515 return !LRegs.empty();
516}
517
518
519/// ListScheduleBottomUp - The main loop of list scheduling for bottom-up
520/// schedulers.
521void ScheduleDAGFast::ListScheduleBottomUp() {
522 unsigned CurCycle = 0;
Dan Gohman9e64bbb2009-02-10 23:27:53 +0000523
524 // Release any predecessors of the special Exit node.
525 ReleasePredecessors(&ExitSU, CurCycle);
526
Dan Gohmanee2e4032008-09-18 16:26:26 +0000527 // Add root to Available queue.
528 if (!SUnits.empty()) {
Dan Gohmana23b3b82008-11-13 21:21:28 +0000529 SUnit *RootSU = &SUnits[DAG->getRoot().getNode()->getNodeId()];
Dan Gohmanee2e4032008-09-18 16:26:26 +0000530 assert(RootSU->Succs.empty() && "Graph root shouldn't have successors!");
531 RootSU->isAvailable = true;
532 AvailableQueue.push(RootSU);
533 }
534
535 // While Available queue is not empty, grab the node with the highest
536 // priority. If it is not ready put it back. Schedule the node.
537 SmallVector<SUnit*, 4> NotReady;
538 DenseMap<SUnit*, SmallVector<unsigned, 4> > LRegsMap;
539 Sequence.reserve(SUnits.size());
540 while (!AvailableQueue.empty()) {
541 bool Delayed = false;
542 LRegsMap.clear();
543 SUnit *CurSU = AvailableQueue.pop();
544 while (CurSU) {
Dan Gohmane93483d2008-11-17 19:52:36 +0000545 SmallVector<unsigned, 4> LRegs;
546 if (!DelayForLiveRegsBottomUp(CurSU, LRegs))
547 break;
548 Delayed = true;
549 LRegsMap.insert(std::make_pair(CurSU, LRegs));
Dan Gohmanee2e4032008-09-18 16:26:26 +0000550
551 CurSU->isPending = true; // This SU is not in AvailableQueue right now.
552 NotReady.push_back(CurSU);
553 CurSU = AvailableQueue.pop();
554 }
555
556 // All candidates are delayed due to live physical reg dependencies.
557 // Try code duplication or inserting cross class copies
558 // to resolve it.
559 if (Delayed && !CurSU) {
560 if (!CurSU) {
561 // Try duplicating the nodes that produces these
562 // "expensive to copy" values to break the dependency. In case even
563 // that doesn't work, insert cross class copies.
564 SUnit *TrySU = NotReady[0];
565 SmallVector<unsigned, 4> &LRegs = LRegsMap[TrySU];
566 assert(LRegs.size() == 1 && "Can't handle this yet!");
567 unsigned Reg = LRegs[0];
568 SUnit *LRDef = LiveRegDefs[Reg];
Owen Andersone50ed302009-08-10 22:56:29 +0000569 EVT VT = getPhysicalRegisterVT(LRDef->getNode(), Reg, TII);
Evan Chengc29a56d2009-01-12 03:19:55 +0000570 const TargetRegisterClass *RC =
Rafael Espindolad31f9722010-06-29 14:02:34 +0000571 TRI->getMinimalPhysRegClass(Reg, VT);
Evan Chengc29a56d2009-01-12 03:19:55 +0000572 const TargetRegisterClass *DestRC = TRI->getCrossCopyRegClass(RC);
573
Evan Chengb0519e12011-03-10 00:16:32 +0000574 // If cross copy register class is the same as RC, then it must be
575 // possible copy the value directly. Do not try duplicate the def.
576 // If cross copy register class is not the same as RC, then it's
577 // possible to copy the value but it require cross register class copies
578 // and it is expensive.
579 // If cross copy register class is null, then it's not possible to copy
580 // the value at all.
Evan Chengc29a56d2009-01-12 03:19:55 +0000581 SUnit *NewDef = 0;
Evan Chengb0519e12011-03-10 00:16:32 +0000582 if (DestRC != RC) {
Evan Chengc29a56d2009-01-12 03:19:55 +0000583 NewDef = CopyAndMoveSuccessors(LRDef);
Evan Chengb0519e12011-03-10 00:16:32 +0000584 if (!DestRC && !NewDef)
585 report_fatal_error("Can't handle live physical "
586 "register dependency!");
587 }
Dan Gohmanee2e4032008-09-18 16:26:26 +0000588 if (!NewDef) {
Evan Chengc29a56d2009-01-12 03:19:55 +0000589 // Issue copies, these can be expensive cross register class copies.
Dan Gohmanee2e4032008-09-18 16:26:26 +0000590 SmallVector<SUnit*, 2> Copies;
Evan Chengc29a56d2009-01-12 03:19:55 +0000591 InsertCopiesAndMoveSuccs(LRDef, Reg, DestRC, RC, Copies);
David Greene33db62c2010-01-05 01:25:09 +0000592 DEBUG(dbgs() << "Adding an edge from SU # " << TrySU->NodeNum
Chris Lattnerbbbfa992009-08-23 06:35:02 +0000593 << " to SU #" << Copies.front()->NodeNum << "\n");
Dan Gohman54e4c362008-12-09 22:54:47 +0000594 AddPred(TrySU, SDep(Copies.front(), SDep::Order, /*Latency=*/1,
595 /*Reg=*/0, /*isNormalMemory=*/false,
596 /*isMustAlias=*/false, /*isArtificial=*/true));
Dan Gohmanee2e4032008-09-18 16:26:26 +0000597 NewDef = Copies.back();
598 }
599
David Greene33db62c2010-01-05 01:25:09 +0000600 DEBUG(dbgs() << "Adding an edge from SU # " << NewDef->NodeNum
Chris Lattnerbbbfa992009-08-23 06:35:02 +0000601 << " to SU #" << TrySU->NodeNum << "\n");
Dan Gohmanee2e4032008-09-18 16:26:26 +0000602 LiveRegDefs[Reg] = NewDef;
Dan Gohman54e4c362008-12-09 22:54:47 +0000603 AddPred(NewDef, SDep(TrySU, SDep::Order, /*Latency=*/1,
604 /*Reg=*/0, /*isNormalMemory=*/false,
605 /*isMustAlias=*/false, /*isArtificial=*/true));
Dan Gohmanee2e4032008-09-18 16:26:26 +0000606 TrySU->isAvailable = false;
607 CurSU = NewDef;
608 }
609
610 if (!CurSU) {
Torok Edwinc23197a2009-07-14 16:55:14 +0000611 llvm_unreachable("Unable to resolve live physical register dependencies!");
Dan Gohmanee2e4032008-09-18 16:26:26 +0000612 }
613 }
614
615 // Add the nodes that aren't ready back onto the available list.
616 for (unsigned i = 0, e = NotReady.size(); i != e; ++i) {
617 NotReady[i]->isPending = false;
618 // May no longer be available due to backtracking.
619 if (NotReady[i]->isAvailable)
620 AvailableQueue.push(NotReady[i]);
621 }
622 NotReady.clear();
623
Dan Gohman47d1a212008-11-21 00:10:42 +0000624 if (CurSU)
Dan Gohmanee2e4032008-09-18 16:26:26 +0000625 ScheduleNodeBottomUp(CurSU, CurCycle);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000626 ++CurCycle;
627 }
628
Dan Gohman937d2d82009-09-28 16:09:41 +0000629 // Reverse the order since it is bottom up.
Dan Gohmanee2e4032008-09-18 16:26:26 +0000630 std::reverse(Sequence.begin(), Sequence.end());
Dan Gohman937d2d82009-09-28 16:09:41 +0000631
Dan Gohmanee2e4032008-09-18 16:26:26 +0000632#ifndef NDEBUG
Andrew Trick4c727202012-03-07 05:21:36 +0000633 VerifyScheduledSequence(/*isBottomUp=*/true);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000634#endif
635}
636
Evan Chengd4f75962012-10-17 19:39:36 +0000637
638//===----------------------------------------------------------------------===//
639// ScheduleDAGLinearize - No scheduling scheduler, it simply linearize the
640// DAG in topological order.
641// IMPORTANT: this may not work for targets with phyreg dependency.
642//
643class ScheduleDAGLinearize : public ScheduleDAGSDNodes {
644public:
645 ScheduleDAGLinearize(MachineFunction &mf) : ScheduleDAGSDNodes(mf) {}
646
647 void Schedule();
648
649 MachineBasicBlock *EmitSchedule(MachineBasicBlock::iterator &InsertPos);
650
651private:
652 std::vector<SDNode*> Sequence;
653 DenseMap<SDNode*, SDNode*> GluedMap; // Cache glue to its user
654
655 void ScheduleNode(SDNode *N);
656};
657
658void ScheduleDAGLinearize::ScheduleNode(SDNode *N) {
659 if (N->getNodeId() != 0)
660 llvm_unreachable(0);
661
662 if (!N->isMachineOpcode() &&
663 (N->getOpcode() == ISD::EntryToken || isPassiveNode(N)))
664 // These nodes do not need to be translated into MIs.
665 return;
666
667 DEBUG(dbgs() << "\n*** Scheduling: ");
668 DEBUG(N->dump(DAG));
669 Sequence.push_back(N);
670
671 unsigned NumOps = N->getNumOperands();
672 if (unsigned NumLeft = NumOps) {
673 SDNode *GluedOpN = 0;
674 do {
675 const SDValue &Op = N->getOperand(NumLeft-1);
676 SDNode *OpN = Op.getNode();
677
678 if (NumLeft == NumOps && Op.getValueType() == MVT::Glue) {
679 // Schedule glue operand right above N.
680 GluedOpN = OpN;
681 assert(OpN->getNodeId() != 0 && "Glue operand not ready?");
682 OpN->setNodeId(0);
683 ScheduleNode(OpN);
684 continue;
685 }
686
687 if (OpN == GluedOpN)
688 // Glue operand is already scheduled.
689 continue;
690
691 DenseMap<SDNode*, SDNode*>::iterator DI = GluedMap.find(OpN);
692 if (DI != GluedMap.end() && DI->second != N)
693 // Users of glues are counted against the glued users.
694 OpN = DI->second;
695
696 unsigned Degree = OpN->getNodeId();
697 assert(Degree > 0 && "Predecessor over-released!");
698 OpN->setNodeId(--Degree);
699 if (Degree == 0)
700 ScheduleNode(OpN);
701 } while (--NumLeft);
702 }
703}
704
705/// findGluedUser - Find the representative use of a glue value by walking
706/// the use chain.
707static SDNode *findGluedUser(SDNode *N) {
708 while (SDNode *Glued = N->getGluedUser())
709 N = Glued;
710 return N;
711}
712
713void ScheduleDAGLinearize::Schedule() {
714 DEBUG(dbgs() << "********** DAG Linearization **********\n");
715
716 SmallVector<SDNode*, 8> Glues;
717 unsigned DAGSize = 0;
718 for (SelectionDAG::allnodes_iterator I = DAG->allnodes_begin(),
719 E = DAG->allnodes_end(); I != E; ++I) {
720 SDNode *N = I;
721
722 // Use node id to record degree.
723 unsigned Degree = N->use_size();
724 N->setNodeId(Degree);
725 unsigned NumVals = N->getNumValues();
726 if (NumVals && N->getValueType(NumVals-1) == MVT::Glue &&
727 N->hasAnyUseOfValue(NumVals-1)) {
728 SDNode *User = findGluedUser(N);
729 if (User) {
730 Glues.push_back(N);
731 GluedMap.insert(std::make_pair(N, User));
732 }
733 }
734
735 if (N->isMachineOpcode() ||
736 (N->getOpcode() != ISD::EntryToken && !isPassiveNode(N)))
737 ++DAGSize;
738 }
739
740 for (unsigned i = 0, e = Glues.size(); i != e; ++i) {
741 SDNode *Glue = Glues[i];
742 SDNode *GUser = GluedMap[Glue];
743 unsigned Degree = Glue->getNodeId();
744 unsigned UDegree = GUser->getNodeId();
745
746 // Glue user must be scheduled together with the glue operand. So other
747 // users of the glue operand must be treated as its users.
748 SDNode *ImmGUser = Glue->getGluedUser();
749 for (SDNode::use_iterator ui = Glue->use_begin(), ue = Glue->use_end();
750 ui != ue; ++ui)
751 if (*ui == ImmGUser)
752 --Degree;
753 GUser->setNodeId(UDegree + Degree);
754 Glue->setNodeId(1);
755 }
756
757 Sequence.reserve(DAGSize);
758 ScheduleNode(DAG->getRoot().getNode());
759}
760
761MachineBasicBlock*
762ScheduleDAGLinearize::EmitSchedule(MachineBasicBlock::iterator &InsertPos) {
763 InstrEmitter Emitter(BB, InsertPos);
764 DenseMap<SDValue, unsigned> VRBaseMap;
765
766 DEBUG({
767 dbgs() << "\n*** Final schedule ***\n";
768 });
769
770 // FIXME: Handle dbg_values.
771 unsigned NumNodes = Sequence.size();
772 for (unsigned i = 0; i != NumNodes; ++i) {
773 SDNode *N = Sequence[NumNodes-i-1];
774 DEBUG(N->dump(DAG));
775 Emitter.EmitNode(N, false, false, VRBaseMap);
776 }
777
778 DEBUG(dbgs() << '\n');
779
780 InsertPos = Emitter.getInsertPos();
781 return Emitter.getBlock();
782}
783
Dan Gohmanee2e4032008-09-18 16:26:26 +0000784//===----------------------------------------------------------------------===//
785// Public Constructor Functions
786//===----------------------------------------------------------------------===//
787
Dan Gohman47ac0f02009-02-11 04:27:20 +0000788llvm::ScheduleDAGSDNodes *
Bill Wendling98a366d2009-04-29 23:29:43 +0000789llvm::createFastDAGScheduler(SelectionDAGISel *IS, CodeGenOpt::Level) {
Dan Gohman79ce2762009-01-15 19:20:50 +0000790 return new ScheduleDAGFast(*IS->MF);
Dan Gohmanee2e4032008-09-18 16:26:26 +0000791}
Evan Chengd4f75962012-10-17 19:39:36 +0000792
793llvm::ScheduleDAGSDNodes *
794llvm::createDAGLinearizer(SelectionDAGISel *IS, CodeGenOpt::Level) {
795 return new ScheduleDAGLinearize(*IS->MF);
796}