LLVM API Documentation

R600MachineScheduler.h
Go to the documentation of this file.
00001 //===-- R600MachineScheduler.h - R600 Scheduler Interface -*- 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 /// \file
00011 /// \brief R600 Machine Scheduler interface
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_LIB_TARGET_R600_R600MACHINESCHEDULER_H
00016 #define LLVM_LIB_TARGET_R600_R600MACHINESCHEDULER_H
00017 
00018 #include "R600InstrInfo.h"
00019 #include "llvm/ADT/PriorityQueue.h"
00020 #include "llvm/CodeGen/MachineScheduler.h"
00021 #include "llvm/Support/Debug.h"
00022 
00023 using namespace llvm;
00024 
00025 namespace llvm {
00026 
00027 class R600SchedStrategy : public MachineSchedStrategy {
00028 
00029   const ScheduleDAGMILive *DAG;
00030   const R600InstrInfo *TII;
00031   const R600RegisterInfo *TRI;
00032   MachineRegisterInfo *MRI;
00033 
00034   enum InstKind {
00035     IDAlu,
00036     IDFetch,
00037     IDOther,
00038     IDLast
00039   };
00040 
00041   enum AluKind {
00042     AluAny,
00043     AluT_X,
00044     AluT_Y,
00045     AluT_Z,
00046     AluT_W,
00047     AluT_XYZW,
00048     AluPredX,
00049     AluTrans,
00050     AluDiscarded, // LLVM Instructions that are going to be eliminated
00051     AluLast
00052   };
00053 
00054   std::vector<SUnit *> Available[IDLast], Pending[IDLast];
00055   std::vector<SUnit *> AvailableAlus[AluLast];
00056   std::vector<SUnit *> PhysicalRegCopy;
00057 
00058   InstKind CurInstKind;
00059   int CurEmitted;
00060   InstKind NextInstKind;
00061 
00062   unsigned AluInstCount;
00063   unsigned FetchInstCount;
00064 
00065   int InstKindLimit[IDLast];
00066 
00067   int OccupedSlotsMask;
00068 
00069 public:
00070   R600SchedStrategy() :
00071     DAG(nullptr), TII(nullptr), TRI(nullptr), MRI(nullptr) {
00072   }
00073 
00074   virtual ~R600SchedStrategy() {}
00075 
00076   void initialize(ScheduleDAGMI *dag) override;
00077   SUnit *pickNode(bool &IsTopNode) override;
00078   void schedNode(SUnit *SU, bool IsTopNode) override;
00079   void releaseTopNode(SUnit *SU) override;
00080   void releaseBottomNode(SUnit *SU) override;
00081 
00082 private:
00083   std::vector<MachineInstr *> InstructionsGroupCandidate;
00084   bool VLIW5;
00085 
00086   int getInstKind(SUnit *SU);
00087   bool regBelongsToClass(unsigned Reg, const TargetRegisterClass *RC) const;
00088   AluKind getAluKind(SUnit *SU) const;
00089   void LoadAlu();
00090   unsigned AvailablesAluCount() const;
00091   SUnit *AttemptFillSlot (unsigned Slot, bool AnyAlu);
00092   void PrepareNextSlot();
00093   SUnit *PopInst(std::vector<SUnit*> &Q, bool AnyALU);
00094 
00095   void AssignSlot(MachineInstr *MI, unsigned Slot);
00096   SUnit* pickAlu();
00097   SUnit* pickOther(int QID);
00098   void MoveUnits(std::vector<SUnit *> &QSrc, std::vector<SUnit *> &QDst);
00099 };
00100 
00101 } // namespace llvm
00102 
00103 #endif /* R600MACHINESCHEDULER_H_ */