Lines Matching defs:SU

103 /// Check if scheduling of this SU is possible
108 bool VLIWResourceModel::isResourceAvailable(SUnit *SU, bool IsTop) {
109 if (!SU || !SU->getInstr())
114 switch (SU->getInstr()->getOpcode()) {
116 if (!ResourcesModel->canReserveResources(*SU->getInstr()))
134 if (hasDependence(U, SU))
138 if (hasDependence(SU, U))
145 bool VLIWResourceModel::reserveResources(SUnit *SU, bool IsTop) {
148 if (!SU) {
153 // If this SU does not fit in the packet or the packet is now full
155 if (!isResourceAvailable(SU, IsTop) ||
162 switch (SU->getInstr()->getOpcode()) {
164 ResourcesModel->reserveResources(*SU->getInstr());
179 Packet.push_back(SU);
184 LLVM_DEBUG(dbgs() << "\t[" << i << "] SU(");
222 for (const SUnit &SU : SUnits)
223 if (SU.getHeight() > maxH)
224 maxH = SU.getHeight();
229 for (const SUnit &SU : SUnits)
230 if (SU.getDepth() > maxD)
231 maxD = SU.getDepth();
244 SUnit *SU = SchedImpl->pickNode(IsTopNode);
245 if (!SU)
251 scheduleMI(SU, IsTopNode);
254 SchedImpl->schedNode(SU, IsTopNode);
256 updateQueues(SU, IsTopNode);
307 void ConvergingVLIWScheduler::releaseTopNode(SUnit *SU) {
308 for (const SDep &PI : SU->Preds) {
314 if (SU->TopReadyCycle < PredReadyCycle + MinLatency)
315 SU->TopReadyCycle = PredReadyCycle + MinLatency;
318 if (!SU->isScheduled)
319 Top.releaseNode(SU, SU->TopReadyCycle);
322 void ConvergingVLIWScheduler::releaseBottomNode(SUnit *SU) {
323 assert(SU->getInstr() && "Scheduled SUnit must have instr");
325 for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end(); I != E;
332 if (SU->BotReadyCycle < SuccReadyCycle + MinLatency)
333 SU->BotReadyCycle = SuccReadyCycle + MinLatency;
336 if (!SU->isScheduled)
337 Bot.releaseNode(SU, SU->BotReadyCycle);
345 /// Does this SU have a hazard within the current instruction group.
357 /// TODO: Also check whether the SU must start a new group.
358 bool ConvergingVLIWScheduler::VLIWSchedBoundary::checkHazard(SUnit *SU) {
360 return HazardRec->getHazardType(SU) != ScheduleHazardRecognizer::NoHazard;
362 unsigned uops = SchedModel->getNumMicroOps(SU->getInstr());
370 SUnit *SU, unsigned ReadyCycle) {
376 if (ReadyCycle > CurrCycle || checkHazard(SU))
378 Pending.push(SU);
380 Available.push(SU);
411 void ConvergingVLIWScheduler::VLIWSchedBoundary::bumpNode(SUnit *SU) {
416 if (!isTop() && SU->isCall) {
421 HazardRec->EmitInstruction(SU);
425 startNewCycle = ResourceModel->reserveResources(SU, isTop());
428 // TODO: Check if this SU must end a dispatch group.
429 IssueCount += SchedModel->getNumMicroOps(SU->getInstr());
448 SUnit *SU = *(Pending.begin() + i);
449 unsigned ReadyCycle = isTop() ? SU->TopReadyCycle : SU->BotReadyCycle;
457 if (checkHazard(SU))
460 Available.push(SU);
468 /// Remove SU from the ready set for this boundary.
469 void ConvergingVLIWScheduler::VLIWSchedBoundary::removeReady(SUnit *SU) {
470 if (Available.isInQueue(SU))
471 Available.remove(Available.find(SU));
473 assert(Pending.isInQueue(SU) && "bad ready count");
474 Pending.remove(Pending.find(SU));
508 const ReadyQueue &Q, SUnit *SU,
517 DAG->dumpNode(*SU);
533 dbgstr << "SU(" << std::setw(3) << (*I)->NodeNum << ")";
544 /// of SU, return true (we may have duplicates)
545 static inline bool isSingleUnscheduledPred(SUnit *SU, SUnit *SU2) {
546 if (SU->NumPredsLeft == 0)
549 for (auto &Pred : SU->Preds) {
559 /// of SU, return true (we may have duplicates)
560 static inline bool isSingleUnscheduledSucc(SUnit *SU, SUnit *SU2) {
561 if (SU->NumSuccsLeft == 0)
564 for (auto &Succ : SU->Succs) {
577 int ConvergingVLIWScheduler::pressureChange(const SUnit *SU, bool isBotUp) {
578 PressureDiff &PD = DAG->getPressureDiff(SU);
593 int ConvergingVLIWScheduler::SchedulingCost(ReadyQueue &Q, SUnit *SU,
601 if (!SU || SU->isScheduled)
607 if (SU->isScheduleHigh) {
615 if (Top.isLatencyBound(SU)) {
617 ResCount += (SU->getHeight() * ScaleTwo);
622 dbgstr << "h" << std::setw(3) << SU->getHeight() << "|";
628 if (Top.ResourceModel->isResourceAvailable(SU, true)) {
635 if (Bot.isLatencyBound(SU)) {
637 ResCount += (SU->getDepth() * ScaleTwo);
642 dbgstr << "d" << std::setw(3) << SU->getDepth() << "|";
648 if (Bot.ResourceModel->isResourceAvailable(SU, false)) {
662 if (Top.isLatencyBound(SU))
663 for (const SDep &SI : SU->Succs)
664 if (isSingleUnscheduledPred(SI.getSUnit(), SU))
668 if (Bot.isLatencyBound(SU))
669 for (const SDep &PI : SU->Preds)
670 if (isSingleUnscheduledSucc(PI.getSUnit(), SU))
693 if (IsAvailableAmt && pressureChange(SU, Q.getID() != TopQID) > 0 &&
706 if (Q.getID() == TopQID && getWeakLeft(SU, true) == 0) {
707 for (const SDep &PI : SU->Preds) {
715 } else if (Q.getID() == BotQID && getWeakLeft(SU, false) == 0) {
716 for (const SDep &SI : SU->Succs) {
733 for (const auto &PI : SU->Preds) {
741 for (const auto &SI : SU->Succs) {
788 if (!Candidate.SU) {
790 Candidate.SU = *I;
800 if ((Q.getID() == TopQID && (*I)->NodeNum < Candidate.SU->NodeNum) ||
801 (Q.getID() == BotQID && (*I)->NodeNum > Candidate.SU->NodeNum)) {
803 Candidate.SU = *I;
814 Candidate.SU = *I;
823 unsigned CandWeak = getWeakLeft(Candidate.SU, (Q.getID() == TopQID));
827 Candidate.SU = *I;
839 CandSize = Candidate.SU->Succs.size();
842 CandSize = Candidate.SU->Preds.size();
846 Candidate.SU = *I;
861 if ((Q.getID() == TopQID && (*I)->NodeNum < Candidate.SU->NodeNum) ||
862 (Q.getID() == BotQID && (*I)->NodeNum > Candidate.SU->NodeNum)) {
864 Candidate.SU = *I;
884 if (SUnit *SU = Bot.pickOnlyChoice()) {
887 return SU;
889 if (SUnit *SU = Top.pickOnlyChoice()) {
892 return SU;
910 return BotCand.SU;
921 return TopCand.SU;
928 return BotCand.SU;
933 return TopCand.SU;
938 return TopCand.SU;
943 return BotCand.SU;
953 SUnit *SU;
955 SU = Top.pickOnlyChoice();
956 if (!SU) {
962 SU = TopCand.SU;
966 SU = Bot.pickOnlyChoice();
967 if (!SU) {
973 SU = BotCand.SU;
977 SU = pickNodeBidrectional(IsTopNode);
979 if (SU->isTopReady())
980 Top.removeReady(SU);
981 if (SU->isBottomReady())
982 Bot.removeReady(SU);
988 DAG->dumpNode(*SU));
989 return SU;
996 void ConvergingVLIWScheduler::schedNode(SUnit *SU, bool IsTopNode) {
998 Top.bumpNode(SU);
999 SU->TopReadyCycle = Top.CurrCycle;
1001 Bot.bumpNode(SU);
1002 SU->BotReadyCycle = Bot.CurrCycle;