1//===-- AMDGPUAsmUtils.cpp - AsmParser/InstPrinter common -----------------===//
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//===----------------------------------------------------------------------===//
8#include "AMDGPUAsmUtils.h"
9#include "AMDGPUBaseInfo.h"
10#include "SIDefines.h"
11
12namespace llvm::AMDGPU {
13
14//===----------------------------------------------------------------------===//
15// Custom Operands.
16//
17// A table of custom operands shall describe "primary" operand names first
18// followed by aliases if any. It is not required but recommended to arrange
19// operands so that operand encoding match operand position in the table. This
20// will make getNameFromOperandTable() a bit more efficient. Unused slots in the
21// table shall have an empty name.
22//
23//===----------------------------------------------------------------------===//
24
25/// Map from the encoding of a sendmsg/hwreg asm operand to it's name.
26template <size_t N>
27static StringRef getNameFromOperandTable(const CustomOperand (&Table)[N],
28 unsigned Encoding,
29 const MCSubtargetInfo &STI) {
30 auto isValidIndexForEncoding = [&](size_t Idx) {
31 return Idx < N && Table[Idx].Encoding == Encoding &&
32 !Table[Idx].Name.empty() &&
33 (!Table[Idx].Cond || Table[Idx].Cond(STI));
34 };
35
36 // This is an optimization that should work in most cases. As a side effect,
37 // it may cause selection of an alias instead of a primary operand name in
38 // case of sparse tables.
39 if (isValidIndexForEncoding(Encoding))
40 return Table[Encoding].Name;
41
42 for (size_t Idx = 0; Idx != N; ++Idx)
43 if (isValidIndexForEncoding(Idx))
44 return Table[Idx].Name;
45
46 return "";
47}
48
49/// Map from a symbolic name for a sendmsg/hwreg asm operand to it's encoding.
50template <size_t N>
51static int64_t getEncodingFromOperandTable(const CustomOperand (&Table)[N],
52 StringRef Name,
53 const MCSubtargetInfo &STI) {
54 int64_t InvalidEncoding = OPR_ID_UNKNOWN;
55 for (const CustomOperand &Entry : Table) {
56 if (Entry.Name != Name)
57 continue;
58
59 if (!Entry.Cond || Entry.Cond(STI))
60 return Entry.Encoding;
61
62 InvalidEncoding = OPR_ID_UNSUPPORTED;
63 }
64
65 return InvalidEncoding;
66}
67
68namespace DepCtr {
69
70// NOLINTBEGIN
71const CustomOperandVal DepCtrInfo[] = {
72 // Name max dflt offset width constraint
73 {.Name: {"depctr_hold_cnt"}, .Max: 1, .Default: 1, .Shift: 7, .Width: 1, .Cond: isGFX10_BEncoding},
74 {.Name: {"depctr_sa_sdst"}, .Max: 1, .Default: 1, .Shift: 0, .Width: 1},
75 {.Name: {"depctr_va_vdst"}, .Max: 15, .Default: 15, .Shift: 12, .Width: 4},
76 {.Name: {"depctr_va_sdst"}, .Max: 7, .Default: 7, .Shift: 9, .Width: 3},
77 {.Name: {"depctr_va_ssrc"}, .Max: 1, .Default: 1, .Shift: 8, .Width: 1},
78 {.Name: {"depctr_va_vcc"}, .Max: 1, .Default: 1, .Shift: 1, .Width: 1},
79 {.Name: {"depctr_vm_vsrc"}, .Max: 7, .Default: 7, .Shift: 2, .Width: 3},
80};
81// NOLINTEND
82
83const int DEP_CTR_SIZE =
84 static_cast<int>(sizeof(DepCtrInfo) / sizeof(CustomOperandVal));
85
86} // namespace DepCtr
87
88namespace SendMsg {
89
90// Disable lint checking here since it makes these tables unreadable.
91// NOLINTBEGIN
92// clang-format off
93
94static constexpr CustomOperand MsgOperands[] = {
95 {.Name: {""}},
96 {.Name: {"MSG_INTERRUPT"}, .Encoding: ID_INTERRUPT},
97 {.Name: {"MSG_GS"}, .Encoding: ID_GS_PreGFX11, .Cond: isNotGFX11Plus},
98 {.Name: {"MSG_GS_DONE"}, .Encoding: ID_GS_DONE_PreGFX11, .Cond: isNotGFX11Plus},
99 {.Name: {"MSG_SAVEWAVE"}, .Encoding: ID_SAVEWAVE, .Cond: isGFX8_GFX9_GFX10},
100 {.Name: {"MSG_STALL_WAVE_GEN"}, .Encoding: ID_STALL_WAVE_GEN, .Cond: isGFX9_GFX10_GFX11},
101 {.Name: {"MSG_HALT_WAVES"}, .Encoding: ID_HALT_WAVES, .Cond: isGFX9_GFX10_GFX11},
102 {.Name: {"MSG_ORDERED_PS_DONE"}, .Encoding: ID_ORDERED_PS_DONE, .Cond: isGFX9_GFX10},
103 {.Name: {"MSG_EARLY_PRIM_DEALLOC"}, .Encoding: ID_EARLY_PRIM_DEALLOC, .Cond: isGFX9_GFX10},
104 {.Name: {"MSG_GS_ALLOC_REQ"}, .Encoding: ID_GS_ALLOC_REQ, .Cond: isGFX9Plus},
105 {.Name: {"MSG_GET_DOORBELL"}, .Encoding: ID_GET_DOORBELL, .Cond: isGFX9_GFX10},
106 {.Name: {"MSG_GET_DDID"}, .Encoding: ID_GET_DDID, .Cond: isGFX10},
107 {.Name: {"MSG_HS_TESSFACTOR"}, .Encoding: ID_HS_TESSFACTOR_GFX11Plus, .Cond: isGFX11Plus},
108 {.Name: {"MSG_DEALLOC_VGPRS"}, .Encoding: ID_DEALLOC_VGPRS_GFX11Plus, .Cond: isGFX11Plus},
109 {.Name: {""}},
110 {.Name: {"MSG_SYSMSG"}, .Encoding: ID_SYSMSG},
111 {.Name: {"MSG_RTN_GET_DOORBELL"}, .Encoding: ID_RTN_GET_DOORBELL, .Cond: isGFX11Plus},
112 {.Name: {"MSG_RTN_GET_DDID"}, .Encoding: ID_RTN_GET_DDID, .Cond: isGFX11Plus},
113 {.Name: {"MSG_RTN_GET_TMA"}, .Encoding: ID_RTN_GET_TMA, .Cond: isGFX11Plus},
114 {.Name: {"MSG_RTN_GET_REALTIME"}, .Encoding: ID_RTN_GET_REALTIME, .Cond: isGFX11Plus},
115 {.Name: {"MSG_RTN_SAVE_WAVE"}, .Encoding: ID_RTN_SAVE_WAVE, .Cond: isGFX11Plus},
116 {.Name: {"MSG_RTN_GET_TBA"}, .Encoding: ID_RTN_GET_TBA, .Cond: isGFX11Plus},
117 {.Name: {"MSG_RTN_GET_TBA_TO_PC"}, .Encoding: ID_RTN_GET_TBA_TO_PC, .Cond: isGFX11Plus},
118 {.Name: {"MSG_RTN_GET_SE_AID_ID"}, .Encoding: ID_RTN_GET_SE_AID_ID, .Cond: isGFX12Plus},
119};
120
121static constexpr CustomOperand SysMsgOperands[] = {
122 {.Name: {""}},
123 {.Name: {"SYSMSG_OP_ECC_ERR_INTERRUPT"}, .Encoding: OP_SYS_ECC_ERR_INTERRUPT},
124 {.Name: {"SYSMSG_OP_REG_RD"}, .Encoding: OP_SYS_REG_RD},
125 {.Name: {"SYSMSG_OP_HOST_TRAP_ACK"}, .Encoding: OP_SYS_HOST_TRAP_ACK, .Cond: isNotGFX9Plus},
126 {.Name: {"SYSMSG_OP_TTRACE_PC"}, .Encoding: OP_SYS_TTRACE_PC},
127};
128
129static constexpr CustomOperand StreamMsgOperands[] = {
130 {.Name: {"GS_OP_NOP"}, .Encoding: OP_GS_NOP},
131 {.Name: {"GS_OP_CUT"}, .Encoding: OP_GS_CUT},
132 {.Name: {"GS_OP_EMIT"}, .Encoding: OP_GS_EMIT},
133 {.Name: {"GS_OP_EMIT_CUT"}, .Encoding: OP_GS_EMIT_CUT},
134};
135
136// clang-format on
137// NOLINTEND
138
139int64_t getMsgId(StringRef Name, const MCSubtargetInfo &STI) {
140 return getEncodingFromOperandTable(Table: MsgOperands, Name, STI);
141}
142
143StringRef getMsgName(uint64_t Encoding, const MCSubtargetInfo &STI) {
144 return getNameFromOperandTable(Table: MsgOperands, Encoding, STI);
145}
146
147int64_t getMsgOpId(int64_t MsgId, StringRef Name, const MCSubtargetInfo &STI) {
148 if (MsgId == ID_SYSMSG)
149 return getEncodingFromOperandTable(Table: SysMsgOperands, Name, STI);
150 return getEncodingFromOperandTable(Table: StreamMsgOperands, Name, STI);
151}
152
153StringRef getMsgOpName(int64_t MsgId, uint64_t Encoding,
154 const MCSubtargetInfo &STI) {
155 assert(msgRequiresOp(MsgId, STI) && "must have an operand");
156
157 if (MsgId == ID_SYSMSG)
158 return getNameFromOperandTable(Table: SysMsgOperands, Encoding, STI);
159 return getNameFromOperandTable(Table: StreamMsgOperands, Encoding, STI);
160}
161
162} // namespace SendMsg
163
164namespace Hwreg {
165
166// Disable lint checking for this block since it makes the table unreadable.
167// NOLINTBEGIN
168// clang-format off
169static constexpr CustomOperand Operands[] = {
170 {.Name: {""}},
171 {.Name: {"HW_REG_MODE"}, .Encoding: ID_MODE},
172 {.Name: {"HW_REG_STATUS"}, .Encoding: ID_STATUS},
173 {.Name: {"HW_REG_TRAPSTS"}, .Encoding: ID_TRAPSTS, .Cond: isNotGFX12Plus},
174 {.Name: {"HW_REG_HW_ID"}, .Encoding: ID_HW_ID, .Cond: isNotGFX10Plus},
175 {.Name: {"HW_REG_GPR_ALLOC"}, .Encoding: ID_GPR_ALLOC},
176 {.Name: {"HW_REG_LDS_ALLOC"}, .Encoding: ID_LDS_ALLOC},
177 {.Name: {"HW_REG_IB_STS"}, .Encoding: ID_IB_STS},
178 {.Name: {""}},
179 {.Name: {""}},
180 {.Name: {"HW_REG_PERF_SNAPSHOT_DATA"}, .Encoding: ID_PERF_SNAPSHOT_DATA_gfx12, .Cond: isGFX12Plus},
181 {.Name: {"HW_REG_PERF_SNAPSHOT_PC_LO"}, .Encoding: ID_PERF_SNAPSHOT_PC_LO_gfx12, .Cond: isGFX12Plus},
182 {.Name: {"HW_REG_PERF_SNAPSHOT_PC_HI"}, .Encoding: ID_PERF_SNAPSHOT_PC_HI_gfx12, .Cond: isGFX12Plus},
183 {.Name: {""}},
184 {.Name: {""}},
185 {.Name: {"HW_REG_SH_MEM_BASES"}, .Encoding: ID_MEM_BASES, .Cond: isGFX9_GFX10_GFX11},
186 {.Name: {"HW_REG_TBA_LO"}, .Encoding: ID_TBA_LO, .Cond: isGFX9_GFX10},
187 {.Name: {"HW_REG_TBA_HI"}, .Encoding: ID_TBA_HI, .Cond: isGFX9_GFX10},
188 {.Name: {"HW_REG_TMA_LO"}, .Encoding: ID_TMA_LO, .Cond: isGFX9_GFX10},
189 {.Name: {"HW_REG_TMA_HI"}, .Encoding: ID_TMA_HI, .Cond: isGFX9_GFX10},
190 {.Name: {"HW_REG_FLAT_SCR_LO"}, .Encoding: ID_FLAT_SCR_LO, .Cond: isGFX10_GFX11},
191 {.Name: {"HW_REG_FLAT_SCR_HI"}, .Encoding: ID_FLAT_SCR_HI, .Cond: isGFX10_GFX11},
192 {.Name: {"HW_REG_XNACK_MASK"}, .Encoding: ID_XNACK_MASK, .Cond: isGFX10Before1030},
193 {.Name: {"HW_REG_HW_ID1"}, .Encoding: ID_HW_ID1, .Cond: isGFX10Plus},
194 {.Name: {"HW_REG_HW_ID2"}, .Encoding: ID_HW_ID2, .Cond: isGFX10Plus},
195 {.Name: {"HW_REG_POPS_PACKER"}, .Encoding: ID_POPS_PACKER, .Cond: isGFX10},
196 {.Name: {""}},
197 {.Name: {"HW_REG_PERF_SNAPSHOT_DATA"}, .Encoding: ID_PERF_SNAPSHOT_DATA_gfx11, .Cond: isGFX11},
198 {.Name: {""}},
199 {.Name: {"HW_REG_SHADER_CYCLES"}, .Encoding: ID_SHADER_CYCLES, .Cond: isGFX10_3_GFX11},
200 {.Name: {"HW_REG_SHADER_CYCLES_HI"}, .Encoding: ID_SHADER_CYCLES_HI, .Cond: isGFX12Plus},
201 {.Name: {"HW_REG_DVGPR_ALLOC_LO"}, .Encoding: ID_DVGPR_ALLOC_LO, .Cond: isGFX12Plus},
202 {.Name: {"HW_REG_DVGPR_ALLOC_HI"}, .Encoding: ID_DVGPR_ALLOC_HI, .Cond: isGFX12Plus},
203
204 // Register numbers reused in GFX11
205 {.Name: {"HW_REG_PERF_SNAPSHOT_PC_LO"}, .Encoding: ID_PERF_SNAPSHOT_PC_LO_gfx11, .Cond: isGFX11},
206 {.Name: {"HW_REG_PERF_SNAPSHOT_PC_HI"}, .Encoding: ID_PERF_SNAPSHOT_PC_HI_gfx11, .Cond: isGFX11},
207
208 // Register numbers reused in GFX12+
209 {.Name: {"HW_REG_STATE_PRIV"}, .Encoding: ID_STATE_PRIV, .Cond: isGFX12Plus},
210 {.Name: {"HW_REG_PERF_SNAPSHOT_DATA1"}, .Encoding: ID_PERF_SNAPSHOT_DATA1, .Cond: isGFX12Plus},
211 {.Name: {"HW_REG_PERF_SNAPSHOT_DATA2"}, .Encoding: ID_PERF_SNAPSHOT_DATA2, .Cond: isGFX12Plus},
212 {.Name: {"HW_REG_EXCP_FLAG_PRIV"}, .Encoding: ID_EXCP_FLAG_PRIV, .Cond: isGFX12Plus},
213 {.Name: {"HW_REG_EXCP_FLAG_USER"}, .Encoding: ID_EXCP_FLAG_USER, .Cond: isGFX12Plus},
214 {.Name: {"HW_REG_TRAP_CTRL"}, .Encoding: ID_TRAP_CTRL, .Cond: isGFX12Plus},
215 {.Name: {"HW_REG_SCRATCH_BASE_LO"}, .Encoding: ID_FLAT_SCR_LO, .Cond: isGFX12Plus},
216 {.Name: {"HW_REG_SCRATCH_BASE_HI"}, .Encoding: ID_FLAT_SCR_HI, .Cond: isGFX12Plus},
217 {.Name: {"HW_REG_SHADER_CYCLES_LO"}, .Encoding: ID_SHADER_CYCLES, .Cond: isGFX12Plus},
218
219 // GFX940 specific registers
220 {.Name: {"HW_REG_XCC_ID"}, .Encoding: ID_XCC_ID, .Cond: isGFX940},
221 {.Name: {"HW_REG_SQ_PERF_SNAPSHOT_DATA"}, .Encoding: ID_SQ_PERF_SNAPSHOT_DATA, .Cond: isGFX940},
222 {.Name: {"HW_REG_SQ_PERF_SNAPSHOT_DATA1"}, .Encoding: ID_SQ_PERF_SNAPSHOT_DATA1, .Cond: isGFX940},
223 {.Name: {"HW_REG_SQ_PERF_SNAPSHOT_PC_LO"}, .Encoding: ID_SQ_PERF_SNAPSHOT_PC_LO, .Cond: isGFX940},
224 {.Name: {"HW_REG_SQ_PERF_SNAPSHOT_PC_HI"}, .Encoding: ID_SQ_PERF_SNAPSHOT_PC_HI, .Cond: isGFX940},
225
226 // Aliases
227 {.Name: {"HW_REG_HW_ID"}, .Encoding: ID_HW_ID1, .Cond: isGFX10},
228};
229// clang-format on
230// NOLINTEND
231
232int64_t getHwregId(StringRef Name, const MCSubtargetInfo &STI) {
233 return getEncodingFromOperandTable(Table: Operands, Name, STI);
234}
235
236StringRef getHwreg(uint64_t Encoding, const MCSubtargetInfo &STI) {
237 return getNameFromOperandTable(Table: Operands, Encoding, STI);
238}
239
240} // namespace Hwreg
241
242namespace MTBUFFormat {
243
244StringLiteral const DfmtSymbolic[] = {
245 "BUF_DATA_FORMAT_INVALID",
246 "BUF_DATA_FORMAT_8",
247 "BUF_DATA_FORMAT_16",
248 "BUF_DATA_FORMAT_8_8",
249 "BUF_DATA_FORMAT_32",
250 "BUF_DATA_FORMAT_16_16",
251 "BUF_DATA_FORMAT_10_11_11",
252 "BUF_DATA_FORMAT_11_11_10",
253 "BUF_DATA_FORMAT_10_10_10_2",
254 "BUF_DATA_FORMAT_2_10_10_10",
255 "BUF_DATA_FORMAT_8_8_8_8",
256 "BUF_DATA_FORMAT_32_32",
257 "BUF_DATA_FORMAT_16_16_16_16",
258 "BUF_DATA_FORMAT_32_32_32",
259 "BUF_DATA_FORMAT_32_32_32_32",
260 "BUF_DATA_FORMAT_RESERVED_15"
261};
262
263StringLiteral const NfmtSymbolicGFX10[] = {
264 "BUF_NUM_FORMAT_UNORM",
265 "BUF_NUM_FORMAT_SNORM",
266 "BUF_NUM_FORMAT_USCALED",
267 "BUF_NUM_FORMAT_SSCALED",
268 "BUF_NUM_FORMAT_UINT",
269 "BUF_NUM_FORMAT_SINT",
270 "",
271 "BUF_NUM_FORMAT_FLOAT"
272};
273
274StringLiteral const NfmtSymbolicSICI[] = {
275 "BUF_NUM_FORMAT_UNORM",
276 "BUF_NUM_FORMAT_SNORM",
277 "BUF_NUM_FORMAT_USCALED",
278 "BUF_NUM_FORMAT_SSCALED",
279 "BUF_NUM_FORMAT_UINT",
280 "BUF_NUM_FORMAT_SINT",
281 "BUF_NUM_FORMAT_SNORM_OGL",
282 "BUF_NUM_FORMAT_FLOAT"
283};
284
285StringLiteral const NfmtSymbolicVI[] = { // VI and GFX9
286 "BUF_NUM_FORMAT_UNORM",
287 "BUF_NUM_FORMAT_SNORM",
288 "BUF_NUM_FORMAT_USCALED",
289 "BUF_NUM_FORMAT_SSCALED",
290 "BUF_NUM_FORMAT_UINT",
291 "BUF_NUM_FORMAT_SINT",
292 "BUF_NUM_FORMAT_RESERVED_6",
293 "BUF_NUM_FORMAT_FLOAT"
294};
295
296StringLiteral const UfmtSymbolicGFX10[] = {
297 "BUF_FMT_INVALID",
298
299 "BUF_FMT_8_UNORM",
300 "BUF_FMT_8_SNORM",
301 "BUF_FMT_8_USCALED",
302 "BUF_FMT_8_SSCALED",
303 "BUF_FMT_8_UINT",
304 "BUF_FMT_8_SINT",
305
306 "BUF_FMT_16_UNORM",
307 "BUF_FMT_16_SNORM",
308 "BUF_FMT_16_USCALED",
309 "BUF_FMT_16_SSCALED",
310 "BUF_FMT_16_UINT",
311 "BUF_FMT_16_SINT",
312 "BUF_FMT_16_FLOAT",
313
314 "BUF_FMT_8_8_UNORM",
315 "BUF_FMT_8_8_SNORM",
316 "BUF_FMT_8_8_USCALED",
317 "BUF_FMT_8_8_SSCALED",
318 "BUF_FMT_8_8_UINT",
319 "BUF_FMT_8_8_SINT",
320
321 "BUF_FMT_32_UINT",
322 "BUF_FMT_32_SINT",
323 "BUF_FMT_32_FLOAT",
324
325 "BUF_FMT_16_16_UNORM",
326 "BUF_FMT_16_16_SNORM",
327 "BUF_FMT_16_16_USCALED",
328 "BUF_FMT_16_16_SSCALED",
329 "BUF_FMT_16_16_UINT",
330 "BUF_FMT_16_16_SINT",
331 "BUF_FMT_16_16_FLOAT",
332
333 "BUF_FMT_10_11_11_UNORM",
334 "BUF_FMT_10_11_11_SNORM",
335 "BUF_FMT_10_11_11_USCALED",
336 "BUF_FMT_10_11_11_SSCALED",
337 "BUF_FMT_10_11_11_UINT",
338 "BUF_FMT_10_11_11_SINT",
339 "BUF_FMT_10_11_11_FLOAT",
340
341 "BUF_FMT_11_11_10_UNORM",
342 "BUF_FMT_11_11_10_SNORM",
343 "BUF_FMT_11_11_10_USCALED",
344 "BUF_FMT_11_11_10_SSCALED",
345 "BUF_FMT_11_11_10_UINT",
346 "BUF_FMT_11_11_10_SINT",
347 "BUF_FMT_11_11_10_FLOAT",
348
349 "BUF_FMT_10_10_10_2_UNORM",
350 "BUF_FMT_10_10_10_2_SNORM",
351 "BUF_FMT_10_10_10_2_USCALED",
352 "BUF_FMT_10_10_10_2_SSCALED",
353 "BUF_FMT_10_10_10_2_UINT",
354 "BUF_FMT_10_10_10_2_SINT",
355
356 "BUF_FMT_2_10_10_10_UNORM",
357 "BUF_FMT_2_10_10_10_SNORM",
358 "BUF_FMT_2_10_10_10_USCALED",
359 "BUF_FMT_2_10_10_10_SSCALED",
360 "BUF_FMT_2_10_10_10_UINT",
361 "BUF_FMT_2_10_10_10_SINT",
362
363 "BUF_FMT_8_8_8_8_UNORM",
364 "BUF_FMT_8_8_8_8_SNORM",
365 "BUF_FMT_8_8_8_8_USCALED",
366 "BUF_FMT_8_8_8_8_SSCALED",
367 "BUF_FMT_8_8_8_8_UINT",
368 "BUF_FMT_8_8_8_8_SINT",
369
370 "BUF_FMT_32_32_UINT",
371 "BUF_FMT_32_32_SINT",
372 "BUF_FMT_32_32_FLOAT",
373
374 "BUF_FMT_16_16_16_16_UNORM",
375 "BUF_FMT_16_16_16_16_SNORM",
376 "BUF_FMT_16_16_16_16_USCALED",
377 "BUF_FMT_16_16_16_16_SSCALED",
378 "BUF_FMT_16_16_16_16_UINT",
379 "BUF_FMT_16_16_16_16_SINT",
380 "BUF_FMT_16_16_16_16_FLOAT",
381
382 "BUF_FMT_32_32_32_UINT",
383 "BUF_FMT_32_32_32_SINT",
384 "BUF_FMT_32_32_32_FLOAT",
385 "BUF_FMT_32_32_32_32_UINT",
386 "BUF_FMT_32_32_32_32_SINT",
387 "BUF_FMT_32_32_32_32_FLOAT"
388};
389
390unsigned const DfmtNfmt2UFmtGFX10[] = {
391 DFMT_INVALID | (NFMT_UNORM << NFMT_SHIFT),
392
393 DFMT_8 | (NFMT_UNORM << NFMT_SHIFT),
394 DFMT_8 | (NFMT_SNORM << NFMT_SHIFT),
395 DFMT_8 | (NFMT_USCALED << NFMT_SHIFT),
396 DFMT_8 | (NFMT_SSCALED << NFMT_SHIFT),
397 DFMT_8 | (NFMT_UINT << NFMT_SHIFT),
398 DFMT_8 | (NFMT_SINT << NFMT_SHIFT),
399
400 DFMT_16 | (NFMT_UNORM << NFMT_SHIFT),
401 DFMT_16 | (NFMT_SNORM << NFMT_SHIFT),
402 DFMT_16 | (NFMT_USCALED << NFMT_SHIFT),
403 DFMT_16 | (NFMT_SSCALED << NFMT_SHIFT),
404 DFMT_16 | (NFMT_UINT << NFMT_SHIFT),
405 DFMT_16 | (NFMT_SINT << NFMT_SHIFT),
406 DFMT_16 | (NFMT_FLOAT << NFMT_SHIFT),
407
408 DFMT_8_8 | (NFMT_UNORM << NFMT_SHIFT),
409 DFMT_8_8 | (NFMT_SNORM << NFMT_SHIFT),
410 DFMT_8_8 | (NFMT_USCALED << NFMT_SHIFT),
411 DFMT_8_8 | (NFMT_SSCALED << NFMT_SHIFT),
412 DFMT_8_8 | (NFMT_UINT << NFMT_SHIFT),
413 DFMT_8_8 | (NFMT_SINT << NFMT_SHIFT),
414
415 DFMT_32 | (NFMT_UINT << NFMT_SHIFT),
416 DFMT_32 | (NFMT_SINT << NFMT_SHIFT),
417 DFMT_32 | (NFMT_FLOAT << NFMT_SHIFT),
418
419 DFMT_16_16 | (NFMT_UNORM << NFMT_SHIFT),
420 DFMT_16_16 | (NFMT_SNORM << NFMT_SHIFT),
421 DFMT_16_16 | (NFMT_USCALED << NFMT_SHIFT),
422 DFMT_16_16 | (NFMT_SSCALED << NFMT_SHIFT),
423 DFMT_16_16 | (NFMT_UINT << NFMT_SHIFT),
424 DFMT_16_16 | (NFMT_SINT << NFMT_SHIFT),
425 DFMT_16_16 | (NFMT_FLOAT << NFMT_SHIFT),
426
427 DFMT_10_11_11 | (NFMT_UNORM << NFMT_SHIFT),
428 DFMT_10_11_11 | (NFMT_SNORM << NFMT_SHIFT),
429 DFMT_10_11_11 | (NFMT_USCALED << NFMT_SHIFT),
430 DFMT_10_11_11 | (NFMT_SSCALED << NFMT_SHIFT),
431 DFMT_10_11_11 | (NFMT_UINT << NFMT_SHIFT),
432 DFMT_10_11_11 | (NFMT_SINT << NFMT_SHIFT),
433 DFMT_10_11_11 | (NFMT_FLOAT << NFMT_SHIFT),
434
435 DFMT_11_11_10 | (NFMT_UNORM << NFMT_SHIFT),
436 DFMT_11_11_10 | (NFMT_SNORM << NFMT_SHIFT),
437 DFMT_11_11_10 | (NFMT_USCALED << NFMT_SHIFT),
438 DFMT_11_11_10 | (NFMT_SSCALED << NFMT_SHIFT),
439 DFMT_11_11_10 | (NFMT_UINT << NFMT_SHIFT),
440 DFMT_11_11_10 | (NFMT_SINT << NFMT_SHIFT),
441 DFMT_11_11_10 | (NFMT_FLOAT << NFMT_SHIFT),
442
443 DFMT_10_10_10_2 | (NFMT_UNORM << NFMT_SHIFT),
444 DFMT_10_10_10_2 | (NFMT_SNORM << NFMT_SHIFT),
445 DFMT_10_10_10_2 | (NFMT_USCALED << NFMT_SHIFT),
446 DFMT_10_10_10_2 | (NFMT_SSCALED << NFMT_SHIFT),
447 DFMT_10_10_10_2 | (NFMT_UINT << NFMT_SHIFT),
448 DFMT_10_10_10_2 | (NFMT_SINT << NFMT_SHIFT),
449
450 DFMT_2_10_10_10 | (NFMT_UNORM << NFMT_SHIFT),
451 DFMT_2_10_10_10 | (NFMT_SNORM << NFMT_SHIFT),
452 DFMT_2_10_10_10 | (NFMT_USCALED << NFMT_SHIFT),
453 DFMT_2_10_10_10 | (NFMT_SSCALED << NFMT_SHIFT),
454 DFMT_2_10_10_10 | (NFMT_UINT << NFMT_SHIFT),
455 DFMT_2_10_10_10 | (NFMT_SINT << NFMT_SHIFT),
456
457 DFMT_8_8_8_8 | (NFMT_UNORM << NFMT_SHIFT),
458 DFMT_8_8_8_8 | (NFMT_SNORM << NFMT_SHIFT),
459 DFMT_8_8_8_8 | (NFMT_USCALED << NFMT_SHIFT),
460 DFMT_8_8_8_8 | (NFMT_SSCALED << NFMT_SHIFT),
461 DFMT_8_8_8_8 | (NFMT_UINT << NFMT_SHIFT),
462 DFMT_8_8_8_8 | (NFMT_SINT << NFMT_SHIFT),
463
464 DFMT_32_32 | (NFMT_UINT << NFMT_SHIFT),
465 DFMT_32_32 | (NFMT_SINT << NFMT_SHIFT),
466 DFMT_32_32 | (NFMT_FLOAT << NFMT_SHIFT),
467
468 DFMT_16_16_16_16 | (NFMT_UNORM << NFMT_SHIFT),
469 DFMT_16_16_16_16 | (NFMT_SNORM << NFMT_SHIFT),
470 DFMT_16_16_16_16 | (NFMT_USCALED << NFMT_SHIFT),
471 DFMT_16_16_16_16 | (NFMT_SSCALED << NFMT_SHIFT),
472 DFMT_16_16_16_16 | (NFMT_UINT << NFMT_SHIFT),
473 DFMT_16_16_16_16 | (NFMT_SINT << NFMT_SHIFT),
474 DFMT_16_16_16_16 | (NFMT_FLOAT << NFMT_SHIFT),
475
476 DFMT_32_32_32 | (NFMT_UINT << NFMT_SHIFT),
477 DFMT_32_32_32 | (NFMT_SINT << NFMT_SHIFT),
478 DFMT_32_32_32 | (NFMT_FLOAT << NFMT_SHIFT),
479 DFMT_32_32_32_32 | (NFMT_UINT << NFMT_SHIFT),
480 DFMT_32_32_32_32 | (NFMT_SINT << NFMT_SHIFT),
481 DFMT_32_32_32_32 | (NFMT_FLOAT << NFMT_SHIFT)
482};
483
484StringLiteral const UfmtSymbolicGFX11[] = {
485 "BUF_FMT_INVALID",
486
487 "BUF_FMT_8_UNORM",
488 "BUF_FMT_8_SNORM",
489 "BUF_FMT_8_USCALED",
490 "BUF_FMT_8_SSCALED",
491 "BUF_FMT_8_UINT",
492 "BUF_FMT_8_SINT",
493
494 "BUF_FMT_16_UNORM",
495 "BUF_FMT_16_SNORM",
496 "BUF_FMT_16_USCALED",
497 "BUF_FMT_16_SSCALED",
498 "BUF_FMT_16_UINT",
499 "BUF_FMT_16_SINT",
500 "BUF_FMT_16_FLOAT",
501
502 "BUF_FMT_8_8_UNORM",
503 "BUF_FMT_8_8_SNORM",
504 "BUF_FMT_8_8_USCALED",
505 "BUF_FMT_8_8_SSCALED",
506 "BUF_FMT_8_8_UINT",
507 "BUF_FMT_8_8_SINT",
508
509 "BUF_FMT_32_UINT",
510 "BUF_FMT_32_SINT",
511 "BUF_FMT_32_FLOAT",
512
513 "BUF_FMT_16_16_UNORM",
514 "BUF_FMT_16_16_SNORM",
515 "BUF_FMT_16_16_USCALED",
516 "BUF_FMT_16_16_SSCALED",
517 "BUF_FMT_16_16_UINT",
518 "BUF_FMT_16_16_SINT",
519 "BUF_FMT_16_16_FLOAT",
520
521 "BUF_FMT_10_11_11_FLOAT",
522
523 "BUF_FMT_11_11_10_FLOAT",
524
525 "BUF_FMT_10_10_10_2_UNORM",
526 "BUF_FMT_10_10_10_2_SNORM",
527 "BUF_FMT_10_10_10_2_UINT",
528 "BUF_FMT_10_10_10_2_SINT",
529
530 "BUF_FMT_2_10_10_10_UNORM",
531 "BUF_FMT_2_10_10_10_SNORM",
532 "BUF_FMT_2_10_10_10_USCALED",
533 "BUF_FMT_2_10_10_10_SSCALED",
534 "BUF_FMT_2_10_10_10_UINT",
535 "BUF_FMT_2_10_10_10_SINT",
536
537 "BUF_FMT_8_8_8_8_UNORM",
538 "BUF_FMT_8_8_8_8_SNORM",
539 "BUF_FMT_8_8_8_8_USCALED",
540 "BUF_FMT_8_8_8_8_SSCALED",
541 "BUF_FMT_8_8_8_8_UINT",
542 "BUF_FMT_8_8_8_8_SINT",
543
544 "BUF_FMT_32_32_UINT",
545 "BUF_FMT_32_32_SINT",
546 "BUF_FMT_32_32_FLOAT",
547
548 "BUF_FMT_16_16_16_16_UNORM",
549 "BUF_FMT_16_16_16_16_SNORM",
550 "BUF_FMT_16_16_16_16_USCALED",
551 "BUF_FMT_16_16_16_16_SSCALED",
552 "BUF_FMT_16_16_16_16_UINT",
553 "BUF_FMT_16_16_16_16_SINT",
554 "BUF_FMT_16_16_16_16_FLOAT",
555
556 "BUF_FMT_32_32_32_UINT",
557 "BUF_FMT_32_32_32_SINT",
558 "BUF_FMT_32_32_32_FLOAT",
559 "BUF_FMT_32_32_32_32_UINT",
560 "BUF_FMT_32_32_32_32_SINT",
561 "BUF_FMT_32_32_32_32_FLOAT"
562};
563
564unsigned const DfmtNfmt2UFmtGFX11[] = {
565 DFMT_INVALID | (NFMT_UNORM << NFMT_SHIFT),
566
567 DFMT_8 | (NFMT_UNORM << NFMT_SHIFT),
568 DFMT_8 | (NFMT_SNORM << NFMT_SHIFT),
569 DFMT_8 | (NFMT_USCALED << NFMT_SHIFT),
570 DFMT_8 | (NFMT_SSCALED << NFMT_SHIFT),
571 DFMT_8 | (NFMT_UINT << NFMT_SHIFT),
572 DFMT_8 | (NFMT_SINT << NFMT_SHIFT),
573
574 DFMT_16 | (NFMT_UNORM << NFMT_SHIFT),
575 DFMT_16 | (NFMT_SNORM << NFMT_SHIFT),
576 DFMT_16 | (NFMT_USCALED << NFMT_SHIFT),
577 DFMT_16 | (NFMT_SSCALED << NFMT_SHIFT),
578 DFMT_16 | (NFMT_UINT << NFMT_SHIFT),
579 DFMT_16 | (NFMT_SINT << NFMT_SHIFT),
580 DFMT_16 | (NFMT_FLOAT << NFMT_SHIFT),
581
582 DFMT_8_8 | (NFMT_UNORM << NFMT_SHIFT),
583 DFMT_8_8 | (NFMT_SNORM << NFMT_SHIFT),
584 DFMT_8_8 | (NFMT_USCALED << NFMT_SHIFT),
585 DFMT_8_8 | (NFMT_SSCALED << NFMT_SHIFT),
586 DFMT_8_8 | (NFMT_UINT << NFMT_SHIFT),
587 DFMT_8_8 | (NFMT_SINT << NFMT_SHIFT),
588
589 DFMT_32 | (NFMT_UINT << NFMT_SHIFT),
590 DFMT_32 | (NFMT_SINT << NFMT_SHIFT),
591 DFMT_32 | (NFMT_FLOAT << NFMT_SHIFT),
592
593 DFMT_16_16 | (NFMT_UNORM << NFMT_SHIFT),
594 DFMT_16_16 | (NFMT_SNORM << NFMT_SHIFT),
595 DFMT_16_16 | (NFMT_USCALED << NFMT_SHIFT),
596 DFMT_16_16 | (NFMT_SSCALED << NFMT_SHIFT),
597 DFMT_16_16 | (NFMT_UINT << NFMT_SHIFT),
598 DFMT_16_16 | (NFMT_SINT << NFMT_SHIFT),
599 DFMT_16_16 | (NFMT_FLOAT << NFMT_SHIFT),
600
601 DFMT_10_11_11 | (NFMT_FLOAT << NFMT_SHIFT),
602
603 DFMT_11_11_10 | (NFMT_FLOAT << NFMT_SHIFT),
604
605 DFMT_10_10_10_2 | (NFMT_UNORM << NFMT_SHIFT),
606 DFMT_10_10_10_2 | (NFMT_SNORM << NFMT_SHIFT),
607 DFMT_10_10_10_2 | (NFMT_UINT << NFMT_SHIFT),
608 DFMT_10_10_10_2 | (NFMT_SINT << NFMT_SHIFT),
609
610 DFMT_2_10_10_10 | (NFMT_UNORM << NFMT_SHIFT),
611 DFMT_2_10_10_10 | (NFMT_SNORM << NFMT_SHIFT),
612 DFMT_2_10_10_10 | (NFMT_USCALED << NFMT_SHIFT),
613 DFMT_2_10_10_10 | (NFMT_SSCALED << NFMT_SHIFT),
614 DFMT_2_10_10_10 | (NFMT_UINT << NFMT_SHIFT),
615 DFMT_2_10_10_10 | (NFMT_SINT << NFMT_SHIFT),
616
617 DFMT_8_8_8_8 | (NFMT_UNORM << NFMT_SHIFT),
618 DFMT_8_8_8_8 | (NFMT_SNORM << NFMT_SHIFT),
619 DFMT_8_8_8_8 | (NFMT_USCALED << NFMT_SHIFT),
620 DFMT_8_8_8_8 | (NFMT_SSCALED << NFMT_SHIFT),
621 DFMT_8_8_8_8 | (NFMT_UINT << NFMT_SHIFT),
622 DFMT_8_8_8_8 | (NFMT_SINT << NFMT_SHIFT),
623
624 DFMT_32_32 | (NFMT_UINT << NFMT_SHIFT),
625 DFMT_32_32 | (NFMT_SINT << NFMT_SHIFT),
626 DFMT_32_32 | (NFMT_FLOAT << NFMT_SHIFT),
627
628 DFMT_16_16_16_16 | (NFMT_UNORM << NFMT_SHIFT),
629 DFMT_16_16_16_16 | (NFMT_SNORM << NFMT_SHIFT),
630 DFMT_16_16_16_16 | (NFMT_USCALED << NFMT_SHIFT),
631 DFMT_16_16_16_16 | (NFMT_SSCALED << NFMT_SHIFT),
632 DFMT_16_16_16_16 | (NFMT_UINT << NFMT_SHIFT),
633 DFMT_16_16_16_16 | (NFMT_SINT << NFMT_SHIFT),
634 DFMT_16_16_16_16 | (NFMT_FLOAT << NFMT_SHIFT),
635
636 DFMT_32_32_32 | (NFMT_UINT << NFMT_SHIFT),
637 DFMT_32_32_32 | (NFMT_SINT << NFMT_SHIFT),
638 DFMT_32_32_32 | (NFMT_FLOAT << NFMT_SHIFT),
639 DFMT_32_32_32_32 | (NFMT_UINT << NFMT_SHIFT),
640 DFMT_32_32_32_32 | (NFMT_SINT << NFMT_SHIFT),
641 DFMT_32_32_32_32 | (NFMT_FLOAT << NFMT_SHIFT)
642};
643
644} // namespace MTBUFFormat
645
646namespace Swizzle {
647
648// This must be in sync with llvm::AMDGPU::Swizzle::Id enum members, see SIDefines.h.
649const char* const IdSymbolic[] = {
650 "QUAD_PERM",
651 "BITMASK_PERM",
652 "SWAP",
653 "REVERSE",
654 "BROADCAST",
655};
656
657} // namespace Swizzle
658
659namespace VGPRIndexMode {
660
661// This must be in sync with llvm::AMDGPU::VGPRIndexMode::Id enum members, see SIDefines.h.
662const char* const IdSymbolic[] = {
663 "SRC0",
664 "SRC1",
665 "SRC2",
666 "DST",
667};
668
669} // namespace VGPRIndexMode
670
671namespace UCVersion {
672
673ArrayRef<GFXVersion> getGFXVersions() {
674 // GFX6, GFX8 and GFX9 don't support s_version and there are no
675 // UC_VERSION_GFX* codes for them.
676 static const GFXVersion Versions[] = {{.Symbol: "UC_VERSION_GFX7", .Code: 0},
677 {.Symbol: "UC_VERSION_GFX10", .Code: 4},
678 {.Symbol: "UC_VERSION_GFX11", .Code: 6},
679 {.Symbol: "UC_VERSION_GFX12", .Code: 9}};
680
681 return Versions;
682}
683
684} // namespace UCVersion
685
686} // namespace llvm::AMDGPU
687