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 def FeatureFlatForGlobal : SubtargetFeature<"flat-for-global",
288 "Force to generate flat instruction for global"
291 // Dummy feature used to disable assembler instructions.
292 def FeatureDisable : SubtargetFeature<"",
293 "FeatureDisable","true",
294 "Dummy feature to disable assembler instructions"
297 class SubtargetFeatureGeneration <string Value,
298 list<SubtargetFeature> Implies> :
299 SubtargetFeature <Value, "Gen", "AMDGPUSubtarget::"#Value,
300 Value#" GPU generation", Implies>;
302 def FeatureLocalMemorySize0 : SubtargetFeatureLocalMemorySize<0>;
303 def FeatureLocalMemorySize32768 : SubtargetFeatureLocalMemorySize<32768>;
304 def FeatureLocalMemorySize65536 : SubtargetFeatureLocalMemorySize<65536>;
306 def FeatureR600 : SubtargetFeatureGeneration<"R600",
307 [FeatureR600ALUInst, FeatureFetchLimit8, FeatureLocalMemorySize0]
310 def FeatureR700 : SubtargetFeatureGeneration<"R700",
311 [FeatureFetchLimit16, FeatureLocalMemorySize0]
314 def FeatureEvergreen : SubtargetFeatureGeneration<"EVERGREEN",
315 [FeatureFetchLimit16, FeatureLocalMemorySize32768]
318 def FeatureNorthernIslands : SubtargetFeatureGeneration<"NORTHERN_ISLANDS",
319 [FeatureFetchLimit16, FeatureWavefrontSize64,
320 FeatureLocalMemorySize32768]
323 def FeatureSouthernIslands : SubtargetFeatureGeneration<"SOUTHERN_ISLANDS",
324 [FeatureFP64, FeatureLocalMemorySize32768,
325 FeatureWavefrontSize64, FeatureGCN, FeatureGCN1Encoding,
326 FeatureLDSBankCount32, FeatureMovrel]
329 def FeatureSeaIslands : SubtargetFeatureGeneration<"SEA_ISLANDS",
330 [FeatureFP64, FeatureLocalMemorySize65536,
331 FeatureWavefrontSize64, FeatureGCN, FeatureFlatAddressSpace,
332 FeatureGCN1Encoding, FeatureCIInsts, FeatureMovrel]
335 def FeatureVolcanicIslands : SubtargetFeatureGeneration<"VOLCANIC_ISLANDS",
336 [FeatureFP64, FeatureLocalMemorySize65536,
337 FeatureWavefrontSize64, FeatureFlatAddressSpace, FeatureGCN,
338 FeatureGCN3Encoding, FeatureCIInsts, Feature16BitInsts,
339 FeatureSMemRealTime, FeatureVGPRIndexMode, FeatureMovrel,
340 FeatureScalarStores, FeatureInv2PiInlineImm
344 class SubtargetFeatureISAVersion <int Major, int Minor, int Stepping,
345 list<SubtargetFeature> Implies>
347 "isaver"#Major#"."#Minor#"."#Stepping,
349 "ISAVersion"#Major#"_"#Minor#"_"#Stepping,
350 "Instruction set version number",
354 def FeatureISAVersion7_0_0 : SubtargetFeatureISAVersion <7,0,0,
356 FeatureLDSBankCount32]>;
358 def FeatureISAVersion7_0_1 : SubtargetFeatureISAVersion <7,0,1,
361 FeatureLDSBankCount32,
364 def FeatureISAVersion7_0_2 : SubtargetFeatureISAVersion <7,0,2,
366 FeatureLDSBankCount16]>;
368 def FeatureISAVersion8_0_0 : SubtargetFeatureISAVersion <8,0,0,
369 [FeatureVolcanicIslands,
370 FeatureLDSBankCount32,
371 FeatureSGPRInitBug]>;
373 def FeatureISAVersion8_0_1 : SubtargetFeatureISAVersion <8,0,1,
374 [FeatureVolcanicIslands,
375 FeatureLDSBankCount32,
378 def FeatureISAVersion8_0_2 : SubtargetFeatureISAVersion <8,0,2,
379 [FeatureVolcanicIslands,
380 FeatureLDSBankCount32,
381 FeatureSGPRInitBug]>;
383 def FeatureISAVersion8_0_3 : SubtargetFeatureISAVersion <8,0,3,
384 [FeatureVolcanicIslands,
385 FeatureLDSBankCount32]>;
387 def FeatureISAVersion8_0_4 : SubtargetFeatureISAVersion <8,0,4,
388 [FeatureVolcanicIslands,
389 FeatureLDSBankCount32]>;
391 def FeatureISAVersion8_1_0 : SubtargetFeatureISAVersion <8,1,0,
392 [FeatureVolcanicIslands,
393 FeatureLDSBankCount16,
396 //===----------------------------------------------------------------------===//
397 // Debugger related subtarget features.
398 //===----------------------------------------------------------------------===//
400 def FeatureDebuggerInsertNops : SubtargetFeature<
401 "amdgpu-debugger-insert-nops",
402 "DebuggerInsertNops",
404 "Insert one nop instruction for each high level source statement"
407 def FeatureDebuggerReserveRegs : SubtargetFeature<
408 "amdgpu-debugger-reserve-regs",
409 "DebuggerReserveRegs",
411 "Reserve registers for debugger usage"
414 def FeatureDebuggerEmitPrologue : SubtargetFeature<
415 "amdgpu-debugger-emit-prologue",
416 "DebuggerEmitPrologue",
418 "Emit debugger prologue"
421 //===----------------------------------------------------------------------===//
423 def AMDGPUInstrInfo : InstrInfo {
424 let guessInstructionProperties = 1;
425 let noNamedPositionallyEncodedOperands = 1;
428 def AMDGPUAsmParser : AsmParser {
429 // Some of the R600 registers have the same name, so this crashes.
430 // For example T0_XYZW and T0_XY both have the asm name T0.
431 let ShouldEmitMatchRegisterName = 0;
434 def AMDGPUAsmWriter : AsmWriter {
435 int PassSubtarget = 1;
438 def AMDGPUAsmVariants {
439 string Default = "Default";
441 string VOP3 = "VOP3";
443 string SDWA = "SDWA";
447 string Disable = "Disable";
451 def DefaultAMDGPUAsmParserVariant : AsmParserVariant {
452 let Variant = AMDGPUAsmVariants.Default_ID;
453 let Name = AMDGPUAsmVariants.Default;
456 def VOP3AsmParserVariant : AsmParserVariant {
457 let Variant = AMDGPUAsmVariants.VOP3_ID;
458 let Name = AMDGPUAsmVariants.VOP3;
461 def SDWAAsmParserVariant : AsmParserVariant {
462 let Variant = AMDGPUAsmVariants.SDWA_ID;
463 let Name = AMDGPUAsmVariants.SDWA;
466 def DPPAsmParserVariant : AsmParserVariant {
467 let Variant = AMDGPUAsmVariants.DPP_ID;
468 let Name = AMDGPUAsmVariants.DPP;
471 def AMDGPU : Target {
472 // Pull in Instruction Info:
473 let InstructionSet = AMDGPUInstrInfo;
474 let AssemblyParsers = [AMDGPUAsmParser];
475 let AssemblyParserVariants = [DefaultAMDGPUAsmParserVariant,
476 VOP3AsmParserVariant,
477 SDWAAsmParserVariant,
478 DPPAsmParserVariant];
479 let AssemblyWriters = [AMDGPUAsmWriter];
482 // Dummy Instruction itineraries for pseudo instructions
483 def ALU_NULL : FuncUnit;
484 def NullALU : InstrItinClass;
486 //===----------------------------------------------------------------------===//
487 // Predicate helper class
488 //===----------------------------------------------------------------------===//
490 def TruePredicate : Predicate<"true">;
492 def isSICI : Predicate<
493 "Subtarget->getGeneration() == AMDGPUSubtarget::SOUTHERN_ISLANDS ||"
494 "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS"
495 >, AssemblerPredicate<"FeatureGCN1Encoding">;
497 def isVI : Predicate <
498 "Subtarget->getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS">,
499 AssemblerPredicate<"FeatureGCN3Encoding">;
501 def isCIVI : Predicate <
502 "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS || "
503 "Subtarget->getGeneration() == AMDGPUSubtarget::VOLCANIC_ISLANDS"
504 >, AssemblerPredicate<"FeatureCIInsts">;
506 def HasFlatAddressSpace : Predicate<"Subtarget->hasFlatAddressSpace()">;
508 def Has16BitInsts : Predicate<"Subtarget->has16BitInsts()">;
510 class PredicateControl {
511 Predicate SubtargetPredicate;
512 Predicate SIAssemblerPredicate = isSICI;
513 Predicate VIAssemblerPredicate = isVI;
514 list<Predicate> AssemblerPredicates = [];
515 Predicate AssemblerPredicate = TruePredicate;
516 list<Predicate> OtherPredicates = [];
517 list<Predicate> Predicates = !listconcat([SubtargetPredicate, AssemblerPredicate],
522 // Include AMDGPU TD files
523 include "R600Schedule.td"
524 include "SISchedule.td"
525 include "Processors.td"
526 include "AMDGPUInstrInfo.td"
527 include "AMDGPUIntrinsics.td"
528 include "AMDGPURegisterInfo.td"
529 include "AMDGPUInstructions.td"
530 include "AMDGPUCallingConv.td"