blob: bd47eadcafc3c436f763ac85f074791fd5c0d4ba [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
Matt Arsenault28f52e52017-10-25 07:00:51 +0000112def FeatureMadMixInsts : SubtargetFeature<"mad-mix-insts",
113 "HasMadMixInsts",
114 "true",
115 "Has v_mad_mix_f32, v_mad_mixlo_f16, v_mad_mixhi_f16 instructions"
116>;
117
Marek Olsak0f55fba2016-12-09 19:49:54 +0000118// XNACK is disabled if SH_MEM_CONFIG.ADDRESS_MODE = GPUVM on chips that support
119// XNACK. The current default kernel driver setting is:
120// - graphics ring: XNACK disabled
121// - compute ring: XNACK enabled
122//
123// If XNACK is enabled, the VMEM latency can be worse.
124// If XNACK is disabled, the 2 SGPRs can be used for general purposes.
Nicolai Haehnle5b504972016-01-04 23:35:53 +0000125def FeatureXNACK : SubtargetFeature<"xnack",
Matt Arsenault382d9452016-01-26 04:49:22 +0000126 "EnableXNACK",
127 "true",
128 "Enable XNACK support"
129>;
Tom Stellarde99fb652015-01-20 19:33:04 +0000130
Marek Olsak4d00dd22015-03-09 15:48:09 +0000131def FeatureSGPRInitBug : SubtargetFeature<"sgpr-init-bug",
Matt Arsenault382d9452016-01-26 04:49:22 +0000132 "SGPRInitBug",
133 "true",
Matt Arsenaulta7eb14af2017-08-06 18:13:23 +0000134 "VI SGPR initialization bug requiring a fixed SGPR allocation size"
Matt Arsenault382d9452016-01-26 04:49:22 +0000135>;
Tom Stellardde008d32016-01-21 04:28:34 +0000136
Tom Stellard3498e4f2013-06-07 20:28:55 +0000137class SubtargetFeatureFetchLimit <string Value> :
138 SubtargetFeature <"fetch"#Value,
Matt Arsenault382d9452016-01-26 04:49:22 +0000139 "TexVTXClauseSize",
140 Value,
141 "Limit the maximum number of fetches in a clause to "#Value
142>;
Tom Stellard99792772013-06-07 20:28:49 +0000143
Tom Stellard3498e4f2013-06-07 20:28:55 +0000144def FeatureFetchLimit8 : SubtargetFeatureFetchLimit <"8">;
145def FeatureFetchLimit16 : SubtargetFeatureFetchLimit <"16">;
146
Tom Stellard8c347b02014-01-22 21:55:40 +0000147class SubtargetFeatureWavefrontSize <int Value> : SubtargetFeature<
Matt Arsenault382d9452016-01-26 04:49:22 +0000148 "wavefrontsize"#Value,
149 "WavefrontSize",
150 !cast<string>(Value),
151 "The number of threads per wavefront"
152>;
Tom Stellard8c347b02014-01-22 21:55:40 +0000153
154def FeatureWavefrontSize16 : SubtargetFeatureWavefrontSize<16>;
155def FeatureWavefrontSize32 : SubtargetFeatureWavefrontSize<32>;
156def FeatureWavefrontSize64 : SubtargetFeatureWavefrontSize<64>;
157
Tom Stellardec87f842015-05-25 16:15:54 +0000158class SubtargetFeatureLDSBankCount <int Value> : SubtargetFeature <
Matt Arsenault382d9452016-01-26 04:49:22 +0000159 "ldsbankcount"#Value,
160 "LDSBankCount",
161 !cast<string>(Value),
162 "The number of LDS banks per compute unit."
163>;
Tom Stellardec87f842015-05-25 16:15:54 +0000164
165def FeatureLDSBankCount16 : SubtargetFeatureLDSBankCount<16>;
166def FeatureLDSBankCount32 : SubtargetFeatureLDSBankCount<32>;
167
Tom Stellard880a80a2014-06-17 16:53:14 +0000168class SubtargetFeatureLocalMemorySize <int Value> : SubtargetFeature<
Matt Arsenault382d9452016-01-26 04:49:22 +0000169 "localmemorysize"#Value,
170 "LocalMemorySize",
171 !cast<string>(Value),
172 "The size of local memory in bytes"
173>;
Tom Stellard880a80a2014-06-17 16:53:14 +0000174
Tom Stellardd7e6f132015-04-08 01:09:26 +0000175def FeatureGCN : SubtargetFeature<"gcn",
Matt Arsenault382d9452016-01-26 04:49:22 +0000176 "IsGCN",
177 "true",
178 "GCN or newer GPU"
179>;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000180
Tom Stellardd7e6f132015-04-08 01:09:26 +0000181def 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",
Matt Arsenaultc6baa852017-10-02 20:31:18 +0000190 "Additional instructions for CI+"
Matt Arsenault382d9452016-01-26 04:49:22 +0000191>;
192
Matt Arsenault2021f082017-02-18 19:12:26 +0000193def FeatureGFX9Insts : SubtargetFeature<"gfx9-insts",
194 "GFX9Insts",
195 "true",
Matt Arsenaultc6baa852017-10-02 20:31:18 +0000196 "Additional instructions for GFX9+"
Matt Arsenault2021f082017-02-18 19:12:26 +0000197>;
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
Dmitry Preobrazhenskyff64aa52017-08-16 13:51:56 +0000283def FeatureIntClamp : SubtargetFeature<"int-clamp-insts",
284 "HasIntClamp",
285 "true",
286 "Support clamp for integer destination"
287>;
288
Matt Arsenault382d9452016-01-26 04:49:22 +0000289//===------------------------------------------------------------===//
290// Subtarget Features (options and debugging)
291//===------------------------------------------------------------===//
292
293// Some instructions do not support denormals despite this flag. Using
294// fp32 denormals also causes instructions to run at the double
295// precision rate for the device.
296def FeatureFP32Denormals : SubtargetFeature<"fp32-denormals",
297 "FP32Denormals",
298 "true",
299 "Enable single precision denormal handling"
300>;
301
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000302// Denormal handling for fp64 and fp16 is controlled by the same
303// config register when fp16 supported.
304// TODO: Do we need a separate f16 setting when not legal?
305def FeatureFP64FP16Denormals : SubtargetFeature<"fp64-fp16-denormals",
306 "FP64FP16Denormals",
Matt Arsenault382d9452016-01-26 04:49:22 +0000307 "true",
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000308 "Enable double and half precision denormal handling",
Matt Arsenault382d9452016-01-26 04:49:22 +0000309 [FeatureFP64]
310>;
311
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000312def FeatureFP64Denormals : SubtargetFeature<"fp64-denormals",
313 "FP64FP16Denormals",
314 "true",
315 "Enable double and half precision denormal handling",
316 [FeatureFP64, FeatureFP64FP16Denormals]
317>;
318
319def FeatureFP16Denormals : SubtargetFeature<"fp16-denormals",
320 "FP64FP16Denormals",
321 "true",
322 "Enable half precision denormal handling",
323 [FeatureFP64FP16Denormals]
324>;
325
Matt Arsenault2fdf2a12017-02-21 23:35:48 +0000326def FeatureDX10Clamp : SubtargetFeature<"dx10-clamp",
327 "DX10Clamp",
328 "true",
329 "clamp modifier clamps NaNs to 0.0"
330>;
331
Matt Arsenaultf639c322016-01-28 20:53:42 +0000332def FeatureFPExceptions : SubtargetFeature<"fp-exceptions",
333 "FPExceptions",
334 "true",
335 "Enable floating point exceptions"
336>;
337
Matt Arsenault24ee0782016-02-12 02:40:47 +0000338class FeatureMaxPrivateElementSize<int size> : SubtargetFeature<
339 "max-private-element-size-"#size,
340 "MaxPrivateElementSize",
341 !cast<string>(size),
342 "Maximum private access size may be "#size
343>;
344
345def FeatureMaxPrivateElementSize4 : FeatureMaxPrivateElementSize<4>;
346def FeatureMaxPrivateElementSize8 : FeatureMaxPrivateElementSize<8>;
347def FeatureMaxPrivateElementSize16 : FeatureMaxPrivateElementSize<16>;
348
Matt Arsenault382d9452016-01-26 04:49:22 +0000349def FeatureVGPRSpilling : SubtargetFeature<"vgpr-spilling",
350 "EnableVGPRSpilling",
351 "true",
352 "Enable spilling of VGPRs to scratch memory"
353>;
354
355def FeatureDumpCode : SubtargetFeature <"DumpCode",
356 "DumpCode",
357 "true",
358 "Dump MachineInstrs in the CodeEmitter"
359>;
360
361def FeatureDumpCodeLower : SubtargetFeature <"dumpcode",
362 "DumpCode",
363 "true",
364 "Dump MachineInstrs in the CodeEmitter"
365>;
366
Matt Arsenault382d9452016-01-26 04:49:22 +0000367def FeaturePromoteAlloca : SubtargetFeature <"promote-alloca",
368 "EnablePromoteAlloca",
369 "true",
370 "Enable promote alloca pass"
371>;
372
373// XXX - This should probably be removed once enabled by default
374def FeatureEnableLoadStoreOpt : SubtargetFeature <"load-store-opt",
375 "EnableLoadStoreOpt",
376 "true",
377 "Enable SI load/store optimizer pass"
378>;
379
380// Performance debugging feature. Allow using DS instruction immediate
381// offsets even if the base pointer can't be proven to be base. On SI,
382// base pointer values that won't give the same result as a 16-bit add
383// are not safe to fold, but this will override the conservative test
384// for the base pointer.
385def FeatureEnableUnsafeDSOffsetFolding : SubtargetFeature <
386 "unsafe-ds-offset-folding",
387 "EnableUnsafeDSOffsetFolding",
388 "true",
389 "Force using DS instruction immediate offsets on SI"
390>;
391
Matt Arsenault382d9452016-01-26 04:49:22 +0000392def FeatureEnableSIScheduler : SubtargetFeature<"si-scheduler",
393 "EnableSIScheduler",
394 "true",
395 "Enable SI Machine Scheduler"
396>;
397
Matt Arsenault7aad8fd2017-01-24 22:02:15 +0000398// Unless +-flat-for-global is specified, turn on FlatForGlobal for
399// all OS-es on VI and newer hardware to avoid assertion failures due
400// to missing ADDR64 variants of MUBUF instructions.
401// FIXME: moveToVALU should be able to handle converting addr64 MUBUF
402// instructions.
403
Matt Arsenault382d9452016-01-26 04:49:22 +0000404def FeatureFlatForGlobal : SubtargetFeature<"flat-for-global",
405 "FlatForGlobal",
406 "true",
Matt Arsenaultd8f7ea32017-01-27 17:42:26 +0000407 "Force to generate flat instruction for global"
Matt Arsenault382d9452016-01-26 04:49:22 +0000408>;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000409
Konstantin Zhuravlyovbe6c0ca2017-06-02 17:40:26 +0000410def FeatureAutoWaitcntBeforeBarrier : SubtargetFeature <
411 "auto-waitcnt-before-barrier",
412 "AutoWaitcntBeforeBarrier",
413 "true",
414 "Hardware automatically inserts waitcnt before barrier"
415>;
416
Konstantin Zhuravlyoveda425e2017-10-14 15:59:07 +0000417def FeatureCodeObjectV3 : SubtargetFeature <
418 "code-object-v3",
419 "CodeObjectV3",
420 "true",
421 "Generate code object version 3"
422>;
423
Tom Stellardd1f0f022015-04-23 19:33:54 +0000424// Dummy feature used to disable assembler instructions.
425def FeatureDisable : SubtargetFeature<"",
Matt Arsenault382d9452016-01-26 04:49:22 +0000426 "FeatureDisable","true",
427 "Dummy feature to disable assembler instructions"
428>;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000429
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000430class SubtargetFeatureGeneration <string Value,
431 list<SubtargetFeature> Implies> :
432 SubtargetFeature <Value, "Gen", "AMDGPUSubtarget::"#Value,
433 Value#" GPU generation", Implies>;
434
Tom Stellard880a80a2014-06-17 16:53:14 +0000435def FeatureLocalMemorySize0 : SubtargetFeatureLocalMemorySize<0>;
436def FeatureLocalMemorySize32768 : SubtargetFeatureLocalMemorySize<32768>;
437def FeatureLocalMemorySize65536 : SubtargetFeatureLocalMemorySize<65536>;
438
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000439def FeatureR600 : SubtargetFeatureGeneration<"R600",
Matt Arsenault382d9452016-01-26 04:49:22 +0000440 [FeatureR600ALUInst, FeatureFetchLimit8, FeatureLocalMemorySize0]
441>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000442
443def FeatureR700 : SubtargetFeatureGeneration<"R700",
Matt Arsenault382d9452016-01-26 04:49:22 +0000444 [FeatureFetchLimit16, FeatureLocalMemorySize0]
445>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000446
447def FeatureEvergreen : SubtargetFeatureGeneration<"EVERGREEN",
Matt Arsenault382d9452016-01-26 04:49:22 +0000448 [FeatureFetchLimit16, FeatureLocalMemorySize32768]
449>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000450
451def FeatureNorthernIslands : SubtargetFeatureGeneration<"NORTHERN_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000452 [FeatureFetchLimit16, FeatureWavefrontSize64,
453 FeatureLocalMemorySize32768]
Tom Stellard880a80a2014-06-17 16:53:14 +0000454>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000455
456def FeatureSouthernIslands : SubtargetFeatureGeneration<"SOUTHERN_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000457 [FeatureFP64, FeatureLocalMemorySize32768,
Matt Arsenault8728c5f2017-08-07 14:58:04 +0000458 FeatureWavefrontSize64, FeatureGCN,
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000459 FeatureLDSBankCount32, FeatureMovrel]
Matt Arsenault382d9452016-01-26 04:49:22 +0000460>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000461
Tom Stellard6e1ee472013-10-29 16:37:28 +0000462def FeatureSeaIslands : SubtargetFeatureGeneration<"SEA_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000463 [FeatureFP64, FeatureLocalMemorySize65536,
464 FeatureWavefrontSize64, FeatureGCN, FeatureFlatAddressSpace,
Matt Arsenault8728c5f2017-08-07 14:58:04 +0000465 FeatureCIInsts, FeatureMovrel]
Matt Arsenault382d9452016-01-26 04:49:22 +0000466>;
Marek Olsak5df00d62014-12-07 12:18:57 +0000467
468def FeatureVolcanicIslands : SubtargetFeatureGeneration<"VOLCANIC_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000469 [FeatureFP64, FeatureLocalMemorySize65536,
470 FeatureWavefrontSize64, FeatureFlatAddressSpace, FeatureGCN,
Matt Arsenault9d82ee72016-02-27 08:53:55 +0000471 FeatureGCN3Encoding, FeatureCIInsts, Feature16BitInsts,
Matt Arsenault7b647552016-10-28 21:55:15 +0000472 FeatureSMemRealTime, FeatureVGPRIndexMode, FeatureMovrel,
Sam Kolton3c4933f2017-06-22 06:26:41 +0000473 FeatureScalarStores, FeatureInv2PiInlineImm,
Dmitry Preobrazhenskyff64aa52017-08-16 13:51:56 +0000474 FeatureSDWA, FeatureSDWAOutModsVOPC, FeatureSDWAMac, FeatureDPP,
475 FeatureIntClamp
Matt Arsenault9d82ee72016-02-27 08:53:55 +0000476 ]
Matt Arsenault382d9452016-01-26 04:49:22 +0000477>;
Marek Olsak5df00d62014-12-07 12:18:57 +0000478
Matt Arsenaulte823d922017-02-18 18:29:53 +0000479def FeatureGFX9 : SubtargetFeatureGeneration<"GFX9",
480 [FeatureFP64, FeatureLocalMemorySize65536,
481 FeatureWavefrontSize64, FeatureFlatAddressSpace, FeatureGCN,
482 FeatureGCN3Encoding, FeatureCIInsts, Feature16BitInsts,
483 FeatureSMemRealTime, FeatureScalarStores, FeatureInv2PiInlineImm,
Konstantin Zhuravlyovf6284062017-04-21 19:57:53 +0000484 FeatureApertureRegs, FeatureGFX9Insts, FeatureVOP3P, FeatureVGPRIndexMode,
Dmitry Preobrazhenskyff64aa52017-08-16 13:51:56 +0000485 FeatureFastFMAF32, FeatureDPP, FeatureIntClamp,
Sam Kolton3c4933f2017-06-22 06:26:41 +0000486 FeatureSDWA, FeatureSDWAOmod, FeatureSDWAScalar, FeatureSDWASdst,
Matt Arsenaultc37fe662017-07-20 17:42:47 +0000487 FeatureFlatInstOffsets, FeatureFlatGlobalInsts, FeatureFlatScratchInsts,
488 FeatureAddNoCarryInsts
Matt Arsenaulte823d922017-02-18 18:29:53 +0000489 ]
490>;
491
Yaxun Liu94add852016-10-26 16:37:56 +0000492class SubtargetFeatureISAVersion <int Major, int Minor, int Stepping,
493 list<SubtargetFeature> Implies>
494 : SubtargetFeature <
495 "isaver"#Major#"."#Minor#"."#Stepping,
496 "IsaVersion",
497 "ISAVersion"#Major#"_"#Minor#"_"#Stepping,
498 "Instruction set version number",
499 Implies
500>;
501
Wei Ding7c3e5112017-06-10 03:53:19 +0000502def FeatureISAVersion6_0_0 : SubtargetFeatureISAVersion <6,0,0,
503 [FeatureSouthernIslands,
Matt Arsenault8bcf2f22017-06-26 03:01:36 +0000504 FeatureFastFMAF32,
Wei Ding7c3e5112017-06-10 03:53:19 +0000505 HalfRate64Ops,
506 FeatureLDSBankCount32]>;
507
508def FeatureISAVersion6_0_1 : SubtargetFeatureISAVersion <6,0,1,
509 [FeatureSouthernIslands,
510 FeatureLDSBankCount32]>;
Matt Arsenault8bcf2f22017-06-26 03:01:36 +0000511
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000512def FeatureISAVersion7_0_0 : SubtargetFeatureISAVersion <7,0,0,
Yaxun Liu94add852016-10-26 16:37:56 +0000513 [FeatureSeaIslands,
514 FeatureLDSBankCount32]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000515
Yaxun Liu94add852016-10-26 16:37:56 +0000516def FeatureISAVersion7_0_1 : SubtargetFeatureISAVersion <7,0,1,
517 [FeatureSeaIslands,
518 HalfRate64Ops,
519 FeatureLDSBankCount32,
520 FeatureFastFMAF32]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000521
Yaxun Liu94add852016-10-26 16:37:56 +0000522def FeatureISAVersion7_0_2 : SubtargetFeatureISAVersion <7,0,2,
523 [FeatureSeaIslands,
Marek Olsak23ae31c2016-12-09 19:49:58 +0000524 FeatureLDSBankCount16]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000525
Wei Ding7c3e5112017-06-10 03:53:19 +0000526def FeatureISAVersion7_0_3 : SubtargetFeatureISAVersion <7,0,3,
527 [FeatureSeaIslands,
528 FeatureLDSBankCount16]>;
529
Yaxun Liu94add852016-10-26 16:37:56 +0000530def FeatureISAVersion8_0_0 : SubtargetFeatureISAVersion <8,0,0,
531 [FeatureVolcanicIslands,
532 FeatureLDSBankCount32,
533 FeatureSGPRInitBug]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000534
Yaxun Liu94add852016-10-26 16:37:56 +0000535def FeatureISAVersion8_0_1 : SubtargetFeatureISAVersion <8,0,1,
536 [FeatureVolcanicIslands,
Konstantin Zhuravlyov68107652017-08-24 20:03:07 +0000537 FeatureFastFMAF32,
538 HalfRate64Ops,
Yaxun Liu94add852016-10-26 16:37:56 +0000539 FeatureLDSBankCount32,
540 FeatureXNACK]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000541
Yaxun Liu94add852016-10-26 16:37:56 +0000542def FeatureISAVersion8_0_2 : SubtargetFeatureISAVersion <8,0,2,
543 [FeatureVolcanicIslands,
544 FeatureLDSBankCount32,
545 FeatureSGPRInitBug]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000546
Yaxun Liu94add852016-10-26 16:37:56 +0000547def FeatureISAVersion8_0_3 : SubtargetFeatureISAVersion <8,0,3,
548 [FeatureVolcanicIslands,
549 FeatureLDSBankCount32]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000550
Yaxun Liu94add852016-10-26 16:37:56 +0000551def FeatureISAVersion8_0_4 : SubtargetFeatureISAVersion <8,0,4,
552 [FeatureVolcanicIslands,
553 FeatureLDSBankCount32]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000554
Yaxun Liu94add852016-10-26 16:37:56 +0000555def FeatureISAVersion8_1_0 : SubtargetFeatureISAVersion <8,1,0,
556 [FeatureVolcanicIslands,
557 FeatureLDSBankCount16,
558 FeatureXNACK]>;
559
Wei Ding7c3e5112017-06-10 03:53:19 +0000560def FeatureISAVersion9_0_0 : SubtargetFeatureISAVersion <9,0,0,
561 [FeatureGFX9,
Matt Arsenault28f52e52017-10-25 07:00:51 +0000562 FeatureMadMixInsts,
563 FeatureLDSBankCount32
564 ]>;
Wei Ding7c3e5112017-06-10 03:53:19 +0000565
566def FeatureISAVersion9_0_1 : SubtargetFeatureISAVersion <9,0,1,
567 [FeatureGFX9,
Matt Arsenault28f52e52017-10-25 07:00:51 +0000568 FeatureMadMixInsts,
Wei Ding7c3e5112017-06-10 03:53:19 +0000569 FeatureLDSBankCount32,
570 FeatureXNACK]>;
571
572def FeatureISAVersion9_0_2 : SubtargetFeatureISAVersion <9,0,2,
573 [FeatureGFX9,
Matt Arsenault28f52e52017-10-25 07:00:51 +0000574 FeatureMadMixInsts,
575 FeatureLDSBankCount32
576 ]>;
Wei Ding7c3e5112017-06-10 03:53:19 +0000577
578def FeatureISAVersion9_0_3 : SubtargetFeatureISAVersion <9,0,3,
579 [FeatureGFX9,
Matt Arsenault28f52e52017-10-25 07:00:51 +0000580 FeatureMadMixInsts,
Wei Ding7c3e5112017-06-10 03:53:19 +0000581 FeatureLDSBankCount32,
582 FeatureXNACK]>;
Matt Arsenaulte823d922017-02-18 18:29:53 +0000583
Tom Stellard3498e4f2013-06-07 20:28:55 +0000584//===----------------------------------------------------------------------===//
Konstantin Zhuravlyov8c273ad2016-04-18 16:28:23 +0000585// Debugger related subtarget features.
586//===----------------------------------------------------------------------===//
587
588def FeatureDebuggerInsertNops : SubtargetFeature<
589 "amdgpu-debugger-insert-nops",
590 "DebuggerInsertNops",
591 "true",
Konstantin Zhuravlyove3d322a2016-05-13 18:21:28 +0000592 "Insert one nop instruction for each high level source statement"
Konstantin Zhuravlyov8c273ad2016-04-18 16:28:23 +0000593>;
594
Konstantin Zhuravlyov29ddd2b2016-05-24 18:37:18 +0000595def FeatureDebuggerReserveRegs : SubtargetFeature<
596 "amdgpu-debugger-reserve-regs",
597 "DebuggerReserveRegs",
Konstantin Zhuravlyov1d99c4d2016-04-26 15:43:14 +0000598 "true",
Konstantin Zhuravlyov29ddd2b2016-05-24 18:37:18 +0000599 "Reserve registers for debugger usage"
Konstantin Zhuravlyov1d99c4d2016-04-26 15:43:14 +0000600>;
601
Konstantin Zhuravlyovf2f3d142016-06-25 03:11:28 +0000602def FeatureDebuggerEmitPrologue : SubtargetFeature<
603 "amdgpu-debugger-emit-prologue",
604 "DebuggerEmitPrologue",
605 "true",
606 "Emit debugger prologue"
607>;
608
Konstantin Zhuravlyov8c273ad2016-04-18 16:28:23 +0000609//===----------------------------------------------------------------------===//
Tom Stellard75aadc22012-12-11 21:25:42 +0000610
611def AMDGPUInstrInfo : InstrInfo {
612 let guessInstructionProperties = 1;
Matt Arsenault1ecac062015-02-18 02:15:32 +0000613 let noNamedPositionallyEncodedOperands = 1;
Tom Stellard75aadc22012-12-11 21:25:42 +0000614}
615
Tom Stellard9d7ddd52014-11-14 14:08:00 +0000616def AMDGPUAsmParser : AsmParser {
617 // Some of the R600 registers have the same name, so this crashes.
618 // For example T0_XYZW and T0_XY both have the asm name T0.
619 let ShouldEmitMatchRegisterName = 0;
620}
621
Konstantin Zhuravlyovda4687c2016-09-27 14:42:48 +0000622def AMDGPUAsmWriter : AsmWriter {
623 int PassSubtarget = 1;
624}
625
Sam Koltond63d8a72016-09-09 09:37:51 +0000626def AMDGPUAsmVariants {
627 string Default = "Default";
628 int Default_ID = 0;
629 string VOP3 = "VOP3";
630 int VOP3_ID = 1;
631 string SDWA = "SDWA";
632 int SDWA_ID = 2;
Sam Koltonf7659d712017-05-23 10:08:55 +0000633 string SDWA9 = "SDWA9";
634 int SDWA9_ID = 3;
Sam Koltond63d8a72016-09-09 09:37:51 +0000635 string DPP = "DPP";
Sam Koltonf7659d712017-05-23 10:08:55 +0000636 int DPP_ID = 4;
Sam Koltonfb0d9d92016-09-12 14:42:43 +0000637 string Disable = "Disable";
Sam Koltonf7659d712017-05-23 10:08:55 +0000638 int Disable_ID = 5;
Sam Koltond63d8a72016-09-09 09:37:51 +0000639}
640
641def DefaultAMDGPUAsmParserVariant : AsmParserVariant {
642 let Variant = AMDGPUAsmVariants.Default_ID;
643 let Name = AMDGPUAsmVariants.Default;
644}
645
646def VOP3AsmParserVariant : AsmParserVariant {
647 let Variant = AMDGPUAsmVariants.VOP3_ID;
648 let Name = AMDGPUAsmVariants.VOP3;
649}
650
651def SDWAAsmParserVariant : AsmParserVariant {
652 let Variant = AMDGPUAsmVariants.SDWA_ID;
653 let Name = AMDGPUAsmVariants.SDWA;
654}
655
Sam Koltonf7659d712017-05-23 10:08:55 +0000656def SDWA9AsmParserVariant : AsmParserVariant {
657 let Variant = AMDGPUAsmVariants.SDWA9_ID;
658 let Name = AMDGPUAsmVariants.SDWA9;
659}
660
661
Sam Koltond63d8a72016-09-09 09:37:51 +0000662def DPPAsmParserVariant : AsmParserVariant {
663 let Variant = AMDGPUAsmVariants.DPP_ID;
664 let Name = AMDGPUAsmVariants.DPP;
665}
666
Tom Stellard75aadc22012-12-11 21:25:42 +0000667def AMDGPU : Target {
668 // Pull in Instruction Info:
669 let InstructionSet = AMDGPUInstrInfo;
Tom Stellard9d7ddd52014-11-14 14:08:00 +0000670 let AssemblyParsers = [AMDGPUAsmParser];
Sam Koltond63d8a72016-09-09 09:37:51 +0000671 let AssemblyParserVariants = [DefaultAMDGPUAsmParserVariant,
672 VOP3AsmParserVariant,
673 SDWAAsmParserVariant,
Sam Koltonf7659d712017-05-23 10:08:55 +0000674 SDWA9AsmParserVariant,
Sam Koltond63d8a72016-09-09 09:37:51 +0000675 DPPAsmParserVariant];
Konstantin Zhuravlyovda4687c2016-09-27 14:42:48 +0000676 let AssemblyWriters = [AMDGPUAsmWriter];
Tom Stellard75aadc22012-12-11 21:25:42 +0000677}
678
Tom Stellardbc5b5372014-06-13 16:38:59 +0000679// Dummy Instruction itineraries for pseudo instructions
680def ALU_NULL : FuncUnit;
681def NullALU : InstrItinClass;
682
Tom Stellard0e70de52014-05-16 20:56:45 +0000683//===----------------------------------------------------------------------===//
684// Predicate helper class
685//===----------------------------------------------------------------------===//
686
Tom Stellardd1f0f022015-04-23 19:33:54 +0000687def TruePredicate : Predicate<"true">;
Matt Arsenault382d9452016-01-26 04:49:22 +0000688
Tom Stellardd1f0f022015-04-23 19:33:54 +0000689def isSICI : Predicate<
690 "Subtarget->getGeneration() == AMDGPUSubtarget::SOUTHERN_ISLANDS ||"
691 "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS"
Matt Arsenault8728c5f2017-08-07 14:58:04 +0000692>, AssemblerPredicate<"!FeatureGCN3Encoding">;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000693
Tom Stellard5ebdfbe2015-12-24 03:18:18 +0000694def isVI : Predicate <
695 "Subtarget->getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS">,
696 AssemblerPredicate<"FeatureGCN3Encoding">;
697
Matt Arsenault2021f082017-02-18 19:12:26 +0000698def isGFX9 : Predicate <
699 "Subtarget->getGeneration() >= AMDGPUSubtarget::GFX9">,
700 AssemblerPredicate<"FeatureGFX9Insts">;
701
Matt Arsenaulte823d922017-02-18 18:29:53 +0000702// TODO: Either the name to be changed or we simply use IsCI!
Matt Arsenault382d9452016-01-26 04:49:22 +0000703def isCIVI : Predicate <
Matt Arsenaulte823d922017-02-18 18:29:53 +0000704 "Subtarget->getGeneration() >= AMDGPUSubtarget::SEA_ISLANDS">,
705 AssemblerPredicate<"FeatureCIInsts">;
Matt Arsenault382d9452016-01-26 04:49:22 +0000706
Matt Arsenault9698f1c2017-06-20 19:54:14 +0000707def HasFlatAddressSpace : Predicate<"Subtarget->hasFlatAddressSpace()">,
708 AssemblerPredicate<"FeatureFlatAddressSpace">;
709
710def HasFlatGlobalInsts : Predicate<"Subtarget->hasFlatGlobalInsts()">,
711 AssemblerPredicate<"FeatureFlatGlobalInsts">;
Matt Arsenaultca7b0a12017-07-21 15:36:16 +0000712def HasFlatScratchInsts : Predicate<"Subtarget->hasFlatScratchInsts()">,
713 AssemblerPredicate<"FeatureFlatScratchInsts">;
Matt Arsenaulted6e8f02017-09-01 18:36:06 +0000714def HasD16LoadStore : Predicate<"Subtarget->hasD16LoadStore()">,
715 AssemblerPredicate<"FeatureGFX9Insts">;
Matt Arsenault382d9452016-01-26 04:49:22 +0000716
Matt Arsenaultefa1d652017-09-01 18:38:02 +0000717def HasDSAddTid : Predicate<"Subtarget->getGeneration() >= AMDGPUSubtarget::GFX9">,
718 AssemblerPredicate<"FeatureGFX9Insts">;
719
Matt Arsenaultc37fe662017-07-20 17:42:47 +0000720def HasAddNoCarryInsts : Predicate<"Subtarget->hasAddNoCarryInsts()">,
721 AssemblerPredicate<"FeatureAddNoCarryInsts">;
722
723def NotHasAddNoCarryInsts : Predicate<"!Subtarget->hasAddNoCarryInsts()">,
724 AssemblerPredicate<"!FeatureAddNoCarryInsts">;
725
Matt Arsenault9be7b0d2017-02-27 18:49:11 +0000726def Has16BitInsts : Predicate<"Subtarget->has16BitInsts()">,
727 AssemblerPredicate<"Feature16BitInsts">;
728def HasVOP3PInsts : Predicate<"Subtarget->hasVOP3PInsts()">,
729 AssemblerPredicate<"FeatureVOP3P">;
Tom Stellard115a6152016-11-10 16:02:37 +0000730
Sam Kolton07dbde22017-01-20 10:01:25 +0000731def HasSDWA : Predicate<"Subtarget->hasSDWA()">,
Sam Koltonf7659d712017-05-23 10:08:55 +0000732 AssemblerPredicate<"FeatureSDWA,FeatureVolcanicIslands">;
733
734def HasSDWA9 : Predicate<"Subtarget->hasSDWA()">,
735 AssemblerPredicate<"FeatureSDWA,FeatureGFX9">;
Sam Kolton07dbde22017-01-20 10:01:25 +0000736
737def HasDPP : Predicate<"Subtarget->hasDPP()">,
738 AssemblerPredicate<"FeatureDPP">;
739
Dmitry Preobrazhenskyff64aa52017-08-16 13:51:56 +0000740def HasIntClamp : Predicate<"Subtarget->hasIntClamp()">,
741 AssemblerPredicate<"FeatureIntClamp">;
742
Matt Arsenault28f52e52017-10-25 07:00:51 +0000743def HasMadMixInsts : Predicate<"Subtarget->hasMadMixInsts()">,
744 AssemblerPredicate<"FeatureMadMixInsts">;
Matt Arsenaultd7e23032017-09-07 18:05:07 +0000745
Matt Arsenaultcc852232017-10-10 20:22:07 +0000746def EnableLateCFGStructurize : Predicate<
747 "EnableLateStructurizeCFG">;
Matt Arsenault90c75932017-10-03 00:06:41 +0000748
749// Exists to help track down where SubtargetPredicate isn't set rather
750// than letting tablegen crash with an unhelpful error.
751def InvalidPred : Predicate<"predicate not set on instruction or pattern">;
752
Tom Stellard0e70de52014-05-16 20:56:45 +0000753class PredicateControl {
Matt Arsenault90c75932017-10-03 00:06:41 +0000754 Predicate SubtargetPredicate = InvalidPred;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000755 Predicate SIAssemblerPredicate = isSICI;
Tom Stellard5ebdfbe2015-12-24 03:18:18 +0000756 Predicate VIAssemblerPredicate = isVI;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000757 list<Predicate> AssemblerPredicates = [];
Tom Stellardd1f0f022015-04-23 19:33:54 +0000758 Predicate AssemblerPredicate = TruePredicate;
Tom Stellard0e70de52014-05-16 20:56:45 +0000759 list<Predicate> OtherPredicates = [];
Matt Arsenault90c75932017-10-03 00:06:41 +0000760 list<Predicate> Predicates = !listconcat([SubtargetPredicate,
761 AssemblerPredicate],
Tom Stellardd7e6f132015-04-08 01:09:26 +0000762 AssemblerPredicates,
Tom Stellard0e70de52014-05-16 20:56:45 +0000763 OtherPredicates);
764}
765
Matt Arsenault90c75932017-10-03 00:06:41 +0000766class AMDGPUPat<dag pattern, dag result> : Pat<pattern, result>,
767 PredicateControl;
768
769
Tom Stellard75aadc22012-12-11 21:25:42 +0000770// Include AMDGPU TD files
771include "R600Schedule.td"
Konstantin Zhuravlyov27b0a032017-11-10 20:01:58 +0000772include "R600Processors.td"
Tom Stellard75aadc22012-12-11 21:25:42 +0000773include "SISchedule.td"
Konstantin Zhuravlyov27b0a032017-11-10 20:01:58 +0000774include "GCNProcessors.td"
Tom Stellard75aadc22012-12-11 21:25:42 +0000775include "AMDGPUInstrInfo.td"
776include "AMDGPUIntrinsics.td"
777include "AMDGPURegisterInfo.td"
Tom Stellardca166212017-01-30 21:56:46 +0000778include "AMDGPURegisterBanks.td"
Tom Stellard75aadc22012-12-11 21:25:42 +0000779include "AMDGPUInstructions.td"
Christian Konig2c8f6d52013-03-07 09:03:52 +0000780include "AMDGPUCallingConv.td"