]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/AMDGPU/AMDGPU.td
Merge ^/head r317971 through r318379.
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / AMDGPU / AMDGPU.td
1 //===-- AMDGPU.td - AMDGPU Tablegen files --------*- tablegen -*-===//
2 //
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 //
8 //===------------------------------------------------------------===//
9
10 include "llvm/Target/Target.td"
11
12 //===------------------------------------------------------------===//
13 // Subtarget Features (device properties)
14 //===------------------------------------------------------------===//
15
16 def FeatureFP64 : SubtargetFeature<"fp64",
17   "FP64",
18   "true",
19   "Enable double precision operations"
20 >;
21
22 def FeatureFastFMAF32 : SubtargetFeature<"fast-fmaf",
23   "FastFMAF32",
24   "true",
25   "Assuming f32 fma is at least as fast as mul + add"
26 >;
27
28 def HalfRate64Ops : SubtargetFeature<"half-rate-64-ops",
29   "HalfRate64Ops",
30   "true",
31   "Most fp64 instructions are half rate instead of quarter"
32 >;
33
34 def FeatureR600ALUInst : SubtargetFeature<"R600ALUInst",
35   "R600ALUInst",
36   "false",
37   "Older version of ALU instructions encoding"
38 >;
39
40 def FeatureVertexCache : SubtargetFeature<"HasVertexCache",
41   "HasVertexCache",
42   "true",
43   "Specify use of dedicated vertex cache"
44 >;
45
46 def FeatureCaymanISA : SubtargetFeature<"caymanISA",
47   "CaymanISA",
48   "true",
49   "Use Cayman ISA"
50 >;
51
52 def FeatureCFALUBug : SubtargetFeature<"cfalubug",
53   "CFALUBug",
54   "true",
55   "GPU has CF_ALU bug"
56 >;
57
58 def FeatureFlatAddressSpace : SubtargetFeature<"flat-address-space",
59   "FlatAddressSpace",
60   "true",
61   "Support flat address space"
62 >;
63
64 def FeatureUnalignedBufferAccess : SubtargetFeature<"unaligned-buffer-access",
65   "UnalignedBufferAccess",
66   "true",
67   "Support unaligned global loads and stores"
68 >;
69
70 def FeatureTrapHandler: SubtargetFeature<"trap-handler",
71   "TrapHandler",
72   "true",
73   "Trap handler support"
74 >;
75
76 def FeatureUnalignedScratchAccess : SubtargetFeature<"unaligned-scratch-access",
77   "UnalignedScratchAccess",
78   "true",
79   "Support unaligned scratch loads and stores"
80 >;
81
82 def FeatureApertureRegs : SubtargetFeature<"aperture-regs",
83   "HasApertureRegs",
84   "true",
85   "Has Memory Aperture Base and Size Registers"
86 >;
87
88 // XNACK is disabled if SH_MEM_CONFIG.ADDRESS_MODE = GPUVM on chips that support
89 // XNACK. The current default kernel driver setting is:
90 // - graphics ring: XNACK disabled
91 // - compute ring: XNACK enabled
92 //
93 // If XNACK is enabled, the VMEM latency can be worse.
94 // If XNACK is disabled, the 2 SGPRs can be used for general purposes.
95 def FeatureXNACK : SubtargetFeature<"xnack",
96   "EnableXNACK",
97   "true",
98   "Enable XNACK support"
99 >;
100
101 def FeatureSGPRInitBug : SubtargetFeature<"sgpr-init-bug",
102   "SGPRInitBug",
103   "true",
104   "VI SGPR initilization bug requiring a fixed SGPR allocation size"
105 >;
106
107 class SubtargetFeatureFetchLimit <string Value> :
108                           SubtargetFeature <"fetch"#Value,
109   "TexVTXClauseSize",
110   Value,
111   "Limit the maximum number of fetches in a clause to "#Value
112 >;
113
114 def FeatureFetchLimit8 : SubtargetFeatureFetchLimit <"8">;
115 def FeatureFetchLimit16 : SubtargetFeatureFetchLimit <"16">;
116
117 class SubtargetFeatureWavefrontSize <int Value> : SubtargetFeature<
118   "wavefrontsize"#Value,
119   "WavefrontSize",
120   !cast<string>(Value),
121   "The number of threads per wavefront"
122 >;
123
124 def FeatureWavefrontSize16 : SubtargetFeatureWavefrontSize<16>;
125 def FeatureWavefrontSize32 : SubtargetFeatureWavefrontSize<32>;
126 def FeatureWavefrontSize64 : SubtargetFeatureWavefrontSize<64>;
127
128 class SubtargetFeatureLDSBankCount <int Value> : SubtargetFeature <
129   "ldsbankcount"#Value,
130   "LDSBankCount",
131   !cast<string>(Value),
132   "The number of LDS banks per compute unit."
133 >;
134
135 def FeatureLDSBankCount16 : SubtargetFeatureLDSBankCount<16>;
136 def FeatureLDSBankCount32 : SubtargetFeatureLDSBankCount<32>;
137
138 class SubtargetFeatureLocalMemorySize <int Value> : SubtargetFeature<
139   "localmemorysize"#Value,
140   "LocalMemorySize",
141   !cast<string>(Value),
142   "The size of local memory in bytes"
143 >;
144
145 def FeatureGCN : SubtargetFeature<"gcn",
146   "IsGCN",
147   "true",
148   "GCN or newer GPU"
149 >;
150
151 def FeatureGCN1Encoding : SubtargetFeature<"gcn1-encoding",
152   "GCN1Encoding",
153   "true",
154   "Encoding format for SI and CI"
155 >;
156
157 def FeatureGCN3Encoding : SubtargetFeature<"gcn3-encoding",
158   "GCN3Encoding",
159   "true",
160   "Encoding format for VI"
161 >;
162
163 def FeatureCIInsts : SubtargetFeature<"ci-insts",
164   "CIInsts",
165   "true",
166   "Additional intstructions for CI+"
167 >;
168
169 def FeatureGFX9Insts : SubtargetFeature<"gfx9-insts",
170   "GFX9Insts",
171   "true",
172   "Additional intstructions for GFX9+"
173 >;
174
175 def FeatureSMemRealTime : SubtargetFeature<"s-memrealtime",
176   "HasSMemRealTime",
177   "true",
178   "Has s_memrealtime instruction"
179 >;
180
181 def FeatureInv2PiInlineImm : SubtargetFeature<"inv-2pi-inline-imm",
182   "HasInv2PiInlineImm",
183   "true",
184   "Has 1 / (2 * pi) as inline immediate"
185 >;
186
187 def Feature16BitInsts : SubtargetFeature<"16-bit-insts",
188   "Has16BitInsts",
189   "true",
190   "Has i16/f16 instructions"
191 >;
192
193 def FeatureVOP3P : SubtargetFeature<"vop3p",
194   "HasVOP3PInsts",
195   "true",
196   "Has VOP3P packed instructions"
197 >;
198
199 def FeatureMovrel : SubtargetFeature<"movrel",
200   "HasMovrel",
201   "true",
202   "Has v_movrel*_b32 instructions"
203 >;
204
205 def FeatureVGPRIndexMode : SubtargetFeature<"vgpr-index-mode",
206   "HasVGPRIndexMode",
207   "true",
208   "Has VGPR mode register indexing"
209 >;
210
211 def FeatureScalarStores : SubtargetFeature<"scalar-stores",
212   "HasScalarStores",
213   "true",
214   "Has store scalar memory instructions"
215 >;
216
217 def FeatureSDWA : SubtargetFeature<"sdwa",
218   "HasSDWA",
219   "true",
220   "Support SDWA (Sub-DWORD Addressing) extension"
221 >;
222
223 def FeatureDPP : SubtargetFeature<"dpp",
224   "HasDPP",
225   "true",
226   "Support DPP (Data Parallel Primitives) extension"
227 >;
228
229 //===------------------------------------------------------------===//
230 // Subtarget Features (options and debugging)
231 //===------------------------------------------------------------===//
232
233 // Some instructions do not support denormals despite this flag. Using
234 // fp32 denormals also causes instructions to run at the double
235 // precision rate for the device.
236 def FeatureFP32Denormals : SubtargetFeature<"fp32-denormals",
237   "FP32Denormals",
238   "true",
239   "Enable single precision denormal handling"
240 >;
241
242 // Denormal handling for fp64 and fp16 is controlled by the same
243 // config register when fp16 supported.
244 // TODO: Do we need a separate f16 setting when not legal?
245 def FeatureFP64FP16Denormals : SubtargetFeature<"fp64-fp16-denormals",
246   "FP64FP16Denormals",
247   "true",
248   "Enable double and half precision denormal handling",
249   [FeatureFP64]
250 >;
251
252 def FeatureFP64Denormals : SubtargetFeature<"fp64-denormals",
253   "FP64FP16Denormals",
254   "true",
255   "Enable double and half precision denormal handling",
256   [FeatureFP64, FeatureFP64FP16Denormals]
257 >;
258
259 def FeatureFP16Denormals : SubtargetFeature<"fp16-denormals",
260   "FP64FP16Denormals",
261   "true",
262   "Enable half precision denormal handling",
263   [FeatureFP64FP16Denormals]
264 >;
265
266 def FeatureDX10Clamp : SubtargetFeature<"dx10-clamp",
267   "DX10Clamp",
268   "true",
269   "clamp modifier clamps NaNs to 0.0"
270 >;
271
272 def FeatureFPExceptions : SubtargetFeature<"fp-exceptions",
273   "FPExceptions",
274   "true",
275   "Enable floating point exceptions"
276 >;
277
278 class FeatureMaxPrivateElementSize<int size> : SubtargetFeature<
279   "max-private-element-size-"#size,
280   "MaxPrivateElementSize",
281   !cast<string>(size),
282   "Maximum private access size may be "#size
283 >;
284
285 def FeatureMaxPrivateElementSize4 : FeatureMaxPrivateElementSize<4>;
286 def FeatureMaxPrivateElementSize8 : FeatureMaxPrivateElementSize<8>;
287 def FeatureMaxPrivateElementSize16 : FeatureMaxPrivateElementSize<16>;
288
289 def FeatureVGPRSpilling : SubtargetFeature<"vgpr-spilling",
290   "EnableVGPRSpilling",
291   "true",
292   "Enable spilling of VGPRs to scratch memory"
293 >;
294
295 def FeatureDumpCode : SubtargetFeature <"DumpCode",
296   "DumpCode",
297   "true",
298   "Dump MachineInstrs in the CodeEmitter"
299 >;
300
301 def FeatureDumpCodeLower : SubtargetFeature <"dumpcode",
302   "DumpCode",
303   "true",
304   "Dump MachineInstrs in the CodeEmitter"
305 >;
306
307 def FeaturePromoteAlloca : SubtargetFeature <"promote-alloca",
308   "EnablePromoteAlloca",
309   "true",
310   "Enable promote alloca pass"
311 >;
312
313 // XXX - This should probably be removed once enabled by default
314 def FeatureEnableLoadStoreOpt : SubtargetFeature <"load-store-opt",
315   "EnableLoadStoreOpt",
316   "true",
317   "Enable SI load/store optimizer pass"
318 >;
319
320 // Performance debugging feature. Allow using DS instruction immediate
321 // offsets even if the base pointer can't be proven to be base. On SI,
322 // base pointer values that won't give the same result as a 16-bit add
323 // are not safe to fold, but this will override the conservative test
324 // for the base pointer.
325 def FeatureEnableUnsafeDSOffsetFolding : SubtargetFeature <
326   "unsafe-ds-offset-folding",
327   "EnableUnsafeDSOffsetFolding",
328   "true",
329   "Force using DS instruction immediate offsets on SI"
330 >;
331
332 def FeatureEnableSIScheduler : SubtargetFeature<"si-scheduler",
333   "EnableSIScheduler",
334   "true",
335   "Enable SI Machine Scheduler"
336 >;
337
338 // Unless +-flat-for-global is specified, turn on FlatForGlobal for
339 // all OS-es on VI and newer hardware to avoid assertion failures due
340 // to missing ADDR64 variants of MUBUF instructions.
341 // FIXME: moveToVALU should be able to handle converting addr64 MUBUF
342 // instructions.
343
344 def FeatureFlatForGlobal : SubtargetFeature<"flat-for-global",
345   "FlatForGlobal",
346   "true",
347   "Force to generate flat instruction for global"
348 >;
349
350 // Dummy feature used to disable assembler instructions.
351 def FeatureDisable : SubtargetFeature<"",
352   "FeatureDisable","true",
353   "Dummy feature to disable assembler instructions"
354 >;
355
356 class SubtargetFeatureGeneration <string Value,
357                                   list<SubtargetFeature> Implies> :
358         SubtargetFeature <Value, "Gen", "AMDGPUSubtarget::"#Value,
359                           Value#" GPU generation", Implies>;
360
361 def FeatureLocalMemorySize0 : SubtargetFeatureLocalMemorySize<0>;
362 def FeatureLocalMemorySize32768 : SubtargetFeatureLocalMemorySize<32768>;
363 def FeatureLocalMemorySize65536 : SubtargetFeatureLocalMemorySize<65536>;
364
365 def FeatureR600 : SubtargetFeatureGeneration<"R600",
366   [FeatureR600ALUInst, FeatureFetchLimit8, FeatureLocalMemorySize0]
367 >;
368
369 def FeatureR700 : SubtargetFeatureGeneration<"R700",
370   [FeatureFetchLimit16, FeatureLocalMemorySize0]
371 >;
372
373 def FeatureEvergreen : SubtargetFeatureGeneration<"EVERGREEN",
374   [FeatureFetchLimit16, FeatureLocalMemorySize32768]
375 >;
376
377 def FeatureNorthernIslands : SubtargetFeatureGeneration<"NORTHERN_ISLANDS",
378   [FeatureFetchLimit16, FeatureWavefrontSize64,
379    FeatureLocalMemorySize32768]
380 >;
381
382 def FeatureSouthernIslands : SubtargetFeatureGeneration<"SOUTHERN_ISLANDS",
383   [FeatureFP64, FeatureLocalMemorySize32768,
384   FeatureWavefrontSize64, FeatureGCN, FeatureGCN1Encoding,
385   FeatureLDSBankCount32, FeatureMovrel]
386 >;
387
388 def FeatureSeaIslands : SubtargetFeatureGeneration<"SEA_ISLANDS",
389   [FeatureFP64, FeatureLocalMemorySize65536,
390   FeatureWavefrontSize64, FeatureGCN, FeatureFlatAddressSpace,
391   FeatureGCN1Encoding, FeatureCIInsts, FeatureMovrel]
392 >;
393
394 def FeatureVolcanicIslands : SubtargetFeatureGeneration<"VOLCANIC_ISLANDS",
395   [FeatureFP64, FeatureLocalMemorySize65536,
396    FeatureWavefrontSize64, FeatureFlatAddressSpace, FeatureGCN,
397    FeatureGCN3Encoding, FeatureCIInsts, Feature16BitInsts,
398    FeatureSMemRealTime, FeatureVGPRIndexMode, FeatureMovrel,
399    FeatureScalarStores, FeatureInv2PiInlineImm, FeatureSDWA,
400    FeatureDPP
401   ]
402 >;
403
404 def FeatureGFX9 : SubtargetFeatureGeneration<"GFX9",
405   [FeatureFP64, FeatureLocalMemorySize65536,
406    FeatureWavefrontSize64, FeatureFlatAddressSpace, FeatureGCN,
407    FeatureGCN3Encoding, FeatureCIInsts, Feature16BitInsts,
408    FeatureSMemRealTime, FeatureScalarStores, FeatureInv2PiInlineImm,
409    FeatureApertureRegs, FeatureGFX9Insts, FeatureVOP3P, FeatureVGPRIndexMode,
410    FeatureFastFMAF32, FeatureDPP
411   ]
412 >;
413
414 class SubtargetFeatureISAVersion <int Major, int Minor, int Stepping,
415                                   list<SubtargetFeature> Implies>
416                                  : SubtargetFeature <
417   "isaver"#Major#"."#Minor#"."#Stepping,
418   "IsaVersion",
419   "ISAVersion"#Major#"_"#Minor#"_"#Stepping,
420   "Instruction set version number",
421   Implies
422 >;
423
424 def FeatureISAVersion7_0_0 : SubtargetFeatureISAVersion <7,0,0,
425   [FeatureSeaIslands,
426    FeatureLDSBankCount32]>;
427
428 def FeatureISAVersion7_0_1 : SubtargetFeatureISAVersion <7,0,1,
429   [FeatureSeaIslands,
430    HalfRate64Ops,
431    FeatureLDSBankCount32,
432    FeatureFastFMAF32]>;
433
434 def FeatureISAVersion7_0_2 : SubtargetFeatureISAVersion <7,0,2,
435   [FeatureSeaIslands,
436    FeatureLDSBankCount16]>;
437
438 def FeatureISAVersion8_0_0 : SubtargetFeatureISAVersion <8,0,0,
439   [FeatureVolcanicIslands,
440    FeatureLDSBankCount32,
441    FeatureSGPRInitBug]>;
442
443 def FeatureISAVersion8_0_1 : SubtargetFeatureISAVersion <8,0,1,
444   [FeatureVolcanicIslands,
445    FeatureLDSBankCount32,
446    FeatureXNACK]>;
447
448 def FeatureISAVersion8_0_2 : SubtargetFeatureISAVersion <8,0,2,
449   [FeatureVolcanicIslands,
450    FeatureLDSBankCount32,
451    FeatureSGPRInitBug]>;
452
453 def FeatureISAVersion8_0_3 : SubtargetFeatureISAVersion <8,0,3,
454   [FeatureVolcanicIslands,
455    FeatureLDSBankCount32]>;
456
457 def FeatureISAVersion8_0_4 : SubtargetFeatureISAVersion <8,0,4,
458   [FeatureVolcanicIslands,
459    FeatureLDSBankCount32]>;
460
461 def FeatureISAVersion8_1_0 : SubtargetFeatureISAVersion <8,1,0,
462   [FeatureVolcanicIslands,
463    FeatureLDSBankCount16,
464    FeatureXNACK]>;
465
466 def FeatureISAVersion9_0_0 : SubtargetFeatureISAVersion <9,0,0,[]>;
467 def FeatureISAVersion9_0_1 : SubtargetFeatureISAVersion <9,0,1,[]>;
468
469 //===----------------------------------------------------------------------===//
470 // Debugger related subtarget features.
471 //===----------------------------------------------------------------------===//
472
473 def FeatureDebuggerInsertNops : SubtargetFeature<
474   "amdgpu-debugger-insert-nops",
475   "DebuggerInsertNops",
476   "true",
477   "Insert one nop instruction for each high level source statement"
478 >;
479
480 def FeatureDebuggerReserveRegs : SubtargetFeature<
481   "amdgpu-debugger-reserve-regs",
482   "DebuggerReserveRegs",
483   "true",
484   "Reserve registers for debugger usage"
485 >;
486
487 def FeatureDebuggerEmitPrologue : SubtargetFeature<
488   "amdgpu-debugger-emit-prologue",
489   "DebuggerEmitPrologue",
490   "true",
491   "Emit debugger prologue"
492 >;
493
494 //===----------------------------------------------------------------------===//
495
496 def AMDGPUInstrInfo : InstrInfo {
497   let guessInstructionProperties = 1;
498   let noNamedPositionallyEncodedOperands = 1;
499 }
500
501 def AMDGPUAsmParser : AsmParser {
502   // Some of the R600 registers have the same name, so this crashes.
503   // For example T0_XYZW and T0_XY both have the asm name T0.
504   let ShouldEmitMatchRegisterName = 0;
505 }
506
507 def AMDGPUAsmWriter : AsmWriter {
508   int PassSubtarget = 1;
509 }
510
511 def AMDGPUAsmVariants {
512   string Default = "Default";
513   int Default_ID = 0;
514   string VOP3 = "VOP3";
515   int VOP3_ID = 1;
516   string SDWA = "SDWA";
517   int SDWA_ID = 2;
518   string DPP = "DPP";
519   int DPP_ID = 3;
520   string Disable = "Disable";
521   int Disable_ID = 4;
522 }
523
524 def DefaultAMDGPUAsmParserVariant : AsmParserVariant {
525   let Variant = AMDGPUAsmVariants.Default_ID;
526   let Name = AMDGPUAsmVariants.Default;
527 }
528
529 def VOP3AsmParserVariant : AsmParserVariant {
530   let Variant = AMDGPUAsmVariants.VOP3_ID;
531   let Name = AMDGPUAsmVariants.VOP3;
532 }
533
534 def SDWAAsmParserVariant : AsmParserVariant {
535   let Variant = AMDGPUAsmVariants.SDWA_ID;
536   let Name = AMDGPUAsmVariants.SDWA;
537 }
538
539 def DPPAsmParserVariant : AsmParserVariant {
540   let Variant = AMDGPUAsmVariants.DPP_ID;
541   let Name = AMDGPUAsmVariants.DPP;
542 }
543
544 def AMDGPU : Target {
545   // Pull in Instruction Info:
546   let InstructionSet = AMDGPUInstrInfo;
547   let AssemblyParsers = [AMDGPUAsmParser];
548   let AssemblyParserVariants = [DefaultAMDGPUAsmParserVariant,
549                                 VOP3AsmParserVariant,
550                                 SDWAAsmParserVariant,
551                                 DPPAsmParserVariant];
552   let AssemblyWriters = [AMDGPUAsmWriter];
553 }
554
555 // Dummy Instruction itineraries for pseudo instructions
556 def ALU_NULL : FuncUnit;
557 def NullALU : InstrItinClass;
558
559 //===----------------------------------------------------------------------===//
560 // Predicate helper class
561 //===----------------------------------------------------------------------===//
562
563 def TruePredicate : Predicate<"true">;
564
565 def isSICI : Predicate<
566   "Subtarget->getGeneration() == AMDGPUSubtarget::SOUTHERN_ISLANDS ||"
567   "Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS"
568 >, AssemblerPredicate<"FeatureGCN1Encoding">;
569
570 def isVI : Predicate <
571   "Subtarget->getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS">,
572   AssemblerPredicate<"FeatureGCN3Encoding">;
573
574 def isGFX9 : Predicate <
575   "Subtarget->getGeneration() >= AMDGPUSubtarget::GFX9">,
576   AssemblerPredicate<"FeatureGFX9Insts">;
577
578 // TODO: Either the name to be changed or we simply use IsCI!
579 def isCIVI : Predicate <
580   "Subtarget->getGeneration() >= AMDGPUSubtarget::SEA_ISLANDS">,
581   AssemblerPredicate<"FeatureCIInsts">;
582
583 def HasFlatAddressSpace : Predicate<"Subtarget->hasFlatAddressSpace()">;
584
585 def Has16BitInsts : Predicate<"Subtarget->has16BitInsts()">,
586   AssemblerPredicate<"Feature16BitInsts">;
587 def HasVOP3PInsts : Predicate<"Subtarget->hasVOP3PInsts()">,
588   AssemblerPredicate<"FeatureVOP3P">;
589
590 def HasSDWA : Predicate<"Subtarget->hasSDWA()">,
591   AssemblerPredicate<"FeatureSDWA">;
592
593 def HasDPP : Predicate<"Subtarget->hasDPP()">,
594   AssemblerPredicate<"FeatureDPP">;
595
596 class PredicateControl {
597   Predicate SubtargetPredicate;
598   Predicate SIAssemblerPredicate = isSICI;
599   Predicate VIAssemblerPredicate = isVI;
600   list<Predicate> AssemblerPredicates = [];
601   Predicate AssemblerPredicate = TruePredicate;
602   list<Predicate> OtherPredicates = [];
603   list<Predicate> Predicates = !listconcat([SubtargetPredicate, AssemblerPredicate],
604                                             AssemblerPredicates,
605                                             OtherPredicates);
606 }
607
608 // Include AMDGPU TD files
609 include "R600Schedule.td"
610 include "SISchedule.td"
611 include "Processors.td"
612 include "AMDGPUInstrInfo.td"
613 include "AMDGPUIntrinsics.td"
614 include "AMDGPURegisterInfo.td"
615 include "AMDGPURegisterBanks.td"
616 include "AMDGPUInstructions.td"
617 include "AMDGPUCallingConv.td"