LLVM API Documentation

ScheduleDAGInstrs.h

Go to the documentation of this file.
00001 //==- llvm/CodeGen/ScheduleDAGInstrs.h - MachineInstr Scheduling -*- C++ -*-==//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file implements the ScheduleDAGInstrs class, which implements
00011 // scheduling for a MachineInstr-based dependency graph.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_CODEGEN_SCHEDULEDAGINSTRS_H
00016 #define LLVM_CODEGEN_SCHEDULEDAGINSTRS_H
00017 
00018 #include "llvm/CodeGen/ScheduleDAG.h"
00019 #include "llvm/Target/TargetRegisterInfo.h"
00020 
00021 namespace llvm {
00022   class MachineLoopInfo;
00023   class MachineDominatorTree;
00024 
00025   class ScheduleDAGInstrs : public ScheduleDAG {
00026     const MachineLoopInfo &MLI;
00027     const MachineDominatorTree &MDT;
00028 
00029     /// Defs, Uses - Remember where defs and uses of each physical register
00030     /// are as we iterate upward through the instructions. This is allocated
00031     /// here instead of inside BuildSchedGraph to avoid the need for it to be
00032     /// initialized and destructed for each block.
00033     std::vector<SUnit *> Defs[TargetRegisterInfo::FirstVirtualRegister];
00034     std::vector<SUnit *> Uses[TargetRegisterInfo::FirstVirtualRegister];
00035 
00036     /// PendingLoads - Remember where unknown loads are after the most recent
00037     /// unknown store, as we iterate. As with Defs and Uses, this is here
00038     /// to minimize construction/destruction.
00039     std::vector<SUnit *> PendingLoads;
00040 
00041   public:
00042     explicit ScheduleDAGInstrs(MachineFunction &mf,
00043                                const MachineLoopInfo &mli,
00044                                const MachineDominatorTree &mdt);
00045 
00046     virtual ~ScheduleDAGInstrs() {}
00047 
00048     /// NewSUnit - Creates a new SUnit and return a ptr to it.
00049     ///
00050     SUnit *NewSUnit(MachineInstr *MI) {
00051 #ifndef NDEBUG
00052       const SUnit *Addr = SUnits.empty() ? 0 : &SUnits[0];
00053 #endif
00054       SUnits.push_back(SUnit(MI, (unsigned)SUnits.size()));
00055       assert((Addr == 0 || Addr == &SUnits[0]) &&
00056              "SUnits std::vector reallocated on the fly!");
00057       SUnits.back().OrigNode = &SUnits.back();
00058       return &SUnits.back();
00059     }
00060 
00061     /// BuildSchedGraph - Build SUnits from the MachineBasicBlock that we are
00062     /// input.
00063     virtual void BuildSchedGraph();
00064 
00065     /// ComputeLatency - Compute node latency.
00066     ///
00067     virtual void ComputeLatency(SUnit *SU);
00068 
00069     virtual MachineBasicBlock *EmitSchedule();
00070 
00071     /// Schedule - Order nodes according to selected style, filling
00072     /// in the Sequence member.
00073     ///
00074     virtual void Schedule() = 0;
00075 
00076     virtual void dumpNode(const SUnit *SU) const;
00077 
00078     virtual std::string getGraphNodeLabel(const SUnit *SU) const;
00079   };
00080 }
00081 
00082 #endif