Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 1 | //===----- 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 Gohman | 343f0c0 | 2008-11-19 23:18:57 +0000 | [diff] [blame] | 15 | #include "llvm/CodeGen/ScheduleDAGSDNodes.h" |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 16 | #include "llvm/CodeGen/SchedulerRegistry.h" |
Dan Gohman | 79ce276 | 2009-01-15 19:20:50 +0000 | [diff] [blame^] | 17 | #include "llvm/CodeGen/SelectionDAGISel.h" |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 18 | #include "llvm/Target/TargetRegisterInfo.h" |
| 19 | #include "llvm/Target/TargetData.h" |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 20 | #include "llvm/Target/TargetInstrInfo.h" |
| 21 | #include "llvm/Support/Debug.h" |
| 22 | #include "llvm/Support/Compiler.h" |
| 23 | #include "llvm/ADT/SmallSet.h" |
| 24 | #include "llvm/ADT/Statistic.h" |
| 25 | #include "llvm/ADT/STLExtras.h" |
| 26 | #include "llvm/Support/CommandLine.h" |
| 27 | using namespace llvm; |
| 28 | |
| 29 | STATISTIC(NumUnfolds, "Number of nodes unfolded"); |
| 30 | STATISTIC(NumDups, "Number of duplicated nodes"); |
Evan Cheng | c29a56d | 2009-01-12 03:19:55 +0000 | [diff] [blame] | 31 | STATISTIC(NumPRCopies, "Number of physical copies"); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 32 | |
| 33 | static RegisterScheduler |
Dan Gohman | b8cab92 | 2008-10-14 20:25:08 +0000 | [diff] [blame] | 34 | fastDAGScheduler("fast", "Fast suboptimal list scheduling", |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 35 | createFastDAGScheduler); |
| 36 | |
| 37 | namespace { |
| 38 | /// FastPriorityQueue - A degenerate priority queue that considers |
| 39 | /// all nodes to have the same priority. |
| 40 | /// |
| 41 | struct VISIBILITY_HIDDEN FastPriorityQueue { |
Dan Gohman | 086ec99 | 2008-09-23 18:50:48 +0000 | [diff] [blame] | 42 | SmallVector<SUnit *, 16> Queue; |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 43 | |
| 44 | bool empty() const { return Queue.empty(); } |
| 45 | |
| 46 | void push(SUnit *U) { |
| 47 | Queue.push_back(U); |
| 48 | } |
| 49 | |
| 50 | SUnit *pop() { |
| 51 | if (empty()) return NULL; |
| 52 | SUnit *V = Queue.back(); |
| 53 | Queue.pop_back(); |
| 54 | return V; |
| 55 | } |
| 56 | }; |
| 57 | |
| 58 | //===----------------------------------------------------------------------===// |
| 59 | /// ScheduleDAGFast - The actual "fast" list scheduler implementation. |
| 60 | /// |
Dan Gohman | 343f0c0 | 2008-11-19 23:18:57 +0000 | [diff] [blame] | 61 | class VISIBILITY_HIDDEN ScheduleDAGFast : public ScheduleDAGSDNodes { |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 62 | private: |
| 63 | /// AvailableQueue - The priority queue to use for the available SUnits. |
| 64 | FastPriorityQueue AvailableQueue; |
| 65 | |
Dan Gohman | 086ec99 | 2008-09-23 18:50:48 +0000 | [diff] [blame] | 66 | /// LiveRegDefs - A set of physical registers and their definition |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 67 | /// that are "live". These nodes must be scheduled before any other nodes that |
| 68 | /// modifies the registers can be scheduled. |
Dan Gohman | 086ec99 | 2008-09-23 18:50:48 +0000 | [diff] [blame] | 69 | unsigned NumLiveRegs; |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 70 | std::vector<SUnit*> LiveRegDefs; |
| 71 | std::vector<unsigned> LiveRegCycles; |
| 72 | |
| 73 | public: |
Dan Gohman | 79ce276 | 2009-01-15 19:20:50 +0000 | [diff] [blame^] | 74 | ScheduleDAGFast(MachineFunction &mf) |
| 75 | : ScheduleDAGSDNodes(mf) {} |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 76 | |
| 77 | void Schedule(); |
| 78 | |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 79 | /// AddPred - adds a predecessor edge to SUnit SU. |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 80 | /// This returns true if this is a new predecessor. |
Dan Gohman | ffa3912 | 2008-12-16 01:00:55 +0000 | [diff] [blame] | 81 | void AddPred(SUnit *SU, const SDep &D) { |
| 82 | SU->addPred(D); |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 83 | } |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 84 | |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 85 | /// RemovePred - removes a predecessor edge from SUnit SU. |
| 86 | /// This returns true if an edge was removed. |
Dan Gohman | ffa3912 | 2008-12-16 01:00:55 +0000 | [diff] [blame] | 87 | void RemovePred(SUnit *SU, const SDep &D) { |
| 88 | SU->removePred(D); |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 89 | } |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 90 | |
| 91 | private: |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 92 | void ReleasePred(SUnit *SU, SDep *PredEdge); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 93 | void ScheduleNodeBottomUp(SUnit*, unsigned); |
| 94 | SUnit *CopyAndMoveSuccessors(SUnit*); |
Evan Cheng | c29a56d | 2009-01-12 03:19:55 +0000 | [diff] [blame] | 95 | void InsertCopiesAndMoveSuccs(SUnit*, unsigned, |
| 96 | const TargetRegisterClass*, |
| 97 | const TargetRegisterClass*, |
| 98 | SmallVector<SUnit*, 2>&); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 99 | bool DelayForLiveRegsBottomUp(SUnit*, SmallVector<unsigned, 4>&); |
| 100 | void ListScheduleBottomUp(); |
Dan Gohman | 3f23744 | 2008-12-16 03:25:46 +0000 | [diff] [blame] | 101 | |
| 102 | /// ForceUnitLatencies - The fast scheduler doesn't care about real latencies. |
| 103 | bool ForceUnitLatencies() const { return true; } |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 104 | }; |
| 105 | } // end anonymous namespace |
| 106 | |
| 107 | |
| 108 | /// Schedule - Schedule the DAG using list scheduling. |
| 109 | void ScheduleDAGFast::Schedule() { |
| 110 | DOUT << "********** List Scheduling **********\n"; |
| 111 | |
Dan Gohman | 086ec99 | 2008-09-23 18:50:48 +0000 | [diff] [blame] | 112 | NumLiveRegs = 0; |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 113 | LiveRegDefs.resize(TRI->getNumRegs(), NULL); |
| 114 | LiveRegCycles.resize(TRI->getNumRegs(), 0); |
| 115 | |
Dan Gohman | c9a5b9e | 2008-12-23 18:36:58 +0000 | [diff] [blame] | 116 | // Build the scheduling graph. |
| 117 | BuildSchedGraph(); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 118 | |
| 119 | DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su) |
Dan Gohman | 3cc6243 | 2008-11-18 02:06:40 +0000 | [diff] [blame] | 120 | SUnits[su].dumpAll(this)); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 121 | |
| 122 | // Execute the actual scheduling loop. |
| 123 | ListScheduleBottomUp(); |
| 124 | } |
| 125 | |
| 126 | //===----------------------------------------------------------------------===// |
| 127 | // Bottom-Up Scheduling |
| 128 | //===----------------------------------------------------------------------===// |
| 129 | |
| 130 | /// ReleasePred - Decrement the NumSuccsLeft count of a predecessor. Add it to |
| 131 | /// the AvailableQueue if the count reaches zero. Also update its cycle bound. |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 132 | void ScheduleDAGFast::ReleasePred(SUnit *SU, SDep *PredEdge) { |
| 133 | SUnit *PredSU = PredEdge->getSUnit(); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 134 | --PredSU->NumSuccsLeft; |
| 135 | |
| 136 | #ifndef NDEBUG |
| 137 | if (PredSU->NumSuccsLeft < 0) { |
Dan Gohman | 2d093f3 | 2008-11-18 00:38:59 +0000 | [diff] [blame] | 138 | cerr << "*** Scheduling failed! ***\n"; |
Dan Gohman | 3cc6243 | 2008-11-18 02:06:40 +0000 | [diff] [blame] | 139 | PredSU->dump(this); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 140 | cerr << " has been released too many times!\n"; |
| 141 | assert(0); |
| 142 | } |
| 143 | #endif |
| 144 | |
| 145 | if (PredSU->NumSuccsLeft == 0) { |
| 146 | PredSU->isAvailable = true; |
| 147 | AvailableQueue.push(PredSU); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | /// ScheduleNodeBottomUp - Add the node to the schedule. Decrement the pending |
| 152 | /// count of its predecessors. If a predecessor pending count is zero, add it to |
| 153 | /// the Available queue. |
| 154 | void ScheduleDAGFast::ScheduleNodeBottomUp(SUnit *SU, unsigned CurCycle) { |
| 155 | DOUT << "*** Scheduling [" << CurCycle << "]: "; |
Dan Gohman | 3cc6243 | 2008-11-18 02:06:40 +0000 | [diff] [blame] | 156 | DEBUG(SU->dump(this)); |
Dan Gohman | 1256f5f | 2008-11-18 21:22:20 +0000 | [diff] [blame] | 157 | |
Dan Gohman | 3f23744 | 2008-12-16 03:25:46 +0000 | [diff] [blame] | 158 | assert(CurCycle >= SU->getHeight() && "Node scheduled below its height!"); |
| 159 | SU->setHeightToAtLeast(CurCycle); |
Dan Gohman | 1256f5f | 2008-11-18 21:22:20 +0000 | [diff] [blame] | 160 | Sequence.push_back(SU); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 161 | |
| 162 | // Bottom up: release predecessors |
| 163 | for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end(); |
| 164 | I != E; ++I) { |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 165 | ReleasePred(SU, &*I); |
| 166 | if (I->isAssignedRegDep()) { |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 167 | // This is a physical register dependency and it's impossible or |
| 168 | // expensive to copy the register. Make sure nothing that can |
| 169 | // clobber the register is scheduled between the predecessor and |
| 170 | // this node. |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 171 | if (!LiveRegDefs[I->getReg()]) { |
Dan Gohman | 086ec99 | 2008-09-23 18:50:48 +0000 | [diff] [blame] | 172 | ++NumLiveRegs; |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 173 | LiveRegDefs[I->getReg()] = I->getSUnit(); |
| 174 | LiveRegCycles[I->getReg()] = CurCycle; |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 175 | } |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | // Release all the implicit physical register defs that are live. |
| 180 | for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end(); |
| 181 | I != E; ++I) { |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 182 | if (I->isAssignedRegDep()) { |
Dan Gohman | 3f23744 | 2008-12-16 03:25:46 +0000 | [diff] [blame] | 183 | if (LiveRegCycles[I->getReg()] == I->getSUnit()->getHeight()) { |
Dan Gohman | 086ec99 | 2008-09-23 18:50:48 +0000 | [diff] [blame] | 184 | assert(NumLiveRegs > 0 && "NumLiveRegs is already zero!"); |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 185 | assert(LiveRegDefs[I->getReg()] == SU && |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 186 | "Physical register dependency violated?"); |
Dan Gohman | 086ec99 | 2008-09-23 18:50:48 +0000 | [diff] [blame] | 187 | --NumLiveRegs; |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 188 | LiveRegDefs[I->getReg()] = NULL; |
| 189 | LiveRegCycles[I->getReg()] = 0; |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 190 | } |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | SU->isScheduled = true; |
| 195 | } |
| 196 | |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 197 | /// CopyAndMoveSuccessors - Clone the specified node and move its scheduled |
| 198 | /// successors to the newly created node. |
| 199 | SUnit *ScheduleDAGFast::CopyAndMoveSuccessors(SUnit *SU) { |
Dan Gohman | d23e0f8 | 2008-11-13 23:24:17 +0000 | [diff] [blame] | 200 | if (SU->getNode()->getFlaggedNode()) |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 201 | return NULL; |
| 202 | |
Dan Gohman | 550f5af | 2008-11-13 21:36:12 +0000 | [diff] [blame] | 203 | SDNode *N = SU->getNode(); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 204 | if (!N) |
| 205 | return NULL; |
| 206 | |
| 207 | SUnit *NewSU; |
| 208 | bool TryUnfold = false; |
| 209 | for (unsigned i = 0, e = N->getNumValues(); i != e; ++i) { |
| 210 | MVT VT = N->getValueType(i); |
| 211 | if (VT == MVT::Flag) |
| 212 | return NULL; |
| 213 | else if (VT == MVT::Other) |
| 214 | TryUnfold = true; |
| 215 | } |
| 216 | for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { |
| 217 | const SDValue &Op = N->getOperand(i); |
| 218 | MVT VT = Op.getNode()->getValueType(Op.getResNo()); |
| 219 | if (VT == MVT::Flag) |
| 220 | return NULL; |
| 221 | } |
| 222 | |
| 223 | if (TryUnfold) { |
| 224 | SmallVector<SDNode*, 2> NewNodes; |
Dan Gohman | a23b3b8 | 2008-11-13 21:21:28 +0000 | [diff] [blame] | 225 | if (!TII->unfoldMemoryOperand(*DAG, N, NewNodes)) |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 226 | return NULL; |
| 227 | |
| 228 | DOUT << "Unfolding SU # " << SU->NodeNum << "\n"; |
| 229 | assert(NewNodes.size() == 2 && "Expected a load folding node!"); |
| 230 | |
| 231 | N = NewNodes[1]; |
| 232 | SDNode *LoadNode = NewNodes[0]; |
| 233 | unsigned NumVals = N->getNumValues(); |
Dan Gohman | 550f5af | 2008-11-13 21:36:12 +0000 | [diff] [blame] | 234 | unsigned OldNumVals = SU->getNode()->getNumValues(); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 235 | for (unsigned i = 0; i != NumVals; ++i) |
Dan Gohman | 550f5af | 2008-11-13 21:36:12 +0000 | [diff] [blame] | 236 | DAG->ReplaceAllUsesOfValueWith(SDValue(SU->getNode(), i), SDValue(N, i)); |
| 237 | DAG->ReplaceAllUsesOfValueWith(SDValue(SU->getNode(), OldNumVals-1), |
Dan Gohman | a23b3b8 | 2008-11-13 21:21:28 +0000 | [diff] [blame] | 238 | SDValue(LoadNode, 1)); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 239 | |
Dan Gohman | cdb260d | 2008-11-19 23:39:02 +0000 | [diff] [blame] | 240 | SUnit *NewSU = NewSUnit(N); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 241 | assert(N->getNodeId() == -1 && "Node already inserted!"); |
| 242 | N->setNodeId(NewSU->NodeNum); |
| 243 | |
| 244 | const TargetInstrDesc &TID = TII->get(N->getMachineOpcode()); |
| 245 | for (unsigned i = 0; i != TID.getNumOperands(); ++i) { |
| 246 | if (TID.getOperandConstraint(i, TOI::TIED_TO) != -1) { |
| 247 | NewSU->isTwoAddress = true; |
| 248 | break; |
| 249 | } |
| 250 | } |
| 251 | if (TID.isCommutable()) |
| 252 | NewSU->isCommutable = true; |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 253 | |
| 254 | // LoadNode may already exist. This can happen when there is another |
| 255 | // load from the same location and producing the same type of value |
| 256 | // but it has different alignment or volatileness. |
| 257 | bool isNewLoad = true; |
| 258 | SUnit *LoadSU; |
| 259 | if (LoadNode->getNodeId() != -1) { |
| 260 | LoadSU = &SUnits[LoadNode->getNodeId()]; |
| 261 | isNewLoad = false; |
| 262 | } else { |
Dan Gohman | cdb260d | 2008-11-19 23:39:02 +0000 | [diff] [blame] | 263 | LoadSU = NewSUnit(LoadNode); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 264 | LoadNode->setNodeId(LoadSU->NodeNum); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 265 | } |
| 266 | |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 267 | SDep ChainPred; |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 268 | SmallVector<SDep, 4> ChainSuccs; |
| 269 | SmallVector<SDep, 4> LoadPreds; |
| 270 | SmallVector<SDep, 4> NodePreds; |
| 271 | SmallVector<SDep, 4> NodeSuccs; |
| 272 | for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end(); |
| 273 | I != E; ++I) { |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 274 | if (I->isCtrl()) |
| 275 | ChainPred = *I; |
| 276 | else if (I->getSUnit()->getNode() && |
| 277 | I->getSUnit()->getNode()->isOperandOf(LoadNode)) |
| 278 | LoadPreds.push_back(*I); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 279 | else |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 280 | NodePreds.push_back(*I); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 281 | } |
| 282 | for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end(); |
| 283 | I != E; ++I) { |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 284 | if (I->isCtrl()) |
| 285 | ChainSuccs.push_back(*I); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 286 | else |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 287 | NodeSuccs.push_back(*I); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 288 | } |
| 289 | |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 290 | if (ChainPred.getSUnit()) { |
| 291 | RemovePred(SU, ChainPred); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 292 | if (isNewLoad) |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 293 | AddPred(LoadSU, ChainPred); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 294 | } |
| 295 | for (unsigned i = 0, e = LoadPreds.size(); i != e; ++i) { |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 296 | const SDep &Pred = LoadPreds[i]; |
| 297 | RemovePred(SU, Pred); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 298 | if (isNewLoad) { |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 299 | AddPred(LoadSU, Pred); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 300 | } |
| 301 | } |
| 302 | for (unsigned i = 0, e = NodePreds.size(); i != e; ++i) { |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 303 | const SDep &Pred = NodePreds[i]; |
| 304 | RemovePred(SU, Pred); |
| 305 | AddPred(NewSU, Pred); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 306 | } |
| 307 | for (unsigned i = 0, e = NodeSuccs.size(); i != e; ++i) { |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 308 | SDep D = NodeSuccs[i]; |
| 309 | SUnit *SuccDep = D.getSUnit(); |
| 310 | D.setSUnit(SU); |
| 311 | RemovePred(SuccDep, D); |
| 312 | D.setSUnit(NewSU); |
| 313 | AddPred(SuccDep, D); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 314 | } |
| 315 | for (unsigned i = 0, e = ChainSuccs.size(); i != e; ++i) { |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 316 | SDep D = ChainSuccs[i]; |
| 317 | SUnit *SuccDep = D.getSUnit(); |
| 318 | D.setSUnit(SU); |
| 319 | RemovePred(SuccDep, D); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 320 | if (isNewLoad) { |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 321 | D.setSUnit(LoadSU); |
| 322 | AddPred(SuccDep, D); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 323 | } |
| 324 | } |
| 325 | if (isNewLoad) { |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 326 | AddPred(NewSU, SDep(LoadSU, SDep::Order, LoadSU->Latency)); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | ++NumUnfolds; |
| 330 | |
| 331 | if (NewSU->NumSuccsLeft == 0) { |
| 332 | NewSU->isAvailable = true; |
| 333 | return NewSU; |
| 334 | } |
| 335 | SU = NewSU; |
| 336 | } |
| 337 | |
| 338 | DOUT << "Duplicating SU # " << SU->NodeNum << "\n"; |
Dan Gohman | cdb260d | 2008-11-19 23:39:02 +0000 | [diff] [blame] | 339 | NewSU = Clone(SU); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 340 | |
| 341 | // New SUnit has the exact same predecessors. |
| 342 | for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end(); |
| 343 | I != E; ++I) |
Dan Gohman | 3f23744 | 2008-12-16 03:25:46 +0000 | [diff] [blame] | 344 | if (!I->isArtificial()) |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 345 | AddPred(NewSU, *I); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 346 | |
| 347 | // Only copy scheduled successors. Cut them from old node's successor |
| 348 | // list and move them over. |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 349 | SmallVector<std::pair<SUnit *, SDep>, 4> DelDeps; |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 350 | for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end(); |
| 351 | I != E; ++I) { |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 352 | if (I->isArtificial()) |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 353 | continue; |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 354 | SUnit *SuccSU = I->getSUnit(); |
| 355 | if (SuccSU->isScheduled) { |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 356 | SDep D = *I; |
| 357 | D.setSUnit(NewSU); |
| 358 | AddPred(SuccSU, D); |
| 359 | D.setSUnit(SU); |
| 360 | DelDeps.push_back(std::make_pair(SuccSU, D)); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 361 | } |
| 362 | } |
Evan Cheng | c29a56d | 2009-01-12 03:19:55 +0000 | [diff] [blame] | 363 | for (unsigned i = 0, e = DelDeps.size(); i != e; ++i) |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 364 | RemovePred(DelDeps[i].first, DelDeps[i].second); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 365 | |
| 366 | ++NumDups; |
| 367 | return NewSU; |
| 368 | } |
| 369 | |
Evan Cheng | c29a56d | 2009-01-12 03:19:55 +0000 | [diff] [blame] | 370 | /// InsertCopiesAndMoveSuccs - Insert register copies and move all |
| 371 | /// scheduled successors of the given SUnit to the last copy. |
| 372 | void ScheduleDAGFast::InsertCopiesAndMoveSuccs(SUnit *SU, unsigned Reg, |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 373 | const TargetRegisterClass *DestRC, |
| 374 | const TargetRegisterClass *SrcRC, |
| 375 | SmallVector<SUnit*, 2> &Copies) { |
Dan Gohman | cdb260d | 2008-11-19 23:39:02 +0000 | [diff] [blame] | 376 | SUnit *CopyFromSU = NewSUnit(static_cast<SDNode *>(NULL)); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 377 | CopyFromSU->CopySrcRC = SrcRC; |
| 378 | CopyFromSU->CopyDstRC = DestRC; |
| 379 | |
Dan Gohman | cdb260d | 2008-11-19 23:39:02 +0000 | [diff] [blame] | 380 | SUnit *CopyToSU = NewSUnit(static_cast<SDNode *>(NULL)); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 381 | CopyToSU->CopySrcRC = DestRC; |
| 382 | CopyToSU->CopyDstRC = SrcRC; |
| 383 | |
| 384 | // Only copy scheduled successors. Cut them from old node's successor |
| 385 | // list and move them over. |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 386 | SmallVector<std::pair<SUnit *, SDep>, 4> DelDeps; |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 387 | for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end(); |
| 388 | I != E; ++I) { |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 389 | if (I->isArtificial()) |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 390 | continue; |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 391 | SUnit *SuccSU = I->getSUnit(); |
| 392 | if (SuccSU->isScheduled) { |
| 393 | SDep D = *I; |
| 394 | D.setSUnit(CopyToSU); |
| 395 | AddPred(SuccSU, D); |
| 396 | DelDeps.push_back(std::make_pair(SuccSU, *I)); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 397 | } |
| 398 | } |
| 399 | for (unsigned i = 0, e = DelDeps.size(); i != e; ++i) { |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 400 | RemovePred(DelDeps[i].first, DelDeps[i].second); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 401 | } |
| 402 | |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 403 | AddPred(CopyFromSU, SDep(SU, SDep::Data, SU->Latency, Reg)); |
| 404 | AddPred(CopyToSU, SDep(CopyFromSU, SDep::Data, CopyFromSU->Latency, 0)); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 405 | |
| 406 | Copies.push_back(CopyFromSU); |
| 407 | Copies.push_back(CopyToSU); |
| 408 | |
Evan Cheng | c29a56d | 2009-01-12 03:19:55 +0000 | [diff] [blame] | 409 | ++NumPRCopies; |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | /// getPhysicalRegisterVT - Returns the ValueType of the physical register |
| 413 | /// definition of the specified node. |
| 414 | /// FIXME: Move to SelectionDAG? |
| 415 | static MVT getPhysicalRegisterVT(SDNode *N, unsigned Reg, |
| 416 | const TargetInstrInfo *TII) { |
| 417 | const TargetInstrDesc &TID = TII->get(N->getMachineOpcode()); |
| 418 | assert(TID.ImplicitDefs && "Physical reg def must be in implicit def list!"); |
| 419 | unsigned NumRes = TID.getNumDefs(); |
| 420 | for (const unsigned *ImpDef = TID.getImplicitDefs(); *ImpDef; ++ImpDef) { |
| 421 | if (Reg == *ImpDef) |
| 422 | break; |
| 423 | ++NumRes; |
| 424 | } |
| 425 | return N->getValueType(NumRes); |
| 426 | } |
| 427 | |
| 428 | /// DelayForLiveRegsBottomUp - Returns true if it is necessary to delay |
| 429 | /// scheduling of the given node to satisfy live physical register dependencies. |
| 430 | /// If the specific node is the last one that's available to schedule, do |
| 431 | /// whatever is necessary (i.e. backtracking or cloning) to make it possible. |
| 432 | bool ScheduleDAGFast::DelayForLiveRegsBottomUp(SUnit *SU, |
| 433 | SmallVector<unsigned, 4> &LRegs){ |
Dan Gohman | 086ec99 | 2008-09-23 18:50:48 +0000 | [diff] [blame] | 434 | if (NumLiveRegs == 0) |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 435 | return false; |
| 436 | |
| 437 | SmallSet<unsigned, 4> RegAdded; |
| 438 | // If this node would clobber any "live" register, then it's not ready. |
| 439 | for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end(); |
| 440 | I != E; ++I) { |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 441 | if (I->isAssignedRegDep()) { |
| 442 | unsigned Reg = I->getReg(); |
| 443 | if (LiveRegDefs[Reg] && LiveRegDefs[Reg] != I->getSUnit()) { |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 444 | if (RegAdded.insert(Reg)) |
| 445 | LRegs.push_back(Reg); |
| 446 | } |
| 447 | for (const unsigned *Alias = TRI->getAliasSet(Reg); |
| 448 | *Alias; ++Alias) |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 449 | if (LiveRegDefs[*Alias] && LiveRegDefs[*Alias] != I->getSUnit()) { |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 450 | if (RegAdded.insert(*Alias)) |
| 451 | LRegs.push_back(*Alias); |
| 452 | } |
| 453 | } |
| 454 | } |
| 455 | |
Dan Gohman | d23e0f8 | 2008-11-13 23:24:17 +0000 | [diff] [blame] | 456 | for (SDNode *Node = SU->getNode(); Node; Node = Node->getFlaggedNode()) { |
| 457 | if (!Node->isMachineOpcode()) |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 458 | continue; |
| 459 | const TargetInstrDesc &TID = TII->get(Node->getMachineOpcode()); |
| 460 | if (!TID.ImplicitDefs) |
| 461 | continue; |
| 462 | for (const unsigned *Reg = TID.ImplicitDefs; *Reg; ++Reg) { |
Dan Gohman | 086ec99 | 2008-09-23 18:50:48 +0000 | [diff] [blame] | 463 | if (LiveRegDefs[*Reg] && LiveRegDefs[*Reg] != SU) { |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 464 | if (RegAdded.insert(*Reg)) |
| 465 | LRegs.push_back(*Reg); |
| 466 | } |
| 467 | for (const unsigned *Alias = TRI->getAliasSet(*Reg); |
| 468 | *Alias; ++Alias) |
Dan Gohman | 086ec99 | 2008-09-23 18:50:48 +0000 | [diff] [blame] | 469 | if (LiveRegDefs[*Alias] && LiveRegDefs[*Alias] != SU) { |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 470 | if (RegAdded.insert(*Alias)) |
| 471 | LRegs.push_back(*Alias); |
| 472 | } |
| 473 | } |
| 474 | } |
| 475 | return !LRegs.empty(); |
| 476 | } |
| 477 | |
| 478 | |
| 479 | /// ListScheduleBottomUp - The main loop of list scheduling for bottom-up |
| 480 | /// schedulers. |
| 481 | void ScheduleDAGFast::ListScheduleBottomUp() { |
| 482 | unsigned CurCycle = 0; |
| 483 | // Add root to Available queue. |
| 484 | if (!SUnits.empty()) { |
Dan Gohman | a23b3b8 | 2008-11-13 21:21:28 +0000 | [diff] [blame] | 485 | SUnit *RootSU = &SUnits[DAG->getRoot().getNode()->getNodeId()]; |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 486 | assert(RootSU->Succs.empty() && "Graph root shouldn't have successors!"); |
| 487 | RootSU->isAvailable = true; |
| 488 | AvailableQueue.push(RootSU); |
| 489 | } |
| 490 | |
| 491 | // While Available queue is not empty, grab the node with the highest |
| 492 | // priority. If it is not ready put it back. Schedule the node. |
| 493 | SmallVector<SUnit*, 4> NotReady; |
| 494 | DenseMap<SUnit*, SmallVector<unsigned, 4> > LRegsMap; |
| 495 | Sequence.reserve(SUnits.size()); |
| 496 | while (!AvailableQueue.empty()) { |
| 497 | bool Delayed = false; |
| 498 | LRegsMap.clear(); |
| 499 | SUnit *CurSU = AvailableQueue.pop(); |
| 500 | while (CurSU) { |
Dan Gohman | e93483d | 2008-11-17 19:52:36 +0000 | [diff] [blame] | 501 | SmallVector<unsigned, 4> LRegs; |
| 502 | if (!DelayForLiveRegsBottomUp(CurSU, LRegs)) |
| 503 | break; |
| 504 | Delayed = true; |
| 505 | LRegsMap.insert(std::make_pair(CurSU, LRegs)); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 506 | |
| 507 | CurSU->isPending = true; // This SU is not in AvailableQueue right now. |
| 508 | NotReady.push_back(CurSU); |
| 509 | CurSU = AvailableQueue.pop(); |
| 510 | } |
| 511 | |
| 512 | // All candidates are delayed due to live physical reg dependencies. |
| 513 | // Try code duplication or inserting cross class copies |
| 514 | // to resolve it. |
| 515 | if (Delayed && !CurSU) { |
| 516 | if (!CurSU) { |
| 517 | // Try duplicating the nodes that produces these |
| 518 | // "expensive to copy" values to break the dependency. In case even |
| 519 | // that doesn't work, insert cross class copies. |
| 520 | SUnit *TrySU = NotReady[0]; |
| 521 | SmallVector<unsigned, 4> &LRegs = LRegsMap[TrySU]; |
| 522 | assert(LRegs.size() == 1 && "Can't handle this yet!"); |
| 523 | unsigned Reg = LRegs[0]; |
| 524 | SUnit *LRDef = LiveRegDefs[Reg]; |
Evan Cheng | c29a56d | 2009-01-12 03:19:55 +0000 | [diff] [blame] | 525 | MVT VT = getPhysicalRegisterVT(LRDef->getNode(), Reg, TII); |
| 526 | const TargetRegisterClass *RC = |
| 527 | TRI->getPhysicalRegisterRegClass(Reg, VT); |
| 528 | const TargetRegisterClass *DestRC = TRI->getCrossCopyRegClass(RC); |
| 529 | |
| 530 | // If cross copy register class is null, then it must be possible copy |
| 531 | // the value directly. Do not try duplicate the def. |
| 532 | SUnit *NewDef = 0; |
| 533 | if (DestRC) |
| 534 | NewDef = CopyAndMoveSuccessors(LRDef); |
| 535 | else |
| 536 | DestRC = RC; |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 537 | if (!NewDef) { |
Evan Cheng | c29a56d | 2009-01-12 03:19:55 +0000 | [diff] [blame] | 538 | // Issue copies, these can be expensive cross register class copies. |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 539 | SmallVector<SUnit*, 2> Copies; |
Evan Cheng | c29a56d | 2009-01-12 03:19:55 +0000 | [diff] [blame] | 540 | InsertCopiesAndMoveSuccs(LRDef, Reg, DestRC, RC, Copies); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 541 | DOUT << "Adding an edge from SU # " << TrySU->NodeNum |
| 542 | << " to SU #" << Copies.front()->NodeNum << "\n"; |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 543 | AddPred(TrySU, SDep(Copies.front(), SDep::Order, /*Latency=*/1, |
| 544 | /*Reg=*/0, /*isNormalMemory=*/false, |
| 545 | /*isMustAlias=*/false, /*isArtificial=*/true)); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 546 | NewDef = Copies.back(); |
| 547 | } |
| 548 | |
| 549 | DOUT << "Adding an edge from SU # " << NewDef->NodeNum |
| 550 | << " to SU #" << TrySU->NodeNum << "\n"; |
| 551 | LiveRegDefs[Reg] = NewDef; |
Dan Gohman | 54e4c36 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 552 | AddPred(NewDef, SDep(TrySU, SDep::Order, /*Latency=*/1, |
| 553 | /*Reg=*/0, /*isNormalMemory=*/false, |
| 554 | /*isMustAlias=*/false, /*isArtificial=*/true)); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 555 | TrySU->isAvailable = false; |
| 556 | CurSU = NewDef; |
| 557 | } |
| 558 | |
| 559 | if (!CurSU) { |
| 560 | assert(false && "Unable to resolve live physical register dependencies!"); |
| 561 | abort(); |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | // Add the nodes that aren't ready back onto the available list. |
| 566 | for (unsigned i = 0, e = NotReady.size(); i != e; ++i) { |
| 567 | NotReady[i]->isPending = false; |
| 568 | // May no longer be available due to backtracking. |
| 569 | if (NotReady[i]->isAvailable) |
| 570 | AvailableQueue.push(NotReady[i]); |
| 571 | } |
| 572 | NotReady.clear(); |
| 573 | |
Dan Gohman | 47d1a21 | 2008-11-21 00:10:42 +0000 | [diff] [blame] | 574 | if (CurSU) |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 575 | ScheduleNodeBottomUp(CurSU, CurCycle); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 576 | ++CurCycle; |
| 577 | } |
| 578 | |
| 579 | // Reverse the order if it is bottom up. |
| 580 | std::reverse(Sequence.begin(), Sequence.end()); |
| 581 | |
| 582 | |
| 583 | #ifndef NDEBUG |
| 584 | // Verify that all SUnits were scheduled. |
| 585 | bool AnyNotSched = false; |
| 586 | unsigned DeadNodes = 0; |
| 587 | unsigned Noops = 0; |
| 588 | for (unsigned i = 0, e = SUnits.size(); i != e; ++i) { |
| 589 | if (!SUnits[i].isScheduled) { |
| 590 | if (SUnits[i].NumPreds == 0 && SUnits[i].NumSuccs == 0) { |
| 591 | ++DeadNodes; |
| 592 | continue; |
| 593 | } |
| 594 | if (!AnyNotSched) |
| 595 | cerr << "*** List scheduling failed! ***\n"; |
Dan Gohman | 3cc6243 | 2008-11-18 02:06:40 +0000 | [diff] [blame] | 596 | SUnits[i].dump(this); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 597 | cerr << "has not been scheduled!\n"; |
| 598 | AnyNotSched = true; |
| 599 | } |
| 600 | if (SUnits[i].NumSuccsLeft != 0) { |
| 601 | if (!AnyNotSched) |
| 602 | cerr << "*** List scheduling failed! ***\n"; |
Dan Gohman | 3cc6243 | 2008-11-18 02:06:40 +0000 | [diff] [blame] | 603 | SUnits[i].dump(this); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 604 | cerr << "has successors left!\n"; |
| 605 | AnyNotSched = true; |
| 606 | } |
| 607 | } |
| 608 | for (unsigned i = 0, e = Sequence.size(); i != e; ++i) |
| 609 | if (!Sequence[i]) |
| 610 | ++Noops; |
| 611 | assert(!AnyNotSched); |
| 612 | assert(Sequence.size() + DeadNodes - Noops == SUnits.size() && |
| 613 | "The number of nodes scheduled doesn't match the expected number!"); |
| 614 | #endif |
| 615 | } |
| 616 | |
| 617 | //===----------------------------------------------------------------------===// |
| 618 | // Public Constructor Functions |
| 619 | //===----------------------------------------------------------------------===// |
| 620 | |
Dan Gohman | 79ce276 | 2009-01-15 19:20:50 +0000 | [diff] [blame^] | 621 | llvm::ScheduleDAG* llvm::createFastDAGScheduler(SelectionDAGISel *IS, bool) { |
| 622 | return new ScheduleDAGFast(*IS->MF); |
Dan Gohman | ee2e403 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 623 | } |