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