comparison lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp @ 134:3a76565eade5 LLVM5.0.1

update 5.0.1
author mir3636
date Sat, 17 Feb 2018 09:57:20 +0900
parents 803732b1fca8
children c2174574ed3a
comparison
equal deleted inserted replaced
133:c60214abe0e8 134:3a76565eade5
30 #include "llvm/CodeGen/ScheduleDAG.h" 30 #include "llvm/CodeGen/ScheduleDAG.h"
31 #include "llvm/CodeGen/ScheduleHazardRecognizer.h" 31 #include "llvm/CodeGen/ScheduleHazardRecognizer.h"
32 #include "llvm/CodeGen/SchedulerRegistry.h" 32 #include "llvm/CodeGen/SchedulerRegistry.h"
33 #include "llvm/CodeGen/SelectionDAGISel.h" 33 #include "llvm/CodeGen/SelectionDAGISel.h"
34 #include "llvm/CodeGen/SelectionDAGNodes.h" 34 #include "llvm/CodeGen/SelectionDAGNodes.h"
35 #include "llvm/CodeGen/TargetInstrInfo.h"
36 #include "llvm/CodeGen/TargetLowering.h"
37 #include "llvm/CodeGen/TargetOpcodes.h"
38 #include "llvm/CodeGen/TargetRegisterInfo.h"
39 #include "llvm/CodeGen/TargetSubtargetInfo.h"
35 #include "llvm/IR/InlineAsm.h" 40 #include "llvm/IR/InlineAsm.h"
36 #include "llvm/MC/MCInstrDesc.h" 41 #include "llvm/MC/MCInstrDesc.h"
37 #include "llvm/MC/MCRegisterInfo.h" 42 #include "llvm/MC/MCRegisterInfo.h"
38 #include "llvm/Support/Casting.h" 43 #include "llvm/Support/Casting.h"
39 #include "llvm/Support/CodeGen.h" 44 #include "llvm/Support/CodeGen.h"
40 #include "llvm/Support/CommandLine.h" 45 #include "llvm/Support/CommandLine.h"
41 #include "llvm/Support/Compiler.h" 46 #include "llvm/Support/Compiler.h"
42 #include "llvm/Support/Debug.h" 47 #include "llvm/Support/Debug.h"
43 #include "llvm/Support/ErrorHandling.h" 48 #include "llvm/Support/ErrorHandling.h"
44 #include "llvm/Support/raw_ostream.h" 49 #include "llvm/Support/raw_ostream.h"
45 #include "llvm/Target/TargetInstrInfo.h"
46 #include "llvm/Target/TargetLowering.h"
47 #include "llvm/Target/TargetOpcodes.h"
48 #include "llvm/Target/TargetRegisterInfo.h"
49 #include "llvm/Target/TargetSubtargetInfo.h"
50 #include <algorithm> 50 #include <algorithm>
51 #include <cassert> 51 #include <cassert>
52 #include <cstdint> 52 #include <cstdint>
53 #include <cstdlib> 53 #include <cstdlib>
54 #include <iterator> 54 #include <iterator>
344 } 344 }
345 } 345 }
346 346
347 /// Schedule - Schedule the DAG using list scheduling. 347 /// Schedule - Schedule the DAG using list scheduling.
348 void ScheduleDAGRRList::Schedule() { 348 void ScheduleDAGRRList::Schedule() {
349 DEBUG(dbgs() 349 DEBUG(dbgs() << "********** List Scheduling " << printMBBReference(*BB)
350 << "********** List Scheduling BB#" << BB->getNumber() 350 << " '" << BB->getName() << "' **********\n");
351 << " '" << BB->getName() << "' **********\n");
352 351
353 CurCycle = 0; 352 CurCycle = 0;
354 IssueCount = 0; 353 IssueCount = 0;
355 MinAvailableCycle = 354 MinAvailableCycle =
356 DisableSchedCycles ? 0 : std::numeric_limits<unsigned>::max(); 355 DisableSchedCycles ? 0 : std::numeric_limits<unsigned>::max();
1116 SUnit *ScheduleDAGRRList::CopyAndMoveSuccessors(SUnit *SU) { 1115 SUnit *ScheduleDAGRRList::CopyAndMoveSuccessors(SUnit *SU) {
1117 SDNode *N = SU->getNode(); 1116 SDNode *N = SU->getNode();
1118 if (!N) 1117 if (!N)
1119 return nullptr; 1118 return nullptr;
1120 1119
1121 if (SU->getNode()->getGluedNode()) 1120 DEBUG(dbgs() << "Considering duplicating the SU\n");
1121 DEBUG(SU->dump(this));
1122
1123 if (N->getGluedNode() &&
1124 !TII->canCopyGluedNodeDuringSchedule(N)) {
1125 DEBUG(dbgs()
1126 << "Giving up because it has incoming glue and the target does not "
1127 "want to copy it\n");
1122 return nullptr; 1128 return nullptr;
1129 }
1123 1130
1124 SUnit *NewSU; 1131 SUnit *NewSU;
1125 bool TryUnfold = false; 1132 bool TryUnfold = false;
1126 for (unsigned i = 0, e = N->getNumValues(); i != e; ++i) { 1133 for (unsigned i = 0, e = N->getNumValues(); i != e; ++i) {
1127 MVT VT = N->getSimpleValueType(i); 1134 MVT VT = N->getSimpleValueType(i);
1128 if (VT == MVT::Glue) 1135 if (VT == MVT::Glue) {
1136 DEBUG(dbgs() << "Giving up because it has outgoing glue\n");
1129 return nullptr; 1137 return nullptr;
1130 else if (VT == MVT::Other) 1138 } else if (VT == MVT::Other)
1131 TryUnfold = true; 1139 TryUnfold = true;
1132 } 1140 }
1133 for (const SDValue &Op : N->op_values()) { 1141 for (const SDValue &Op : N->op_values()) {
1134 MVT VT = Op.getNode()->getSimpleValueType(Op.getResNo()); 1142 MVT VT = Op.getNode()->getSimpleValueType(Op.getResNo());
1135 if (VT == MVT::Glue) 1143 if (VT == MVT::Glue && !TII->canCopyGluedNodeDuringSchedule(N)) {
1144 DEBUG(dbgs() << "Giving up because it one of the operands is glue and "
1145 "the target does not want to copy it\n");
1136 return nullptr; 1146 return nullptr;
1147 }
1137 } 1148 }
1138 1149
1139 // If possible unfold instruction. 1150 // If possible unfold instruction.
1140 if (TryUnfold) { 1151 if (TryUnfold) {
1141 SUnit *UnfoldSU = TryUnfoldSU(SU); 1152 SUnit *UnfoldSU = TryUnfoldSU(SU);
1428 auto FindAvailableNode = [&]() { 1439 auto FindAvailableNode = [&]() {
1429 while (CurSU) { 1440 while (CurSU) {
1430 SmallVector<unsigned, 4> LRegs; 1441 SmallVector<unsigned, 4> LRegs;
1431 if (!DelayForLiveRegsBottomUp(CurSU, LRegs)) 1442 if (!DelayForLiveRegsBottomUp(CurSU, LRegs))
1432 break; 1443 break;
1433 DEBUG(dbgs() << " Interfering reg " << 1444 DEBUG(dbgs() << " Interfering reg ";
1434 (LRegs[0] == TRI->getNumRegs() ? "CallResource" 1445 if (LRegs[0] == TRI->getNumRegs())
1435 : TRI->getName(LRegs[0])) 1446 dbgs() << "CallResource";
1436 << " SU #" << CurSU->NodeNum << '\n'); 1447 else
1448 dbgs() << printReg(LRegs[0], TRI);
1449 dbgs() << " SU #" << CurSU->NodeNum << '\n');
1437 std::pair<LRegsMapT::iterator, bool> LRegsPair = 1450 std::pair<LRegsMapT::iterator, bool> LRegsPair =
1438 LRegsMap.insert(std::make_pair(CurSU, LRegs)); 1451 LRegsMap.insert(std::make_pair(CurSU, LRegs));
1439 if (LRegsPair.second) { 1452 if (LRegsPair.second) {
1440 CurSU->isPending = true; // This SU is not in AvailableQueue right now. 1453 CurSU->isPending = true; // This SU is not in AvailableQueue right now.
1441 Interferences.push_back(CurSU); 1454 Interferences.push_back(CurSU);