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