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 isBuffer(const T &...O) {
259 return getTSFlags(O...) & (MUBUF | MTBUF);
260}
261template <typename... T> constexpr bool isSMRD(const T &...O) {
262 return getTSFlags(O...) & SMRD;
263}
264template <typename... T> constexpr bool isMIMG(const T &...O) {
265 return getTSFlags(O...) & MIMG;
266}
267template <typename... T> constexpr bool isVIMAGE(const T &...O) {
268 return getTSFlags(O...) & VIMAGE;
269}
270template <typename... T> constexpr bool isVSAMPLE(const T &...O) {
271 return getTSFlags(O...) & VSAMPLE;
272}
273template <typename... T> constexpr bool isEXP(const T &...O) {
274 return getTSFlags(O...) & EXP;
275}
276template <typename... T> constexpr bool isFLAT(const T &...O) {
277 return getTSFlags(O...) & FLAT;
278}
279template <typename... T> constexpr bool isDS(const T &...O) {
280 return getTSFlags(O...) & DS;
281}
282template <typename... T> constexpr bool isSpill(const T &...O) {
283 return getTSFlags(O...) & Spill;
284}
285template <typename... T> constexpr bool isLDSDIR(const T &...O) {
286 return getTSFlags(O...) & LDSDIR;
287}
288template <typename... T> constexpr bool isVINTERP(const T &...O) {
289 return getTSFlags(O...) & VINTERP;
290}
291template <typename... T> constexpr bool isWQM(const T &...O) {
292 return getTSFlags(O...) & WQM;
293}
294template <typename... T> constexpr bool isDisableWQM(const T &...O) {
295 return getTSFlags(O...) & DisableWQM;
296}
297template <typename... T> constexpr bool isGather4(const T &...O) {
298 return getTSFlags(O...) & Gather4;
299}
300template <typename... T> constexpr bool usesTENSOR_CNT(const T &...O) {
301 return getTSFlags(O...) & TENSOR_CNT;
302}
303template <typename... T> constexpr bool isScalarStore(const T &...O) {
304 return getTSFlags(O...) & SCALAR_STORE;
305}
306template <typename... T> constexpr bool isFixedSize(const T &...O) {
307 return getTSFlags(O...) & FIXED_SIZE;
308}
309template <typename... T> constexpr bool usesASYNC_CNT(const T &...O) {
310 return getTSFlags(O...) & ASYNC_CNT;
311}
312template <typename... T> constexpr bool hasVOP3OpSel(const T &...O) {
313 return getTSFlags(O...) & VOP3_OPSEL;
314}
315template <typename... T> constexpr bool isMaybeAtomic(const T &...O) {
316 return getTSFlags(O...) & maybeAtomic;
317}
318template <typename... T> constexpr bool hasFPClamp(const T &...O) {
319 return getTSFlags(O...) & FPClamp;
320}
321template <typename... T> constexpr bool hasIntClamp(const T &...O) {
322 return getTSFlags(O...) & IntClamp;
323}
324template <typename... T> constexpr bool hasClampLo(const T &...O) {
325 return getTSFlags(O...) & ClampLo;
326}
327template <typename... T> constexpr bool hasClampHi(const T &...O) {
328 return getTSFlags(O...) & ClampHi;
329}
330template <typename... T> constexpr bool isPacked(const T &...O) {
331 return getTSFlags(O...) & IsPacked;
332}
333template <typename... T> constexpr bool isD16Buf(const T &...O) {
334 return getTSFlags(O...) & D16Buf;
335}
336template <typename... T> constexpr bool isFlatGlobal(const T &...O) {
337 return getTSFlags(O...) & FlatGlobal;
338}
339template <typename... T> constexpr bool usesFPDPRounding(const T &...O) {
340 return getTSFlags(O...) & FPDPRounding;
341}
342template <typename... T> constexpr bool isFPAtomic(const T &...O) {
343 return getTSFlags(O...) & FPAtomic;
344}
345template <typename... T> constexpr bool isMAI(const T &...O) {
346 return getTSFlags(O...) & IsMAI;
347}
348template <typename... T> constexpr bool isDOT(const T &...O) {
349 return getTSFlags(O...) & IsDOT;
350}
351template <typename... T> constexpr bool isFlatScratch(const T &...O) {
352 return getTSFlags(O...) & FlatScratch;
353}
354template <typename... T> constexpr bool isAtomicNoRet(const T &...O) {
355 return getTSFlags(O...) & IsAtomicNoRet;
356}
357template <typename... T> constexpr bool isAtomicRet(const T &...O) {
358 return getTSFlags(O...) & IsAtomicRet;
359}
360template <typename... T> constexpr bool isWMMA(const T &...O) {
361 return getTSFlags(O...) & IsWMMA;
362}
363template <typename... T> constexpr bool isTiedSourceNotRead(const T &...O) {
364 return getTSFlags(O...) & TiedSourceNotRead;
365}
366template <typename... T> constexpr bool isNeverUniform(const T &...O) {
367 return getTSFlags(O...) & IsNeverUniform;
368}
369template <typename... T> constexpr bool isGWS(const T &...O) {
370 return getTSFlags(O...) & GWS;
371}
372template <typename... T> constexpr bool isSWMMAC(const T &...O) {
373 return getTSFlags(O...) & IsSWMMAC;
374}
375template <typename... T> constexpr bool usesVM_CNT(const T &...O) {
376 return getTSFlags(O...) & VM_CNT;
377}
378template <typename... T> constexpr bool usesLGKM_CNT(const T &...O) {
379 return getTSFlags(O...) & LGKM_CNT;
380}
381
382// Compound predicates.
383template <typename... T> constexpr bool isAtomic(const T &...O) {
384 return isAtomicNoRet(O...) || isAtomicRet(O...);
385}
386template <typename... T> constexpr bool isSegmentSpecificFLAT(const T &...O) {
387 return isFlatGlobal(O...) || isFlatScratch(O...);
388}
389// Any image-family instruction: pre-gfx11 MIMG, gfx11+ VIMAGE or VSAMPLE.
390template <typename... T> constexpr bool isImage(const T &...O) {
391 return isMIMG(O...) || isVIMAGE(O...) || isVSAMPLE(O...);
392}
393// Vector memory: buffer + image + flat.
394template <typename... T> constexpr bool isVMEM(const T &...O) {
395 return isMUBUF(O...) || isMTBUF(O...) || isImage(O...) || isFLAT(O...);
396}
397
398// v_cmp_class_* etc. use a 10-bit mask for what operation is checked.
399// The result is true if any of these tests are true.
400enum ClassFlags : unsigned {
401 S_NAN = 1 << 0, // Signaling NaN
402 Q_NAN = 1 << 1, // Quiet NaN
403 N_INFINITY = 1 << 2, // Negative infinity
404 N_NORMAL = 1 << 3, // Negative normal
405 N_SUBNORMAL = 1 << 4, // Negative subnormal
406 N_ZERO = 1 << 5, // Negative zero
407 P_ZERO = 1 << 6, // Positive zero
408 P_SUBNORMAL = 1 << 7, // Positive subnormal
409 P_NORMAL = 1 << 8, // Positive normal
410 P_INFINITY = 1 << 9 // Positive infinity
411};
412}
413
414namespace AMDGPU {
415
416enum OperandType : unsigned {
417 /// Operands with register, 32-bit, or 64-bit immediate
434
435 /// Operands with register or inline constant
446
447 // Operand for split barrier inline constant
449
450 /// Operand with 32-bit immediate that uses the constant bus.
454
455 /// Operands with an AccVGPR register or inline constant
459
460 // Operand for AV_MOV_B64_IMM_PSEUDO, which is a pair of 32-bit inline
461 // constants. Does not accept registers.
463
464 // Operand for source modifiers for VOP instructions
466
467 // Operand for SDWA instructions
469
472
475
478
481
484
485};
486}
487
488// Input operand modifiers bit-masks
489// NEG and SEXT share same bit-mask because they can't be set simultaneously.
490namespace SISrcMods {
491enum : unsigned {
492 NONE = 0,
493 NEG = 1 << 0, // Floating-point negate modifier
494 ABS = 1 << 1, // Floating-point absolute modifier
495 SEXT = 1 << 4, // Integer sign-extend modifier
496 NEG_HI = ABS, // Floating-point negate high packed component modifier.
497 OP_SEL_0 = 1 << 2,
498 OP_SEL_1 = 1 << 3,
499 DST_OP_SEL = 1 << 3 // VOP3 dst op_sel (share mask with OP_SEL_1)
500};
501}
502
503namespace SIOutMods {
504 enum : unsigned {
505 NONE = 0,
506 MUL2 = 1,
507 MUL4 = 2,
509 };
510}
511
512namespace AMDGPU {
513namespace VGPRIndexMode {
514
515enum Id : unsigned { // id of symbolic names
520
523};
524
534
535} // namespace VGPRIndexMode
536} // namespace AMDGPU
537
539 enum : unsigned {
541 VOP3 = 1,
542 SDWA = 2,
543 SDWA9 = 3,
544 DPP = 4,
546 };
547} // namespace AMDGPUAsmVariants
548
549namespace AMDGPU {
550namespace EncValues { // Encoding values of enum9/8/7 operands
551
552enum : unsigned {
567 VGPR_MIN = 256,
568 VGPR_MAX = 511,
569 IS_VGPR = 256, // Indicates VGPR or AGPR
570};
571
572} // namespace EncValues
573
574// Register codes as defined in the TableGen's HWEncoding field.
575namespace HWEncoding {
576enum : unsigned {
579 IS_VGPR = 1 << 10,
580 IS_AGPR = 1 << 11,
581 IS_HI16 = 1 << 12,
582};
583} // namespace HWEncoding
584
585namespace CPol {
586
587enum CPol {
588 GLC = 1,
589 SLC = 2,
590 DLC = 4,
591 SCC = 16,
597
598 // Below are GFX12+ cache policy bits
599
600 // Temporal hint
601 TH = 0x7, // All TH bits
602 TH_RT = 0, // regular
603 TH_NT = 1, // non-temporal
604 TH_HT = 2, // high-temporal
605 TH_LU = 3, // last use
606 TH_WB = 3, // regular (CU, SE), high-temporal with write-back (MALL)
607 TH_NT_RT = 4, // non-temporal (CU, SE), regular (MALL)
608 TH_RT_NT = 5, // regular (CU, SE), non-temporal (MALL)
609 TH_NT_HT = 6, // non-temporal (CU, SE), high-temporal (MALL)
610 TH_NT_WB = 7, // non-temporal (CU, SE), high-temporal with write-back (MALL)
611 TH_BYPASS = 3, // only to be used with scope = 3
612
613 TH_RESERVED = 7, // unused value for load insts
614
615 // Bits of TH for atomics
616 TH_ATOMIC_RETURN = GLC, // Returning vs non-returning
617 TH_ATOMIC_NT = SLC, // Non-temporal vs regular
618 TH_ATOMIC_CASCADE = 4, // Cascading vs regular
619
620 // Scope
623 SCOPE = SCOPE_MASK << SCOPE_SHIFT, // All Scope bits
628
629 NV = 1 << 5, // Non-volatile bit
630
631 SWZ = 1 << 6, // Swizzle bit
632
633 SCAL = 1 << 11, // Scale offset bit
634
635 ALL = TH | SCOPE | NV,
636
637 // Helper bits
638 TH_TYPE_LOAD = 1 << 7, // TH_LOAD policy
639 TH_TYPE_STORE = 1 << 8, // TH_STORE policy
640 TH_TYPE_ATOMIC = 1 << 9, // TH_ATOMIC policy
641 TH_REAL_BYPASS = 1 << 10, // is TH=3 bypass policy or not
642
643 // Volatile (used to preserve/signal operation volatility for buffer
644 // operations not a real instruction bit)
645 VOLATILE = 1 << 31,
646 // The set of "cache policy" bits used for compiler features that
647 // do not correspond to handware features.
649};
650
651} // namespace CPol
652
653namespace SendMsg { // Encoding of SIMM16 used in s_sendmsg* insns.
654
655enum Id { // Message ID, width(4) [3:0].
657
658 ID_GS_PreGFX11 = 2, // replaced in GFX11
659 ID_GS_DONE_PreGFX11 = 3, // replaced in GFX11
660
661 ID_HS_TESSFACTOR_GFX11Plus = 2, // reused in GFX11
662 ID_DEALLOC_VGPRS_GFX11Plus = 3, // reused in GFX11
663
664 ID_SAVEWAVE = 4, // added in GFX8, removed in GFX11
665 ID_STALL_WAVE_GEN = 5, // added in GFX9, removed in GFX12
666 ID_HALT_WAVES = 6, // added in GFX9, removed in GFX12
667 ID_ORDERED_PS_DONE = 7, // added in GFX9, removed in GFX11
668 ID_EARLY_PRIM_DEALLOC = 8, // added in GFX9, removed in GFX10
669 ID_GS_ALLOC_REQ = 9, // added in GFX9
670 ID_GET_DOORBELL = 10, // added in GFX9, removed in GFX11
671 ID_GET_DDID = 11, // added in GFX10, removed in GFX11
673
682
683 ID_RTN_GET_CLUSTER_BARRIER_STATE = 136, // added in GFX1250
684 ID_RTN_SAVE_WAVE_HAS_TDM = 152, // added in GFX1250
685
688};
689
690enum Op { // Both GS and SYS operation IDs.
693 // Bits used for operation encoding
695 OP_MASK_ = (((1 << OP_WIDTH_) - 1) << OP_SHIFT_),
696 // GS operations are encoded in bits 5:4
702 // SYS operations are encoded in bits 6:4
708};
709
719
720} // namespace SendMsg
721
722namespace WaitEvent { // Encoding of SIMM16 used in s_wait_event
723enum Id {
724 DONT_WAIT_EXPORT_READY = 1 << 0, // Only used in gfx11
725 EXPORT_READY = 1 << 1, // gfx12+
726};
727
728} // namespace WaitEvent
729
730namespace Hwreg { // Encoding of SIMM16 used in s_setreg/getreg* insns.
731
785
786enum Offset : unsigned { // Offset, (5) [10:6]
788 OFFSET_ME_ID = 8, // in HW_ID2
789};
790
792 FP_ROUND_MASK = 0xf << 0, // Bits 0..3
793 FP_DENORM_MASK = 0xf << 4, // Bits 4..7
796 LOD_CLAMP_MASK = 1 << 10,
797 DEBUG_MASK = 1 << 11,
798
799 // EXCP_EN fields.
807
809 VSKIP_MASK = 1 << 28,
810 CSP_MASK = 0x7u << 29, // Bits 29..31
811
812 // GFX1250
813 DST_VGPR_MSB = 0x3 << 12,
814 SRC0_VGPR_MSB = 0x3 << 14,
815 SRC1_VGPR_MSB = 0x3 << 16,
816 SRC2_VGPR_MSB = 0x3 << 18,
817 VGPR_MSB_MASK = 0xff << 12, // Bits 12..19
818
819 REPLAY_MODE = 1 << 25,
821};
822
823} // namespace Hwreg
824
894
895namespace UfmtGFX10 {
896enum UnifiedFormat : int64_t {
898
905
913
920
924
932
940
948
955
962
969
973
981
988
991};
992
993} // namespace UfmtGFX10
994
995namespace UfmtGFX11 {
996enum UnifiedFormat : int64_t {
998
1005
1013
1020
1024
1032
1034
1036
1041
1048
1055
1059
1067
1074
1077};
1078
1079} // namespace UfmtGFX11
1080
1081namespace Swizzle { // Encoding of swizzle macro used in ds_swizzle_b32.
1082
1092
1093// clang-format off
1094enum EncBits : unsigned {
1095
1096 // swizzle mode encodings
1097
1100
1103
1105
1108
1110 FFT_MODE_LO = 0xE000,
1111
1112 // QUAD_PERM encodings
1113
1118
1119 // BITMASK_PERM encodings
1120
1124
1128
1129 // FFT encodings
1130
1133
1134 // ROTATE encodings
1136 ROTATE_DIR_SHIFT = 10, // bit position of rotate direction
1138 ROTATE_SIZE_SHIFT = 5, // bit position of rotate size
1140};
1141// clang-format on
1142
1143} // namespace Swizzle
1144
1145namespace SDWA {
1146
1147enum SdwaSel : unsigned {
1155};
1156
1157enum DstUnused : unsigned {
1161};
1162
1177
1178} // namespace SDWA
1179
1180namespace DPP {
1181
1182// clang-format off
1227// clang-format on
1228
1235
1236} // namespace DPP
1237
1238namespace Exp {
1239
1240enum Target : unsigned {
1244 ET_NULL = 9, // Pre-GFX11
1247 ET_POS4 = 16, // GFX10+
1248 ET_POS_LAST = ET_POS4, // Highest pos used on any subtarget
1249 ET_PRIM = 20, // GFX10+
1250 ET_DUAL_SRC_BLEND0 = 21, // GFX11+
1251 ET_DUAL_SRC_BLEND1 = 22, // GFX11+
1252 ET_PARAM0 = 32, // Pre-GFX11
1253 ET_PARAM31 = 63, // Pre-GFX11
1254
1262
1264};
1265
1266} // namespace Exp
1267
1288
1289namespace VOP3PEncoding {
1290
1292 OP_SEL_HI_0 = UINT64_C(1) << 59,
1293 OP_SEL_HI_1 = UINT64_C(1) << 60,
1294 OP_SEL_HI_2 = UINT64_C(1) << 14,
1295};
1296
1297} // namespace VOP3PEncoding
1298
1299namespace ImplicitArg {
1300// Implicit kernel argument offset for code object version 5.
1313
1314} // namespace ImplicitArg
1315
1317// Enum value used in cbsz/blgp for F8F6F4 MFMA operations to select the matrix
1318// format.
1326} // namespace MFMAScaleFormats
1327
1328namespace VirtRegFlag {
1329// Virtual register flags used for various target specific handlings during
1330// codegen.
1332 // Register operand in a whole-wave mode operation.
1333 WWM_REG = 1 << 0,
1334};
1335
1336} // namespace VirtRegFlag
1337
1338} // namespace AMDGPU
1339
1340namespace AMDGPU {
1341namespace Barrier {
1342
1351
1352enum {
1354};
1355
1356} // namespace Barrier
1357} // namespace AMDGPU
1358
1359// clang-format off
1360
1361#define R_00B028_SPI_SHADER_PGM_RSRC1_PS 0x00B028
1362#define S_00B028_VGPRS(x) (((x) & 0x3F) << 0)
1363#define S_00B028_SGPRS(x) (((x) & 0x0F) << 6)
1364#define S_00B028_MEM_ORDERED(x) (((x) & 0x1) << 25)
1365#define G_00B028_MEM_ORDERED(x) (((x) >> 25) & 0x1)
1366#define C_00B028_MEM_ORDERED 0xFDFFFFFF
1367
1368#define R_00B02C_SPI_SHADER_PGM_RSRC2_PS 0x00B02C
1369#define S_00B02C_EXTRA_LDS_SIZE(x) (((x) & 0xFF) << 8)
1370#define R_00B128_SPI_SHADER_PGM_RSRC1_VS 0x00B128
1371#define S_00B128_MEM_ORDERED(x) (((x) & 0x1) << 27)
1372#define G_00B128_MEM_ORDERED(x) (((x) >> 27) & 0x1)
1373#define C_00B128_MEM_ORDERED 0xF7FFFFFF
1374
1375#define R_00B228_SPI_SHADER_PGM_RSRC1_GS 0x00B228
1376#define S_00B228_WGP_MODE(x) (((x) & 0x1) << 27)
1377#define G_00B228_WGP_MODE(x) (((x) >> 27) & 0x1)
1378#define C_00B228_WGP_MODE 0xF7FFFFFF
1379#define S_00B228_MEM_ORDERED(x) (((x) & 0x1) << 25)
1380#define G_00B228_MEM_ORDERED(x) (((x) >> 25) & 0x1)
1381#define C_00B228_MEM_ORDERED 0xFDFFFFFF
1382
1383#define R_00B328_SPI_SHADER_PGM_RSRC1_ES 0x00B328
1384#define R_00B428_SPI_SHADER_PGM_RSRC1_HS 0x00B428
1385#define S_00B428_WGP_MODE(x) (((x) & 0x1) << 26)
1386#define G_00B428_WGP_MODE(x) (((x) >> 26) & 0x1)
1387#define C_00B428_WGP_MODE 0xFBFFFFFF
1388#define S_00B428_MEM_ORDERED(x) (((x) & 0x1) << 24)
1389#define G_00B428_MEM_ORDERED(x) (((x) >> 24) & 0x1)
1390#define C_00B428_MEM_ORDERED 0xFEFFFFFF
1391
1392#define R_00B528_SPI_SHADER_PGM_RSRC1_LS 0x00B528
1393
1394#define R_00B84C_COMPUTE_PGM_RSRC2 0x00B84C
1395#define S_00B84C_SCRATCH_EN(x) (((x) & 0x1) << 0)
1396#define G_00B84C_SCRATCH_EN(x) (((x) >> 0) & 0x1)
1397#define C_00B84C_SCRATCH_EN 0xFFFFFFFE
1398#define S_00B84C_USER_SGPR(x) (((x) & 0x1F) << 1)
1399#define G_00B84C_USER_SGPR(x) (((x) >> 1) & 0x1F)
1400#define C_00B84C_USER_SGPR 0xFFFFFFC1
1401#define S_00B84C_TRAP_HANDLER(x) (((x) & 0x1) << 6)
1402#define G_00B84C_TRAP_HANDLER(x) (((x) >> 6) & 0x1)
1403#define C_00B84C_TRAP_HANDLER 0xFFFFFFBF
1404#define S_00B84C_TGID_X_EN(x) (((x) & 0x1) << 7)
1405#define G_00B84C_TGID_X_EN(x) (((x) >> 7) & 0x1)
1406#define C_00B84C_TGID_X_EN 0xFFFFFF7F
1407#define S_00B84C_TGID_Y_EN(x) (((x) & 0x1) << 8)
1408#define G_00B84C_TGID_Y_EN(x) (((x) >> 8) & 0x1)
1409#define C_00B84C_TGID_Y_EN 0xFFFFFEFF
1410#define S_00B84C_TGID_Z_EN(x) (((x) & 0x1) << 9)
1411#define G_00B84C_TGID_Z_EN(x) (((x) >> 9) & 0x1)
1412#define C_00B84C_TGID_Z_EN 0xFFFFFDFF
1413#define S_00B84C_TG_SIZE_EN(x) (((x) & 0x1) << 10)
1414#define G_00B84C_TG_SIZE_EN(x) (((x) >> 10) & 0x1)
1415#define C_00B84C_TG_SIZE_EN 0xFFFFFBFF
1416#define S_00B84C_TIDIG_COMP_CNT(x) (((x) & 0x03) << 11)
1417#define G_00B84C_TIDIG_COMP_CNT(x) (((x) >> 11) & 0x03)
1418#define C_00B84C_TIDIG_COMP_CNT 0xFFFFE7FF
1419/* CIK */
1420#define S_00B84C_EXCP_EN_MSB(x) (((x) & 0x03) << 13)
1421#define G_00B84C_EXCP_EN_MSB(x) (((x) >> 13) & 0x03)
1422#define C_00B84C_EXCP_EN_MSB 0xFFFF9FFF
1423/* */
1424#define S_00B84C_LDS_SIZE(x) (((x) & 0x1FF) << 15)
1425#define G_00B84C_LDS_SIZE(x) (((x) >> 15) & 0x1FF)
1426#define C_00B84C_LDS_SIZE 0xFF007FFF
1427#define S_00B84C_EXCP_EN(x) (((x) & 0x7F) << 24)
1428#define G_00B84C_EXCP_EN(x) (((x) >> 24) & 0x7F)
1429#define C_00B84C_EXCP_EN 0x80FFFFFF
1430
1431#define S_00B84C_USER_SGPR_GFX1250(x) (((x) & 0x3F) << 1)
1432#define G_00B84C_USER_SGPR_GFX1250(x) (((x) >> 1) & 0x3F)
1433#define C_00B84C_USER_SGPR_GFX1250 0xFFFFFF81
1434
1435#define R_0286CC_SPI_PS_INPUT_ENA 0x0286CC
1436#define R_0286D0_SPI_PS_INPUT_ADDR 0x0286D0
1437
1438#define R_00B848_COMPUTE_PGM_RSRC1 0x00B848
1439#define S_00B848_VGPRS(x) (((x) & 0x3F) << 0)
1440#define G_00B848_VGPRS(x) (((x) >> 0) & 0x3F)
1441#define C_00B848_VGPRS 0xFFFFFFC0
1442#define S_00B848_SGPRS(x) (((x) & 0x0F) << 6)
1443#define G_00B848_SGPRS(x) (((x) >> 6) & 0x0F)
1444#define C_00B848_SGPRS 0xFFFFFC3F
1445#define S_00B848_PRIORITY(x) (((x) & 0x03) << 10)
1446#define G_00B848_PRIORITY(x) (((x) >> 10) & 0x03)
1447#define C_00B848_PRIORITY 0xFFFFF3FF
1448#define S_00B848_FLOAT_MODE(x) (((x) & 0xFF) << 12)
1449#define G_00B848_FLOAT_MODE(x) (((x) >> 12) & 0xFF)
1450#define C_00B848_FLOAT_MODE 0xFFF00FFF
1451#define S_00B848_PRIV(x) (((x) & 0x1) << 20)
1452#define G_00B848_PRIV(x) (((x) >> 20) & 0x1)
1453#define C_00B848_PRIV 0xFFEFFFFF
1454#define S_00B848_DX10_CLAMP(x) (((x) & 0x1) << 21)
1455#define G_00B848_DX10_CLAMP(x) (((x) >> 21) & 0x1)
1456#define C_00B848_DX10_CLAMP 0xFFDFFFFF
1457#define S_00B848_RR_WG_MODE(x) (((x) & 0x1) << 21)
1458#define G_00B848_RR_WG_MODE(x) (((x) >> 21) & 0x1)
1459#define C_00B848_RR_WG_MODE 0xFFDFFFFF
1460#define S_00B848_DEBUG_MODE(x) (((x) & 0x1) << 22)
1461#define G_00B848_DEBUG_MODE(x) (((x) >> 22) & 0x1)
1462#define C_00B848_DEBUG_MODE 0xFFBFFFFF
1463#define S_00B848_IEEE_MODE(x) (((x) & 0x1) << 23)
1464#define G_00B848_IEEE_MODE(x) (((x) >> 23) & 0x1)
1465#define C_00B848_IEEE_MODE 0xFF7FFFFF
1466#define S_00B848_WGP_MODE(x) (((x) & 0x1) << 29)
1467#define G_00B848_WGP_MODE(x) (((x) >> 29) & 0x1)
1468#define C_00B848_WGP_MODE 0xDFFFFFFF
1469#define S_00B848_MEM_ORDERED(x) (((x) & 0x1) << 30)
1470#define G_00B848_MEM_ORDERED(x) (((x) >> 30) & 0x1)
1471#define C_00B848_MEM_ORDERED 0xBFFFFFFF
1472#define S_00B848_FWD_PROGRESS(x) (((x) & 0x1) << 31)
1473#define G_00B848_FWD_PROGRESS(x) (((x) >> 31) & 0x1)
1474#define C_00B848_FWD_PROGRESS 0x7FFFFFFF
1475
1476// Helpers for setting FLOAT_MODE
1477#define FP_ROUND_ROUND_TO_NEAREST 0
1478#define FP_ROUND_ROUND_TO_INF 1
1479#define FP_ROUND_ROUND_TO_NEGINF 2
1480#define FP_ROUND_ROUND_TO_ZERO 3
1481
1482// Bits 3:0 control rounding mode. 1:0 control single precision, 3:2 double
1483// precision.
1484#define FP_ROUND_MODE_SP(x) ((x) & 0x3)
1485#define FP_ROUND_MODE_DP(x) (((x) & 0x3) << 2)
1486
1487#define FP_DENORM_FLUSH_IN_FLUSH_OUT 0
1488#define FP_DENORM_FLUSH_OUT 1
1489#define FP_DENORM_FLUSH_IN 2
1490#define FP_DENORM_FLUSH_NONE 3
1491
1492
1493// Bits 7:4 control denormal handling. 5:4 control single precision, 6:7 double
1494// precision.
1495#define FP_DENORM_MODE_SP(x) (((x) & 0x3) << 4)
1496#define FP_DENORM_MODE_DP(x) (((x) & 0x3) << 6)
1497
1498#define R_00B860_COMPUTE_TMPRING_SIZE 0x00B860
1499#define S_00B860_WAVESIZE_PreGFX11(x) (((x) & 0x1FFF) << 12)
1500#define S_00B860_WAVESIZE_GFX11(x) (((x) & 0x7FFF) << 12)
1501#define S_00B860_WAVESIZE_GFX12Plus(x) (((x) & 0x3FFFF) << 12)
1502
1503#define R_0286E8_SPI_TMPRING_SIZE 0x0286E8
1504#define S_0286E8_WAVESIZE_PreGFX11(x) (((x) & 0x1FFF) << 12)
1505#define S_0286E8_WAVESIZE_GFX11(x) (((x) & 0x7FFF) << 12)
1506#define S_0286E8_WAVESIZE_GFX12Plus(x) (((x) & 0x3FFFF) << 12)
1507
1508#define R_028B54_VGT_SHADER_STAGES_EN 0x028B54
1509#define S_028B54_HS_W32_EN(x) (((x) & 0x1) << 21)
1510#define S_028B54_GS_W32_EN(x) (((x) & 0x1) << 22)
1511#define S_028B54_VS_W32_EN(x) (((x) & 0x1) << 23)
1512#define R_0286D8_SPI_PS_IN_CONTROL 0x0286D8
1513#define S_0286D8_PS_W32_EN(x) (((x) & 0x1) << 15)
1514#define R_00B800_COMPUTE_DISPATCH_INITIATOR 0x00B800
1515#define S_00B800_CS_W32_EN(x) (((x) & 0x1) << 15)
1516
1517#define R_SPILLED_SGPRS 0x4
1518#define R_SPILLED_VGPRS 0x8
1519
1520// clang-format on
1521
1522} // End namespace llvm
1523
1524#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:433
@ OPERAND_KIMM32
Operand with 32-bit immediate that uses the constant bus.
Definition SIDefines.h:451
@ OPERAND_REG_INLINE_C_LAST
Definition SIDefines.h:474
@ OPERAND_REG_IMM_INT64
Definition SIDefines.h:419
@ OPERAND_REG_IMM_V2FP16
Definition SIDefines.h:426
@ OPERAND_REG_INLINE_C_FP64
Definition SIDefines.h:442
@ OPERAND_REG_INLINE_C_BF16
Definition SIDefines.h:439
@ OPERAND_REG_IMM_FIRST
Definition SIDefines.h:470
@ OPERAND_REG_INLINE_C_V2BF16
Definition SIDefines.h:444
@ OPERAND_REG_IMM_V2INT64
Definition SIDefines.h:429
@ OPERAND_REG_IMM_V2INT16
Definition SIDefines.h:428
@ OPERAND_REG_IMM_BF16
Definition SIDefines.h:423
@ OPERAND_REG_IMM_INT32
Operands with register, 32-bit, or 64-bit immediate.
Definition SIDefines.h:418
@ OPERAND_REG_IMM_V2BF16
Definition SIDefines.h:425
@ OPERAND_REG_INLINE_AC_FIRST
Definition SIDefines.h:476
@ OPERAND_REG_IMM_FP16
Definition SIDefines.h:424
@ OPERAND_REG_IMM_V2FP16_SPLAT
Definition SIDefines.h:427
@ OPERAND_REG_INLINE_C_INT64
Definition SIDefines.h:438
@ OPERAND_REG_INLINE_C_INT16
Operands with register or inline constant.
Definition SIDefines.h:436
@ OPERAND_REG_IMM_NOINLINE_V2FP16
Definition SIDefines.h:430
@ OPERAND_REG_IMM_FP64
Definition SIDefines.h:422
@ OPERAND_REG_INLINE_C_V2FP16
Definition SIDefines.h:445
@ OPERAND_REG_INLINE_AC_INT32
Operands with an AccVGPR register or inline constant.
Definition SIDefines.h:456
@ OPERAND_REG_INLINE_AC_FP32
Definition SIDefines.h:457
@ OPERAND_REG_IMM_V2INT32
Definition SIDefines.h:431
@ OPERAND_SDWA_VOPC_DST
Definition SIDefines.h:468
@ OPERAND_REG_IMM_FP32
Definition SIDefines.h:421
@ OPERAND_REG_INLINE_C_FIRST
Definition SIDefines.h:473
@ OPERAND_REG_INLINE_C_FP32
Definition SIDefines.h:441
@ OPERAND_REG_INLINE_AC_LAST
Definition SIDefines.h:477
@ OPERAND_REG_IMM_LAST
Definition SIDefines.h:471
@ OPERAND_REG_INLINE_C_INT32
Definition SIDefines.h:437
@ OPERAND_REG_INLINE_C_V2INT16
Definition SIDefines.h:443
@ OPERAND_INLINE_C_AV64_PSEUDO
Definition SIDefines.h:462
@ OPERAND_REG_IMM_V2FP32
Definition SIDefines.h:432
@ OPERAND_REG_INLINE_AC_FP64
Definition SIDefines.h:458
@ OPERAND_REG_INLINE_C_FP16
Definition SIDefines.h:440
@ OPERAND_REG_IMM_INT16
Definition SIDefines.h:420
@ OPERAND_INLINE_SPLIT_BARRIER_INT32
Definition SIDefines.h:448
@ OPERAND_FIRST_TARGET
Definition MCInstrDesc.h:79
constexpr bool isAtomicRet(const T &...O)
Definition SIDefines.h:357
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:303
constexpr bool hasVOP3OpSel(const T &...O)
Definition SIDefines.h:312
constexpr bool isVOP1(const T &...O)
Definition SIDefines.h:225
constexpr bool isFPAtomic(const T &...O)
Definition SIDefines.h:342
constexpr bool usesVM_CNT(const T &...O)
Definition SIDefines.h:375
constexpr bool usesTENSOR_CNT(const T &...O)
Definition SIDefines.h:300
constexpr bool isD16Buf(const T &...O)
Definition SIDefines.h:333
constexpr bool isMAI(const T &...O)
Definition SIDefines.h:345
constexpr bool isVOP2(const T &...O)
Definition SIDefines.h:228
constexpr bool isMaybeAtomic(const T &...O)
Definition SIDefines.h:315
constexpr bool isSWMMAC(const T &...O)
Definition SIDefines.h:372
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:276
constexpr bool isVOP3P(const T &...O)
Definition SIDefines.h:237
constexpr bool usesFPDPRounding(const T &...O)
Definition SIDefines.h:339
constexpr bool isDisableWQM(const T &...O)
Definition SIDefines.h:294
constexpr bool isBuffer(const T &...O)
Definition SIDefines.h:258
constexpr bool hasIntClamp(const T &...O)
Definition SIDefines.h:321
constexpr bool isAtomicNoRet(const T &...O)
Definition SIDefines.h:354
constexpr bool isMTBUF(const T &...O)
Definition SIDefines.h:255
constexpr bool isVIMAGE(const T &...O)
Definition SIDefines.h:267
constexpr bool isSMRD(const T &...O)
Definition SIDefines.h:261
constexpr bool isFlatScratch(const T &...O)
Definition SIDefines.h:351
constexpr bool isSpill(const T &...O)
Definition SIDefines.h:282
constexpr uint64_t getTSFlags(const MCInstrDesc &Desc)
Definition SIDefines.h:196
constexpr bool isMIMG(const T &...O)
Definition SIDefines.h:264
constexpr bool isVMEM(const T &...O)
Definition SIDefines.h:394
constexpr bool hasFPClamp(const T &...O)
Definition SIDefines.h:318
constexpr bool isNeverUniform(const T &...O)
Definition SIDefines.h:366
constexpr bool isImage(const T &...O)
Definition SIDefines.h:390
constexpr bool isWMMA(const T &...O)
Definition SIDefines.h:360
constexpr bool isVALU(const T &...O)
Definition SIDefines.h:207
constexpr bool isWQM(const T &...O)
Definition SIDefines.h:291
constexpr bool hasClampLo(const T &...O)
Definition SIDefines.h:324
constexpr bool isGWS(const T &...O)
Definition SIDefines.h:369
constexpr bool isFlatGlobal(const T &...O)
Definition SIDefines.h:336
constexpr bool usesASYNC_CNT(const T &...O)
Definition SIDefines.h:309
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:363
constexpr bool isEXP(const T &...O)
Definition SIDefines.h:273
constexpr bool usesLGKM_CNT(const T &...O)
Definition SIDefines.h:378
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:348
constexpr bool isVINTRP(const T &...O)
Definition SIDefines.h:240
constexpr bool isVINTERP(const T &...O)
Definition SIDefines.h:288
constexpr bool isVSAMPLE(const T &...O)
Definition SIDefines.h:270
constexpr bool isDS(const T &...O)
Definition SIDefines.h:279
constexpr bool isAtomic(const T &...O)
Definition SIDefines.h:383
constexpr bool isLDSDIR(const T &...O)
Definition SIDefines.h:285
constexpr bool isSALU(const T &...O)
Definition SIDefines.h:204
constexpr bool isGather4(const T &...O)
Definition SIDefines.h:297
constexpr bool isPacked(const T &...O)
Definition SIDefines.h:330
constexpr bool hasClampHi(const T &...O)
Definition SIDefines.h:327
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:386
constexpr bool isFixedSize(const T &...O)
Definition SIDefines.h:306
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