blob: 145fadcee744d1f2be8c42124a6ff14393134404 [file] [log] [blame]
Matt Arsenault382d9452016-01-26 04:49:22 +00001//===-- AMDGPU.td - AMDGPU Tablegen files --------*- tablegen -*-===//
Tom Stellard75aadc22012-12-11 21:25:42 +00002//
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//
Matt Arsenault382d9452016-01-26 04:49:22 +00008//===------------------------------------------------------------===//
Tom Stellard75aadc22012-12-11 21:25:42 +00009
Tom Stellardbc5b5372014-06-13 16:38:59 +000010include "llvm/Target/Target.td"
Tom Stellard75aadc22012-12-11 21:25:42 +000011
Matt Arsenault382d9452016-01-26 04:49:22 +000012//===------------------------------------------------------------===//
13// Subtarget Features (device properties)
14//===------------------------------------------------------------===//
Tom Stellard783893a2013-11-18 19:43:33 +000015
Matt Arsenaultf5e29972014-06-20 06:50:05 +000016def FeatureFP64 : SubtargetFeature<"fp64",
Matt Arsenault382d9452016-01-26 04:49:22 +000017 "FP64",
18 "true",
19 "Enable double precision operations"
20>;
Matt Arsenaultf171cf22014-07-14 23:40:49 +000021
Matt Arsenaultb035a572015-01-29 19:34:25 +000022def FeatureFastFMAF32 : SubtargetFeature<"fast-fmaf",
Matt Arsenault382d9452016-01-26 04:49:22 +000023 "FastFMAF32",
24 "true",
25 "Assuming f32 fma is at least as fast as mul + add"
26>;
Matt Arsenaultb035a572015-01-29 19:34:25 +000027
Matt Arsenaulte83690c2016-01-18 21:13:50 +000028def HalfRate64Ops : SubtargetFeature<"half-rate-64-ops",
Matt Arsenault382d9452016-01-26 04:49:22 +000029 "HalfRate64Ops",
30 "true",
31 "Most fp64 instructions are half rate instead of quarter"
32>;
Matt Arsenaultf171cf22014-07-14 23:40:49 +000033
Tom Stellard99792772013-06-07 20:28:49 +000034def FeatureR600ALUInst : SubtargetFeature<"R600ALUInst",
Matt Arsenault382d9452016-01-26 04:49:22 +000035 "R600ALUInst",
36 "false",
37 "Older version of ALU instructions encoding"
38>;
Tom Stellard99792772013-06-07 20:28:49 +000039
40def FeatureVertexCache : SubtargetFeature<"HasVertexCache",
Matt Arsenault382d9452016-01-26 04:49:22 +000041 "HasVertexCache",
42 "true",
43 "Specify use of dedicated vertex cache"
44>;
Tom Stellard99792772013-06-07 20:28:49 +000045
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000046def FeatureCaymanISA : SubtargetFeature<"caymanISA",
Matt Arsenault382d9452016-01-26 04:49:22 +000047 "CaymanISA",
48 "true",
49 "Use Cayman ISA"
50>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000051
Tom Stellard348273d2014-01-23 16:18:02 +000052def FeatureCFALUBug : SubtargetFeature<"cfalubug",
Matt Arsenault382d9452016-01-26 04:49:22 +000053 "CFALUBug",
54 "true",
55 "GPU has CF_ALU bug"
56>;
Changpeng Fangb41574a2015-12-22 20:55:23 +000057
Matt Arsenault3f981402014-09-15 15:41:53 +000058def FeatureFlatAddressSpace : SubtargetFeature<"flat-address-space",
Matt Arsenault382d9452016-01-26 04:49:22 +000059 "FlatAddressSpace",
60 "true",
61 "Support flat address space"
62>;
Matt Arsenault3f981402014-09-15 15:41:53 +000063
Nicolai Haehnle5b504972016-01-04 23:35:53 +000064def FeatureXNACK : SubtargetFeature<"xnack",
Matt Arsenault382d9452016-01-26 04:49:22 +000065 "EnableXNACK",
66 "true",
67 "Enable XNACK support"
68>;
Tom Stellarde99fb652015-01-20 19:33:04 +000069
Marek Olsak4d00dd22015-03-09 15:48:09 +000070def FeatureSGPRInitBug : SubtargetFeature<"sgpr-init-bug",
Matt Arsenault382d9452016-01-26 04:49:22 +000071 "SGPRInitBug",
72 "true",
73 "VI SGPR initilization bug requiring a fixed SGPR allocation size"
74>;
Tom Stellardde008d32016-01-21 04:28:34 +000075
Tom Stellard3498e4f2013-06-07 20:28:55 +000076class SubtargetFeatureFetchLimit <string Value> :
77 SubtargetFeature <"fetch"#Value,
Matt Arsenault382d9452016-01-26 04:49:22 +000078 "TexVTXClauseSize",
79 Value,
80 "Limit the maximum number of fetches in a clause to "#Value
81>;
Tom Stellard99792772013-06-07 20:28:49 +000082
Tom Stellard3498e4f2013-06-07 20:28:55 +000083def FeatureFetchLimit8 : SubtargetFeatureFetchLimit <"8">;
84def FeatureFetchLimit16 : SubtargetFeatureFetchLimit <"16">;
85
Tom Stellard8c347b02014-01-22 21:55:40 +000086class SubtargetFeatureWavefrontSize <int Value> : SubtargetFeature<
Matt Arsenault382d9452016-01-26 04:49:22 +000087 "wavefrontsize"#Value,
88 "WavefrontSize",
89 !cast<string>(Value),
90 "The number of threads per wavefront"
91>;
Tom Stellard8c347b02014-01-22 21:55:40 +000092
93def FeatureWavefrontSize16 : SubtargetFeatureWavefrontSize<16>;
94def FeatureWavefrontSize32 : SubtargetFeatureWavefrontSize<32>;
95def FeatureWavefrontSize64 : SubtargetFeatureWavefrontSize<64>;
96
Tom Stellardec87f842015-05-25 16:15:54 +000097class SubtargetFeatureLDSBankCount <int Value> : SubtargetFeature <
Matt Arsenault382d9452016-01-26 04:49:22 +000098 "ldsbankcount"#Value,
99 "LDSBankCount",
100 !cast<string>(Value),
101 "The number of LDS banks per compute unit."
102>;
Tom Stellardec87f842015-05-25 16:15:54 +0000103
104def FeatureLDSBankCount16 : SubtargetFeatureLDSBankCount<16>;
105def FeatureLDSBankCount32 : SubtargetFeatureLDSBankCount<32>;
106
Tom Stellard347ac792015-06-26 21:15:07 +0000107class SubtargetFeatureISAVersion <int Major, int Minor, int Stepping>
108 : SubtargetFeature <
Matt Arsenault382d9452016-01-26 04:49:22 +0000109 "isaver"#Major#"."#Minor#"."#Stepping,
110 "IsaVersion",
111 "ISAVersion"#Major#"_"#Minor#"_"#Stepping,
112 "Instruction set version number"
Tom Stellard347ac792015-06-26 21:15:07 +0000113>;
114
115def FeatureISAVersion7_0_0 : SubtargetFeatureISAVersion <7,0,0>;
116def FeatureISAVersion7_0_1 : SubtargetFeatureISAVersion <7,0,1>;
117def FeatureISAVersion8_0_0 : SubtargetFeatureISAVersion <8,0,0>;
118def FeatureISAVersion8_0_1 : SubtargetFeatureISAVersion <8,0,1>;
Changpeng Fangc16be002016-01-13 20:39:25 +0000119def FeatureISAVersion8_0_3 : SubtargetFeatureISAVersion <8,0,3>;
Tom Stellard347ac792015-06-26 21:15:07 +0000120
Tom Stellard880a80a2014-06-17 16:53:14 +0000121class SubtargetFeatureLocalMemorySize <int Value> : SubtargetFeature<
Matt Arsenault382d9452016-01-26 04:49:22 +0000122 "localmemorysize"#Value,
123 "LocalMemorySize",
124 !cast<string>(Value),
125 "The size of local memory in bytes"
126>;
Tom Stellard880a80a2014-06-17 16:53:14 +0000127
Tom Stellardd7e6f132015-04-08 01:09:26 +0000128def FeatureGCN : SubtargetFeature<"gcn",
Matt Arsenault382d9452016-01-26 04:49:22 +0000129 "IsGCN",
130 "true",
131 "GCN or newer GPU"
132>;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000133
134def FeatureGCN1Encoding : SubtargetFeature<"gcn1-encoding",
Matt Arsenault382d9452016-01-26 04:49:22 +0000135 "GCN1Encoding",
136 "true",
137 "Encoding format for SI and CI"
138>;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000139
140def FeatureGCN3Encoding : SubtargetFeature<"gcn3-encoding",
Matt Arsenault382d9452016-01-26 04:49:22 +0000141 "GCN3Encoding",
142 "true",
143 "Encoding format for VI"
144>;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000145
146def FeatureCIInsts : SubtargetFeature<"ci-insts",
Matt Arsenault382d9452016-01-26 04:49:22 +0000147 "CIInsts",
148 "true",
149 "Additional intstructions for CI+"
150>;
151
Matt Arsenault61738cb2016-02-27 08:53:46 +0000152def FeatureVIInsts : SubtargetFeature<"vi-insts",
153 "VIInsts",
154 "true",
155 "Additional intstructions for VI+"
156>;
157
Matt Arsenault382d9452016-01-26 04:49:22 +0000158//===------------------------------------------------------------===//
159// Subtarget Features (options and debugging)
160//===------------------------------------------------------------===//
161
162// Some instructions do not support denormals despite this flag. Using
163// fp32 denormals also causes instructions to run at the double
164// precision rate for the device.
165def FeatureFP32Denormals : SubtargetFeature<"fp32-denormals",
166 "FP32Denormals",
167 "true",
168 "Enable single precision denormal handling"
169>;
170
171def FeatureFP64Denormals : SubtargetFeature<"fp64-denormals",
172 "FP64Denormals",
173 "true",
174 "Enable double precision denormal handling",
175 [FeatureFP64]
176>;
177
Matt Arsenaultf639c322016-01-28 20:53:42 +0000178def FeatureFPExceptions : SubtargetFeature<"fp-exceptions",
179 "FPExceptions",
180 "true",
181 "Enable floating point exceptions"
182>;
183
Matt Arsenault24ee0782016-02-12 02:40:47 +0000184class FeatureMaxPrivateElementSize<int size> : SubtargetFeature<
185 "max-private-element-size-"#size,
186 "MaxPrivateElementSize",
187 !cast<string>(size),
188 "Maximum private access size may be "#size
189>;
190
191def FeatureMaxPrivateElementSize4 : FeatureMaxPrivateElementSize<4>;
192def FeatureMaxPrivateElementSize8 : FeatureMaxPrivateElementSize<8>;
193def FeatureMaxPrivateElementSize16 : FeatureMaxPrivateElementSize<16>;
194
195
Matt Arsenault382d9452016-01-26 04:49:22 +0000196def FeatureEnableHugeScratchBuffer : SubtargetFeature<
197 "huge-scratch-buffer",
198 "EnableHugeScratchBuffer",
199 "true",
200 "Enable scratch buffer sizes greater than 128 GB"
201>;
202
203def FeatureVGPRSpilling : SubtargetFeature<"vgpr-spilling",
204 "EnableVGPRSpilling",
205 "true",
206 "Enable spilling of VGPRs to scratch memory"
207>;
208
209def FeatureDumpCode : SubtargetFeature <"DumpCode",
210 "DumpCode",
211 "true",
212 "Dump MachineInstrs in the CodeEmitter"
213>;
214
215def FeatureDumpCodeLower : SubtargetFeature <"dumpcode",
216 "DumpCode",
217 "true",
218 "Dump MachineInstrs in the CodeEmitter"
219>;
220
221def FeatureIRStructurizer : SubtargetFeature <"disable-irstructurizer",
222 "EnableIRStructurizer",
223 "false",
224 "Disable IR Structurizer"
225>;
226
227def FeaturePromoteAlloca : SubtargetFeature <"promote-alloca",
228 "EnablePromoteAlloca",
229 "true",
230 "Enable promote alloca pass"
231>;
232
233// XXX - This should probably be removed once enabled by default
234def FeatureEnableLoadStoreOpt : SubtargetFeature <"load-store-opt",
235 "EnableLoadStoreOpt",
236 "true",
237 "Enable SI load/store optimizer pass"
238>;
239
240// Performance debugging feature. Allow using DS instruction immediate
241// offsets even if the base pointer can't be proven to be base. On SI,
242// base pointer values that won't give the same result as a 16-bit add
243// are not safe to fold, but this will override the conservative test
244// for the base pointer.
245def FeatureEnableUnsafeDSOffsetFolding : SubtargetFeature <
246 "unsafe-ds-offset-folding",
247 "EnableUnsafeDSOffsetFolding",
248 "true",
249 "Force using DS instruction immediate offsets on SI"
250>;
251
252def FeatureIfCvt : SubtargetFeature <"disable-ifcvt",
253 "EnableIfCvt",
254 "false",
255 "Disable the if conversion pass"
256>;
257
258def FeatureEnableSIScheduler : SubtargetFeature<"si-scheduler",
259 "EnableSIScheduler",
260 "true",
261 "Enable SI Machine Scheduler"
262>;
263
264def FeatureFlatForGlobal : SubtargetFeature<"flat-for-global",
265 "FlatForGlobal",
266 "true",
267 "Force to generate flat instruction for global"
268>;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000269
270// Dummy feature used to disable assembler instructions.
271def FeatureDisable : SubtargetFeature<"",
Matt Arsenault382d9452016-01-26 04:49:22 +0000272 "FeatureDisable","true",
273 "Dummy feature to disable assembler instructions"
274>;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000275
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000276class SubtargetFeatureGeneration <string Value,
277 list<SubtargetFeature> Implies> :
278 SubtargetFeature <Value, "Gen", "AMDGPUSubtarget::"#Value,
279 Value#" GPU generation", Implies>;
280
Tom Stellard880a80a2014-06-17 16:53:14 +0000281def FeatureLocalMemorySize0 : SubtargetFeatureLocalMemorySize<0>;
282def FeatureLocalMemorySize32768 : SubtargetFeatureLocalMemorySize<32768>;
283def FeatureLocalMemorySize65536 : SubtargetFeatureLocalMemorySize<65536>;
284
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000285def FeatureR600 : SubtargetFeatureGeneration<"R600",
Matt Arsenault382d9452016-01-26 04:49:22 +0000286 [FeatureR600ALUInst, FeatureFetchLimit8, FeatureLocalMemorySize0]
287>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000288
289def FeatureR700 : SubtargetFeatureGeneration<"R700",
Matt Arsenault382d9452016-01-26 04:49:22 +0000290 [FeatureFetchLimit16, FeatureLocalMemorySize0]
291>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000292
293def FeatureEvergreen : SubtargetFeatureGeneration<"EVERGREEN",
Matt Arsenault382d9452016-01-26 04:49:22 +0000294 [FeatureFetchLimit16, FeatureLocalMemorySize32768]
295>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000296
297def FeatureNorthernIslands : SubtargetFeatureGeneration<"NORTHERN_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000298 [FeatureFetchLimit16, FeatureWavefrontSize64,
299 FeatureLocalMemorySize32768]
Tom Stellard880a80a2014-06-17 16:53:14 +0000300>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000301
302def FeatureSouthernIslands : SubtargetFeatureGeneration<"SOUTHERN_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000303 [FeatureFP64, FeatureLocalMemorySize32768,
304 FeatureWavefrontSize64, FeatureGCN, FeatureGCN1Encoding,
305 FeatureLDSBankCount32]
306>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000307
Tom Stellard6e1ee472013-10-29 16:37:28 +0000308def FeatureSeaIslands : SubtargetFeatureGeneration<"SEA_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000309 [FeatureFP64, FeatureLocalMemorySize65536,
310 FeatureWavefrontSize64, FeatureGCN, FeatureFlatAddressSpace,
311 FeatureGCN1Encoding, FeatureCIInsts]
312>;
Marek Olsak5df00d62014-12-07 12:18:57 +0000313
314def FeatureVolcanicIslands : SubtargetFeatureGeneration<"VOLCANIC_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000315 [FeatureFP64, FeatureLocalMemorySize65536,
316 FeatureWavefrontSize64, FeatureFlatAddressSpace, FeatureGCN,
Matt Arsenault61738cb2016-02-27 08:53:46 +0000317 FeatureGCN3Encoding, FeatureCIInsts, FeatureVIInsts]
Matt Arsenault382d9452016-01-26 04:49:22 +0000318>;
Marek Olsak5df00d62014-12-07 12:18:57 +0000319
Tom Stellard3498e4f2013-06-07 20:28:55 +0000320//===----------------------------------------------------------------------===//
Tom Stellard75aadc22012-12-11 21:25:42 +0000321
322def AMDGPUInstrInfo : InstrInfo {
323 let guessInstructionProperties = 1;
Matt Arsenault1ecac062015-02-18 02:15:32 +0000324 let noNamedPositionallyEncodedOperands = 1;
Tom Stellard75aadc22012-12-11 21:25:42 +0000325}
326
Tom Stellard9d7ddd52014-11-14 14:08:00 +0000327def AMDGPUAsmParser : AsmParser {
328 // Some of the R600 registers have the same name, so this crashes.
329 // For example T0_XYZW and T0_XY both have the asm name T0.
330 let ShouldEmitMatchRegisterName = 0;
331}
332
Tom Stellard75aadc22012-12-11 21:25:42 +0000333def AMDGPU : Target {
334 // Pull in Instruction Info:
335 let InstructionSet = AMDGPUInstrInfo;
Tom Stellard9d7ddd52014-11-14 14:08:00 +0000336 let AssemblyParsers = [AMDGPUAsmParser];
Tom Stellard75aadc22012-12-11 21:25:42 +0000337}
338
Tom Stellardbc5b5372014-06-13 16:38:59 +0000339// Dummy Instruction itineraries for pseudo instructions
340def ALU_NULL : FuncUnit;
341def NullALU : InstrItinClass;
342
Tom Stellard0e70de52014-05-16 20:56:45 +0000343//===----------------------------------------------------------------------===//
344// Predicate helper class
345//===----------------------------------------------------------------------===//
346
Tom Stellardd1f0f022015-04-23 19:33:54 +0000347def TruePredicate : Predicate<"true">;
Matt Arsenault382d9452016-01-26 04:49:22 +0000348
Tom Stellardd1f0f022015-04-23 19:33:54 +0000349def isSICI : Predicate<
350 "Subtarget->getGeneration() == AMDGPUSubtarget::SOUTHERN_ISLANDS ||"
351 "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS"
352>, AssemblerPredicate<"FeatureGCN1Encoding">;
353
Tom Stellard5ebdfbe2015-12-24 03:18:18 +0000354def isVI : Predicate <
355 "Subtarget->getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS">,
356 AssemblerPredicate<"FeatureGCN3Encoding">;
357
Matt Arsenault382d9452016-01-26 04:49:22 +0000358def isCIVI : Predicate <
359 "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS || "
360 "Subtarget->getGeneration() == AMDGPUSubtarget::VOLCANIC_ISLANDS"
361>, AssemblerPredicate<"FeatureCIInsts">;
362
363def HasFlatAddressSpace : Predicate<"Subtarget->hasFlatAddressSpace()">;
364
Tom Stellard0e70de52014-05-16 20:56:45 +0000365class PredicateControl {
366 Predicate SubtargetPredicate;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000367 Predicate SIAssemblerPredicate = isSICI;
Tom Stellard5ebdfbe2015-12-24 03:18:18 +0000368 Predicate VIAssemblerPredicate = isVI;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000369 list<Predicate> AssemblerPredicates = [];
Tom Stellardd1f0f022015-04-23 19:33:54 +0000370 Predicate AssemblerPredicate = TruePredicate;
Tom Stellard0e70de52014-05-16 20:56:45 +0000371 list<Predicate> OtherPredicates = [];
Tom Stellardd1f0f022015-04-23 19:33:54 +0000372 list<Predicate> Predicates = !listconcat([SubtargetPredicate, AssemblerPredicate],
Tom Stellardd7e6f132015-04-08 01:09:26 +0000373 AssemblerPredicates,
Tom Stellard0e70de52014-05-16 20:56:45 +0000374 OtherPredicates);
375}
376
Tom Stellard75aadc22012-12-11 21:25:42 +0000377// Include AMDGPU TD files
378include "R600Schedule.td"
379include "SISchedule.td"
380include "Processors.td"
381include "AMDGPUInstrInfo.td"
382include "AMDGPUIntrinsics.td"
383include "AMDGPURegisterInfo.td"
384include "AMDGPUInstructions.td"
Christian Konig2c8f6d52013-03-07 09:03:52 +0000385include "AMDGPUCallingConv.td"