1 //===-- ScheduleDAGSimple.cpp - Implement a list scheduler for isel DAG ---===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Evan Cheng and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This implements a simple two pass scheduler. The first pass attempts to push
11 // backward any lengthy instructions and critical paths. The second pass packs
12 // instructions into semi-optimal time slots.
14 //===----------------------------------------------------------------------===//
16 #define DEBUG_TYPE "sched"
17 #include "llvm/CodeGen/ScheduleDAG.h"
18 #include "llvm/CodeGen/SelectionDAG.h"
19 #include "llvm/Target/TargetMachine.h"
20 #include "llvm/Target/TargetInstrInfo.h"
27 /// Sorting functions for ready queue.
28 struct LSSortPred : public std::binary_function<SDOperand, SDOperand, bool> {
29 bool operator()(const SDOperand* left, const SDOperand* right) const {
34 /// ScheduleDAGList - List scheduler.
36 class ScheduleDAGList : public ScheduleDAG {
41 std::priority_queue<SDOperand*, std::vector<SDOperand*>, LSSortPred> Ready;
44 ScheduleDAGList(SelectionDAG &dag, MachineBasicBlock *bb,
45 const TargetMachine &tm, LSSortPred cmp)
46 : ScheduleDAG(listSchedulingBURR, dag, bb, tm), Cmp(cmp), Ready(Cmp)
51 } // end namespace llvm
53 void ScheduleDAGList::Schedule() {
58 llvm::createBURRListDAGScheduler(SelectionDAG &DAG,
59 MachineBasicBlock *BB) {
60 return new ScheduleDAGList(DAG, BB, DAG.getTarget(), LSSortPred());