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);
310 void ConvergingVLIWScheduler::releaseTopNode(SUnit *SU) {
311 for (const SDep &PI : SU->Preds) {
317 if (SU->TopReadyCycle < PredReadyCycle + MinLatency)
318 SU->TopReadyCycle = PredReadyCycle + MinLatency;
321 if (!SU->isScheduled)
322 Top.releaseNode(SU, SU->TopReadyCycle);
325 void ConvergingVLIWScheduler::releaseBottomNode(SUnit *SU) {
326 assert(SU->getInstr() && "Scheduled SUnit must have instr");
328 for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end(); I != E;
335 if (SU->BotReadyCycle < SuccReadyCycle + MinLatency)
336 SU->BotReadyCycle = SuccReadyCycle + MinLatency;
339 if (!SU->isScheduled)
340 Bot.releaseNode(SU, SU->BotReadyCycle);
348 /// Does this SU have a hazard within the current instruction group.
360 /// TODO: Also check whether the SU must start a new group.
361 bool ConvergingVLIWScheduler::VLIWSchedBoundary::checkHazard(SUnit *SU) {
363 return HazardRec->getHazardType(SU) != ScheduleHazardRecognizer::NoHazard;
365 unsigned uops = SchedModel->getNumMicroOps(SU->getInstr());
373 SUnit *SU, unsigned ReadyCycle) {
379 if (ReadyCycle > CurrCycle || checkHazard(SU))
381 Pending.push(SU);
383 Available.push(SU);
414 void ConvergingVLIWScheduler::VLIWSchedBoundary::bumpNode(SUnit *SU) {
419 if (!isTop() && SU->isCall) {
424 HazardRec->EmitInstruction(SU);
428 startNewCycle = ResourceModel->reserveResources(SU, isTop());
431 // TODO: Check if this SU must end a dispatch group.
432 IssueCount += SchedModel->getNumMicroOps(SU->getInstr());
451 SUnit *SU = *(Pending.begin() + i);
452 unsigned ReadyCycle = isTop() ? SU->TopReadyCycle : SU->BotReadyCycle;
460 if (checkHazard(SU))
463 Available.push(SU);
471 /// Remove SU from the ready set for this boundary.
472 void ConvergingVLIWScheduler::VLIWSchedBoundary::removeReady(SUnit *SU) {
473 if (Available.isInQueue(SU))
474 Available.remove(Available.find(SU));
476 assert(Pending.isInQueue(SU) && "bad ready count");
477 Pending.remove(Pending.find(SU));
511 const ReadyQueue &Q, SUnit *SU,
520 DAG->dumpNode(*SU);
536 dbgstr << "SU(" << std::setw(3) << (*I)->NodeNum << ")";
547 /// of SU, return true (we may have duplicates)
548 static inline bool isSingleUnscheduledPred(SUnit *SU, SUnit *SU2) {
549 if (SU->NumPredsLeft == 0)
552 for (auto &Pred : SU->Preds) {
562 /// of SU, return true (we may have duplicates)
563 static inline bool isSingleUnscheduledSucc(SUnit *SU, SUnit *SU2) {
564 if (SU->NumSuccsLeft == 0)
567 for (auto &Succ : SU->Succs) {
580 int ConvergingVLIWScheduler::pressureChange(const SUnit *SU, bool isBotUp) {
581 PressureDiff &PD = DAG->getPressureDiff(SU);
596 int ConvergingVLIWScheduler::SchedulingCost(ReadyQueue &Q, SUnit *SU,
604 if (!SU || SU->isScheduled)
610 if (SU->isScheduleHigh) {
618 if (Top.isLatencyBound(SU)) {
620 ResCount += (SU->getHeight() * ScaleTwo);
625 dbgstr << "h" << std::setw(3) << SU->getHeight() << "|";
631 if (Top.ResourceModel->isResourceAvailable(SU, true)) {
638 if (Bot.isLatencyBound(SU)) {
640 ResCount += (SU->getDepth() * ScaleTwo);
645 dbgstr << "d" << std::setw(3) << SU->getDepth() << "|";
651 if (Bot.ResourceModel->isResourceAvailable(SU, false)) {
665 if (Top.isLatencyBound(SU))
666 for (const SDep &SI : SU->Succs)
667 if (isSingleUnscheduledPred(SI.getSUnit(), SU))
671 if (Bot.isLatencyBound(SU))
672 for (const SDep &PI : SU->Preds)
673 if (isSingleUnscheduledSucc(PI.getSUnit(), SU))
696 if (IsAvailableAmt && pressureChange(SU, Q.getID() != TopQID) > 0 &&
709 if (Q.getID() == TopQID && getWeakLeft(SU, true) == 0) {
710 for (const SDep &PI : SU->Preds) {
718 } else if (Q.getID() == BotQID && getWeakLeft(SU, false) == 0) {
719 for (const SDep &SI : SU->Succs) {
736 for (const auto &PI : SU->Preds) {
744 for (const auto &SI : SU->Succs) {
791 if (!Candidate.SU) {
793 Candidate.SU = *I;
803 if ((Q.getID() == TopQID && (*I)->NodeNum < Candidate.SU->NodeNum) ||
804 (Q.getID() == BotQID && (*I)->NodeNum > Candidate.SU->NodeNum)) {
806 Candidate.SU = *I;
817 Candidate.SU = *I;
826 unsigned CandWeak = getWeakLeft(Candidate.SU, (Q.getID() == TopQID));
830 Candidate.SU = *I;
842 CandSize = Candidate.SU->Succs.size();
845 CandSize = Candidate.SU->Preds.size();
849 Candidate.SU = *I;
864 if ((Q.getID() == TopQID && (*I)->NodeNum < Candidate.SU->NodeNum) ||
865 (Q.getID() == BotQID && (*I)->NodeNum > Candidate.SU->NodeNum)) {
867 Candidate.SU = *I;
887 if (SUnit *SU = Bot.pickOnlyChoice()) {
890 return SU;
892 if (SUnit *SU = Top.pickOnlyChoice()) {
895 return SU;
913 return BotCand.SU;
924 return TopCand.SU;
931 return BotCand.SU;
936 return TopCand.SU;
941 return TopCand.SU;
946 return BotCand.SU;
956 SUnit *SU;
958 SU = Top.pickOnlyChoice();
959 if (!SU) {
965 SU = TopCand.SU;
969 SU = Bot.pickOnlyChoice();
970 if (!SU) {
976 SU = BotCand.SU;
980 SU = pickNodeBidrectional(IsTopNode);
982 if (SU->isTopReady())
983 Top.removeReady(SU);
984 if (SU->isBottomReady())
985 Bot.removeReady(SU);
991 DAG->dumpNode(*SU));
992 return SU;
999 void ConvergingVLIWScheduler::schedNode(SUnit *SU, bool IsTopNode) {
1001 Top.bumpNode(SU);
1002 SU->TopReadyCycle = Top.CurrCycle;
1004 Bot.bumpNode(SU);
1005 SU->BotReadyCycle = Bot.CurrCycle;