AMDGPU: add +xnack feature
[oota-llvm.git] / lib / Target / AMDGPU / AMDGPU.td
1 //===-- AMDGPU.td - AMDGPU Tablegen files ------------------*- tablegen -*-===//
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 include "llvm/Target/Target.td"
11
12 //===----------------------------------------------------------------------===//
13 // Subtarget Features
14 //===----------------------------------------------------------------------===//
15
16 // Debugging Features
17
18 def FeatureDumpCode : SubtargetFeature <"DumpCode",
19         "DumpCode",
20         "true",
21         "Dump MachineInstrs in the CodeEmitter">;
22
23 def FeatureDumpCodeLower : SubtargetFeature <"dumpcode",
24         "DumpCode",
25         "true",
26         "Dump MachineInstrs in the CodeEmitter">;
27
28 def FeatureIRStructurizer : SubtargetFeature <"disable-irstructurizer",
29         "EnableIRStructurizer",
30         "false",
31         "Disable IR Structurizer">;
32
33 def FeaturePromoteAlloca : SubtargetFeature <"promote-alloca",
34         "EnablePromoteAlloca",
35         "true",
36         "Enable promote alloca pass">;
37
38 // Target features
39
40 def FeatureIfCvt : SubtargetFeature <"disable-ifcvt",
41         "EnableIfCvt",
42         "false",
43         "Disable the if conversion pass">;
44
45 def FeatureFP64 : SubtargetFeature<"fp64",
46         "FP64",
47         "true",
48         "Enable double precision operations">;
49
50 def FeatureFP64Denormals : SubtargetFeature<"fp64-denormals",
51         "FP64Denormals",
52         "true",
53         "Enable double precision denormal handling",
54         [FeatureFP64]>;
55
56 def FeatureFastFMAF32 : SubtargetFeature<"fast-fmaf",
57         "FastFMAF32",
58         "true",
59         "Assuming f32 fma is at least as fast as mul + add",
60         []>;
61
62 // Some instructions do not support denormals despite this flag. Using
63 // fp32 denormals also causes instructions to run at the double
64 // precision rate for the device.
65 def FeatureFP32Denormals : SubtargetFeature<"fp32-denormals",
66         "FP32Denormals",
67         "true",
68         "Enable single precision denormal handling">;
69
70 def Feature64BitPtr : SubtargetFeature<"64BitPtr",
71         "Is64bit",
72         "true",
73         "Specify if 64-bit addressing should be used">;
74
75 def FeatureR600ALUInst : SubtargetFeature<"R600ALUInst",
76         "R600ALUInst",
77         "false",
78         "Older version of ALU instructions encoding">;
79
80 def FeatureVertexCache : SubtargetFeature<"HasVertexCache",
81         "HasVertexCache",
82         "true",
83         "Specify use of dedicated vertex cache">;
84
85 def FeatureCaymanISA : SubtargetFeature<"caymanISA",
86         "CaymanISA",
87         "true",
88         "Use Cayman ISA">;
89
90 def FeatureCFALUBug : SubtargetFeature<"cfalubug",
91         "CFALUBug",
92         "true",
93         "GPU has CF_ALU bug">;
94
95 // XXX - This should probably be removed once enabled by default
96 def FeatureEnableLoadStoreOpt : SubtargetFeature <"load-store-opt",
97         "EnableLoadStoreOpt",
98         "true",
99         "Enable SI load/store optimizer pass">;
100
101 // Performance debugging feature. Allow using DS instruction immediate
102 // offsets even if the base pointer can't be proven to be base. On SI,
103 // base pointer values that won't give the same result as a 16-bit add
104 // are not safe to fold, but this will override the conservative test
105 // for the base pointer.
106 def FeatureEnableUnsafeDSOffsetFolding : SubtargetFeature <"unsafe-ds-offset-folding",
107         "EnableUnsafeDSOffsetFolding",
108         "true",
109         "Force using DS instruction immediate offsets on SI">;
110
111 def FeatureFlatForGlobal : SubtargetFeature<"flat-for-global",
112         "FlatForGlobal",
113         "true",
114         "Force to generate flat instruction for global">;
115
116 def FeatureFlatAddressSpace : SubtargetFeature<"flat-address-space",
117         "FlatAddressSpace",
118         "true",
119         "Support flat address space">;
120
121 def FeatureXNACK : SubtargetFeature<"xnack",
122         "EnableXNACK",
123         "true",
124         "Enable XNACK support">;
125
126 def FeatureVGPRSpilling : SubtargetFeature<"vgpr-spilling",
127         "EnableVGPRSpilling",
128         "true",
129         "Enable spilling of VGPRs to scratch memory">;
130
131 def FeatureSGPRInitBug : SubtargetFeature<"sgpr-init-bug",
132         "SGPRInitBug",
133         "true",
134         "VI SGPR initilization bug requiring a fixed SGPR allocation size">;
135
136 def FeatureEnableHugeScratchBuffer : SubtargetFeature<"huge-scratch-buffer",
137         "EnableHugeScratchBuffer",
138         "true",
139         "Enable scratch buffer sizes greater than 128 GB">;
140
141 class SubtargetFeatureFetchLimit <string Value> :
142                           SubtargetFeature <"fetch"#Value,
143         "TexVTXClauseSize",
144         Value,
145         "Limit the maximum number of fetches in a clause to "#Value>;
146
147 def FeatureFetchLimit8 : SubtargetFeatureFetchLimit <"8">;
148 def FeatureFetchLimit16 : SubtargetFeatureFetchLimit <"16">;
149
150 class SubtargetFeatureWavefrontSize <int Value> : SubtargetFeature<
151         "wavefrontsize"#Value,
152         "WavefrontSize",
153         !cast<string>(Value),
154         "The number of threads per wavefront">;
155
156 def FeatureWavefrontSize16 : SubtargetFeatureWavefrontSize<16>;
157 def FeatureWavefrontSize32 : SubtargetFeatureWavefrontSize<32>;
158 def FeatureWavefrontSize64 : SubtargetFeatureWavefrontSize<64>;
159
160 class SubtargetFeatureLDSBankCount <int Value> : SubtargetFeature <
161       "ldsbankcount"#Value,
162       "LDSBankCount",
163       !cast<string>(Value),
164       "The number of LDS banks per compute unit.">;
165
166 def FeatureLDSBankCount16 : SubtargetFeatureLDSBankCount<16>;
167 def FeatureLDSBankCount32 : SubtargetFeatureLDSBankCount<32>;
168
169 class SubtargetFeatureISAVersion <int Major, int Minor, int Stepping>
170                                  : SubtargetFeature <
171       "isaver"#Major#"."#Minor#"."#Stepping,
172       "IsaVersion",
173       "ISAVersion"#Major#"_"#Minor#"_"#Stepping,
174       "Instruction set version number"
175 >;
176
177 def FeatureISAVersion7_0_0 : SubtargetFeatureISAVersion <7,0,0>;
178 def FeatureISAVersion7_0_1 : SubtargetFeatureISAVersion <7,0,1>;
179 def FeatureISAVersion8_0_0 : SubtargetFeatureISAVersion <8,0,0>;
180 def FeatureISAVersion8_0_1 : SubtargetFeatureISAVersion <8,0,1>;
181
182 class SubtargetFeatureLocalMemorySize <int Value> : SubtargetFeature<
183         "localmemorysize"#Value,
184         "LocalMemorySize",
185         !cast<string>(Value),
186         "The size of local memory in bytes">;
187
188 def FeatureGCN : SubtargetFeature<"gcn",
189         "IsGCN",
190         "true",
191         "GCN or newer GPU">;
192
193 def FeatureGCN1Encoding : SubtargetFeature<"gcn1-encoding",
194         "GCN1Encoding",
195         "true",
196         "Encoding format for SI and CI">;
197
198 def FeatureGCN3Encoding : SubtargetFeature<"gcn3-encoding",
199         "GCN3Encoding",
200         "true",
201         "Encoding format for VI">;
202
203 def FeatureCIInsts : SubtargetFeature<"ci-insts",
204         "CIInsts",
205         "true",
206         "Additional intstructions for CI+">;
207
208 // Dummy feature used to disable assembler instructions.
209 def FeatureDisable : SubtargetFeature<"",
210                                       "FeatureDisable","true",
211                                       "Dummy feature to disable assembler"
212                                       " instructions">;
213
214 class SubtargetFeatureGeneration <string Value,
215                                   list<SubtargetFeature> Implies> :
216         SubtargetFeature <Value, "Gen", "AMDGPUSubtarget::"#Value,
217                           Value#" GPU generation", Implies>;
218
219 def FeatureLocalMemorySize0 : SubtargetFeatureLocalMemorySize<0>;
220 def FeatureLocalMemorySize32768 : SubtargetFeatureLocalMemorySize<32768>;
221 def FeatureLocalMemorySize65536 : SubtargetFeatureLocalMemorySize<65536>;
222
223 def FeatureR600 : SubtargetFeatureGeneration<"R600",
224         [FeatureR600ALUInst, FeatureFetchLimit8, FeatureLocalMemorySize0]>;
225
226 def FeatureR700 : SubtargetFeatureGeneration<"R700",
227         [FeatureFetchLimit16, FeatureLocalMemorySize0]>;
228
229 def FeatureEvergreen : SubtargetFeatureGeneration<"EVERGREEN",
230         [FeatureFetchLimit16, FeatureLocalMemorySize32768]>;
231
232 def FeatureNorthernIslands : SubtargetFeatureGeneration<"NORTHERN_ISLANDS",
233         [FeatureFetchLimit16, FeatureWavefrontSize64,
234          FeatureLocalMemorySize32768]
235 >;
236
237 def FeatureSouthernIslands : SubtargetFeatureGeneration<"SOUTHERN_ISLANDS",
238         [Feature64BitPtr, FeatureFP64, FeatureLocalMemorySize32768,
239          FeatureWavefrontSize64, FeatureGCN, FeatureGCN1Encoding,
240          FeatureLDSBankCount32]>;
241
242 def FeatureSeaIslands : SubtargetFeatureGeneration<"SEA_ISLANDS",
243         [Feature64BitPtr, FeatureFP64, FeatureLocalMemorySize65536,
244          FeatureWavefrontSize64, FeatureGCN, FeatureFlatAddressSpace,
245          FeatureGCN1Encoding, FeatureCIInsts]>;
246
247 def FeatureVolcanicIslands : SubtargetFeatureGeneration<"VOLCANIC_ISLANDS",
248         [Feature64BitPtr, FeatureFP64, FeatureLocalMemorySize65536,
249          FeatureWavefrontSize64, FeatureFlatAddressSpace, FeatureGCN,
250          FeatureGCN3Encoding, FeatureCIInsts, FeatureLDSBankCount32]>;
251
252 //===----------------------------------------------------------------------===//
253
254 def AMDGPUInstrInfo : InstrInfo {
255   let guessInstructionProperties = 1;
256   let noNamedPositionallyEncodedOperands = 1;
257 }
258
259 def AMDGPUAsmParser : AsmParser {
260   // Some of the R600 registers have the same name, so this crashes.
261   // For example T0_XYZW and T0_XY both have the asm name T0.
262   let ShouldEmitMatchRegisterName = 0;
263 }
264
265 def AMDGPU : Target {
266   // Pull in Instruction Info:
267   let InstructionSet = AMDGPUInstrInfo;
268   let AssemblyParsers = [AMDGPUAsmParser];
269 }
270
271 // Dummy Instruction itineraries for pseudo instructions
272 def ALU_NULL : FuncUnit;
273 def NullALU : InstrItinClass;
274
275 //===----------------------------------------------------------------------===//
276 // Predicate helper class
277 //===----------------------------------------------------------------------===//
278
279 def TruePredicate : Predicate<"true">;
280 def isSICI : Predicate<
281   "Subtarget->getGeneration() == AMDGPUSubtarget::SOUTHERN_ISLANDS ||"
282   "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS"
283 >, AssemblerPredicate<"FeatureGCN1Encoding">;
284
285 def isVI : Predicate <
286   "Subtarget->getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS">,
287   AssemblerPredicate<"FeatureGCN3Encoding">;
288
289 class PredicateControl {
290   Predicate SubtargetPredicate;
291   Predicate SIAssemblerPredicate = isSICI;
292   Predicate VIAssemblerPredicate = isVI;
293   list<Predicate> AssemblerPredicates = [];
294   Predicate AssemblerPredicate = TruePredicate;
295   list<Predicate> OtherPredicates = [];
296   list<Predicate> Predicates = !listconcat([SubtargetPredicate, AssemblerPredicate],
297                                             AssemblerPredicates,
298                                             OtherPredicates);
299 }
300
301 // Include AMDGPU TD files
302 include "R600Schedule.td"
303 include "SISchedule.td"
304 include "Processors.td"
305 include "AMDGPUInstrInfo.td"
306 include "AMDGPUIntrinsics.td"
307 include "AMDGPURegisterInfo.td"
308 include "AMDGPUInstructions.td"
309 include "AMDGPUCallingConv.td"