xref: /aosp_15_r20/external/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===- SIMachineFunctionInfo.h - SIMachineFunctionInfo interface -*- C++ -*-==//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker /// \file
11*9880d681SAndroid Build Coastguard Worker //
12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
13*9880d681SAndroid Build Coastguard Worker 
14*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_AMDGPU_SIMACHINEFUNCTIONINFO_H
15*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_AMDGPU_SIMACHINEFUNCTIONINFO_H
16*9880d681SAndroid Build Coastguard Worker 
17*9880d681SAndroid Build Coastguard Worker #include "AMDGPUMachineFunction.h"
18*9880d681SAndroid Build Coastguard Worker #include "SIRegisterInfo.h"
19*9880d681SAndroid Build Coastguard Worker #include <array>
20*9880d681SAndroid Build Coastguard Worker #include <map>
21*9880d681SAndroid Build Coastguard Worker 
22*9880d681SAndroid Build Coastguard Worker namespace llvm {
23*9880d681SAndroid Build Coastguard Worker 
24*9880d681SAndroid Build Coastguard Worker class MachineRegisterInfo;
25*9880d681SAndroid Build Coastguard Worker 
26*9880d681SAndroid Build Coastguard Worker /// This class keeps track of the SPI_SP_INPUT_ADDR config register, which
27*9880d681SAndroid Build Coastguard Worker /// tells the hardware which interpolation parameters to load.
28*9880d681SAndroid Build Coastguard Worker class SIMachineFunctionInfo final : public AMDGPUMachineFunction {
29*9880d681SAndroid Build Coastguard Worker   // FIXME: This should be removed and getPreloadedValue moved here.
30*9880d681SAndroid Build Coastguard Worker   friend struct SIRegisterInfo;
31*9880d681SAndroid Build Coastguard Worker   void anchor() override;
32*9880d681SAndroid Build Coastguard Worker 
33*9880d681SAndroid Build Coastguard Worker   unsigned TIDReg;
34*9880d681SAndroid Build Coastguard Worker 
35*9880d681SAndroid Build Coastguard Worker   // Registers that may be reserved for spilling purposes. These may be the same
36*9880d681SAndroid Build Coastguard Worker   // as the input registers.
37*9880d681SAndroid Build Coastguard Worker   unsigned ScratchRSrcReg;
38*9880d681SAndroid Build Coastguard Worker   unsigned ScratchWaveOffsetReg;
39*9880d681SAndroid Build Coastguard Worker 
40*9880d681SAndroid Build Coastguard Worker   // Input registers setup for the HSA ABI.
41*9880d681SAndroid Build Coastguard Worker   // User SGPRs in allocation order.
42*9880d681SAndroid Build Coastguard Worker   unsigned PrivateSegmentBufferUserSGPR;
43*9880d681SAndroid Build Coastguard Worker   unsigned DispatchPtrUserSGPR;
44*9880d681SAndroid Build Coastguard Worker   unsigned QueuePtrUserSGPR;
45*9880d681SAndroid Build Coastguard Worker   unsigned KernargSegmentPtrUserSGPR;
46*9880d681SAndroid Build Coastguard Worker   unsigned DispatchIDUserSGPR;
47*9880d681SAndroid Build Coastguard Worker   unsigned FlatScratchInitUserSGPR;
48*9880d681SAndroid Build Coastguard Worker   unsigned PrivateSegmentSizeUserSGPR;
49*9880d681SAndroid Build Coastguard Worker   unsigned GridWorkGroupCountXUserSGPR;
50*9880d681SAndroid Build Coastguard Worker   unsigned GridWorkGroupCountYUserSGPR;
51*9880d681SAndroid Build Coastguard Worker   unsigned GridWorkGroupCountZUserSGPR;
52*9880d681SAndroid Build Coastguard Worker 
53*9880d681SAndroid Build Coastguard Worker   // System SGPRs in allocation order.
54*9880d681SAndroid Build Coastguard Worker   unsigned WorkGroupIDXSystemSGPR;
55*9880d681SAndroid Build Coastguard Worker   unsigned WorkGroupIDYSystemSGPR;
56*9880d681SAndroid Build Coastguard Worker   unsigned WorkGroupIDZSystemSGPR;
57*9880d681SAndroid Build Coastguard Worker   unsigned WorkGroupInfoSystemSGPR;
58*9880d681SAndroid Build Coastguard Worker   unsigned PrivateSegmentWaveByteOffsetSystemSGPR;
59*9880d681SAndroid Build Coastguard Worker 
60*9880d681SAndroid Build Coastguard Worker   // Graphics info.
61*9880d681SAndroid Build Coastguard Worker   unsigned PSInputAddr;
62*9880d681SAndroid Build Coastguard Worker   bool ReturnsVoid;
63*9880d681SAndroid Build Coastguard Worker 
64*9880d681SAndroid Build Coastguard Worker   unsigned MaximumWorkGroupSize;
65*9880d681SAndroid Build Coastguard Worker 
66*9880d681SAndroid Build Coastguard Worker   // Number of reserved VGPRs for debugger usage.
67*9880d681SAndroid Build Coastguard Worker   unsigned DebuggerReservedVGPRCount;
68*9880d681SAndroid Build Coastguard Worker   // Stack object indices for work group IDs.
69*9880d681SAndroid Build Coastguard Worker   std::array<int, 3> DebuggerWorkGroupIDStackObjectIndices;
70*9880d681SAndroid Build Coastguard Worker   // Stack object indices for work item IDs.
71*9880d681SAndroid Build Coastguard Worker   std::array<int, 3> DebuggerWorkItemIDStackObjectIndices;
72*9880d681SAndroid Build Coastguard Worker 
73*9880d681SAndroid Build Coastguard Worker public:
74*9880d681SAndroid Build Coastguard Worker   // FIXME: Make private
75*9880d681SAndroid Build Coastguard Worker   unsigned LDSWaveSpillSize;
76*9880d681SAndroid Build Coastguard Worker   unsigned PSInputEna;
77*9880d681SAndroid Build Coastguard Worker   std::map<unsigned, unsigned> LaneVGPRs;
78*9880d681SAndroid Build Coastguard Worker   unsigned ScratchOffsetReg;
79*9880d681SAndroid Build Coastguard Worker   unsigned NumUserSGPRs;
80*9880d681SAndroid Build Coastguard Worker   unsigned NumSystemSGPRs;
81*9880d681SAndroid Build Coastguard Worker 
82*9880d681SAndroid Build Coastguard Worker private:
83*9880d681SAndroid Build Coastguard Worker   bool HasSpilledSGPRs;
84*9880d681SAndroid Build Coastguard Worker   bool HasSpilledVGPRs;
85*9880d681SAndroid Build Coastguard Worker   bool HasNonSpillStackObjects;
86*9880d681SAndroid Build Coastguard Worker   bool HasFlatInstructions;
87*9880d681SAndroid Build Coastguard Worker 
88*9880d681SAndroid Build Coastguard Worker   unsigned NumSpilledSGPRs;
89*9880d681SAndroid Build Coastguard Worker   unsigned NumSpilledVGPRs;
90*9880d681SAndroid Build Coastguard Worker 
91*9880d681SAndroid Build Coastguard Worker   // Feature bits required for inputs passed in user SGPRs.
92*9880d681SAndroid Build Coastguard Worker   bool PrivateSegmentBuffer : 1;
93*9880d681SAndroid Build Coastguard Worker   bool DispatchPtr : 1;
94*9880d681SAndroid Build Coastguard Worker   bool QueuePtr : 1;
95*9880d681SAndroid Build Coastguard Worker   bool DispatchID : 1;
96*9880d681SAndroid Build Coastguard Worker   bool KernargSegmentPtr : 1;
97*9880d681SAndroid Build Coastguard Worker   bool FlatScratchInit : 1;
98*9880d681SAndroid Build Coastguard Worker   bool GridWorkgroupCountX : 1;
99*9880d681SAndroid Build Coastguard Worker   bool GridWorkgroupCountY : 1;
100*9880d681SAndroid Build Coastguard Worker   bool GridWorkgroupCountZ : 1;
101*9880d681SAndroid Build Coastguard Worker 
102*9880d681SAndroid Build Coastguard Worker   // Feature bits required for inputs passed in system SGPRs.
103*9880d681SAndroid Build Coastguard Worker   bool WorkGroupIDX : 1; // Always initialized.
104*9880d681SAndroid Build Coastguard Worker   bool WorkGroupIDY : 1;
105*9880d681SAndroid Build Coastguard Worker   bool WorkGroupIDZ : 1;
106*9880d681SAndroid Build Coastguard Worker   bool WorkGroupInfo : 1;
107*9880d681SAndroid Build Coastguard Worker   bool PrivateSegmentWaveByteOffset : 1;
108*9880d681SAndroid Build Coastguard Worker 
109*9880d681SAndroid Build Coastguard Worker   bool WorkItemIDX : 1; // Always initialized.
110*9880d681SAndroid Build Coastguard Worker   bool WorkItemIDY : 1;
111*9880d681SAndroid Build Coastguard Worker   bool WorkItemIDZ : 1;
112*9880d681SAndroid Build Coastguard Worker 
getNextUserSGPR()113*9880d681SAndroid Build Coastguard Worker   MCPhysReg getNextUserSGPR() const {
114*9880d681SAndroid Build Coastguard Worker     assert(NumSystemSGPRs == 0 && "System SGPRs must be added after user SGPRs");
115*9880d681SAndroid Build Coastguard Worker     return AMDGPU::SGPR0 + NumUserSGPRs;
116*9880d681SAndroid Build Coastguard Worker   }
117*9880d681SAndroid Build Coastguard Worker 
getNextSystemSGPR()118*9880d681SAndroid Build Coastguard Worker   MCPhysReg getNextSystemSGPR() const {
119*9880d681SAndroid Build Coastguard Worker     return AMDGPU::SGPR0 + NumUserSGPRs + NumSystemSGPRs;
120*9880d681SAndroid Build Coastguard Worker   }
121*9880d681SAndroid Build Coastguard Worker 
122*9880d681SAndroid Build Coastguard Worker public:
123*9880d681SAndroid Build Coastguard Worker   struct SpilledReg {
124*9880d681SAndroid Build Coastguard Worker     unsigned VGPR;
125*9880d681SAndroid Build Coastguard Worker     int Lane;
SpilledRegSpilledReg126*9880d681SAndroid Build Coastguard Worker     SpilledReg(unsigned R, int L) : VGPR (R), Lane (L) { }
SpilledRegSpilledReg127*9880d681SAndroid Build Coastguard Worker     SpilledReg() : VGPR(AMDGPU::NoRegister), Lane(-1) { }
hasLaneSpilledReg128*9880d681SAndroid Build Coastguard Worker     bool hasLane() { return Lane != -1;}
hasRegSpilledReg129*9880d681SAndroid Build Coastguard Worker     bool hasReg() { return VGPR != AMDGPU::NoRegister;}
130*9880d681SAndroid Build Coastguard Worker   };
131*9880d681SAndroid Build Coastguard Worker 
132*9880d681SAndroid Build Coastguard Worker   // SIMachineFunctionInfo definition
133*9880d681SAndroid Build Coastguard Worker 
134*9880d681SAndroid Build Coastguard Worker   SIMachineFunctionInfo(const MachineFunction &MF);
135*9880d681SAndroid Build Coastguard Worker   SpilledReg getSpilledReg(MachineFunction *MF, unsigned FrameIndex,
136*9880d681SAndroid Build Coastguard Worker                            unsigned SubIdx);
hasCalculatedTID()137*9880d681SAndroid Build Coastguard Worker   bool hasCalculatedTID() const { return TIDReg != AMDGPU::NoRegister; };
getTIDReg()138*9880d681SAndroid Build Coastguard Worker   unsigned getTIDReg() const { return TIDReg; };
setTIDReg(unsigned Reg)139*9880d681SAndroid Build Coastguard Worker   void setTIDReg(unsigned Reg) { TIDReg = Reg; }
140*9880d681SAndroid Build Coastguard Worker 
141*9880d681SAndroid Build Coastguard Worker   // Add user SGPRs.
142*9880d681SAndroid Build Coastguard Worker   unsigned addPrivateSegmentBuffer(const SIRegisterInfo &TRI);
143*9880d681SAndroid Build Coastguard Worker   unsigned addDispatchPtr(const SIRegisterInfo &TRI);
144*9880d681SAndroid Build Coastguard Worker   unsigned addQueuePtr(const SIRegisterInfo &TRI);
145*9880d681SAndroid Build Coastguard Worker   unsigned addKernargSegmentPtr(const SIRegisterInfo &TRI);
146*9880d681SAndroid Build Coastguard Worker   unsigned addFlatScratchInit(const SIRegisterInfo &TRI);
147*9880d681SAndroid Build Coastguard Worker 
148*9880d681SAndroid Build Coastguard Worker   // Add system SGPRs.
addWorkGroupIDX()149*9880d681SAndroid Build Coastguard Worker   unsigned addWorkGroupIDX() {
150*9880d681SAndroid Build Coastguard Worker     WorkGroupIDXSystemSGPR = getNextSystemSGPR();
151*9880d681SAndroid Build Coastguard Worker     NumSystemSGPRs += 1;
152*9880d681SAndroid Build Coastguard Worker     return WorkGroupIDXSystemSGPR;
153*9880d681SAndroid Build Coastguard Worker   }
154*9880d681SAndroid Build Coastguard Worker 
addWorkGroupIDY()155*9880d681SAndroid Build Coastguard Worker   unsigned addWorkGroupIDY() {
156*9880d681SAndroid Build Coastguard Worker     WorkGroupIDYSystemSGPR = getNextSystemSGPR();
157*9880d681SAndroid Build Coastguard Worker     NumSystemSGPRs += 1;
158*9880d681SAndroid Build Coastguard Worker     return WorkGroupIDYSystemSGPR;
159*9880d681SAndroid Build Coastguard Worker   }
160*9880d681SAndroid Build Coastguard Worker 
addWorkGroupIDZ()161*9880d681SAndroid Build Coastguard Worker   unsigned addWorkGroupIDZ() {
162*9880d681SAndroid Build Coastguard Worker     WorkGroupIDZSystemSGPR = getNextSystemSGPR();
163*9880d681SAndroid Build Coastguard Worker     NumSystemSGPRs += 1;
164*9880d681SAndroid Build Coastguard Worker     return WorkGroupIDZSystemSGPR;
165*9880d681SAndroid Build Coastguard Worker   }
166*9880d681SAndroid Build Coastguard Worker 
addWorkGroupInfo()167*9880d681SAndroid Build Coastguard Worker   unsigned addWorkGroupInfo() {
168*9880d681SAndroid Build Coastguard Worker     WorkGroupInfoSystemSGPR = getNextSystemSGPR();
169*9880d681SAndroid Build Coastguard Worker     NumSystemSGPRs += 1;
170*9880d681SAndroid Build Coastguard Worker     return WorkGroupInfoSystemSGPR;
171*9880d681SAndroid Build Coastguard Worker   }
172*9880d681SAndroid Build Coastguard Worker 
addPrivateSegmentWaveByteOffset()173*9880d681SAndroid Build Coastguard Worker   unsigned addPrivateSegmentWaveByteOffset() {
174*9880d681SAndroid Build Coastguard Worker     PrivateSegmentWaveByteOffsetSystemSGPR = getNextSystemSGPR();
175*9880d681SAndroid Build Coastguard Worker     NumSystemSGPRs += 1;
176*9880d681SAndroid Build Coastguard Worker     return PrivateSegmentWaveByteOffsetSystemSGPR;
177*9880d681SAndroid Build Coastguard Worker   }
178*9880d681SAndroid Build Coastguard Worker 
setPrivateSegmentWaveByteOffset(unsigned Reg)179*9880d681SAndroid Build Coastguard Worker   void setPrivateSegmentWaveByteOffset(unsigned Reg) {
180*9880d681SAndroid Build Coastguard Worker     PrivateSegmentWaveByteOffsetSystemSGPR = Reg;
181*9880d681SAndroid Build Coastguard Worker   }
182*9880d681SAndroid Build Coastguard Worker 
hasPrivateSegmentBuffer()183*9880d681SAndroid Build Coastguard Worker   bool hasPrivateSegmentBuffer() const {
184*9880d681SAndroid Build Coastguard Worker     return PrivateSegmentBuffer;
185*9880d681SAndroid Build Coastguard Worker   }
186*9880d681SAndroid Build Coastguard Worker 
hasDispatchPtr()187*9880d681SAndroid Build Coastguard Worker   bool hasDispatchPtr() const {
188*9880d681SAndroid Build Coastguard Worker     return DispatchPtr;
189*9880d681SAndroid Build Coastguard Worker   }
190*9880d681SAndroid Build Coastguard Worker 
hasQueuePtr()191*9880d681SAndroid Build Coastguard Worker   bool hasQueuePtr() const {
192*9880d681SAndroid Build Coastguard Worker     return QueuePtr;
193*9880d681SAndroid Build Coastguard Worker   }
194*9880d681SAndroid Build Coastguard Worker 
hasDispatchID()195*9880d681SAndroid Build Coastguard Worker   bool hasDispatchID() const {
196*9880d681SAndroid Build Coastguard Worker     return DispatchID;
197*9880d681SAndroid Build Coastguard Worker   }
198*9880d681SAndroid Build Coastguard Worker 
hasKernargSegmentPtr()199*9880d681SAndroid Build Coastguard Worker   bool hasKernargSegmentPtr() const {
200*9880d681SAndroid Build Coastguard Worker     return KernargSegmentPtr;
201*9880d681SAndroid Build Coastguard Worker   }
202*9880d681SAndroid Build Coastguard Worker 
hasFlatScratchInit()203*9880d681SAndroid Build Coastguard Worker   bool hasFlatScratchInit() const {
204*9880d681SAndroid Build Coastguard Worker     return FlatScratchInit;
205*9880d681SAndroid Build Coastguard Worker   }
206*9880d681SAndroid Build Coastguard Worker 
hasGridWorkgroupCountX()207*9880d681SAndroid Build Coastguard Worker   bool hasGridWorkgroupCountX() const {
208*9880d681SAndroid Build Coastguard Worker     return GridWorkgroupCountX;
209*9880d681SAndroid Build Coastguard Worker   }
210*9880d681SAndroid Build Coastguard Worker 
hasGridWorkgroupCountY()211*9880d681SAndroid Build Coastguard Worker   bool hasGridWorkgroupCountY() const {
212*9880d681SAndroid Build Coastguard Worker     return GridWorkgroupCountY;
213*9880d681SAndroid Build Coastguard Worker   }
214*9880d681SAndroid Build Coastguard Worker 
hasGridWorkgroupCountZ()215*9880d681SAndroid Build Coastguard Worker   bool hasGridWorkgroupCountZ() const {
216*9880d681SAndroid Build Coastguard Worker     return GridWorkgroupCountZ;
217*9880d681SAndroid Build Coastguard Worker   }
218*9880d681SAndroid Build Coastguard Worker 
hasWorkGroupIDX()219*9880d681SAndroid Build Coastguard Worker   bool hasWorkGroupIDX() const {
220*9880d681SAndroid Build Coastguard Worker     return WorkGroupIDX;
221*9880d681SAndroid Build Coastguard Worker   }
222*9880d681SAndroid Build Coastguard Worker 
hasWorkGroupIDY()223*9880d681SAndroid Build Coastguard Worker   bool hasWorkGroupIDY() const {
224*9880d681SAndroid Build Coastguard Worker     return WorkGroupIDY;
225*9880d681SAndroid Build Coastguard Worker   }
226*9880d681SAndroid Build Coastguard Worker 
hasWorkGroupIDZ()227*9880d681SAndroid Build Coastguard Worker   bool hasWorkGroupIDZ() const {
228*9880d681SAndroid Build Coastguard Worker     return WorkGroupIDZ;
229*9880d681SAndroid Build Coastguard Worker   }
230*9880d681SAndroid Build Coastguard Worker 
hasWorkGroupInfo()231*9880d681SAndroid Build Coastguard Worker   bool hasWorkGroupInfo() const {
232*9880d681SAndroid Build Coastguard Worker     return WorkGroupInfo;
233*9880d681SAndroid Build Coastguard Worker   }
234*9880d681SAndroid Build Coastguard Worker 
hasPrivateSegmentWaveByteOffset()235*9880d681SAndroid Build Coastguard Worker   bool hasPrivateSegmentWaveByteOffset() const {
236*9880d681SAndroid Build Coastguard Worker     return PrivateSegmentWaveByteOffset;
237*9880d681SAndroid Build Coastguard Worker   }
238*9880d681SAndroid Build Coastguard Worker 
hasWorkItemIDX()239*9880d681SAndroid Build Coastguard Worker   bool hasWorkItemIDX() const {
240*9880d681SAndroid Build Coastguard Worker     return WorkItemIDX;
241*9880d681SAndroid Build Coastguard Worker   }
242*9880d681SAndroid Build Coastguard Worker 
hasWorkItemIDY()243*9880d681SAndroid Build Coastguard Worker   bool hasWorkItemIDY() const {
244*9880d681SAndroid Build Coastguard Worker     return WorkItemIDY;
245*9880d681SAndroid Build Coastguard Worker   }
246*9880d681SAndroid Build Coastguard Worker 
hasWorkItemIDZ()247*9880d681SAndroid Build Coastguard Worker   bool hasWorkItemIDZ() const {
248*9880d681SAndroid Build Coastguard Worker     return WorkItemIDZ;
249*9880d681SAndroid Build Coastguard Worker   }
250*9880d681SAndroid Build Coastguard Worker 
getNumUserSGPRs()251*9880d681SAndroid Build Coastguard Worker   unsigned getNumUserSGPRs() const {
252*9880d681SAndroid Build Coastguard Worker     return NumUserSGPRs;
253*9880d681SAndroid Build Coastguard Worker   }
254*9880d681SAndroid Build Coastguard Worker 
getNumPreloadedSGPRs()255*9880d681SAndroid Build Coastguard Worker   unsigned getNumPreloadedSGPRs() const {
256*9880d681SAndroid Build Coastguard Worker     return NumUserSGPRs + NumSystemSGPRs;
257*9880d681SAndroid Build Coastguard Worker   }
258*9880d681SAndroid Build Coastguard Worker 
getPrivateSegmentWaveByteOffsetSystemSGPR()259*9880d681SAndroid Build Coastguard Worker   unsigned getPrivateSegmentWaveByteOffsetSystemSGPR() const {
260*9880d681SAndroid Build Coastguard Worker     return PrivateSegmentWaveByteOffsetSystemSGPR;
261*9880d681SAndroid Build Coastguard Worker   }
262*9880d681SAndroid Build Coastguard Worker 
263*9880d681SAndroid Build Coastguard Worker   /// \brief Returns the physical register reserved for use as the resource
264*9880d681SAndroid Build Coastguard Worker   /// descriptor for scratch accesses.
getScratchRSrcReg()265*9880d681SAndroid Build Coastguard Worker   unsigned getScratchRSrcReg() const {
266*9880d681SAndroid Build Coastguard Worker     return ScratchRSrcReg;
267*9880d681SAndroid Build Coastguard Worker   }
268*9880d681SAndroid Build Coastguard Worker 
setScratchRSrcReg(unsigned Reg)269*9880d681SAndroid Build Coastguard Worker   void setScratchRSrcReg(unsigned Reg) {
270*9880d681SAndroid Build Coastguard Worker     assert(Reg != AMDGPU::NoRegister && "Should never be unset");
271*9880d681SAndroid Build Coastguard Worker     ScratchRSrcReg = Reg;
272*9880d681SAndroid Build Coastguard Worker   }
273*9880d681SAndroid Build Coastguard Worker 
getScratchWaveOffsetReg()274*9880d681SAndroid Build Coastguard Worker   unsigned getScratchWaveOffsetReg() const {
275*9880d681SAndroid Build Coastguard Worker     return ScratchWaveOffsetReg;
276*9880d681SAndroid Build Coastguard Worker   }
277*9880d681SAndroid Build Coastguard Worker 
setScratchWaveOffsetReg(unsigned Reg)278*9880d681SAndroid Build Coastguard Worker   void setScratchWaveOffsetReg(unsigned Reg) {
279*9880d681SAndroid Build Coastguard Worker     assert(Reg != AMDGPU::NoRegister && "Should never be unset");
280*9880d681SAndroid Build Coastguard Worker     ScratchWaveOffsetReg = Reg;
281*9880d681SAndroid Build Coastguard Worker   }
282*9880d681SAndroid Build Coastguard Worker 
getQueuePtrUserSGPR()283*9880d681SAndroid Build Coastguard Worker   unsigned getQueuePtrUserSGPR() const {
284*9880d681SAndroid Build Coastguard Worker     return QueuePtrUserSGPR;
285*9880d681SAndroid Build Coastguard Worker   }
286*9880d681SAndroid Build Coastguard Worker 
hasSpilledSGPRs()287*9880d681SAndroid Build Coastguard Worker   bool hasSpilledSGPRs() const {
288*9880d681SAndroid Build Coastguard Worker     return HasSpilledSGPRs;
289*9880d681SAndroid Build Coastguard Worker   }
290*9880d681SAndroid Build Coastguard Worker 
291*9880d681SAndroid Build Coastguard Worker   void setHasSpilledSGPRs(bool Spill = true) {
292*9880d681SAndroid Build Coastguard Worker     HasSpilledSGPRs = Spill;
293*9880d681SAndroid Build Coastguard Worker   }
294*9880d681SAndroid Build Coastguard Worker 
hasSpilledVGPRs()295*9880d681SAndroid Build Coastguard Worker   bool hasSpilledVGPRs() const {
296*9880d681SAndroid Build Coastguard Worker     return HasSpilledVGPRs;
297*9880d681SAndroid Build Coastguard Worker   }
298*9880d681SAndroid Build Coastguard Worker 
299*9880d681SAndroid Build Coastguard Worker   void setHasSpilledVGPRs(bool Spill = true) {
300*9880d681SAndroid Build Coastguard Worker     HasSpilledVGPRs = Spill;
301*9880d681SAndroid Build Coastguard Worker   }
302*9880d681SAndroid Build Coastguard Worker 
hasNonSpillStackObjects()303*9880d681SAndroid Build Coastguard Worker   bool hasNonSpillStackObjects() const {
304*9880d681SAndroid Build Coastguard Worker     return HasNonSpillStackObjects;
305*9880d681SAndroid Build Coastguard Worker   }
306*9880d681SAndroid Build Coastguard Worker 
307*9880d681SAndroid Build Coastguard Worker   void setHasNonSpillStackObjects(bool StackObject = true) {
308*9880d681SAndroid Build Coastguard Worker     HasNonSpillStackObjects = StackObject;
309*9880d681SAndroid Build Coastguard Worker   }
310*9880d681SAndroid Build Coastguard Worker 
hasFlatInstructions()311*9880d681SAndroid Build Coastguard Worker   bool hasFlatInstructions() const {
312*9880d681SAndroid Build Coastguard Worker     return HasFlatInstructions;
313*9880d681SAndroid Build Coastguard Worker   }
314*9880d681SAndroid Build Coastguard Worker 
315*9880d681SAndroid Build Coastguard Worker   void setHasFlatInstructions(bool UseFlat = true) {
316*9880d681SAndroid Build Coastguard Worker     HasFlatInstructions = UseFlat;
317*9880d681SAndroid Build Coastguard Worker   }
318*9880d681SAndroid Build Coastguard Worker 
getNumSpilledSGPRs()319*9880d681SAndroid Build Coastguard Worker   unsigned getNumSpilledSGPRs() const {
320*9880d681SAndroid Build Coastguard Worker     return NumSpilledSGPRs;
321*9880d681SAndroid Build Coastguard Worker   }
322*9880d681SAndroid Build Coastguard Worker 
getNumSpilledVGPRs()323*9880d681SAndroid Build Coastguard Worker   unsigned getNumSpilledVGPRs() const {
324*9880d681SAndroid Build Coastguard Worker     return NumSpilledVGPRs;
325*9880d681SAndroid Build Coastguard Worker   }
326*9880d681SAndroid Build Coastguard Worker 
addToSpilledSGPRs(unsigned num)327*9880d681SAndroid Build Coastguard Worker   void addToSpilledSGPRs(unsigned num) {
328*9880d681SAndroid Build Coastguard Worker     NumSpilledSGPRs += num;
329*9880d681SAndroid Build Coastguard Worker   }
330*9880d681SAndroid Build Coastguard Worker 
addToSpilledVGPRs(unsigned num)331*9880d681SAndroid Build Coastguard Worker   void addToSpilledVGPRs(unsigned num) {
332*9880d681SAndroid Build Coastguard Worker     NumSpilledVGPRs += num;
333*9880d681SAndroid Build Coastguard Worker   }
334*9880d681SAndroid Build Coastguard Worker 
getPSInputAddr()335*9880d681SAndroid Build Coastguard Worker   unsigned getPSInputAddr() const {
336*9880d681SAndroid Build Coastguard Worker     return PSInputAddr;
337*9880d681SAndroid Build Coastguard Worker   }
338*9880d681SAndroid Build Coastguard Worker 
isPSInputAllocated(unsigned Index)339*9880d681SAndroid Build Coastguard Worker   bool isPSInputAllocated(unsigned Index) const {
340*9880d681SAndroid Build Coastguard Worker     return PSInputAddr & (1 << Index);
341*9880d681SAndroid Build Coastguard Worker   }
342*9880d681SAndroid Build Coastguard Worker 
markPSInputAllocated(unsigned Index)343*9880d681SAndroid Build Coastguard Worker   void markPSInputAllocated(unsigned Index) {
344*9880d681SAndroid Build Coastguard Worker     PSInputAddr |= 1 << Index;
345*9880d681SAndroid Build Coastguard Worker   }
346*9880d681SAndroid Build Coastguard Worker 
returnsVoid()347*9880d681SAndroid Build Coastguard Worker   bool returnsVoid() const {
348*9880d681SAndroid Build Coastguard Worker     return ReturnsVoid;
349*9880d681SAndroid Build Coastguard Worker   }
350*9880d681SAndroid Build Coastguard Worker 
setIfReturnsVoid(bool Value)351*9880d681SAndroid Build Coastguard Worker   void setIfReturnsVoid(bool Value) {
352*9880d681SAndroid Build Coastguard Worker     ReturnsVoid = Value;
353*9880d681SAndroid Build Coastguard Worker   }
354*9880d681SAndroid Build Coastguard Worker 
355*9880d681SAndroid Build Coastguard Worker   /// \returns Number of reserved VGPRs for debugger usage.
getDebuggerReservedVGPRCount()356*9880d681SAndroid Build Coastguard Worker   unsigned getDebuggerReservedVGPRCount() const {
357*9880d681SAndroid Build Coastguard Worker     return DebuggerReservedVGPRCount;
358*9880d681SAndroid Build Coastguard Worker   }
359*9880d681SAndroid Build Coastguard Worker 
360*9880d681SAndroid Build Coastguard Worker   /// \returns Stack object index for \p Dim's work group ID.
getDebuggerWorkGroupIDStackObjectIndex(unsigned Dim)361*9880d681SAndroid Build Coastguard Worker   int getDebuggerWorkGroupIDStackObjectIndex(unsigned Dim) const {
362*9880d681SAndroid Build Coastguard Worker     assert(Dim < 3);
363*9880d681SAndroid Build Coastguard Worker     return DebuggerWorkGroupIDStackObjectIndices[Dim];
364*9880d681SAndroid Build Coastguard Worker   }
365*9880d681SAndroid Build Coastguard Worker 
366*9880d681SAndroid Build Coastguard Worker   /// \brief Sets stack object index for \p Dim's work group ID to \p ObjectIdx.
setDebuggerWorkGroupIDStackObjectIndex(unsigned Dim,int ObjectIdx)367*9880d681SAndroid Build Coastguard Worker   void setDebuggerWorkGroupIDStackObjectIndex(unsigned Dim, int ObjectIdx) {
368*9880d681SAndroid Build Coastguard Worker     assert(Dim < 3);
369*9880d681SAndroid Build Coastguard Worker     DebuggerWorkGroupIDStackObjectIndices[Dim] = ObjectIdx;
370*9880d681SAndroid Build Coastguard Worker   }
371*9880d681SAndroid Build Coastguard Worker 
372*9880d681SAndroid Build Coastguard Worker   /// \returns Stack object index for \p Dim's work item ID.
getDebuggerWorkItemIDStackObjectIndex(unsigned Dim)373*9880d681SAndroid Build Coastguard Worker   int getDebuggerWorkItemIDStackObjectIndex(unsigned Dim) const {
374*9880d681SAndroid Build Coastguard Worker     assert(Dim < 3);
375*9880d681SAndroid Build Coastguard Worker     return DebuggerWorkItemIDStackObjectIndices[Dim];
376*9880d681SAndroid Build Coastguard Worker   }
377*9880d681SAndroid Build Coastguard Worker 
378*9880d681SAndroid Build Coastguard Worker   /// \brief Sets stack object index for \p Dim's work item ID to \p ObjectIdx.
setDebuggerWorkItemIDStackObjectIndex(unsigned Dim,int ObjectIdx)379*9880d681SAndroid Build Coastguard Worker   void setDebuggerWorkItemIDStackObjectIndex(unsigned Dim, int ObjectIdx) {
380*9880d681SAndroid Build Coastguard Worker     assert(Dim < 3);
381*9880d681SAndroid Build Coastguard Worker     DebuggerWorkItemIDStackObjectIndices[Dim] = ObjectIdx;
382*9880d681SAndroid Build Coastguard Worker   }
383*9880d681SAndroid Build Coastguard Worker 
384*9880d681SAndroid Build Coastguard Worker   /// \returns SGPR used for \p Dim's work group ID.
getWorkGroupIDSGPR(unsigned Dim)385*9880d681SAndroid Build Coastguard Worker   unsigned getWorkGroupIDSGPR(unsigned Dim) const {
386*9880d681SAndroid Build Coastguard Worker     switch (Dim) {
387*9880d681SAndroid Build Coastguard Worker     case 0:
388*9880d681SAndroid Build Coastguard Worker       assert(hasWorkGroupIDX());
389*9880d681SAndroid Build Coastguard Worker       return WorkGroupIDXSystemSGPR;
390*9880d681SAndroid Build Coastguard Worker     case 1:
391*9880d681SAndroid Build Coastguard Worker       assert(hasWorkGroupIDY());
392*9880d681SAndroid Build Coastguard Worker       return WorkGroupIDYSystemSGPR;
393*9880d681SAndroid Build Coastguard Worker     case 2:
394*9880d681SAndroid Build Coastguard Worker       assert(hasWorkGroupIDZ());
395*9880d681SAndroid Build Coastguard Worker       return WorkGroupIDZSystemSGPR;
396*9880d681SAndroid Build Coastguard Worker     }
397*9880d681SAndroid Build Coastguard Worker     llvm_unreachable("unexpected dimension");
398*9880d681SAndroid Build Coastguard Worker   }
399*9880d681SAndroid Build Coastguard Worker 
400*9880d681SAndroid Build Coastguard Worker   /// \returns VGPR used for \p Dim' work item ID.
getWorkItemIDVGPR(unsigned Dim)401*9880d681SAndroid Build Coastguard Worker   unsigned getWorkItemIDVGPR(unsigned Dim) const {
402*9880d681SAndroid Build Coastguard Worker     switch (Dim) {
403*9880d681SAndroid Build Coastguard Worker     case 0:
404*9880d681SAndroid Build Coastguard Worker       assert(hasWorkItemIDX());
405*9880d681SAndroid Build Coastguard Worker       return AMDGPU::VGPR0;
406*9880d681SAndroid Build Coastguard Worker     case 1:
407*9880d681SAndroid Build Coastguard Worker       assert(hasWorkItemIDY());
408*9880d681SAndroid Build Coastguard Worker       return AMDGPU::VGPR1;
409*9880d681SAndroid Build Coastguard Worker     case 2:
410*9880d681SAndroid Build Coastguard Worker       assert(hasWorkItemIDZ());
411*9880d681SAndroid Build Coastguard Worker       return AMDGPU::VGPR2;
412*9880d681SAndroid Build Coastguard Worker     }
413*9880d681SAndroid Build Coastguard Worker     llvm_unreachable("unexpected dimension");
414*9880d681SAndroid Build Coastguard Worker   }
415*9880d681SAndroid Build Coastguard Worker 
416*9880d681SAndroid Build Coastguard Worker   unsigned getMaximumWorkGroupSize(const MachineFunction &MF) const;
417*9880d681SAndroid Build Coastguard Worker };
418*9880d681SAndroid Build Coastguard Worker 
419*9880d681SAndroid Build Coastguard Worker } // End namespace llvm
420*9880d681SAndroid Build Coastguard Worker 
421*9880d681SAndroid Build Coastguard Worker #endif
422