LLVM 23.0.0git
SIDefines.h
Go to the documentation of this file.
1//===-- SIDefines.h - SI Helper Macros ----------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7/// \file
8//===----------------------------------------------------------------------===//
9
10#ifndef LLVM_LIB_TARGET_AMDGPU_SIDEFINES_H
11#define LLVM_LIB_TARGET_AMDGPU_SIDEFINES_H
12
13#include "llvm/MC/MCInst.h"
14#include "llvm/MC/MCInstrDesc.h"
15#include "llvm/MC/MCInstrInfo.h"
17
18namespace llvm {
19
20// This needs to be kept in sync with the field bits in SIRegisterClass.
34
36// This must be kept in sync with the SIEncodingFamily class in SIInstrInfo.td
37// and the columns of the getMCOpcodeGen table.
38enum {
39 SI = 0,
40 VI = 1,
41 SDWA = 2,
42 SDWA9 = 3,
43 GFX80 = 4,
44 GFX9 = 5,
45 GFX10 = 6,
46 SDWA10 = 7,
47 GFX90A = 8,
48 GFX940 = 9,
49 GFX11 = 10,
50 GFX1170 = 11,
51 GFX12 = 12,
52 GFX1250 = 13,
53 GFX13 = 14,
54};
55}
56
57namespace SIInstrFlags {
58// This needs to be kept in sync with the field bits in InstSI.
59enum : uint64_t {
60 // Low bits - basic encoding information.
61 SALU = 1 << 0,
62 VALU = 1 << 1,
63
64 // SALU instruction formats.
65 SOP1 = 1 << 2,
66 SOP2 = 1 << 3,
67 SOPC = 1 << 4,
68 SOPK = 1 << 5,
69 SOPP = 1 << 6,
70
71 // VALU instruction formats.
72 VOP1 = 1 << 7,
73 VOP2 = 1 << 8,
74 VOPC = 1 << 9,
75
76 // TODO: Should this be spilt into VOP3 a and b?
77 VOP3 = 1 << 10,
78 VOP3P = 1 << 12,
79
80 VINTRP = 1 << 13,
81 SDWA = 1 << 14,
82 DPP = 1 << 15,
83 TRANS = 1 << 16,
84
85 // Memory instruction formats.
86 MUBUF = 1 << 17,
87 MTBUF = 1 << 18,
88 SMRD = 1 << 19,
89 MIMG = 1 << 20,
90 VIMAGE = 1 << 21,
91 VSAMPLE = 1 << 22,
92 EXP = 1 << 23,
93 FLAT = 1 << 24,
94 DS = 1 << 25,
95
96 // Combined SGPR/VGPR Spill bit
97 // Logic to separate them out is done in isSGPRSpill and isVGPRSpill
98 Spill = 1 << 26,
99
100 // LDSDIR instruction format.
101 LDSDIR = 1 << 28,
102
103 // VINTERP instruction format.
104 VINTERP = 1 << 29,
105
106 VOPD3 = 1 << 30,
107
108 // High bits - other information.
109 VM_CNT = UINT64_C(1) << 32,
110 EXP_CNT = UINT64_C(1) << 33,
111 LGKM_CNT = UINT64_C(1) << 34,
112
113 WQM = UINT64_C(1) << 35,
114 DisableWQM = UINT64_C(1) << 36,
115 Gather4 = UINT64_C(1) << 37,
116
117 TENSOR_CNT = UINT64_C(1) << 38,
118
119 SCALAR_STORE = UINT64_C(1) << 39,
120 FIXED_SIZE = UINT64_C(1) << 40,
121
122 ASYNC_CNT = UINT64_C(1) << 41,
123
124 VOP3_OPSEL = UINT64_C(1) << 42,
125 maybeAtomic = UINT64_C(1) << 43,
126 renamedInGFX9 = UINT64_C(1) << 44,
127
128 // Is a clamp on FP type.
129 FPClamp = UINT64_C(1) << 45,
130
131 // Is an integer clamp
132 IntClamp = UINT64_C(1) << 46,
133
134 // Clamps lo component of register.
135 ClampLo = UINT64_C(1) << 47,
136
137 // Clamps hi component of register.
138 // ClampLo and ClampHi set for packed clamp.
139 ClampHi = UINT64_C(1) << 48,
140
141 // Is a packed VOP3P instruction.
142 IsPacked = UINT64_C(1) << 49,
143
144 // Is a D16 buffer instruction.
145 D16Buf = UINT64_C(1) << 50,
146
147 // FLAT instruction accesses FLAT_GLBL segment.
148 FlatGlobal = UINT64_C(1) << 51,
149
150 // Uses floating point double precision rounding mode
151 FPDPRounding = UINT64_C(1) << 52,
152
153 // Instruction is FP atomic.
154 FPAtomic = UINT64_C(1) << 53,
155
156 // Is a MFMA instruction.
157 IsMAI = UINT64_C(1) << 54,
158
159 // Is a DOT instruction.
160 IsDOT = UINT64_C(1) << 55,
161
162 // FLAT instruction accesses FLAT_SCRATCH segment.
163 FlatScratch = UINT64_C(1) << 56,
164
165 // Atomic without return.
166 IsAtomicNoRet = UINT64_C(1) << 57,
167
168 // Atomic with return.
169 IsAtomicRet = UINT64_C(1) << 58,
170
171 // Is a WMMA instruction.
172 IsWMMA = UINT64_C(1) << 59,
173
174 // Whether tied sources will be read.
175 TiedSourceNotRead = UINT64_C(1) << 60,
176
177 // Is never uniform.
178 IsNeverUniform = UINT64_C(1) << 61,
179
180 // ds_gws_* instructions.
181 GWS = UINT64_C(1) << 62,
182
183 // Is a SWMMAC instruction.
184 IsSWMMAC = UINT64_C(1) << 63,
185};
186
187// Predicate functions over TSFlags — the single place where raw TSFlags bit
188// tests are written. All callers (SIInstrInfo methods, MC-layer code) go
189// through these so that bit-layout changes require updating only this file.
190//
191// getTSFlags is overloaded for MCInstrDesc, (MCInstrInfo, Opcode), and
192// (MCInstrInfo, MCInst) here; SIInstrInfo.h adds a MachineInstr overload in
193// namespace llvm so ADL finds it when predicates are instantiated with
194// MachineInstr.
195
196constexpr uint64_t getTSFlags(const MCInstrDesc &Desc) { return Desc.TSFlags; }
197inline uint64_t getTSFlags(const MCInstrInfo &MII, unsigned Opcode) {
198 return MII.get(Opcode).TSFlags;
199}
200inline uint64_t getTSFlags(const MCInstrInfo &MII, const MCInst &Inst) {
201 return MII.get(Inst.getOpcode()).TSFlags;
202}
203
204template <typename... T> constexpr bool isSALU(const T &...O) {
205 return getTSFlags(O...) & SALU;
206}
207template <typename... T> constexpr bool isVALU(const T &...O) {
208 return getTSFlags(O...) & VALU;
209}
210template <typename... T> constexpr bool isSOP1(const T &...O) {
211 return getTSFlags(O...) & SOP1;
212}
213template <typename... T> constexpr bool isSOP2(const T &...O) {
214 return getTSFlags(O...) & SOP2;
215}
216template <typename... T> constexpr bool isSOPC(const T &...O) {
217 return getTSFlags(O...) & SOPC;
218}
219template <typename... T> constexpr bool isSOPK(const T &...O) {
220 return getTSFlags(O...) & SOPK;
221}
222template <typename... T> constexpr bool isSOPP(const T &...O) {
223 return getTSFlags(O...) & SOPP;
224}
225template <typename... T> constexpr bool isVOP1(const T &...O) {
226 return getTSFlags(O...) & VOP1;
227}
228template <typename... T> constexpr bool isVOP2(const T &...O) {
229 return getTSFlags(O...) & VOP2;
230}
231template <typename... T> constexpr bool isVOPC(const T &...O) {
232 return getTSFlags(O...) & VOPC;
233}
234template <typename... T> constexpr bool isVOP3(const T &...O) {
235 return getTSFlags(O...) & VOP3;
236}
237template <typename... T> constexpr bool isVOP3P(const T &...O) {
238 return getTSFlags(O...) & VOP3P;
239}
240template <typename... T> constexpr bool isVINTRP(const T &...O) {
241 return getTSFlags(O...) & VINTRP;
242}
243template <typename... T> constexpr bool isSDWA(const T &...O) {
244 return getTSFlags(O...) & SDWA;
245}
246template <typename... T> constexpr bool isDPP(const T &...O) {
247 return getTSFlags(O...) & DPP;
248}
249template <typename... T> constexpr bool isTRANS(const T &...O) {
250 return getTSFlags(O...) & TRANS;
251}
252template <typename... T> constexpr bool isMUBUF(const T &...O) {
253 return getTSFlags(O...) & MUBUF;
254}
255template <typename... T> constexpr bool isMTBUF(const T &...O) {
256 return getTSFlags(O...) & MTBUF;
257}
258template <typename... T> constexpr bool isSMRD(const T &...O) {
259 return getTSFlags(O...) & SMRD;
260}
261template <typename... T> constexpr bool isMIMG(const T &...O) {
262 return getTSFlags(O...) & MIMG;
263}
264template <typename... T> constexpr bool isVIMAGE(const T &...O) {
265 return getTSFlags(O...) & VIMAGE;
266}
267template <typename... T> constexpr bool isVSAMPLE(const T &...O) {
268 return getTSFlags(O...) & VSAMPLE;
269}
270template <typename... T> constexpr bool isEXP(const T &...O) {
271 return getTSFlags(O...) & EXP;
272}
273template <typename... T> constexpr bool isFLAT(const T &...O) {
274 return getTSFlags(O...) & FLAT;
275}
276template <typename... T> constexpr bool isDS(const T &...O) {
277 return getTSFlags(O...) & DS;
278}
279template <typename... T> constexpr bool isSpill(const T &...O) {
280 return getTSFlags(O...) & Spill;
281}
282template <typename... T> constexpr bool isLDSDIR(const T &...O) {
283 return getTSFlags(O...) & LDSDIR;
284}
285template <typename... T> constexpr bool isVINTERP(const T &...O) {
286 return getTSFlags(O...) & VINTERP;
287}
288template <typename... T> constexpr bool isWQM(const T &...O) {
289 return getTSFlags(O...) & WQM;
290}
291template <typename... T> constexpr bool isDisableWQM(const T &...O) {
292 return getTSFlags(O...) & DisableWQM;
293}
294template <typename... T> constexpr bool isGather4(const T &...O) {
295 return getTSFlags(O...) & Gather4;
296}
297template <typename... T> constexpr bool usesTENSOR_CNT(const T &...O) {
298 return getTSFlags(O...) & TENSOR_CNT;
299}
300template <typename... T> constexpr bool isScalarStore(const T &...O) {
301 return getTSFlags(O...) & SCALAR_STORE;
302}
303template <typename... T> constexpr bool isFixedSize(const T &...O) {
304 return getTSFlags(O...) & FIXED_SIZE;
305}
306template <typename... T> constexpr bool usesASYNC_CNT(const T &...O) {
307 return getTSFlags(O...) & ASYNC_CNT;
308}
309template <typename... T> constexpr bool hasVOP3OpSel(const T &...O) {
310 return getTSFlags(O...) & VOP3_OPSEL;
311}
312template <typename... T> constexpr bool isMaybeAtomic(const T &...O) {
313 return getTSFlags(O...) & maybeAtomic;
314}
315template <typename... T> constexpr bool hasFPClamp(const T &...O) {
316 return getTSFlags(O...) & FPClamp;
317}
318template <typename... T> constexpr bool hasIntClamp(const T &...O) {
319 return getTSFlags(O...) & IntClamp;
320}
321template <typename... T> constexpr bool hasClampLo(const T &...O) {
322 return getTSFlags(O...) & ClampLo;
323}
324template <typename... T> constexpr bool hasClampHi(const T &...O) {
325 return getTSFlags(O...) & ClampHi;
326}
327template <typename... T> constexpr bool isPacked(const T &...O) {
328 return getTSFlags(O...) & IsPacked;
329}
330template <typename... T> constexpr bool isD16Buf(const T &...O) {
331 return getTSFlags(O...) & D16Buf;
332}
333template <typename... T> constexpr bool isFlatGlobal(const T &...O) {
334 return getTSFlags(O...) & FlatGlobal;
335}
336template <typename... T> constexpr bool usesFPDPRounding(const T &...O) {
337 return getTSFlags(O...) & FPDPRounding;
338}
339template <typename... T> constexpr bool isFPAtomic(const T &...O) {
340 return getTSFlags(O...) & FPAtomic;
341}
342template <typename... T> constexpr bool isMAI(const T &...O) {
343 return getTSFlags(O...) & IsMAI;
344}
345template <typename... T> constexpr bool isDOT(const T &...O) {
346 return getTSFlags(O...) & IsDOT;
347}
348template <typename... T> constexpr bool isFlatScratch(const T &...O) {
349 return getTSFlags(O...) & FlatScratch;
350}
351template <typename... T> constexpr bool isAtomicNoRet(const T &...O) {
352 return getTSFlags(O...) & IsAtomicNoRet;
353}
354template <typename... T> constexpr bool isAtomicRet(const T &...O) {
355 return getTSFlags(O...) & IsAtomicRet;
356}
357template <typename... T> constexpr bool isWMMA(const T &...O) {
358 return getTSFlags(O...) & IsWMMA;
359}
360template <typename... T> constexpr bool isTiedSourceNotRead(const T &...O) {
361 return getTSFlags(O...) & TiedSourceNotRead;
362}
363template <typename... T> constexpr bool isNeverUniform(const T &...O) {
364 return getTSFlags(O...) & IsNeverUniform;
365}
366template <typename... T> constexpr bool isGWS(const T &...O) {
367 return getTSFlags(O...) & GWS;
368}
369template <typename... T> constexpr bool isSWMMAC(const T &...O) {
370 return getTSFlags(O...) & IsSWMMAC;
371}
372template <typename... T> constexpr bool usesVM_CNT(const T &...O) {
373 return getTSFlags(O...) & VM_CNT;
374}
375template <typename... T> constexpr bool usesLGKM_CNT(const T &...O) {
376 return getTSFlags(O...) & LGKM_CNT;
377}
378
379// Compound predicates.
380template <typename... T> constexpr bool isAtomic(const T &...O) {
381 return isAtomicNoRet(O...) || isAtomicRet(O...);
382}
383template <typename... T> constexpr bool isSegmentSpecificFLAT(const T &...O) {
384 return isFlatGlobal(O...) || isFlatScratch(O...);
385}
386// Any image-family instruction: pre-gfx11 MIMG, gfx11+ VIMAGE or VSAMPLE.
387template <typename... T> constexpr bool isImage(const T &...O) {
388 return isMIMG(O...) || isVIMAGE(O...) || isVSAMPLE(O...);
389}
390// Vector memory: buffer + image + flat.
391template <typename... T> constexpr bool isVMEM(const T &...O) {
392 return isMUBUF(O...) || isMTBUF(O...) || isImage(O...) || isFLAT(O...);
393}
394
395// v_cmp_class_* etc. use a 10-bit mask for what operation is checked.
396// The result is true if any of these tests are true.
397enum ClassFlags : unsigned {
398 S_NAN = 1 << 0, // Signaling NaN
399 Q_NAN = 1 << 1, // Quiet NaN
400 N_INFINITY = 1 << 2, // Negative infinity
401 N_NORMAL = 1 << 3, // Negative normal
402 N_SUBNORMAL = 1 << 4, // Negative subnormal
403 N_ZERO = 1 << 5, // Negative zero
404 P_ZERO = 1 << 6, // Positive zero
405 P_SUBNORMAL = 1 << 7, // Positive subnormal
406 P_NORMAL = 1 << 8, // Positive normal
407 P_INFINITY = 1 << 9 // Positive infinity
408};
409}
410
411namespace AMDGPU {
412
413enum OperandType : unsigned {
414 /// Operands with register, 32-bit, or 64-bit immediate
431
432 /// Operands with register or inline constant
443
444 // Operand for split barrier inline constant
446
447 /// Operand with 32-bit immediate that uses the constant bus.
451
452 /// Operands with an AccVGPR register or inline constant
456
457 // Operand for AV_MOV_B64_IMM_PSEUDO, which is a pair of 32-bit inline
458 // constants. Does not accept registers.
460
461 // Operand for source modifiers for VOP instructions
463
464 // Operand for SDWA instructions
466
469
472
475
478
481
482};
483}
484
485// Input operand modifiers bit-masks
486// NEG and SEXT share same bit-mask because they can't be set simultaneously.
487namespace SISrcMods {
488enum : unsigned {
489 NONE = 0,
490 NEG = 1 << 0, // Floating-point negate modifier
491 ABS = 1 << 1, // Floating-point absolute modifier
492 SEXT = 1 << 4, // Integer sign-extend modifier
493 NEG_HI = ABS, // Floating-point negate high packed component modifier.
494 OP_SEL_0 = 1 << 2,
495 OP_SEL_1 = 1 << 3,
496 DST_OP_SEL = 1 << 3 // VOP3 dst op_sel (share mask with OP_SEL_1)
497};
498}
499
500namespace SIOutMods {
501 enum : unsigned {
502 NONE = 0,
503 MUL2 = 1,
504 MUL4 = 2,
506 };
507}
508
509namespace AMDGPU {
510namespace VGPRIndexMode {
511
512enum Id : unsigned { // id of symbolic names
517
520};
521
531
532} // namespace VGPRIndexMode
533} // namespace AMDGPU
534
536 enum : unsigned {
538 VOP3 = 1,
539 SDWA = 2,
540 SDWA9 = 3,
541 DPP = 4,
543 };
544} // namespace AMDGPUAsmVariants
545
546namespace AMDGPU {
547namespace EncValues { // Encoding values of enum9/8/7 operands
548
549enum : unsigned {
564 VGPR_MIN = 256,
565 VGPR_MAX = 511,
566 IS_VGPR = 256, // Indicates VGPR or AGPR
567};
568
569} // namespace EncValues
570
571// Register codes as defined in the TableGen's HWEncoding field.
572namespace HWEncoding {
573enum : unsigned {
576 IS_VGPR = 1 << 10,
577 IS_AGPR = 1 << 11,
578 IS_HI16 = 1 << 12,
579};
580} // namespace HWEncoding
581
582namespace CPol {
583
584enum CPol {
585 GLC = 1,
586 SLC = 2,
587 DLC = 4,
588 SCC = 16,
594
595 // Below are GFX12+ cache policy bits
596
597 // Temporal hint
598 TH = 0x7, // All TH bits
599 TH_RT = 0, // regular
600 TH_NT = 1, // non-temporal
601 TH_HT = 2, // high-temporal
602 TH_LU = 3, // last use
603 TH_WB = 3, // regular (CU, SE), high-temporal with write-back (MALL)
604 TH_NT_RT = 4, // non-temporal (CU, SE), regular (MALL)
605 TH_RT_NT = 5, // regular (CU, SE), non-temporal (MALL)
606 TH_NT_HT = 6, // non-temporal (CU, SE), high-temporal (MALL)
607 TH_NT_WB = 7, // non-temporal (CU, SE), high-temporal with write-back (MALL)
608 TH_BYPASS = 3, // only to be used with scope = 3
609
610 TH_RESERVED = 7, // unused value for load insts
611
612 // Bits of TH for atomics
613 TH_ATOMIC_RETURN = GLC, // Returning vs non-returning
614 TH_ATOMIC_NT = SLC, // Non-temporal vs regular
615 TH_ATOMIC_CASCADE = 4, // Cascading vs regular
616
617 // Scope
620 SCOPE = SCOPE_MASK << SCOPE_SHIFT, // All Scope bits
625
626 NV = 1 << 5, // Non-volatile bit
627
628 SWZ = 1 << 6, // Swizzle bit
629
630 SCAL = 1 << 11, // Scale offset bit
631
632 ALL = TH | SCOPE | NV,
633
634 // Helper bits
635 TH_TYPE_LOAD = 1 << 7, // TH_LOAD policy
636 TH_TYPE_STORE = 1 << 8, // TH_STORE policy
637 TH_TYPE_ATOMIC = 1 << 9, // TH_ATOMIC policy
638 TH_REAL_BYPASS = 1 << 10, // is TH=3 bypass policy or not
639
640 // Volatile (used to preserve/signal operation volatility for buffer
641 // operations not a real instruction bit)
642 VOLATILE = 1 << 31,
643 // The set of "cache policy" bits used for compiler features that
644 // do not correspond to handware features.
646};
647
648} // namespace CPol
649
650namespace SendMsg { // Encoding of SIMM16 used in s_sendmsg* insns.
651
652enum Id { // Message ID, width(4) [3:0].
654
655 ID_GS_PreGFX11 = 2, // replaced in GFX11
656 ID_GS_DONE_PreGFX11 = 3, // replaced in GFX11
657
658 ID_HS_TESSFACTOR_GFX11Plus = 2, // reused in GFX11
659 ID_DEALLOC_VGPRS_GFX11Plus = 3, // reused in GFX11
660
661 ID_SAVEWAVE = 4, // added in GFX8, removed in GFX11
662 ID_STALL_WAVE_GEN = 5, // added in GFX9, removed in GFX12
663 ID_HALT_WAVES = 6, // added in GFX9, removed in GFX12
664 ID_ORDERED_PS_DONE = 7, // added in GFX9, removed in GFX11
665 ID_EARLY_PRIM_DEALLOC = 8, // added in GFX9, removed in GFX10
666 ID_GS_ALLOC_REQ = 9, // added in GFX9
667 ID_GET_DOORBELL = 10, // added in GFX9, removed in GFX11
668 ID_GET_DDID = 11, // added in GFX10, removed in GFX11
670
679
680 ID_RTN_GET_CLUSTER_BARRIER_STATE = 136, // added in GFX1250
681 ID_RTN_SAVE_WAVE_HAS_TDM = 152, // added in GFX1250
682
685};
686
687enum Op { // Both GS and SYS operation IDs.
690 // Bits used for operation encoding
692 OP_MASK_ = (((1 << OP_WIDTH_) - 1) << OP_SHIFT_),
693 // GS operations are encoded in bits 5:4
699 // SYS operations are encoded in bits 6:4
705};
706
716
717} // namespace SendMsg
718
719namespace WaitEvent { // Encoding of SIMM16 used in s_wait_event
720enum Id {
721 DONT_WAIT_EXPORT_READY = 1 << 0, // Only used in gfx11
722 EXPORT_READY = 1 << 1, // gfx12+
723};
724
725} // namespace WaitEvent
726
727namespace Hwreg { // Encoding of SIMM16 used in s_setreg/getreg* insns.
728
782
783enum Offset : unsigned { // Offset, (5) [10:6]
785 OFFSET_ME_ID = 8, // in HW_ID2
786};
787
789 FP_ROUND_MASK = 0xf << 0, // Bits 0..3
790 FP_DENORM_MASK = 0xf << 4, // Bits 4..7
793 LOD_CLAMP_MASK = 1 << 10,
794 DEBUG_MASK = 1 << 11,
795
796 // EXCP_EN fields.
804
806 VSKIP_MASK = 1 << 28,
807 CSP_MASK = 0x7u << 29, // Bits 29..31
808
809 // GFX1250
810 DST_VGPR_MSB = 0x3 << 12,
811 SRC0_VGPR_MSB = 0x3 << 14,
812 SRC1_VGPR_MSB = 0x3 << 16,
813 SRC2_VGPR_MSB = 0x3 << 18,
814 VGPR_MSB_MASK = 0xff << 12, // Bits 12..19
815
816 REPLAY_MODE = 1 << 25,
818};
819
820} // namespace Hwreg
821
891
892namespace UfmtGFX10 {
893enum UnifiedFormat : int64_t {
895
902
910
917
921
929
937
945
952
959
966
970
978
985
988};
989
990} // namespace UfmtGFX10
991
992namespace UfmtGFX11 {
993enum UnifiedFormat : int64_t {
995
1002
1010
1017
1021
1029
1031
1033
1038
1045
1052
1056
1064
1071
1074};
1075
1076} // namespace UfmtGFX11
1077
1078namespace Swizzle { // Encoding of swizzle macro used in ds_swizzle_b32.
1079
1089
1090// clang-format off
1091enum EncBits : unsigned {
1092
1093 // swizzle mode encodings
1094
1097
1100
1102
1105
1107 FFT_MODE_LO = 0xE000,
1108
1109 // QUAD_PERM encodings
1110
1115
1116 // BITMASK_PERM encodings
1117
1121
1125
1126 // FFT encodings
1127
1130
1131 // ROTATE encodings
1133 ROTATE_DIR_SHIFT = 10, // bit position of rotate direction
1135 ROTATE_SIZE_SHIFT = 5, // bit position of rotate size
1137};
1138// clang-format on
1139
1140} // namespace Swizzle
1141
1142namespace SDWA {
1143
1144enum SdwaSel : unsigned {
1152};
1153
1154enum DstUnused : unsigned {
1158};
1159
1174
1175} // namespace SDWA
1176
1177namespace DPP {
1178
1179// clang-format off
1224// clang-format on
1225
1232
1233} // namespace DPP
1234
1235namespace Exp {
1236
1237enum Target : unsigned {
1241 ET_NULL = 9, // Pre-GFX11
1244 ET_POS4 = 16, // GFX10+
1245 ET_POS_LAST = ET_POS4, // Highest pos used on any subtarget
1246 ET_PRIM = 20, // GFX10+
1247 ET_DUAL_SRC_BLEND0 = 21, // GFX11+
1248 ET_DUAL_SRC_BLEND1 = 22, // GFX11+
1249 ET_PARAM0 = 32, // Pre-GFX11
1250 ET_PARAM31 = 63, // Pre-GFX11
1251
1259
1261};
1262
1263} // namespace Exp
1264
1285
1286namespace VOP3PEncoding {
1287
1289 OP_SEL_HI_0 = UINT64_C(1) << 59,
1290 OP_SEL_HI_1 = UINT64_C(1) << 60,
1291 OP_SEL_HI_2 = UINT64_C(1) << 14,
1292};
1293
1294} // namespace VOP3PEncoding
1295
1296namespace ImplicitArg {
1297// Implicit kernel argument offset for code object version 5.
1310
1311} // namespace ImplicitArg
1312
1314// Enum value used in cbsz/blgp for F8F6F4 MFMA operations to select the matrix
1315// format.
1323} // namespace MFMAScaleFormats
1324
1325namespace VirtRegFlag {
1326// Virtual register flags used for various target specific handlings during
1327// codegen.
1329 // Register operand in a whole-wave mode operation.
1330 WWM_REG = 1 << 0,
1331};
1332
1333} // namespace VirtRegFlag
1334
1335} // namespace AMDGPU
1336
1337namespace AMDGPU {
1338namespace Barrier {
1339
1348
1349enum {
1351};
1352
1353} // namespace Barrier
1354} // namespace AMDGPU
1355
1356// clang-format off
1357
1358#define R_00B028_SPI_SHADER_PGM_RSRC1_PS 0x00B028
1359#define S_00B028_VGPRS(x) (((x) & 0x3F) << 0)
1360#define S_00B028_SGPRS(x) (((x) & 0x0F) << 6)
1361#define S_00B028_MEM_ORDERED(x) (((x) & 0x1) << 25)
1362#define G_00B028_MEM_ORDERED(x) (((x) >> 25) & 0x1)
1363#define C_00B028_MEM_ORDERED 0xFDFFFFFF
1364
1365#define R_00B02C_SPI_SHADER_PGM_RSRC2_PS 0x00B02C
1366#define S_00B02C_EXTRA_LDS_SIZE(x) (((x) & 0xFF) << 8)
1367#define R_00B128_SPI_SHADER_PGM_RSRC1_VS 0x00B128
1368#define S_00B128_MEM_ORDERED(x) (((x) & 0x1) << 27)
1369#define G_00B128_MEM_ORDERED(x) (((x) >> 27) & 0x1)
1370#define C_00B128_MEM_ORDERED 0xF7FFFFFF
1371
1372#define R_00B228_SPI_SHADER_PGM_RSRC1_GS 0x00B228
1373#define S_00B228_WGP_MODE(x) (((x) & 0x1) << 27)
1374#define G_00B228_WGP_MODE(x) (((x) >> 27) & 0x1)
1375#define C_00B228_WGP_MODE 0xF7FFFFFF
1376#define S_00B228_MEM_ORDERED(x) (((x) & 0x1) << 25)
1377#define G_00B228_MEM_ORDERED(x) (((x) >> 25) & 0x1)
1378#define C_00B228_MEM_ORDERED 0xFDFFFFFF
1379
1380#define R_00B328_SPI_SHADER_PGM_RSRC1_ES 0x00B328
1381#define R_00B428_SPI_SHADER_PGM_RSRC1_HS 0x00B428
1382#define S_00B428_WGP_MODE(x) (((x) & 0x1) << 26)
1383#define G_00B428_WGP_MODE(x) (((x) >> 26) & 0x1)
1384#define C_00B428_WGP_MODE 0xFBFFFFFF
1385#define S_00B428_MEM_ORDERED(x) (((x) & 0x1) << 24)
1386#define G_00B428_MEM_ORDERED(x) (((x) >> 24) & 0x1)
1387#define C_00B428_MEM_ORDERED 0xFEFFFFFF
1388
1389#define R_00B528_SPI_SHADER_PGM_RSRC1_LS 0x00B528
1390
1391#define R_00B84C_COMPUTE_PGM_RSRC2 0x00B84C
1392#define S_00B84C_SCRATCH_EN(x) (((x) & 0x1) << 0)
1393#define G_00B84C_SCRATCH_EN(x) (((x) >> 0) & 0x1)
1394#define C_00B84C_SCRATCH_EN 0xFFFFFFFE
1395#define S_00B84C_USER_SGPR(x) (((x) & 0x1F) << 1)
1396#define G_00B84C_USER_SGPR(x) (((x) >> 1) & 0x1F)
1397#define C_00B84C_USER_SGPR 0xFFFFFFC1
1398#define S_00B84C_TRAP_HANDLER(x) (((x) & 0x1) << 6)
1399#define G_00B84C_TRAP_HANDLER(x) (((x) >> 6) & 0x1)
1400#define C_00B84C_TRAP_HANDLER 0xFFFFFFBF
1401#define S_00B84C_TGID_X_EN(x) (((x) & 0x1) << 7)
1402#define G_00B84C_TGID_X_EN(x) (((x) >> 7) & 0x1)
1403#define C_00B84C_TGID_X_EN 0xFFFFFF7F
1404#define S_00B84C_TGID_Y_EN(x) (((x) & 0x1) << 8)
1405#define G_00B84C_TGID_Y_EN(x) (((x) >> 8) & 0x1)
1406#define C_00B84C_TGID_Y_EN 0xFFFFFEFF
1407#define S_00B84C_TGID_Z_EN(x) (((x) & 0x1) << 9)
1408#define G_00B84C_TGID_Z_EN(x) (((x) >> 9) & 0x1)
1409#define C_00B84C_TGID_Z_EN 0xFFFFFDFF
1410#define S_00B84C_TG_SIZE_EN(x) (((x) & 0x1) << 10)
1411#define G_00B84C_TG_SIZE_EN(x) (((x) >> 10) & 0x1)
1412#define C_00B84C_TG_SIZE_EN 0xFFFFFBFF
1413#define S_00B84C_TIDIG_COMP_CNT(x) (((x) & 0x03) << 11)
1414#define G_00B84C_TIDIG_COMP_CNT(x) (((x) >> 11) & 0x03)
1415#define C_00B84C_TIDIG_COMP_CNT 0xFFFFE7FF
1416/* CIK */
1417#define S_00B84C_EXCP_EN_MSB(x) (((x) & 0x03) << 13)
1418#define G_00B84C_EXCP_EN_MSB(x) (((x) >> 13) & 0x03)
1419#define C_00B84C_EXCP_EN_MSB 0xFFFF9FFF
1420/* */
1421#define S_00B84C_LDS_SIZE(x) (((x) & 0x1FF) << 15)
1422#define G_00B84C_LDS_SIZE(x) (((x) >> 15) & 0x1FF)
1423#define C_00B84C_LDS_SIZE 0xFF007FFF
1424#define S_00B84C_EXCP_EN(x) (((x) & 0x7F) << 24)
1425#define G_00B84C_EXCP_EN(x) (((x) >> 24) & 0x7F)
1426#define C_00B84C_EXCP_EN 0x80FFFFFF
1427
1428#define S_00B84C_USER_SGPR_GFX1250(x) (((x) & 0x3F) << 1)
1429#define G_00B84C_USER_SGPR_GFX1250(x) (((x) >> 1) & 0x3F)
1430#define C_00B84C_USER_SGPR_GFX1250 0xFFFFFF81
1431
1432#define R_0286CC_SPI_PS_INPUT_ENA 0x0286CC
1433#define R_0286D0_SPI_PS_INPUT_ADDR 0x0286D0
1434
1435#define R_00B848_COMPUTE_PGM_RSRC1 0x00B848
1436#define S_00B848_VGPRS(x) (((x) & 0x3F) << 0)
1437#define G_00B848_VGPRS(x) (((x) >> 0) & 0x3F)
1438#define C_00B848_VGPRS 0xFFFFFFC0
1439#define S_00B848_SGPRS(x) (((x) & 0x0F) << 6)
1440#define G_00B848_SGPRS(x) (((x) >> 6) & 0x0F)
1441#define C_00B848_SGPRS 0xFFFFFC3F
1442#define S_00B848_PRIORITY(x) (((x) & 0x03) << 10)
1443#define G_00B848_PRIORITY(x) (((x) >> 10) & 0x03)
1444#define C_00B848_PRIORITY 0xFFFFF3FF
1445#define S_00B848_FLOAT_MODE(x) (((x) & 0xFF) << 12)
1446#define G_00B848_FLOAT_MODE(x) (((x) >> 12) & 0xFF)
1447#define C_00B848_FLOAT_MODE 0xFFF00FFF
1448#define S_00B848_PRIV(x) (((x) & 0x1) << 20)
1449#define G_00B848_PRIV(x) (((x) >> 20) & 0x1)
1450#define C_00B848_PRIV 0xFFEFFFFF
1451#define S_00B848_DX10_CLAMP(x) (((x) & 0x1) << 21)
1452#define G_00B848_DX10_CLAMP(x) (((x) >> 21) & 0x1)
1453#define C_00B848_DX10_CLAMP 0xFFDFFFFF
1454#define S_00B848_RR_WG_MODE(x) (((x) & 0x1) << 21)
1455#define G_00B848_RR_WG_MODE(x) (((x) >> 21) & 0x1)
1456#define C_00B848_RR_WG_MODE 0xFFDFFFFF
1457#define S_00B848_DEBUG_MODE(x) (((x) & 0x1) << 22)
1458#define G_00B848_DEBUG_MODE(x) (((x) >> 22) & 0x1)
1459#define C_00B848_DEBUG_MODE 0xFFBFFFFF
1460#define S_00B848_IEEE_MODE(x) (((x) & 0x1) << 23)
1461#define G_00B848_IEEE_MODE(x) (((x) >> 23) & 0x1)
1462#define C_00B848_IEEE_MODE 0xFF7FFFFF
1463#define S_00B848_WGP_MODE(x) (((x) & 0x1) << 29)
1464#define G_00B848_WGP_MODE(x) (((x) >> 29) & 0x1)
1465#define C_00B848_WGP_MODE 0xDFFFFFFF
1466#define S_00B848_MEM_ORDERED(x) (((x) & 0x1) << 30)
1467#define G_00B848_MEM_ORDERED(x) (((x) >> 30) & 0x1)
1468#define C_00B848_MEM_ORDERED 0xBFFFFFFF
1469#define S_00B848_FWD_PROGRESS(x) (((x) & 0x1) << 31)
1470#define G_00B848_FWD_PROGRESS(x) (((x) >> 31) & 0x1)
1471#define C_00B848_FWD_PROGRESS 0x7FFFFFFF
1472
1473// Helpers for setting FLOAT_MODE
1474#define FP_ROUND_ROUND_TO_NEAREST 0
1475#define FP_ROUND_ROUND_TO_INF 1
1476#define FP_ROUND_ROUND_TO_NEGINF 2
1477#define FP_ROUND_ROUND_TO_ZERO 3
1478
1479// Bits 3:0 control rounding mode. 1:0 control single precision, 3:2 double
1480// precision.
1481#define FP_ROUND_MODE_SP(x) ((x) & 0x3)
1482#define FP_ROUND_MODE_DP(x) (((x) & 0x3) << 2)
1483
1484#define FP_DENORM_FLUSH_IN_FLUSH_OUT 0
1485#define FP_DENORM_FLUSH_OUT 1
1486#define FP_DENORM_FLUSH_IN 2
1487#define FP_DENORM_FLUSH_NONE 3
1488
1489
1490// Bits 7:4 control denormal handling. 5:4 control single precision, 6:7 double
1491// precision.
1492#define FP_DENORM_MODE_SP(x) (((x) & 0x3) << 4)
1493#define FP_DENORM_MODE_DP(x) (((x) & 0x3) << 6)
1494
1495#define R_00B860_COMPUTE_TMPRING_SIZE 0x00B860
1496#define S_00B860_WAVESIZE_PreGFX11(x) (((x) & 0x1FFF) << 12)
1497#define S_00B860_WAVESIZE_GFX11(x) (((x) & 0x7FFF) << 12)
1498#define S_00B860_WAVESIZE_GFX12Plus(x) (((x) & 0x3FFFF) << 12)
1499
1500#define R_0286E8_SPI_TMPRING_SIZE 0x0286E8
1501#define S_0286E8_WAVESIZE_PreGFX11(x) (((x) & 0x1FFF) << 12)
1502#define S_0286E8_WAVESIZE_GFX11(x) (((x) & 0x7FFF) << 12)
1503#define S_0286E8_WAVESIZE_GFX12Plus(x) (((x) & 0x3FFFF) << 12)
1504
1505#define R_028B54_VGT_SHADER_STAGES_EN 0x028B54
1506#define S_028B54_HS_W32_EN(x) (((x) & 0x1) << 21)
1507#define S_028B54_GS_W32_EN(x) (((x) & 0x1) << 22)
1508#define S_028B54_VS_W32_EN(x) (((x) & 0x1) << 23)
1509#define R_0286D8_SPI_PS_IN_CONTROL 0x0286D8
1510#define S_0286D8_PS_W32_EN(x) (((x) & 0x1) << 15)
1511#define R_00B800_COMPUTE_DISPATCH_INITIATOR 0x00B800
1512#define S_00B800_CS_W32_EN(x) (((x) & 0x1) << 15)
1513
1514#define R_SPILLED_SGPRS 0x4
1515#define R_SPILLED_VGPRS 0x8
1516
1517// clang-format on
1518
1519} // End namespace llvm
1520
1521#endif
AMDGPU address space definition.
#define T
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
unsigned getOpcode() const
Definition MCInst.h:202
Describe properties that are true of each instruction in the target description file.
Interface to description of machine instruction set.
Definition MCInstrInfo.h:27
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
Definition MCInstrInfo.h:90
@ OPERAND_REG_IMM_V2FP64
Definition SIDefines.h:430
@ OPERAND_KIMM32
Operand with 32-bit immediate that uses the constant bus.
Definition SIDefines.h:448
@ OPERAND_REG_INLINE_C_LAST
Definition SIDefines.h:471
@ OPERAND_REG_IMM_INT64
Definition SIDefines.h:416
@ OPERAND_REG_IMM_V2FP16
Definition SIDefines.h:423
@ OPERAND_REG_INLINE_C_FP64
Definition SIDefines.h:439
@ OPERAND_REG_INLINE_C_BF16
Definition SIDefines.h:436
@ OPERAND_REG_IMM_FIRST
Definition SIDefines.h:467
@ OPERAND_REG_INLINE_C_V2BF16
Definition SIDefines.h:441
@ OPERAND_REG_IMM_V2INT64
Definition SIDefines.h:426
@ OPERAND_REG_IMM_V2INT16
Definition SIDefines.h:425
@ OPERAND_REG_IMM_BF16
Definition SIDefines.h:420
@ OPERAND_REG_IMM_INT32
Operands with register, 32-bit, or 64-bit immediate.
Definition SIDefines.h:415
@ OPERAND_REG_IMM_V2BF16
Definition SIDefines.h:422
@ OPERAND_REG_INLINE_AC_FIRST
Definition SIDefines.h:473
@ OPERAND_REG_IMM_FP16
Definition SIDefines.h:421
@ OPERAND_REG_IMM_V2FP16_SPLAT
Definition SIDefines.h:424
@ OPERAND_REG_INLINE_C_INT64
Definition SIDefines.h:435
@ OPERAND_REG_INLINE_C_INT16
Operands with register or inline constant.
Definition SIDefines.h:433
@ OPERAND_REG_IMM_NOINLINE_V2FP16
Definition SIDefines.h:427
@ OPERAND_REG_IMM_FP64
Definition SIDefines.h:419
@ OPERAND_REG_INLINE_C_V2FP16
Definition SIDefines.h:442
@ OPERAND_REG_INLINE_AC_INT32
Operands with an AccVGPR register or inline constant.
Definition SIDefines.h:453
@ OPERAND_REG_INLINE_AC_FP32
Definition SIDefines.h:454
@ OPERAND_REG_IMM_V2INT32
Definition SIDefines.h:428
@ OPERAND_SDWA_VOPC_DST
Definition SIDefines.h:465
@ OPERAND_REG_IMM_FP32
Definition SIDefines.h:418
@ OPERAND_REG_INLINE_C_FIRST
Definition SIDefines.h:470
@ OPERAND_REG_INLINE_C_FP32
Definition SIDefines.h:438
@ OPERAND_REG_INLINE_AC_LAST
Definition SIDefines.h:474
@ OPERAND_REG_IMM_LAST
Definition SIDefines.h:468
@ OPERAND_REG_INLINE_C_INT32
Definition SIDefines.h:434
@ OPERAND_REG_INLINE_C_V2INT16
Definition SIDefines.h:440
@ OPERAND_INLINE_C_AV64_PSEUDO
Definition SIDefines.h:459
@ OPERAND_REG_IMM_V2FP32
Definition SIDefines.h:429
@ OPERAND_REG_INLINE_AC_FP64
Definition SIDefines.h:455
@ OPERAND_REG_INLINE_C_FP16
Definition SIDefines.h:437
@ OPERAND_REG_IMM_INT16
Definition SIDefines.h:417
@ OPERAND_INLINE_SPLIT_BARRIER_INT32
Definition SIDefines.h:445
@ OPERAND_FIRST_TARGET
Definition MCInstrDesc.h:79
constexpr bool isAtomicRet(const T &...O)
Definition SIDefines.h:354
constexpr bool isVOPC(const T &...O)
Definition SIDefines.h:231
constexpr bool isVOP3(const T &...O)
Definition SIDefines.h:234
constexpr bool isScalarStore(const T &...O)
Definition SIDefines.h:300
constexpr bool hasVOP3OpSel(const T &...O)
Definition SIDefines.h:309
constexpr bool isVOP1(const T &...O)
Definition SIDefines.h:225
constexpr bool isFPAtomic(const T &...O)
Definition SIDefines.h:339
constexpr bool usesVM_CNT(const T &...O)
Definition SIDefines.h:372
constexpr bool usesTENSOR_CNT(const T &...O)
Definition SIDefines.h:297
constexpr bool isD16Buf(const T &...O)
Definition SIDefines.h:330
constexpr bool isMAI(const T &...O)
Definition SIDefines.h:342
constexpr bool isVOP2(const T &...O)
Definition SIDefines.h:228
constexpr bool isMaybeAtomic(const T &...O)
Definition SIDefines.h:312
constexpr bool isSWMMAC(const T &...O)
Definition SIDefines.h:369
constexpr bool isTRANS(const T &...O)
Definition SIDefines.h:249
constexpr bool isSOP2(const T &...O)
Definition SIDefines.h:213
constexpr bool isFLAT(const T &...O)
Definition SIDefines.h:273
constexpr bool isVOP3P(const T &...O)
Definition SIDefines.h:237
constexpr bool usesFPDPRounding(const T &...O)
Definition SIDefines.h:336
constexpr bool isDisableWQM(const T &...O)
Definition SIDefines.h:291
constexpr bool hasIntClamp(const T &...O)
Definition SIDefines.h:318
constexpr bool isAtomicNoRet(const T &...O)
Definition SIDefines.h:351
constexpr bool isMTBUF(const T &...O)
Definition SIDefines.h:255
constexpr bool isVIMAGE(const T &...O)
Definition SIDefines.h:264
constexpr bool isSMRD(const T &...O)
Definition SIDefines.h:258
constexpr bool isFlatScratch(const T &...O)
Definition SIDefines.h:348
constexpr bool isSpill(const T &...O)
Definition SIDefines.h:279
constexpr uint64_t getTSFlags(const MCInstrDesc &Desc)
Definition SIDefines.h:196
constexpr bool isMIMG(const T &...O)
Definition SIDefines.h:261
constexpr bool isVMEM(const T &...O)
Definition SIDefines.h:391
constexpr bool hasFPClamp(const T &...O)
Definition SIDefines.h:315
constexpr bool isNeverUniform(const T &...O)
Definition SIDefines.h:363
constexpr bool isImage(const T &...O)
Definition SIDefines.h:387
constexpr bool isWMMA(const T &...O)
Definition SIDefines.h:357
constexpr bool isVALU(const T &...O)
Definition SIDefines.h:207
constexpr bool isWQM(const T &...O)
Definition SIDefines.h:288
constexpr bool hasClampLo(const T &...O)
Definition SIDefines.h:321
constexpr bool isGWS(const T &...O)
Definition SIDefines.h:366
constexpr bool isFlatGlobal(const T &...O)
Definition SIDefines.h:333
constexpr bool usesASYNC_CNT(const T &...O)
Definition SIDefines.h:306
constexpr bool isMUBUF(const T &...O)
Definition SIDefines.h:252
constexpr bool isSDWA(const T &...O)
Definition SIDefines.h:243
constexpr bool isTiedSourceNotRead(const T &...O)
Definition SIDefines.h:360
constexpr bool isEXP(const T &...O)
Definition SIDefines.h:270
constexpr bool usesLGKM_CNT(const T &...O)
Definition SIDefines.h:375
constexpr bool isSOPK(const T &...O)
Definition SIDefines.h:219
constexpr bool isSOPC(const T &...O)
Definition SIDefines.h:216
constexpr bool isSOPP(const T &...O)
Definition SIDefines.h:222
constexpr bool isDOT(const T &...O)
Definition SIDefines.h:345
constexpr bool isVINTRP(const T &...O)
Definition SIDefines.h:240
constexpr bool isVINTERP(const T &...O)
Definition SIDefines.h:285
constexpr bool isVSAMPLE(const T &...O)
Definition SIDefines.h:267
constexpr bool isDS(const T &...O)
Definition SIDefines.h:276
constexpr bool isAtomic(const T &...O)
Definition SIDefines.h:380
constexpr bool isLDSDIR(const T &...O)
Definition SIDefines.h:282
constexpr bool isSALU(const T &...O)
Definition SIDefines.h:204
constexpr bool isGather4(const T &...O)
Definition SIDefines.h:294
constexpr bool isPacked(const T &...O)
Definition SIDefines.h:327
constexpr bool hasClampHi(const T &...O)
Definition SIDefines.h:324
constexpr bool isDPP(const T &...O)
Definition SIDefines.h:246
constexpr bool isSOP1(const T &...O)
Definition SIDefines.h:210
constexpr bool isSegmentSpecificFLAT(const T &...O)
Definition SIDefines.h:383
constexpr bool isFixedSize(const T &...O)
Definition SIDefines.h:303
This is an optimization pass for GlobalISel generic memory operations.
Op::Description Desc
SIRCFlags
Definition SIDefines.h:21
@ HasSGPR
Definition SIDefines.h:29
@ HasAGPRBit
Definition SIDefines.h:24
@ HasSGPRbit
Definition SIDefines.h:25
@ RegTupleAlignUnitsWidth
Definition SIDefines.h:22
@ RegTupleAlignUnitsMask
Definition SIDefines.h:31
@ HasVGPRBit
Definition SIDefines.h:23
@ HasVGPR
Definition SIDefines.h:27
@ RegKindMask
Definition SIDefines.h:32
@ HasAGPR
Definition SIDefines.h:28