AMDGPU: Add llvm.amdgcn.dispatch.ptr intrinsic
[oota-llvm.git] / lib / Target / AMDGPU / SIMachineFunctionInfo.h
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
15 #ifndef LLVM_LIB_TARGET_R600_SIMACHINEFUNCTIONINFO_H
16 #define LLVM_LIB_TARGET_R600_SIMACHINEFUNCTIONINFO_H
17
18 #include "AMDGPUMachineFunction.h"
19 #include "SIRegisterInfo.h"
20 #include <map>
21
22 namespace llvm {
23
24 class MachineRegisterInfo;
25
26 /// This class keeps track of the SPI_SP_INPUT_ADDR config register, which
27 /// tells the hardware which interpolation parameters to load.
28 class SIMachineFunctionInfo : public AMDGPUMachineFunction {
29   void anchor() override;
30
31   unsigned TIDReg;
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:
43   bool HasSpilledSGPRs;
44   bool HasSpilledVGPRs;
45
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;
55
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:
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
74   // SIMachineFunctionInfo definition
75
76   SIMachineFunctionInfo(const MachineFunction &MF);
77   SpilledReg getSpilledReg(MachineFunction *MF, unsigned FrameIndex,
78                            unsigned SubIdx);
79   bool hasCalculatedTID() const { return TIDReg != AMDGPU::NoRegister; };
80   unsigned getTIDReg() const { return TIDReg; };
81   void setTIDReg(unsigned Reg) { TIDReg = Reg; }
82
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
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   }
166
167   unsigned getMaximumWorkGroupSize(const MachineFunction &MF) const;
168 };
169
170 } // End namespace llvm
171
172
173 #endif