Commit b2c2fe72 authored by Qiu Chaofan's avatar Qiu Chaofan
Browse files

[NFC] Move InPQueue into arguments of releaseNode

This patch moves `InPQueue` into function arguments instead of template
arguments of `releaseNode`, which is a cleaner approach.

Differential Revision: https://reviews.llvm.org/D72125
parent 7a77ad14
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -757,8 +757,16 @@ public:

  unsigned getOtherResourceCount(unsigned &OtherCritIdx);

  template <bool InPQueue>
  void releaseNode(SUnit *SU, unsigned ReadyCycle, unsigned Idx = 0);
  /// Release SU to make it ready. If it's not in hazard, remove it from
  /// pending queue (if already in) and push into available queue.
  /// Otherwise, push the SU into pending queue.
  ///
  /// @param SU The unit to be released.
  /// @param ReadyCycle Until which cycle the unit is ready.
  /// @param InPQueue Whether SU is already in pending queue.
  /// @param Idx Position offset in pending queue (if in it).
  void releaseNode(SUnit *SU, unsigned ReadyCycle, bool InPQueue,
                   unsigned Idx = 0);

  void bumpCycle(unsigned NextCycle);

@@ -956,7 +964,7 @@ public:
    if (SU->isScheduled)
      return;

    Top.releaseNode<false>(SU, SU->TopReadyCycle);
    Top.releaseNode(SU, SU->TopReadyCycle, false);
    TopCand.SU = nullptr;
  }

@@ -964,7 +972,7 @@ public:
    if (SU->isScheduled)
      return;

    Bot.releaseNode<false>(SU, SU->BotReadyCycle);
    Bot.releaseNode(SU, SU->BotReadyCycle, false);
    BotCand.SU = nullptr;
  }

@@ -1044,7 +1052,7 @@ public:
  void releaseTopNode(SUnit *SU) override {
    if (SU->isScheduled)
      return;
    Top.releaseNode<false>(SU, SU->TopReadyCycle);
    Top.releaseNode(SU, SU->TopReadyCycle, false);
  }

  // Only called for roots.
+3 −8
Original line number Diff line number Diff line
@@ -2088,13 +2088,8 @@ getOtherResourceCount(unsigned &OtherCritIdx) {
  return OtherCritCount;
}

template void SchedBoundary::releaseNode<true>(SUnit *SU, unsigned ReadyCycle,
                                               unsigned Idx);
template void SchedBoundary::releaseNode<false>(SUnit *SU, unsigned ReadyCycle,
                                                unsigned Idx);

template <bool InPQueue>
void SchedBoundary::releaseNode(SUnit *SU, unsigned ReadyCycle, unsigned Idx) {
void SchedBoundary::releaseNode(SUnit *SU, unsigned ReadyCycle, bool InPQueue,
                                unsigned Idx) {
  assert(SU->getInstr() && "Scheduled SUnit must have instr");

#ifndef NDEBUG
@@ -2373,7 +2368,7 @@ void SchedBoundary::releasePending() {
    if (Available.size() >= ReadyListLimit)
      break;

    releaseNode<true>(SU, ReadyCycle, I);
    releaseNode(SU, ReadyCycle, true, I);
    if (E != Pending.size()) {
      --I;
      --E;