Dan Gohman | d27a0e0 | 2008-11-19 23:18:57 +0000 | [diff] [blame] | 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 | |
| 20 | namespace llvm { |
Dan Gohman | 6b2ee8f | 2008-12-16 03:25:46 +0000 | [diff] [blame] | 21 | class MachineLoopInfo; |
| 22 | class MachineDominatorTree; |
| 23 | |
Dan Gohman | d27a0e0 | 2008-11-19 23:18:57 +0000 | [diff] [blame] | 24 | class ScheduleDAGInstrs : public ScheduleDAG { |
Dan Gohman | 6b2ee8f | 2008-12-16 03:25:46 +0000 | [diff] [blame] | 25 | const MachineLoopInfo &MLI; |
| 26 | const MachineDominatorTree &MDT; |
| 27 | |
Dan Gohman | d27a0e0 | 2008-11-19 23:18:57 +0000 | [diff] [blame] | 28 | public: |
| 29 | ScheduleDAGInstrs(MachineBasicBlock *bb, |
Dan Gohman | 6b2ee8f | 2008-12-16 03:25:46 +0000 | [diff] [blame] | 30 | const TargetMachine &tm, |
| 31 | const MachineLoopInfo &mli, |
| 32 | const MachineDominatorTree &mdt); |
Dan Gohman | d27a0e0 | 2008-11-19 23:18:57 +0000 | [diff] [blame] | 33 | |
| 34 | virtual ~ScheduleDAGInstrs() {} |
| 35 | |
| 36 | /// NewSUnit - Creates a new SUnit and return a ptr to it. |
| 37 | /// |
| 38 | SUnit *NewSUnit(MachineInstr *MI) { |
Dan Gohman | f347002 | 2008-12-22 21:08:08 +0000 | [diff] [blame] | 39 | #ifndef NDEBUG |
| 40 | const SUnit *Addr = &SUnits[0]; |
| 41 | #endif |
Dan Gohman | d27a0e0 | 2008-11-19 23:18:57 +0000 | [diff] [blame] | 42 | SUnits.push_back(SUnit(MI, (unsigned)SUnits.size())); |
Dan Gohman | f347002 | 2008-12-22 21:08:08 +0000 | [diff] [blame] | 43 | assert(Addr == &SUnits[0] && "SUnits std::vector reallocated on the fly!"); |
Dan Gohman | d27a0e0 | 2008-11-19 23:18:57 +0000 | [diff] [blame] | 44 | SUnits.back().OrigNode = &SUnits.back(); |
| 45 | return &SUnits.back(); |
| 46 | } |
| 47 | |
Dan Gohman | 9e7bcd6 | 2008-12-23 18:36:58 +0000 | [diff] [blame^] | 48 | /// BuildSchedGraph - Build SUnits from the MachineBasicBlock that we are |
Dan Gohman | d27a0e0 | 2008-11-19 23:18:57 +0000 | [diff] [blame] | 49 | /// input. |
Dan Gohman | 9e7bcd6 | 2008-12-23 18:36:58 +0000 | [diff] [blame^] | 50 | virtual void BuildSchedGraph(); |
Dan Gohman | d27a0e0 | 2008-11-19 23:18:57 +0000 | [diff] [blame] | 51 | |
Dan Gohman | 8efc97b | 2008-11-21 00:12:10 +0000 | [diff] [blame] | 52 | /// ComputeLatency - Compute node latency. |
| 53 | /// |
| 54 | virtual void ComputeLatency(SUnit *SU); |
| 55 | |
Dan Gohman | d27a0e0 | 2008-11-19 23:18:57 +0000 | [diff] [blame] | 56 | 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 |