blob: e70d0560715bc8b3dba620032fab759b73316863 [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
Matt Arsenaultacdc7652017-05-10 21:19:05 +000064def FeatureFlatInstOffsets : SubtargetFeature<"flat-inst-offsets",
65 "FlatInstOffsets",
66 "true",
67 "Flat instructions have immediate offset addressing mode"
68>;
69
70def FeatureFlatGlobalInsts : SubtargetFeature<"flat-global-insts",
71 "FlatGlobalInsts",
72 "true",
73 "Have global_* flat memory instructions"
74>;
75
76def FeatureFlatScratchInsts : SubtargetFeature<"flat-scratch-insts",
77 "FlatScratchInsts",
78 "true",
79 "Have scratch_* flat memory instructions"
80>;
81
Matt Arsenaultc37fe662017-07-20 17:42:47 +000082def FeatureAddNoCarryInsts : SubtargetFeature<"add-no-carry-insts",
83 "AddNoCarryInsts",
84 "true",
85 "Have VALU add/sub instructions without carry out"
86>;
87
Matt Arsenault7f681ac2016-07-01 23:03:44 +000088def FeatureUnalignedBufferAccess : SubtargetFeature<"unaligned-buffer-access",
89 "UnalignedBufferAccess",
90 "true",
91 "Support unaligned global loads and stores"
92>;
93
Wei Ding205bfdb2017-02-10 02:15:29 +000094def FeatureTrapHandler: SubtargetFeature<"trap-handler",
95 "TrapHandler",
96 "true",
97 "Trap handler support"
98>;
99
Tom Stellard64a9d082016-10-14 18:10:39 +0000100def FeatureUnalignedScratchAccess : SubtargetFeature<"unaligned-scratch-access",
101 "UnalignedScratchAccess",
102 "true",
103 "Support unaligned scratch loads and stores"
104>;
105
Matt Arsenaulte823d922017-02-18 18:29:53 +0000106def FeatureApertureRegs : SubtargetFeature<"aperture-regs",
107 "HasApertureRegs",
108 "true",
109 "Has Memory Aperture Base and Size Registers"
110>;
111
Marek Olsak0f55fba2016-12-09 19:49:54 +0000112// XNACK is disabled if SH_MEM_CONFIG.ADDRESS_MODE = GPUVM on chips that support
113// XNACK. The current default kernel driver setting is:
114// - graphics ring: XNACK disabled
115// - compute ring: XNACK enabled
116//
117// If XNACK is enabled, the VMEM latency can be worse.
118// If XNACK is disabled, the 2 SGPRs can be used for general purposes.
Nicolai Haehnle5b504972016-01-04 23:35:53 +0000119def FeatureXNACK : SubtargetFeature<"xnack",
Matt Arsenault382d9452016-01-26 04:49:22 +0000120 "EnableXNACK",
121 "true",
122 "Enable XNACK support"
123>;
Tom Stellarde99fb652015-01-20 19:33:04 +0000124
Marek Olsak4d00dd22015-03-09 15:48:09 +0000125def FeatureSGPRInitBug : SubtargetFeature<"sgpr-init-bug",
Matt Arsenault382d9452016-01-26 04:49:22 +0000126 "SGPRInitBug",
127 "true",
128 "VI SGPR initilization bug requiring a fixed SGPR allocation size"
129>;
Tom Stellardde008d32016-01-21 04:28:34 +0000130
Tom Stellard3498e4f2013-06-07 20:28:55 +0000131class SubtargetFeatureFetchLimit <string Value> :
132 SubtargetFeature <"fetch"#Value,
Matt Arsenault382d9452016-01-26 04:49:22 +0000133 "TexVTXClauseSize",
134 Value,
135 "Limit the maximum number of fetches in a clause to "#Value
136>;
Tom Stellard99792772013-06-07 20:28:49 +0000137
Tom Stellard3498e4f2013-06-07 20:28:55 +0000138def FeatureFetchLimit8 : SubtargetFeatureFetchLimit <"8">;
139def FeatureFetchLimit16 : SubtargetFeatureFetchLimit <"16">;
140
Tom Stellard8c347b02014-01-22 21:55:40 +0000141class SubtargetFeatureWavefrontSize <int Value> : SubtargetFeature<
Matt Arsenault382d9452016-01-26 04:49:22 +0000142 "wavefrontsize"#Value,
143 "WavefrontSize",
144 !cast<string>(Value),
145 "The number of threads per wavefront"
146>;
Tom Stellard8c347b02014-01-22 21:55:40 +0000147
148def FeatureWavefrontSize16 : SubtargetFeatureWavefrontSize<16>;
149def FeatureWavefrontSize32 : SubtargetFeatureWavefrontSize<32>;
150def FeatureWavefrontSize64 : SubtargetFeatureWavefrontSize<64>;
151
Tom Stellardec87f842015-05-25 16:15:54 +0000152class SubtargetFeatureLDSBankCount <int Value> : SubtargetFeature <
Matt Arsenault382d9452016-01-26 04:49:22 +0000153 "ldsbankcount"#Value,
154 "LDSBankCount",
155 !cast<string>(Value),
156 "The number of LDS banks per compute unit."
157>;
Tom Stellardec87f842015-05-25 16:15:54 +0000158
159def FeatureLDSBankCount16 : SubtargetFeatureLDSBankCount<16>;
160def FeatureLDSBankCount32 : SubtargetFeatureLDSBankCount<32>;
161
Tom Stellard880a80a2014-06-17 16:53:14 +0000162class SubtargetFeatureLocalMemorySize <int Value> : SubtargetFeature<
Matt Arsenault382d9452016-01-26 04:49:22 +0000163 "localmemorysize"#Value,
164 "LocalMemorySize",
165 !cast<string>(Value),
166 "The size of local memory in bytes"
167>;
Tom Stellard880a80a2014-06-17 16:53:14 +0000168
Tom Stellardd7e6f132015-04-08 01:09:26 +0000169def FeatureGCN : SubtargetFeature<"gcn",
Matt Arsenault382d9452016-01-26 04:49:22 +0000170 "IsGCN",
171 "true",
172 "GCN or newer GPU"
173>;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000174
175def FeatureGCN1Encoding : SubtargetFeature<"gcn1-encoding",
Matt Arsenault382d9452016-01-26 04:49:22 +0000176 "GCN1Encoding",
177 "true",
178 "Encoding format for SI and CI"
179>;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000180
181def FeatureGCN3Encoding : SubtargetFeature<"gcn3-encoding",
Matt Arsenault382d9452016-01-26 04:49:22 +0000182 "GCN3Encoding",
183 "true",
184 "Encoding format for VI"
185>;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000186
187def FeatureCIInsts : SubtargetFeature<"ci-insts",
Matt Arsenault382d9452016-01-26 04:49:22 +0000188 "CIInsts",
189 "true",
190 "Additional intstructions for CI+"
191>;
192
Matt Arsenault2021f082017-02-18 19:12:26 +0000193def FeatureGFX9Insts : SubtargetFeature<"gfx9-insts",
194 "GFX9Insts",
195 "true",
196 "Additional intstructions for GFX9+"
197>;
198
Matt Arsenault9d82ee72016-02-27 08:53:55 +0000199def FeatureSMemRealTime : SubtargetFeature<"s-memrealtime",
200 "HasSMemRealTime",
Matt Arsenault61738cb2016-02-27 08:53:46 +0000201 "true",
Matt Arsenault9d82ee72016-02-27 08:53:55 +0000202 "Has s_memrealtime instruction"
203>;
204
Matt Arsenaultc88ba362016-10-29 04:05:06 +0000205def FeatureInv2PiInlineImm : SubtargetFeature<"inv-2pi-inline-imm",
206 "HasInv2PiInlineImm",
207 "true",
208 "Has 1 / (2 * pi) as inline immediate"
209>;
210
Matt Arsenault9d82ee72016-02-27 08:53:55 +0000211def Feature16BitInsts : SubtargetFeature<"16-bit-insts",
212 "Has16BitInsts",
213 "true",
214 "Has i16/f16 instructions"
Matt Arsenault61738cb2016-02-27 08:53:46 +0000215>;
216
Matt Arsenault9be7b0d2017-02-27 18:49:11 +0000217def FeatureVOP3P : SubtargetFeature<"vop3p",
218 "HasVOP3PInsts",
219 "true",
220 "Has VOP3P packed instructions"
221>;
222
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000223def FeatureMovrel : SubtargetFeature<"movrel",
224 "HasMovrel",
225 "true",
226 "Has v_movrel*_b32 instructions"
227>;
228
229def FeatureVGPRIndexMode : SubtargetFeature<"vgpr-index-mode",
230 "HasVGPRIndexMode",
231 "true",
232 "Has VGPR mode register indexing"
233>;
234
Matt Arsenault7b647552016-10-28 21:55:15 +0000235def FeatureScalarStores : SubtargetFeature<"scalar-stores",
236 "HasScalarStores",
237 "true",
238 "Has store scalar memory instructions"
239>;
240
Sam Kolton07dbde22017-01-20 10:01:25 +0000241def FeatureSDWA : SubtargetFeature<"sdwa",
242 "HasSDWA",
243 "true",
244 "Support SDWA (Sub-DWORD Addressing) extension"
245>;
246
Sam Kolton3c4933f2017-06-22 06:26:41 +0000247def FeatureSDWAOmod : SubtargetFeature<"sdwa-omod",
248 "HasSDWAOmod",
249 "true",
250 "Support OMod with SDWA (Sub-DWORD Addressing) extension"
251>;
252
253def FeatureSDWAScalar : SubtargetFeature<"sdwa-scalar",
254 "HasSDWAScalar",
255 "true",
256 "Support scalar register with SDWA (Sub-DWORD Addressing) extension"
257>;
258
259def FeatureSDWASdst : SubtargetFeature<"sdwa-sdst",
260 "HasSDWASdst",
261 "true",
262 "Support scalar dst for VOPC with SDWA (Sub-DWORD Addressing) extension"
263>;
264
265def FeatureSDWAMac : SubtargetFeature<"sdwa-mav",
266 "HasSDWAMac",
267 "true",
268 "Support v_mac_f32/f16 with SDWA (Sub-DWORD Addressing) extension"
269>;
270
Sam Koltona179d252017-06-27 15:02:23 +0000271def FeatureSDWAOutModsVOPC : SubtargetFeature<"sdwa-out-mods-vopc",
272 "HasSDWAOutModsVOPC",
Sam Kolton3c4933f2017-06-22 06:26:41 +0000273 "true",
274 "Support clamp for VOPC with SDWA (Sub-DWORD Addressing) extension"
275>;
276
Sam Kolton07dbde22017-01-20 10:01:25 +0000277def FeatureDPP : SubtargetFeature<"dpp",
278 "HasDPP",
279 "true",
280 "Support DPP (Data Parallel Primitives) extension"
281>;
282
Matt Arsenault382d9452016-01-26 04:49:22 +0000283//===------------------------------------------------------------===//
284// Subtarget Features (options and debugging)
285//===------------------------------------------------------------===//
286
287// Some instructions do not support denormals despite this flag. Using
288// fp32 denormals also causes instructions to run at the double
289// precision rate for the device.
290def FeatureFP32Denormals : SubtargetFeature<"fp32-denormals",
291 "FP32Denormals",
292 "true",
293 "Enable single precision denormal handling"
294>;
295
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000296// Denormal handling for fp64 and fp16 is controlled by the same
297// config register when fp16 supported.
298// TODO: Do we need a separate f16 setting when not legal?
299def FeatureFP64FP16Denormals : SubtargetFeature<"fp64-fp16-denormals",
300 "FP64FP16Denormals",
Matt Arsenault382d9452016-01-26 04:49:22 +0000301 "true",
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000302 "Enable double and half precision denormal handling",
Matt Arsenault382d9452016-01-26 04:49:22 +0000303 [FeatureFP64]
304>;
305
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000306def FeatureFP64Denormals : SubtargetFeature<"fp64-denormals",
307 "FP64FP16Denormals",
308 "true",
309 "Enable double and half precision denormal handling",
310 [FeatureFP64, FeatureFP64FP16Denormals]
311>;
312
313def FeatureFP16Denormals : SubtargetFeature<"fp16-denormals",
314 "FP64FP16Denormals",
315 "true",
316 "Enable half precision denormal handling",
317 [FeatureFP64FP16Denormals]
318>;
319
Matt Arsenault2fdf2a12017-02-21 23:35:48 +0000320def FeatureDX10Clamp : SubtargetFeature<"dx10-clamp",
321 "DX10Clamp",
322 "true",
323 "clamp modifier clamps NaNs to 0.0"
324>;
325
Matt Arsenaultf639c322016-01-28 20:53:42 +0000326def FeatureFPExceptions : SubtargetFeature<"fp-exceptions",
327 "FPExceptions",
328 "true",
329 "Enable floating point exceptions"
330>;
331
Matt Arsenault24ee0782016-02-12 02:40:47 +0000332class FeatureMaxPrivateElementSize<int size> : SubtargetFeature<
333 "max-private-element-size-"#size,
334 "MaxPrivateElementSize",
335 !cast<string>(size),
336 "Maximum private access size may be "#size
337>;
338
339def FeatureMaxPrivateElementSize4 : FeatureMaxPrivateElementSize<4>;
340def FeatureMaxPrivateElementSize8 : FeatureMaxPrivateElementSize<8>;
341def FeatureMaxPrivateElementSize16 : FeatureMaxPrivateElementSize<16>;
342
Matt Arsenault382d9452016-01-26 04:49:22 +0000343def FeatureVGPRSpilling : SubtargetFeature<"vgpr-spilling",
344 "EnableVGPRSpilling",
345 "true",
346 "Enable spilling of VGPRs to scratch memory"
347>;
348
349def FeatureDumpCode : SubtargetFeature <"DumpCode",
350 "DumpCode",
351 "true",
352 "Dump MachineInstrs in the CodeEmitter"
353>;
354
355def FeatureDumpCodeLower : SubtargetFeature <"dumpcode",
356 "DumpCode",
357 "true",
358 "Dump MachineInstrs in the CodeEmitter"
359>;
360
Matt Arsenault382d9452016-01-26 04:49:22 +0000361def FeaturePromoteAlloca : SubtargetFeature <"promote-alloca",
362 "EnablePromoteAlloca",
363 "true",
364 "Enable promote alloca pass"
365>;
366
367// XXX - This should probably be removed once enabled by default
368def FeatureEnableLoadStoreOpt : SubtargetFeature <"load-store-opt",
369 "EnableLoadStoreOpt",
370 "true",
371 "Enable SI load/store optimizer pass"
372>;
373
374// Performance debugging feature. Allow using DS instruction immediate
375// offsets even if the base pointer can't be proven to be base. On SI,
376// base pointer values that won't give the same result as a 16-bit add
377// are not safe to fold, but this will override the conservative test
378// for the base pointer.
379def FeatureEnableUnsafeDSOffsetFolding : SubtargetFeature <
380 "unsafe-ds-offset-folding",
381 "EnableUnsafeDSOffsetFolding",
382 "true",
383 "Force using DS instruction immediate offsets on SI"
384>;
385
Matt Arsenault382d9452016-01-26 04:49:22 +0000386def FeatureEnableSIScheduler : SubtargetFeature<"si-scheduler",
387 "EnableSIScheduler",
388 "true",
389 "Enable SI Machine Scheduler"
390>;
391
Matt Arsenault7aad8fd2017-01-24 22:02:15 +0000392// Unless +-flat-for-global is specified, turn on FlatForGlobal for
393// all OS-es on VI and newer hardware to avoid assertion failures due
394// to missing ADDR64 variants of MUBUF instructions.
395// FIXME: moveToVALU should be able to handle converting addr64 MUBUF
396// instructions.
397
Matt Arsenault382d9452016-01-26 04:49:22 +0000398def FeatureFlatForGlobal : SubtargetFeature<"flat-for-global",
399 "FlatForGlobal",
400 "true",
Matt Arsenaultd8f7ea32017-01-27 17:42:26 +0000401 "Force to generate flat instruction for global"
Matt Arsenault382d9452016-01-26 04:49:22 +0000402>;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000403
Konstantin Zhuravlyovbe6c0ca2017-06-02 17:40:26 +0000404def FeatureAutoWaitcntBeforeBarrier : SubtargetFeature <
405 "auto-waitcnt-before-barrier",
406 "AutoWaitcntBeforeBarrier",
407 "true",
408 "Hardware automatically inserts waitcnt before barrier"
409>;
410
Tom Stellardd1f0f022015-04-23 19:33:54 +0000411// Dummy feature used to disable assembler instructions.
412def FeatureDisable : SubtargetFeature<"",
Matt Arsenault382d9452016-01-26 04:49:22 +0000413 "FeatureDisable","true",
414 "Dummy feature to disable assembler instructions"
415>;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000416
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000417class SubtargetFeatureGeneration <string Value,
418 list<SubtargetFeature> Implies> :
419 SubtargetFeature <Value, "Gen", "AMDGPUSubtarget::"#Value,
420 Value#" GPU generation", Implies>;
421
Tom Stellard880a80a2014-06-17 16:53:14 +0000422def FeatureLocalMemorySize0 : SubtargetFeatureLocalMemorySize<0>;
423def FeatureLocalMemorySize32768 : SubtargetFeatureLocalMemorySize<32768>;
424def FeatureLocalMemorySize65536 : SubtargetFeatureLocalMemorySize<65536>;
425
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000426def FeatureR600 : SubtargetFeatureGeneration<"R600",
Matt Arsenault382d9452016-01-26 04:49:22 +0000427 [FeatureR600ALUInst, FeatureFetchLimit8, FeatureLocalMemorySize0]
428>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000429
430def FeatureR700 : SubtargetFeatureGeneration<"R700",
Matt Arsenault382d9452016-01-26 04:49:22 +0000431 [FeatureFetchLimit16, FeatureLocalMemorySize0]
432>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000433
434def FeatureEvergreen : SubtargetFeatureGeneration<"EVERGREEN",
Matt Arsenault382d9452016-01-26 04:49:22 +0000435 [FeatureFetchLimit16, FeatureLocalMemorySize32768]
436>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000437
438def FeatureNorthernIslands : SubtargetFeatureGeneration<"NORTHERN_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000439 [FeatureFetchLimit16, FeatureWavefrontSize64,
440 FeatureLocalMemorySize32768]
Tom Stellard880a80a2014-06-17 16:53:14 +0000441>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000442
443def FeatureSouthernIslands : SubtargetFeatureGeneration<"SOUTHERN_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000444 [FeatureFP64, FeatureLocalMemorySize32768,
445 FeatureWavefrontSize64, FeatureGCN, FeatureGCN1Encoding,
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000446 FeatureLDSBankCount32, FeatureMovrel]
Matt Arsenault382d9452016-01-26 04:49:22 +0000447>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000448
Tom Stellard6e1ee472013-10-29 16:37:28 +0000449def FeatureSeaIslands : SubtargetFeatureGeneration<"SEA_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000450 [FeatureFP64, FeatureLocalMemorySize65536,
451 FeatureWavefrontSize64, FeatureGCN, FeatureFlatAddressSpace,
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000452 FeatureGCN1Encoding, FeatureCIInsts, FeatureMovrel]
Matt Arsenault382d9452016-01-26 04:49:22 +0000453>;
Marek Olsak5df00d62014-12-07 12:18:57 +0000454
455def FeatureVolcanicIslands : SubtargetFeatureGeneration<"VOLCANIC_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000456 [FeatureFP64, FeatureLocalMemorySize65536,
457 FeatureWavefrontSize64, FeatureFlatAddressSpace, FeatureGCN,
Matt Arsenault9d82ee72016-02-27 08:53:55 +0000458 FeatureGCN3Encoding, FeatureCIInsts, Feature16BitInsts,
Matt Arsenault7b647552016-10-28 21:55:15 +0000459 FeatureSMemRealTime, FeatureVGPRIndexMode, FeatureMovrel,
Sam Kolton3c4933f2017-06-22 06:26:41 +0000460 FeatureScalarStores, FeatureInv2PiInlineImm,
Sam Koltona179d252017-06-27 15:02:23 +0000461 FeatureSDWA, FeatureSDWAOutModsVOPC, FeatureSDWAMac, FeatureDPP
Matt Arsenault9d82ee72016-02-27 08:53:55 +0000462 ]
Matt Arsenault382d9452016-01-26 04:49:22 +0000463>;
Marek Olsak5df00d62014-12-07 12:18:57 +0000464
Matt Arsenaulte823d922017-02-18 18:29:53 +0000465def FeatureGFX9 : SubtargetFeatureGeneration<"GFX9",
466 [FeatureFP64, FeatureLocalMemorySize65536,
467 FeatureWavefrontSize64, FeatureFlatAddressSpace, FeatureGCN,
468 FeatureGCN3Encoding, FeatureCIInsts, Feature16BitInsts,
469 FeatureSMemRealTime, FeatureScalarStores, FeatureInv2PiInlineImm,
Konstantin Zhuravlyovf6284062017-04-21 19:57:53 +0000470 FeatureApertureRegs, FeatureGFX9Insts, FeatureVOP3P, FeatureVGPRIndexMode,
Sam Kolton3c4933f2017-06-22 06:26:41 +0000471 FeatureFastFMAF32, FeatureDPP,
472 FeatureSDWA, FeatureSDWAOmod, FeatureSDWAScalar, FeatureSDWASdst,
Matt Arsenaultc37fe662017-07-20 17:42:47 +0000473 FeatureFlatInstOffsets, FeatureFlatGlobalInsts, FeatureFlatScratchInsts,
474 FeatureAddNoCarryInsts
Matt Arsenaulte823d922017-02-18 18:29:53 +0000475 ]
476>;
477
Yaxun Liu94add852016-10-26 16:37:56 +0000478class SubtargetFeatureISAVersion <int Major, int Minor, int Stepping,
479 list<SubtargetFeature> Implies>
480 : SubtargetFeature <
481 "isaver"#Major#"."#Minor#"."#Stepping,
482 "IsaVersion",
483 "ISAVersion"#Major#"_"#Minor#"_"#Stepping,
484 "Instruction set version number",
485 Implies
486>;
487
Wei Ding7c3e5112017-06-10 03:53:19 +0000488def FeatureISAVersion6_0_0 : SubtargetFeatureISAVersion <6,0,0,
489 [FeatureSouthernIslands,
Matt Arsenault8bcf2f22017-06-26 03:01:36 +0000490 FeatureFastFMAF32,
Wei Ding7c3e5112017-06-10 03:53:19 +0000491 HalfRate64Ops,
492 FeatureLDSBankCount32]>;
493
494def FeatureISAVersion6_0_1 : SubtargetFeatureISAVersion <6,0,1,
495 [FeatureSouthernIslands,
496 FeatureLDSBankCount32]>;
Matt Arsenault8bcf2f22017-06-26 03:01:36 +0000497
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000498def FeatureISAVersion7_0_0 : SubtargetFeatureISAVersion <7,0,0,
Yaxun Liu94add852016-10-26 16:37:56 +0000499 [FeatureSeaIslands,
500 FeatureLDSBankCount32]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000501
Yaxun Liu94add852016-10-26 16:37:56 +0000502def FeatureISAVersion7_0_1 : SubtargetFeatureISAVersion <7,0,1,
503 [FeatureSeaIslands,
504 HalfRate64Ops,
505 FeatureLDSBankCount32,
506 FeatureFastFMAF32]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000507
Yaxun Liu94add852016-10-26 16:37:56 +0000508def FeatureISAVersion7_0_2 : SubtargetFeatureISAVersion <7,0,2,
509 [FeatureSeaIslands,
Marek Olsak23ae31c2016-12-09 19:49:58 +0000510 FeatureLDSBankCount16]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000511
Wei Ding7c3e5112017-06-10 03:53:19 +0000512def FeatureISAVersion7_0_3 : SubtargetFeatureISAVersion <7,0,3,
513 [FeatureSeaIslands,
514 FeatureLDSBankCount16]>;
515
Yaxun Liu94add852016-10-26 16:37:56 +0000516def FeatureISAVersion8_0_0 : SubtargetFeatureISAVersion <8,0,0,
517 [FeatureVolcanicIslands,
518 FeatureLDSBankCount32,
519 FeatureSGPRInitBug]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000520
Yaxun Liu94add852016-10-26 16:37:56 +0000521def FeatureISAVersion8_0_1 : SubtargetFeatureISAVersion <8,0,1,
522 [FeatureVolcanicIslands,
523 FeatureLDSBankCount32,
524 FeatureXNACK]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000525
Yaxun Liu94add852016-10-26 16:37:56 +0000526def FeatureISAVersion8_0_2 : SubtargetFeatureISAVersion <8,0,2,
527 [FeatureVolcanicIslands,
528 FeatureLDSBankCount32,
529 FeatureSGPRInitBug]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000530
Yaxun Liu94add852016-10-26 16:37:56 +0000531def FeatureISAVersion8_0_3 : SubtargetFeatureISAVersion <8,0,3,
532 [FeatureVolcanicIslands,
533 FeatureLDSBankCount32]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000534
Yaxun Liu94add852016-10-26 16:37:56 +0000535def FeatureISAVersion8_0_4 : SubtargetFeatureISAVersion <8,0,4,
536 [FeatureVolcanicIslands,
537 FeatureLDSBankCount32]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000538
Yaxun Liu94add852016-10-26 16:37:56 +0000539def FeatureISAVersion8_1_0 : SubtargetFeatureISAVersion <8,1,0,
540 [FeatureVolcanicIslands,
541 FeatureLDSBankCount16,
542 FeatureXNACK]>;
543
Wei Ding7c3e5112017-06-10 03:53:19 +0000544def FeatureISAVersion9_0_0 : SubtargetFeatureISAVersion <9,0,0,
545 [FeatureGFX9,
546 FeatureLDSBankCount32]>;
547
548def FeatureISAVersion9_0_1 : SubtargetFeatureISAVersion <9,0,1,
549 [FeatureGFX9,
550 FeatureLDSBankCount32,
551 FeatureXNACK]>;
552
553def FeatureISAVersion9_0_2 : SubtargetFeatureISAVersion <9,0,2,
554 [FeatureGFX9,
555 FeatureLDSBankCount32]>;
556
557def FeatureISAVersion9_0_3 : SubtargetFeatureISAVersion <9,0,3,
558 [FeatureGFX9,
559 FeatureLDSBankCount32,
560 FeatureXNACK]>;
Matt Arsenaulte823d922017-02-18 18:29:53 +0000561
Tom Stellard3498e4f2013-06-07 20:28:55 +0000562//===----------------------------------------------------------------------===//
Konstantin Zhuravlyov8c273ad2016-04-18 16:28:23 +0000563// Debugger related subtarget features.
564//===----------------------------------------------------------------------===//
565
566def FeatureDebuggerInsertNops : SubtargetFeature<
567 "amdgpu-debugger-insert-nops",
568 "DebuggerInsertNops",
569 "true",
Konstantin Zhuravlyove3d322a2016-05-13 18:21:28 +0000570 "Insert one nop instruction for each high level source statement"
Konstantin Zhuravlyov8c273ad2016-04-18 16:28:23 +0000571>;
572
Konstantin Zhuravlyov29ddd2b2016-05-24 18:37:18 +0000573def FeatureDebuggerReserveRegs : SubtargetFeature<
574 "amdgpu-debugger-reserve-regs",
575 "DebuggerReserveRegs",
Konstantin Zhuravlyov1d99c4d2016-04-26 15:43:14 +0000576 "true",
Konstantin Zhuravlyov29ddd2b2016-05-24 18:37:18 +0000577 "Reserve registers for debugger usage"
Konstantin Zhuravlyov1d99c4d2016-04-26 15:43:14 +0000578>;
579
Konstantin Zhuravlyovf2f3d142016-06-25 03:11:28 +0000580def FeatureDebuggerEmitPrologue : SubtargetFeature<
581 "amdgpu-debugger-emit-prologue",
582 "DebuggerEmitPrologue",
583 "true",
584 "Emit debugger prologue"
585>;
586
Konstantin Zhuravlyov8c273ad2016-04-18 16:28:23 +0000587//===----------------------------------------------------------------------===//
Tom Stellard75aadc22012-12-11 21:25:42 +0000588
589def AMDGPUInstrInfo : InstrInfo {
590 let guessInstructionProperties = 1;
Matt Arsenault1ecac062015-02-18 02:15:32 +0000591 let noNamedPositionallyEncodedOperands = 1;
Tom Stellard75aadc22012-12-11 21:25:42 +0000592}
593
Tom Stellard9d7ddd52014-11-14 14:08:00 +0000594def AMDGPUAsmParser : AsmParser {
595 // Some of the R600 registers have the same name, so this crashes.
596 // For example T0_XYZW and T0_XY both have the asm name T0.
597 let ShouldEmitMatchRegisterName = 0;
598}
599
Konstantin Zhuravlyovda4687c2016-09-27 14:42:48 +0000600def AMDGPUAsmWriter : AsmWriter {
601 int PassSubtarget = 1;
602}
603
Sam Koltond63d8a72016-09-09 09:37:51 +0000604def AMDGPUAsmVariants {
605 string Default = "Default";
606 int Default_ID = 0;
607 string VOP3 = "VOP3";
608 int VOP3_ID = 1;
609 string SDWA = "SDWA";
610 int SDWA_ID = 2;
Sam Koltonf7659d712017-05-23 10:08:55 +0000611 string SDWA9 = "SDWA9";
612 int SDWA9_ID = 3;
Sam Koltond63d8a72016-09-09 09:37:51 +0000613 string DPP = "DPP";
Sam Koltonf7659d712017-05-23 10:08:55 +0000614 int DPP_ID = 4;
Sam Koltonfb0d9d92016-09-12 14:42:43 +0000615 string Disable = "Disable";
Sam Koltonf7659d712017-05-23 10:08:55 +0000616 int Disable_ID = 5;
Sam Koltond63d8a72016-09-09 09:37:51 +0000617}
618
619def DefaultAMDGPUAsmParserVariant : AsmParserVariant {
620 let Variant = AMDGPUAsmVariants.Default_ID;
621 let Name = AMDGPUAsmVariants.Default;
622}
623
624def VOP3AsmParserVariant : AsmParserVariant {
625 let Variant = AMDGPUAsmVariants.VOP3_ID;
626 let Name = AMDGPUAsmVariants.VOP3;
627}
628
629def SDWAAsmParserVariant : AsmParserVariant {
630 let Variant = AMDGPUAsmVariants.SDWA_ID;
631 let Name = AMDGPUAsmVariants.SDWA;
632}
633
Sam Koltonf7659d712017-05-23 10:08:55 +0000634def SDWA9AsmParserVariant : AsmParserVariant {
635 let Variant = AMDGPUAsmVariants.SDWA9_ID;
636 let Name = AMDGPUAsmVariants.SDWA9;
637}
638
639
Sam Koltond63d8a72016-09-09 09:37:51 +0000640def DPPAsmParserVariant : AsmParserVariant {
641 let Variant = AMDGPUAsmVariants.DPP_ID;
642 let Name = AMDGPUAsmVariants.DPP;
643}
644
Tom Stellard75aadc22012-12-11 21:25:42 +0000645def AMDGPU : Target {
646 // Pull in Instruction Info:
647 let InstructionSet = AMDGPUInstrInfo;
Tom Stellard9d7ddd52014-11-14 14:08:00 +0000648 let AssemblyParsers = [AMDGPUAsmParser];
Sam Koltond63d8a72016-09-09 09:37:51 +0000649 let AssemblyParserVariants = [DefaultAMDGPUAsmParserVariant,
650 VOP3AsmParserVariant,
651 SDWAAsmParserVariant,
Sam Koltonf7659d712017-05-23 10:08:55 +0000652 SDWA9AsmParserVariant,
Sam Koltond63d8a72016-09-09 09:37:51 +0000653 DPPAsmParserVariant];
Konstantin Zhuravlyovda4687c2016-09-27 14:42:48 +0000654 let AssemblyWriters = [AMDGPUAsmWriter];
Tom Stellard75aadc22012-12-11 21:25:42 +0000655}
656
Tom Stellardbc5b5372014-06-13 16:38:59 +0000657// Dummy Instruction itineraries for pseudo instructions
658def ALU_NULL : FuncUnit;
659def NullALU : InstrItinClass;
660
Tom Stellard0e70de52014-05-16 20:56:45 +0000661//===----------------------------------------------------------------------===//
662// Predicate helper class
663//===----------------------------------------------------------------------===//
664
Tom Stellardd1f0f022015-04-23 19:33:54 +0000665def TruePredicate : Predicate<"true">;
Matt Arsenault382d9452016-01-26 04:49:22 +0000666
Tom Stellardd1f0f022015-04-23 19:33:54 +0000667def isSICI : Predicate<
668 "Subtarget->getGeneration() == AMDGPUSubtarget::SOUTHERN_ISLANDS ||"
669 "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS"
670>, AssemblerPredicate<"FeatureGCN1Encoding">;
671
Tom Stellard5ebdfbe2015-12-24 03:18:18 +0000672def isVI : Predicate <
673 "Subtarget->getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS">,
674 AssemblerPredicate<"FeatureGCN3Encoding">;
675
Matt Arsenault2021f082017-02-18 19:12:26 +0000676def isGFX9 : Predicate <
677 "Subtarget->getGeneration() >= AMDGPUSubtarget::GFX9">,
678 AssemblerPredicate<"FeatureGFX9Insts">;
679
Matt Arsenaulte823d922017-02-18 18:29:53 +0000680// TODO: Either the name to be changed or we simply use IsCI!
Matt Arsenault382d9452016-01-26 04:49:22 +0000681def isCIVI : Predicate <
Matt Arsenaulte823d922017-02-18 18:29:53 +0000682 "Subtarget->getGeneration() >= AMDGPUSubtarget::SEA_ISLANDS">,
683 AssemblerPredicate<"FeatureCIInsts">;
Matt Arsenault382d9452016-01-26 04:49:22 +0000684
Matt Arsenault9698f1c2017-06-20 19:54:14 +0000685def HasFlatAddressSpace : Predicate<"Subtarget->hasFlatAddressSpace()">,
686 AssemblerPredicate<"FeatureFlatAddressSpace">;
687
688def HasFlatGlobalInsts : Predicate<"Subtarget->hasFlatGlobalInsts()">,
689 AssemblerPredicate<"FeatureFlatGlobalInsts">;
Matt Arsenaultca7b0a12017-07-21 15:36:16 +0000690def HasFlatScratchInsts : Predicate<"Subtarget->hasFlatScratchInsts()">,
691 AssemblerPredicate<"FeatureFlatScratchInsts">;
Matt Arsenault382d9452016-01-26 04:49:22 +0000692
Matt Arsenaultc37fe662017-07-20 17:42:47 +0000693def HasAddNoCarryInsts : Predicate<"Subtarget->hasAddNoCarryInsts()">,
694 AssemblerPredicate<"FeatureAddNoCarryInsts">;
695
696def NotHasAddNoCarryInsts : Predicate<"!Subtarget->hasAddNoCarryInsts()">,
697 AssemblerPredicate<"!FeatureAddNoCarryInsts">;
698
Matt Arsenault9be7b0d2017-02-27 18:49:11 +0000699def Has16BitInsts : Predicate<"Subtarget->has16BitInsts()">,
700 AssemblerPredicate<"Feature16BitInsts">;
701def HasVOP3PInsts : Predicate<"Subtarget->hasVOP3PInsts()">,
702 AssemblerPredicate<"FeatureVOP3P">;
Tom Stellard115a6152016-11-10 16:02:37 +0000703
Sam Kolton07dbde22017-01-20 10:01:25 +0000704def HasSDWA : Predicate<"Subtarget->hasSDWA()">,
Sam Koltonf7659d712017-05-23 10:08:55 +0000705 AssemblerPredicate<"FeatureSDWA,FeatureVolcanicIslands">;
706
707def HasSDWA9 : Predicate<"Subtarget->hasSDWA()">,
708 AssemblerPredicate<"FeatureSDWA,FeatureGFX9">;
Sam Kolton07dbde22017-01-20 10:01:25 +0000709
710def HasDPP : Predicate<"Subtarget->hasDPP()">,
711 AssemblerPredicate<"FeatureDPP">;
712
Tom Stellard0e70de52014-05-16 20:56:45 +0000713class PredicateControl {
714 Predicate SubtargetPredicate;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000715 Predicate SIAssemblerPredicate = isSICI;
Tom Stellard5ebdfbe2015-12-24 03:18:18 +0000716 Predicate VIAssemblerPredicate = isVI;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000717 list<Predicate> AssemblerPredicates = [];
Tom Stellardd1f0f022015-04-23 19:33:54 +0000718 Predicate AssemblerPredicate = TruePredicate;
Tom Stellard0e70de52014-05-16 20:56:45 +0000719 list<Predicate> OtherPredicates = [];
Tom Stellardd1f0f022015-04-23 19:33:54 +0000720 list<Predicate> Predicates = !listconcat([SubtargetPredicate, AssemblerPredicate],
Tom Stellardd7e6f132015-04-08 01:09:26 +0000721 AssemblerPredicates,
Tom Stellard0e70de52014-05-16 20:56:45 +0000722 OtherPredicates);
723}
724
Tom Stellard75aadc22012-12-11 21:25:42 +0000725// Include AMDGPU TD files
726include "R600Schedule.td"
727include "SISchedule.td"
728include "Processors.td"
729include "AMDGPUInstrInfo.td"
730include "AMDGPUIntrinsics.td"
731include "AMDGPURegisterInfo.td"
Tom Stellardca166212017-01-30 21:56:46 +0000732include "AMDGPURegisterBanks.td"
Tom Stellard75aadc22012-12-11 21:25:42 +0000733include "AMDGPUInstructions.td"
Christian Konig2c8f6d52013-03-07 09:03:52 +0000734include "AMDGPUCallingConv.td"