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 LLVM_LIB_TARGET_R600_R600MACHINESCHEDULER_H
16 #define LLVM_LIB_TARGET_R600_R600MACHINESCHEDULER_H
18 #include "R600InstrInfo.h"
19 #include "llvm/ADT/PriorityQueue.h"
20 #include "llvm/CodeGen/MachineScheduler.h"
21 #include "llvm/Support/Debug.h"
27 class R600SchedStrategy : public MachineSchedStrategy {
29 const ScheduleDAGMILive *DAG;
30 const R600InstrInfo *TII;
31 const R600RegisterInfo *TRI;
32 MachineRegisterInfo *MRI;
50 AluDiscarded, // LLVM Instructions that are going to be eliminated
54 std::vector<SUnit *> Available[IDLast], Pending[IDLast];
55 std::vector<SUnit *> AvailableAlus[AluLast];
56 std::vector<SUnit *> PhysicalRegCopy;
60 InstKind NextInstKind;
62 unsigned AluInstCount;
63 unsigned FetchInstCount;
65 int InstKindLimit[IDLast];
71 DAG(nullptr), TII(nullptr), TRI(nullptr), MRI(nullptr) {
74 virtual ~R600SchedStrategy() {}
76 void initialize(ScheduleDAGMI *dag) override;
77 SUnit *pickNode(bool &IsTopNode) override;
78 void schedNode(SUnit *SU, bool IsTopNode) override;
79 void releaseTopNode(SUnit *SU) override;
80 void releaseBottomNode(SUnit *SU) override;
83 std::vector<MachineInstr *> InstructionsGroupCandidate;
86 int getInstKind(SUnit *SU);
87 bool regBelongsToClass(unsigned Reg, const TargetRegisterClass *RC) const;
88 AluKind getAluKind(SUnit *SU) const;
90 unsigned AvailablesAluCount() const;
91 SUnit *AttemptFillSlot (unsigned Slot, bool AnyAlu);
92 void PrepareNextSlot();
93 SUnit *PopInst(std::vector<SUnit*> &Q, bool AnyALU);
95 void AssignSlot(MachineInstr *MI, unsigned Slot);
97 SUnit* pickOther(int QID);
98 void MoveUnits(std::vector<SUnit *> &QSrc, std::vector<SUnit *> &QDst);
103 #endif /* R600MACHINESCHEDULER_H_ */