16 #include "llvm/Config/llvm-config.h" 21 #define DEBUG_TYPE "scheduler" 38 if (LHSLatency < RHSLatency)
return true;
39 if (LHSLatency > RHSLatency)
return false;
45 if (LHSBlocked < RHSBlocked)
return true;
46 if (LHSBlocked > RHSBlocked)
return false;
50 return RHSNum < LHSNum;
56 SUnit *LatencyPriorityQueue::getSingleUnscheduledPred(
SUnit *SU) {
57 SUnit *OnlyAvailablePred =
nullptr;
60 SUnit &Pred = *
I->getSUnit();
64 if (OnlyAvailablePred && OnlyAvailablePred != &Pred)
66 OnlyAvailablePred = &Pred;
70 return OnlyAvailablePred;
76 unsigned NumNodesBlocking = 0;
79 if (getSingleUnscheduledPred(
I->getSUnit()) == SU)
82 NumNodesSolelyBlocking[SU->
NodeNum] = NumNodesBlocking;
95 AdjustPriorityOfUnscheduledPreds(
I->getSUnit());
105 void LatencyPriorityQueue::AdjustPriorityOfUnscheduledPreds(
SUnit *SU) {
108 SUnit *OnlyAvailablePred = getSingleUnscheduledPred(SU);
109 if (!OnlyAvailablePred || !OnlyAvailablePred->
isAvailable)
return;
113 remove(OnlyAvailablePred);
117 push(OnlyAvailablePred);
121 if (
empty())
return nullptr;
122 std::vector<SUnit *>::iterator Best = Queue.begin();
123 for (std::vector<SUnit *>::iterator
I = std::next(Queue.begin()),
124 E = Queue.end();
I !=
E; ++
I)
125 if (Picker(*Best, *
I))
128 if (Best != std::prev(Queue.end()))
135 assert(!Queue.empty() &&
"Queue is empty!");
136 std::vector<SUnit *>::iterator
I =
find(Queue, SU);
137 assert(I != Queue.end() &&
"Queue doesn't contain the SU being removed!");
138 if (I != std::prev(Queue.end()))
143 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 145 dbgs() <<
"Latency Priority Queue\n";
146 dbgs() <<
" Number of Queue Entries: " << Queue.size() <<
"\n";
147 for (
const SUnit *SU : Queue) {
This class represents lattice values for constants.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
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.