1 //==- ScheduleDAGInstrs.h - MachineInstr Scheduling --------------*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the ScheduleDAGInstrs class, which implements
11 // scheduling for a MachineInstr-based dependency graph.
13 //===----------------------------------------------------------------------===//
15 #ifndef SCHEDULEDAGINSTRS_H
16 #define SCHEDULEDAGINSTRS_H
18 #include "llvm/CodeGen/ScheduleDAG.h"
19 #include "llvm/Target/TargetRegisterInfo.h"
22 class MachineLoopInfo;
23 class MachineDominatorTree;
25 class ScheduleDAGInstrs : public ScheduleDAG {
26 const MachineLoopInfo &MLI;
27 const MachineDominatorTree &MDT;
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];
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;
42 explicit ScheduleDAGInstrs(MachineFunction &mf,
43 const MachineLoopInfo &mli,
44 const MachineDominatorTree &mdt);
46 virtual ~ScheduleDAGInstrs() {}
48 /// NewSUnit - Creates a new SUnit and return a ptr to it.
50 SUnit *NewSUnit(MachineInstr *MI) {
52 const SUnit *Addr = SUnits.empty() ? 0 : &SUnits[0];
54 SUnits.push_back(SUnit(MI, (unsigned)SUnits.size()));
55 assert((Addr == 0 || Addr == &SUnits[0]) &&
56 "SUnits std::vector reallocated on the fly!");
57 SUnits.back().OrigNode = &SUnits.back();
58 return &SUnits.back();
61 /// BuildSchedGraph - Build SUnits from the MachineBasicBlock that we are
63 virtual void BuildSchedGraph();
65 /// ComputeLatency - Compute node latency.
67 virtual void ComputeLatency(SUnit *SU);
69 virtual MachineBasicBlock *EmitSchedule();
71 /// Schedule - Order nodes according to selected style, filling
72 /// in the Sequence member.
74 virtual void Schedule() = 0;
76 virtual void dumpNode(const SUnit *SU) const;
78 virtual std::string getGraphNodeLabel(const SUnit *SU) const;