blob: 96d3f0f212a1a9cdc991bce93904d12f9e73e972 [file] [log] [blame]
Dan Gohmand27a0e02008-11-19 23:18:57 +00001//==- llvm/CodeGen/ScheduleDAGInstrs.h - MachineInstr Scheduling -*- C++ -*-==//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the ScheduleDAGInstrs class, which implements
11// scheduling for a MachineInstr-based dependency graph.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CODEGEN_SCHEDULEDAGINSTRS_H
16#define LLVM_CODEGEN_SCHEDULEDAGINSTRS_H
17
18#include "llvm/CodeGen/ScheduleDAG.h"
19
20namespace llvm {
Dan Gohman6b2ee8f2008-12-16 03:25:46 +000021 class MachineLoopInfo;
22 class MachineDominatorTree;
23
Dan Gohmand27a0e02008-11-19 23:18:57 +000024 class ScheduleDAGInstrs : public ScheduleDAG {
Dan Gohman6b2ee8f2008-12-16 03:25:46 +000025 const MachineLoopInfo &MLI;
26 const MachineDominatorTree &MDT;
27
Dan Gohmand27a0e02008-11-19 23:18:57 +000028 public:
29 ScheduleDAGInstrs(MachineBasicBlock *bb,
Dan Gohman6b2ee8f2008-12-16 03:25:46 +000030 const TargetMachine &tm,
31 const MachineLoopInfo &mli,
32 const MachineDominatorTree &mdt);
Dan Gohmand27a0e02008-11-19 23:18:57 +000033
34 virtual ~ScheduleDAGInstrs() {}
35
36 /// NewSUnit - Creates a new SUnit and return a ptr to it.
37 ///
38 SUnit *NewSUnit(MachineInstr *MI) {
Dan Gohmanf3470022008-12-22 21:08:08 +000039#ifndef NDEBUG
40 const SUnit *Addr = &SUnits[0];
41#endif
Dan Gohmand27a0e02008-11-19 23:18:57 +000042 SUnits.push_back(SUnit(MI, (unsigned)SUnits.size()));
Dan Gohmanf3470022008-12-22 21:08:08 +000043 assert(Addr == &SUnits[0] && "SUnits std::vector reallocated on the fly!");
Dan Gohmand27a0e02008-11-19 23:18:57 +000044 SUnits.back().OrigNode = &SUnits.back();
45 return &SUnits.back();
46 }
47
Dan Gohman9e7bcd62008-12-23 18:36:58 +000048 /// BuildSchedGraph - Build SUnits from the MachineBasicBlock that we are
Dan Gohmand27a0e02008-11-19 23:18:57 +000049 /// input.
Dan Gohman9e7bcd62008-12-23 18:36:58 +000050 virtual void BuildSchedGraph();
Dan Gohmand27a0e02008-11-19 23:18:57 +000051
Dan Gohman8efc97b2008-11-21 00:12:10 +000052 /// ComputeLatency - Compute node latency.
53 ///
54 virtual void ComputeLatency(SUnit *SU);
55
Dan Gohmand27a0e02008-11-19 23:18:57 +000056 virtual MachineBasicBlock *EmitSchedule();
57
58 /// Schedule - Order nodes according to selected style, filling
59 /// in the Sequence member.
60 ///
61 virtual void Schedule() = 0;
62
63 virtual void dumpNode(const SUnit *SU) const;
64
65 virtual std::string getGraphNodeLabel(const SUnit *SU) const;
66 };
67}
68
69#endif