//===---- LatencyPriorityQueue.cpp - A latency-oriented priority queue ----===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements the LatencyPriorityQueue class, which is a // SchedulingPriorityQueue that schedules using latency information to // reduce the length of the critical path through the basic block. // //===----------------------------------------------------------------------===// #include "llvm/CodeGen/LatencyPriorityQueue.h" #include "llvm/Config/llvm-config.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" usingnamespacellvm; #define DEBUG_TYPE … bool latency_sort::operator()(const SUnit *LHS, const SUnit *RHS) const { … } /// getSingleUnscheduledPred - If there is exactly one unscheduled predecessor /// of SU, return it, otherwise return null. SUnit *LatencyPriorityQueue::getSingleUnscheduledPred(SUnit *SU) { … } void LatencyPriorityQueue::push(SUnit *SU) { … } // scheduledNode - As nodes are scheduled, we look to see if there are any // successor nodes that have a single unscheduled predecessor. If so, that // single predecessor has a higher priority, since scheduling it will make // the node available. void LatencyPriorityQueue::scheduledNode(SUnit *SU) { … } /// AdjustPriorityOfUnscheduledPreds - One of the predecessors of SU was just /// scheduled. If SU is not itself available, then there is at least one /// predecessor node that has not been scheduled yet. If SU has exactly ONE /// unscheduled predecessor, we want to increase its priority: it getting /// scheduled will make this node available, so it is better than some other /// node of the same priority that will not make a node available. void LatencyPriorityQueue::AdjustPriorityOfUnscheduledPreds(SUnit *SU) { … } SUnit *LatencyPriorityQueue::pop() { … } void LatencyPriorityQueue::remove(SUnit *SU) { … } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void LatencyPriorityQueue::dump(ScheduleDAG *DAG) const { dbgs() << "Latency Priority Queue\n"; dbgs() << " Number of Queue Entries: " << Queue.size() << "\n"; for (const SUnit *SU : Queue) { dbgs() << " "; DAG->dumpNode(*SU); } } #endif