blob: e7ebb37a9d62e65c760c446387e352d73217d70d [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 Arsenault7f681ac2016-07-01 23:03:44 +000082def FeatureUnalignedBufferAccess : SubtargetFeature<"unaligned-buffer-access",
83 "UnalignedBufferAccess",
84 "true",
85 "Support unaligned global loads and stores"
86>;
87
Wei Ding205bfdb2017-02-10 02:15:29 +000088def FeatureTrapHandler: SubtargetFeature<"trap-handler",
89 "TrapHandler",
90 "true",
91 "Trap handler support"
92>;
93
Tom Stellard64a9d082016-10-14 18:10:39 +000094def FeatureUnalignedScratchAccess : SubtargetFeature<"unaligned-scratch-access",
95 "UnalignedScratchAccess",
96 "true",
97 "Support unaligned scratch loads and stores"
98>;
99
Matt Arsenaulte823d922017-02-18 18:29:53 +0000100def FeatureApertureRegs : SubtargetFeature<"aperture-regs",
101 "HasApertureRegs",
102 "true",
103 "Has Memory Aperture Base and Size Registers"
104>;
105
Marek Olsak0f55fba2016-12-09 19:49:54 +0000106// XNACK is disabled if SH_MEM_CONFIG.ADDRESS_MODE = GPUVM on chips that support
107// XNACK. The current default kernel driver setting is:
108// - graphics ring: XNACK disabled
109// - compute ring: XNACK enabled
110//
111// If XNACK is enabled, the VMEM latency can be worse.
112// If XNACK is disabled, the 2 SGPRs can be used for general purposes.
Nicolai Haehnle5b504972016-01-04 23:35:53 +0000113def FeatureXNACK : SubtargetFeature<"xnack",
Matt Arsenault382d9452016-01-26 04:49:22 +0000114 "EnableXNACK",
115 "true",
116 "Enable XNACK support"
117>;
Tom Stellarde99fb652015-01-20 19:33:04 +0000118
Marek Olsak4d00dd22015-03-09 15:48:09 +0000119def FeatureSGPRInitBug : SubtargetFeature<"sgpr-init-bug",
Matt Arsenault382d9452016-01-26 04:49:22 +0000120 "SGPRInitBug",
121 "true",
122 "VI SGPR initilization bug requiring a fixed SGPR allocation size"
123>;
Tom Stellardde008d32016-01-21 04:28:34 +0000124
Tom Stellard3498e4f2013-06-07 20:28:55 +0000125class SubtargetFeatureFetchLimit <string Value> :
126 SubtargetFeature <"fetch"#Value,
Matt Arsenault382d9452016-01-26 04:49:22 +0000127 "TexVTXClauseSize",
128 Value,
129 "Limit the maximum number of fetches in a clause to "#Value
130>;
Tom Stellard99792772013-06-07 20:28:49 +0000131
Tom Stellard3498e4f2013-06-07 20:28:55 +0000132def FeatureFetchLimit8 : SubtargetFeatureFetchLimit <"8">;
133def FeatureFetchLimit16 : SubtargetFeatureFetchLimit <"16">;
134
Tom Stellard8c347b02014-01-22 21:55:40 +0000135class SubtargetFeatureWavefrontSize <int Value> : SubtargetFeature<
Matt Arsenault382d9452016-01-26 04:49:22 +0000136 "wavefrontsize"#Value,
137 "WavefrontSize",
138 !cast<string>(Value),
139 "The number of threads per wavefront"
140>;
Tom Stellard8c347b02014-01-22 21:55:40 +0000141
142def FeatureWavefrontSize16 : SubtargetFeatureWavefrontSize<16>;
143def FeatureWavefrontSize32 : SubtargetFeatureWavefrontSize<32>;
144def FeatureWavefrontSize64 : SubtargetFeatureWavefrontSize<64>;
145
Tom Stellardec87f842015-05-25 16:15:54 +0000146class SubtargetFeatureLDSBankCount <int Value> : SubtargetFeature <
Matt Arsenault382d9452016-01-26 04:49:22 +0000147 "ldsbankcount"#Value,
148 "LDSBankCount",
149 !cast<string>(Value),
150 "The number of LDS banks per compute unit."
151>;
Tom Stellardec87f842015-05-25 16:15:54 +0000152
153def FeatureLDSBankCount16 : SubtargetFeatureLDSBankCount<16>;
154def FeatureLDSBankCount32 : SubtargetFeatureLDSBankCount<32>;
155
Tom Stellard880a80a2014-06-17 16:53:14 +0000156class SubtargetFeatureLocalMemorySize <int Value> : SubtargetFeature<
Matt Arsenault382d9452016-01-26 04:49:22 +0000157 "localmemorysize"#Value,
158 "LocalMemorySize",
159 !cast<string>(Value),
160 "The size of local memory in bytes"
161>;
Tom Stellard880a80a2014-06-17 16:53:14 +0000162
Tom Stellardd7e6f132015-04-08 01:09:26 +0000163def FeatureGCN : SubtargetFeature<"gcn",
Matt Arsenault382d9452016-01-26 04:49:22 +0000164 "IsGCN",
165 "true",
166 "GCN or newer GPU"
167>;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000168
169def FeatureGCN1Encoding : SubtargetFeature<"gcn1-encoding",
Matt Arsenault382d9452016-01-26 04:49:22 +0000170 "GCN1Encoding",
171 "true",
172 "Encoding format for SI and CI"
173>;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000174
175def FeatureGCN3Encoding : SubtargetFeature<"gcn3-encoding",
Matt Arsenault382d9452016-01-26 04:49:22 +0000176 "GCN3Encoding",
177 "true",
178 "Encoding format for VI"
179>;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000180
181def FeatureCIInsts : SubtargetFeature<"ci-insts",
Matt Arsenault382d9452016-01-26 04:49:22 +0000182 "CIInsts",
183 "true",
184 "Additional intstructions for CI+"
185>;
186
Matt Arsenault2021f082017-02-18 19:12:26 +0000187def FeatureGFX9Insts : SubtargetFeature<"gfx9-insts",
188 "GFX9Insts",
189 "true",
190 "Additional intstructions for GFX9+"
191>;
192
Matt Arsenault9d82ee72016-02-27 08:53:55 +0000193def FeatureSMemRealTime : SubtargetFeature<"s-memrealtime",
194 "HasSMemRealTime",
Matt Arsenault61738cb2016-02-27 08:53:46 +0000195 "true",
Matt Arsenault9d82ee72016-02-27 08:53:55 +0000196 "Has s_memrealtime instruction"
197>;
198
Matt Arsenaultc88ba362016-10-29 04:05:06 +0000199def FeatureInv2PiInlineImm : SubtargetFeature<"inv-2pi-inline-imm",
200 "HasInv2PiInlineImm",
201 "true",
202 "Has 1 / (2 * pi) as inline immediate"
203>;
204
Matt Arsenault9d82ee72016-02-27 08:53:55 +0000205def Feature16BitInsts : SubtargetFeature<"16-bit-insts",
206 "Has16BitInsts",
207 "true",
208 "Has i16/f16 instructions"
Matt Arsenault61738cb2016-02-27 08:53:46 +0000209>;
210
Matt Arsenault9be7b0d2017-02-27 18:49:11 +0000211def FeatureVOP3P : SubtargetFeature<"vop3p",
212 "HasVOP3PInsts",
213 "true",
214 "Has VOP3P packed instructions"
215>;
216
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000217def FeatureMovrel : SubtargetFeature<"movrel",
218 "HasMovrel",
219 "true",
220 "Has v_movrel*_b32 instructions"
221>;
222
223def FeatureVGPRIndexMode : SubtargetFeature<"vgpr-index-mode",
224 "HasVGPRIndexMode",
225 "true",
226 "Has VGPR mode register indexing"
227>;
228
Matt Arsenault7b647552016-10-28 21:55:15 +0000229def FeatureScalarStores : SubtargetFeature<"scalar-stores",
230 "HasScalarStores",
231 "true",
232 "Has store scalar memory instructions"
233>;
234
Sam Kolton07dbde22017-01-20 10:01:25 +0000235def FeatureSDWA : SubtargetFeature<"sdwa",
236 "HasSDWA",
237 "true",
238 "Support SDWA (Sub-DWORD Addressing) extension"
239>;
240
241def FeatureDPP : SubtargetFeature<"dpp",
242 "HasDPP",
243 "true",
244 "Support DPP (Data Parallel Primitives) extension"
245>;
246
Matt Arsenault382d9452016-01-26 04:49:22 +0000247//===------------------------------------------------------------===//
248// Subtarget Features (options and debugging)
249//===------------------------------------------------------------===//
250
251// Some instructions do not support denormals despite this flag. Using
252// fp32 denormals also causes instructions to run at the double
253// precision rate for the device.
254def FeatureFP32Denormals : SubtargetFeature<"fp32-denormals",
255 "FP32Denormals",
256 "true",
257 "Enable single precision denormal handling"
258>;
259
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000260// Denormal handling for fp64 and fp16 is controlled by the same
261// config register when fp16 supported.
262// TODO: Do we need a separate f16 setting when not legal?
263def FeatureFP64FP16Denormals : SubtargetFeature<"fp64-fp16-denormals",
264 "FP64FP16Denormals",
Matt Arsenault382d9452016-01-26 04:49:22 +0000265 "true",
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000266 "Enable double and half precision denormal handling",
Matt Arsenault382d9452016-01-26 04:49:22 +0000267 [FeatureFP64]
268>;
269
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000270def FeatureFP64Denormals : SubtargetFeature<"fp64-denormals",
271 "FP64FP16Denormals",
272 "true",
273 "Enable double and half precision denormal handling",
274 [FeatureFP64, FeatureFP64FP16Denormals]
275>;
276
277def FeatureFP16Denormals : SubtargetFeature<"fp16-denormals",
278 "FP64FP16Denormals",
279 "true",
280 "Enable half precision denormal handling",
281 [FeatureFP64FP16Denormals]
282>;
283
Matt Arsenault2fdf2a12017-02-21 23:35:48 +0000284def FeatureDX10Clamp : SubtargetFeature<"dx10-clamp",
285 "DX10Clamp",
286 "true",
287 "clamp modifier clamps NaNs to 0.0"
288>;
289
Matt Arsenaultf639c322016-01-28 20:53:42 +0000290def FeatureFPExceptions : SubtargetFeature<"fp-exceptions",
291 "FPExceptions",
292 "true",
293 "Enable floating point exceptions"
294>;
295
Matt Arsenault24ee0782016-02-12 02:40:47 +0000296class FeatureMaxPrivateElementSize<int size> : SubtargetFeature<
297 "max-private-element-size-"#size,
298 "MaxPrivateElementSize",
299 !cast<string>(size),
300 "Maximum private access size may be "#size
301>;
302
303def FeatureMaxPrivateElementSize4 : FeatureMaxPrivateElementSize<4>;
304def FeatureMaxPrivateElementSize8 : FeatureMaxPrivateElementSize<8>;
305def FeatureMaxPrivateElementSize16 : FeatureMaxPrivateElementSize<16>;
306
Matt Arsenault382d9452016-01-26 04:49:22 +0000307def FeatureVGPRSpilling : SubtargetFeature<"vgpr-spilling",
308 "EnableVGPRSpilling",
309 "true",
310 "Enable spilling of VGPRs to scratch memory"
311>;
312
313def FeatureDumpCode : SubtargetFeature <"DumpCode",
314 "DumpCode",
315 "true",
316 "Dump MachineInstrs in the CodeEmitter"
317>;
318
319def FeatureDumpCodeLower : SubtargetFeature <"dumpcode",
320 "DumpCode",
321 "true",
322 "Dump MachineInstrs in the CodeEmitter"
323>;
324
Matt Arsenault382d9452016-01-26 04:49:22 +0000325def FeaturePromoteAlloca : SubtargetFeature <"promote-alloca",
326 "EnablePromoteAlloca",
327 "true",
328 "Enable promote alloca pass"
329>;
330
331// XXX - This should probably be removed once enabled by default
332def FeatureEnableLoadStoreOpt : SubtargetFeature <"load-store-opt",
333 "EnableLoadStoreOpt",
334 "true",
335 "Enable SI load/store optimizer pass"
336>;
337
338// Performance debugging feature. Allow using DS instruction immediate
339// offsets even if the base pointer can't be proven to be base. On SI,
340// base pointer values that won't give the same result as a 16-bit add
341// are not safe to fold, but this will override the conservative test
342// for the base pointer.
343def FeatureEnableUnsafeDSOffsetFolding : SubtargetFeature <
344 "unsafe-ds-offset-folding",
345 "EnableUnsafeDSOffsetFolding",
346 "true",
347 "Force using DS instruction immediate offsets on SI"
348>;
349
Matt Arsenault382d9452016-01-26 04:49:22 +0000350def FeatureEnableSIScheduler : SubtargetFeature<"si-scheduler",
351 "EnableSIScheduler",
352 "true",
353 "Enable SI Machine Scheduler"
354>;
355
Matt Arsenault7aad8fd2017-01-24 22:02:15 +0000356// Unless +-flat-for-global is specified, turn on FlatForGlobal for
357// all OS-es on VI and newer hardware to avoid assertion failures due
358// to missing ADDR64 variants of MUBUF instructions.
359// FIXME: moveToVALU should be able to handle converting addr64 MUBUF
360// instructions.
361
Matt Arsenault382d9452016-01-26 04:49:22 +0000362def FeatureFlatForGlobal : SubtargetFeature<"flat-for-global",
363 "FlatForGlobal",
364 "true",
Matt Arsenaultd8f7ea32017-01-27 17:42:26 +0000365 "Force to generate flat instruction for global"
Matt Arsenault382d9452016-01-26 04:49:22 +0000366>;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000367
368// Dummy feature used to disable assembler instructions.
369def FeatureDisable : SubtargetFeature<"",
Matt Arsenault382d9452016-01-26 04:49:22 +0000370 "FeatureDisable","true",
371 "Dummy feature to disable assembler instructions"
372>;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000373
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000374class SubtargetFeatureGeneration <string Value,
375 list<SubtargetFeature> Implies> :
376 SubtargetFeature <Value, "Gen", "AMDGPUSubtarget::"#Value,
377 Value#" GPU generation", Implies>;
378
Tom Stellard880a80a2014-06-17 16:53:14 +0000379def FeatureLocalMemorySize0 : SubtargetFeatureLocalMemorySize<0>;
380def FeatureLocalMemorySize32768 : SubtargetFeatureLocalMemorySize<32768>;
381def FeatureLocalMemorySize65536 : SubtargetFeatureLocalMemorySize<65536>;
382
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000383def FeatureR600 : SubtargetFeatureGeneration<"R600",
Matt Arsenault382d9452016-01-26 04:49:22 +0000384 [FeatureR600ALUInst, FeatureFetchLimit8, FeatureLocalMemorySize0]
385>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000386
387def FeatureR700 : SubtargetFeatureGeneration<"R700",
Matt Arsenault382d9452016-01-26 04:49:22 +0000388 [FeatureFetchLimit16, FeatureLocalMemorySize0]
389>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000390
391def FeatureEvergreen : SubtargetFeatureGeneration<"EVERGREEN",
Matt Arsenault382d9452016-01-26 04:49:22 +0000392 [FeatureFetchLimit16, FeatureLocalMemorySize32768]
393>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000394
395def FeatureNorthernIslands : SubtargetFeatureGeneration<"NORTHERN_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000396 [FeatureFetchLimit16, FeatureWavefrontSize64,
397 FeatureLocalMemorySize32768]
Tom Stellard880a80a2014-06-17 16:53:14 +0000398>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000399
400def FeatureSouthernIslands : SubtargetFeatureGeneration<"SOUTHERN_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000401 [FeatureFP64, FeatureLocalMemorySize32768,
402 FeatureWavefrontSize64, FeatureGCN, FeatureGCN1Encoding,
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000403 FeatureLDSBankCount32, FeatureMovrel]
Matt Arsenault382d9452016-01-26 04:49:22 +0000404>;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000405
Tom Stellard6e1ee472013-10-29 16:37:28 +0000406def FeatureSeaIslands : SubtargetFeatureGeneration<"SEA_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000407 [FeatureFP64, FeatureLocalMemorySize65536,
408 FeatureWavefrontSize64, FeatureGCN, FeatureFlatAddressSpace,
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000409 FeatureGCN1Encoding, FeatureCIInsts, FeatureMovrel]
Matt Arsenault382d9452016-01-26 04:49:22 +0000410>;
Marek Olsak5df00d62014-12-07 12:18:57 +0000411
412def FeatureVolcanicIslands : SubtargetFeatureGeneration<"VOLCANIC_ISLANDS",
Matt Arsenault382d9452016-01-26 04:49:22 +0000413 [FeatureFP64, FeatureLocalMemorySize65536,
414 FeatureWavefrontSize64, FeatureFlatAddressSpace, FeatureGCN,
Matt Arsenault9d82ee72016-02-27 08:53:55 +0000415 FeatureGCN3Encoding, FeatureCIInsts, Feature16BitInsts,
Matt Arsenault7b647552016-10-28 21:55:15 +0000416 FeatureSMemRealTime, FeatureVGPRIndexMode, FeatureMovrel,
Sam Kolton07dbde22017-01-20 10:01:25 +0000417 FeatureScalarStores, FeatureInv2PiInlineImm, FeatureSDWA,
Matt Arsenaultd8f7ea32017-01-27 17:42:26 +0000418 FeatureDPP
Matt Arsenault9d82ee72016-02-27 08:53:55 +0000419 ]
Matt Arsenault382d9452016-01-26 04:49:22 +0000420>;
Marek Olsak5df00d62014-12-07 12:18:57 +0000421
Matt Arsenaulte823d922017-02-18 18:29:53 +0000422def FeatureGFX9 : SubtargetFeatureGeneration<"GFX9",
423 [FeatureFP64, FeatureLocalMemorySize65536,
424 FeatureWavefrontSize64, FeatureFlatAddressSpace, FeatureGCN,
425 FeatureGCN3Encoding, FeatureCIInsts, Feature16BitInsts,
426 FeatureSMemRealTime, FeatureScalarStores, FeatureInv2PiInlineImm,
Konstantin Zhuravlyovf6284062017-04-21 19:57:53 +0000427 FeatureApertureRegs, FeatureGFX9Insts, FeatureVOP3P, FeatureVGPRIndexMode,
Sam Koltonf7659d712017-05-23 10:08:55 +0000428 FeatureFastFMAF32, FeatureSDWA, FeatureDPP,
Matt Arsenaultacdc7652017-05-10 21:19:05 +0000429 FeatureFlatInstOffsets, FeatureFlatGlobalInsts, FeatureFlatScratchInsts
Matt Arsenaulte823d922017-02-18 18:29:53 +0000430 ]
431>;
432
Yaxun Liu94add852016-10-26 16:37:56 +0000433class SubtargetFeatureISAVersion <int Major, int Minor, int Stepping,
434 list<SubtargetFeature> Implies>
435 : SubtargetFeature <
436 "isaver"#Major#"."#Minor#"."#Stepping,
437 "IsaVersion",
438 "ISAVersion"#Major#"_"#Minor#"_"#Stepping,
439 "Instruction set version number",
440 Implies
441>;
442
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000443def FeatureISAVersion7_0_0 : SubtargetFeatureISAVersion <7,0,0,
Yaxun Liu94add852016-10-26 16:37:56 +0000444 [FeatureSeaIslands,
445 FeatureLDSBankCount32]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000446
Yaxun Liu94add852016-10-26 16:37:56 +0000447def FeatureISAVersion7_0_1 : SubtargetFeatureISAVersion <7,0,1,
448 [FeatureSeaIslands,
449 HalfRate64Ops,
450 FeatureLDSBankCount32,
451 FeatureFastFMAF32]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000452
Yaxun Liu94add852016-10-26 16:37:56 +0000453def FeatureISAVersion7_0_2 : SubtargetFeatureISAVersion <7,0,2,
454 [FeatureSeaIslands,
Marek Olsak23ae31c2016-12-09 19:49:58 +0000455 FeatureLDSBankCount16]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000456
Yaxun Liu94add852016-10-26 16:37:56 +0000457def FeatureISAVersion8_0_0 : SubtargetFeatureISAVersion <8,0,0,
458 [FeatureVolcanicIslands,
459 FeatureLDSBankCount32,
460 FeatureSGPRInitBug]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000461
Yaxun Liu94add852016-10-26 16:37:56 +0000462def FeatureISAVersion8_0_1 : SubtargetFeatureISAVersion <8,0,1,
463 [FeatureVolcanicIslands,
464 FeatureLDSBankCount32,
465 FeatureXNACK]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000466
Yaxun Liu94add852016-10-26 16:37:56 +0000467def FeatureISAVersion8_0_2 : SubtargetFeatureISAVersion <8,0,2,
468 [FeatureVolcanicIslands,
469 FeatureLDSBankCount32,
470 FeatureSGPRInitBug]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000471
Yaxun Liu94add852016-10-26 16:37:56 +0000472def FeatureISAVersion8_0_3 : SubtargetFeatureISAVersion <8,0,3,
473 [FeatureVolcanicIslands,
474 FeatureLDSBankCount32]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000475
Yaxun Liu94add852016-10-26 16:37:56 +0000476def FeatureISAVersion8_0_4 : SubtargetFeatureISAVersion <8,0,4,
477 [FeatureVolcanicIslands,
478 FeatureLDSBankCount32]>;
Matt Arsenaultf3dd8632016-11-01 00:55:14 +0000479
Yaxun Liu94add852016-10-26 16:37:56 +0000480def FeatureISAVersion8_1_0 : SubtargetFeatureISAVersion <8,1,0,
481 [FeatureVolcanicIslands,
482 FeatureLDSBankCount16,
483 FeatureXNACK]>;
484
Matt Arsenaulte823d922017-02-18 18:29:53 +0000485def FeatureISAVersion9_0_0 : SubtargetFeatureISAVersion <9,0,0,[]>;
486def FeatureISAVersion9_0_1 : SubtargetFeatureISAVersion <9,0,1,[]>;
487
Tom Stellard3498e4f2013-06-07 20:28:55 +0000488//===----------------------------------------------------------------------===//
Konstantin Zhuravlyov8c273ad2016-04-18 16:28:23 +0000489// Debugger related subtarget features.
490//===----------------------------------------------------------------------===//
491
492def FeatureDebuggerInsertNops : SubtargetFeature<
493 "amdgpu-debugger-insert-nops",
494 "DebuggerInsertNops",
495 "true",
Konstantin Zhuravlyove3d322a2016-05-13 18:21:28 +0000496 "Insert one nop instruction for each high level source statement"
Konstantin Zhuravlyov8c273ad2016-04-18 16:28:23 +0000497>;
498
Konstantin Zhuravlyov29ddd2b2016-05-24 18:37:18 +0000499def FeatureDebuggerReserveRegs : SubtargetFeature<
500 "amdgpu-debugger-reserve-regs",
501 "DebuggerReserveRegs",
Konstantin Zhuravlyov1d99c4d2016-04-26 15:43:14 +0000502 "true",
Konstantin Zhuravlyov29ddd2b2016-05-24 18:37:18 +0000503 "Reserve registers for debugger usage"
Konstantin Zhuravlyov1d99c4d2016-04-26 15:43:14 +0000504>;
505
Konstantin Zhuravlyovf2f3d142016-06-25 03:11:28 +0000506def FeatureDebuggerEmitPrologue : SubtargetFeature<
507 "amdgpu-debugger-emit-prologue",
508 "DebuggerEmitPrologue",
509 "true",
510 "Emit debugger prologue"
511>;
512
Konstantin Zhuravlyov8c273ad2016-04-18 16:28:23 +0000513//===----------------------------------------------------------------------===//
Tom Stellard75aadc22012-12-11 21:25:42 +0000514
515def AMDGPUInstrInfo : InstrInfo {
516 let guessInstructionProperties = 1;
Matt Arsenault1ecac062015-02-18 02:15:32 +0000517 let noNamedPositionallyEncodedOperands = 1;
Tom Stellard75aadc22012-12-11 21:25:42 +0000518}
519
Tom Stellard9d7ddd52014-11-14 14:08:00 +0000520def AMDGPUAsmParser : AsmParser {
521 // Some of the R600 registers have the same name, so this crashes.
522 // For example T0_XYZW and T0_XY both have the asm name T0.
523 let ShouldEmitMatchRegisterName = 0;
524}
525
Konstantin Zhuravlyovda4687c2016-09-27 14:42:48 +0000526def AMDGPUAsmWriter : AsmWriter {
527 int PassSubtarget = 1;
528}
529
Sam Koltond63d8a72016-09-09 09:37:51 +0000530def AMDGPUAsmVariants {
531 string Default = "Default";
532 int Default_ID = 0;
533 string VOP3 = "VOP3";
534 int VOP3_ID = 1;
535 string SDWA = "SDWA";
536 int SDWA_ID = 2;
Sam Koltonf7659d712017-05-23 10:08:55 +0000537 string SDWA9 = "SDWA9";
538 int SDWA9_ID = 3;
Sam Koltond63d8a72016-09-09 09:37:51 +0000539 string DPP = "DPP";
Sam Koltonf7659d712017-05-23 10:08:55 +0000540 int DPP_ID = 4;
Sam Koltonfb0d9d92016-09-12 14:42:43 +0000541 string Disable = "Disable";
Sam Koltonf7659d712017-05-23 10:08:55 +0000542 int Disable_ID = 5;
Sam Koltond63d8a72016-09-09 09:37:51 +0000543}
544
545def DefaultAMDGPUAsmParserVariant : AsmParserVariant {
546 let Variant = AMDGPUAsmVariants.Default_ID;
547 let Name = AMDGPUAsmVariants.Default;
548}
549
550def VOP3AsmParserVariant : AsmParserVariant {
551 let Variant = AMDGPUAsmVariants.VOP3_ID;
552 let Name = AMDGPUAsmVariants.VOP3;
553}
554
555def SDWAAsmParserVariant : AsmParserVariant {
556 let Variant = AMDGPUAsmVariants.SDWA_ID;
557 let Name = AMDGPUAsmVariants.SDWA;
558}
559
Sam Koltonf7659d712017-05-23 10:08:55 +0000560def SDWA9AsmParserVariant : AsmParserVariant {
561 let Variant = AMDGPUAsmVariants.SDWA9_ID;
562 let Name = AMDGPUAsmVariants.SDWA9;
563}
564
565
Sam Koltond63d8a72016-09-09 09:37:51 +0000566def DPPAsmParserVariant : AsmParserVariant {
567 let Variant = AMDGPUAsmVariants.DPP_ID;
568 let Name = AMDGPUAsmVariants.DPP;
569}
570
Tom Stellard75aadc22012-12-11 21:25:42 +0000571def AMDGPU : Target {
572 // Pull in Instruction Info:
573 let InstructionSet = AMDGPUInstrInfo;
Tom Stellard9d7ddd52014-11-14 14:08:00 +0000574 let AssemblyParsers = [AMDGPUAsmParser];
Sam Koltond63d8a72016-09-09 09:37:51 +0000575 let AssemblyParserVariants = [DefaultAMDGPUAsmParserVariant,
576 VOP3AsmParserVariant,
577 SDWAAsmParserVariant,
Sam Koltonf7659d712017-05-23 10:08:55 +0000578 SDWA9AsmParserVariant,
Sam Koltond63d8a72016-09-09 09:37:51 +0000579 DPPAsmParserVariant];
Konstantin Zhuravlyovda4687c2016-09-27 14:42:48 +0000580 let AssemblyWriters = [AMDGPUAsmWriter];
Tom Stellard75aadc22012-12-11 21:25:42 +0000581}
582
Tom Stellardbc5b5372014-06-13 16:38:59 +0000583// Dummy Instruction itineraries for pseudo instructions
584def ALU_NULL : FuncUnit;
585def NullALU : InstrItinClass;
586
Tom Stellard0e70de52014-05-16 20:56:45 +0000587//===----------------------------------------------------------------------===//
588// Predicate helper class
589//===----------------------------------------------------------------------===//
590
Tom Stellardd1f0f022015-04-23 19:33:54 +0000591def TruePredicate : Predicate<"true">;
Matt Arsenault382d9452016-01-26 04:49:22 +0000592
Tom Stellardd1f0f022015-04-23 19:33:54 +0000593def isSICI : Predicate<
594 "Subtarget->getGeneration() == AMDGPUSubtarget::SOUTHERN_ISLANDS ||"
595 "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS"
596>, AssemblerPredicate<"FeatureGCN1Encoding">;
597
Tom Stellard5ebdfbe2015-12-24 03:18:18 +0000598def isVI : Predicate <
599 "Subtarget->getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS">,
600 AssemblerPredicate<"FeatureGCN3Encoding">;
601
Matt Arsenault2021f082017-02-18 19:12:26 +0000602def isGFX9 : Predicate <
603 "Subtarget->getGeneration() >= AMDGPUSubtarget::GFX9">,
604 AssemblerPredicate<"FeatureGFX9Insts">;
605
Matt Arsenaulte823d922017-02-18 18:29:53 +0000606// TODO: Either the name to be changed or we simply use IsCI!
Matt Arsenault382d9452016-01-26 04:49:22 +0000607def isCIVI : Predicate <
Matt Arsenaulte823d922017-02-18 18:29:53 +0000608 "Subtarget->getGeneration() >= AMDGPUSubtarget::SEA_ISLANDS">,
609 AssemblerPredicate<"FeatureCIInsts">;
Matt Arsenault382d9452016-01-26 04:49:22 +0000610
611def HasFlatAddressSpace : Predicate<"Subtarget->hasFlatAddressSpace()">;
612
Matt Arsenault9be7b0d2017-02-27 18:49:11 +0000613def Has16BitInsts : Predicate<"Subtarget->has16BitInsts()">,
614 AssemblerPredicate<"Feature16BitInsts">;
615def HasVOP3PInsts : Predicate<"Subtarget->hasVOP3PInsts()">,
616 AssemblerPredicate<"FeatureVOP3P">;
Tom Stellard115a6152016-11-10 16:02:37 +0000617
Sam Kolton07dbde22017-01-20 10:01:25 +0000618def HasSDWA : Predicate<"Subtarget->hasSDWA()">,
Sam Koltonf7659d712017-05-23 10:08:55 +0000619 AssemblerPredicate<"FeatureSDWA,FeatureVolcanicIslands">;
620
621def HasSDWA9 : Predicate<"Subtarget->hasSDWA()">,
622 AssemblerPredicate<"FeatureSDWA,FeatureGFX9">;
Sam Kolton07dbde22017-01-20 10:01:25 +0000623
624def HasDPP : Predicate<"Subtarget->hasDPP()">,
625 AssemblerPredicate<"FeatureDPP">;
626
Tom Stellard0e70de52014-05-16 20:56:45 +0000627class PredicateControl {
628 Predicate SubtargetPredicate;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000629 Predicate SIAssemblerPredicate = isSICI;
Tom Stellard5ebdfbe2015-12-24 03:18:18 +0000630 Predicate VIAssemblerPredicate = isVI;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000631 list<Predicate> AssemblerPredicates = [];
Tom Stellardd1f0f022015-04-23 19:33:54 +0000632 Predicate AssemblerPredicate = TruePredicate;
Tom Stellard0e70de52014-05-16 20:56:45 +0000633 list<Predicate> OtherPredicates = [];
Tom Stellardd1f0f022015-04-23 19:33:54 +0000634 list<Predicate> Predicates = !listconcat([SubtargetPredicate, AssemblerPredicate],
Tom Stellardd7e6f132015-04-08 01:09:26 +0000635 AssemblerPredicates,
Tom Stellard0e70de52014-05-16 20:56:45 +0000636 OtherPredicates);
637}
638
Tom Stellard75aadc22012-12-11 21:25:42 +0000639// Include AMDGPU TD files
640include "R600Schedule.td"
641include "SISchedule.td"
642include "Processors.td"
643include "AMDGPUInstrInfo.td"
644include "AMDGPUIntrinsics.td"
645include "AMDGPURegisterInfo.td"
Tom Stellardca166212017-01-30 21:56:46 +0000646include "AMDGPURegisterBanks.td"
Tom Stellard75aadc22012-12-11 21:25:42 +0000647include "AMDGPUInstructions.td"
Christian Konig2c8f6d52013-03-07 09:03:52 +0000648include "AMDGPUCallingConv.td"