1 //===-- R600MachineScheduler.h - R600 Scheduler Interface -*- 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 //===----------------------------------------------------------------------===//
11 /// \brief R600 Machine Scheduler interface
13 //===----------------------------------------------------------------------===//
15 #ifndef R600MACHINESCHEDULER_H_
16 #define R600MACHINESCHEDULER_H_
18 #include "R600InstrInfo.h"
19 #include "llvm/CodeGen/MachineScheduler.h"
20 #include "llvm/Support/Debug.h"
21 #include "llvm/ADT/PriorityQueue.h"
29 bool operator()(const SUnit *S1, const SUnit *S2) {
30 return S1->getDepth() > S2->getDepth();
34 class R600SchedStrategy : public MachineSchedStrategy {
36 const ScheduleDAGMI *DAG;
37 const R600InstrInfo *TII;
38 const R600RegisterInfo *TRI;
39 MachineRegisterInfo *MRI;
61 AluDiscarded, // LLVM Instructions that are going to be eliminated
65 ReadyQueue *Available[IDLast], *Pending[IDLast];
66 std::multiset<SUnit *, CompareSUnit> AvailableAlus[AluLast];
70 InstKind NextInstKind;
72 int InstKindLimit[IDLast];
78 DAG(0), TII(0), TRI(0), MRI(0) {
79 Available[IDAlu] = new ReadyQueue(QAlu, "AAlu");
80 Available[IDFetch] = new ReadyQueue(QFetch, "AFetch");
81 Available[IDOther] = new ReadyQueue(QOther, "AOther");
82 Pending[IDAlu] = new ReadyQueue(QAlu<<4, "PAlu");
83 Pending[IDFetch] = new ReadyQueue(QFetch<<4, "PFetch");
84 Pending[IDOther] = new ReadyQueue(QOther<<4, "POther");
87 virtual ~R600SchedStrategy() {
88 for (unsigned I = 0; I < IDLast; ++I) {
94 virtual void initialize(ScheduleDAGMI *dag);
95 virtual SUnit *pickNode(bool &IsTopNode);
96 virtual void schedNode(SUnit *SU, bool IsTopNode);
97 virtual void releaseTopNode(SUnit *SU);
98 virtual void releaseBottomNode(SUnit *SU);
101 std::vector<MachineInstr *> InstructionsGroupCandidate;
103 int getInstKind(SUnit *SU);
104 bool regBelongsToClass(unsigned Reg, const TargetRegisterClass *RC) const;
105 AluKind getAluKind(SUnit *SU) const;
107 bool isAvailablesAluEmpty() const;
108 SUnit *AttemptFillSlot (unsigned Slot);
109 void PrepareNextSlot();
110 SUnit *PopInst(std::multiset<SUnit *, CompareSUnit> &Q);
112 void AssignSlot(MachineInstr *MI, unsigned Slot);
114 SUnit* pickOther(int QID);
115 void MoveUnits(ReadyQueue *QSrc, ReadyQueue *QDst);
120 #endif /* R600MACHINESCHEDULER_H_ */