]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/Target/AMDGPU/AMDGPUSubtarget.h
Vendor import of llvm release_38 branch r260756:
[FreeBSD/FreeBSD.git] / lib / Target / AMDGPU / AMDGPUSubtarget.h
1 //=====-- AMDGPUSubtarget.h - Define Subtarget for AMDGPU ------*- 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 AMDGPU specific subclass of TargetSubtarget.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
16 #define LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
17
18 #include "AMDGPU.h"
19 #include "AMDGPUFrameLowering.h"
20 #include "AMDGPUInstrInfo.h"
21 #include "AMDGPUISelLowering.h"
22 #include "AMDGPUSubtarget.h"
23 #include "Utils/AMDGPUBaseInfo.h"
24 #include "llvm/ADT/StringRef.h"
25 #include "llvm/Target/TargetSubtargetInfo.h"
26
27 #define GET_SUBTARGETINFO_HEADER
28 #include "AMDGPUGenSubtargetInfo.inc"
29
30 namespace llvm {
31
32 class SIMachineFunctionInfo;
33
34 class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
35
36 public:
37   enum Generation {
38     R600 = 0,
39     R700,
40     EVERGREEN,
41     NORTHERN_ISLANDS,
42     SOUTHERN_ISLANDS,
43     SEA_ISLANDS,
44     VOLCANIC_ISLANDS,
45   };
46
47   enum {
48     FIXED_SGPR_COUNT_FOR_INIT_BUG = 80
49   };
50
51   enum {
52     ISAVersion0_0_0,
53     ISAVersion7_0_0,
54     ISAVersion7_0_1,
55     ISAVersion8_0_0,
56     ISAVersion8_0_1,
57     ISAVersion8_0_3
58   };
59
60 private:
61   std::string DevName;
62   bool Is64bit;
63   bool DumpCode;
64   bool R600ALUInst;
65   bool HasVertexCache;
66   short TexVTXClauseSize;
67   Generation Gen;
68   bool FP64;
69   bool FP64Denormals;
70   bool FP32Denormals;
71   bool FastFMAF32;
72   bool CaymanISA;
73   bool FlatAddressSpace;
74   bool FlatForGlobal;
75   bool EnableIRStructurizer;
76   bool EnablePromoteAlloca;
77   bool EnableIfCvt;
78   bool EnableLoadStoreOpt;
79   bool EnableUnsafeDSOffsetFolding;
80   bool EnableXNACK;
81   unsigned WavefrontSize;
82   bool CFALUBug;
83   int LocalMemorySize;
84   bool EnableVGPRSpilling;
85   bool SGPRInitBug;
86   bool IsGCN;
87   bool GCN1Encoding;
88   bool GCN3Encoding;
89   bool CIInsts;
90   bool FeatureDisable;
91   int LDSBankCount;
92   unsigned IsaVersion;
93   bool EnableHugeScratchBuffer;
94   bool EnableSIScheduler;
95
96   std::unique_ptr<AMDGPUFrameLowering> FrameLowering;
97   std::unique_ptr<AMDGPUTargetLowering> TLInfo;
98   std::unique_ptr<AMDGPUInstrInfo> InstrInfo;
99   InstrItineraryData InstrItins;
100   Triple TargetTriple;
101
102 public:
103   AMDGPUSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
104                   TargetMachine &TM);
105   AMDGPUSubtarget &initializeSubtargetDependencies(const Triple &TT,
106                                                    StringRef GPU, StringRef FS);
107
108   const AMDGPUFrameLowering *getFrameLowering() const override {
109     return FrameLowering.get();
110   }
111   const AMDGPUInstrInfo *getInstrInfo() const override {
112     return InstrInfo.get();
113   }
114   const AMDGPURegisterInfo *getRegisterInfo() const override {
115     return &InstrInfo->getRegisterInfo();
116   }
117   AMDGPUTargetLowering *getTargetLowering() const override {
118     return TLInfo.get();
119   }
120   const InstrItineraryData *getInstrItineraryData() const override {
121     return &InstrItins;
122   }
123
124   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
125
126   bool is64bit() const {
127     return Is64bit;
128   }
129
130   bool hasVertexCache() const {
131     return HasVertexCache;
132   }
133
134   short getTexVTXClauseSize() const {
135     return TexVTXClauseSize;
136   }
137
138   Generation getGeneration() const {
139     return Gen;
140   }
141
142   bool hasHWFP64() const {
143     return FP64;
144   }
145
146   bool hasCaymanISA() const {
147     return CaymanISA;
148   }
149
150   bool hasFP32Denormals() const {
151     return FP32Denormals;
152   }
153
154   bool hasFP64Denormals() const {
155     return FP64Denormals;
156   }
157
158   bool hasFastFMAF32() const {
159     return FastFMAF32;
160   }
161
162   bool hasFlatAddressSpace() const {
163     return FlatAddressSpace;
164   }
165
166   bool useFlatForGlobal() const {
167     return FlatForGlobal;
168   }
169
170   bool hasBFE() const {
171     return (getGeneration() >= EVERGREEN);
172   }
173
174   bool hasBFI() const {
175     return (getGeneration() >= EVERGREEN);
176   }
177
178   bool hasBFM() const {
179     return hasBFE();
180   }
181
182   bool hasBCNT(unsigned Size) const {
183     if (Size == 32)
184       return (getGeneration() >= EVERGREEN);
185
186     if (Size == 64)
187       return (getGeneration() >= SOUTHERN_ISLANDS);
188
189     return false;
190   }
191
192   bool hasMulU24() const {
193     return (getGeneration() >= EVERGREEN);
194   }
195
196   bool hasMulI24() const {
197     return (getGeneration() >= SOUTHERN_ISLANDS ||
198             hasCaymanISA());
199   }
200
201   bool hasFFBL() const {
202     return (getGeneration() >= EVERGREEN);
203   }
204
205   bool hasFFBH() const {
206     return (getGeneration() >= EVERGREEN);
207   }
208
209   bool hasCARRY() const {
210     return (getGeneration() >= EVERGREEN);
211   }
212
213   bool hasBORROW() const {
214     return (getGeneration() >= EVERGREEN);
215   }
216
217   bool IsIRStructurizerEnabled() const {
218     return EnableIRStructurizer;
219   }
220
221   bool isPromoteAllocaEnabled() const {
222     return EnablePromoteAlloca;
223   }
224
225   bool isIfCvtEnabled() const {
226     return EnableIfCvt;
227   }
228
229   bool loadStoreOptEnabled() const {
230     return EnableLoadStoreOpt;
231   }
232
233   bool unsafeDSOffsetFoldingEnabled() const {
234     return EnableUnsafeDSOffsetFolding;
235   }
236
237   unsigned getWavefrontSize() const {
238     return WavefrontSize;
239   }
240
241   unsigned getStackEntrySize() const;
242
243   bool hasCFAluBug() const {
244     assert(getGeneration() <= NORTHERN_ISLANDS);
245     return CFALUBug;
246   }
247
248   int getLocalMemorySize() const {
249     return LocalMemorySize;
250   }
251
252   bool hasSGPRInitBug() const {
253     return SGPRInitBug;
254   }
255
256   int getLDSBankCount() const {
257     return LDSBankCount;
258   }
259
260   unsigned getAmdKernelCodeChipID() const;
261
262   AMDGPU::IsaVersion getIsaVersion() const;
263
264   bool enableMachineScheduler() const override {
265     return true;
266   }
267
268   void overrideSchedPolicy(MachineSchedPolicy &Policy,
269                            MachineInstr *begin, MachineInstr *end,
270                            unsigned NumRegionInstrs) const override;
271
272   // Helper functions to simplify if statements
273   bool isTargetELF() const {
274     return false;
275   }
276
277   StringRef getDeviceName() const {
278     return DevName;
279   }
280
281   bool enableHugeScratchBuffer() const {
282     return EnableHugeScratchBuffer;
283   }
284
285   bool enableSIScheduler() const {
286     return EnableSIScheduler;
287   }
288
289   bool dumpCode() const {
290     return DumpCode;
291   }
292   bool r600ALUEncoding() const {
293     return R600ALUInst;
294   }
295   bool isAmdHsaOS() const {
296     return TargetTriple.getOS() == Triple::AMDHSA;
297   }
298   bool isVGPRSpillingEnabled(const SIMachineFunctionInfo *MFI) const;
299
300   bool isXNACKEnabled() const {
301     return EnableXNACK;
302   }
303
304   unsigned getMaxWavesPerCU() const {
305     if (getGeneration() >= AMDGPUSubtarget::SOUTHERN_ISLANDS)
306       return 10;
307
308     // FIXME: Not sure what this is for other subtagets.
309     llvm_unreachable("do not know max waves per CU for this subtarget.");
310   }
311
312   bool enableSubRegLiveness() const override {
313     return true;
314   }
315
316   /// \brief Returns the offset in bytes from the start of the input buffer
317   ///        of the first explicit kernel argument.
318   unsigned getExplicitKernelArgOffset() const {
319     return isAmdHsaOS() ? 0 : 36;
320   }
321
322   unsigned getMaxNumUserSGPRs() const {
323     return 16;
324   }
325 };
326
327 } // End namespace llvm
328
329 #endif