LLVM 24.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
59// Raw TSFlags bit constants — use the predicate functions below instead of
60// testing these directly. This namespace makes accidental direct use a
61// compile error outside of SIDefines.h itself.
63// This needs to be kept in sync with the field bits in InstSI.
64enum : uint64_t {
65 // Low bits - basic encoding information.
66 SALU = 1 << 0,
67 VALU = 1 << 1,
68
69 // SALU instruction formats.
70 SOP1 = 1 << 2,
71 SOP2 = 1 << 3,
72 SOPC = 1 << 4,
73 SOPK = 1 << 5,
74 SOPP = 1 << 6,
75
76 // VALU instruction formats.
77 VOP1 = 1 << 7,
78 VOP2 = 1 << 8,
79 VOPC = 1 << 9,
80
81 // TODO: Should this be spilt into VOP3 a and b?
82 VOP3 = 1 << 10,
83 VOP3P = 1 << 12,
84
85 VINTRP = 1 << 13,
86 SDWA = 1 << 14,
87 DPP = 1 << 15,
88 TRANS = 1 << 16,
89
90 // Memory instruction formats.
91 MUBUF = 1 << 17,
92 MTBUF = 1 << 18,
93 SMRD = 1 << 19,
94 MIMG = 1 << 20,
95 VIMAGE = 1 << 21,
96 VSAMPLE = 1 << 22,
97 EXP = 1 << 23,
98 FLAT = 1 << 24,
99 DS = 1 << 25,
100
101 // Combined SGPR/VGPR Spill bit
102 // Logic to separate them out is done in isSGPRSpill and isVGPRSpill
103 Spill = 1 << 26,
104
105 // LDSDIR instruction format.
106 LDSDIR = 1 << 28,
107
108 // VINTERP instruction format.
109 VINTERP = 1 << 29,
110
111 VOPD3 = 1 << 30,
112
113 // High bits - other information.
114 VM_CNT = UINT64_C(1) << 32,
115 EXP_CNT = UINT64_C(1) << 33,
116 LGKM_CNT = UINT64_C(1) << 34,
117
118 WQM = UINT64_C(1) << 35,
119 DisableWQM = UINT64_C(1) << 36,
120 Gather4 = UINT64_C(1) << 37,
121
122 TENSOR_CNT = UINT64_C(1) << 38,
123
124 SCALAR_STORE = UINT64_C(1) << 39,
125 FIXED_SIZE = UINT64_C(1) << 40,
126
127 ASYNC_CNT = UINT64_C(1) << 41,
128
129 VOP3_OPSEL = UINT64_C(1) << 42,
130 maybeAtomic = UINT64_C(1) << 43,
131 renamedInGFX9 = UINT64_C(1) << 44,
132
133 // Is a clamp on FP type.
134 FPClamp = UINT64_C(1) << 45,
135
136 // Is an integer clamp
137 IntClamp = UINT64_C(1) << 46,
138
139 // Clamps lo component of register.
140 ClampLo = UINT64_C(1) << 47,
141
142 // Clamps hi component of register.
143 // ClampLo and ClampHi set for packed clamp.
144 ClampHi = UINT64_C(1) << 48,
145
146 // Is a packed VOP3P instruction.
147 IsPacked = UINT64_C(1) << 49,
148
149 // Is a D16 buffer instruction.
150 D16Buf = UINT64_C(1) << 50,
151
152 // FLAT instruction accesses FLAT_GLBL segment.
153 FlatGlobal = UINT64_C(1) << 51,
154
155 // Uses floating point double precision rounding mode
156 FPDPRounding = UINT64_C(1) << 52,
157
158 // Instruction is FP atomic.
159 FPAtomic = UINT64_C(1) << 53,
160
161 // Is a MFMA instruction.
162 IsMAI = UINT64_C(1) << 54,
163
164 // Is a DOT instruction.
165 IsDOT = UINT64_C(1) << 55,
166
167 // FLAT instruction accesses FLAT_SCRATCH segment.
168 FlatScratch = UINT64_C(1) << 56,
169
170 // Atomic without return.
171 IsAtomicNoRet = UINT64_C(1) << 57,
172
173 // Atomic with return.
174 IsAtomicRet = UINT64_C(1) << 58,
175
176 // Is a WMMA instruction.
177 IsWMMA = UINT64_C(1) << 59,
178
179 // Whether tied sources will be read.
180 TiedSourceNotRead = UINT64_C(1) << 60,
181
182 // Is never uniform.
183 IsNeverUniform = UINT64_C(1) << 61,
184
185 // ds_gws_* instructions.
186 GWS = UINT64_C(1) << 62,
187
188 // Is a SWMMAC instruction.
189 IsSWMMAC = UINT64_C(1) << 63,
190};
191} // namespace DontUseRawTSFlags
192
193// Predicate functions over TSFlags — the single place where raw TSFlags bit
194// tests are written. All callers (SIInstrInfo methods, MC-layer code) go
195// through these so that bit-layout changes require updating only this file.
196//
197// getTSFlags is overloaded for MCInstrDesc, (MCInstrInfo, Opcode), and
198// (MCInstrInfo, MCInst) here; SIInstrInfo.h adds a MachineInstr overload in
199// namespace llvm so ADL finds it when predicates are instantiated with
200// MachineInstr.
201
202constexpr uint64_t getTSFlags(const MCInstrDesc &Desc) { return Desc.TSFlags; }
203inline uint64_t getTSFlags(const MCInstrInfo &MII, unsigned Opcode) {
204 return MII.get(Opcode).TSFlags;
205}
206inline uint64_t getTSFlags(const MCInstrInfo &MII, const MCInst &Inst) {
207 return MII.get(Inst.getOpcode()).TSFlags;
208}
209
210template <typename... T> constexpr bool isSALU(const T &...O) {
211 return getTSFlags(O...) & DontUseRawTSFlags::SALU;
212}
213template <typename... T> constexpr bool isVALU(const T &...O) {
214 return getTSFlags(O...) & DontUseRawTSFlags::VALU;
215}
216template <typename... T> constexpr bool isSOP1(const T &...O) {
217 return getTSFlags(O...) & DontUseRawTSFlags::SOP1;
218}
219template <typename... T> constexpr bool isSOP2(const T &...O) {
220 return getTSFlags(O...) & DontUseRawTSFlags::SOP2;
221}
222template <typename... T> constexpr bool isSOPC(const T &...O) {
223 return getTSFlags(O...) & DontUseRawTSFlags::SOPC;
224}
225template <typename... T> constexpr bool isSOPK(const T &...O) {
226 return getTSFlags(O...) & DontUseRawTSFlags::SOPK;
227}
228template <typename... T> constexpr bool isSOPP(const T &...O) {
229 return getTSFlags(O...) & DontUseRawTSFlags::SOPP;
230}
231template <typename... T> constexpr bool isVOP1(const T &...O) {
232 return getTSFlags(O...) & DontUseRawTSFlags::VOP1;
233}
234template <typename... T> constexpr bool isVOP2(const T &...O) {
235 return getTSFlags(O...) & DontUseRawTSFlags::VOP2;
236}
237template <typename... T> constexpr bool isVOPC(const T &...O) {
238 return getTSFlags(O...) & DontUseRawTSFlags::VOPC;
239}
240template <typename... T> constexpr bool isVOP3(const T &...O) {
241 return getTSFlags(O...) & DontUseRawTSFlags::VOP3;
242}
243template <typename... T> constexpr bool isVOP3P(const T &...O) {
245}
246template <typename... T> constexpr bool isVOP3Like(const T &...O) {
247 return getTSFlags(O...) &
249}
250template <typename... T> constexpr bool isVINTRP(const T &...O) {
252}
253template <typename... T> constexpr bool isSDWA(const T &...O) {
254 return getTSFlags(O...) & DontUseRawTSFlags::SDWA;
255}
256template <typename... T> constexpr bool isDPP(const T &...O) {
257 return getTSFlags(O...) & DontUseRawTSFlags::DPP;
258}
259template <typename... T> constexpr bool isTRANS(const T &...O) {
261}
262template <typename... T> constexpr bool isMUBUF(const T &...O) {
264}
265template <typename... T> constexpr bool isMTBUF(const T &...O) {
267}
268template <typename... T> constexpr bool isBuffer(const T &...O) {
269 return getTSFlags(O...) &
271}
272template <typename... T> constexpr bool isSMRD(const T &...O) {
273 return getTSFlags(O...) & DontUseRawTSFlags::SMRD;
274}
275template <typename... T> constexpr bool isMIMG(const T &...O) {
276 return getTSFlags(O...) & DontUseRawTSFlags::MIMG;
277}
278template <typename... T> constexpr bool isVIMAGE(const T &...O) {
280}
281template <typename... T> constexpr bool isVSAMPLE(const T &...O) {
283}
284template <typename... T> constexpr bool isEXP(const T &...O) {
285 return getTSFlags(O...) & DontUseRawTSFlags::EXP;
286}
287template <typename... T> constexpr bool isFLAT(const T &...O) {
288 return getTSFlags(O...) & DontUseRawTSFlags::FLAT;
289}
290template <typename... T> constexpr bool isDS(const T &...O) {
291 return getTSFlags(O...) & DontUseRawTSFlags::DS;
292}
293template <typename... T> constexpr bool isSpill(const T &...O) {
295}
296template <typename... T> constexpr bool isLDSDIR(const T &...O) {
298}
299template <typename... T> constexpr bool isVINTERP(const T &...O) {
301}
302template <typename... T> constexpr bool isWQM(const T &...O) {
303 return getTSFlags(O...) & DontUseRawTSFlags::WQM;
304}
305template <typename... T> constexpr bool isDisableWQM(const T &...O) {
307}
308template <typename... T> constexpr bool isGather4(const T &...O) {
310}
311template <typename... T> constexpr bool usesTENSOR_CNT(const T &...O) {
313}
314template <typename... T> constexpr bool isScalarStore(const T &...O) {
316}
317template <typename... T> constexpr bool isFixedSize(const T &...O) {
319}
320template <typename... T> constexpr bool usesASYNC_CNT(const T &...O) {
322}
323template <typename... T> constexpr bool hasVOP3OpSel(const T &...O) {
325}
326template <typename... T> constexpr bool isMaybeAtomic(const T &...O) {
328}
329template <typename... T> constexpr bool hasFPClamp(const T &...O) {
331}
332template <typename... T> constexpr bool hasIntClamp(const T &...O) {
334}
335template <typename... T> constexpr bool hasClampLo(const T &...O) {
337}
338template <typename... T> constexpr bool hasClampHi(const T &...O) {
340}
341template <typename... T> constexpr bool isPacked(const T &...O) {
343}
344template <typename... T> constexpr bool isD16Buf(const T &...O) {
346}
347template <typename... T> constexpr bool isFlatGlobal(const T &...O) {
349}
350template <typename... T> constexpr bool usesFPDPRounding(const T &...O) {
352}
353template <typename... T> constexpr bool isFPAtomic(const T &...O) {
355}
356template <typename... T> constexpr bool isMAI(const T &...O) {
358}
359template <typename... T> constexpr bool isDOT(const T &...O) {
361}
362template <typename... T> constexpr bool isFlatScratch(const T &...O) {
364}
365template <typename... T> constexpr bool isAtomicNoRet(const T &...O) {
367}
368template <typename... T> constexpr bool isAtomicRet(const T &...O) {
370}
371template <typename... T> constexpr bool isWMMA(const T &...O) {
373}
374template <typename... T> constexpr bool isTiedSourceNotRead(const T &...O) {
376}
377template <typename... T> constexpr bool isNeverUniform(const T &...O) {
379}
380template <typename... T> constexpr bool isGWS(const T &...O) {
381 return getTSFlags(O...) & DontUseRawTSFlags::GWS;
382}
383template <typename... T> constexpr bool isSWMMAC(const T &...O) {
385}
386template <typename... T> constexpr bool isVOPD3(const T &...O) {
388}
389template <typename... T> constexpr bool usesVM_CNT(const T &...O) {
391}
392template <typename... T> constexpr bool usesLGKM_CNT(const T &...O) {
394}
395
396// Compound predicates.
397template <typename... T> constexpr bool isAtomic(const T &...O) {
398 return isAtomicNoRet(O...) || isAtomicRet(O...);
399}
400template <typename... T> constexpr bool isSegmentSpecificFLAT(const T &...O) {
401 return isFlatGlobal(O...) || isFlatScratch(O...);
402}
403// Any image-family instruction: pre-gfx11 MIMG, gfx11+ VIMAGE or VSAMPLE.
404template <typename... T> constexpr bool isImage(const T &...O) {
405 return isMIMG(O...) || isVIMAGE(O...) || isVSAMPLE(O...);
406}
407// Vector memory: buffer + image + flat.
408template <typename... T> constexpr bool isVMEM(const T &...O) {
409 return isMUBUF(O...) || isMTBUF(O...) || isImage(O...) || isFLAT(O...);
410}
411
412// v_cmp_class_* etc. use a 10-bit mask for what operation is checked.
413// The result is true if any of these tests are true.
414enum ClassFlags : unsigned {
415 S_NAN = 1 << 0, // Signaling NaN
416 Q_NAN = 1 << 1, // Quiet NaN
417 N_INFINITY = 1 << 2, // Negative infinity
418 N_NORMAL = 1 << 3, // Negative normal
419 N_SUBNORMAL = 1 << 4, // Negative subnormal
420 N_ZERO = 1 << 5, // Negative zero
421 P_ZERO = 1 << 6, // Positive zero
422 P_SUBNORMAL = 1 << 7, // Positive subnormal
423 P_NORMAL = 1 << 8, // Positive normal
424 P_INFINITY = 1 << 9 // Positive infinity
425};
426}
427
428namespace AMDGPU {
429
430enum OperandType : unsigned {
431 /// Operands with register, 32-bit, or 64-bit immediate
448
449 /// Operands with register or inline constant
460
461 // Operand for split barrier inline constant
463
464 /// Operand with 32-bit immediate that uses the constant bus.
468
469 /// Operands with an AccVGPR register or inline constant
473
474 // Operand for AV_MOV_B64_IMM_PSEUDO, which is a pair of 32-bit inline
475 // constants. Does not accept registers.
477
478 // Operand for source modifiers for VOP instructions
480
481 // Operand for SDWA instructions
483
486
489
492
495
498
499};
500}
501
502// Input operand modifiers bit-masks
503// NEG and SEXT share same bit-mask because they can't be set simultaneously.
504namespace SISrcMods {
505enum : unsigned {
506 NONE = 0,
507 NEG = 1 << 0, // Floating-point negate modifier
508 ABS = 1 << 1, // Floating-point absolute modifier
509 SEXT = 1 << 4, // Integer sign-extend modifier
510 NEG_HI = ABS, // Floating-point negate high packed component modifier.
511 OP_SEL_0 = 1 << 2,
512 OP_SEL_1 = 1 << 3,
513 DST_OP_SEL = 1 << 3 // VOP3 dst op_sel (share mask with OP_SEL_1)
514};
515}
516
517namespace SIOutMods {
518 enum : unsigned {
519 NONE = 0,
520 MUL2 = 1,
521 MUL4 = 2,
523 };
524}
525
526namespace AMDGPU {
527namespace VGPRIndexMode {
528
529enum Id : unsigned { // id of symbolic names
534
537};
538
548
549} // namespace VGPRIndexMode
550} // namespace AMDGPU
551
553 enum : unsigned {
555 VOP3 = 1,
556 SDWA = 2,
557 SDWA9 = 3,
558 DPP = 4,
560 };
561} // namespace AMDGPUAsmVariants
562
563namespace AMDGPU {
564namespace EncValues { // Encoding values of enum9/8/7 operands
565
566enum : unsigned {
581 VGPR_MIN = 256,
582 VGPR_MAX = 511,
583 IS_VGPR = 256, // Indicates VGPR or AGPR
584};
585
586} // namespace EncValues
587
588// Register codes as defined in the TableGen's HWEncoding field.
589namespace HWEncoding {
590enum : unsigned {
593 IS_VGPR = 1 << 10,
594 IS_AGPR = 1 << 11,
595 IS_HI16 = 1 << 12,
596};
597} // namespace HWEncoding
598
599namespace CPol {
600
601enum CPol {
602 GLC = 1,
603 SLC = 2,
604 DLC = 4,
605 SCC = 16,
611
612 // Below are GFX12+ cache policy bits
613
614 // Temporal hint
615 TH = 0x7, // All TH bits
616 TH_RT = 0, // regular
617 TH_NT = 1, // non-temporal
618 TH_HT = 2, // high-temporal
619 TH_LU = 3, // last use
620 TH_WB = 3, // regular (CU, SE), high-temporal with write-back (MALL)
621 TH_NT_RT = 4, // non-temporal (CU, SE), regular (MALL)
622 TH_RT_NT = 5, // regular (CU, SE), non-temporal (MALL)
623 TH_NT_HT = 6, // non-temporal (CU, SE), high-temporal (MALL)
624 TH_NT_WB = 7, // non-temporal (CU, SE), high-temporal with write-back (MALL)
625 TH_BYPASS = 3, // only to be used with scope = 3
626
627 TH_RESERVED = 7, // unused value for load insts
628
629 // Bits of TH for atomics
630 TH_ATOMIC_RETURN = GLC, // Returning vs non-returning
631 TH_ATOMIC_NT = SLC, // Non-temporal vs regular
632 TH_ATOMIC_CASCADE = 4, // Cascading vs regular
633
634 // Scope
637 SCOPE = SCOPE_MASK << SCOPE_SHIFT, // All Scope bits
642
643 NV = 1 << 5, // Non-volatile bit
644
645 SWZ = 1 << 6, // Swizzle bit
646
647 SCAL = 1 << 11, // Scale offset bit
648
649 ALL = TH | SCOPE | NV,
650
651 // Helper bits
652 TH_TYPE_LOAD = 1 << 7, // TH_LOAD policy
653 TH_TYPE_STORE = 1 << 8, // TH_STORE policy
654 TH_TYPE_ATOMIC = 1 << 9, // TH_ATOMIC policy
655 TH_REAL_BYPASS = 1 << 10, // is TH=3 bypass policy or not
656
657 // Volatile (used to preserve/signal operation volatility for buffer
658 // operations not a real instruction bit)
659 VOLATILE = 1 << 31,
660 // The set of "cache policy" bits used for compiler features that
661 // do not correspond to handware features.
663};
664
665} // namespace CPol
666
667namespace SendMsg { // Encoding of SIMM16 used in s_sendmsg* insns.
668
669enum Id { // Message ID, width(4) [3:0].
671
672 ID_GS_PreGFX11 = 2, // replaced in GFX11
673 ID_GS_DONE_PreGFX11 = 3, // replaced in GFX11
674
675 ID_HS_TESSFACTOR_GFX11Plus = 2, // reused in GFX11
676 ID_DEALLOC_VGPRS_GFX11Plus = 3, // reused in GFX11
677
678 ID_SAVEWAVE = 4, // added in GFX8, removed in GFX11
679 ID_STALL_WAVE_GEN = 5, // added in GFX9, removed in GFX12
680 ID_HALT_WAVES = 6, // added in GFX9, removed in GFX12
681 ID_ORDERED_PS_DONE = 7, // added in GFX9, removed in GFX11
682 ID_EARLY_PRIM_DEALLOC = 8, // added in GFX9, removed in GFX10
683 ID_GS_ALLOC_REQ = 9, // added in GFX9
684 ID_GET_DOORBELL = 10, // added in GFX9, removed in GFX11
685 ID_GET_DDID = 11, // added in GFX10, removed in GFX11
687
696
697 ID_RTN_GET_CLUSTER_BARRIER_STATE = 136, // added in GFX1250
698 ID_RTN_SAVE_WAVE_HAS_TDM = 152, // added in GFX1250
699
702};
703
704enum Op { // Both GS and SYS operation IDs.
707 // Bits used for operation encoding
709 OP_MASK_ = (((1 << OP_WIDTH_) - 1) << OP_SHIFT_),
710 // GS operations are encoded in bits 5:4
716 // SYS operations are encoded in bits 6:4
722};
723
733
734} // namespace SendMsg
735
736namespace WaitEvent { // Encoding of SIMM16 used in s_wait_event
737enum Id {
738 DONT_WAIT_EXPORT_READY = 1 << 0, // Only used in gfx11
739 EXPORT_READY = 1 << 1, // gfx12+
740};
741
742} // namespace WaitEvent
743
744namespace Hwreg { // Encoding of SIMM16 used in s_setreg/getreg* insns.
745
799
800enum Offset : unsigned { // Offset, (5) [10:6]
802 OFFSET_ME_ID = 8, // in HW_ID2
803};
804
806 FP_ROUND_MASK = 0xf << 0, // Bits 0..3
807 FP_DENORM_MASK = 0xf << 4, // Bits 4..7
810 LOD_CLAMP_MASK = 1 << 10,
811 DEBUG_MASK = 1 << 11,
812
813 // EXCP_EN fields.
821
823 VSKIP_MASK = 1 << 28,
824 CSP_MASK = 0x7u << 29, // Bits 29..31
825
826 // GFX1250
827 DST_VGPR_MSB = 0x3 << 12,
828 SRC0_VGPR_MSB = 0x3 << 14,
829 SRC1_VGPR_MSB = 0x3 << 16,
830 SRC2_VGPR_MSB = 0x3 << 18,
831 VGPR_MSB_MASK = 0xff << 12, // Bits 12..19
832
833 REPLAY_MODE = 1 << 25,
835};
836
837} // namespace Hwreg
838
908
909namespace UfmtGFX10 {
910enum UnifiedFormat : int64_t {
912
919
927
934
938
946
954
962
969
976
983
987
995
1002
1005};
1006
1007} // namespace UfmtGFX10
1008
1009namespace UfmtGFX11 {
1010enum UnifiedFormat : int64_t {
1012
1019
1027
1034
1038
1046
1048
1050
1055
1062
1069
1073
1081
1088
1091};
1092
1093} // namespace UfmtGFX11
1094
1095namespace Swizzle { // Encoding of swizzle macro used in ds_swizzle_b32.
1096
1106
1107// clang-format off
1108enum EncBits : unsigned {
1109
1110 // swizzle mode encodings
1111
1114
1117
1119
1122
1124 FFT_MODE_LO = 0xE000,
1125
1126 // QUAD_PERM encodings
1127
1132
1133 // BITMASK_PERM encodings
1134
1138
1142
1143 // FFT encodings
1144
1147
1148 // ROTATE encodings
1150 ROTATE_DIR_SHIFT = 10, // bit position of rotate direction
1152 ROTATE_SIZE_SHIFT = 5, // bit position of rotate size
1154};
1155// clang-format on
1156
1157} // namespace Swizzle
1158
1159namespace SDWA {
1160
1161enum SdwaSel : unsigned {
1169};
1170
1171enum DstUnused : unsigned {
1175};
1176
1191
1192} // namespace SDWA
1193
1194namespace DPP {
1195
1196// clang-format off
1241// clang-format on
1242
1249
1250} // namespace DPP
1251
1252namespace Exp {
1253
1254enum Target : unsigned {
1258 ET_NULL = 9, // Pre-GFX11
1261 ET_POS4 = 16, // GFX10+
1262 ET_POS_LAST = ET_POS4, // Highest pos used on any subtarget
1263 ET_PRIM = 20, // GFX10+
1264 ET_DUAL_SRC_BLEND0 = 21, // GFX11+
1265 ET_DUAL_SRC_BLEND1 = 22, // GFX11+
1266 ET_PARAM0 = 32, // Pre-GFX11
1267 ET_PARAM31 = 63, // Pre-GFX11
1268
1276
1278};
1279
1280} // namespace Exp
1281
1302
1303namespace VOP3PEncoding {
1304
1306 OP_SEL_HI_0 = UINT64_C(1) << 59,
1307 OP_SEL_HI_1 = UINT64_C(1) << 60,
1308 OP_SEL_HI_2 = UINT64_C(1) << 14,
1309};
1310
1311} // namespace VOP3PEncoding
1312
1313namespace ImplicitArg {
1314// Implicit kernel argument offset for code object version 5.
1327
1328} // namespace ImplicitArg
1329
1331// Enum value used in cbsz/blgp for F8F6F4 MFMA operations to select the matrix
1332// format.
1340} // namespace MFMAScaleFormats
1341
1342namespace VirtRegFlag {
1343// Virtual register flags used for various target specific handlings during
1344// codegen.
1346 // Register operand in a whole-wave mode operation.
1347 WWM_REG = 1 << 0,
1348};
1349
1350} // namespace VirtRegFlag
1351
1352} // namespace AMDGPU
1353
1354namespace AMDGPU {
1355namespace Barrier {
1356
1365
1366enum {
1368};
1369
1370} // namespace Barrier
1371} // namespace AMDGPU
1372
1373// clang-format off
1374
1375#define R_00B028_SPI_SHADER_PGM_RSRC1_PS 0x00B028
1376#define S_00B028_VGPRS(x) (((x) & 0x3F) << 0)
1377#define S_00B028_SGPRS(x) (((x) & 0x0F) << 6)
1378#define S_00B028_MEM_ORDERED(x) (((x) & 0x1) << 25)
1379#define G_00B028_MEM_ORDERED(x) (((x) >> 25) & 0x1)
1380#define C_00B028_MEM_ORDERED 0xFDFFFFFF
1381
1382#define R_00B02C_SPI_SHADER_PGM_RSRC2_PS 0x00B02C
1383#define S_00B02C_EXTRA_LDS_SIZE(x) (((x) & 0xFF) << 8)
1384#define R_00B128_SPI_SHADER_PGM_RSRC1_VS 0x00B128
1385#define S_00B128_MEM_ORDERED(x) (((x) & 0x1) << 27)
1386#define G_00B128_MEM_ORDERED(x) (((x) >> 27) & 0x1)
1387#define C_00B128_MEM_ORDERED 0xF7FFFFFF
1388
1389#define R_00B228_SPI_SHADER_PGM_RSRC1_GS 0x00B228
1390#define S_00B228_WGP_MODE(x) (((x) & 0x1) << 27)
1391#define G_00B228_WGP_MODE(x) (((x) >> 27) & 0x1)
1392#define C_00B228_WGP_MODE 0xF7FFFFFF
1393#define S_00B228_MEM_ORDERED(x) (((x) & 0x1) << 25)
1394#define G_00B228_MEM_ORDERED(x) (((x) >> 25) & 0x1)
1395#define C_00B228_MEM_ORDERED 0xFDFFFFFF
1396
1397#define R_00B328_SPI_SHADER_PGM_RSRC1_ES 0x00B328
1398#define R_00B428_SPI_SHADER_PGM_RSRC1_HS 0x00B428
1399#define S_00B428_WGP_MODE(x) (((x) & 0x1) << 26)
1400#define G_00B428_WGP_MODE(x) (((x) >> 26) & 0x1)
1401#define C_00B428_WGP_MODE 0xFBFFFFFF
1402#define S_00B428_MEM_ORDERED(x) (((x) & 0x1) << 24)
1403#define G_00B428_MEM_ORDERED(x) (((x) >> 24) & 0x1)
1404#define C_00B428_MEM_ORDERED 0xFEFFFFFF
1405
1406#define R_00B528_SPI_SHADER_PGM_RSRC1_LS 0x00B528
1407
1408#define R_00B84C_COMPUTE_PGM_RSRC2 0x00B84C
1409#define S_00B84C_SCRATCH_EN(x) (((x) & 0x1) << 0)
1410#define G_00B84C_SCRATCH_EN(x) (((x) >> 0) & 0x1)
1411#define C_00B84C_SCRATCH_EN 0xFFFFFFFE
1412#define S_00B84C_USER_SGPR(x) (((x) & 0x1F) << 1)
1413#define G_00B84C_USER_SGPR(x) (((x) >> 1) & 0x1F)
1414#define C_00B84C_USER_SGPR 0xFFFFFFC1
1415#define S_00B84C_TRAP_HANDLER(x) (((x) & 0x1) << 6)
1416#define G_00B84C_TRAP_HANDLER(x) (((x) >> 6) & 0x1)
1417#define C_00B84C_TRAP_HANDLER 0xFFFFFFBF
1418#define S_00B84C_TGID_X_EN(x) (((x) & 0x1) << 7)
1419#define G_00B84C_TGID_X_EN(x) (((x) >> 7) & 0x1)
1420#define C_00B84C_TGID_X_EN 0xFFFFFF7F
1421#define S_00B84C_TGID_Y_EN(x) (((x) & 0x1) << 8)
1422#define G_00B84C_TGID_Y_EN(x) (((x) >> 8) & 0x1)
1423#define C_00B84C_TGID_Y_EN 0xFFFFFEFF
1424#define S_00B84C_TGID_Z_EN(x) (((x) & 0x1) << 9)
1425#define G_00B84C_TGID_Z_EN(x) (((x) >> 9) & 0x1)
1426#define C_00B84C_TGID_Z_EN 0xFFFFFDFF
1427#define S_00B84C_TG_SIZE_EN(x) (((x) & 0x1) << 10)
1428#define G_00B84C_TG_SIZE_EN(x) (((x) >> 10) & 0x1)
1429#define C_00B84C_TG_SIZE_EN 0xFFFFFBFF
1430#define S_00B84C_TIDIG_COMP_CNT(x) (((x) & 0x03) << 11)
1431#define G_00B84C_TIDIG_COMP_CNT(x) (((x) >> 11) & 0x03)
1432#define C_00B84C_TIDIG_COMP_CNT 0xFFFFE7FF
1433/* CIK */
1434#define S_00B84C_EXCP_EN_MSB(x) (((x) & 0x03) << 13)
1435#define G_00B84C_EXCP_EN_MSB(x) (((x) >> 13) & 0x03)
1436#define C_00B84C_EXCP_EN_MSB 0xFFFF9FFF
1437/* */
1438#define S_00B84C_LDS_SIZE(x) (((x) & 0x1FF) << 15)
1439#define G_00B84C_LDS_SIZE(x) (((x) >> 15) & 0x1FF)
1440#define C_00B84C_LDS_SIZE 0xFF007FFF
1441#define S_00B84C_EXCP_EN(x) (((x) & 0x7F) << 24)
1442#define G_00B84C_EXCP_EN(x) (((x) >> 24) & 0x7F)
1443#define C_00B84C_EXCP_EN 0x80FFFFFF
1444
1445#define S_00B84C_USER_SGPR_GFX1250(x) (((x) & 0x3F) << 1)
1446#define G_00B84C_USER_SGPR_GFX1250(x) (((x) >> 1) & 0x3F)
1447#define C_00B84C_USER_SGPR_GFX1250 0xFFFFFF81
1448
1449#define R_0286CC_SPI_PS_INPUT_ENA 0x0286CC
1450#define R_0286D0_SPI_PS_INPUT_ADDR 0x0286D0
1451
1452#define R_00B848_COMPUTE_PGM_RSRC1 0x00B848
1453#define S_00B848_VGPRS(x) (((x) & 0x3F) << 0)
1454#define G_00B848_VGPRS(x) (((x) >> 0) & 0x3F)
1455#define C_00B848_VGPRS 0xFFFFFFC0
1456#define S_00B848_SGPRS(x) (((x) & 0x0F) << 6)
1457#define G_00B848_SGPRS(x) (((x) >> 6) & 0x0F)
1458#define C_00B848_SGPRS 0xFFFFFC3F
1459#define S_00B848_PRIORITY(x) (((x) & 0x03) << 10)
1460#define G_00B848_PRIORITY(x) (((x) >> 10) & 0x03)
1461#define C_00B848_PRIORITY 0xFFFFF3FF
1462#define S_00B848_FLOAT_MODE(x) (((x) & 0xFF) << 12)
1463#define G_00B848_FLOAT_MODE(x) (((x) >> 12) & 0xFF)
1464#define C_00B848_FLOAT_MODE 0xFFF00FFF
1465#define S_00B848_PRIV(x) (((x) & 0x1) << 20)
1466#define G_00B848_PRIV(x) (((x) >> 20) & 0x1)
1467#define C_00B848_PRIV 0xFFEFFFFF
1468#define S_00B848_DX10_CLAMP(x) (((x) & 0x1) << 21)
1469#define G_00B848_DX10_CLAMP(x) (((x) >> 21) & 0x1)
1470#define C_00B848_DX10_CLAMP 0xFFDFFFFF
1471#define S_00B848_RR_WG_MODE(x) (((x) & 0x1) << 21)
1472#define G_00B848_RR_WG_MODE(x) (((x) >> 21) & 0x1)
1473#define C_00B848_RR_WG_MODE 0xFFDFFFFF
1474#define S_00B848_DEBUG_MODE(x) (((x) & 0x1) << 22)
1475#define G_00B848_DEBUG_MODE(x) (((x) >> 22) & 0x1)
1476#define C_00B848_DEBUG_MODE 0xFFBFFFFF
1477#define S_00B848_IEEE_MODE(x) (((x) & 0x1) << 23)
1478#define G_00B848_IEEE_MODE(x) (((x) >> 23) & 0x1)
1479#define C_00B848_IEEE_MODE 0xFF7FFFFF
1480#define S_00B848_WGP_MODE(x) (((x) & 0x1) << 29)
1481#define G_00B848_WGP_MODE(x) (((x) >> 29) & 0x1)
1482#define C_00B848_WGP_MODE 0xDFFFFFFF
1483#define S_00B848_MEM_ORDERED(x) (((x) & 0x1) << 30)
1484#define G_00B848_MEM_ORDERED(x) (((x) >> 30) & 0x1)
1485#define C_00B848_MEM_ORDERED 0xBFFFFFFF
1486#define S_00B848_FWD_PROGRESS(x) (((x) & 0x1) << 31)
1487#define G_00B848_FWD_PROGRESS(x) (((x) >> 31) & 0x1)
1488#define C_00B848_FWD_PROGRESS 0x7FFFFFFF
1489
1490// Helpers for setting FLOAT_MODE
1491#define FP_ROUND_ROUND_TO_NEAREST 0
1492#define FP_ROUND_ROUND_TO_INF 1
1493#define FP_ROUND_ROUND_TO_NEGINF 2
1494#define FP_ROUND_ROUND_TO_ZERO 3
1495
1496// Bits 3:0 control rounding mode. 1:0 control single precision, 3:2 double
1497// precision.
1498#define FP_ROUND_MODE_SP(x) ((x) & 0x3)
1499#define FP_ROUND_MODE_DP(x) (((x) & 0x3) << 2)
1500
1501#define FP_DENORM_FLUSH_IN_FLUSH_OUT 0
1502#define FP_DENORM_FLUSH_OUT 1
1503#define FP_DENORM_FLUSH_IN 2
1504#define FP_DENORM_FLUSH_NONE 3
1505
1506
1507// Bits 7:4 control denormal handling. 5:4 control single precision, 6:7 double
1508// precision.
1509#define FP_DENORM_MODE_SP(x) (((x) & 0x3) << 4)
1510#define FP_DENORM_MODE_DP(x) (((x) & 0x3) << 6)
1511
1512#define R_00B860_COMPUTE_TMPRING_SIZE 0x00B860
1513#define S_00B860_WAVESIZE_PreGFX11(x) (((x) & 0x1FFF) << 12)
1514#define S_00B860_WAVESIZE_GFX11(x) (((x) & 0x7FFF) << 12)
1515#define S_00B860_WAVESIZE_GFX12Plus(x) (((x) & 0x3FFFF) << 12)
1516
1517#define R_0286E8_SPI_TMPRING_SIZE 0x0286E8
1518#define S_0286E8_WAVESIZE_PreGFX11(x) (((x) & 0x1FFF) << 12)
1519#define S_0286E8_WAVESIZE_GFX11(x) (((x) & 0x7FFF) << 12)
1520#define S_0286E8_WAVESIZE_GFX12Plus(x) (((x) & 0x3FFFF) << 12)
1521
1522#define R_028B54_VGT_SHADER_STAGES_EN 0x028B54
1523#define S_028B54_HS_W32_EN(x) (((x) & 0x1) << 21)
1524#define S_028B54_GS_W32_EN(x) (((x) & 0x1) << 22)
1525#define S_028B54_VS_W32_EN(x) (((x) & 0x1) << 23)
1526#define R_0286D8_SPI_PS_IN_CONTROL 0x0286D8
1527#define S_0286D8_PS_W32_EN(x) (((x) & 0x1) << 15)
1528#define R_00B800_COMPUTE_DISPATCH_INITIATOR 0x00B800
1529#define S_00B800_CS_W32_EN(x) (((x) & 0x1) << 15)
1530
1531#define R_SPILLED_SGPRS 0x4
1532#define R_SPILLED_VGPRS 0x8
1533
1534// clang-format on
1535
1536} // End namespace llvm
1537
1538#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:89
@ OPERAND_REG_IMM_V2FP64
Definition SIDefines.h:447
@ OPERAND_KIMM32
Operand with 32-bit immediate that uses the constant bus.
Definition SIDefines.h:465
@ OPERAND_REG_INLINE_C_LAST
Definition SIDefines.h:488
@ OPERAND_REG_IMM_INT64
Definition SIDefines.h:433
@ OPERAND_REG_IMM_V2FP16
Definition SIDefines.h:440
@ OPERAND_REG_INLINE_C_FP64
Definition SIDefines.h:456
@ OPERAND_REG_INLINE_C_BF16
Definition SIDefines.h:453
@ OPERAND_REG_IMM_FIRST
Definition SIDefines.h:484
@ OPERAND_REG_INLINE_C_V2BF16
Definition SIDefines.h:458
@ OPERAND_REG_IMM_V2INT64
Definition SIDefines.h:443
@ OPERAND_REG_IMM_V2INT16
Definition SIDefines.h:442
@ OPERAND_REG_IMM_BF16
Definition SIDefines.h:437
@ OPERAND_REG_IMM_INT32
Operands with register, 32-bit, or 64-bit immediate.
Definition SIDefines.h:432
@ OPERAND_REG_IMM_V2BF16
Definition SIDefines.h:439
@ OPERAND_REG_INLINE_AC_FIRST
Definition SIDefines.h:490
@ OPERAND_REG_IMM_FP16
Definition SIDefines.h:438
@ OPERAND_REG_IMM_V2FP16_SPLAT
Definition SIDefines.h:441
@ OPERAND_REG_INLINE_C_INT64
Definition SIDefines.h:452
@ OPERAND_REG_INLINE_C_INT16
Operands with register or inline constant.
Definition SIDefines.h:450
@ OPERAND_REG_IMM_NOINLINE_V2FP16
Definition SIDefines.h:444
@ OPERAND_REG_IMM_FP64
Definition SIDefines.h:436
@ OPERAND_REG_INLINE_C_V2FP16
Definition SIDefines.h:459
@ OPERAND_REG_INLINE_AC_INT32
Operands with an AccVGPR register or inline constant.
Definition SIDefines.h:470
@ OPERAND_REG_INLINE_AC_FP32
Definition SIDefines.h:471
@ OPERAND_REG_IMM_V2INT32
Definition SIDefines.h:445
@ OPERAND_SDWA_VOPC_DST
Definition SIDefines.h:482
@ OPERAND_REG_IMM_FP32
Definition SIDefines.h:435
@ OPERAND_REG_INLINE_C_FIRST
Definition SIDefines.h:487
@ OPERAND_REG_INLINE_C_FP32
Definition SIDefines.h:455
@ OPERAND_REG_INLINE_AC_LAST
Definition SIDefines.h:491
@ OPERAND_REG_IMM_LAST
Definition SIDefines.h:485
@ OPERAND_REG_INLINE_C_INT32
Definition SIDefines.h:451
@ OPERAND_REG_INLINE_C_V2INT16
Definition SIDefines.h:457
@ OPERAND_INLINE_C_AV64_PSEUDO
Definition SIDefines.h:476
@ OPERAND_REG_IMM_V2FP32
Definition SIDefines.h:446
@ OPERAND_REG_INLINE_AC_FP64
Definition SIDefines.h:472
@ OPERAND_REG_INLINE_C_FP16
Definition SIDefines.h:454
@ OPERAND_REG_IMM_INT16
Definition SIDefines.h:434
@ OPERAND_INLINE_SPLIT_BARRIER_INT32
Definition SIDefines.h:462
@ OPERAND_FIRST_TARGET
Definition MCInstrDesc.h:79
constexpr bool isAtomicRet(const T &...O)
Definition SIDefines.h:368
constexpr bool isVOPC(const T &...O)
Definition SIDefines.h:237
constexpr bool isVOP3(const T &...O)
Definition SIDefines.h:240
constexpr bool isScalarStore(const T &...O)
Definition SIDefines.h:314
constexpr bool hasVOP3OpSel(const T &...O)
Definition SIDefines.h:323
constexpr bool isVOP1(const T &...O)
Definition SIDefines.h:231
constexpr bool isFPAtomic(const T &...O)
Definition SIDefines.h:353
constexpr bool usesVM_CNT(const T &...O)
Definition SIDefines.h:389
constexpr bool usesTENSOR_CNT(const T &...O)
Definition SIDefines.h:311
constexpr bool isD16Buf(const T &...O)
Definition SIDefines.h:344
constexpr bool isMAI(const T &...O)
Definition SIDefines.h:356
constexpr bool isVOP2(const T &...O)
Definition SIDefines.h:234
constexpr bool isMaybeAtomic(const T &...O)
Definition SIDefines.h:326
constexpr bool isSWMMAC(const T &...O)
Definition SIDefines.h:383
constexpr bool isTRANS(const T &...O)
Definition SIDefines.h:259
constexpr bool isSOP2(const T &...O)
Definition SIDefines.h:219
constexpr bool isFLAT(const T &...O)
Definition SIDefines.h:287
constexpr bool isVOP3P(const T &...O)
Definition SIDefines.h:243
constexpr bool usesFPDPRounding(const T &...O)
Definition SIDefines.h:350
constexpr bool isDisableWQM(const T &...O)
Definition SIDefines.h:305
constexpr bool isBuffer(const T &...O)
Definition SIDefines.h:268
constexpr bool hasIntClamp(const T &...O)
Definition SIDefines.h:332
constexpr bool isAtomicNoRet(const T &...O)
Definition SIDefines.h:365
constexpr bool isMTBUF(const T &...O)
Definition SIDefines.h:265
constexpr bool isVIMAGE(const T &...O)
Definition SIDefines.h:278
constexpr bool isSMRD(const T &...O)
Definition SIDefines.h:272
constexpr bool isVOP3Like(const T &...O)
Definition SIDefines.h:246
constexpr bool isFlatScratch(const T &...O)
Definition SIDefines.h:362
constexpr bool isSpill(const T &...O)
Definition SIDefines.h:293
constexpr uint64_t getTSFlags(const MCInstrDesc &Desc)
Definition SIDefines.h:202
constexpr bool isMIMG(const T &...O)
Definition SIDefines.h:275
constexpr bool isVMEM(const T &...O)
Definition SIDefines.h:408
constexpr bool hasFPClamp(const T &...O)
Definition SIDefines.h:329
constexpr bool isNeverUniform(const T &...O)
Definition SIDefines.h:377
constexpr bool isImage(const T &...O)
Definition SIDefines.h:404
constexpr bool isWMMA(const T &...O)
Definition SIDefines.h:371
constexpr bool isVALU(const T &...O)
Definition SIDefines.h:213
constexpr bool isWQM(const T &...O)
Definition SIDefines.h:302
constexpr bool isVOPD3(const T &...O)
Definition SIDefines.h:386
constexpr bool hasClampLo(const T &...O)
Definition SIDefines.h:335
constexpr bool isGWS(const T &...O)
Definition SIDefines.h:380
constexpr bool isFlatGlobal(const T &...O)
Definition SIDefines.h:347
constexpr bool usesASYNC_CNT(const T &...O)
Definition SIDefines.h:320
constexpr bool isMUBUF(const T &...O)
Definition SIDefines.h:262
constexpr bool isSDWA(const T &...O)
Definition SIDefines.h:253
constexpr bool isTiedSourceNotRead(const T &...O)
Definition SIDefines.h:374
constexpr bool isEXP(const T &...O)
Definition SIDefines.h:284
constexpr bool usesLGKM_CNT(const T &...O)
Definition SIDefines.h:392
constexpr bool isSOPK(const T &...O)
Definition SIDefines.h:225
constexpr bool isSOPC(const T &...O)
Definition SIDefines.h:222
constexpr bool isSOPP(const T &...O)
Definition SIDefines.h:228
constexpr bool isDOT(const T &...O)
Definition SIDefines.h:359
constexpr bool isVINTRP(const T &...O)
Definition SIDefines.h:250
constexpr bool isVINTERP(const T &...O)
Definition SIDefines.h:299
constexpr bool isVSAMPLE(const T &...O)
Definition SIDefines.h:281
constexpr bool isDS(const T &...O)
Definition SIDefines.h:290
constexpr bool isAtomic(const T &...O)
Definition SIDefines.h:397
constexpr bool isLDSDIR(const T &...O)
Definition SIDefines.h:296
constexpr bool isSALU(const T &...O)
Definition SIDefines.h:210
constexpr bool isGather4(const T &...O)
Definition SIDefines.h:308
constexpr bool isPacked(const T &...O)
Definition SIDefines.h:341
constexpr bool hasClampHi(const T &...O)
Definition SIDefines.h:338
constexpr bool isDPP(const T &...O)
Definition SIDefines.h:256
constexpr bool isSOP1(const T &...O)
Definition SIDefines.h:216
constexpr bool isSegmentSpecificFLAT(const T &...O)
Definition SIDefines.h:400
constexpr bool isFixedSize(const T &...O)
Definition SIDefines.h:317
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