//===- ScheduleDAGVLIW.cpp - SelectionDAG list scheduler for VLIW -*- C++ -*-=// // // 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 implements a top-down list scheduler, using standard algorithms. // The basic approach uses a priority queue of available nodes to schedule. // One at a time, nodes are taken from the priority queue (thus in priority // order), checked for legality to schedule, and emitted if legal. // // Nodes may not be legal to schedule either due to structural hazards (e.g. // pipeline or resource constraints) or because an input to the instruction has // not completed execution. // //===----------------------------------------------------------------------===// #include "ScheduleDAGSDNodes.h" #include "llvm/ADT/Statistic.h" #include "llvm/CodeGen/ResourcePriorityQueue.h" #include "llvm/CodeGen/ScheduleHazardRecognizer.h" #include "llvm/CodeGen/SchedulerRegistry.h" #include "llvm/CodeGen/SelectionDAGISel.h" #include "llvm/CodeGen/TargetInstrInfo.h" #include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" usingnamespacellvm; #define DEBUG_TYPE … STATISTIC(NumNoops , "Number of noops inserted"); STATISTIC(NumStalls, "Number of pipeline stalls"); static RegisterScheduler VLIWScheduler("vliw-td", "VLIW scheduler", createVLIWDAGScheduler); namespace { //===----------------------------------------------------------------------===// /// ScheduleDAGVLIW - The actual DFA list scheduler implementation. This /// supports / top-down scheduling. /// class ScheduleDAGVLIW : public ScheduleDAGSDNodes { … }; } // end anonymous namespace /// Schedule - Schedule the DAG using list scheduling. void ScheduleDAGVLIW::Schedule() { … } //===----------------------------------------------------------------------===// // Top-Down Scheduling //===----------------------------------------------------------------------===// /// releaseSucc - Decrement the NumPredsLeft count of a successor. Add it to /// the PendingQueue if the count reaches zero. Also update its cycle bound. void ScheduleDAGVLIW::releaseSucc(SUnit *SU, const SDep &D) { … } void ScheduleDAGVLIW::releaseSuccessors(SUnit *SU) { … } /// scheduleNodeTopDown - Add the node to the schedule. Decrement the pending /// count of its successors. If a successor pending count is zero, add it to /// the Available queue. void ScheduleDAGVLIW::scheduleNodeTopDown(SUnit *SU, unsigned CurCycle) { … } /// listScheduleTopDown - The main loop of list scheduling for top-down /// schedulers. void ScheduleDAGVLIW::listScheduleTopDown() { … } //===----------------------------------------------------------------------===// // Public Constructor Functions //===----------------------------------------------------------------------===// /// createVLIWDAGScheduler - This creates a top-down list scheduler. ScheduleDAGSDNodes *llvm::createVLIWDAGScheduler(SelectionDAGISel *IS, CodeGenOptLevel) { … }