Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 1 | //===- SIMachineFunctionInfo.h - SIMachineFunctionInfo 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 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 15 | #ifndef LLVM_LIB_TARGET_R600_SIMACHINEFUNCTIONINFO_H |
| 16 | #define LLVM_LIB_TARGET_R600_SIMACHINEFUNCTIONINFO_H |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 17 | |
Vincent Lejeune | ace6f73 | 2013-04-01 21:47:53 +0000 | [diff] [blame] | 18 | #include "AMDGPUMachineFunction.h" |
Tom Stellard | 9646890 | 2014-09-24 01:33:17 +0000 | [diff] [blame] | 19 | #include "SIRegisterInfo.h" |
Tom Stellard | c149dc0 | 2013-11-27 21:23:35 +0000 | [diff] [blame] | 20 | #include <map> |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 21 | |
| 22 | namespace llvm { |
| 23 | |
Tom Stellard | c149dc0 | 2013-11-27 21:23:35 +0000 | [diff] [blame] | 24 | class MachineRegisterInfo; |
| 25 | |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 26 | /// This class keeps track of the SPI_SP_INPUT_ADDR config register, which |
| 27 | /// tells the hardware which interpolation parameters to load. |
Vincent Lejeune | ace6f73 | 2013-04-01 21:47:53 +0000 | [diff] [blame] | 28 | class SIMachineFunctionInfo : public AMDGPUMachineFunction { |
Craig Topper | 5656db4 | 2014-04-29 07:57:24 +0000 | [diff] [blame] | 29 | void anchor() override; |
Tom Stellard | 9646890 | 2014-09-24 01:33:17 +0000 | [diff] [blame] | 30 | |
| 31 | unsigned TIDReg; |
Matt Arsenault | 49affb8 | 2015-11-25 20:55:12 +0000 | [diff] [blame^] | 32 | unsigned ScratchRSrcReg; |
| 33 | |
| 34 | public: |
| 35 | // FIXME: Make private |
| 36 | unsigned LDSWaveSpillSize; |
| 37 | unsigned PSInputAddr; |
| 38 | std::map<unsigned, unsigned> LaneVGPRs; |
| 39 | unsigned ScratchOffsetReg; |
| 40 | unsigned NumUserSGPRs; |
| 41 | |
| 42 | private: |
Matt Arsenault | 5b22dfa | 2015-11-05 05:27:10 +0000 | [diff] [blame] | 43 | bool HasSpilledSGPRs; |
Tom Stellard | 42fb60e | 2015-01-14 15:42:31 +0000 | [diff] [blame] | 44 | bool HasSpilledVGPRs; |
Tom Stellard | 9646890 | 2014-09-24 01:33:17 +0000 | [diff] [blame] | 45 | |
Matt Arsenault | 49affb8 | 2015-11-25 20:55:12 +0000 | [diff] [blame^] | 46 | // Feature bits required for inputs passed in user / system SGPRs. |
| 47 | bool DispatchPtr : 1; |
| 48 | bool QueuePtr : 1; |
| 49 | bool DispatchID : 1; |
| 50 | bool KernargSegmentPtr : 1; |
| 51 | bool FlatScratchInit : 1; |
| 52 | bool GridWorkgroupCountX : 1; |
| 53 | bool GridWorkgroupCountY : 1; |
| 54 | bool GridWorkgroupCountZ : 1; |
Tom Stellard | c149dc0 | 2013-11-27 21:23:35 +0000 | [diff] [blame] | 55 | |
Matt Arsenault | 49affb8 | 2015-11-25 20:55:12 +0000 | [diff] [blame^] | 56 | bool WorkGroupIDX : 1; // Always initialized. |
| 57 | bool WorkGroupIDY : 1; |
| 58 | bool WorkGroupIDZ : 1; |
| 59 | bool WorkGroupInfo : 1; |
| 60 | |
| 61 | bool WorkItemIDX : 1; // Always initialized. |
| 62 | bool WorkItemIDY : 1; |
| 63 | bool WorkItemIDZ : 1; |
| 64 | |
| 65 | public: |
Tom Stellard | c149dc0 | 2013-11-27 21:23:35 +0000 | [diff] [blame] | 66 | struct SpilledReg { |
| 67 | unsigned VGPR; |
| 68 | int Lane; |
| 69 | SpilledReg(unsigned R, int L) : VGPR (R), Lane (L) { } |
| 70 | SpilledReg() : VGPR(0), Lane(-1) { } |
| 71 | bool hasLane() { return Lane != -1;} |
| 72 | }; |
| 73 | |
Tom Stellard | c149dc0 | 2013-11-27 21:23:35 +0000 | [diff] [blame] | 74 | // SIMachineFunctionInfo definition |
| 75 | |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 76 | SIMachineFunctionInfo(const MachineFunction &MF); |
Tom Stellard | c5cf2f0 | 2014-08-21 20:40:54 +0000 | [diff] [blame] | 77 | SpilledReg getSpilledReg(MachineFunction *MF, unsigned FrameIndex, |
| 78 | unsigned SubIdx); |
Tom Stellard | 9646890 | 2014-09-24 01:33:17 +0000 | [diff] [blame] | 79 | bool hasCalculatedTID() const { return TIDReg != AMDGPU::NoRegister; }; |
| 80 | unsigned getTIDReg() const { return TIDReg; }; |
| 81 | void setTIDReg(unsigned Reg) { TIDReg = Reg; } |
Matt Arsenault | 5b22dfa | 2015-11-05 05:27:10 +0000 | [diff] [blame] | 82 | |
Matt Arsenault | 49affb8 | 2015-11-25 20:55:12 +0000 | [diff] [blame^] | 83 | bool hasDispatchPtr() const { |
| 84 | return DispatchPtr; |
| 85 | } |
| 86 | |
| 87 | bool hasQueuePtr() const { |
| 88 | return QueuePtr; |
| 89 | } |
| 90 | |
| 91 | bool hasDispatchID() const { |
| 92 | return DispatchID; |
| 93 | } |
| 94 | |
| 95 | bool hasKernargSegmentPtr() const { |
| 96 | return KernargSegmentPtr; |
| 97 | } |
| 98 | |
| 99 | bool hasFlatScratchInit() const { |
| 100 | return FlatScratchInit; |
| 101 | } |
| 102 | |
| 103 | bool hasGridWorkgroupCountX() const { |
| 104 | return GridWorkgroupCountX; |
| 105 | } |
| 106 | |
| 107 | bool hasGridWorkgroupCountY() const { |
| 108 | return GridWorkgroupCountY; |
| 109 | } |
| 110 | |
| 111 | bool hasGridWorkgroupCountZ() const { |
| 112 | return GridWorkgroupCountZ; |
| 113 | } |
| 114 | |
| 115 | bool hasWorkGroupIDX() const { |
| 116 | return WorkGroupIDX; |
| 117 | } |
| 118 | |
| 119 | bool hasWorkGroupIDY() const { |
| 120 | return WorkGroupIDY; |
| 121 | } |
| 122 | |
| 123 | bool hasWorkGroupIDZ() const { |
| 124 | return WorkGroupIDZ; |
| 125 | } |
| 126 | |
| 127 | bool hasWorkGroupInfo() const { |
| 128 | return WorkGroupInfo; |
| 129 | } |
| 130 | |
| 131 | bool hasWorkItemIDX() const { |
| 132 | return WorkItemIDX; |
| 133 | } |
| 134 | |
| 135 | bool hasWorkItemIDY() const { |
| 136 | return WorkItemIDY; |
| 137 | } |
| 138 | |
| 139 | bool hasWorkItemIDZ() const { |
| 140 | return WorkItemIDZ; |
| 141 | } |
| 142 | |
| 143 | /// \brief Returns the physical register reserved for use as the resource |
| 144 | /// descriptor for scratch accesses. |
| 145 | unsigned getScratchRSrcReg() const { |
| 146 | return ScratchRSrcReg; |
| 147 | } |
| 148 | |
| 149 | void setScratchRSrcReg(const SIRegisterInfo *TRI); |
| 150 | |
Matt Arsenault | 5b22dfa | 2015-11-05 05:27:10 +0000 | [diff] [blame] | 151 | bool hasSpilledSGPRs() const { |
| 152 | return HasSpilledSGPRs; |
| 153 | } |
| 154 | |
| 155 | void setHasSpilledSGPRs(bool Spill = true) { |
| 156 | HasSpilledSGPRs = Spill; |
| 157 | } |
| 158 | |
| 159 | bool hasSpilledVGPRs() const { |
| 160 | return HasSpilledVGPRs; |
| 161 | } |
| 162 | |
| 163 | void setHasSpilledVGPRs(bool Spill = true) { |
| 164 | HasSpilledVGPRs = Spill; |
| 165 | } |
Tom Stellard | 9646890 | 2014-09-24 01:33:17 +0000 | [diff] [blame] | 166 | |
| 167 | unsigned getMaximumWorkGroupSize(const MachineFunction &MF) const; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 168 | }; |
| 169 | |
| 170 | } // End namespace llvm |
| 171 | |
| 172 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 173 | #endif |