Move a few containers out of ScheduleDAGInstrs::BuildSchedGraph
[oota-llvm.git] / include / llvm / CodeGen / ScheduleDAGInstrs.h
1 //==- 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 #include "llvm/Target/TargetRegisterInfo.h"
20
21 namespace llvm {
22   class MachineLoopInfo;
23   class MachineDominatorTree;
24
25   class ScheduleDAGInstrs : public ScheduleDAG {
26     const MachineLoopInfo &MLI;
27     const MachineDominatorTree &MDT;
28
29     /// Defs, Uses - Remember where defs and uses of each physical register
30     /// are as we iterate upward through the instructions. This is allocated
31     /// here instead of inside BuildSchedGraph to avoid the need for it to be
32     /// initialized and destructed for each block.
33     std::vector<SUnit *> Defs[TargetRegisterInfo::FirstVirtualRegister];
34     std::vector<SUnit *> Uses[TargetRegisterInfo::FirstVirtualRegister];
35
36     /// PendingLoads - Remember where unknown loads are after the most recent
37     /// unknown store, as we iterate. As with Defs and Uses, this is here
38     /// to minimize construction/destruction.
39     std::vector<SUnit *> PendingLoads;
40
41   public:
42     explicit ScheduleDAGInstrs(MachineFunction &mf,
43                                const MachineLoopInfo &mli,
44                                const MachineDominatorTree &mdt);
45
46     virtual ~ScheduleDAGInstrs() {}
47
48     /// NewSUnit - Creates a new SUnit and return a ptr to it.
49     ///
50     SUnit *NewSUnit(MachineInstr *MI) {
51 #ifndef NDEBUG
52       const SUnit *Addr = &SUnits[0];
53 #endif
54       SUnits.push_back(SUnit(MI, (unsigned)SUnits.size()));
55       assert(Addr == &SUnits[0] && "SUnits std::vector reallocated on the fly!");
56       SUnits.back().OrigNode = &SUnits.back();
57       return &SUnits.back();
58     }
59
60     /// BuildSchedGraph - Build SUnits from the MachineBasicBlock that we are
61     /// input.
62     virtual void BuildSchedGraph();
63
64     /// ComputeLatency - Compute node latency.
65     ///
66     virtual void ComputeLatency(SUnit *SU);
67
68     virtual MachineBasicBlock *EmitSchedule();
69
70     /// Schedule - Order nodes according to selected style, filling
71     /// in the Sequence member.
72     ///
73     virtual void Schedule() = 0;
74
75     virtual void dumpNode(const SUnit *SU) const;
76
77     virtual std::string getGraphNodeLabel(const SUnit *SU) const;
78   };
79 }
80
81 #endif