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
132 // Is a clamp on FP type.
133 FPClamp = UINT64_C(1) << 45,
134
135 // Is an integer clamp
136 IntClamp = UINT64_C(1) << 46,
137
138 // Clamps lo component of register.
139 ClampLo = UINT64_C(1) << 47,
140
141 // Clamps hi component of register.
142 // ClampLo and ClampHi set for packed clamp.
143 ClampHi = UINT64_C(1) << 48,
144
145 // Is a packed VOP3P instruction.
146 IsPacked = UINT64_C(1) << 49,
147
148 // Is a D16 buffer instruction.
149 D16Buf = UINT64_C(1) << 50,
150
151 // FLAT instruction accesses FLAT_GLBL segment.
152 FlatGlobal = UINT64_C(1) << 51,
153
154 // Uses floating point double precision rounding mode
155 FPDPRounding = UINT64_C(1) << 52,
156
157 // Instruction is FP atomic.
158 FPAtomic = UINT64_C(1) << 53,
159
160 // Is a MFMA instruction.
161 IsMAI = UINT64_C(1) << 54,
162
163 // Is a DOT instruction.
164 IsDOT = UINT64_C(1) << 55,
165
166 // FLAT instruction accesses FLAT_SCRATCH segment.
167 FlatScratch = UINT64_C(1) << 56,
168
169 // Atomic without return.
170 IsAtomicNoRet = UINT64_C(1) << 57,
171
172 // Atomic with return.
173 IsAtomicRet = UINT64_C(1) << 58,
174
175 // Is a WMMA instruction.
176 IsWMMA = UINT64_C(1) << 59,
177
178 // Whether tied sources will be read.
179 TiedSourceNotRead = UINT64_C(1) << 60,
180
181 // Is never uniform.
182 IsNeverUniform = UINT64_C(1) << 61,
183
184 // ds_gws_* instructions.
185 GWS = UINT64_C(1) << 62,
186
187 // Is a SWMMAC instruction.
188 IsSWMMAC = UINT64_C(1) << 63,
189};
190} // namespace DontUseRawTSFlags
191
192// Predicate functions over TSFlags — the single place where raw TSFlags bit
193// tests are written. All callers (SIInstrInfo methods, MC-layer code) go
194// through these so that bit-layout changes require updating only this file.
195//
196// getTSFlags is overloaded for MCInstrDesc, (MCInstrInfo, Opcode), and
197// (MCInstrInfo, MCInst) here; SIInstrInfo.h adds a MachineInstr overload in
198// namespace llvm so ADL finds it when predicates are instantiated with
199// MachineInstr.
200
201constexpr uint64_t getTSFlags(const MCInstrDesc &Desc) { return Desc.TSFlags; }
202inline uint64_t getTSFlags(const MCInstrInfo &MII, unsigned Opcode) {
203 return MII.get(Opcode).TSFlags;
204}
205inline uint64_t getTSFlags(const MCInstrInfo &MII, const MCInst &Inst) {
206 return MII.get(Inst.getOpcode()).TSFlags;
207}
208
209template <typename... T> constexpr bool isSALU(const T &...O) {
210 return getTSFlags(O...) & DontUseRawTSFlags::SALU;
211}
212template <typename... T> constexpr bool isVALU(const T &...O) {
213 return getTSFlags(O...) & DontUseRawTSFlags::VALU;
214}
215template <typename... T> constexpr bool isSOP1(const T &...O) {
216 return getTSFlags(O...) & DontUseRawTSFlags::SOP1;
217}
218template <typename... T> constexpr bool isSOP2(const T &...O) {
219 return getTSFlags(O...) & DontUseRawTSFlags::SOP2;
220}
221template <typename... T> constexpr bool isSOPC(const T &...O) {
222 return getTSFlags(O...) & DontUseRawTSFlags::SOPC;
223}
224template <typename... T> constexpr bool isSOPK(const T &...O) {
225 return getTSFlags(O...) & DontUseRawTSFlags::SOPK;
226}
227template <typename... T> constexpr bool isSOPP(const T &...O) {
228 return getTSFlags(O...) & DontUseRawTSFlags::SOPP;
229}
230template <typename... T> constexpr bool isVOP1(const T &...O) {
231 return getTSFlags(O...) & DontUseRawTSFlags::VOP1;
232}
233template <typename... T> constexpr bool isVOP2(const T &...O) {
234 return getTSFlags(O...) & DontUseRawTSFlags::VOP2;
235}
236template <typename... T> constexpr bool isVOPC(const T &...O) {
237 return getTSFlags(O...) & DontUseRawTSFlags::VOPC;
238}
239template <typename... T> constexpr bool isVOP3(const T &...O) {
240 return getTSFlags(O...) & DontUseRawTSFlags::VOP3;
241}
242template <typename... T> constexpr bool isVOP3P(const T &...O) {
244}
245template <typename... T> constexpr bool isVOP3Like(const T &...O) {
246 return getTSFlags(O...) &
248}
249template <typename... T> constexpr bool isVINTRP(const T &...O) {
251}
252template <typename... T> constexpr bool isSDWA(const T &...O) {
253 return getTSFlags(O...) & DontUseRawTSFlags::SDWA;
254}
255template <typename... T> constexpr bool isDPP(const T &...O) {
256 return getTSFlags(O...) & DontUseRawTSFlags::DPP;
257}
258template <typename... T> constexpr bool isTRANS(const T &...O) {
260}
261template <typename... T> constexpr bool isMUBUF(const T &...O) {
263}
264template <typename... T> constexpr bool isMTBUF(const T &...O) {
266}
267template <typename... T> constexpr bool isBuffer(const T &...O) {
268 return getTSFlags(O...) &
270}
271template <typename... T> constexpr bool isSMRD(const T &...O) {
272 return getTSFlags(O...) & DontUseRawTSFlags::SMRD;
273}
274template <typename... T> constexpr bool isMIMG(const T &...O) {
275 return getTSFlags(O...) & DontUseRawTSFlags::MIMG;
276}
277template <typename... T> constexpr bool isVIMAGE(const T &...O) {
279}
280template <typename... T> constexpr bool isVSAMPLE(const T &...O) {
282}
283template <typename... T> constexpr bool isEXP(const T &...O) {
284 return getTSFlags(O...) & DontUseRawTSFlags::EXP;
285}
286template <typename... T> constexpr bool isFLAT(const T &...O) {
287 return getTSFlags(O...) & DontUseRawTSFlags::FLAT;
288}
289template <typename... T> constexpr bool isDS(const T &...O) {
290 return getTSFlags(O...) & DontUseRawTSFlags::DS;
291}
292template <typename... T> constexpr bool isSpill(const T &...O) {
294}
295template <typename... T> constexpr bool isLDSDIR(const T &...O) {
297}
298template <typename... T> constexpr bool isVINTERP(const T &...O) {
300}
301template <typename... T> constexpr bool isWQM(const T &...O) {
302 return getTSFlags(O...) & DontUseRawTSFlags::WQM;
303}
304template <typename... T> constexpr bool isDisableWQM(const T &...O) {
306}
307template <typename... T> constexpr bool isGather4(const T &...O) {
309}
310template <typename... T> constexpr bool usesTENSOR_CNT(const T &...O) {
312}
313template <typename... T> constexpr bool isScalarStore(const T &...O) {
315}
316template <typename... T> constexpr bool isFixedSize(const T &...O) {
318}
319template <typename... T> constexpr bool usesASYNC_CNT(const T &...O) {
321}
322template <typename... T> constexpr bool hasVOP3OpSel(const T &...O) {
324}
325template <typename... T> constexpr bool isMaybeAtomic(const T &...O) {
327}
328template <typename... T> constexpr bool hasFPClamp(const T &...O) {
330}
331template <typename... T> constexpr bool hasIntClamp(const T &...O) {
333}
334template <typename... T> constexpr bool hasClampLo(const T &...O) {
336}
337template <typename... T> constexpr bool hasClampHi(const T &...O) {
339}
340template <typename... T> constexpr bool isPacked(const T &...O) {
342}
343template <typename... T> constexpr bool isD16Buf(const T &...O) {
345}
346template <typename... T> constexpr bool isFlatGlobal(const T &...O) {
348}
349template <typename... T> constexpr bool usesFPDPRounding(const T &...O) {
351}
352template <typename... T> constexpr bool isFPAtomic(const T &...O) {
354}
355template <typename... T> constexpr bool isMAI(const T &...O) {
357}
358template <typename... T> constexpr bool isDOT(const T &...O) {
360}
361template <typename... T> constexpr bool isFlatScratch(const T &...O) {
363}
364template <typename... T> constexpr bool isAtomicNoRet(const T &...O) {
366}
367template <typename... T> constexpr bool isAtomicRet(const T &...O) {
369}
370template <typename... T> constexpr bool isWMMA(const T &...O) {
372}
373template <typename... T> constexpr bool isTiedSourceNotRead(const T &...O) {
375}
376template <typename... T> constexpr bool isNeverUniform(const T &...O) {
378}
379template <typename... T> constexpr bool isGWS(const T &...O) {
380 return getTSFlags(O...) & DontUseRawTSFlags::GWS;
381}
382template <typename... T> constexpr bool isSWMMAC(const T &...O) {
384}
385template <typename... T> constexpr bool isVOPD3(const T &...O) {
387}
388template <typename... T> constexpr bool usesVM_CNT(const T &...O) {
390}
391template <typename... T> constexpr bool usesLGKM_CNT(const T &...O) {
393}
394
395// Compound predicates.
396template <typename... T> constexpr bool isAtomic(const T &...O) {
397 return isAtomicNoRet(O...) || isAtomicRet(O...);
398}
399template <typename... T> constexpr bool isSegmentSpecificFLAT(const T &...O) {
400 return isFlatGlobal(O...) || isFlatScratch(O...);
401}
402// Any image-family instruction: pre-gfx11 MIMG, gfx11+ VIMAGE or VSAMPLE.
403template <typename... T> constexpr bool isImage(const T &...O) {
404 return isMIMG(O...) || isVIMAGE(O...) || isVSAMPLE(O...);
405}
406// Vector memory: buffer + image + flat.
407template <typename... T> constexpr bool isVMEM(const T &...O) {
408 return isMUBUF(O...) || isMTBUF(O...) || isImage(O...) || isFLAT(O...);
409}
410
411// v_cmp_class_* etc. use a 10-bit mask for what operation is checked.
412// The result is true if any of these tests are true.
413enum ClassFlags : unsigned {
414 S_NAN = 1 << 0, // Signaling NaN
415 Q_NAN = 1 << 1, // Quiet NaN
416 N_INFINITY = 1 << 2, // Negative infinity
417 N_NORMAL = 1 << 3, // Negative normal
418 N_SUBNORMAL = 1 << 4, // Negative subnormal
419 N_ZERO = 1 << 5, // Negative zero
420 P_ZERO = 1 << 6, // Positive zero
421 P_SUBNORMAL = 1 << 7, // Positive subnormal
422 P_NORMAL = 1 << 8, // Positive normal
423 P_INFINITY = 1 << 9 // Positive infinity
424};
425}
426
427namespace AMDGPU {
428
429enum OperandType : unsigned {
430 /// Operands with register, 32-bit, or 64-bit immediate
447
448 /// Operands with register or inline constant
459
460 // Operand for split barrier inline constant
462
463 /// Operand with 32-bit immediate that uses the constant bus.
467
468 /// Operands with an AccVGPR register or inline constant
472
473 // Operand for AV_MOV_B64_IMM_PSEUDO, which is a pair of 32-bit inline
474 // constants. Does not accept registers.
476
477 // Operand for source modifiers for VOP instructions
479
480 // Operand for SDWA instructions
482
485
488
491
494
497
498};
499}
500
501// Input operand modifiers bit-masks
502// NEG and SEXT share same bit-mask because they can't be set simultaneously.
503namespace SISrcMods {
504enum : unsigned {
505 NONE = 0,
506 NEG = 1 << 0, // Floating-point negate modifier
507 ABS = 1 << 1, // Floating-point absolute modifier
508 SEXT = 1 << 4, // Integer sign-extend modifier
509 NEG_HI = ABS, // Floating-point negate high packed component modifier.
510 OP_SEL_0 = 1 << 2,
511 OP_SEL_1 = 1 << 3,
512 DST_OP_SEL = 1 << 3 // VOP3 dst op_sel (share mask with OP_SEL_1)
513};
514}
515
516namespace SIOutMods {
517 enum : unsigned {
518 NONE = 0,
519 MUL2 = 1,
520 MUL4 = 2,
522 };
523}
524
525namespace AMDGPU {
526namespace VGPRIndexMode {
527
528enum Id : unsigned { // id of symbolic names
533
536};
537
547
548} // namespace VGPRIndexMode
549} // namespace AMDGPU
550
552 enum : unsigned {
554 VOP3 = 1,
555 SDWA = 2,
556 SDWA9 = 3,
557 DPP = 4,
559 };
560} // namespace AMDGPUAsmVariants
561
562namespace AMDGPU {
563namespace EncValues { // Encoding values of enum9/8/7 operands
564
565enum : unsigned {
580 VGPR_MIN = 256,
581 VGPR_MAX = 511,
582 IS_VGPR = 256, // Indicates VGPR or AGPR
583};
584
585} // namespace EncValues
586
587// Register codes as defined in the TableGen's HWEncoding field.
588namespace HWEncoding {
589enum : unsigned {
592 IS_VGPR = 1 << 10,
593 IS_AGPR = 1 << 11,
594 IS_HI16 = 1 << 12,
595};
596} // namespace HWEncoding
597
598namespace CPol {
599
600enum CPol {
601 GLC = 1,
602 SLC = 2,
603 DLC = 4,
604 SCC = 16,
610
611 // Below are GFX12+ cache policy bits
612
613 // Temporal hint
614 TH = 0x7, // All TH bits
615 TH_RT = 0, // regular
616 TH_NT = 1, // non-temporal
617 TH_HT = 2, // high-temporal
618 TH_LU = 3, // last use
619 TH_WB = 3, // regular (CU, SE), high-temporal with write-back (MALL)
620 TH_NT_RT = 4, // non-temporal (CU, SE), regular (MALL)
621 TH_RT_NT = 5, // regular (CU, SE), non-temporal (MALL)
622 TH_NT_HT = 6, // non-temporal (CU, SE), high-temporal (MALL)
623 TH_NT_WB = 7, // non-temporal (CU, SE), high-temporal with write-back (MALL)
624 TH_BYPASS = 3, // only to be used with scope = 3
625
626 TH_RESERVED = 7, // unused value for load insts
627
628 // Bits of TH for atomics
629 TH_ATOMIC_RETURN = GLC, // Returning vs non-returning
630 TH_ATOMIC_NT = SLC, // Non-temporal vs regular
631 TH_ATOMIC_CASCADE = 4, // Cascading vs regular
632
633 // Scope
636 SCOPE = SCOPE_MASK << SCOPE_SHIFT, // All Scope bits
641
642 NV = 1 << 5, // Non-volatile bit
643
644 SWZ = 1 << 6, // Swizzle bit
645
646 SCAL = 1 << 11, // Scale offset bit
647
648 ALL = TH | SCOPE | NV,
649
650 // Helper bits
651 TH_TYPE_LOAD = 1 << 7, // TH_LOAD policy
652 TH_TYPE_STORE = 1 << 8, // TH_STORE policy
653 TH_TYPE_ATOMIC = 1 << 9, // TH_ATOMIC policy
654 TH_REAL_BYPASS = 1 << 10, // is TH=3 bypass policy or not
655
656 // Volatile (used to preserve/signal operation volatility for buffer
657 // operations not a real instruction bit)
658 VOLATILE = 1 << 31,
659 // The set of "cache policy" bits used for compiler features that
660 // do not correspond to handware features.
662};
663
664} // namespace CPol
665
666namespace SendMsg { // Encoding of SIMM16 used in s_sendmsg* insns.
667
668enum Id { // Message ID, width(4) [3:0].
670
671 ID_GS_PreGFX11 = 2, // replaced in GFX11
672 ID_GS_DONE_PreGFX11 = 3, // replaced in GFX11
673
674 ID_HS_TESSFACTOR_GFX11Plus = 2, // reused in GFX11
675 ID_DEALLOC_VGPRS_GFX11Plus = 3, // reused in GFX11
676
677 ID_SAVEWAVE = 4, // added in GFX8, removed in GFX11
678 ID_STALL_WAVE_GEN = 5, // added in GFX9, removed in GFX12
679 ID_HALT_WAVES = 6, // added in GFX9, removed in GFX12
680 ID_ORDERED_PS_DONE = 7, // added in GFX9, removed in GFX11
681 ID_EARLY_PRIM_DEALLOC = 8, // added in GFX9, removed in GFX10
682 ID_GS_ALLOC_REQ = 9, // added in GFX9
683 ID_GET_DOORBELL = 10, // added in GFX9, removed in GFX11
684 ID_GET_DDID = 11, // added in GFX10, removed in GFX11
686
695
696 ID_RTN_GET_CLUSTER_BARRIER_STATE = 136, // added in GFX1250
697 ID_RTN_SAVE_WAVE_HAS_TDM = 152, // added in GFX1250
698
701};
702
703enum Op { // Both GS and SYS operation IDs.
706 // Bits used for operation encoding
708 OP_MASK_ = (((1 << OP_WIDTH_) - 1) << OP_SHIFT_),
709 // GS operations are encoded in bits 5:4
715 // SYS operations are encoded in bits 6:4
721};
722
732
733} // namespace SendMsg
734
735namespace WaitEvent { // Encoding of SIMM16 used in s_wait_event
736enum Id {
737 DONT_WAIT_EXPORT_READY = 1 << 0, // Only used in gfx11
738 EXPORT_READY = 1 << 1, // gfx12+
739};
740
741} // namespace WaitEvent
742
743namespace Hwreg { // Encoding of SIMM16 used in s_setreg/getreg* insns.
744
798
799enum Offset : unsigned { // Offset, (5) [10:6]
801 OFFSET_ME_ID = 8, // in HW_ID2
802};
803
805 FP_ROUND_MASK = 0xf << 0, // Bits 0..3
806 FP_DENORM_MASK = 0xf << 4, // Bits 4..7
809 LOD_CLAMP_MASK = 1 << 10,
810 DEBUG_MASK = 1 << 11,
811
812 // EXCP_EN fields.
820
822 VSKIP_MASK = 1 << 28,
823 CSP_MASK = 0x7u << 29, // Bits 29..31
824
825 // GFX1250
826 DST_VGPR_MSB = 0x3 << 12,
827 SRC0_VGPR_MSB = 0x3 << 14,
828 SRC1_VGPR_MSB = 0x3 << 16,
829 SRC2_VGPR_MSB = 0x3 << 18,
830 VGPR_MSB_MASK = 0xff << 12, // Bits 12..19
831
832 REPLAY_MODE = 1 << 25,
834};
835
836} // namespace Hwreg
837
907
908namespace UfmtGFX10 {
909enum UnifiedFormat : int64_t {
911
918
926
933
937
945
953
961
968
975
982
986
994
1001
1004};
1005
1006} // namespace UfmtGFX10
1007
1008namespace UfmtGFX11 {
1009enum UnifiedFormat : int64_t {
1011
1018
1026
1033
1037
1045
1047
1049
1054
1061
1068
1072
1080
1087
1090};
1091
1092} // namespace UfmtGFX11
1093
1094namespace Swizzle { // Encoding of swizzle macro used in ds_swizzle_b32.
1095
1105
1106// clang-format off
1107enum EncBits : unsigned {
1108
1109 // swizzle mode encodings
1110
1113
1116
1118
1121
1123 FFT_MODE_LO = 0xE000,
1124
1125 // QUAD_PERM encodings
1126
1131
1132 // BITMASK_PERM encodings
1133
1137
1141
1142 // FFT encodings
1143
1146
1147 // ROTATE encodings
1149 ROTATE_DIR_SHIFT = 10, // bit position of rotate direction
1151 ROTATE_SIZE_SHIFT = 5, // bit position of rotate size
1153};
1154// clang-format on
1155
1156} // namespace Swizzle
1157
1158namespace SDWA {
1159
1160enum SdwaSel : unsigned {
1168};
1169
1170enum DstUnused : unsigned {
1174};
1175
1190
1191} // namespace SDWA
1192
1193namespace DPP {
1194
1195// clang-format off
1240// clang-format on
1241
1248
1249} // namespace DPP
1250
1251namespace Exp {
1252
1253enum Target : unsigned {
1257 ET_NULL = 9, // Pre-GFX11
1260 ET_POS4 = 16, // GFX10+
1261 ET_POS_LAST = ET_POS4, // Highest pos used on any subtarget
1262 ET_PRIM = 20, // GFX10+
1263 ET_DUAL_SRC_BLEND0 = 21, // GFX11+
1264 ET_DUAL_SRC_BLEND1 = 22, // GFX11+
1265 ET_PARAM0 = 32, // Pre-GFX11
1266 ET_PARAM31 = 63, // Pre-GFX11
1267
1275
1277};
1278
1279} // namespace Exp
1280
1301
1302namespace VOP3PEncoding {
1303
1305 OP_SEL_HI_0 = UINT64_C(1) << 59,
1306 OP_SEL_HI_1 = UINT64_C(1) << 60,
1307 OP_SEL_HI_2 = UINT64_C(1) << 14,
1308};
1309
1310} // namespace VOP3PEncoding
1311
1312namespace ImplicitArg {
1313// Implicit kernel argument offset for code object version 5.
1326
1327} // namespace ImplicitArg
1328
1330// Enum value used in cbsz/blgp for F8F6F4 MFMA operations to select the matrix
1331// format.
1339} // namespace MFMAScaleFormats
1340
1341namespace VirtRegFlag {
1342// Virtual register flags used for various target specific handlings during
1343// codegen.
1345 // Register operand in a whole-wave mode operation.
1346 WWM_REG = 1 << 0,
1347};
1348
1349} // namespace VirtRegFlag
1350
1351} // namespace AMDGPU
1352
1353namespace AMDGPU {
1354namespace Barrier {
1355
1364
1365enum {
1367};
1368
1369} // namespace Barrier
1370} // namespace AMDGPU
1371
1372// clang-format off
1373
1374#define R_00B028_SPI_SHADER_PGM_RSRC1_PS 0x00B028
1375#define S_00B028_VGPRS(x) (((x) & 0x3F) << 0)
1376#define S_00B028_SGPRS(x) (((x) & 0x0F) << 6)
1377#define S_00B028_MEM_ORDERED(x) (((x) & 0x1) << 25)
1378#define G_00B028_MEM_ORDERED(x) (((x) >> 25) & 0x1)
1379#define C_00B028_MEM_ORDERED 0xFDFFFFFF
1380
1381#define R_00B02C_SPI_SHADER_PGM_RSRC2_PS 0x00B02C
1382#define S_00B02C_EXTRA_LDS_SIZE(x) (((x) & 0xFF) << 8)
1383#define R_00B128_SPI_SHADER_PGM_RSRC1_VS 0x00B128
1384#define S_00B128_MEM_ORDERED(x) (((x) & 0x1) << 27)
1385#define G_00B128_MEM_ORDERED(x) (((x) >> 27) & 0x1)
1386#define C_00B128_MEM_ORDERED 0xF7FFFFFF
1387
1388#define R_00B228_SPI_SHADER_PGM_RSRC1_GS 0x00B228
1389#define S_00B228_WGP_MODE(x) (((x) & 0x1) << 27)
1390#define G_00B228_WGP_MODE(x) (((x) >> 27) & 0x1)
1391#define C_00B228_WGP_MODE 0xF7FFFFFF
1392#define S_00B228_MEM_ORDERED(x) (((x) & 0x1) << 25)
1393#define G_00B228_MEM_ORDERED(x) (((x) >> 25) & 0x1)
1394#define C_00B228_MEM_ORDERED 0xFDFFFFFF
1395
1396#define R_00B328_SPI_SHADER_PGM_RSRC1_ES 0x00B328
1397#define R_00B428_SPI_SHADER_PGM_RSRC1_HS 0x00B428
1398#define S_00B428_WGP_MODE(x) (((x) & 0x1) << 26)
1399#define G_00B428_WGP_MODE(x) (((x) >> 26) & 0x1)
1400#define C_00B428_WGP_MODE 0xFBFFFFFF
1401#define S_00B428_MEM_ORDERED(x) (((x) & 0x1) << 24)
1402#define G_00B428_MEM_ORDERED(x) (((x) >> 24) & 0x1)
1403#define C_00B428_MEM_ORDERED 0xFEFFFFFF
1404
1405#define R_00B528_SPI_SHADER_PGM_RSRC1_LS 0x00B528
1406
1407#define R_00B84C_COMPUTE_PGM_RSRC2 0x00B84C
1408#define S_00B84C_SCRATCH_EN(x) (((x) & 0x1) << 0)
1409#define G_00B84C_SCRATCH_EN(x) (((x) >> 0) & 0x1)
1410#define C_00B84C_SCRATCH_EN 0xFFFFFFFE
1411#define S_00B84C_USER_SGPR(x) (((x) & 0x1F) << 1)
1412#define G_00B84C_USER_SGPR(x) (((x) >> 1) & 0x1F)
1413#define C_00B84C_USER_SGPR 0xFFFFFFC1
1414#define S_00B84C_TRAP_HANDLER(x) (((x) & 0x1) << 6)
1415#define G_00B84C_TRAP_HANDLER(x) (((x) >> 6) & 0x1)
1416#define C_00B84C_TRAP_HANDLER 0xFFFFFFBF
1417#define S_00B84C_TGID_X_EN(x) (((x) & 0x1) << 7)
1418#define G_00B84C_TGID_X_EN(x) (((x) >> 7) & 0x1)
1419#define C_00B84C_TGID_X_EN 0xFFFFFF7F
1420#define S_00B84C_TGID_Y_EN(x) (((x) & 0x1) << 8)
1421#define G_00B84C_TGID_Y_EN(x) (((x) >> 8) & 0x1)
1422#define C_00B84C_TGID_Y_EN 0xFFFFFEFF
1423#define S_00B84C_TGID_Z_EN(x) (((x) & 0x1) << 9)
1424#define G_00B84C_TGID_Z_EN(x) (((x) >> 9) & 0x1)
1425#define C_00B84C_TGID_Z_EN 0xFFFFFDFF
1426#define S_00B84C_TG_SIZE_EN(x) (((x) & 0x1) << 10)
1427#define G_00B84C_TG_SIZE_EN(x) (((x) >> 10) & 0x1)
1428#define C_00B84C_TG_SIZE_EN 0xFFFFFBFF
1429#define S_00B84C_TIDIG_COMP_CNT(x) (((x) & 0x03) << 11)
1430#define G_00B84C_TIDIG_COMP_CNT(x) (((x) >> 11) & 0x03)
1431#define C_00B84C_TIDIG_COMP_CNT 0xFFFFE7FF
1432/* CIK */
1433#define S_00B84C_EXCP_EN_MSB(x) (((x) & 0x03) << 13)
1434#define G_00B84C_EXCP_EN_MSB(x) (((x) >> 13) & 0x03)
1435#define C_00B84C_EXCP_EN_MSB 0xFFFF9FFF
1436/* */
1437#define S_00B84C_LDS_SIZE(x) (((x) & 0x1FF) << 15)
1438#define G_00B84C_LDS_SIZE(x) (((x) >> 15) & 0x1FF)
1439#define C_00B84C_LDS_SIZE 0xFF007FFF
1440#define S_00B84C_EXCP_EN(x) (((x) & 0x7F) << 24)
1441#define G_00B84C_EXCP_EN(x) (((x) >> 24) & 0x7F)
1442#define C_00B84C_EXCP_EN 0x80FFFFFF
1443
1444#define S_00B84C_USER_SGPR_GFX1250(x) (((x) & 0x3F) << 1)
1445#define G_00B84C_USER_SGPR_GFX1250(x) (((x) >> 1) & 0x3F)
1446#define C_00B84C_USER_SGPR_GFX1250 0xFFFFFF81
1447
1448#define R_0286CC_SPI_PS_INPUT_ENA 0x0286CC
1449#define R_0286D0_SPI_PS_INPUT_ADDR 0x0286D0
1450
1451#define R_00B848_COMPUTE_PGM_RSRC1 0x00B848
1452#define S_00B848_VGPRS(x) (((x) & 0x3F) << 0)
1453#define G_00B848_VGPRS(x) (((x) >> 0) & 0x3F)
1454#define C_00B848_VGPRS 0xFFFFFFC0
1455#define S_00B848_SGPRS(x) (((x) & 0x0F) << 6)
1456#define G_00B848_SGPRS(x) (((x) >> 6) & 0x0F)
1457#define C_00B848_SGPRS 0xFFFFFC3F
1458#define S_00B848_PRIORITY(x) (((x) & 0x03) << 10)
1459#define G_00B848_PRIORITY(x) (((x) >> 10) & 0x03)
1460#define C_00B848_PRIORITY 0xFFFFF3FF
1461#define S_00B848_FLOAT_MODE(x) (((x) & 0xFF) << 12)
1462#define G_00B848_FLOAT_MODE(x) (((x) >> 12) & 0xFF)
1463#define C_00B848_FLOAT_MODE 0xFFF00FFF
1464#define S_00B848_PRIV(x) (((x) & 0x1) << 20)
1465#define G_00B848_PRIV(x) (((x) >> 20) & 0x1)
1466#define C_00B848_PRIV 0xFFEFFFFF
1467#define S_00B848_DX10_CLAMP(x) (((x) & 0x1) << 21)
1468#define G_00B848_DX10_CLAMP(x) (((x) >> 21) & 0x1)
1469#define C_00B848_DX10_CLAMP 0xFFDFFFFF
1470#define S_00B848_RR_WG_MODE(x) (((x) & 0x1) << 21)
1471#define G_00B848_RR_WG_MODE(x) (((x) >> 21) & 0x1)
1472#define C_00B848_RR_WG_MODE 0xFFDFFFFF
1473#define S_00B848_DEBUG_MODE(x) (((x) & 0x1) << 22)
1474#define G_00B848_DEBUG_MODE(x) (((x) >> 22) & 0x1)
1475#define C_00B848_DEBUG_MODE 0xFFBFFFFF
1476#define S_00B848_IEEE_MODE(x) (((x) & 0x1) << 23)
1477#define G_00B848_IEEE_MODE(x) (((x) >> 23) & 0x1)
1478#define C_00B848_IEEE_MODE 0xFF7FFFFF
1479#define S_00B848_WGP_MODE(x) (((x) & 0x1) << 29)
1480#define G_00B848_WGP_MODE(x) (((x) >> 29) & 0x1)
1481#define C_00B848_WGP_MODE 0xDFFFFFFF
1482#define S_00B848_MEM_ORDERED(x) (((x) & 0x1) << 30)
1483#define G_00B848_MEM_ORDERED(x) (((x) >> 30) & 0x1)
1484#define C_00B848_MEM_ORDERED 0xBFFFFFFF
1485#define S_00B848_FWD_PROGRESS(x) (((x) & 0x1) << 31)
1486#define G_00B848_FWD_PROGRESS(x) (((x) >> 31) & 0x1)
1487#define C_00B848_FWD_PROGRESS 0x7FFFFFFF
1488
1489// Helpers for setting FLOAT_MODE
1490#define FP_ROUND_ROUND_TO_NEAREST 0
1491#define FP_ROUND_ROUND_TO_INF 1
1492#define FP_ROUND_ROUND_TO_NEGINF 2
1493#define FP_ROUND_ROUND_TO_ZERO 3
1494
1495// Bits 3:0 control rounding mode. 1:0 control single precision, 3:2 double
1496// precision.
1497#define FP_ROUND_MODE_SP(x) ((x) & 0x3)
1498#define FP_ROUND_MODE_DP(x) (((x) & 0x3) << 2)
1499
1500#define FP_DENORM_FLUSH_IN_FLUSH_OUT 0
1501#define FP_DENORM_FLUSH_OUT 1
1502#define FP_DENORM_FLUSH_IN 2
1503#define FP_DENORM_FLUSH_NONE 3
1504
1505
1506// Bits 7:4 control denormal handling. 5:4 control single precision, 6:7 double
1507// precision.
1508#define FP_DENORM_MODE_SP(x) (((x) & 0x3) << 4)
1509#define FP_DENORM_MODE_DP(x) (((x) & 0x3) << 6)
1510
1511#define R_00B860_COMPUTE_TMPRING_SIZE 0x00B860
1512#define S_00B860_WAVESIZE_PreGFX11(x) (((x) & 0x1FFF) << 12)
1513#define S_00B860_WAVESIZE_GFX11(x) (((x) & 0x7FFF) << 12)
1514#define S_00B860_WAVESIZE_GFX12Plus(x) (((x) & 0x3FFFF) << 12)
1515
1516#define R_0286E8_SPI_TMPRING_SIZE 0x0286E8
1517#define S_0286E8_WAVESIZE_PreGFX11(x) (((x) & 0x1FFF) << 12)
1518#define S_0286E8_WAVESIZE_GFX11(x) (((x) & 0x7FFF) << 12)
1519#define S_0286E8_WAVESIZE_GFX12Plus(x) (((x) & 0x3FFFF) << 12)
1520
1521#define R_028B54_VGT_SHADER_STAGES_EN 0x028B54
1522#define S_028B54_HS_W32_EN(x) (((x) & 0x1) << 21)
1523#define S_028B54_GS_W32_EN(x) (((x) & 0x1) << 22)
1524#define S_028B54_VS_W32_EN(x) (((x) & 0x1) << 23)
1525#define R_0286D8_SPI_PS_IN_CONTROL 0x0286D8
1526#define S_0286D8_PS_W32_EN(x) (((x) & 0x1) << 15)
1527#define R_00B800_COMPUTE_DISPATCH_INITIATOR 0x00B800
1528#define S_00B800_CS_W32_EN(x) (((x) & 0x1) << 15)
1529
1530#define R_SPILLED_SGPRS 0x4
1531#define R_SPILLED_VGPRS 0x8
1532
1533// clang-format on
1534
1535} // End namespace llvm
1536
1537#endif
AMDGPU address space definition.
unsigned uint64_t
#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:446
@ OPERAND_KIMM32
Operand with 32-bit immediate that uses the constant bus.
Definition SIDefines.h:464
@ OPERAND_REG_INLINE_C_LAST
Definition SIDefines.h:487
@ OPERAND_REG_IMM_INT64
Definition SIDefines.h:432
@ OPERAND_REG_IMM_V2FP16
Definition SIDefines.h:439
@ OPERAND_REG_INLINE_C_FP64
Definition SIDefines.h:455
@ OPERAND_REG_INLINE_C_BF16
Definition SIDefines.h:452
@ OPERAND_REG_IMM_FIRST
Definition SIDefines.h:483
@ OPERAND_REG_INLINE_C_V2BF16
Definition SIDefines.h:457
@ OPERAND_REG_IMM_V2INT64
Definition SIDefines.h:442
@ OPERAND_REG_IMM_V2INT16
Definition SIDefines.h:441
@ OPERAND_REG_IMM_BF16
Definition SIDefines.h:436
@ OPERAND_REG_IMM_INT32
Operands with register, 32-bit, or 64-bit immediate.
Definition SIDefines.h:431
@ OPERAND_REG_IMM_V2BF16
Definition SIDefines.h:438
@ OPERAND_REG_INLINE_AC_FIRST
Definition SIDefines.h:489
@ OPERAND_REG_IMM_FP16
Definition SIDefines.h:437
@ OPERAND_REG_IMM_V2FP16_SPLAT
Definition SIDefines.h:440
@ OPERAND_REG_INLINE_C_INT64
Definition SIDefines.h:451
@ OPERAND_REG_INLINE_C_INT16
Operands with register or inline constant.
Definition SIDefines.h:449
@ OPERAND_REG_IMM_NOINLINE_V2FP16
Definition SIDefines.h:443
@ OPERAND_REG_IMM_FP64
Definition SIDefines.h:435
@ OPERAND_REG_INLINE_C_V2FP16
Definition SIDefines.h:458
@ OPERAND_REG_INLINE_AC_INT32
Operands with an AccVGPR register or inline constant.
Definition SIDefines.h:469
@ OPERAND_REG_INLINE_AC_FP32
Definition SIDefines.h:470
@ OPERAND_REG_IMM_V2INT32
Definition SIDefines.h:444
@ OPERAND_SDWA_VOPC_DST
Definition SIDefines.h:481
@ OPERAND_REG_IMM_FP32
Definition SIDefines.h:434
@ OPERAND_REG_INLINE_C_FIRST
Definition SIDefines.h:486
@ OPERAND_REG_INLINE_C_FP32
Definition SIDefines.h:454
@ OPERAND_REG_INLINE_AC_LAST
Definition SIDefines.h:490
@ OPERAND_REG_IMM_LAST
Definition SIDefines.h:484
@ OPERAND_REG_INLINE_C_INT32
Definition SIDefines.h:450
@ OPERAND_REG_INLINE_C_V2INT16
Definition SIDefines.h:456
@ OPERAND_INLINE_C_AV64_PSEUDO
Definition SIDefines.h:475
@ OPERAND_REG_IMM_V2FP32
Definition SIDefines.h:445
@ OPERAND_REG_INLINE_AC_FP64
Definition SIDefines.h:471
@ OPERAND_REG_INLINE_C_FP16
Definition SIDefines.h:453
@ OPERAND_REG_IMM_INT16
Definition SIDefines.h:433
@ OPERAND_INLINE_SPLIT_BARRIER_INT32
Definition SIDefines.h:461
@ OPERAND_FIRST_TARGET
Definition MCInstrDesc.h:81
constexpr bool isAtomicRet(const T &...O)
Definition SIDefines.h:367
constexpr bool isVOPC(const T &...O)
Definition SIDefines.h:236
constexpr bool isVOP3(const T &...O)
Definition SIDefines.h:239
constexpr bool isScalarStore(const T &...O)
Definition SIDefines.h:313
constexpr bool hasVOP3OpSel(const T &...O)
Definition SIDefines.h:322
constexpr bool isVOP1(const T &...O)
Definition SIDefines.h:230
constexpr bool isFPAtomic(const T &...O)
Definition SIDefines.h:352
constexpr bool usesVM_CNT(const T &...O)
Definition SIDefines.h:388
constexpr bool usesTENSOR_CNT(const T &...O)
Definition SIDefines.h:310
constexpr bool isD16Buf(const T &...O)
Definition SIDefines.h:343
constexpr bool isMAI(const T &...O)
Definition SIDefines.h:355
constexpr bool isVOP2(const T &...O)
Definition SIDefines.h:233
constexpr bool isMaybeAtomic(const T &...O)
Definition SIDefines.h:325
constexpr bool isSWMMAC(const T &...O)
Definition SIDefines.h:382
constexpr bool isTRANS(const T &...O)
Definition SIDefines.h:258
constexpr bool isSOP2(const T &...O)
Definition SIDefines.h:218
constexpr bool isFLAT(const T &...O)
Definition SIDefines.h:286
constexpr bool isVOP3P(const T &...O)
Definition SIDefines.h:242
constexpr bool usesFPDPRounding(const T &...O)
Definition SIDefines.h:349
constexpr bool isDisableWQM(const T &...O)
Definition SIDefines.h:304
constexpr bool isBuffer(const T &...O)
Definition SIDefines.h:267
constexpr bool hasIntClamp(const T &...O)
Definition SIDefines.h:331
constexpr bool isAtomicNoRet(const T &...O)
Definition SIDefines.h:364
constexpr bool isMTBUF(const T &...O)
Definition SIDefines.h:264
constexpr bool isVIMAGE(const T &...O)
Definition SIDefines.h:277
constexpr bool isSMRD(const T &...O)
Definition SIDefines.h:271
constexpr bool isVOP3Like(const T &...O)
Definition SIDefines.h:245
constexpr bool isFlatScratch(const T &...O)
Definition SIDefines.h:361
constexpr bool isSpill(const T &...O)
Definition SIDefines.h:292
constexpr uint64_t getTSFlags(const MCInstrDesc &Desc)
Definition SIDefines.h:201
constexpr bool isMIMG(const T &...O)
Definition SIDefines.h:274
constexpr bool isVMEM(const T &...O)
Definition SIDefines.h:407
constexpr bool hasFPClamp(const T &...O)
Definition SIDefines.h:328
constexpr bool isNeverUniform(const T &...O)
Definition SIDefines.h:376
constexpr bool isImage(const T &...O)
Definition SIDefines.h:403
constexpr bool isWMMA(const T &...O)
Definition SIDefines.h:370
constexpr bool isVALU(const T &...O)
Definition SIDefines.h:212
constexpr bool isWQM(const T &...O)
Definition SIDefines.h:301
constexpr bool isVOPD3(const T &...O)
Definition SIDefines.h:385
constexpr bool hasClampLo(const T &...O)
Definition SIDefines.h:334
constexpr bool isGWS(const T &...O)
Definition SIDefines.h:379
constexpr bool isFlatGlobal(const T &...O)
Definition SIDefines.h:346
constexpr bool usesASYNC_CNT(const T &...O)
Definition SIDefines.h:319
constexpr bool isMUBUF(const T &...O)
Definition SIDefines.h:261
constexpr bool isSDWA(const T &...O)
Definition SIDefines.h:252
constexpr bool isTiedSourceNotRead(const T &...O)
Definition SIDefines.h:373
constexpr bool isEXP(const T &...O)
Definition SIDefines.h:283
constexpr bool usesLGKM_CNT(const T &...O)
Definition SIDefines.h:391
constexpr bool isSOPK(const T &...O)
Definition SIDefines.h:224
constexpr bool isSOPC(const T &...O)
Definition SIDefines.h:221
constexpr bool isSOPP(const T &...O)
Definition SIDefines.h:227
constexpr bool isDOT(const T &...O)
Definition SIDefines.h:358
constexpr bool isVINTRP(const T &...O)
Definition SIDefines.h:249
constexpr bool isVINTERP(const T &...O)
Definition SIDefines.h:298
constexpr bool isVSAMPLE(const T &...O)
Definition SIDefines.h:280
constexpr bool isDS(const T &...O)
Definition SIDefines.h:289
constexpr bool isAtomic(const T &...O)
Definition SIDefines.h:396
constexpr bool isLDSDIR(const T &...O)
Definition SIDefines.h:295
constexpr bool isSALU(const T &...O)
Definition SIDefines.h:209
constexpr bool isGather4(const T &...O)
Definition SIDefines.h:307
constexpr bool isPacked(const T &...O)
Definition SIDefines.h:340
constexpr bool hasClampHi(const T &...O)
Definition SIDefines.h:337
constexpr bool isDPP(const T &...O)
Definition SIDefines.h:255
constexpr bool isSOP1(const T &...O)
Definition SIDefines.h:215
constexpr bool isSegmentSpecificFLAT(const T &...O)
Definition SIDefines.h:399
constexpr bool isFixedSize(const T &...O)
Definition SIDefines.h:316
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