17 #include "llvm/Config/llvm-config.h" 22 #define DEBUG_TYPE "scheduler" 39 if (LHSLatency < RHSLatency)
return true;
40 if (LHSLatency > RHSLatency)
return false;
46 if (LHSBlocked < RHSBlocked)
return true;
47 if (LHSBlocked > RHSBlocked)
return false;
51 return RHSNum < LHSNum;
57 SUnit *LatencyPriorityQueue::getSingleUnscheduledPred(
SUnit *SU) {
58 SUnit *OnlyAvailablePred =
nullptr;
61 SUnit &Pred = *
I->getSUnit();
65 if (OnlyAvailablePred && OnlyAvailablePred != &Pred)
67 OnlyAvailablePred = &Pred;
71 return OnlyAvailablePred;
77 unsigned NumNodesBlocking = 0;
80 if (getSingleUnscheduledPred(
I->getSUnit()) == SU)
83 NumNodesSolelyBlocking[SU->
NodeNum] = NumNodesBlocking;
96 AdjustPriorityOfUnscheduledPreds(
I->getSUnit());
106 void LatencyPriorityQueue::AdjustPriorityOfUnscheduledPreds(
SUnit *SU) {
109 SUnit *OnlyAvailablePred = getSingleUnscheduledPred(SU);
110 if (!OnlyAvailablePred || !OnlyAvailablePred->
isAvailable)
return;
114 remove(OnlyAvailablePred);
118 push(OnlyAvailablePred);
122 if (
empty())
return nullptr;
123 std::vector<SUnit *>::iterator Best = Queue.begin();
124 for (std::vector<SUnit *>::iterator
I = std::next(Queue.begin()),
125 E = Queue.end();
I !=
E; ++
I)
126 if (Picker(*Best, *
I))
129 if (Best != std::prev(Queue.end()))
136 assert(!Queue.empty() &&
"Queue is empty!");
137 std::vector<SUnit *>::iterator
I =
find(Queue, SU);
138 assert(I != Queue.end() &&
"Queue doesn't contain the SU being removed!");
139 if (I != std::prev(Queue.end()))
144 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 146 dbgs() <<
"Latency Priority Queue\n";
147 dbgs() <<
" Number of Queue Entries: " << Queue.size() <<
"\n";
148 for (
const SUnit *SU : Queue) {
This class represents lattice values for constants.
virtual void dumpNode(const SUnit &SU) const =0
SmallVector< SDep, 4 > Preds
All sunit predecessors.
bool isScheduled
True once scheduled.
SmallVectorImpl< SDep >::const_iterator const_pred_iterator
void scheduledNode(SUnit *SU) override
As each node is scheduled, this method is invoked.
void remove(SUnit *SU) override
bool operator()(const SUnit *LHS, const SUnit *RHS) const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
unsigned getLatency(unsigned NodeNum) const
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
void push(SUnit *U) override
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
bool isScheduleHigh
True if preferable to schedule high.
LatencyPriorityQueue * PQ
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
LLVM_DUMP_METHOD void dump(ScheduleDAG *DAG) const override
SmallVectorImpl< SDep >::const_iterator const_succ_iterator
bool isAvailable
True once available.
unsigned getNumSolelyBlockNodes(unsigned NodeNum) const
unsigned NodeNum
Entry # of node in the node vector.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SmallVector< SDep, 4 > Succs
All sunit successors.
Scheduling unit. This is a node in the scheduling DAG.