diff options
Diffstat (limited to 'llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp')
-rw-r--r-- | llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp | 144 |
1 files changed, 73 insertions, 71 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp b/llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp index 4376a30fdd9..74c550ce822 100644 --- a/llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp +++ b/llvm/lib/Target/Hexagon/HexagonMachineScheduler.cpp @@ -172,11 +172,11 @@ bool VLIWResourceModel::reserveResources(SUnit *SU, bool IsTop) { Packet.push_back(SU); #ifndef NDEBUG - DEBUG(dbgs() << "Packet[" << TotalPackets << "]:\n"); + LLVM_DEBUG(dbgs() << "Packet[" << TotalPackets << "]:\n"); for (unsigned i = 0, e = Packet.size(); i != e; ++i) { - DEBUG(dbgs() << "\t[" << i << "] SU("); - DEBUG(dbgs() << Packet[i]->NodeNum << ")\t"); - DEBUG(Packet[i]->getInstr()->dump()); + LLVM_DEBUG(dbgs() << "\t[" << i << "] SU("); + LLVM_DEBUG(dbgs() << Packet[i]->NodeNum << ")\t"); + LLVM_DEBUG(Packet[i]->getInstr()->dump()); } #endif @@ -187,10 +187,10 @@ bool VLIWResourceModel::reserveResources(SUnit *SU, bool IsTop) { /// after setting up the current scheduling region. [RegionBegin, RegionEnd) /// only includes instructions that have DAG nodes, not scheduling boundaries. void VLIWMachineScheduler::schedule() { - DEBUG(dbgs() << "********** MI Converging Scheduling VLIW " - << printMBBReference(*BB) << " " << BB->getName() << " in_func " - << BB->getParent()->getName() << " at loop depth " - << MLI->getLoopDepth(BB) << " \n"); + LLVM_DEBUG(dbgs() << "********** MI Converging Scheduling VLIW " + << printMBBReference(*BB) << " " << BB->getName() + << " in_func " << BB->getParent()->getName() + << " at loop depth " << MLI->getLoopDepth(BB) << " \n"); buildDAGWithRegPressure(); @@ -205,24 +205,25 @@ void VLIWMachineScheduler::schedule() { // Initialize the strategy before modifying the DAG. SchedImpl->initialize(this); - DEBUG(unsigned maxH = 0; - for (unsigned su = 0, e = SUnits.size(); su != e; ++su) - if (SUnits[su].getHeight() > maxH) - maxH = SUnits[su].getHeight(); - dbgs() << "Max Height " << maxH << "\n";); - DEBUG(unsigned maxD = 0; - for (unsigned su = 0, e = SUnits.size(); su != e; ++su) - if (SUnits[su].getDepth() > maxD) - maxD = SUnits[su].getDepth(); - dbgs() << "Max Depth " << maxD << "\n";); - DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su) - SUnits[su].dumpAll(this)); + LLVM_DEBUG(unsigned maxH = 0; + for (unsigned su = 0, e = SUnits.size(); su != e; + ++su) if (SUnits[su].getHeight() > maxH) maxH = + SUnits[su].getHeight(); + dbgs() << "Max Height " << maxH << "\n";); + LLVM_DEBUG(unsigned maxD = 0; + for (unsigned su = 0, e = SUnits.size(); su != e; + ++su) if (SUnits[su].getDepth() > maxD) maxD = + SUnits[su].getDepth(); + dbgs() << "Max Depth " << maxD << "\n";); + LLVM_DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su) SUnits[su] + .dumpAll(this)); initQueues(TopRoots, BotRoots); bool IsTopNode = false; while (true) { - DEBUG(dbgs() << "** VLIWMachineScheduler::schedule picking next node\n"); + LLVM_DEBUG( + dbgs() << "** VLIWMachineScheduler::schedule picking next node\n"); SUnit *SU = SchedImpl->pickNode(IsTopNode); if (!SU) break; @@ -240,7 +241,7 @@ void VLIWMachineScheduler::schedule() { placeDebugValues(); - DEBUG({ + LLVM_DEBUG({ dbgs() << "*** Final schedule for " << printMBBReference(*begin()->getParent()) << " ***\n"; dumpSchedule(); @@ -379,8 +380,8 @@ void ConvergingVLIWScheduler::VLIWSchedBoundary::bumpCycle() { } CheckPending = true; - DEBUG(dbgs() << "*** Next cycle " << Available.getName() << " cycle " - << CurrCycle << '\n'); + LLVM_DEBUG(dbgs() << "*** Next cycle " << Available.getName() << " cycle " + << CurrCycle << '\n'); } /// Move the boundary of scheduled code by one SUnit. @@ -404,12 +405,12 @@ void ConvergingVLIWScheduler::VLIWSchedBoundary::bumpNode(SUnit *SU) { // TODO: Check if this SU must end a dispatch group. IssueCount += SchedModel->getNumMicroOps(SU->getInstr()); if (startNewCycle) { - DEBUG(dbgs() << "*** Max instrs at cycle " << CurrCycle << '\n'); + LLVM_DEBUG(dbgs() << "*** Max instrs at cycle " << CurrCycle << '\n'); bumpCycle(); } else - DEBUG(dbgs() << "*** IssueCount " << IssueCount - << " at cycle " << CurrCycle << '\n'); + LLVM_DEBUG(dbgs() << "*** IssueCount " << IssueCount << " at cycle " + << CurrCycle << '\n'); } /// Release pending ready nodes in to the available queue. This makes them @@ -582,22 +583,23 @@ int ConvergingVLIWScheduler::SchedulingCost(ReadyQueue &Q, SUnit *SU, if (!SU || SU->isScheduled) return ResCount; - DEBUG(if (verbose) dbgs() << ((Q.getID() == TopQID) ? "(top|" : "(bot|")); + LLVM_DEBUG(if (verbose) dbgs() + << ((Q.getID() == TopQID) ? "(top|" : "(bot|")); // Forced priority is high. if (SU->isScheduleHigh) { ResCount += PriorityOne; - DEBUG(dbgs() << "H|"); + LLVM_DEBUG(dbgs() << "H|"); } unsigned IsAvailableAmt = 0; // Critical path first. if (Q.getID() == TopQID) { if (Top.isLatencyBound(SU)) { - DEBUG(if (verbose) dbgs() << "LB|"); + LLVM_DEBUG(if (verbose) dbgs() << "LB|"); ResCount += (SU->getHeight() * ScaleTwo); } - DEBUG(if (verbose) { + LLVM_DEBUG(if (verbose) { std::stringstream dbgstr; dbgstr << "h" << std::setw(3) << SU->getHeight() << "|"; dbgs() << dbgstr.str(); @@ -608,16 +610,16 @@ int ConvergingVLIWScheduler::SchedulingCost(ReadyQueue &Q, SUnit *SU, if (Top.ResourceModel->isResourceAvailable(SU, true)) { IsAvailableAmt = (PriorityTwo + PriorityThree); ResCount += IsAvailableAmt; - DEBUG(if (verbose) dbgs() << "A|"); + LLVM_DEBUG(if (verbose) dbgs() << "A|"); } else - DEBUG(if (verbose) dbgs() << " |"); + LLVM_DEBUG(if (verbose) dbgs() << " |"); } else { if (Bot.isLatencyBound(SU)) { - DEBUG(if (verbose) dbgs() << "LB|"); + LLVM_DEBUG(if (verbose) dbgs() << "LB|"); ResCount += (SU->getDepth() * ScaleTwo); } - DEBUG(if (verbose) { + LLVM_DEBUG(if (verbose) { std::stringstream dbgstr; dbgstr << "d" << std::setw(3) << SU->getDepth() << "|"; dbgs() << dbgstr.str(); @@ -628,9 +630,9 @@ int ConvergingVLIWScheduler::SchedulingCost(ReadyQueue &Q, SUnit *SU, if (Bot.ResourceModel->isResourceAvailable(SU, false)) { IsAvailableAmt = (PriorityTwo + PriorityThree); ResCount += IsAvailableAmt; - DEBUG(if (verbose) dbgs() << "A|"); + LLVM_DEBUG(if (verbose) dbgs() << "A|"); } else - DEBUG(if (verbose) dbgs() << " |"); + LLVM_DEBUG(if (verbose) dbgs() << " |"); } unsigned NumNodesBlocking = 0; @@ -652,7 +654,7 @@ int ConvergingVLIWScheduler::SchedulingCost(ReadyQueue &Q, SUnit *SU, } ResCount += (NumNodesBlocking * ScaleTwo); - DEBUG(if (verbose) { + LLVM_DEBUG(if (verbose) { std::stringstream dbgstr; dbgstr << "blk " << std::setw(2) << NumNodesBlocking << ")|"; dbgs() << dbgstr.str(); @@ -674,10 +676,10 @@ int ConvergingVLIWScheduler::SchedulingCost(ReadyQueue &Q, SUnit *SU, (Delta.Excess.getUnitInc() || Delta.CriticalMax.getUnitInc() || Delta.CurrentMax.getUnitInc())) ResCount -= IsAvailableAmt; - DEBUG(if (verbose) { - dbgs() << "RP " << Delta.Excess.getUnitInc() << "/" - << Delta.CriticalMax.getUnitInc() <<"/" - << Delta.CurrentMax.getUnitInc() << ")|"; + LLVM_DEBUG(if (verbose) { + dbgs() << "RP " << Delta.Excess.getUnitInc() << "/" + << Delta.CriticalMax.getUnitInc() << "/" + << Delta.CurrentMax.getUnitInc() << ")|"; }); } @@ -689,11 +691,11 @@ int ConvergingVLIWScheduler::SchedulingCost(ReadyQueue &Q, SUnit *SU, if (Q.getID() == TopQID && Top.ResourceModel->isResourceAvailable(SU, true)) { ResCount += PriorityTwo; - DEBUG(if (verbose) dbgs() << "C|"); + LLVM_DEBUG(if (verbose) dbgs() << "C|"); } else if (Q.getID() == BotQID && Bot.ResourceModel->isResourceAvailable(SU, false)) { ResCount += PriorityTwo; - DEBUG(if (verbose) dbgs() << "C|"); + LLVM_DEBUG(if (verbose) dbgs() << "C|"); } } @@ -705,7 +707,7 @@ int ConvergingVLIWScheduler::SchedulingCost(ReadyQueue &Q, SUnit *SU, PI.getLatency() == 0 && Top.ResourceModel->isInPacket(PI.getSUnit())) { ResCount += PriorityThree; - DEBUG(if (verbose) dbgs() << "Z|"); + LLVM_DEBUG(if (verbose) dbgs() << "Z|"); } } } else if (Q.getID() == BotQID && getWeakLeft(SU, false) == 0) { @@ -714,7 +716,7 @@ int ConvergingVLIWScheduler::SchedulingCost(ReadyQueue &Q, SUnit *SU, SI.getLatency() == 0 && Bot.ResourceModel->isInPacket(SI.getSUnit())) { ResCount += PriorityThree; - DEBUG(if (verbose) dbgs() << "Z|"); + LLVM_DEBUG(if (verbose) dbgs() << "Z|"); } } } @@ -730,7 +732,7 @@ int ConvergingVLIWScheduler::SchedulingCost(ReadyQueue &Q, SUnit *SU, if (PI.getLatency() > 0 && Top.ResourceModel->isInPacket(PI.getSUnit())) { ResCount -= PriorityOne; - DEBUG(if (verbose) dbgs() << "D|"); + LLVM_DEBUG(if (verbose) dbgs() << "D|"); } } } else { @@ -738,13 +740,13 @@ int ConvergingVLIWScheduler::SchedulingCost(ReadyQueue &Q, SUnit *SU, if (SI.getLatency() > 0 && Bot.ResourceModel->isInPacket(SI.getSUnit())) { ResCount -= PriorityOne; - DEBUG(if (verbose) dbgs() << "D|"); + LLVM_DEBUG(if (verbose) dbgs() << "D|"); } } } } - DEBUG(if (verbose) { + LLVM_DEBUG(if (verbose) { std::stringstream dbgstr; dbgstr << "Total " << std::setw(4) << ResCount << ")"; dbgs() << dbgstr.str(); @@ -762,9 +764,9 @@ ConvergingVLIWScheduler::CandResult ConvergingVLIWScheduler:: pickNodeFromQueue(VLIWSchedBoundary &Zone, const RegPressureTracker &RPTracker, SchedCandidate &Candidate) { ReadyQueue &Q = Zone.Available; - DEBUG(if (SchedDebugVerboseLevel > 1) - readyQueueVerboseDump(RPTracker, Candidate, Q); - else Q.dump();); + LLVM_DEBUG(if (SchedDebugVerboseLevel > 1) + readyQueueVerboseDump(RPTracker, Candidate, Q); + else Q.dump();); // getMaxPressureDelta temporarily modifies the tracker. RegPressureTracker &TempTracker = const_cast<RegPressureTracker&>(RPTracker); @@ -781,7 +783,7 @@ pickNodeFromQueue(VLIWSchedBoundary &Zone, const RegPressureTracker &RPTracker, // Initialize the candidate if needed. if (!Candidate.SU) { - DEBUG(traceCandidate("DCAND", Q, *I, CurrentCost)); + LLVM_DEBUG(traceCandidate("DCAND", Q, *I, CurrentCost)); Candidate.SU = *I; Candidate.RPDelta = RPDelta; Candidate.SCost = CurrentCost; @@ -794,7 +796,7 @@ pickNodeFromQueue(VLIWSchedBoundary &Zone, const RegPressureTracker &RPTracker, if (CurrentCost < 0 && Candidate.SCost < 0) { if ((Q.getID() == TopQID && (*I)->NodeNum < Candidate.SU->NodeNum) || (Q.getID() == BotQID && (*I)->NodeNum > Candidate.SU->NodeNum)) { - DEBUG(traceCandidate("NCAND", Q, *I, CurrentCost)); + LLVM_DEBUG(traceCandidate("NCAND", Q, *I, CurrentCost)); Candidate.SU = *I; Candidate.RPDelta = RPDelta; Candidate.SCost = CurrentCost; @@ -805,7 +807,7 @@ pickNodeFromQueue(VLIWSchedBoundary &Zone, const RegPressureTracker &RPTracker, // Best cost. if (CurrentCost > Candidate.SCost) { - DEBUG(traceCandidate("CCAND", Q, *I, CurrentCost)); + LLVM_DEBUG(traceCandidate("CCAND", Q, *I, CurrentCost)); Candidate.SU = *I; Candidate.RPDelta = RPDelta; Candidate.SCost = CurrentCost; @@ -818,7 +820,7 @@ pickNodeFromQueue(VLIWSchedBoundary &Zone, const RegPressureTracker &RPTracker, unsigned CandWeak = getWeakLeft(Candidate.SU, (Q.getID() == TopQID)); if (CurrWeak != CandWeak) { if (CurrWeak < CandWeak) { - DEBUG(traceCandidate("WCAND", Q, *I, CurrentCost)); + LLVM_DEBUG(traceCandidate("WCAND", Q, *I, CurrentCost)); Candidate.SU = *I; Candidate.RPDelta = RPDelta; Candidate.SCost = CurrentCost; @@ -837,7 +839,7 @@ pickNodeFromQueue(VLIWSchedBoundary &Zone, const RegPressureTracker &RPTracker, CandSize = Candidate.SU->Preds.size(); } if (CurrSize > CandSize) { - DEBUG(traceCandidate("SPCAND", Q, *I, CurrentCost)); + LLVM_DEBUG(traceCandidate("SPCAND", Q, *I, CurrentCost)); Candidate.SU = *I; Candidate.RPDelta = RPDelta; Candidate.SCost = CurrentCost; @@ -855,7 +857,7 @@ pickNodeFromQueue(VLIWSchedBoundary &Zone, const RegPressureTracker &RPTracker, if (UseNewerCandidate && CurrentCost == Candidate.SCost) { if ((Q.getID() == TopQID && (*I)->NodeNum < Candidate.SU->NodeNum) || (Q.getID() == BotQID && (*I)->NodeNum > Candidate.SU->NodeNum)) { - DEBUG(traceCandidate("TCAND", Q, *I, CurrentCost)); + LLVM_DEBUG(traceCandidate("TCAND", Q, *I, CurrentCost)); Candidate.SU = *I; Candidate.RPDelta = RPDelta; Candidate.SCost = CurrentCost; @@ -877,12 +879,12 @@ SUnit *ConvergingVLIWScheduler::pickNodeBidrectional(bool &IsTopNode) { // Schedule as far as possible in the direction of no choice. This is most // efficient, but also provides the best heuristics for CriticalPSets. if (SUnit *SU = Bot.pickOnlyChoice()) { - DEBUG(dbgs() << "Picked only Bottom\n"); + LLVM_DEBUG(dbgs() << "Picked only Bottom\n"); IsTopNode = false; return SU; } if (SUnit *SU = Top.pickOnlyChoice()) { - DEBUG(dbgs() << "Picked only Top\n"); + LLVM_DEBUG(dbgs() << "Picked only Top\n"); IsTopNode = true; return SU; } @@ -900,7 +902,7 @@ SUnit *ConvergingVLIWScheduler::pickNodeBidrectional(bool &IsTopNode) { // increase pressure for one of the excess PSets, then schedule in that // direction first to provide more freedom in the other direction. if (BotResult == SingleExcess || BotResult == SingleCritical) { - DEBUG(dbgs() << "Prefered Bottom Node\n"); + LLVM_DEBUG(dbgs() << "Prefered Bottom Node\n"); IsTopNode = false; return BotCand.SU; } @@ -911,29 +913,29 @@ SUnit *ConvergingVLIWScheduler::pickNodeBidrectional(bool &IsTopNode) { assert(TopResult != NoCand && "failed to find the first candidate"); if (TopResult == SingleExcess || TopResult == SingleCritical) { - DEBUG(dbgs() << "Prefered Top Node\n"); + LLVM_DEBUG(dbgs() << "Prefered Top Node\n"); IsTopNode = true; return TopCand.SU; } // If either Q has a single candidate that minimizes pressure above the // original region's pressure pick it. if (BotResult == SingleMax) { - DEBUG(dbgs() << "Prefered Bottom Node SingleMax\n"); + LLVM_DEBUG(dbgs() << "Prefered Bottom Node SingleMax\n"); IsTopNode = false; return BotCand.SU; } if (TopResult == SingleMax) { - DEBUG(dbgs() << "Prefered Top Node SingleMax\n"); + LLVM_DEBUG(dbgs() << "Prefered Top Node SingleMax\n"); IsTopNode = true; return TopCand.SU; } if (TopCand.SCost > BotCand.SCost) { - DEBUG(dbgs() << "Prefered Top Node Cost\n"); + LLVM_DEBUG(dbgs() << "Prefered Top Node Cost\n"); IsTopNode = true; return TopCand.SU; } // Otherwise prefer the bottom candidate in node order. - DEBUG(dbgs() << "Prefered Bottom in Node order\n"); + LLVM_DEBUG(dbgs() << "Prefered Bottom in Node order\n"); IsTopNode = false; return BotCand.SU; } @@ -976,11 +978,11 @@ SUnit *ConvergingVLIWScheduler::pickNode(bool &IsTopNode) { if (SU->isBottomReady()) Bot.removeReady(SU); - DEBUG(dbgs() << "*** " << (IsTopNode ? "Top" : "Bottom") - << " Scheduling instruction in cycle " - << (IsTopNode ? Top.CurrCycle : Bot.CurrCycle) << " (" << - reportPackets() << ")\n"; - SU->dump(DAG)); + LLVM_DEBUG(dbgs() << "*** " << (IsTopNode ? "Top" : "Bottom") + << " Scheduling instruction in cycle " + << (IsTopNode ? Top.CurrCycle : Bot.CurrCycle) << " (" + << reportPackets() << ")\n"; + SU->dump(DAG)); return SU; } |