1 //===-- AMDGPU.td - AMDGPU Tablegen files --------*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===------------------------------------------------------------===//
10 include "llvm/Target/Target.td"
12 //===------------------------------------------------------------===//
13 // Subtarget Features (device properties)
14 //===------------------------------------------------------------===//
16 def FeatureFP64 : SubtargetFeature<"fp64",
19 "Enable double precision operations"
22 def FeatureFastFMAF32 : SubtargetFeature<"fast-fmaf",
25 "Assuming f32 fma is at least as fast as mul + add"
28 def HalfRate64Ops : SubtargetFeature<"half-rate-64-ops",
31 "Most fp64 instructions are half rate instead of quarter"
34 def FeatureR600ALUInst : SubtargetFeature<"R600ALUInst",
37 "Older version of ALU instructions encoding"
40 def FeatureVertexCache : SubtargetFeature<"HasVertexCache",
43 "Specify use of dedicated vertex cache"
46 def FeatureCaymanISA : SubtargetFeature<"caymanISA",
52 def FeatureCFALUBug : SubtargetFeature<"cfalubug",
58 def FeatureFlatAddressSpace : SubtargetFeature<"flat-address-space",
61 "Support flat address space"
64 def FeatureUnalignedBufferAccess : SubtargetFeature<"unaligned-buffer-access",
65 "UnalignedBufferAccess",
67 "Support unaligned global loads and stores"
70 def FeatureUnalignedScratchAccess : SubtargetFeature<"unaligned-scratch-access",
71 "UnalignedScratchAccess",
73 "Support unaligned scratch loads and stores"
76 // XNACK is disabled if SH_MEM_CONFIG.ADDRESS_MODE = GPUVM on chips that support
77 // XNACK. The current default kernel driver setting is:
78 // - graphics ring: XNACK disabled
79 // - compute ring: XNACK enabled
81 // If XNACK is enabled, the VMEM latency can be worse.
82 // If XNACK is disabled, the 2 SGPRs can be used for general purposes.
83 def FeatureXNACK : SubtargetFeature<"xnack",
86 "Enable XNACK support"
89 def FeatureSGPRInitBug : SubtargetFeature<"sgpr-init-bug",
92 "VI SGPR initilization bug requiring a fixed SGPR allocation size"
95 class SubtargetFeatureFetchLimit <string Value> :
96 SubtargetFeature <"fetch"#Value,
99 "Limit the maximum number of fetches in a clause to "#Value
102 def FeatureFetchLimit8 : SubtargetFeatureFetchLimit <"8">;
103 def FeatureFetchLimit16 : SubtargetFeatureFetchLimit <"16">;
105 class SubtargetFeatureWavefrontSize <int Value> : SubtargetFeature<
106 "wavefrontsize"#Value,
108 !cast<string>(Value),
109 "The number of threads per wavefront"
112 def FeatureWavefrontSize16 : SubtargetFeatureWavefrontSize<16>;
113 def FeatureWavefrontSize32 : SubtargetFeatureWavefrontSize<32>;
114 def FeatureWavefrontSize64 : SubtargetFeatureWavefrontSize<64>;
116 class SubtargetFeatureLDSBankCount <int Value> : SubtargetFeature <
117 "ldsbankcount"#Value,
119 !cast<string>(Value),
120 "The number of LDS banks per compute unit."
123 def FeatureLDSBankCount16 : SubtargetFeatureLDSBankCount<16>;
124 def FeatureLDSBankCount32 : SubtargetFeatureLDSBankCount<32>;
126 class SubtargetFeatureLocalMemorySize <int Value> : SubtargetFeature<
127 "localmemorysize"#Value,
129 !cast<string>(Value),
130 "The size of local memory in bytes"
133 def FeatureGCN : SubtargetFeature<"gcn",
139 def FeatureGCN1Encoding : SubtargetFeature<"gcn1-encoding",
142 "Encoding format for SI and CI"
145 def FeatureGCN3Encoding : SubtargetFeature<"gcn3-encoding",
148 "Encoding format for VI"
151 def FeatureCIInsts : SubtargetFeature<"ci-insts",
154 "Additional intstructions for CI+"
157 def FeatureSMemRealTime : SubtargetFeature<"s-memrealtime",
160 "Has s_memrealtime instruction"
163 def FeatureInv2PiInlineImm : SubtargetFeature<"inv-2pi-inline-imm",
164 "HasInv2PiInlineImm",
166 "Has 1 / (2 * pi) as inline immediate"
169 def Feature16BitInsts : SubtargetFeature<"16-bit-insts",
172 "Has i16/f16 instructions"
175 def FeatureMovrel : SubtargetFeature<"movrel",
178 "Has v_movrel*_b32 instructions"
181 def FeatureVGPRIndexMode : SubtargetFeature<"vgpr-index-mode",
184 "Has VGPR mode register indexing"
187 def FeatureScalarStores : SubtargetFeature<"scalar-stores",
190 "Has store scalar memory instructions"
193 //===------------------------------------------------------------===//
194 // Subtarget Features (options and debugging)
195 //===------------------------------------------------------------===//
197 def FeatureFP16Denormals : SubtargetFeature<"fp16-denormals",
200 "Enable half precision denormal handling"
203 // Some instructions do not support denormals despite this flag. Using
204 // fp32 denormals also causes instructions to run at the double
205 // precision rate for the device.
206 def FeatureFP32Denormals : SubtargetFeature<"fp32-denormals",
209 "Enable single precision denormal handling"
212 def FeatureFP64Denormals : SubtargetFeature<"fp64-denormals",
215 "Enable double precision denormal handling",
219 def FeatureFPExceptions : SubtargetFeature<"fp-exceptions",
222 "Enable floating point exceptions"
225 class FeatureMaxPrivateElementSize<int size> : SubtargetFeature<
226 "max-private-element-size-"#size,
227 "MaxPrivateElementSize",
229 "Maximum private access size may be "#size
232 def FeatureMaxPrivateElementSize4 : FeatureMaxPrivateElementSize<4>;
233 def FeatureMaxPrivateElementSize8 : FeatureMaxPrivateElementSize<8>;
234 def FeatureMaxPrivateElementSize16 : FeatureMaxPrivateElementSize<16>;
236 def FeatureVGPRSpilling : SubtargetFeature<"vgpr-spilling",
237 "EnableVGPRSpilling",
239 "Enable spilling of VGPRs to scratch memory"
242 def FeatureDumpCode : SubtargetFeature <"DumpCode",
245 "Dump MachineInstrs in the CodeEmitter"
248 def FeatureDumpCodeLower : SubtargetFeature <"dumpcode",
251 "Dump MachineInstrs in the CodeEmitter"
254 def FeaturePromoteAlloca : SubtargetFeature <"promote-alloca",
255 "EnablePromoteAlloca",
257 "Enable promote alloca pass"
260 // XXX - This should probably be removed once enabled by default
261 def FeatureEnableLoadStoreOpt : SubtargetFeature <"load-store-opt",
262 "EnableLoadStoreOpt",
264 "Enable SI load/store optimizer pass"
267 // Performance debugging feature. Allow using DS instruction immediate
268 // offsets even if the base pointer can't be proven to be base. On SI,
269 // base pointer values that won't give the same result as a 16-bit add
270 // are not safe to fold, but this will override the conservative test
271 // for the base pointer.
272 def FeatureEnableUnsafeDSOffsetFolding : SubtargetFeature <
273 "unsafe-ds-offset-folding",
274 "EnableUnsafeDSOffsetFolding",
276 "Force using DS instruction immediate offsets on SI"
279 def FeatureEnableSIScheduler : SubtargetFeature<"si-scheduler",
282 "Enable SI Machine Scheduler"
285 // Unless +-flat-for-global is specified, turn on FlatForGlobal for
286 // all OS-es on VI and newer hardware to avoid assertion failures due
287 // to missing ADDR64 variants of MUBUF instructions.
288 // FIXME: moveToVALU should be able to handle converting addr64 MUBUF
291 def FeatureFlatForGlobal : SubtargetFeature<"flat-for-global",
294 "Force to generate flat instruction for global"
297 // Dummy feature used to disable assembler instructions.
298 def FeatureDisable : SubtargetFeature<"",
299 "FeatureDisable","true",
300 "Dummy feature to disable assembler instructions"
303 class SubtargetFeatureGeneration <string Value,
304 list<SubtargetFeature> Implies> :
305 SubtargetFeature <Value, "Gen", "AMDGPUSubtarget::"#Value,
306 Value#" GPU generation", Implies>;
308 def FeatureLocalMemorySize0 : SubtargetFeatureLocalMemorySize<0>;
309 def FeatureLocalMemorySize32768 : SubtargetFeatureLocalMemorySize<32768>;
310 def FeatureLocalMemorySize65536 : SubtargetFeatureLocalMemorySize<65536>;
312 def FeatureR600 : SubtargetFeatureGeneration<"R600",
313 [FeatureR600ALUInst, FeatureFetchLimit8, FeatureLocalMemorySize0]
316 def FeatureR700 : SubtargetFeatureGeneration<"R700",
317 [FeatureFetchLimit16, FeatureLocalMemorySize0]
320 def FeatureEvergreen : SubtargetFeatureGeneration<"EVERGREEN",
321 [FeatureFetchLimit16, FeatureLocalMemorySize32768]
324 def FeatureNorthernIslands : SubtargetFeatureGeneration<"NORTHERN_ISLANDS",
325 [FeatureFetchLimit16, FeatureWavefrontSize64,
326 FeatureLocalMemorySize32768]
329 def FeatureSouthernIslands : SubtargetFeatureGeneration<"SOUTHERN_ISLANDS",
330 [FeatureFP64, FeatureLocalMemorySize32768,
331 FeatureWavefrontSize64, FeatureGCN, FeatureGCN1Encoding,
332 FeatureLDSBankCount32, FeatureMovrel]
335 def FeatureSeaIslands : SubtargetFeatureGeneration<"SEA_ISLANDS",
336 [FeatureFP64, FeatureLocalMemorySize65536,
337 FeatureWavefrontSize64, FeatureGCN, FeatureFlatAddressSpace,
338 FeatureGCN1Encoding, FeatureCIInsts, FeatureMovrel]
341 def FeatureVolcanicIslands : SubtargetFeatureGeneration<"VOLCANIC_ISLANDS",
342 [FeatureFP64, FeatureLocalMemorySize65536,
343 FeatureWavefrontSize64, FeatureFlatAddressSpace, FeatureGCN,
344 FeatureGCN3Encoding, FeatureCIInsts, Feature16BitInsts,
345 FeatureSMemRealTime, FeatureVGPRIndexMode, FeatureMovrel,
346 FeatureScalarStores, FeatureInv2PiInlineImm
350 class SubtargetFeatureISAVersion <int Major, int Minor, int Stepping,
351 list<SubtargetFeature> Implies>
353 "isaver"#Major#"."#Minor#"."#Stepping,
355 "ISAVersion"#Major#"_"#Minor#"_"#Stepping,
356 "Instruction set version number",
360 def FeatureISAVersion7_0_0 : SubtargetFeatureISAVersion <7,0,0,
362 FeatureLDSBankCount32]>;
364 def FeatureISAVersion7_0_1 : SubtargetFeatureISAVersion <7,0,1,
367 FeatureLDSBankCount32,
370 def FeatureISAVersion7_0_2 : SubtargetFeatureISAVersion <7,0,2,
372 FeatureLDSBankCount16]>;
374 def FeatureISAVersion8_0_0 : SubtargetFeatureISAVersion <8,0,0,
375 [FeatureVolcanicIslands,
376 FeatureLDSBankCount32,
377 FeatureSGPRInitBug]>;
379 def FeatureISAVersion8_0_1 : SubtargetFeatureISAVersion <8,0,1,
380 [FeatureVolcanicIslands,
381 FeatureLDSBankCount32,
384 def FeatureISAVersion8_0_2 : SubtargetFeatureISAVersion <8,0,2,
385 [FeatureVolcanicIslands,
386 FeatureLDSBankCount32,
387 FeatureSGPRInitBug]>;
389 def FeatureISAVersion8_0_3 : SubtargetFeatureISAVersion <8,0,3,
390 [FeatureVolcanicIslands,
391 FeatureLDSBankCount32]>;
393 def FeatureISAVersion8_0_4 : SubtargetFeatureISAVersion <8,0,4,
394 [FeatureVolcanicIslands,
395 FeatureLDSBankCount32]>;
397 def FeatureISAVersion8_1_0 : SubtargetFeatureISAVersion <8,1,0,
398 [FeatureVolcanicIslands,
399 FeatureLDSBankCount16,
402 //===----------------------------------------------------------------------===//
403 // Debugger related subtarget features.
404 //===----------------------------------------------------------------------===//
406 def FeatureDebuggerInsertNops : SubtargetFeature<
407 "amdgpu-debugger-insert-nops",
408 "DebuggerInsertNops",
410 "Insert one nop instruction for each high level source statement"
413 def FeatureDebuggerReserveRegs : SubtargetFeature<
414 "amdgpu-debugger-reserve-regs",
415 "DebuggerReserveRegs",
417 "Reserve registers for debugger usage"
420 def FeatureDebuggerEmitPrologue : SubtargetFeature<
421 "amdgpu-debugger-emit-prologue",
422 "DebuggerEmitPrologue",
424 "Emit debugger prologue"
427 //===----------------------------------------------------------------------===//
429 def AMDGPUInstrInfo : InstrInfo {
430 let guessInstructionProperties = 1;
431 let noNamedPositionallyEncodedOperands = 1;
434 def AMDGPUAsmParser : AsmParser {
435 // Some of the R600 registers have the same name, so this crashes.
436 // For example T0_XYZW and T0_XY both have the asm name T0.
437 let ShouldEmitMatchRegisterName = 0;
440 def AMDGPUAsmWriter : AsmWriter {
441 int PassSubtarget = 1;
444 def AMDGPUAsmVariants {
445 string Default = "Default";
447 string VOP3 = "VOP3";
449 string SDWA = "SDWA";
453 string Disable = "Disable";
457 def DefaultAMDGPUAsmParserVariant : AsmParserVariant {
458 let Variant = AMDGPUAsmVariants.Default_ID;
459 let Name = AMDGPUAsmVariants.Default;
462 def VOP3AsmParserVariant : AsmParserVariant {
463 let Variant = AMDGPUAsmVariants.VOP3_ID;
464 let Name = AMDGPUAsmVariants.VOP3;
467 def SDWAAsmParserVariant : AsmParserVariant {
468 let Variant = AMDGPUAsmVariants.SDWA_ID;
469 let Name = AMDGPUAsmVariants.SDWA;
472 def DPPAsmParserVariant : AsmParserVariant {
473 let Variant = AMDGPUAsmVariants.DPP_ID;
474 let Name = AMDGPUAsmVariants.DPP;
477 def AMDGPU : Target {
478 // Pull in Instruction Info:
479 let InstructionSet = AMDGPUInstrInfo;
480 let AssemblyParsers = [AMDGPUAsmParser];
481 let AssemblyParserVariants = [DefaultAMDGPUAsmParserVariant,
482 VOP3AsmParserVariant,
483 SDWAAsmParserVariant,
484 DPPAsmParserVariant];
485 let AssemblyWriters = [AMDGPUAsmWriter];
488 // Dummy Instruction itineraries for pseudo instructions
489 def ALU_NULL : FuncUnit;
490 def NullALU : InstrItinClass;
492 //===----------------------------------------------------------------------===//
493 // Predicate helper class
494 //===----------------------------------------------------------------------===//
496 def TruePredicate : Predicate<"true">;
498 def isSICI : Predicate<
499 "Subtarget->getGeneration() == AMDGPUSubtarget::SOUTHERN_ISLANDS ||"
500 "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS"
501 >, AssemblerPredicate<"FeatureGCN1Encoding">;
503 def isVI : Predicate <
504 "Subtarget->getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS">,
505 AssemblerPredicate<"FeatureGCN3Encoding">;
507 def isCIVI : Predicate <
508 "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS || "
509 "Subtarget->getGeneration() == AMDGPUSubtarget::VOLCANIC_ISLANDS"
510 >, AssemblerPredicate<"FeatureCIInsts">;
512 def HasFlatAddressSpace : Predicate<"Subtarget->hasFlatAddressSpace()">;
514 def Has16BitInsts : Predicate<"Subtarget->has16BitInsts()">;
516 class PredicateControl {
517 Predicate SubtargetPredicate;
518 Predicate SIAssemblerPredicate = isSICI;
519 Predicate VIAssemblerPredicate = isVI;
520 list<Predicate> AssemblerPredicates = [];
521 Predicate AssemblerPredicate = TruePredicate;
522 list<Predicate> OtherPredicates = [];
523 list<Predicate> Predicates = !listconcat([SubtargetPredicate, AssemblerPredicate],
528 // Include AMDGPU TD files
529 include "R600Schedule.td"
530 include "SISchedule.td"
531 include "Processors.td"
532 include "AMDGPUInstrInfo.td"
533 include "AMDGPUIntrinsics.td"
534 include "AMDGPURegisterInfo.td"
535 include "AMDGPUInstructions.td"
536 include "AMDGPUCallingConv.td"