Lines Matching defs:su
71 ResourcePriorityQueue::numberRCValPredInSU(SUnit *SU, unsigned RCId) {
73 for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
108 unsigned ResourcePriorityQueue::numberRCValSuccInSU(SUnit *SU,
111 for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
146 static unsigned numberCtrlDepsInSU(SUnit *SU) {
148 for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
156 static unsigned numberCtrlPredInSU(SUnit *SU) {
158 for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
174 SUnit *SU = &(*SUnits)[i];
175 initNumRegDefsLeft(SU);
176 SU->NodeQueueId = 0;
215 /// of SU, return it, otherwise return null.
216 SUnit *ResourcePriorityQueue::getSingleUnscheduledPred(SUnit *SU) {
218 for (SUnit::const_pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
232 void ResourcePriorityQueue::push(SUnit *SU) {
236 for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
238 if (getSingleUnscheduledPred(I->getSUnit()) == SU)
241 NumNodesSolelyBlocking[SU->NodeNum] = NumNodesBlocking;
242 Queue.push_back(SU);
245 /// Check if scheduling of this SU is possible
247 bool ResourcePriorityQueue::isResourceAvailable(SUnit *SU) {
248 if (!SU || !SU->getNode())
253 if (SU->getNode()->getGluedNode())
258 if (SU->getNode()->isMachineOpcode())
259 switch (SU->getNode()->getMachineOpcode()) {
262 SU->getNode()->getMachineOpcode())))
282 if (I->getSUnit() == SU)
290 void ResourcePriorityQueue::reserveResources(SUnit *SU) {
291 // If this SU does not fit in the packet
293 if (!isResourceAvailable(SU) || SU->getNode()->getGluedNode()) {
298 if (SU->getNode() && SU->getNode()->isMachineOpcode()) {
299 switch (SU->getNode()->getMachineOpcode()) {
302 SU->getNode()->getMachineOpcode()));
311 Packet.push_back(SU);
327 signed ResourcePriorityQueue::rawRegPressureDelta(SUnit *SU, unsigned RCId) {
330 if (!SU || !SU->getNode() || !SU->getNode()->isMachineOpcode())
334 for (unsigned i = 0, e = SU->getNode()->getNumValues(); i != e; ++i) {
335 MVT VT = SU->getNode()->getSimpleValueType(i);
339 RegBalance += numberRCValSuccInSU(SU, RCId);
342 for (unsigned i = 0, e = SU->getNode()->getNumOperands(); i != e; ++i) {
343 const SDValue &Op = SU->getNode()->getOperand(i);
350 RegBalance -= numberRCValPredInSU(SU, RCId);
355 /// Estimates change in reg pressure from this SU.
361 signed ResourcePriorityQueue::regPressureDelta(SUnit *SU, bool RawPressure) {
364 if (!SU || !SU->getNode() || !SU->getNode()->isMachineOpcode())
371 RegBalance += rawRegPressureDelta(SU, RC->getID());
379 rawRegPressureDelta(SU, RC->getID()) > 0) &&
381 rawRegPressureDelta(SU, RC->getID()) >= RegLimit[RC->getID()]))
382 RegBalance += rawRegPressureDelta(SU, RC->getID());
401 /// Returns single number reflecting benefit of scheduling SU
403 signed ResourcePriorityQueue::SUSchedulingCost(SUnit *SU) {
408 if (SU->isScheduled)
412 if (SU->isScheduleHigh)
420 ResCount += (SU->getHeight() * ScaleTwo);
423 if (isResourceAvailable(SU))
427 // this SU.
428 ResCount -= (regPressureDelta(SU,true) * ScaleOne);
434 ResCount += (SU->getHeight() * ScaleTwo);
435 // Now see how many instructions is blocked by this SU.
436 ResCount += (NumNodesSolelyBlocking[SU->NodeNum] * ScaleTwo);
439 if (isResourceAvailable(SU))
442 ResCount -= (regPressureDelta(SU) * ScaleTwo);
448 for (SDNode *N = SU->getNode(); N; N = N->getGluedNode()) {
473 void ResourcePriorityQueue::scheduledNode(SUnit *SU) {
476 if (!SU) {
482 const SDNode *ScegN = SU->getNode();
493 RegPressure[RC->getID()] += numberRCValSuccInSU(SU, RC->getID());
505 (numberRCValPredInSU(SU, RC->getID())))
506 RegPressure[RC->getID()] -= numberRCValPredInSU(SU, RC->getID());
511 for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end();
519 // Reserve resources for this SU.
520 reserveResources(SU);
527 for (SUnit::const_succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
535 if (ParallelLiveRanges >= SU->NumPreds)
536 ParallelLiveRanges -= SU->NumPreds;
542 ParallelLiveRanges += SU->NumRegDefsLeft;
545 HorizontalVerticalBalance += (SU->Succs.size() - numberCtrlDepsInSU(SU));
546 HorizontalVerticalBalance -= (SU->Preds.size() - numberCtrlPredInSU(SU));
549 void ResourcePriorityQueue::initNumRegDefsLeft(SUnit *SU) {
551 for (SDNode *N = SU->getNode(); N; N = N->getGluedNode())
572 SU->NumRegDefsLeft = NodeNumDefs;
575 /// adjustPriorityOfUnscheduledPreds - One of the predecessors of SU was just
576 /// scheduled. If SU is not itself available, then there is at least one
577 /// predecessor node that has not been scheduled yet. If SU has exactly ONE
581 void ResourcePriorityQueue::adjustPriorityOfUnscheduledPreds(SUnit *SU) {
582 if (SU->isAvailable) return; // All preds scheduled.
584 SUnit *OnlyAvailablePred = getSingleUnscheduledPred(SU);
634 void ResourcePriorityQueue::remove(SUnit *SU) {
636 std::vector<SUnit *>::iterator I = std::find(Queue.begin(), Queue.end(), SU);
650 SUnit *su = q.pop();
651 dbgs() << "Height " << su->getHeight() << ": ";
652 su->dump(DAG);