Vincent Lejeune | 68b6b6d | 2013-03-05 18:41:32 +0000 | [diff] [blame] | 1 | //===-- R600MachineScheduler.h - R600 Scheduler Interface -*- 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 | /// \file |
| 11 | /// \brief R600 Machine Scheduler interface |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Matt Arsenault | 6b6a2c3 | 2016-03-11 08:00:27 +0000 | [diff] [blame] | 15 | #ifndef LLVM_LIB_TARGET_AMDGPU_R600MACHINESCHEDULER_H |
| 16 | #define LLVM_LIB_TARGET_AMDGPU_R600MACHINESCHEDULER_H |
Vincent Lejeune | 68b6b6d | 2013-03-05 18:41:32 +0000 | [diff] [blame] | 17 | |
| 18 | #include "R600InstrInfo.h" |
| 19 | #include "llvm/CodeGen/MachineScheduler.h" |
Vincent Lejeune | 68b6b6d | 2013-03-05 18:41:32 +0000 | [diff] [blame] | 20 | |
| 21 | using namespace llvm; |
| 22 | |
| 23 | namespace llvm { |
| 24 | |
Matt Arsenault | 6b6a2c3 | 2016-03-11 08:00:27 +0000 | [diff] [blame] | 25 | class R600SchedStrategy final : public MachineSchedStrategy { |
Vincent Lejeune | 68b6b6d | 2013-03-05 18:41:32 +0000 | [diff] [blame] | 26 | |
Andrew Trick | d7f890e | 2013-12-28 21:56:47 +0000 | [diff] [blame] | 27 | const ScheduleDAGMILive *DAG; |
Vincent Lejeune | 68b6b6d | 2013-03-05 18:41:32 +0000 | [diff] [blame] | 28 | const R600InstrInfo *TII; |
| 29 | const R600RegisterInfo *TRI; |
| 30 | MachineRegisterInfo *MRI; |
| 31 | |
Vincent Lejeune | 68b6b6d | 2013-03-05 18:41:32 +0000 | [diff] [blame] | 32 | enum InstKind { |
| 33 | IDAlu, |
| 34 | IDFetch, |
| 35 | IDOther, |
| 36 | IDLast |
| 37 | }; |
| 38 | |
| 39 | enum AluKind { |
| 40 | AluAny, |
| 41 | AluT_X, |
| 42 | AluT_Y, |
| 43 | AluT_Z, |
| 44 | AluT_W, |
| 45 | AluT_XYZW, |
Vincent Lejeune | 3d5118c | 2013-05-17 16:50:56 +0000 | [diff] [blame] | 46 | AluPredX, |
Vincent Lejeune | 77a8352 | 2013-06-29 19:32:43 +0000 | [diff] [blame] | 47 | AluTrans, |
Vincent Lejeune | 68b6b6d | 2013-03-05 18:41:32 +0000 | [diff] [blame] | 48 | AluDiscarded, // LLVM Instructions that are going to be eliminated |
| 49 | AluLast |
| 50 | }; |
| 51 | |
Vincent Lejeune | 4c81d4d | 2013-05-17 16:50:44 +0000 | [diff] [blame] | 52 | std::vector<SUnit *> Available[IDLast], Pending[IDLast]; |
| 53 | std::vector<SUnit *> AvailableAlus[AluLast]; |
Vincent Lejeune | 4b5b849 | 2013-06-05 20:27:35 +0000 | [diff] [blame] | 54 | std::vector<SUnit *> PhysicalRegCopy; |
Vincent Lejeune | 68b6b6d | 2013-03-05 18:41:32 +0000 | [diff] [blame] | 55 | |
| 56 | InstKind CurInstKind; |
| 57 | int CurEmitted; |
| 58 | InstKind NextInstKind; |
| 59 | |
Vincent Lejeune | d1a9d18 | 2013-06-07 23:30:34 +0000 | [diff] [blame] | 60 | unsigned AluInstCount; |
| 61 | unsigned FetchInstCount; |
| 62 | |
Vincent Lejeune | 68b6b6d | 2013-03-05 18:41:32 +0000 | [diff] [blame] | 63 | int InstKindLimit[IDLast]; |
| 64 | |
| 65 | int OccupedSlotsMask; |
| 66 | |
| 67 | public: |
| 68 | R600SchedStrategy() : |
Craig Topper | e73658d | 2014-04-28 04:05:08 +0000 | [diff] [blame] | 69 | DAG(nullptr), TII(nullptr), TRI(nullptr), MRI(nullptr) { |
Vincent Lejeune | 68b6b6d | 2013-03-05 18:41:32 +0000 | [diff] [blame] | 70 | } |
| 71 | |
Craig Topper | 5656db4 | 2014-04-29 07:57:24 +0000 | [diff] [blame] | 72 | virtual ~R600SchedStrategy() {} |
Vincent Lejeune | 68b6b6d | 2013-03-05 18:41:32 +0000 | [diff] [blame] | 73 | |
Craig Topper | 5656db4 | 2014-04-29 07:57:24 +0000 | [diff] [blame] | 74 | void initialize(ScheduleDAGMI *dag) override; |
| 75 | SUnit *pickNode(bool &IsTopNode) override; |
| 76 | void schedNode(SUnit *SU, bool IsTopNode) override; |
| 77 | void releaseTopNode(SUnit *SU) override; |
| 78 | void releaseBottomNode(SUnit *SU) override; |
Vincent Lejeune | 68b6b6d | 2013-03-05 18:41:32 +0000 | [diff] [blame] | 79 | |
| 80 | private: |
Vincent Lejeune | 0a22bc4 | 2013-03-14 15:50:45 +0000 | [diff] [blame] | 81 | std::vector<MachineInstr *> InstructionsGroupCandidate; |
Vincent Lejeune | 7e2c832 | 2013-09-04 19:53:46 +0000 | [diff] [blame] | 82 | bool VLIW5; |
Vincent Lejeune | 68b6b6d | 2013-03-05 18:41:32 +0000 | [diff] [blame] | 83 | |
| 84 | int getInstKind(SUnit *SU); |
| 85 | bool regBelongsToClass(unsigned Reg, const TargetRegisterClass *RC) const; |
| 86 | AluKind getAluKind(SUnit *SU) const; |
| 87 | void LoadAlu(); |
Vincent Lejeune | d1a9d18 | 2013-06-07 23:30:34 +0000 | [diff] [blame] | 88 | unsigned AvailablesAluCount() const; |
Vincent Lejeune | 7e2c832 | 2013-09-04 19:53:46 +0000 | [diff] [blame] | 89 | SUnit *AttemptFillSlot (unsigned Slot, bool AnyAlu); |
Vincent Lejeune | 68b6b6d | 2013-03-05 18:41:32 +0000 | [diff] [blame] | 90 | void PrepareNextSlot(); |
Vincent Lejeune | 7e2c832 | 2013-09-04 19:53:46 +0000 | [diff] [blame] | 91 | SUnit *PopInst(std::vector<SUnit*> &Q, bool AnyALU); |
Vincent Lejeune | 68b6b6d | 2013-03-05 18:41:32 +0000 | [diff] [blame] | 92 | |
| 93 | void AssignSlot(MachineInstr *MI, unsigned Slot); |
| 94 | SUnit* pickAlu(); |
| 95 | SUnit* pickOther(int QID); |
Vincent Lejeune | 4c81d4d | 2013-05-17 16:50:44 +0000 | [diff] [blame] | 96 | void MoveUnits(std::vector<SUnit *> &QSrc, std::vector<SUnit *> &QDst); |
Vincent Lejeune | 68b6b6d | 2013-03-05 18:41:32 +0000 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | } // namespace llvm |
| 100 | |
| 101 | #endif /* R600MACHINESCHEDULER_H_ */ |