1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright (c) 2013 Rob Clark <robdclark@gmail.com>
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13bf215546Sopenharmony_ci * Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21bf215546Sopenharmony_ci * SOFTWARE.
22bf215546Sopenharmony_ci */
23bf215546Sopenharmony_ci
24bf215546Sopenharmony_ci#ifndef INSTR_A3XX_H_
25bf215546Sopenharmony_ci#define INSTR_A3XX_H_
26bf215546Sopenharmony_ci
27bf215546Sopenharmony_ci#define PACKED __attribute__((__packed__))
28bf215546Sopenharmony_ci
29bf215546Sopenharmony_ci#include <assert.h>
30bf215546Sopenharmony_ci#include <stdbool.h>
31bf215546Sopenharmony_ci#include <stdint.h>
32bf215546Sopenharmony_ci#include <stdio.h>
33bf215546Sopenharmony_ci
34bf215546Sopenharmony_ci/* clang-format off */
35bf215546Sopenharmony_civoid ir3_assert_handler(const char *expr, const char *file, int line,
36bf215546Sopenharmony_ci                        const char *func) __attribute__((weak)) __attribute__((__noreturn__));
37bf215546Sopenharmony_ci/* clang-format on */
38bf215546Sopenharmony_ci
39bf215546Sopenharmony_ci/* A wrapper for assert() that allows overriding handling of a failed
40bf215546Sopenharmony_ci * assert.  This is needed for tools like crashdec which can want to
41bf215546Sopenharmony_ci * attempt to disassemble memory that might not actually be valid
42bf215546Sopenharmony_ci * instructions.
43bf215546Sopenharmony_ci */
44bf215546Sopenharmony_ci#define ir3_assert(expr)                                                       \
45bf215546Sopenharmony_ci   do {                                                                        \
46bf215546Sopenharmony_ci      if (!(expr)) {                                                           \
47bf215546Sopenharmony_ci         if (ir3_assert_handler) {                                             \
48bf215546Sopenharmony_ci            ir3_assert_handler(#expr, __FILE__, __LINE__, __func__);           \
49bf215546Sopenharmony_ci         }                                                                     \
50bf215546Sopenharmony_ci         assert(expr);                                                         \
51bf215546Sopenharmony_ci      }                                                                        \
52bf215546Sopenharmony_ci   } while (0)
53bf215546Sopenharmony_ci/* size of largest OPC field of all the instruction categories: */
54bf215546Sopenharmony_ci#define NOPC_BITS 7
55bf215546Sopenharmony_ci
56bf215546Sopenharmony_ci#define _OPC(cat, opc) (((cat) << NOPC_BITS) | opc)
57bf215546Sopenharmony_ci
58bf215546Sopenharmony_ci/* clang-format off */
59bf215546Sopenharmony_citypedef enum {
60bf215546Sopenharmony_ci   /* category 0: */
61bf215546Sopenharmony_ci   OPC_NOP             = _OPC(0, 0),
62bf215546Sopenharmony_ci   OPC_B               = _OPC(0, 1),
63bf215546Sopenharmony_ci   OPC_JUMP            = _OPC(0, 2),
64bf215546Sopenharmony_ci   OPC_CALL            = _OPC(0, 3),
65bf215546Sopenharmony_ci   OPC_RET             = _OPC(0, 4),
66bf215546Sopenharmony_ci   OPC_KILL            = _OPC(0, 5),
67bf215546Sopenharmony_ci   OPC_END             = _OPC(0, 6),
68bf215546Sopenharmony_ci   OPC_EMIT            = _OPC(0, 7),
69bf215546Sopenharmony_ci   OPC_CUT             = _OPC(0, 8),
70bf215546Sopenharmony_ci   OPC_CHMASK          = _OPC(0, 9),
71bf215546Sopenharmony_ci   OPC_CHSH            = _OPC(0, 10),
72bf215546Sopenharmony_ci   OPC_FLOW_REV        = _OPC(0, 11),
73bf215546Sopenharmony_ci
74bf215546Sopenharmony_ci   OPC_BKT             = _OPC(0, 16),
75bf215546Sopenharmony_ci   OPC_STKS            = _OPC(0, 17),
76bf215546Sopenharmony_ci   OPC_STKR            = _OPC(0, 18),
77bf215546Sopenharmony_ci   OPC_XSET            = _OPC(0, 19),
78bf215546Sopenharmony_ci   OPC_XCLR            = _OPC(0, 20),
79bf215546Sopenharmony_ci   OPC_GETONE          = _OPC(0, 21),
80bf215546Sopenharmony_ci   OPC_DBG             = _OPC(0, 22),
81bf215546Sopenharmony_ci   OPC_SHPS            = _OPC(0, 23),   /* shader prologue start */
82bf215546Sopenharmony_ci   OPC_SHPE            = _OPC(0, 24),   /* shader prologue end */
83bf215546Sopenharmony_ci   OPC_GETLAST         = _OPC(0, 25),
84bf215546Sopenharmony_ci
85bf215546Sopenharmony_ci   OPC_PREDT           = _OPC(0, 29),   /* predicated true */
86bf215546Sopenharmony_ci   OPC_PREDF           = _OPC(0, 30),   /* predicated false */
87bf215546Sopenharmony_ci   OPC_PREDE           = _OPC(0, 31),   /* predicated end */
88bf215546Sopenharmony_ci
89bf215546Sopenharmony_ci   /* Logical opcodes for different branch instruction variations: */
90bf215546Sopenharmony_ci   OPC_BR              = _OPC(0, 40),
91bf215546Sopenharmony_ci   OPC_BRAO            = _OPC(0, 41),
92bf215546Sopenharmony_ci   OPC_BRAA            = _OPC(0, 42),
93bf215546Sopenharmony_ci   OPC_BRAC            = _OPC(0, 43),
94bf215546Sopenharmony_ci   OPC_BANY            = _OPC(0, 44),
95bf215546Sopenharmony_ci   OPC_BALL            = _OPC(0, 45),
96bf215546Sopenharmony_ci   OPC_BRAX            = _OPC(0, 46),
97bf215546Sopenharmony_ci
98bf215546Sopenharmony_ci   /* Logical opcode to distinguish kill and demote */
99bf215546Sopenharmony_ci   OPC_DEMOTE          = _OPC(0, 47),
100bf215546Sopenharmony_ci
101bf215546Sopenharmony_ci   /* category 1: */
102bf215546Sopenharmony_ci   OPC_MOV             = _OPC(1, 0),
103bf215546Sopenharmony_ci   OPC_MOVP            = _OPC(1, 1),
104bf215546Sopenharmony_ci   /* swz, gat, sct */
105bf215546Sopenharmony_ci   OPC_MOVMSK          = _OPC(1, 3),
106bf215546Sopenharmony_ci
107bf215546Sopenharmony_ci   /* Virtual opcodes for instructions differentiated via a "sub-opcode" that
108bf215546Sopenharmony_ci    * replaces the repeat field:
109bf215546Sopenharmony_ci    */
110bf215546Sopenharmony_ci   OPC_SWZ            = _OPC(1, 4),
111bf215546Sopenharmony_ci   OPC_GAT            = _OPC(1, 5),
112bf215546Sopenharmony_ci   OPC_SCT            = _OPC(1, 6),
113bf215546Sopenharmony_ci
114bf215546Sopenharmony_ci   /* Logical opcodes for different variants of mov: */
115bf215546Sopenharmony_ci   OPC_MOV_IMMED       = _OPC(1, 40),
116bf215546Sopenharmony_ci   OPC_MOV_CONST       = _OPC(1, 41),
117bf215546Sopenharmony_ci   OPC_MOV_GPR         = _OPC(1, 42),
118bf215546Sopenharmony_ci   OPC_MOV_RELGPR      = _OPC(1, 43),
119bf215546Sopenharmony_ci   OPC_MOV_RELCONST    = _OPC(1, 44),
120bf215546Sopenharmony_ci
121bf215546Sopenharmony_ci   /* Macros that expand to an if statement + move */
122bf215546Sopenharmony_ci   OPC_BALLOT_MACRO    = _OPC(1, 50),
123bf215546Sopenharmony_ci   OPC_ANY_MACRO       = _OPC(1, 51),
124bf215546Sopenharmony_ci   OPC_ALL_MACRO       = _OPC(1, 52),
125bf215546Sopenharmony_ci   OPC_ELECT_MACRO     = _OPC(1, 53),
126bf215546Sopenharmony_ci   OPC_READ_COND_MACRO = _OPC(1, 54),
127bf215546Sopenharmony_ci   OPC_READ_FIRST_MACRO = _OPC(1, 55),
128bf215546Sopenharmony_ci   OPC_SWZ_SHARED_MACRO = _OPC(1, 56),
129bf215546Sopenharmony_ci   OPC_SHPS_MACRO       = _OPC(1, 57),
130bf215546Sopenharmony_ci
131bf215546Sopenharmony_ci   /* Macros that expand to a loop */
132bf215546Sopenharmony_ci   OPC_SCAN_MACRO      = _OPC(1, 58),
133bf215546Sopenharmony_ci
134bf215546Sopenharmony_ci   /* category 2: */
135bf215546Sopenharmony_ci   OPC_ADD_F           = _OPC(2, 0),
136bf215546Sopenharmony_ci   OPC_MIN_F           = _OPC(2, 1),
137bf215546Sopenharmony_ci   OPC_MAX_F           = _OPC(2, 2),
138bf215546Sopenharmony_ci   OPC_MUL_F           = _OPC(2, 3),
139bf215546Sopenharmony_ci   OPC_SIGN_F          = _OPC(2, 4),
140bf215546Sopenharmony_ci   OPC_CMPS_F          = _OPC(2, 5),
141bf215546Sopenharmony_ci   OPC_ABSNEG_F        = _OPC(2, 6),
142bf215546Sopenharmony_ci   OPC_CMPV_F          = _OPC(2, 7),
143bf215546Sopenharmony_ci   /* 8 - invalid */
144bf215546Sopenharmony_ci   OPC_FLOOR_F         = _OPC(2, 9),
145bf215546Sopenharmony_ci   OPC_CEIL_F          = _OPC(2, 10),
146bf215546Sopenharmony_ci   OPC_RNDNE_F         = _OPC(2, 11),
147bf215546Sopenharmony_ci   OPC_RNDAZ_F         = _OPC(2, 12),
148bf215546Sopenharmony_ci   OPC_TRUNC_F         = _OPC(2, 13),
149bf215546Sopenharmony_ci   /* 14-15 - invalid */
150bf215546Sopenharmony_ci   OPC_ADD_U           = _OPC(2, 16),
151bf215546Sopenharmony_ci   OPC_ADD_S           = _OPC(2, 17),
152bf215546Sopenharmony_ci   OPC_SUB_U           = _OPC(2, 18),
153bf215546Sopenharmony_ci   OPC_SUB_S           = _OPC(2, 19),
154bf215546Sopenharmony_ci   OPC_CMPS_U          = _OPC(2, 20),
155bf215546Sopenharmony_ci   OPC_CMPS_S          = _OPC(2, 21),
156bf215546Sopenharmony_ci   OPC_MIN_U           = _OPC(2, 22),
157bf215546Sopenharmony_ci   OPC_MIN_S           = _OPC(2, 23),
158bf215546Sopenharmony_ci   OPC_MAX_U           = _OPC(2, 24),
159bf215546Sopenharmony_ci   OPC_MAX_S           = _OPC(2, 25),
160bf215546Sopenharmony_ci   OPC_ABSNEG_S        = _OPC(2, 26),
161bf215546Sopenharmony_ci   /* 27 - invalid */
162bf215546Sopenharmony_ci   OPC_AND_B           = _OPC(2, 28),
163bf215546Sopenharmony_ci   OPC_OR_B            = _OPC(2, 29),
164bf215546Sopenharmony_ci   OPC_NOT_B           = _OPC(2, 30),
165bf215546Sopenharmony_ci   OPC_XOR_B           = _OPC(2, 31),
166bf215546Sopenharmony_ci   /* 32 - invalid */
167bf215546Sopenharmony_ci   OPC_CMPV_U          = _OPC(2, 33),
168bf215546Sopenharmony_ci   OPC_CMPV_S          = _OPC(2, 34),
169bf215546Sopenharmony_ci   /* 35-47 - invalid */
170bf215546Sopenharmony_ci   OPC_MUL_U24         = _OPC(2, 48), /* 24b mul into 32b result */
171bf215546Sopenharmony_ci   OPC_MUL_S24         = _OPC(2, 49), /* 24b mul into 32b result with sign extension */
172bf215546Sopenharmony_ci   OPC_MULL_U          = _OPC(2, 50),
173bf215546Sopenharmony_ci   OPC_BFREV_B         = _OPC(2, 51),
174bf215546Sopenharmony_ci   OPC_CLZ_S           = _OPC(2, 52),
175bf215546Sopenharmony_ci   OPC_CLZ_B           = _OPC(2, 53),
176bf215546Sopenharmony_ci   OPC_SHL_B           = _OPC(2, 54),
177bf215546Sopenharmony_ci   OPC_SHR_B           = _OPC(2, 55),
178bf215546Sopenharmony_ci   OPC_ASHR_B          = _OPC(2, 56),
179bf215546Sopenharmony_ci   OPC_BARY_F          = _OPC(2, 57),
180bf215546Sopenharmony_ci   OPC_MGEN_B          = _OPC(2, 58),
181bf215546Sopenharmony_ci   OPC_GETBIT_B        = _OPC(2, 59),
182bf215546Sopenharmony_ci   OPC_SETRM           = _OPC(2, 60),
183bf215546Sopenharmony_ci   OPC_CBITS_B         = _OPC(2, 61),
184bf215546Sopenharmony_ci   OPC_SHB             = _OPC(2, 62),
185bf215546Sopenharmony_ci   OPC_MSAD            = _OPC(2, 63),
186bf215546Sopenharmony_ci   OPC_FLAT_B          = _OPC(2, 64),
187bf215546Sopenharmony_ci
188bf215546Sopenharmony_ci   /* category 3: */
189bf215546Sopenharmony_ci   OPC_MAD_U16         = _OPC(3, 0),
190bf215546Sopenharmony_ci   OPC_MADSH_U16       = _OPC(3, 1),
191bf215546Sopenharmony_ci   OPC_MAD_S16         = _OPC(3, 2),
192bf215546Sopenharmony_ci   OPC_MADSH_M16       = _OPC(3, 3),   /* should this be .s16? */
193bf215546Sopenharmony_ci   OPC_MAD_U24         = _OPC(3, 4),
194bf215546Sopenharmony_ci   OPC_MAD_S24         = _OPC(3, 5),
195bf215546Sopenharmony_ci   OPC_MAD_F16         = _OPC(3, 6),
196bf215546Sopenharmony_ci   OPC_MAD_F32         = _OPC(3, 7),
197bf215546Sopenharmony_ci   OPC_SEL_B16         = _OPC(3, 8),
198bf215546Sopenharmony_ci   OPC_SEL_B32         = _OPC(3, 9),
199bf215546Sopenharmony_ci   OPC_SEL_S16         = _OPC(3, 10),
200bf215546Sopenharmony_ci   OPC_SEL_S32         = _OPC(3, 11),
201bf215546Sopenharmony_ci   OPC_SEL_F16         = _OPC(3, 12),
202bf215546Sopenharmony_ci   OPC_SEL_F32         = _OPC(3, 13),
203bf215546Sopenharmony_ci   OPC_SAD_S16         = _OPC(3, 14),
204bf215546Sopenharmony_ci   OPC_SAD_S32         = _OPC(3, 15),
205bf215546Sopenharmony_ci   OPC_SHRM            = _OPC(3, 16),
206bf215546Sopenharmony_ci   OPC_SHLM            = _OPC(3, 17),
207bf215546Sopenharmony_ci   OPC_SHRG            = _OPC(3, 18),
208bf215546Sopenharmony_ci   OPC_SHLG            = _OPC(3, 19),
209bf215546Sopenharmony_ci   OPC_ANDG            = _OPC(3, 20),
210bf215546Sopenharmony_ci   OPC_DP2ACC          = _OPC(3, 21),
211bf215546Sopenharmony_ci   OPC_DP4ACC          = _OPC(3, 22),
212bf215546Sopenharmony_ci   OPC_WMM             = _OPC(3, 23),
213bf215546Sopenharmony_ci   OPC_WMM_ACCU        = _OPC(3, 24),
214bf215546Sopenharmony_ci
215bf215546Sopenharmony_ci   /* category 4: */
216bf215546Sopenharmony_ci   OPC_RCP             = _OPC(4, 0),
217bf215546Sopenharmony_ci   OPC_RSQ             = _OPC(4, 1),
218bf215546Sopenharmony_ci   OPC_LOG2            = _OPC(4, 2),
219bf215546Sopenharmony_ci   OPC_EXP2            = _OPC(4, 3),
220bf215546Sopenharmony_ci   OPC_SIN             = _OPC(4, 4),
221bf215546Sopenharmony_ci   OPC_COS             = _OPC(4, 5),
222bf215546Sopenharmony_ci   OPC_SQRT            = _OPC(4, 6),
223bf215546Sopenharmony_ci   /* NOTE that these are 8+opc from their highp equivs, so it's possible
224bf215546Sopenharmony_ci    * that the high order bit in the opc field has been repurposed for
225bf215546Sopenharmony_ci    * half-precision use?  But note that other ops (rcp/lsin/cos/sqrt)
226bf215546Sopenharmony_ci    * still use the same opc as highp
227bf215546Sopenharmony_ci    */
228bf215546Sopenharmony_ci   OPC_HRSQ            = _OPC(4, 9),
229bf215546Sopenharmony_ci   OPC_HLOG2           = _OPC(4, 10),
230bf215546Sopenharmony_ci   OPC_HEXP2           = _OPC(4, 11),
231bf215546Sopenharmony_ci
232bf215546Sopenharmony_ci   /* category 5: */
233bf215546Sopenharmony_ci   OPC_ISAM            = _OPC(5, 0),
234bf215546Sopenharmony_ci   OPC_ISAML           = _OPC(5, 1),
235bf215546Sopenharmony_ci   OPC_ISAMM           = _OPC(5, 2),
236bf215546Sopenharmony_ci   OPC_SAM             = _OPC(5, 3),
237bf215546Sopenharmony_ci   OPC_SAMB            = _OPC(5, 4),
238bf215546Sopenharmony_ci   OPC_SAML            = _OPC(5, 5),
239bf215546Sopenharmony_ci   OPC_SAMGQ           = _OPC(5, 6),
240bf215546Sopenharmony_ci   OPC_GETLOD          = _OPC(5, 7),
241bf215546Sopenharmony_ci   OPC_CONV            = _OPC(5, 8),
242bf215546Sopenharmony_ci   OPC_CONVM           = _OPC(5, 9),
243bf215546Sopenharmony_ci   OPC_GETSIZE         = _OPC(5, 10),
244bf215546Sopenharmony_ci   OPC_GETBUF          = _OPC(5, 11),
245bf215546Sopenharmony_ci   OPC_GETPOS          = _OPC(5, 12),
246bf215546Sopenharmony_ci   OPC_GETINFO         = _OPC(5, 13),
247bf215546Sopenharmony_ci   OPC_DSX             = _OPC(5, 14),
248bf215546Sopenharmony_ci   OPC_DSY             = _OPC(5, 15),
249bf215546Sopenharmony_ci   OPC_GATHER4R        = _OPC(5, 16),
250bf215546Sopenharmony_ci   OPC_GATHER4G        = _OPC(5, 17),
251bf215546Sopenharmony_ci   OPC_GATHER4B        = _OPC(5, 18),
252bf215546Sopenharmony_ci   OPC_GATHER4A        = _OPC(5, 19),
253bf215546Sopenharmony_ci   OPC_SAMGP0          = _OPC(5, 20),
254bf215546Sopenharmony_ci   OPC_SAMGP1          = _OPC(5, 21),
255bf215546Sopenharmony_ci   OPC_SAMGP2          = _OPC(5, 22),
256bf215546Sopenharmony_ci   OPC_SAMGP3          = _OPC(5, 23),
257bf215546Sopenharmony_ci   OPC_DSXPP_1         = _OPC(5, 24),
258bf215546Sopenharmony_ci   OPC_DSYPP_1         = _OPC(5, 25),
259bf215546Sopenharmony_ci   OPC_RGETPOS         = _OPC(5, 26),
260bf215546Sopenharmony_ci   OPC_RGETINFO        = _OPC(5, 27),
261bf215546Sopenharmony_ci   OPC_BRCST_ACTIVE    = _OPC(5, 28),
262bf215546Sopenharmony_ci   OPC_QUAD_SHUFFLE_BRCST  = _OPC(5, 29),
263bf215546Sopenharmony_ci   OPC_QUAD_SHUFFLE_HORIZ  = _OPC(5, 30),
264bf215546Sopenharmony_ci   OPC_QUAD_SHUFFLE_VERT   = _OPC(5, 31),
265bf215546Sopenharmony_ci   OPC_QUAD_SHUFFLE_DIAG   = _OPC(5, 32),
266bf215546Sopenharmony_ci   /* cat5 meta instructions, placed above the cat5 opc field's size */
267bf215546Sopenharmony_ci   OPC_DSXPP_MACRO     = _OPC(5, 35),
268bf215546Sopenharmony_ci   OPC_DSYPP_MACRO     = _OPC(5, 36),
269bf215546Sopenharmony_ci
270bf215546Sopenharmony_ci   /* category 6: */
271bf215546Sopenharmony_ci   OPC_LDG             = _OPC(6, 0),        /* load-global */
272bf215546Sopenharmony_ci   OPC_LDL             = _OPC(6, 1),
273bf215546Sopenharmony_ci   OPC_LDP             = _OPC(6, 2),
274bf215546Sopenharmony_ci   OPC_STG             = _OPC(6, 3),        /* store-global */
275bf215546Sopenharmony_ci   OPC_STL             = _OPC(6, 4),
276bf215546Sopenharmony_ci   OPC_STP             = _OPC(6, 5),
277bf215546Sopenharmony_ci   OPC_LDIB            = _OPC(6, 6),
278bf215546Sopenharmony_ci   OPC_G2L             = _OPC(6, 7),
279bf215546Sopenharmony_ci   OPC_L2G             = _OPC(6, 8),
280bf215546Sopenharmony_ci   OPC_PREFETCH        = _OPC(6, 9),
281bf215546Sopenharmony_ci   OPC_LDLW            = _OPC(6, 10),
282bf215546Sopenharmony_ci   OPC_STLW            = _OPC(6, 11),
283bf215546Sopenharmony_ci   OPC_RESFMT          = _OPC(6, 14),
284bf215546Sopenharmony_ci   OPC_RESINFO         = _OPC(6, 15),
285bf215546Sopenharmony_ci   OPC_ATOMIC_ADD      = _OPC(6, 16),
286bf215546Sopenharmony_ci   OPC_ATOMIC_SUB      = _OPC(6, 17),
287bf215546Sopenharmony_ci   OPC_ATOMIC_XCHG     = _OPC(6, 18),
288bf215546Sopenharmony_ci   OPC_ATOMIC_INC      = _OPC(6, 19),
289bf215546Sopenharmony_ci   OPC_ATOMIC_DEC      = _OPC(6, 20),
290bf215546Sopenharmony_ci   OPC_ATOMIC_CMPXCHG  = _OPC(6, 21),
291bf215546Sopenharmony_ci   OPC_ATOMIC_MIN      = _OPC(6, 22),
292bf215546Sopenharmony_ci   OPC_ATOMIC_MAX      = _OPC(6, 23),
293bf215546Sopenharmony_ci   OPC_ATOMIC_AND      = _OPC(6, 24),
294bf215546Sopenharmony_ci   OPC_ATOMIC_OR       = _OPC(6, 25),
295bf215546Sopenharmony_ci   OPC_ATOMIC_XOR      = _OPC(6, 26),
296bf215546Sopenharmony_ci   OPC_LDGB            = _OPC(6, 27),
297bf215546Sopenharmony_ci   OPC_STGB            = _OPC(6, 28),
298bf215546Sopenharmony_ci   OPC_STIB            = _OPC(6, 29),
299bf215546Sopenharmony_ci   OPC_LDC             = _OPC(6, 30),
300bf215546Sopenharmony_ci   OPC_LDLV            = _OPC(6, 31),
301bf215546Sopenharmony_ci   OPC_PIPR            = _OPC(6, 32), /* ??? */
302bf215546Sopenharmony_ci   OPC_PIPC            = _OPC(6, 33), /* ??? */
303bf215546Sopenharmony_ci   OPC_EMIT2           = _OPC(6, 34), /* ??? */
304bf215546Sopenharmony_ci   OPC_ENDLS           = _OPC(6, 35), /* ??? */
305bf215546Sopenharmony_ci   OPC_GETSPID         = _OPC(6, 36), /* SP ID */
306bf215546Sopenharmony_ci   OPC_GETWID          = _OPC(6, 37), /* wavefront ID */
307bf215546Sopenharmony_ci   OPC_GETFIBERID      = _OPC(6, 38), /* fiber ID */
308bf215546Sopenharmony_ci
309bf215546Sopenharmony_ci   /* Logical opcodes for things that differ in a6xx+ */
310bf215546Sopenharmony_ci   OPC_STC             = _OPC(6, 40),
311bf215546Sopenharmony_ci   OPC_RESINFO_B       = _OPC(6, 41),
312bf215546Sopenharmony_ci   OPC_LDIB_B          = _OPC(6, 42),
313bf215546Sopenharmony_ci   OPC_STIB_B          = _OPC(6, 43),
314bf215546Sopenharmony_ci
315bf215546Sopenharmony_ci   /* Logical opcodes for different atomic instruction variations: */
316bf215546Sopenharmony_ci   OPC_ATOMIC_B_ADD      = _OPC(6, 44),
317bf215546Sopenharmony_ci   OPC_ATOMIC_B_SUB      = _OPC(6, 45),
318bf215546Sopenharmony_ci   OPC_ATOMIC_B_XCHG     = _OPC(6, 46),
319bf215546Sopenharmony_ci   OPC_ATOMIC_B_INC      = _OPC(6, 47),
320bf215546Sopenharmony_ci   OPC_ATOMIC_B_DEC      = _OPC(6, 48),
321bf215546Sopenharmony_ci   OPC_ATOMIC_B_CMPXCHG  = _OPC(6, 49),
322bf215546Sopenharmony_ci   OPC_ATOMIC_B_MIN      = _OPC(6, 50),
323bf215546Sopenharmony_ci   OPC_ATOMIC_B_MAX      = _OPC(6, 51),
324bf215546Sopenharmony_ci   OPC_ATOMIC_B_AND      = _OPC(6, 52),
325bf215546Sopenharmony_ci   OPC_ATOMIC_B_OR       = _OPC(6, 53),
326bf215546Sopenharmony_ci   OPC_ATOMIC_B_XOR      = _OPC(6, 54),
327bf215546Sopenharmony_ci
328bf215546Sopenharmony_ci   OPC_ATOMIC_S_ADD      = _OPC(6, 55),
329bf215546Sopenharmony_ci   OPC_ATOMIC_S_SUB      = _OPC(6, 56),
330bf215546Sopenharmony_ci   OPC_ATOMIC_S_XCHG     = _OPC(6, 57),
331bf215546Sopenharmony_ci   OPC_ATOMIC_S_INC      = _OPC(6, 58),
332bf215546Sopenharmony_ci   OPC_ATOMIC_S_DEC      = _OPC(6, 59),
333bf215546Sopenharmony_ci   OPC_ATOMIC_S_CMPXCHG  = _OPC(6, 60),
334bf215546Sopenharmony_ci   OPC_ATOMIC_S_MIN      = _OPC(6, 61),
335bf215546Sopenharmony_ci   OPC_ATOMIC_S_MAX      = _OPC(6, 62),
336bf215546Sopenharmony_ci   OPC_ATOMIC_S_AND      = _OPC(6, 63),
337bf215546Sopenharmony_ci   OPC_ATOMIC_S_OR       = _OPC(6, 64),
338bf215546Sopenharmony_ci   OPC_ATOMIC_S_XOR      = _OPC(6, 65),
339bf215546Sopenharmony_ci
340bf215546Sopenharmony_ci   OPC_ATOMIC_G_ADD      = _OPC(6, 66),
341bf215546Sopenharmony_ci   OPC_ATOMIC_G_SUB      = _OPC(6, 67),
342bf215546Sopenharmony_ci   OPC_ATOMIC_G_XCHG     = _OPC(6, 68),
343bf215546Sopenharmony_ci   OPC_ATOMIC_G_INC      = _OPC(6, 69),
344bf215546Sopenharmony_ci   OPC_ATOMIC_G_DEC      = _OPC(6, 70),
345bf215546Sopenharmony_ci   OPC_ATOMIC_G_CMPXCHG  = _OPC(6, 71),
346bf215546Sopenharmony_ci   OPC_ATOMIC_G_MIN      = _OPC(6, 72),
347bf215546Sopenharmony_ci   OPC_ATOMIC_G_MAX      = _OPC(6, 73),
348bf215546Sopenharmony_ci   OPC_ATOMIC_G_AND      = _OPC(6, 74),
349bf215546Sopenharmony_ci   OPC_ATOMIC_G_OR       = _OPC(6, 75),
350bf215546Sopenharmony_ci   OPC_ATOMIC_G_XOR      = _OPC(6, 76),
351bf215546Sopenharmony_ci
352bf215546Sopenharmony_ci   OPC_LDG_A           = _OPC(6, 77),
353bf215546Sopenharmony_ci   OPC_STG_A           = _OPC(6, 78),
354bf215546Sopenharmony_ci
355bf215546Sopenharmony_ci   OPC_SPILL_MACRO     = _OPC(6, 79),
356bf215546Sopenharmony_ci   OPC_RELOAD_MACRO    = _OPC(6, 80),
357bf215546Sopenharmony_ci
358bf215546Sopenharmony_ci   OPC_LDC_K           = _OPC(6, 81),
359bf215546Sopenharmony_ci
360bf215546Sopenharmony_ci   /* category 7: */
361bf215546Sopenharmony_ci   OPC_BAR             = _OPC(7, 0),
362bf215546Sopenharmony_ci   OPC_FENCE           = _OPC(7, 1),
363bf215546Sopenharmony_ci
364bf215546Sopenharmony_ci   /* meta instructions (category -1): */
365bf215546Sopenharmony_ci   /* placeholder instr to mark shader inputs: */
366bf215546Sopenharmony_ci   OPC_META_INPUT      = _OPC(-1, 0),
367bf215546Sopenharmony_ci   /* The "collect" and "split" instructions are used for keeping
368bf215546Sopenharmony_ci    * track of instructions that write to multiple dst registers
369bf215546Sopenharmony_ci    * (split) like texture sample instructions, or read multiple
370bf215546Sopenharmony_ci    * consecutive scalar registers (collect) (bary.f, texture samp)
371bf215546Sopenharmony_ci    *
372bf215546Sopenharmony_ci    * A "split" extracts a scalar component from a vecN, and a
373bf215546Sopenharmony_ci    * "collect" gathers multiple scalar components into a vecN
374bf215546Sopenharmony_ci    */
375bf215546Sopenharmony_ci   OPC_META_SPLIT      = _OPC(-1, 2),
376bf215546Sopenharmony_ci   OPC_META_COLLECT    = _OPC(-1, 3),
377bf215546Sopenharmony_ci
378bf215546Sopenharmony_ci   /* placeholder for texture fetches that run before FS invocation
379bf215546Sopenharmony_ci    * starts:
380bf215546Sopenharmony_ci    */
381bf215546Sopenharmony_ci   OPC_META_TEX_PREFETCH = _OPC(-1, 4),
382bf215546Sopenharmony_ci
383bf215546Sopenharmony_ci   /* Parallel copies have multiple destinations, and copy each destination
384bf215546Sopenharmony_ci    * to its corresponding source. This happens "in parallel," meaning that
385bf215546Sopenharmony_ci    * it happens as-if every source is read first and then every destination
386bf215546Sopenharmony_ci    * is stored. These are produced in RA when register shuffling is
387bf215546Sopenharmony_ci    * required, and then lowered away immediately afterwards.
388bf215546Sopenharmony_ci    */
389bf215546Sopenharmony_ci   OPC_META_PARALLEL_COPY = _OPC(-1, 5),
390bf215546Sopenharmony_ci   OPC_META_PHI = _OPC(-1, 6),
391bf215546Sopenharmony_ci} opc_t;
392bf215546Sopenharmony_ci/* clang-format on */
393bf215546Sopenharmony_ci
394bf215546Sopenharmony_ci#define opc_cat(opc) ((int)((opc) >> NOPC_BITS))
395bf215546Sopenharmony_ci#define opc_op(opc)  ((unsigned)((opc) & ((1 << NOPC_BITS) - 1)))
396bf215546Sopenharmony_ci
397bf215546Sopenharmony_ciconst char *disasm_a3xx_instr_name(opc_t opc);
398bf215546Sopenharmony_ci
399bf215546Sopenharmony_citypedef enum {
400bf215546Sopenharmony_ci   TYPE_F16 = 0,
401bf215546Sopenharmony_ci   TYPE_F32 = 1,
402bf215546Sopenharmony_ci   TYPE_U16 = 2,
403bf215546Sopenharmony_ci   TYPE_U32 = 3,
404bf215546Sopenharmony_ci   TYPE_S16 = 4,
405bf215546Sopenharmony_ci   TYPE_S32 = 5,
406bf215546Sopenharmony_ci   TYPE_U8 = 6,
407bf215546Sopenharmony_ci   TYPE_S8 = 7, // XXX I assume?
408bf215546Sopenharmony_ci} type_t;
409bf215546Sopenharmony_ci
410bf215546Sopenharmony_cistatic inline uint32_t
411bf215546Sopenharmony_citype_size(type_t type)
412bf215546Sopenharmony_ci{
413bf215546Sopenharmony_ci   switch (type) {
414bf215546Sopenharmony_ci   case TYPE_F32:
415bf215546Sopenharmony_ci   case TYPE_U32:
416bf215546Sopenharmony_ci   case TYPE_S32:
417bf215546Sopenharmony_ci      return 32;
418bf215546Sopenharmony_ci   case TYPE_F16:
419bf215546Sopenharmony_ci   case TYPE_U16:
420bf215546Sopenharmony_ci   case TYPE_S16:
421bf215546Sopenharmony_ci      return 16;
422bf215546Sopenharmony_ci   case TYPE_U8:
423bf215546Sopenharmony_ci   case TYPE_S8:
424bf215546Sopenharmony_ci      return 8;
425bf215546Sopenharmony_ci   default:
426bf215546Sopenharmony_ci      ir3_assert(0); /* invalid type */
427bf215546Sopenharmony_ci      return 0;
428bf215546Sopenharmony_ci   }
429bf215546Sopenharmony_ci}
430bf215546Sopenharmony_ci
431bf215546Sopenharmony_cistatic inline type_t
432bf215546Sopenharmony_citype_uint_size(unsigned bit_size)
433bf215546Sopenharmony_ci{
434bf215546Sopenharmony_ci   switch (bit_size) {
435bf215546Sopenharmony_ci   case 8:  return TYPE_U8;
436bf215546Sopenharmony_ci   case 1:  /* 1b bools are treated as normal half-regs */
437bf215546Sopenharmony_ci   case 16: return TYPE_U16;
438bf215546Sopenharmony_ci   case 32: return TYPE_U32;
439bf215546Sopenharmony_ci   default:
440bf215546Sopenharmony_ci      ir3_assert(0); /* invalid size */
441bf215546Sopenharmony_ci      return 0;
442bf215546Sopenharmony_ci   }
443bf215546Sopenharmony_ci}
444bf215546Sopenharmony_ci
445bf215546Sopenharmony_cistatic inline type_t
446bf215546Sopenharmony_citype_float_size(unsigned bit_size)
447bf215546Sopenharmony_ci{
448bf215546Sopenharmony_ci   switch (bit_size) {
449bf215546Sopenharmony_ci   case 16: return TYPE_F16;
450bf215546Sopenharmony_ci   case 32: return TYPE_F32;
451bf215546Sopenharmony_ci   default:
452bf215546Sopenharmony_ci      ir3_assert(0); /* invalid size */
453bf215546Sopenharmony_ci      return 0;
454bf215546Sopenharmony_ci   }
455bf215546Sopenharmony_ci}
456bf215546Sopenharmony_ci
457bf215546Sopenharmony_cistatic inline int
458bf215546Sopenharmony_citype_float(type_t type)
459bf215546Sopenharmony_ci{
460bf215546Sopenharmony_ci   return (type == TYPE_F32) || (type == TYPE_F16);
461bf215546Sopenharmony_ci}
462bf215546Sopenharmony_ci
463bf215546Sopenharmony_cistatic inline int
464bf215546Sopenharmony_citype_uint(type_t type)
465bf215546Sopenharmony_ci{
466bf215546Sopenharmony_ci   return (type == TYPE_U32) || (type == TYPE_U16) || (type == TYPE_U8);
467bf215546Sopenharmony_ci}
468bf215546Sopenharmony_ci
469bf215546Sopenharmony_cistatic inline int
470bf215546Sopenharmony_citype_sint(type_t type)
471bf215546Sopenharmony_ci{
472bf215546Sopenharmony_ci   return (type == TYPE_S32) || (type == TYPE_S16) || (type == TYPE_S8);
473bf215546Sopenharmony_ci}
474bf215546Sopenharmony_ci
475bf215546Sopenharmony_citypedef enum {
476bf215546Sopenharmony_ci   ROUND_ZERO = 0,
477bf215546Sopenharmony_ci   ROUND_EVEN = 1,
478bf215546Sopenharmony_ci   ROUND_POS_INF = 2,
479bf215546Sopenharmony_ci   ROUND_NEG_INF = 3,
480bf215546Sopenharmony_ci} round_t;
481bf215546Sopenharmony_ci
482bf215546Sopenharmony_ci/* comp:
483bf215546Sopenharmony_ci *   0 - x
484bf215546Sopenharmony_ci *   1 - y
485bf215546Sopenharmony_ci *   2 - z
486bf215546Sopenharmony_ci *   3 - w
487bf215546Sopenharmony_ci */
488bf215546Sopenharmony_cistatic inline uint32_t
489bf215546Sopenharmony_ciregid(int num, int comp)
490bf215546Sopenharmony_ci{
491bf215546Sopenharmony_ci   return (num << 2) | (comp & 0x3);
492bf215546Sopenharmony_ci}
493bf215546Sopenharmony_ci
494bf215546Sopenharmony_ci#define INVALID_REG     regid(63, 0)
495bf215546Sopenharmony_ci#define VALIDREG(r)     ((r) != INVALID_REG)
496bf215546Sopenharmony_ci#define CONDREG(r, val) COND(VALIDREG(r), (val))
497bf215546Sopenharmony_ci
498bf215546Sopenharmony_ci/* special registers: */
499bf215546Sopenharmony_ci#define REG_A0 61 /* address register */
500bf215546Sopenharmony_ci#define REG_P0 62 /* predicate register */
501bf215546Sopenharmony_ci
502bf215546Sopenharmony_citypedef enum {
503bf215546Sopenharmony_ci   BRANCH_PLAIN = 0, /* br */
504bf215546Sopenharmony_ci   BRANCH_OR = 1,    /* brao */
505bf215546Sopenharmony_ci   BRANCH_AND = 2,   /* braa */
506bf215546Sopenharmony_ci   BRANCH_CONST = 3, /* brac */
507bf215546Sopenharmony_ci   BRANCH_ANY = 4,   /* bany */
508bf215546Sopenharmony_ci   BRANCH_ALL = 5,   /* ball */
509bf215546Sopenharmony_ci   BRANCH_X = 6,     /* brax ??? */
510bf215546Sopenharmony_ci} brtype_t;
511bf215546Sopenharmony_ci
512bf215546Sopenharmony_ci/* With is_bindless_s2en = 1, this determines whether bindless is enabled and
513bf215546Sopenharmony_ci * if so, how to get the (base, index) pair for both sampler and texture.
514bf215546Sopenharmony_ci * There is a single base embedded in the instruction, which is always used
515bf215546Sopenharmony_ci * for the texture.
516bf215546Sopenharmony_ci */
517bf215546Sopenharmony_citypedef enum {
518bf215546Sopenharmony_ci   /* Use traditional GL binding model, get texture and sampler index from src3
519bf215546Sopenharmony_ci    * which is presumed to be uniform on a4xx+ (a3xx doesn't have the other
520bf215546Sopenharmony_ci    * modes, but does handle non-uniform indexing).
521bf215546Sopenharmony_ci    */
522bf215546Sopenharmony_ci   CAT5_UNIFORM = 0,
523bf215546Sopenharmony_ci
524bf215546Sopenharmony_ci   /* The sampler base comes from the low 3 bits of a1.x, and the sampler
525bf215546Sopenharmony_ci    * and texture index come from src3 which is presumed to be uniform.
526bf215546Sopenharmony_ci    */
527bf215546Sopenharmony_ci   CAT5_BINDLESS_A1_UNIFORM = 1,
528bf215546Sopenharmony_ci
529bf215546Sopenharmony_ci   /* The texture and sampler share the same base, and the sampler and
530bf215546Sopenharmony_ci    * texture index come from src3 which is *not* presumed to be uniform.
531bf215546Sopenharmony_ci    */
532bf215546Sopenharmony_ci   CAT5_BINDLESS_NONUNIFORM = 2,
533bf215546Sopenharmony_ci
534bf215546Sopenharmony_ci   /* The sampler base comes from the low 3 bits of a1.x, and the sampler
535bf215546Sopenharmony_ci    * and texture index come from src3 which is *not* presumed to be
536bf215546Sopenharmony_ci    * uniform.
537bf215546Sopenharmony_ci    */
538bf215546Sopenharmony_ci   CAT5_BINDLESS_A1_NONUNIFORM = 3,
539bf215546Sopenharmony_ci
540bf215546Sopenharmony_ci   /* Use traditional GL binding model, get texture and sampler index
541bf215546Sopenharmony_ci    * from src3 which is *not* presumed to be uniform.
542bf215546Sopenharmony_ci    */
543bf215546Sopenharmony_ci   CAT5_NONUNIFORM = 4,
544bf215546Sopenharmony_ci
545bf215546Sopenharmony_ci   /* The texture and sampler share the same base, and the sampler and
546bf215546Sopenharmony_ci    * texture index come from src3 which is presumed to be uniform.
547bf215546Sopenharmony_ci    */
548bf215546Sopenharmony_ci   CAT5_BINDLESS_UNIFORM = 5,
549bf215546Sopenharmony_ci
550bf215546Sopenharmony_ci   /* The texture and sampler share the same base, get sampler index from low
551bf215546Sopenharmony_ci    * 4 bits of src3 and texture index from high 4 bits.
552bf215546Sopenharmony_ci    */
553bf215546Sopenharmony_ci   CAT5_BINDLESS_IMM = 6,
554bf215546Sopenharmony_ci
555bf215546Sopenharmony_ci   /* The sampler base comes from the low 3 bits of a1.x, and the texture
556bf215546Sopenharmony_ci    * index comes from the next 8 bits of a1.x. The sampler index is an
557bf215546Sopenharmony_ci    * immediate in src3.
558bf215546Sopenharmony_ci    */
559bf215546Sopenharmony_ci   CAT5_BINDLESS_A1_IMM = 7,
560bf215546Sopenharmony_ci} cat5_desc_mode_t;
561bf215546Sopenharmony_ci
562bf215546Sopenharmony_ci/* Similar to cat5_desc_mode_t, describes how the descriptor is loaded.
563bf215546Sopenharmony_ci */
564bf215546Sopenharmony_citypedef enum {
565bf215546Sopenharmony_ci   /* Use old GL binding model with an immediate index. */
566bf215546Sopenharmony_ci   CAT6_IMM = 0,
567bf215546Sopenharmony_ci
568bf215546Sopenharmony_ci   CAT6_UNIFORM = 1,
569bf215546Sopenharmony_ci
570bf215546Sopenharmony_ci   CAT6_NONUNIFORM = 2,
571bf215546Sopenharmony_ci
572bf215546Sopenharmony_ci   /* Use the bindless model, with an immediate index.
573bf215546Sopenharmony_ci    */
574bf215546Sopenharmony_ci   CAT6_BINDLESS_IMM = 4,
575bf215546Sopenharmony_ci
576bf215546Sopenharmony_ci   /* Use the bindless model, with a uniform register index.
577bf215546Sopenharmony_ci    */
578bf215546Sopenharmony_ci   CAT6_BINDLESS_UNIFORM = 5,
579bf215546Sopenharmony_ci
580bf215546Sopenharmony_ci   /* Use the bindless model, with a register index that isn't guaranteed
581bf215546Sopenharmony_ci    * to be uniform. This presumably checks if the indices are equal and
582bf215546Sopenharmony_ci    * splits up the load/store, because it works the way you would
583bf215546Sopenharmony_ci    * expect.
584bf215546Sopenharmony_ci    */
585bf215546Sopenharmony_ci   CAT6_BINDLESS_NONUNIFORM = 6,
586bf215546Sopenharmony_ci} cat6_desc_mode_t;
587bf215546Sopenharmony_ci
588bf215546Sopenharmony_cistatic inline bool
589bf215546Sopenharmony_ciis_sat_compatible(opc_t opc)
590bf215546Sopenharmony_ci{
591bf215546Sopenharmony_ci   /* On a6xx saturation doesn't work on cat4 */
592bf215546Sopenharmony_ci   if (opc_cat(opc) != 2 && opc_cat(opc) != 3)
593bf215546Sopenharmony_ci      return false;
594bf215546Sopenharmony_ci
595bf215546Sopenharmony_ci   switch (opc) {
596bf215546Sopenharmony_ci   /* On a3xx and a6xx saturation doesn't work on bary.f */
597bf215546Sopenharmony_ci   case OPC_BARY_F:
598bf215546Sopenharmony_ci   /* On a6xx saturation doesn't work on sel.* */
599bf215546Sopenharmony_ci   case OPC_SEL_B16:
600bf215546Sopenharmony_ci   case OPC_SEL_B32:
601bf215546Sopenharmony_ci   case OPC_SEL_S16:
602bf215546Sopenharmony_ci   case OPC_SEL_S32:
603bf215546Sopenharmony_ci   case OPC_SEL_F16:
604bf215546Sopenharmony_ci   case OPC_SEL_F32:
605bf215546Sopenharmony_ci      return false;
606bf215546Sopenharmony_ci   default:
607bf215546Sopenharmony_ci      return true;
608bf215546Sopenharmony_ci   }
609bf215546Sopenharmony_ci}
610bf215546Sopenharmony_ci
611bf215546Sopenharmony_cistatic inline bool
612bf215546Sopenharmony_ciis_mad(opc_t opc)
613bf215546Sopenharmony_ci{
614bf215546Sopenharmony_ci   switch (opc) {
615bf215546Sopenharmony_ci   case OPC_MAD_U16:
616bf215546Sopenharmony_ci   case OPC_MAD_S16:
617bf215546Sopenharmony_ci   case OPC_MAD_U24:
618bf215546Sopenharmony_ci   case OPC_MAD_S24:
619bf215546Sopenharmony_ci   case OPC_MAD_F16:
620bf215546Sopenharmony_ci   case OPC_MAD_F32:
621bf215546Sopenharmony_ci      return true;
622bf215546Sopenharmony_ci   default:
623bf215546Sopenharmony_ci      return false;
624bf215546Sopenharmony_ci   }
625bf215546Sopenharmony_ci}
626bf215546Sopenharmony_ci
627bf215546Sopenharmony_cistatic inline bool
628bf215546Sopenharmony_ciis_madsh(opc_t opc)
629bf215546Sopenharmony_ci{
630bf215546Sopenharmony_ci   switch (opc) {
631bf215546Sopenharmony_ci   case OPC_MADSH_U16:
632bf215546Sopenharmony_ci   case OPC_MADSH_M16:
633bf215546Sopenharmony_ci      return true;
634bf215546Sopenharmony_ci   default:
635bf215546Sopenharmony_ci      return false;
636bf215546Sopenharmony_ci   }
637bf215546Sopenharmony_ci}
638bf215546Sopenharmony_ci
639bf215546Sopenharmony_cistatic inline bool
640bf215546Sopenharmony_ciis_local_atomic(opc_t opc)
641bf215546Sopenharmony_ci{
642bf215546Sopenharmony_ci   switch (opc) {
643bf215546Sopenharmony_ci   case OPC_ATOMIC_ADD:
644bf215546Sopenharmony_ci   case OPC_ATOMIC_SUB:
645bf215546Sopenharmony_ci   case OPC_ATOMIC_XCHG:
646bf215546Sopenharmony_ci   case OPC_ATOMIC_INC:
647bf215546Sopenharmony_ci   case OPC_ATOMIC_DEC:
648bf215546Sopenharmony_ci   case OPC_ATOMIC_CMPXCHG:
649bf215546Sopenharmony_ci   case OPC_ATOMIC_MIN:
650bf215546Sopenharmony_ci   case OPC_ATOMIC_MAX:
651bf215546Sopenharmony_ci   case OPC_ATOMIC_AND:
652bf215546Sopenharmony_ci   case OPC_ATOMIC_OR:
653bf215546Sopenharmony_ci   case OPC_ATOMIC_XOR:
654bf215546Sopenharmony_ci      return true;
655bf215546Sopenharmony_ci   default:
656bf215546Sopenharmony_ci      return false;
657bf215546Sopenharmony_ci   }
658bf215546Sopenharmony_ci}
659bf215546Sopenharmony_ci
660bf215546Sopenharmony_cistatic inline bool
661bf215546Sopenharmony_ciis_global_a3xx_atomic(opc_t opc)
662bf215546Sopenharmony_ci{
663bf215546Sopenharmony_ci   switch (opc) {
664bf215546Sopenharmony_ci   case OPC_ATOMIC_S_ADD:
665bf215546Sopenharmony_ci   case OPC_ATOMIC_S_SUB:
666bf215546Sopenharmony_ci   case OPC_ATOMIC_S_XCHG:
667bf215546Sopenharmony_ci   case OPC_ATOMIC_S_INC:
668bf215546Sopenharmony_ci   case OPC_ATOMIC_S_DEC:
669bf215546Sopenharmony_ci   case OPC_ATOMIC_S_CMPXCHG:
670bf215546Sopenharmony_ci   case OPC_ATOMIC_S_MIN:
671bf215546Sopenharmony_ci   case OPC_ATOMIC_S_MAX:
672bf215546Sopenharmony_ci   case OPC_ATOMIC_S_AND:
673bf215546Sopenharmony_ci   case OPC_ATOMIC_S_OR:
674bf215546Sopenharmony_ci   case OPC_ATOMIC_S_XOR:
675bf215546Sopenharmony_ci      return true;
676bf215546Sopenharmony_ci   default:
677bf215546Sopenharmony_ci      return false;
678bf215546Sopenharmony_ci   }
679bf215546Sopenharmony_ci}
680bf215546Sopenharmony_ci
681bf215546Sopenharmony_cistatic inline bool
682bf215546Sopenharmony_ciis_global_a6xx_atomic(opc_t opc)
683bf215546Sopenharmony_ci{
684bf215546Sopenharmony_ci   switch (opc) {
685bf215546Sopenharmony_ci   case OPC_ATOMIC_G_ADD:
686bf215546Sopenharmony_ci   case OPC_ATOMIC_G_SUB:
687bf215546Sopenharmony_ci   case OPC_ATOMIC_G_XCHG:
688bf215546Sopenharmony_ci   case OPC_ATOMIC_G_INC:
689bf215546Sopenharmony_ci   case OPC_ATOMIC_G_DEC:
690bf215546Sopenharmony_ci   case OPC_ATOMIC_G_CMPXCHG:
691bf215546Sopenharmony_ci   case OPC_ATOMIC_G_MIN:
692bf215546Sopenharmony_ci   case OPC_ATOMIC_G_MAX:
693bf215546Sopenharmony_ci   case OPC_ATOMIC_G_AND:
694bf215546Sopenharmony_ci   case OPC_ATOMIC_G_OR:
695bf215546Sopenharmony_ci   case OPC_ATOMIC_G_XOR:
696bf215546Sopenharmony_ci      return true;
697bf215546Sopenharmony_ci   default:
698bf215546Sopenharmony_ci      return false;
699bf215546Sopenharmony_ci   }
700bf215546Sopenharmony_ci}
701bf215546Sopenharmony_ci
702bf215546Sopenharmony_cistatic inline bool
703bf215546Sopenharmony_ciis_bindless_atomic(opc_t opc)
704bf215546Sopenharmony_ci{
705bf215546Sopenharmony_ci   switch (opc) {
706bf215546Sopenharmony_ci   case OPC_ATOMIC_B_ADD:
707bf215546Sopenharmony_ci   case OPC_ATOMIC_B_SUB:
708bf215546Sopenharmony_ci   case OPC_ATOMIC_B_XCHG:
709bf215546Sopenharmony_ci   case OPC_ATOMIC_B_INC:
710bf215546Sopenharmony_ci   case OPC_ATOMIC_B_DEC:
711bf215546Sopenharmony_ci   case OPC_ATOMIC_B_CMPXCHG:
712bf215546Sopenharmony_ci   case OPC_ATOMIC_B_MIN:
713bf215546Sopenharmony_ci   case OPC_ATOMIC_B_MAX:
714bf215546Sopenharmony_ci   case OPC_ATOMIC_B_AND:
715bf215546Sopenharmony_ci   case OPC_ATOMIC_B_OR:
716bf215546Sopenharmony_ci   case OPC_ATOMIC_B_XOR:
717bf215546Sopenharmony_ci      return true;
718bf215546Sopenharmony_ci   default:
719bf215546Sopenharmony_ci      return false;
720bf215546Sopenharmony_ci   }
721bf215546Sopenharmony_ci}
722bf215546Sopenharmony_ci
723bf215546Sopenharmony_cistatic inline bool
724bf215546Sopenharmony_ciis_atomic(opc_t opc)
725bf215546Sopenharmony_ci{
726bf215546Sopenharmony_ci   return is_local_atomic(opc) || is_global_a3xx_atomic(opc) ||
727bf215546Sopenharmony_ci          is_global_a6xx_atomic(opc) || is_bindless_atomic(opc);
728bf215546Sopenharmony_ci}
729bf215546Sopenharmony_ci
730bf215546Sopenharmony_cistatic inline bool
731bf215546Sopenharmony_ciis_ssbo(opc_t opc)
732bf215546Sopenharmony_ci{
733bf215546Sopenharmony_ci   switch (opc) {
734bf215546Sopenharmony_ci   case OPC_RESFMT:
735bf215546Sopenharmony_ci   case OPC_RESINFO:
736bf215546Sopenharmony_ci   case OPC_LDGB:
737bf215546Sopenharmony_ci   case OPC_STGB:
738bf215546Sopenharmony_ci   case OPC_STIB:
739bf215546Sopenharmony_ci      return true;
740bf215546Sopenharmony_ci   default:
741bf215546Sopenharmony_ci      return false;
742bf215546Sopenharmony_ci   }
743bf215546Sopenharmony_ci}
744bf215546Sopenharmony_ci
745bf215546Sopenharmony_cistatic inline bool
746bf215546Sopenharmony_ciis_isam(opc_t opc)
747bf215546Sopenharmony_ci{
748bf215546Sopenharmony_ci   switch (opc) {
749bf215546Sopenharmony_ci   case OPC_ISAM:
750bf215546Sopenharmony_ci   case OPC_ISAML:
751bf215546Sopenharmony_ci   case OPC_ISAMM:
752bf215546Sopenharmony_ci      return true;
753bf215546Sopenharmony_ci   default:
754bf215546Sopenharmony_ci      return false;
755bf215546Sopenharmony_ci   }
756bf215546Sopenharmony_ci}
757bf215546Sopenharmony_ci
758bf215546Sopenharmony_cistatic inline bool
759bf215546Sopenharmony_ciis_cat2_float(opc_t opc)
760bf215546Sopenharmony_ci{
761bf215546Sopenharmony_ci   switch (opc) {
762bf215546Sopenharmony_ci   case OPC_ADD_F:
763bf215546Sopenharmony_ci   case OPC_MIN_F:
764bf215546Sopenharmony_ci   case OPC_MAX_F:
765bf215546Sopenharmony_ci   case OPC_MUL_F:
766bf215546Sopenharmony_ci   case OPC_SIGN_F:
767bf215546Sopenharmony_ci   case OPC_CMPS_F:
768bf215546Sopenharmony_ci   case OPC_ABSNEG_F:
769bf215546Sopenharmony_ci   case OPC_CMPV_F:
770bf215546Sopenharmony_ci   case OPC_FLOOR_F:
771bf215546Sopenharmony_ci   case OPC_CEIL_F:
772bf215546Sopenharmony_ci   case OPC_RNDNE_F:
773bf215546Sopenharmony_ci   case OPC_RNDAZ_F:
774bf215546Sopenharmony_ci   case OPC_TRUNC_F:
775bf215546Sopenharmony_ci      return true;
776bf215546Sopenharmony_ci
777bf215546Sopenharmony_ci   default:
778bf215546Sopenharmony_ci      return false;
779bf215546Sopenharmony_ci   }
780bf215546Sopenharmony_ci}
781bf215546Sopenharmony_ci
782bf215546Sopenharmony_cistatic inline bool
783bf215546Sopenharmony_ciis_cat3_float(opc_t opc)
784bf215546Sopenharmony_ci{
785bf215546Sopenharmony_ci   switch (opc) {
786bf215546Sopenharmony_ci   case OPC_MAD_F16:
787bf215546Sopenharmony_ci   case OPC_MAD_F32:
788bf215546Sopenharmony_ci   case OPC_SEL_F16:
789bf215546Sopenharmony_ci   case OPC_SEL_F32:
790bf215546Sopenharmony_ci      return true;
791bf215546Sopenharmony_ci   default:
792bf215546Sopenharmony_ci      return false;
793bf215546Sopenharmony_ci   }
794bf215546Sopenharmony_ci}
795bf215546Sopenharmony_ci
796bf215546Sopenharmony_ci#endif /* INSTR_A3XX_H_ */
797