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