R600/SI: Add VI versions of MUBUF atomics
[oota-llvm.git] / lib / Target / R600 / 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 "llvm/ADT/StringExtras.h"
24 #include "llvm/ADT/StringRef.h"
25 #include "llvm/IR/DataLayout.h"
26 #include "llvm/Target/TargetSubtargetInfo.h"
27
28 #define GET_SUBTARGETINFO_HEADER
29 #include "AMDGPUGenSubtargetInfo.inc"
30
31 namespace llvm {
32
33 class SIMachineFunctionInfo;
34
35 class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
36
37 public:
38   enum Generation {
39     R600 = 0,
40     R700,
41     EVERGREEN,
42     NORTHERN_ISLANDS,
43     SOUTHERN_ISLANDS,
44     SEA_ISLANDS,
45     VOLCANIC_ISLANDS,
46   };
47
48 private:
49   std::string DevName;
50   bool Is64bit;
51   bool DumpCode;
52   bool R600ALUInst;
53   bool HasVertexCache;
54   short TexVTXClauseSize;
55   Generation Gen;
56   bool FP64;
57   bool FP64Denormals;
58   bool FP32Denormals;
59   bool CaymanISA;
60   bool FlatAddressSpace;
61   bool EnableIRStructurizer;
62   bool EnablePromoteAlloca;
63   bool EnableIfCvt;
64   bool EnableLoadStoreOpt;
65   unsigned WavefrontSize;
66   bool CFALUBug;
67   int LocalMemorySize;
68   bool EnableVGPRSpilling;
69
70   DataLayout DL;
71   AMDGPUFrameLowering FrameLowering;
72   std::unique_ptr<AMDGPUTargetLowering> TLInfo;
73   std::unique_ptr<AMDGPUInstrInfo> InstrInfo;
74   InstrItineraryData InstrItins;
75   Triple TargetTriple;
76
77 public:
78   AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS, TargetMachine &TM);
79   AMDGPUSubtarget &initializeSubtargetDependencies(StringRef GPU, StringRef FS);
80
81   // FIXME: This routine needs to go away. See comments in
82   // AMDGPUTargetMachine.h.
83   const DataLayout *getDataLayout() const { return &DL; }
84
85   const AMDGPUFrameLowering *getFrameLowering() const override {
86     return &FrameLowering;
87   }
88   const AMDGPUInstrInfo *getInstrInfo() const override {
89     return InstrInfo.get();
90   }
91   const AMDGPURegisterInfo *getRegisterInfo() const override {
92     return &InstrInfo->getRegisterInfo();
93   }
94   AMDGPUTargetLowering *getTargetLowering() const override {
95     return TLInfo.get();
96   }
97   const InstrItineraryData *getInstrItineraryData() const override {
98     return &InstrItins;
99   }
100
101   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
102
103   bool is64bit() const {
104     return Is64bit;
105   }
106
107   bool hasVertexCache() const {
108     return HasVertexCache;
109   }
110
111   short getTexVTXClauseSize() const {
112     return TexVTXClauseSize;
113   }
114
115   Generation getGeneration() const {
116     return Gen;
117   }
118
119   bool hasHWFP64() const {
120     return FP64;
121   }
122
123   bool hasCaymanISA() const {
124     return CaymanISA;
125   }
126
127   bool hasFP32Denormals() const {
128     return FP32Denormals;
129   }
130
131   bool hasFP64Denormals() const {
132     return FP64Denormals;
133   }
134
135   bool hasFlatAddressSpace() const {
136     return FlatAddressSpace;
137   }
138
139   bool hasBFE() const {
140     return (getGeneration() >= EVERGREEN);
141   }
142
143   bool hasBFI() const {
144     return (getGeneration() >= EVERGREEN);
145   }
146
147   bool hasBFM() const {
148     return hasBFE();
149   }
150
151   bool hasBCNT(unsigned Size) const {
152     if (Size == 32)
153       return (getGeneration() >= EVERGREEN);
154
155     if (Size == 64)
156       return (getGeneration() >= SOUTHERN_ISLANDS);
157
158     return false;
159   }
160
161   bool hasMulU24() const {
162     return (getGeneration() >= EVERGREEN);
163   }
164
165   bool hasMulI24() const {
166     return (getGeneration() >= SOUTHERN_ISLANDS ||
167             hasCaymanISA());
168   }
169
170   bool hasFFBL() const {
171     return (getGeneration() >= EVERGREEN);
172   }
173
174   bool hasFFBH() const {
175     return (getGeneration() >= EVERGREEN);
176   }
177
178   bool IsIRStructurizerEnabled() const {
179     return EnableIRStructurizer;
180   }
181
182   bool isPromoteAllocaEnabled() const {
183     return EnablePromoteAlloca;
184   }
185
186   bool isIfCvtEnabled() const {
187     return EnableIfCvt;
188   }
189
190   bool loadStoreOptEnabled() const {
191     return EnableLoadStoreOpt;
192   }
193
194   unsigned getWavefrontSize() const {
195     return WavefrontSize;
196   }
197
198   unsigned getStackEntrySize() const;
199
200   bool hasCFAluBug() const {
201     assert(getGeneration() <= NORTHERN_ISLANDS);
202     return CFALUBug;
203   }
204
205   int getLocalMemorySize() const {
206     return LocalMemorySize;
207   }
208
209   unsigned getAmdKernelCodeChipID() const;
210
211   bool enableMachineScheduler() const override {
212     return getGeneration() <= NORTHERN_ISLANDS;
213   }
214
215   // Helper functions to simplify if statements
216   bool isTargetELF() const {
217     return false;
218   }
219
220   StringRef getDeviceName() const {
221     return DevName;
222   }
223
224   bool dumpCode() const {
225     return DumpCode;
226   }
227   bool r600ALUEncoding() const {
228     return R600ALUInst;
229   }
230   bool isAmdHsaOS() const {
231     return TargetTriple.getOS() == Triple::AMDHSA;
232   }
233   bool isVGPRSpillingEnabled(const SIMachineFunctionInfo *MFI) const;
234 };
235
236 } // End namespace llvm
237
238 #endif