Dan Gohman | 95be7d7 | 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 | |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 14 | #include "InstrEmitter.h" |
| 15 | #include "ScheduleDAGSDNodes.h" |
Adrian Prantl | dfe15f3 | 2018-03-02 22:59:51 +0000 | [diff] [blame] | 16 | #include "SDNodeDbgValue.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/STLExtras.h" |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/SmallSet.h" |
| 19 | #include "llvm/ADT/Statistic.h" |
Chandler Carruth | 6bda14b | 2017-06-06 11:49:48 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/SchedulerRegistry.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 21 | #include "llvm/CodeGen/SelectionDAGISel.h" |
David Blaikie | 3f833ed | 2017-11-08 01:01:31 +0000 | [diff] [blame] | 22 | #include "llvm/CodeGen/TargetInstrInfo.h" |
David Blaikie | b3bde2e | 2017-11-17 01:07:10 +0000 | [diff] [blame] | 23 | #include "llvm/CodeGen/TargetRegisterInfo.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 24 | #include "llvm/IR/DataLayout.h" |
| 25 | #include "llvm/IR/InlineAsm.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 26 | #include "llvm/Support/Debug.h" |
Torok Edwin | ccb29cd | 2009-07-11 13:10:19 +0000 | [diff] [blame] | 27 | #include "llvm/Support/ErrorHandling.h" |
Chris Lattner | 4dc3edd | 2009-08-23 06:35:02 +0000 | [diff] [blame] | 28 | #include "llvm/Support/raw_ostream.h" |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 29 | using namespace llvm; |
| 30 | |
Chandler Carruth | 1b9dde0 | 2014-04-22 02:02:50 +0000 | [diff] [blame] | 31 | #define DEBUG_TYPE "pre-RA-sched" |
| 32 | |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 33 | STATISTIC(NumUnfolds, "Number of nodes unfolded"); |
| 34 | STATISTIC(NumDups, "Number of duplicated nodes"); |
Evan Cheng | b2c42c6 | 2009-01-12 03:19:55 +0000 | [diff] [blame] | 35 | STATISTIC(NumPRCopies, "Number of physical copies"); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 36 | |
| 37 | static RegisterScheduler |
Dan Gohman | 9c4b7d5 | 2008-10-14 20:25:08 +0000 | [diff] [blame] | 38 | fastDAGScheduler("fast", "Fast suboptimal list scheduling", |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 39 | createFastDAGScheduler); |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 40 | static RegisterScheduler |
| 41 | linearizeDAGScheduler("linearize", "Linearize DAG, no scheduling", |
| 42 | createDAGLinearizer); |
| 43 | |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 44 | |
| 45 | namespace { |
| 46 | /// FastPriorityQueue - A degenerate priority queue that considers |
| 47 | /// all nodes to have the same priority. |
| 48 | /// |
Nick Lewycky | 02d5f77 | 2009-10-25 06:33:48 +0000 | [diff] [blame] | 49 | struct FastPriorityQueue { |
Dan Gohman | c07f686 | 2008-09-23 18:50:48 +0000 | [diff] [blame] | 50 | SmallVector<SUnit *, 16> Queue; |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 51 | |
| 52 | bool empty() const { return Queue.empty(); } |
Andrew Trick | 7c6c41a | 2012-03-07 05:21:32 +0000 | [diff] [blame] | 53 | |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 54 | void push(SUnit *U) { |
| 55 | Queue.push_back(U); |
| 56 | } |
| 57 | |
| 58 | SUnit *pop() { |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 59 | if (empty()) return nullptr; |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 60 | SUnit *V = Queue.back(); |
| 61 | Queue.pop_back(); |
| 62 | return V; |
| 63 | } |
| 64 | }; |
| 65 | |
| 66 | //===----------------------------------------------------------------------===// |
| 67 | /// ScheduleDAGFast - The actual "fast" list scheduler implementation. |
| 68 | /// |
Nick Lewycky | 02d5f77 | 2009-10-25 06:33:48 +0000 | [diff] [blame] | 69 | class ScheduleDAGFast : public ScheduleDAGSDNodes { |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 70 | private: |
| 71 | /// AvailableQueue - The priority queue to use for the available SUnits. |
| 72 | FastPriorityQueue AvailableQueue; |
| 73 | |
Dan Gohman | c07f686 | 2008-09-23 18:50:48 +0000 | [diff] [blame] | 74 | /// LiveRegDefs - A set of physical registers and their definition |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 75 | /// that are "live". These nodes must be scheduled before any other nodes that |
| 76 | /// modifies the registers can be scheduled. |
Dan Gohman | c07f686 | 2008-09-23 18:50:48 +0000 | [diff] [blame] | 77 | unsigned NumLiveRegs; |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 78 | std::vector<SUnit*> LiveRegDefs; |
| 79 | std::vector<unsigned> LiveRegCycles; |
| 80 | |
| 81 | public: |
Dan Gohman | 619ef48 | 2009-01-15 19:20:50 +0000 | [diff] [blame] | 82 | ScheduleDAGFast(MachineFunction &mf) |
| 83 | : ScheduleDAGSDNodes(mf) {} |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 84 | |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 85 | void Schedule() override; |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 86 | |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 87 | /// AddPred - adds a predecessor edge to SUnit SU. |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 88 | /// This returns true if this is a new predecessor. |
Dan Gohman | 17214e6 | 2008-12-16 01:00:55 +0000 | [diff] [blame] | 89 | void AddPred(SUnit *SU, const SDep &D) { |
| 90 | SU->addPred(D); |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 91 | } |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 92 | |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 93 | /// RemovePred - removes a predecessor edge from SUnit SU. |
| 94 | /// This returns true if an edge was removed. |
Dan Gohman | 17214e6 | 2008-12-16 01:00:55 +0000 | [diff] [blame] | 95 | void RemovePred(SUnit *SU, const SDep &D) { |
| 96 | SU->removePred(D); |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 97 | } |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 98 | |
| 99 | private: |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 100 | void ReleasePred(SUnit *SU, SDep *PredEdge); |
Dan Gohman | b954343 | 2009-02-10 23:27:53 +0000 | [diff] [blame] | 101 | void ReleasePredecessors(SUnit *SU, unsigned CurCycle); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 102 | void ScheduleNodeBottomUp(SUnit*, unsigned); |
| 103 | SUnit *CopyAndMoveSuccessors(SUnit*); |
Evan Cheng | b2c42c6 | 2009-01-12 03:19:55 +0000 | [diff] [blame] | 104 | void InsertCopiesAndMoveSuccs(SUnit*, unsigned, |
| 105 | const TargetRegisterClass*, |
| 106 | const TargetRegisterClass*, |
Craig Topper | b94011f | 2013-07-14 04:42:23 +0000 | [diff] [blame] | 107 | SmallVectorImpl<SUnit*>&); |
| 108 | bool DelayForLiveRegsBottomUp(SUnit*, SmallVectorImpl<unsigned>&); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 109 | void ListScheduleBottomUp(); |
Dan Gohman | dddc1ac | 2008-12-16 03:25:46 +0000 | [diff] [blame] | 110 | |
Andrew Trick | 52226d4 | 2012-03-07 23:00:49 +0000 | [diff] [blame] | 111 | /// forceUnitLatencies - The fast scheduler doesn't care about real latencies. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 112 | bool forceUnitLatencies() const override { return true; } |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 113 | }; |
| 114 | } // end anonymous namespace |
| 115 | |
| 116 | |
| 117 | /// Schedule - Schedule the DAG using list scheduling. |
| 118 | void ScheduleDAGFast::Schedule() { |
Nicola Zaghen | d34e60c | 2018-05-14 12:53:11 +0000 | [diff] [blame^] | 119 | LLVM_DEBUG(dbgs() << "********** List Scheduling **********\n"); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 120 | |
Dan Gohman | c07f686 | 2008-09-23 18:50:48 +0000 | [diff] [blame] | 121 | NumLiveRegs = 0; |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 122 | LiveRegDefs.resize(TRI->getNumRegs(), nullptr); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 123 | LiveRegCycles.resize(TRI->getNumRegs(), 0); |
| 124 | |
Dan Gohman | 04543e7 | 2008-12-23 18:36:58 +0000 | [diff] [blame] | 125 | // Build the scheduling graph. |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 126 | BuildSchedGraph(nullptr); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 127 | |
Nicola Zaghen | d34e60c | 2018-05-14 12:53:11 +0000 | [diff] [blame^] | 128 | LLVM_DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su) SUnits[su] |
| 129 | .dumpAll(this)); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 130 | |
| 131 | // Execute the actual scheduling loop. |
| 132 | ListScheduleBottomUp(); |
| 133 | } |
| 134 | |
| 135 | //===----------------------------------------------------------------------===// |
| 136 | // Bottom-Up Scheduling |
| 137 | //===----------------------------------------------------------------------===// |
| 138 | |
| 139 | /// ReleasePred - Decrement the NumSuccsLeft count of a predecessor. Add it to |
| 140 | /// the AvailableQueue if the count reaches zero. Also update its cycle bound. |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 141 | void ScheduleDAGFast::ReleasePred(SUnit *SU, SDep *PredEdge) { |
| 142 | SUnit *PredSU = PredEdge->getSUnit(); |
Reid Kleckner | 8ff5c19 | 2009-09-30 20:15:38 +0000 | [diff] [blame] | 143 | |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 144 | #ifndef NDEBUG |
Reid Kleckner | 8ff5c19 | 2009-09-30 20:15:38 +0000 | [diff] [blame] | 145 | if (PredSU->NumSuccsLeft == 0) { |
David Greene | d65bc15 | 2010-01-05 01:25:09 +0000 | [diff] [blame] | 146 | dbgs() << "*** Scheduling failed! ***\n"; |
Dan Gohman | 22d07b1 | 2008-11-18 02:06:40 +0000 | [diff] [blame] | 147 | PredSU->dump(this); |
David Greene | d65bc15 | 2010-01-05 01:25:09 +0000 | [diff] [blame] | 148 | dbgs() << " has been released too many times!\n"; |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 149 | llvm_unreachable(nullptr); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 150 | } |
| 151 | #endif |
Reid Kleckner | 8ff5c19 | 2009-09-30 20:15:38 +0000 | [diff] [blame] | 152 | --PredSU->NumSuccsLeft; |
| 153 | |
Dan Gohman | b954343 | 2009-02-10 23:27:53 +0000 | [diff] [blame] | 154 | // If all the node's successors are scheduled, this node is ready |
| 155 | // to be scheduled. Ignore the special EntrySU node. |
| 156 | if (PredSU->NumSuccsLeft == 0 && PredSU != &EntrySU) { |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 157 | PredSU->isAvailable = true; |
| 158 | AvailableQueue.push(PredSU); |
| 159 | } |
| 160 | } |
| 161 | |
Dan Gohman | b954343 | 2009-02-10 23:27:53 +0000 | [diff] [blame] | 162 | void ScheduleDAGFast::ReleasePredecessors(SUnit *SU, unsigned CurCycle) { |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 163 | // Bottom up: release predecessors |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 164 | for (SDep &Pred : SU->Preds) { |
| 165 | ReleasePred(SU, &Pred); |
| 166 | if (Pred.isAssignedRegDep()) { |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 167 | // This is a physical register dependency and it's impossible or |
Andrew Trick | 7c6c41a | 2012-03-07 05:21:32 +0000 | [diff] [blame] | 168 | // expensive to copy the register. Make sure nothing that can |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 169 | // clobber the register is scheduled between the predecessor and |
| 170 | // this node. |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 171 | if (!LiveRegDefs[Pred.getReg()]) { |
Dan Gohman | c07f686 | 2008-09-23 18:50:48 +0000 | [diff] [blame] | 172 | ++NumLiveRegs; |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 173 | LiveRegDefs[Pred.getReg()] = Pred.getSUnit(); |
| 174 | LiveRegCycles[Pred.getReg()] = CurCycle; |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 175 | } |
| 176 | } |
| 177 | } |
Dan Gohman | b954343 | 2009-02-10 23:27:53 +0000 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | /// ScheduleNodeBottomUp - Add the node to the schedule. Decrement the pending |
| 181 | /// count of its predecessors. If a predecessor pending count is zero, add it to |
| 182 | /// the Available queue. |
| 183 | void ScheduleDAGFast::ScheduleNodeBottomUp(SUnit *SU, unsigned CurCycle) { |
Nicola Zaghen | d34e60c | 2018-05-14 12:53:11 +0000 | [diff] [blame^] | 184 | LLVM_DEBUG(dbgs() << "*** Scheduling [" << CurCycle << "]: "); |
| 185 | LLVM_DEBUG(SU->dump(this)); |
Dan Gohman | b954343 | 2009-02-10 23:27:53 +0000 | [diff] [blame] | 186 | |
| 187 | assert(CurCycle >= SU->getHeight() && "Node scheduled below its height!"); |
| 188 | SU->setHeightToAtLeast(CurCycle); |
| 189 | Sequence.push_back(SU); |
| 190 | |
| 191 | ReleasePredecessors(SU, CurCycle); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 192 | |
| 193 | // Release all the implicit physical register defs that are live. |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 194 | for (SDep &Succ : SU->Succs) { |
| 195 | if (Succ.isAssignedRegDep()) { |
| 196 | if (LiveRegCycles[Succ.getReg()] == Succ.getSUnit()->getHeight()) { |
Dan Gohman | c07f686 | 2008-09-23 18:50:48 +0000 | [diff] [blame] | 197 | assert(NumLiveRegs > 0 && "NumLiveRegs is already zero!"); |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 198 | assert(LiveRegDefs[Succ.getReg()] == SU && |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 199 | "Physical register dependency violated?"); |
Dan Gohman | c07f686 | 2008-09-23 18:50:48 +0000 | [diff] [blame] | 200 | --NumLiveRegs; |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 201 | LiveRegDefs[Succ.getReg()] = nullptr; |
| 202 | LiveRegCycles[Succ.getReg()] = 0; |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 203 | } |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | SU->isScheduled = true; |
| 208 | } |
| 209 | |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 210 | /// CopyAndMoveSuccessors - Clone the specified node and move its scheduled |
| 211 | /// successors to the newly created node. |
| 212 | SUnit *ScheduleDAGFast::CopyAndMoveSuccessors(SUnit *SU) { |
Chris Lattner | 11a3381 | 2010-12-23 17:24:32 +0000 | [diff] [blame] | 213 | if (SU->getNode()->getGluedNode()) |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 214 | return nullptr; |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 215 | |
Dan Gohman | 1ddfcba | 2008-11-13 21:36:12 +0000 | [diff] [blame] | 216 | SDNode *N = SU->getNode(); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 217 | if (!N) |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 218 | return nullptr; |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 219 | |
| 220 | SUnit *NewSU; |
| 221 | bool TryUnfold = false; |
| 222 | for (unsigned i = 0, e = N->getNumValues(); i != e; ++i) { |
Craig Topper | 7f416c8 | 2014-11-16 21:17:18 +0000 | [diff] [blame] | 223 | MVT VT = N->getSimpleValueType(i); |
Chris Lattner | 3e5fbd7 | 2010-12-21 02:38:05 +0000 | [diff] [blame] | 224 | if (VT == MVT::Glue) |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 225 | return nullptr; |
Owen Anderson | 9f94459 | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 226 | else if (VT == MVT::Other) |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 227 | TryUnfold = true; |
| 228 | } |
Pete Cooper | 9271ccc | 2015-06-26 19:18:49 +0000 | [diff] [blame] | 229 | for (const SDValue &Op : N->op_values()) { |
Craig Topper | 7f416c8 | 2014-11-16 21:17:18 +0000 | [diff] [blame] | 230 | MVT VT = Op.getNode()->getSimpleValueType(Op.getResNo()); |
Chris Lattner | 3e5fbd7 | 2010-12-21 02:38:05 +0000 | [diff] [blame] | 231 | if (VT == MVT::Glue) |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 232 | return nullptr; |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | if (TryUnfold) { |
| 236 | SmallVector<SDNode*, 2> NewNodes; |
Dan Gohman | 5a390b9 | 2008-11-13 21:21:28 +0000 | [diff] [blame] | 237 | if (!TII->unfoldMemoryOperand(*DAG, N, NewNodes)) |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 238 | return nullptr; |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 239 | |
Nicola Zaghen | d34e60c | 2018-05-14 12:53:11 +0000 | [diff] [blame^] | 240 | LLVM_DEBUG(dbgs() << "Unfolding SU # " << SU->NodeNum << "\n"); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 241 | assert(NewNodes.size() == 2 && "Expected a load folding node!"); |
| 242 | |
| 243 | N = NewNodes[1]; |
| 244 | SDNode *LoadNode = NewNodes[0]; |
| 245 | unsigned NumVals = N->getNumValues(); |
Dan Gohman | 1ddfcba | 2008-11-13 21:36:12 +0000 | [diff] [blame] | 246 | unsigned OldNumVals = SU->getNode()->getNumValues(); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 247 | for (unsigned i = 0; i != NumVals; ++i) |
Dan Gohman | 1ddfcba | 2008-11-13 21:36:12 +0000 | [diff] [blame] | 248 | DAG->ReplaceAllUsesOfValueWith(SDValue(SU->getNode(), i), SDValue(N, i)); |
| 249 | DAG->ReplaceAllUsesOfValueWith(SDValue(SU->getNode(), OldNumVals-1), |
Dan Gohman | 5a390b9 | 2008-11-13 21:21:28 +0000 | [diff] [blame] | 250 | SDValue(LoadNode, 1)); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 251 | |
Andrew Trick | 52226d4 | 2012-03-07 23:00:49 +0000 | [diff] [blame] | 252 | SUnit *NewSU = newSUnit(N); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 253 | assert(N->getNodeId() == -1 && "Node already inserted!"); |
| 254 | N->setNodeId(NewSU->NodeNum); |
Andrew Trick | 7c6c41a | 2012-03-07 05:21:32 +0000 | [diff] [blame] | 255 | |
Evan Cheng | 6cc775f | 2011-06-28 19:10:37 +0000 | [diff] [blame] | 256 | const MCInstrDesc &MCID = TII->get(N->getMachineOpcode()); |
| 257 | for (unsigned i = 0; i != MCID.getNumOperands(); ++i) { |
| 258 | if (MCID.getOperandConstraint(i, MCOI::TIED_TO) != -1) { |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 259 | NewSU->isTwoAddress = true; |
| 260 | break; |
| 261 | } |
| 262 | } |
Evan Cheng | 6cc775f | 2011-06-28 19:10:37 +0000 | [diff] [blame] | 263 | if (MCID.isCommutable()) |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 264 | NewSU->isCommutable = true; |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 265 | |
| 266 | // LoadNode may already exist. This can happen when there is another |
| 267 | // load from the same location and producing the same type of value |
| 268 | // but it has different alignment or volatileness. |
| 269 | bool isNewLoad = true; |
| 270 | SUnit *LoadSU; |
| 271 | if (LoadNode->getNodeId() != -1) { |
| 272 | LoadSU = &SUnits[LoadNode->getNodeId()]; |
| 273 | isNewLoad = false; |
| 274 | } else { |
Andrew Trick | 52226d4 | 2012-03-07 23:00:49 +0000 | [diff] [blame] | 275 | LoadSU = newSUnit(LoadNode); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 276 | LoadNode->setNodeId(LoadSU->NodeNum); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 277 | } |
| 278 | |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 279 | SDep ChainPred; |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 280 | SmallVector<SDep, 4> ChainSuccs; |
| 281 | SmallVector<SDep, 4> LoadPreds; |
| 282 | SmallVector<SDep, 4> NodePreds; |
| 283 | SmallVector<SDep, 4> NodeSuccs; |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 284 | for (SDep &Pred : SU->Preds) { |
| 285 | if (Pred.isCtrl()) |
| 286 | ChainPred = Pred; |
| 287 | else if (Pred.getSUnit()->getNode() && |
| 288 | Pred.getSUnit()->getNode()->isOperandOf(LoadNode)) |
| 289 | LoadPreds.push_back(Pred); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 290 | else |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 291 | NodePreds.push_back(Pred); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 292 | } |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 293 | for (SDep &Succ : SU->Succs) { |
| 294 | if (Succ.isCtrl()) |
| 295 | ChainSuccs.push_back(Succ); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 296 | else |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 297 | NodeSuccs.push_back(Succ); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 298 | } |
| 299 | |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 300 | if (ChainPred.getSUnit()) { |
| 301 | RemovePred(SU, ChainPred); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 302 | if (isNewLoad) |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 303 | AddPred(LoadSU, ChainPred); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 304 | } |
| 305 | for (unsigned i = 0, e = LoadPreds.size(); i != e; ++i) { |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 306 | const SDep &Pred = LoadPreds[i]; |
| 307 | RemovePred(SU, Pred); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 308 | if (isNewLoad) { |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 309 | AddPred(LoadSU, Pred); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 310 | } |
| 311 | } |
| 312 | for (unsigned i = 0, e = NodePreds.size(); i != e; ++i) { |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 313 | const SDep &Pred = NodePreds[i]; |
| 314 | RemovePred(SU, Pred); |
| 315 | AddPred(NewSU, Pred); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 316 | } |
| 317 | for (unsigned i = 0, e = NodeSuccs.size(); i != e; ++i) { |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 318 | SDep D = NodeSuccs[i]; |
| 319 | SUnit *SuccDep = D.getSUnit(); |
| 320 | D.setSUnit(SU); |
| 321 | RemovePred(SuccDep, D); |
| 322 | D.setSUnit(NewSU); |
| 323 | AddPred(SuccDep, D); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 324 | } |
| 325 | for (unsigned i = 0, e = ChainSuccs.size(); i != e; ++i) { |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 326 | SDep D = ChainSuccs[i]; |
| 327 | SUnit *SuccDep = D.getSUnit(); |
| 328 | D.setSUnit(SU); |
| 329 | RemovePred(SuccDep, D); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 330 | if (isNewLoad) { |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 331 | D.setSUnit(LoadSU); |
| 332 | AddPred(SuccDep, D); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 333 | } |
Andrew Trick | 7c6c41a | 2012-03-07 05:21:32 +0000 | [diff] [blame] | 334 | } |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 335 | if (isNewLoad) { |
Andrew Trick | baeaabb | 2012-11-06 03:13:46 +0000 | [diff] [blame] | 336 | SDep D(LoadSU, SDep::Barrier); |
| 337 | D.setLatency(LoadSU->Latency); |
| 338 | AddPred(NewSU, D); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | ++NumUnfolds; |
| 342 | |
| 343 | if (NewSU->NumSuccsLeft == 0) { |
| 344 | NewSU->isAvailable = true; |
| 345 | return NewSU; |
| 346 | } |
| 347 | SU = NewSU; |
| 348 | } |
| 349 | |
Nicola Zaghen | d34e60c | 2018-05-14 12:53:11 +0000 | [diff] [blame^] | 350 | LLVM_DEBUG(dbgs() << "Duplicating SU # " << SU->NodeNum << "\n"); |
Dan Gohman | 4c3034f | 2008-11-19 23:39:02 +0000 | [diff] [blame] | 351 | NewSU = Clone(SU); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 352 | |
| 353 | // New SUnit has the exact same predecessors. |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 354 | for (SDep &Pred : SU->Preds) |
| 355 | if (!Pred.isArtificial()) |
| 356 | AddPred(NewSU, Pred); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 357 | |
| 358 | // Only copy scheduled successors. Cut them from old node's successor |
| 359 | // list and move them over. |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 360 | SmallVector<std::pair<SUnit *, SDep>, 4> DelDeps; |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 361 | for (SDep &Succ : SU->Succs) { |
| 362 | if (Succ.isArtificial()) |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 363 | continue; |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 364 | SUnit *SuccSU = Succ.getSUnit(); |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 365 | if (SuccSU->isScheduled) { |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 366 | SDep D = Succ; |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 367 | D.setSUnit(NewSU); |
| 368 | AddPred(SuccSU, D); |
| 369 | D.setSUnit(SU); |
| 370 | DelDeps.push_back(std::make_pair(SuccSU, D)); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 371 | } |
| 372 | } |
Evan Cheng | b2c42c6 | 2009-01-12 03:19:55 +0000 | [diff] [blame] | 373 | for (unsigned i = 0, e = DelDeps.size(); i != e; ++i) |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 374 | RemovePred(DelDeps[i].first, DelDeps[i].second); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 375 | |
| 376 | ++NumDups; |
| 377 | return NewSU; |
| 378 | } |
| 379 | |
Evan Cheng | b2c42c6 | 2009-01-12 03:19:55 +0000 | [diff] [blame] | 380 | /// InsertCopiesAndMoveSuccs - Insert register copies and move all |
| 381 | /// scheduled successors of the given SUnit to the last copy. |
| 382 | void ScheduleDAGFast::InsertCopiesAndMoveSuccs(SUnit *SU, unsigned Reg, |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 383 | const TargetRegisterClass *DestRC, |
| 384 | const TargetRegisterClass *SrcRC, |
Craig Topper | b94011f | 2013-07-14 04:42:23 +0000 | [diff] [blame] | 385 | SmallVectorImpl<SUnit*> &Copies) { |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 386 | SUnit *CopyFromSU = newSUnit(static_cast<SDNode *>(nullptr)); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 387 | CopyFromSU->CopySrcRC = SrcRC; |
| 388 | CopyFromSU->CopyDstRC = DestRC; |
| 389 | |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 390 | SUnit *CopyToSU = newSUnit(static_cast<SDNode *>(nullptr)); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 391 | CopyToSU->CopySrcRC = DestRC; |
| 392 | CopyToSU->CopyDstRC = SrcRC; |
| 393 | |
| 394 | // Only copy scheduled successors. Cut them from old node's successor |
| 395 | // list and move them over. |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 396 | SmallVector<std::pair<SUnit *, SDep>, 4> DelDeps; |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 397 | for (SDep &Succ : SU->Succs) { |
| 398 | if (Succ.isArtificial()) |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 399 | continue; |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 400 | SUnit *SuccSU = Succ.getSUnit(); |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 401 | if (SuccSU->isScheduled) { |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 402 | SDep D = Succ; |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 403 | D.setSUnit(CopyToSU); |
| 404 | AddPred(SuccSU, D); |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 405 | DelDeps.push_back(std::make_pair(SuccSU, Succ)); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 406 | } |
| 407 | } |
| 408 | for (unsigned i = 0, e = DelDeps.size(); i != e; ++i) { |
Dan Gohman | 2d17089 | 2008-12-09 22:54:47 +0000 | [diff] [blame] | 409 | RemovePred(DelDeps[i].first, DelDeps[i].second); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 410 | } |
Andrew Trick | baeaabb | 2012-11-06 03:13:46 +0000 | [diff] [blame] | 411 | SDep FromDep(SU, SDep::Data, Reg); |
| 412 | FromDep.setLatency(SU->Latency); |
| 413 | AddPred(CopyFromSU, FromDep); |
| 414 | SDep ToDep(CopyFromSU, SDep::Data, 0); |
| 415 | ToDep.setLatency(CopyFromSU->Latency); |
| 416 | AddPred(CopyToSU, ToDep); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 417 | |
| 418 | Copies.push_back(CopyFromSU); |
| 419 | Copies.push_back(CopyToSU); |
| 420 | |
Evan Cheng | b2c42c6 | 2009-01-12 03:19:55 +0000 | [diff] [blame] | 421 | ++NumPRCopies; |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | /// getPhysicalRegisterVT - Returns the ValueType of the physical register |
| 425 | /// definition of the specified node. |
| 426 | /// FIXME: Move to SelectionDAG? |
Craig Topper | 7f416c8 | 2014-11-16 21:17:18 +0000 | [diff] [blame] | 427 | static MVT getPhysicalRegisterVT(SDNode *N, unsigned Reg, |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 428 | const TargetInstrInfo *TII) { |
Tim Northover | e4c7be5 | 2014-10-23 22:31:48 +0000 | [diff] [blame] | 429 | unsigned NumRes; |
| 430 | if (N->getOpcode() == ISD::CopyFromReg) { |
| 431 | // CopyFromReg has: "chain, Val, glue" so operand 1 gives the type. |
| 432 | NumRes = 1; |
| 433 | } else { |
| 434 | const MCInstrDesc &MCID = TII->get(N->getMachineOpcode()); |
| 435 | assert(MCID.ImplicitDefs && "Physical reg def must be in implicit def list!"); |
| 436 | NumRes = MCID.getNumDefs(); |
Craig Topper | e5e035a3 | 2015-12-05 07:13:35 +0000 | [diff] [blame] | 437 | for (const MCPhysReg *ImpDef = MCID.getImplicitDefs(); *ImpDef; ++ImpDef) { |
Tim Northover | e4c7be5 | 2014-10-23 22:31:48 +0000 | [diff] [blame] | 438 | if (Reg == *ImpDef) |
| 439 | break; |
| 440 | ++NumRes; |
| 441 | } |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 442 | } |
Craig Topper | 7f416c8 | 2014-11-16 21:17:18 +0000 | [diff] [blame] | 443 | return N->getSimpleValueType(NumRes); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 444 | } |
| 445 | |
Dale Johannesen | 16f9644 | 2010-08-17 22:17:24 +0000 | [diff] [blame] | 446 | /// CheckForLiveRegDef - Return true and update live register vector if the |
| 447 | /// specified register def of the specified SUnit clobbers any "live" registers. |
| 448 | static bool CheckForLiveRegDef(SUnit *SU, unsigned Reg, |
| 449 | std::vector<SUnit*> &LiveRegDefs, |
| 450 | SmallSet<unsigned, 4> &RegAdded, |
Craig Topper | b94011f | 2013-07-14 04:42:23 +0000 | [diff] [blame] | 451 | SmallVectorImpl<unsigned> &LRegs, |
Dale Johannesen | 16f9644 | 2010-08-17 22:17:24 +0000 | [diff] [blame] | 452 | const TargetRegisterInfo *TRI) { |
| 453 | bool Added = false; |
Jakob Stoklund Olesen | 9b09cf0 | 2012-06-01 22:38:17 +0000 | [diff] [blame] | 454 | for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI) { |
| 455 | if (LiveRegDefs[*AI] && LiveRegDefs[*AI] != SU) { |
David Blaikie | 70573dc | 2014-11-19 07:49:26 +0000 | [diff] [blame] | 456 | if (RegAdded.insert(*AI).second) { |
Jakob Stoklund Olesen | 9b09cf0 | 2012-06-01 22:38:17 +0000 | [diff] [blame] | 457 | LRegs.push_back(*AI); |
Dale Johannesen | 16f9644 | 2010-08-17 22:17:24 +0000 | [diff] [blame] | 458 | Added = true; |
| 459 | } |
| 460 | } |
Jakob Stoklund Olesen | 9b09cf0 | 2012-06-01 22:38:17 +0000 | [diff] [blame] | 461 | } |
Dale Johannesen | 16f9644 | 2010-08-17 22:17:24 +0000 | [diff] [blame] | 462 | return Added; |
| 463 | } |
| 464 | |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 465 | /// DelayForLiveRegsBottomUp - Returns true if it is necessary to delay |
| 466 | /// scheduling of the given node to satisfy live physical register dependencies. |
| 467 | /// If the specific node is the last one that's available to schedule, do |
| 468 | /// whatever is necessary (i.e. backtracking or cloning) to make it possible. |
| 469 | bool ScheduleDAGFast::DelayForLiveRegsBottomUp(SUnit *SU, |
Craig Topper | b94011f | 2013-07-14 04:42:23 +0000 | [diff] [blame] | 470 | SmallVectorImpl<unsigned> &LRegs){ |
Dan Gohman | c07f686 | 2008-09-23 18:50:48 +0000 | [diff] [blame] | 471 | if (NumLiveRegs == 0) |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 472 | return false; |
| 473 | |
| 474 | SmallSet<unsigned, 4> RegAdded; |
| 475 | // If this node would clobber any "live" register, then it's not ready. |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 476 | for (SDep &Pred : SU->Preds) { |
| 477 | if (Pred.isAssignedRegDep()) { |
| 478 | CheckForLiveRegDef(Pred.getSUnit(), Pred.getReg(), LiveRegDefs, |
Dale Johannesen | 16f9644 | 2010-08-17 22:17:24 +0000 | [diff] [blame] | 479 | RegAdded, LRegs, TRI); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 480 | } |
| 481 | } |
| 482 | |
Chris Lattner | 11a3381 | 2010-12-23 17:24:32 +0000 | [diff] [blame] | 483 | for (SDNode *Node = SU->getNode(); Node; Node = Node->getGluedNode()) { |
Dale Johannesen | 16f9644 | 2010-08-17 22:17:24 +0000 | [diff] [blame] | 484 | if (Node->getOpcode() == ISD::INLINEASM) { |
| 485 | // Inline asm can clobber physical defs. |
| 486 | unsigned NumOps = Node->getNumOperands(); |
Chris Lattner | 3e5fbd7 | 2010-12-21 02:38:05 +0000 | [diff] [blame] | 487 | if (Node->getOperand(NumOps-1).getValueType() == MVT::Glue) |
Chris Lattner | 11a3381 | 2010-12-23 17:24:32 +0000 | [diff] [blame] | 488 | --NumOps; // Ignore the glue operand. |
Dale Johannesen | 16f9644 | 2010-08-17 22:17:24 +0000 | [diff] [blame] | 489 | |
| 490 | for (unsigned i = InlineAsm::Op_FirstOperand; i != NumOps;) { |
| 491 | unsigned Flags = |
| 492 | cast<ConstantSDNode>(Node->getOperand(i))->getZExtValue(); |
| 493 | unsigned NumVals = InlineAsm::getNumOperandRegisters(Flags); |
| 494 | |
| 495 | ++i; // Skip the ID value. |
| 496 | if (InlineAsm::isRegDefKind(Flags) || |
Jakob Stoklund Olesen | 537a302 | 2011-06-27 04:08:33 +0000 | [diff] [blame] | 497 | InlineAsm::isRegDefEarlyClobberKind(Flags) || |
| 498 | InlineAsm::isClobberKind(Flags)) { |
Dale Johannesen | 16f9644 | 2010-08-17 22:17:24 +0000 | [diff] [blame] | 499 | // Check for def of register or earlyclobber register. |
| 500 | for (; NumVals; --NumVals, ++i) { |
| 501 | unsigned Reg = cast<RegisterSDNode>(Node->getOperand(i))->getReg(); |
| 502 | if (TargetRegisterInfo::isPhysicalRegister(Reg)) |
| 503 | CheckForLiveRegDef(SU, Reg, LiveRegDefs, RegAdded, LRegs, TRI); |
| 504 | } |
| 505 | } else |
| 506 | i += NumVals; |
| 507 | } |
| 508 | continue; |
| 509 | } |
Dan Gohman | 072734e | 2008-11-13 23:24:17 +0000 | [diff] [blame] | 510 | if (!Node->isMachineOpcode()) |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 511 | continue; |
Evan Cheng | 6cc775f | 2011-06-28 19:10:37 +0000 | [diff] [blame] | 512 | const MCInstrDesc &MCID = TII->get(Node->getMachineOpcode()); |
| 513 | if (!MCID.ImplicitDefs) |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 514 | continue; |
Craig Topper | e5e035a3 | 2015-12-05 07:13:35 +0000 | [diff] [blame] | 515 | for (const MCPhysReg *Reg = MCID.getImplicitDefs(); *Reg; ++Reg) { |
Dale Johannesen | 16f9644 | 2010-08-17 22:17:24 +0000 | [diff] [blame] | 516 | CheckForLiveRegDef(SU, *Reg, LiveRegDefs, RegAdded, LRegs, TRI); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 517 | } |
| 518 | } |
| 519 | return !LRegs.empty(); |
| 520 | } |
| 521 | |
| 522 | |
| 523 | /// ListScheduleBottomUp - The main loop of list scheduling for bottom-up |
| 524 | /// schedulers. |
| 525 | void ScheduleDAGFast::ListScheduleBottomUp() { |
| 526 | unsigned CurCycle = 0; |
Dan Gohman | b954343 | 2009-02-10 23:27:53 +0000 | [diff] [blame] | 527 | |
| 528 | // Release any predecessors of the special Exit node. |
| 529 | ReleasePredecessors(&ExitSU, CurCycle); |
| 530 | |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 531 | // Add root to Available queue. |
| 532 | if (!SUnits.empty()) { |
Dan Gohman | 5a390b9 | 2008-11-13 21:21:28 +0000 | [diff] [blame] | 533 | SUnit *RootSU = &SUnits[DAG->getRoot().getNode()->getNodeId()]; |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 534 | assert(RootSU->Succs.empty() && "Graph root shouldn't have successors!"); |
| 535 | RootSU->isAvailable = true; |
| 536 | AvailableQueue.push(RootSU); |
| 537 | } |
| 538 | |
| 539 | // While Available queue is not empty, grab the node with the highest |
| 540 | // priority. If it is not ready put it back. Schedule the node. |
| 541 | SmallVector<SUnit*, 4> NotReady; |
| 542 | DenseMap<SUnit*, SmallVector<unsigned, 4> > LRegsMap; |
| 543 | Sequence.reserve(SUnits.size()); |
| 544 | while (!AvailableQueue.empty()) { |
| 545 | bool Delayed = false; |
| 546 | LRegsMap.clear(); |
| 547 | SUnit *CurSU = AvailableQueue.pop(); |
| 548 | while (CurSU) { |
Dan Gohman | 4f474b0 | 2008-11-17 19:52:36 +0000 | [diff] [blame] | 549 | SmallVector<unsigned, 4> LRegs; |
| 550 | if (!DelayForLiveRegsBottomUp(CurSU, LRegs)) |
| 551 | break; |
| 552 | Delayed = true; |
| 553 | LRegsMap.insert(std::make_pair(CurSU, LRegs)); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 554 | |
| 555 | CurSU->isPending = true; // This SU is not in AvailableQueue right now. |
| 556 | NotReady.push_back(CurSU); |
| 557 | CurSU = AvailableQueue.pop(); |
| 558 | } |
| 559 | |
| 560 | // All candidates are delayed due to live physical reg dependencies. |
| 561 | // Try code duplication or inserting cross class copies |
| 562 | // to resolve it. |
| 563 | if (Delayed && !CurSU) { |
| 564 | if (!CurSU) { |
| 565 | // Try duplicating the nodes that produces these |
| 566 | // "expensive to copy" values to break the dependency. In case even |
| 567 | // that doesn't work, insert cross class copies. |
| 568 | SUnit *TrySU = NotReady[0]; |
Craig Topper | b94011f | 2013-07-14 04:42:23 +0000 | [diff] [blame] | 569 | SmallVectorImpl<unsigned> &LRegs = LRegsMap[TrySU]; |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 570 | assert(LRegs.size() == 1 && "Can't handle this yet!"); |
| 571 | unsigned Reg = LRegs[0]; |
| 572 | SUnit *LRDef = LiveRegDefs[Reg]; |
Craig Topper | 7f416c8 | 2014-11-16 21:17:18 +0000 | [diff] [blame] | 573 | MVT VT = getPhysicalRegisterVT(LRDef->getNode(), Reg, TII); |
Evan Cheng | b2c42c6 | 2009-01-12 03:19:55 +0000 | [diff] [blame] | 574 | const TargetRegisterClass *RC = |
Rafael Espindola | 38a7d7c | 2010-06-29 14:02:34 +0000 | [diff] [blame] | 575 | TRI->getMinimalPhysRegClass(Reg, VT); |
Evan Cheng | b2c42c6 | 2009-01-12 03:19:55 +0000 | [diff] [blame] | 576 | const TargetRegisterClass *DestRC = TRI->getCrossCopyRegClass(RC); |
| 577 | |
Evan Cheng | b4c6a34 | 2011-03-10 00:16:32 +0000 | [diff] [blame] | 578 | // If cross copy register class is the same as RC, then it must be |
| 579 | // possible copy the value directly. Do not try duplicate the def. |
| 580 | // If cross copy register class is not the same as RC, then it's |
| 581 | // possible to copy the value but it require cross register class copies |
| 582 | // and it is expensive. |
| 583 | // If cross copy register class is null, then it's not possible to copy |
| 584 | // the value at all. |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 585 | SUnit *NewDef = nullptr; |
Evan Cheng | b4c6a34 | 2011-03-10 00:16:32 +0000 | [diff] [blame] | 586 | if (DestRC != RC) { |
Evan Cheng | b2c42c6 | 2009-01-12 03:19:55 +0000 | [diff] [blame] | 587 | NewDef = CopyAndMoveSuccessors(LRDef); |
Evan Cheng | b4c6a34 | 2011-03-10 00:16:32 +0000 | [diff] [blame] | 588 | if (!DestRC && !NewDef) |
| 589 | report_fatal_error("Can't handle live physical " |
| 590 | "register dependency!"); |
| 591 | } |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 592 | if (!NewDef) { |
Evan Cheng | b2c42c6 | 2009-01-12 03:19:55 +0000 | [diff] [blame] | 593 | // Issue copies, these can be expensive cross register class copies. |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 594 | SmallVector<SUnit*, 2> Copies; |
Evan Cheng | b2c42c6 | 2009-01-12 03:19:55 +0000 | [diff] [blame] | 595 | InsertCopiesAndMoveSuccs(LRDef, Reg, DestRC, RC, Copies); |
Nicola Zaghen | d34e60c | 2018-05-14 12:53:11 +0000 | [diff] [blame^] | 596 | LLVM_DEBUG(dbgs() << "Adding an edge from SU # " << TrySU->NodeNum |
| 597 | << " to SU #" << Copies.front()->NodeNum << "\n"); |
Andrew Trick | baeaabb | 2012-11-06 03:13:46 +0000 | [diff] [blame] | 598 | AddPred(TrySU, SDep(Copies.front(), SDep::Artificial)); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 599 | NewDef = Copies.back(); |
| 600 | } |
| 601 | |
Nicola Zaghen | d34e60c | 2018-05-14 12:53:11 +0000 | [diff] [blame^] | 602 | LLVM_DEBUG(dbgs() << "Adding an edge from SU # " << NewDef->NodeNum |
| 603 | << " to SU #" << TrySU->NodeNum << "\n"); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 604 | LiveRegDefs[Reg] = NewDef; |
Andrew Trick | baeaabb | 2012-11-06 03:13:46 +0000 | [diff] [blame] | 605 | AddPred(NewDef, SDep(TrySU, SDep::Artificial)); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 606 | TrySU->isAvailable = false; |
| 607 | CurSU = NewDef; |
| 608 | } |
| 609 | |
| 610 | if (!CurSU) { |
Torok Edwin | fbcc663 | 2009-07-14 16:55:14 +0000 | [diff] [blame] | 611 | llvm_unreachable("Unable to resolve live physical register dependencies!"); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 612 | } |
| 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 Gohman | c602dd4 | 2008-11-21 00:10:42 +0000 | [diff] [blame] | 624 | if (CurSU) |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 625 | ScheduleNodeBottomUp(CurSU, CurCycle); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 626 | ++CurCycle; |
| 627 | } |
| 628 | |
Dan Gohman | 6905f15 | 2009-09-28 16:09:41 +0000 | [diff] [blame] | 629 | // Reverse the order since it is bottom up. |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 630 | std::reverse(Sequence.begin(), Sequence.end()); |
Dan Gohman | 6905f15 | 2009-09-28 16:09:41 +0000 | [diff] [blame] | 631 | |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 632 | #ifndef NDEBUG |
Andrew Trick | 46a5866 | 2012-03-07 05:21:36 +0000 | [diff] [blame] | 633 | VerifyScheduledSequence(/*isBottomUp=*/true); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 634 | #endif |
| 635 | } |
| 636 | |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 637 | |
Benjamin Kramer | a74129a | 2012-10-20 12:53:26 +0000 | [diff] [blame] | 638 | namespace { |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 639 | //===----------------------------------------------------------------------===// |
| 640 | // ScheduleDAGLinearize - No scheduling scheduler, it simply linearize the |
| 641 | // DAG in topological order. |
| 642 | // IMPORTANT: this may not work for targets with phyreg dependency. |
| 643 | // |
| 644 | class ScheduleDAGLinearize : public ScheduleDAGSDNodes { |
| 645 | public: |
| 646 | ScheduleDAGLinearize(MachineFunction &mf) : ScheduleDAGSDNodes(mf) {} |
| 647 | |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 648 | void Schedule() override; |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 649 | |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 650 | MachineBasicBlock * |
| 651 | EmitSchedule(MachineBasicBlock::iterator &InsertPos) override; |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 652 | |
| 653 | private: |
| 654 | std::vector<SDNode*> Sequence; |
| 655 | DenseMap<SDNode*, SDNode*> GluedMap; // Cache glue to its user |
| 656 | |
| 657 | void ScheduleNode(SDNode *N); |
| 658 | }; |
Benjamin Kramer | a74129a | 2012-10-20 12:53:26 +0000 | [diff] [blame] | 659 | } // end anonymous namespace |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 660 | |
| 661 | void ScheduleDAGLinearize::ScheduleNode(SDNode *N) { |
| 662 | if (N->getNodeId() != 0) |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 663 | llvm_unreachable(nullptr); |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 664 | |
| 665 | if (!N->isMachineOpcode() && |
| 666 | (N->getOpcode() == ISD::EntryToken || isPassiveNode(N))) |
| 667 | // These nodes do not need to be translated into MIs. |
| 668 | return; |
| 669 | |
Nicola Zaghen | d34e60c | 2018-05-14 12:53:11 +0000 | [diff] [blame^] | 670 | LLVM_DEBUG(dbgs() << "\n*** Scheduling: "); |
| 671 | LLVM_DEBUG(N->dump(DAG)); |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 672 | Sequence.push_back(N); |
| 673 | |
| 674 | unsigned NumOps = N->getNumOperands(); |
| 675 | if (unsigned NumLeft = NumOps) { |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 676 | SDNode *GluedOpN = nullptr; |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 677 | do { |
| 678 | const SDValue &Op = N->getOperand(NumLeft-1); |
| 679 | SDNode *OpN = Op.getNode(); |
| 680 | |
| 681 | if (NumLeft == NumOps && Op.getValueType() == MVT::Glue) { |
| 682 | // Schedule glue operand right above N. |
| 683 | GluedOpN = OpN; |
| 684 | assert(OpN->getNodeId() != 0 && "Glue operand not ready?"); |
| 685 | OpN->setNodeId(0); |
| 686 | ScheduleNode(OpN); |
| 687 | continue; |
| 688 | } |
| 689 | |
| 690 | if (OpN == GluedOpN) |
| 691 | // Glue operand is already scheduled. |
| 692 | continue; |
| 693 | |
| 694 | DenseMap<SDNode*, SDNode*>::iterator DI = GluedMap.find(OpN); |
| 695 | if (DI != GluedMap.end() && DI->second != N) |
| 696 | // Users of glues are counted against the glued users. |
| 697 | OpN = DI->second; |
| 698 | |
| 699 | unsigned Degree = OpN->getNodeId(); |
| 700 | assert(Degree > 0 && "Predecessor over-released!"); |
| 701 | OpN->setNodeId(--Degree); |
| 702 | if (Degree == 0) |
| 703 | ScheduleNode(OpN); |
| 704 | } while (--NumLeft); |
| 705 | } |
| 706 | } |
| 707 | |
| 708 | /// findGluedUser - Find the representative use of a glue value by walking |
| 709 | /// the use chain. |
| 710 | static SDNode *findGluedUser(SDNode *N) { |
| 711 | while (SDNode *Glued = N->getGluedUser()) |
| 712 | N = Glued; |
| 713 | return N; |
| 714 | } |
| 715 | |
| 716 | void ScheduleDAGLinearize::Schedule() { |
Nicola Zaghen | d34e60c | 2018-05-14 12:53:11 +0000 | [diff] [blame^] | 717 | LLVM_DEBUG(dbgs() << "********** DAG Linearization **********\n"); |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 718 | |
| 719 | SmallVector<SDNode*, 8> Glues; |
| 720 | unsigned DAGSize = 0; |
Pete Cooper | 65c6940 | 2015-07-14 22:10:54 +0000 | [diff] [blame] | 721 | for (SDNode &Node : DAG->allnodes()) { |
| 722 | SDNode *N = &Node; |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 723 | |
| 724 | // Use node id to record degree. |
| 725 | unsigned Degree = N->use_size(); |
| 726 | N->setNodeId(Degree); |
| 727 | unsigned NumVals = N->getNumValues(); |
| 728 | if (NumVals && N->getValueType(NumVals-1) == MVT::Glue && |
| 729 | N->hasAnyUseOfValue(NumVals-1)) { |
| 730 | SDNode *User = findGluedUser(N); |
| 731 | if (User) { |
| 732 | Glues.push_back(N); |
| 733 | GluedMap.insert(std::make_pair(N, User)); |
| 734 | } |
| 735 | } |
| 736 | |
| 737 | if (N->isMachineOpcode() || |
| 738 | (N->getOpcode() != ISD::EntryToken && !isPassiveNode(N))) |
| 739 | ++DAGSize; |
| 740 | } |
| 741 | |
| 742 | for (unsigned i = 0, e = Glues.size(); i != e; ++i) { |
| 743 | SDNode *Glue = Glues[i]; |
| 744 | SDNode *GUser = GluedMap[Glue]; |
| 745 | unsigned Degree = Glue->getNodeId(); |
| 746 | unsigned UDegree = GUser->getNodeId(); |
| 747 | |
| 748 | // Glue user must be scheduled together with the glue operand. So other |
| 749 | // users of the glue operand must be treated as its users. |
| 750 | SDNode *ImmGUser = Glue->getGluedUser(); |
Krzysztof Parzyszek | 41b6e14 | 2017-05-04 13:35:17 +0000 | [diff] [blame] | 751 | for (const SDNode *U : Glue->uses()) |
| 752 | if (U == ImmGUser) |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 753 | --Degree; |
| 754 | GUser->setNodeId(UDegree + Degree); |
| 755 | Glue->setNodeId(1); |
| 756 | } |
| 757 | |
| 758 | Sequence.reserve(DAGSize); |
| 759 | ScheduleNode(DAG->getRoot().getNode()); |
| 760 | } |
| 761 | |
| 762 | MachineBasicBlock* |
| 763 | ScheduleDAGLinearize::EmitSchedule(MachineBasicBlock::iterator &InsertPos) { |
| 764 | InstrEmitter Emitter(BB, InsertPos); |
| 765 | DenseMap<SDValue, unsigned> VRBaseMap; |
| 766 | |
Nicola Zaghen | d34e60c | 2018-05-14 12:53:11 +0000 | [diff] [blame^] | 767 | LLVM_DEBUG({ dbgs() << "\n*** Final schedule ***\n"; }); |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 768 | |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 769 | unsigned NumNodes = Sequence.size(); |
Adrian Prantl | dfe15f3 | 2018-03-02 22:59:51 +0000 | [diff] [blame] | 770 | MachineBasicBlock *BB = Emitter.getBlock(); |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 771 | for (unsigned i = 0; i != NumNodes; ++i) { |
| 772 | SDNode *N = Sequence[NumNodes-i-1]; |
Nicola Zaghen | d34e60c | 2018-05-14 12:53:11 +0000 | [diff] [blame^] | 773 | LLVM_DEBUG(N->dump(DAG)); |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 774 | Emitter.EmitNode(N, false, false, VRBaseMap); |
Adrian Prantl | dfe15f3 | 2018-03-02 22:59:51 +0000 | [diff] [blame] | 775 | |
| 776 | // Emit any debug values associated with the node. |
| 777 | if (N->getHasDebugValue()) { |
| 778 | MachineBasicBlock::iterator InsertPos = Emitter.getInsertPos(); |
| 779 | for (auto DV : DAG->GetDbgValues(N)) { |
| 780 | if (DV->isInvalidated()) |
| 781 | continue; |
| 782 | if (auto *DbgMI = Emitter.EmitDbgValue(DV, VRBaseMap)) |
| 783 | BB->insert(InsertPos, DbgMI); |
| 784 | DV->setIsInvalidated(); |
| 785 | } |
| 786 | } |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 787 | } |
| 788 | |
Nicola Zaghen | d34e60c | 2018-05-14 12:53:11 +0000 | [diff] [blame^] | 789 | LLVM_DEBUG(dbgs() << '\n'); |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 790 | |
| 791 | InsertPos = Emitter.getInsertPos(); |
| 792 | return Emitter.getBlock(); |
| 793 | } |
| 794 | |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 795 | //===----------------------------------------------------------------------===// |
| 796 | // Public Constructor Functions |
| 797 | //===----------------------------------------------------------------------===// |
| 798 | |
Dan Gohman | dfaf646 | 2009-02-11 04:27:20 +0000 | [diff] [blame] | 799 | llvm::ScheduleDAGSDNodes * |
Bill Wendling | 026e5d7 | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 800 | llvm::createFastDAGScheduler(SelectionDAGISel *IS, CodeGenOpt::Level) { |
Dan Gohman | 619ef48 | 2009-01-15 19:20:50 +0000 | [diff] [blame] | 801 | return new ScheduleDAGFast(*IS->MF); |
Dan Gohman | 95be7d7 | 2008-09-18 16:26:26 +0000 | [diff] [blame] | 802 | } |
Evan Cheng | 839fb65 | 2012-10-17 19:39:36 +0000 | [diff] [blame] | 803 | |
| 804 | llvm::ScheduleDAGSDNodes * |
| 805 | llvm::createDAGLinearizer(SelectionDAGISel *IS, CodeGenOpt::Level) { |
| 806 | return new ScheduleDAGLinearize(*IS->MF); |
| 807 | } |