1#include "util/macros.h"
2#include "disassemble.h"
3#define _BITS(bits, pos, width) (((bits) >> (pos)) & ((1 << (width)) - 1))
4static void
5bi_disasm_fma_arshift_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6{
7    static const char *lane2_table[] = {
8        "", ".b1", ".b2", ".b3"
9    };
10
11    const char *lane2 = lane2_table[_BITS(bits, 9, 2)];
12
13    fputs("*ARSHIFT.i32", fp);
14    fputs(" ", fp);
15    bi_disasm_dest_fma(fp, next_regs, last);
16    fputs(", ", fp);
17    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
18    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
19    fputs(", ", fp);
20    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
21    if (!(0x8 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
22    fputs(", ", fp);
23    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
24    fputs(lane2, fp);
25}
26
27static void
28bi_disasm_fma_arshift_v2i16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
29{
30    static const char *lanes2_table[] = {
31        ".b00", ".b11", ".b22", ".b33"
32    };
33    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
34    fputs("*ARSHIFT.v2i16", fp);
35    fputs(" ", fp);
36    bi_disasm_dest_fma(fp, next_regs, last);
37    fputs(", ", fp);
38    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
39    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
40    fputs(", ", fp);
41    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
42    if (!(0x8 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
43    fputs(", ", fp);
44    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
45    fputs(lanes2, fp);
46}
47
48static void
49bi_disasm_fma_arshift_v2i16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
50{
51    static const char *lanes2_table[] = {
52        ".reserved", ".b01", ".b23", ""
53    };
54    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
55    fputs("*ARSHIFT.v2i16", fp);
56    fputs(" ", fp);
57    bi_disasm_dest_fma(fp, next_regs, last);
58    fputs(", ", fp);
59    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
60    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
61    fputs(", ", fp);
62    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
63    if (!(0x8 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
64    fputs(", ", fp);
65    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
66    fputs(lanes2, fp);
67}
68
69static void
70bi_disasm_fma_arshift_v4i8_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
71{
72    static const char *lanes2_table[] = {
73        ".b0000", ".b1111", ".b2222", ".b3333"
74    };
75    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
76    fputs("*ARSHIFT.v4i8", fp);
77    fputs(" ", fp);
78    bi_disasm_dest_fma(fp, next_regs, last);
79    fputs(", ", fp);
80    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
81    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
82    fputs(", ", fp);
83    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
84    if (!(0x8 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
85    fputs(", ", fp);
86    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
87    fputs(lanes2, fp);
88}
89
90static void
91bi_disasm_fma_arshift_v4i8_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
92{
93    static const char *lanes2_table[] = {
94        ""
95    };
96    const char *lanes2 = lanes2_table[0];
97    fputs("*ARSHIFT.v4i8", fp);
98    fputs(" ", fp);
99    bi_disasm_dest_fma(fp, next_regs, last);
100    fputs(", ", fp);
101    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
102    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
103    fputs(", ", fp);
104    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
105    if (!(0x8 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
106    fputs(", ", fp);
107    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
108    fputs(lanes2, fp);
109}
110
111static void
112bi_disasm_fma_arshift_double_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
113{
114    static const char *bytes2_table[] = {
115        "", ".bytes2"
116    };
117
118    const char *bytes2 = bytes2_table[_BITS(bits, 9, 1)];
119
120    static const char *lane2_table[] = {
121        "", ".b2"
122    };
123
124    const char *lane2 = lane2_table[_BITS(bits, 10, 1)];
125
126    static const char *result_word_table[] = {
127        "", ".w1"
128    };
129
130    const char *result_word = result_word_table[_BITS(bits, 11, 1)];
131
132    fputs("*ARSHIFT_DOUBLE.i32", fp);
133    fputs(result_word, fp);
134    fputs(" ", fp);
135    bi_disasm_dest_fma(fp, next_regs, last);
136    fputs(", ", fp);
137    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
138    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
139    fputs(", ", fp);
140    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
141    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
142    fputs(", ", fp);
143    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
144    fputs(bytes2, fp);
145    fputs(lane2, fp);
146}
147
148static void
149bi_disasm_fma_atom_c_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
150{
151    static const char *atom_opc_table[] = {
152        ".reserved", ".reserved", ".aadd", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".asmin", ".asmax", ".aumin", ".aumax", ".aand", ".aor", ".axor", ".reserved"
153    };
154
155    const char *atom_opc = atom_opc_table[_BITS(bits, 9, 4)];
156
157    fputs("*ATOM_C.i32", fp);
158    fputs(atom_opc, fp);
159    fputs(" ", fp);
160    bi_disasm_dest_fma(fp, next_regs, last);
161    fputs(", ", fp);
162    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
163    if (!(0xf3 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
164    fputs(", ", fp);
165    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
166    if (!(0xf3 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
167    fputs(", ", fp);
168    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
169    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
170}
171
172static void
173bi_disasm_fma_atom_c_i64(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
174{
175    static const char *atom_opc_table[] = {
176        ".aaddu", ".aadds", ".aadd", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".asmin", ".asmax", ".aumin", ".aumax", ".aand", ".aor", ".axor", ".reserved"
177    };
178
179    const char *atom_opc = atom_opc_table[_BITS(bits, 9, 4)];
180
181    fputs("*ATOM_C.i64", fp);
182    fputs(atom_opc, fp);
183    fputs(" ", fp);
184    bi_disasm_dest_fma(fp, next_regs, last);
185    fputs(", ", fp);
186    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
187    if (!(0xf3 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
188    fputs(", ", fp);
189    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
190    if (!(0xf3 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
191    fputs(", ", fp);
192    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
193    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
194}
195
196static void
197bi_disasm_fma_atom_c1_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
198{
199    static const char *atom_opc_table[] = {
200        ".ainc", ".adec", ".aumax1", ".asmax1", ".aor1", ".reserved", ".reserved", ".reserved"
201    };
202
203    const char *atom_opc = atom_opc_table[_BITS(bits, 6, 3)];
204
205    fputs("*ATOM_C1.i32", fp);
206    fputs(atom_opc, fp);
207    fputs(" ", fp);
208    bi_disasm_dest_fma(fp, next_regs, last);
209    fputs(", ", fp);
210    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
211    if (!(0xf3 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
212    fputs(", ", fp);
213    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
214    if (!(0xf3 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
215}
216
217static void
218bi_disasm_fma_atom_c1_i64(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
219{
220    static const char *atom_opc_table[] = {
221        ".ainc", ".adec", ".aumax1", ".asmax1", ".aor1", ".reserved", ".reserved", ".reserved"
222    };
223
224    const char *atom_opc = atom_opc_table[_BITS(bits, 6, 3)];
225
226    fputs("*ATOM_C1.i64", fp);
227    fputs(atom_opc, fp);
228    fputs(" ", fp);
229    bi_disasm_dest_fma(fp, next_regs, last);
230    fputs(", ", fp);
231    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
232    if (!(0xf3 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
233    fputs(", ", fp);
234    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
235    if (!(0xf3 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
236}
237
238static void
239bi_disasm_fma_atom_c1_return_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
240{
241    static const char *atom_opc_table[] = {
242        ".ainc", ".adec", ".aumax1", ".asmax1", ".aor1", ".reserved", ".reserved", ".reserved"
243    };
244
245    const char *atom_opc = atom_opc_table[_BITS(bits, 6, 3)];
246
247    fputs("*ATOM_C1_RETURN.i32", fp);
248    fputs(atom_opc, fp);
249    fputs(" ", fp);
250    bi_disasm_dest_fma(fp, next_regs, last);
251    fputs(", ", fp);
252    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
253    if (!(0xf3 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
254    fputs(", ", fp);
255    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
256    if (!(0xf3 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
257}
258
259static void
260bi_disasm_fma_atom_c1_return_i64(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
261{
262    static const char *atom_opc_table[] = {
263        ".ainc", ".adec", ".aumax1", ".asmax1", ".aor1", ".reserved", ".reserved", ".reserved"
264    };
265
266    const char *atom_opc = atom_opc_table[_BITS(bits, 6, 3)];
267
268    fputs("*ATOM_C1_RETURN.i64", fp);
269    fputs(atom_opc, fp);
270    fputs(" ", fp);
271    bi_disasm_dest_fma(fp, next_regs, last);
272    fputs(", ", fp);
273    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
274    if (!(0xf3 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
275    fputs(", ", fp);
276    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
277    if (!(0xf3 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
278}
279
280static void
281bi_disasm_fma_atom_c_return_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
282{
283    static const char *atom_opc_table[] = {
284        ".reserved", ".reserved", ".aadd", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".asmin", ".asmax", ".aumin", ".aumax", ".aand", ".aor", ".axor", ".reserved"
285    };
286
287    const char *atom_opc = atom_opc_table[_BITS(bits, 9, 4)];
288
289    fputs("*ATOM_C_RETURN.i32", fp);
290    fputs(atom_opc, fp);
291    fputs(" ", fp);
292    bi_disasm_dest_fma(fp, next_regs, last);
293    fputs(", ", fp);
294    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
295    if (!(0xf3 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
296    fputs(", ", fp);
297    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
298    if (!(0xf3 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
299    fputs(", ", fp);
300    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
301    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
302}
303
304static void
305bi_disasm_fma_atom_c_return_i64(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
306{
307    static const char *atom_opc_table[] = {
308        ".aaddu", ".aadds", ".aadd", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".asmin", ".asmax", ".aumin", ".aumax", ".aand", ".aor", ".axor", ".reserved"
309    };
310
311    const char *atom_opc = atom_opc_table[_BITS(bits, 9, 4)];
312
313    fputs("*ATOM_C_RETURN.i64", fp);
314    fputs(atom_opc, fp);
315    fputs(" ", fp);
316    bi_disasm_dest_fma(fp, next_regs, last);
317    fputs(", ", fp);
318    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
319    if (!(0xf3 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
320    fputs(", ", fp);
321    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
322    if (!(0xf3 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
323    fputs(", ", fp);
324    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
325    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
326}
327
328static void
329bi_disasm_fma_atom_post_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
330{
331    static const char *atom_opc_table[] = {
332        ".reserved", ".reserved", ".aadd", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".asmin", ".asmax", ".aumin", ".aumax", ".aand", ".aor", ".axor", ".reserved"
333    };
334
335    const char *atom_opc = atom_opc_table[_BITS(bits, 6, 4)];
336
337    fputs("*ATOM_POST.i32", fp);
338    fputs(atom_opc, fp);
339    fputs(" ", fp);
340    bi_disasm_dest_fma(fp, next_regs, last);
341    fputs(", ", fp);
342    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
343    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
344    fputs(", ", fp);
345    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
346    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
347}
348
349static void
350bi_disasm_fma_atom_post_i64(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
351{
352    static const char *atom_opc_table[] = {
353        ".aaddu", ".aadds", ".aadd", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".asmin", ".asmax", ".aumin", ".aumax", ".aand", ".aor", ".axor", ".reserved"
354    };
355
356    const char *atom_opc = atom_opc_table[_BITS(bits, 6, 4)];
357
358    fputs("*ATOM_POST.i64", fp);
359    fputs(atom_opc, fp);
360    fputs(" ", fp);
361    bi_disasm_dest_fma(fp, next_regs, last);
362    fputs(", ", fp);
363    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
364    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
365    fputs(", ", fp);
366    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
367    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
368}
369
370static void
371bi_disasm_fma_atom_pre_i64(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
372{
373    static const char *atom_opc_table[] = {
374        ".aaddu", ".aadds", ".aadd", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".asmin", ".asmax", ".aumin", ".aumax", ".aand", ".aor", ".axor", ".reserved"
375    };
376
377    const char *atom_opc = atom_opc_table[_BITS(bits, 9, 4)];
378
379    fputs("*ATOM_PRE.i64", fp);
380    fputs(atom_opc, fp);
381    fputs(" ", fp);
382    bi_disasm_dest_fma(fp, next_regs, last);
383    fputs(", ", fp);
384    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
385    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
386    fputs(", ", fp);
387    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
388    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
389    fputs(", ", fp);
390    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
391}
392
393static void
394bi_disasm_fma_bitrev_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
395{
396    fputs("*BITREV.i32", fp);
397    fputs(" ", fp);
398    bi_disasm_dest_fma(fp, next_regs, last);
399    fputs(", ", fp);
400    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
401    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
402}
403
404static void
405bi_disasm_fma_clz_u32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
406{
407    static const char *mask_table[] = {
408        "", ".mask"
409    };
410
411    const char *mask = mask_table[_BITS(bits, 3, 1)];
412
413    fputs("*CLZ.u32", fp);
414    fputs(mask, fp);
415    fputs(" ", fp);
416    bi_disasm_dest_fma(fp, next_regs, last);
417    fputs(", ", fp);
418    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
419    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
420}
421
422static void
423bi_disasm_fma_clz_v2u16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
424{
425    static const char *mask_table[] = {
426        "", ".mask"
427    };
428
429    const char *mask = mask_table[_BITS(bits, 3, 1)];
430
431    static const char *swz0_table[] = {
432        ".h00", ".h10", "", ".h11"
433    };
434
435    const char *swz0 = swz0_table[_BITS(bits, 4, 2)];
436
437    fputs("*CLZ.v2u16", fp);
438    fputs(mask, fp);
439    fputs(" ", fp);
440    bi_disasm_dest_fma(fp, next_regs, last);
441    fputs(", ", fp);
442    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
443    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
444    fputs(swz0, fp);
445}
446
447static void
448bi_disasm_fma_clz_v4u8(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
449{
450    static const char *mask_table[] = {
451        "", ".mask"
452    };
453
454    const char *mask = mask_table[_BITS(bits, 3, 1)];
455
456    fputs("*CLZ.v4u8", fp);
457    fputs(mask, fp);
458    fputs(" ", fp);
459    bi_disasm_dest_fma(fp, next_regs, last);
460    fputs(", ", fp);
461    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
462    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
463}
464
465static void
466bi_disasm_fma_csel_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
467{
468    static const char *cmpf_table[] = {
469        ".eq", ".gt", ".ge", ".reserved"
470    };
471    const char *cmpf = cmpf_table[(_BITS(bits, 12, 2) << 0)];
472    fputs("*CSEL.f32", fp);
473    fputs(cmpf, fp);
474    fputs(" ", fp);
475    bi_disasm_dest_fma(fp, next_regs, last);
476    fputs(", ", fp);
477    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
478    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
479    fputs(", ", fp);
480    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
481    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
482    fputs(", ", fp);
483    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
484    fputs(", ", fp);
485    dump_src(fp, _BITS(bits, 9, 3), *srcs, branch_offset, consts, true);
486}
487
488static void
489bi_disasm_fma_csel_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
490{
491    static const char *cmpf_table[] = {
492        ".reserved", ".reserved", ".reserved", ".eq", ".reserved", ".reserved", ".reserved", ".reserved"
493    };
494    const char *cmpf = cmpf_table[(_BITS(bits, 12, 3) << 0)];
495    fputs("*CSEL.i32", fp);
496    fputs(cmpf, fp);
497    fputs(" ", fp);
498    bi_disasm_dest_fma(fp, next_regs, last);
499    fputs(", ", fp);
500    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
501    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
502    fputs(", ", fp);
503    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
504    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
505    fputs(", ", fp);
506    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
507    fputs(", ", fp);
508    dump_src(fp, _BITS(bits, 9, 3), *srcs, branch_offset, consts, true);
509}
510
511static void
512bi_disasm_fma_csel_s32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
513{
514    static const char *cmpf_table[] = {
515        ".gt", ".ge"
516    };
517    const char *cmpf = cmpf_table[(_BITS(bits, 12, 1) << 0)];
518    fputs("*CSEL.s32", fp);
519    fputs(cmpf, fp);
520    fputs(" ", fp);
521    bi_disasm_dest_fma(fp, next_regs, last);
522    fputs(", ", fp);
523    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
524    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
525    fputs(", ", fp);
526    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
527    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
528    fputs(", ", fp);
529    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
530    fputs(", ", fp);
531    dump_src(fp, _BITS(bits, 9, 3), *srcs, branch_offset, consts, true);
532}
533
534static void
535bi_disasm_fma_csel_u32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
536{
537    static const char *cmpf_table[] = {
538        ".gt", ".ge"
539    };
540    const char *cmpf = cmpf_table[(_BITS(bits, 12, 1) << 0)];
541    fputs("*CSEL.u32", fp);
542    fputs(cmpf, fp);
543    fputs(" ", fp);
544    bi_disasm_dest_fma(fp, next_regs, last);
545    fputs(", ", fp);
546    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
547    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
548    fputs(", ", fp);
549    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
550    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
551    fputs(", ", fp);
552    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
553    fputs(", ", fp);
554    dump_src(fp, _BITS(bits, 9, 3), *srcs, branch_offset, consts, true);
555}
556
557static void
558bi_disasm_fma_csel_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
559{
560    static const char *cmpf_table[] = {
561        ".eq", ".gt", ".ge", ".reserved"
562    };
563    const char *cmpf = cmpf_table[(_BITS(bits, 12, 2) << 0)];
564    fputs("*CSEL.v2f16", fp);
565    fputs(cmpf, fp);
566    fputs(" ", fp);
567    bi_disasm_dest_fma(fp, next_regs, last);
568    fputs(", ", fp);
569    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
570    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
571    fputs(", ", fp);
572    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
573    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
574    fputs(", ", fp);
575    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
576    fputs(", ", fp);
577    dump_src(fp, _BITS(bits, 9, 3), *srcs, branch_offset, consts, true);
578}
579
580static void
581bi_disasm_fma_csel_v2i16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
582{
583    static const char *cmpf_table[] = {
584        ".reserved", ".reserved", ".reserved", ".eq", ".reserved", ".reserved", ".reserved", ".reserved"
585    };
586    const char *cmpf = cmpf_table[(_BITS(bits, 12, 3) << 0)];
587    fputs("*CSEL.v2i16", fp);
588    fputs(cmpf, fp);
589    fputs(" ", fp);
590    bi_disasm_dest_fma(fp, next_regs, last);
591    fputs(", ", fp);
592    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
593    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
594    fputs(", ", fp);
595    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
596    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
597    fputs(", ", fp);
598    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
599    fputs(", ", fp);
600    dump_src(fp, _BITS(bits, 9, 3), *srcs, branch_offset, consts, true);
601}
602
603static void
604bi_disasm_fma_csel_v2s16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
605{
606    static const char *cmpf_table[] = {
607        ".gt", ".ge"
608    };
609    const char *cmpf = cmpf_table[(_BITS(bits, 12, 1) << 0)];
610    fputs("*CSEL.v2s16", fp);
611    fputs(cmpf, fp);
612    fputs(" ", fp);
613    bi_disasm_dest_fma(fp, next_regs, last);
614    fputs(", ", fp);
615    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
616    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
617    fputs(", ", fp);
618    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
619    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
620    fputs(", ", fp);
621    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
622    fputs(", ", fp);
623    dump_src(fp, _BITS(bits, 9, 3), *srcs, branch_offset, consts, true);
624}
625
626static void
627bi_disasm_fma_csel_v2u16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
628{
629    static const char *cmpf_table[] = {
630        ".gt", ".ge"
631    };
632    const char *cmpf = cmpf_table[(_BITS(bits, 12, 1) << 0)];
633    fputs("*CSEL.v2u16", fp);
634    fputs(cmpf, fp);
635    fputs(" ", fp);
636    bi_disasm_dest_fma(fp, next_regs, last);
637    fputs(", ", fp);
638    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
639    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
640    fputs(", ", fp);
641    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
642    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
643    fputs(", ", fp);
644    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
645    fputs(", ", fp);
646    dump_src(fp, _BITS(bits, 9, 3), *srcs, branch_offset, consts, true);
647}
648
649static void
650bi_disasm_fma_cubeface1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
651{
652    static const char *neg1_table[] = {
653        "", ".neg"
654    };
655    const char *neg1 = neg1_table[(_BITS(bits, 9, 1) << 0)];
656    static const char *neg0_table[] = {
657        "", ".neg"
658    };
659    const char *neg0 = neg0_table[(_BITS(bits, 9, 1) << 0)];
660    static const char *neg2_table[] = {
661        "", ".neg"
662    };
663    const char *neg2 = neg2_table[(_BITS(bits, 9, 1) << 0)];
664    fputs("*CUBEFACE1", fp);
665    fputs(" ", fp);
666    bi_disasm_dest_fma(fp, next_regs, last);
667    fputs(", ", fp);
668    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
669    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
670    fputs(neg0, fp);
671    fputs(", ", fp);
672    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
673    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
674    fputs(neg1, fp);
675    fputs(", ", fp);
676    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
677    fputs(neg2, fp);
678}
679
680static void
681bi_disasm_fma_dtsel_imm(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
682{
683    static const char *table_table[] = {
684        ".attribute_1", ".attribute_2", "", ".flat"
685    };
686
687    const char *table = table_table[_BITS(bits, 3, 2)];
688
689    fputs("*DTSEL_IMM", fp);
690    fputs(table, fp);
691    fputs(" ", fp);
692    bi_disasm_dest_fma(fp, next_regs, last);
693    fputs(", ", fp);
694    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
695    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
696}
697
698static void
699bi_disasm_fma_f16_to_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
700{
701    static const char *lane0_table[] = {
702        "", ".h1"
703    };
704
705    const char *lane0 = lane0_table[_BITS(bits, 3, 1)];
706
707    fputs("*F16_TO_F32", fp);
708    fputs(" ", fp);
709    bi_disasm_dest_fma(fp, next_regs, last);
710    fputs(", ", fp);
711    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
712    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
713    fputs(lane0, fp);
714}
715
716static void
717bi_disasm_fma_fadd_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
718{
719    static const char *widen1_table[] = {
720        "", ".h0", ".h1", ".h0", ".h1", ".h1", "", ""
721    };
722    const char *widen1 = widen1_table[(_BITS(bits, 9, 3) << 0)];
723    static const char *widen0_table[] = {
724        "", "", "", ".h0", ".h0", ".h1", ".h0", ".h1"
725    };
726    const char *widen0 = widen0_table[(_BITS(bits, 9, 3) << 0)];
727    static const char *abs1_table[] = {
728        "", ".abs"
729    };
730
731    const char *abs1 = abs1_table[_BITS(bits, 6, 1)];
732
733    static const char *neg0_table[] = {
734        "", ".neg"
735    };
736
737    const char *neg0 = neg0_table[_BITS(bits, 7, 1)];
738
739    static const char *neg1_table[] = {
740        "", ".neg"
741    };
742
743    const char *neg1 = neg1_table[_BITS(bits, 8, 1)];
744
745    static const char *abs0_table[] = {
746        "", ".abs"
747    };
748
749    const char *abs0 = abs0_table[_BITS(bits, 12, 1)];
750
751    static const char *round_table[] = {
752        "", ".rtp", ".rtn", ".rtz"
753    };
754
755    const char *round = round_table[_BITS(bits, 13, 2)];
756
757    static const char *clamp_table[] = {
758        "", ".clamp_0_inf", ".clamp_m1_1", ".clamp_0_1"
759    };
760
761    const char *clamp = clamp_table[_BITS(bits, 15, 2)];
762
763    fputs("*FADD.f32", fp);
764    fputs(round, fp);
765    fputs(clamp, fp);
766    fputs(" ", fp);
767    bi_disasm_dest_fma(fp, next_regs, last);
768    fputs(", ", fp);
769    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
770    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
771    fputs(neg0, fp);
772    fputs(abs0, fp);
773    fputs(widen0, fp);
774    fputs(", ", fp);
775    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
776    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
777    fputs(abs1, fp);
778    fputs(neg1, fp);
779    fputs(widen1, fp);
780}
781
782static void
783bi_disasm_fma_fadd_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
784{
785    bool ordering = (_BITS(bits, 0, 3) > _BITS(bits, 3, 3));
786    static const char *abs0_0[] = {
787        "", ".abs"
788    };
789    static const char *abs0_1[] = {
790        ".abs", ".abs"
791    };
792    const char *abs0 = ordering ? abs0_1[(_BITS(bits, 6, 1) << 0)] : abs0_0[(_BITS(bits, 6, 1) << 0)];
793    static const char *abs1_0[] = {
794        "", ""
795    };
796    static const char *abs1_1[] = {
797        "", ".abs"
798    };
799    const char *abs1 = ordering ? abs1_1[(_BITS(bits, 6, 1) << 0)] : abs1_0[(_BITS(bits, 6, 1) << 0)];
800    static const char *neg0_table[] = {
801        "", ".neg"
802    };
803
804    const char *neg0 = neg0_table[_BITS(bits, 7, 1)];
805
806    static const char *neg1_table[] = {
807        "", ".neg"
808    };
809
810    const char *neg1 = neg1_table[_BITS(bits, 8, 1)];
811
812    static const char *swz0_table[] = {
813        ".h00", ".h10", "", ".h11"
814    };
815
816    const char *swz0 = swz0_table[_BITS(bits, 9, 2)];
817
818    static const char *swz1_table[] = {
819        ".h00", ".h10", "", ".h11"
820    };
821
822    const char *swz1 = swz1_table[_BITS(bits, 11, 2)];
823
824    static const char *round_table[] = {
825        "", ".rtp", ".rtn", ".rtz"
826    };
827
828    const char *round = round_table[_BITS(bits, 13, 2)];
829
830    static const char *clamp_table[] = {
831        "", ".clamp_0_inf", ".clamp_m1_1", ".clamp_0_1"
832    };
833
834    const char *clamp = clamp_table[_BITS(bits, 15, 2)];
835
836    fputs("*FADD.v2f16", fp);
837    fputs(round, fp);
838    fputs(clamp, fp);
839    fputs(" ", fp);
840    bi_disasm_dest_fma(fp, next_regs, last);
841    fputs(", ", fp);
842    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
843    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
844    fputs(abs0, fp);
845    fputs(neg0, fp);
846    fputs(swz0, fp);
847    fputs(", ", fp);
848    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
849    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
850    fputs(abs1, fp);
851    fputs(neg1, fp);
852    fputs(swz1, fp);
853}
854
855static void
856bi_disasm_fma_fadd_lscale_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
857{
858    static const char *abs0_table[] = {
859        "", ".abs"
860    };
861
862    const char *abs0 = abs0_table[_BITS(bits, 6, 1)];
863
864    static const char *neg0_table[] = {
865        "", ".neg"
866    };
867
868    const char *neg0 = neg0_table[_BITS(bits, 7, 1)];
869
870    static const char *abs1_table[] = {
871        "", ".abs"
872    };
873
874    const char *abs1 = abs1_table[_BITS(bits, 8, 1)];
875
876    static const char *neg1_table[] = {
877        "", ".neg"
878    };
879
880    const char *neg1 = neg1_table[_BITS(bits, 9, 1)];
881
882    fputs("*FADD_LSCALE.f32", fp);
883    fputs(" ", fp);
884    bi_disasm_dest_fma(fp, next_regs, last);
885    fputs(", ", fp);
886    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
887    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
888    fputs(abs0, fp);
889    fputs(neg0, fp);
890    fputs(", ", fp);
891    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
892    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
893    fputs(abs1, fp);
894    fputs(neg1, fp);
895}
896
897static void
898bi_disasm_fma_fcmp_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
899{
900    static const char *widen1_table[] = {
901        "", ".h0", ".h1", ".h0", ".h1", ".h1", "", ""
902    };
903    const char *widen1 = widen1_table[(_BITS(bits, 9, 3) << 0)];
904    static const char *widen0_table[] = {
905        "", "", "", ".h0", ".h0", ".h1", ".h0", ".h1"
906    };
907    const char *widen0 = widen0_table[(_BITS(bits, 9, 3) << 0)];
908    static const char *abs1_table[] = {
909        "", ".abs"
910    };
911
912    const char *abs1 = abs1_table[_BITS(bits, 6, 1)];
913
914    static const char *neg0_table[] = {
915        "", ".neg"
916    };
917
918    const char *neg0 = neg0_table[_BITS(bits, 7, 1)];
919
920    static const char *neg1_table[] = {
921        "", ".neg"
922    };
923
924    const char *neg1 = neg1_table[_BITS(bits, 8, 1)];
925
926    static const char *abs0_table[] = {
927        "", ".abs"
928    };
929
930    const char *abs0 = abs0_table[_BITS(bits, 12, 1)];
931
932    static const char *cmpf_table[] = {
933        ".eq", ".gt", ".ge", ".ne", ".lt", ".le", ".gtlt", ".total"
934    };
935
936    const char *cmpf = cmpf_table[_BITS(bits, 13, 3)];
937
938    static const char *result_type_table[] = {
939        "", ".f1", ".m1", ".reserved"
940    };
941
942    const char *result_type = result_type_table[_BITS(bits, 16, 2)];
943
944    fputs("*FCMP.f32", fp);
945    fputs(cmpf, fp);
946    fputs(result_type, fp);
947    fputs(" ", fp);
948    bi_disasm_dest_fma(fp, next_regs, last);
949    fputs(", ", fp);
950    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
951    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
952    fputs(widen0, fp);
953    fputs(neg0, fp);
954    fputs(abs0, fp);
955    fputs(", ", fp);
956    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
957    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
958    fputs(widen1, fp);
959    fputs(abs1, fp);
960    fputs(neg1, fp);
961}
962
963static void
964bi_disasm_fma_fcmp_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
965{
966    bool ordering = (_BITS(bits, 0, 3) > _BITS(bits, 3, 3));
967    static const char *abs0_0[] = {
968        "", ".abs", "", ".abs", "", ".abs", "", ".abs", "", ".abs", "", ".abs", "", ".abs", "", ".reserved"
969    };
970    static const char *abs0_1[] = {
971        ".abs", ".abs", ".abs", ".abs", ".abs", ".abs", ".abs", ".abs", ".abs", ".abs", ".abs", ".abs", ".abs", ".abs", ".reserved", ".reserved"
972    };
973    const char *abs0 = ordering ? abs0_1[(_BITS(bits, 6, 1) << 0) | (_BITS(bits, 13, 3) << 1)] : abs0_0[(_BITS(bits, 6, 1) << 0) | (_BITS(bits, 13, 3) << 1)];
974    static const char *cmpf_0[] = {
975        ".eq", ".eq", ".gt", ".gt", ".ge", ".ge", ".ne", ".ne", ".lt", ".lt", ".le", ".le", ".gtlt", ".gtlt", ".total", ".reserved"
976    };
977    static const char *cmpf_1[] = {
978        ".eq", ".eq", ".gt", ".gt", ".ge", ".ge", ".ne", ".ne", ".lt", ".lt", ".le", ".le", ".gtlt", ".gtlt", ".reserved", ".reserved"
979    };
980    const char *cmpf = ordering ? cmpf_1[(_BITS(bits, 6, 1) << 0) | (_BITS(bits, 13, 3) << 1)] : cmpf_0[(_BITS(bits, 6, 1) << 0) | (_BITS(bits, 13, 3) << 1)];
981    static const char *abs1_0[] = {
982        "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ".reserved"
983    };
984    static const char *abs1_1[] = {
985        "", ".abs", "", ".abs", "", ".abs", "", ".abs", "", ".abs", "", ".abs", "", ".abs", ".reserved", ".reserved"
986    };
987    const char *abs1 = ordering ? abs1_1[(_BITS(bits, 6, 1) << 0) | (_BITS(bits, 13, 3) << 1)] : abs1_0[(_BITS(bits, 6, 1) << 0) | (_BITS(bits, 13, 3) << 1)];
988    static const char *neg0_table[] = {
989        "", ".neg"
990    };
991
992    const char *neg0 = neg0_table[_BITS(bits, 7, 1)];
993
994    static const char *neg1_table[] = {
995        "", ".neg"
996    };
997
998    const char *neg1 = neg1_table[_BITS(bits, 8, 1)];
999
1000    static const char *swz0_table[] = {
1001        ".h00", ".h10", "", ".h11"
1002    };
1003
1004    const char *swz0 = swz0_table[_BITS(bits, 9, 2)];
1005
1006    static const char *swz1_table[] = {
1007        ".h00", ".h10", "", ".h11"
1008    };
1009
1010    const char *swz1 = swz1_table[_BITS(bits, 11, 2)];
1011
1012    static const char *result_type_table[] = {
1013        "", ".f1", ".m1", ".reserved"
1014    };
1015
1016    const char *result_type = result_type_table[_BITS(bits, 16, 2)];
1017
1018    fputs("*FCMP.v2f16", fp);
1019    fputs(cmpf, fp);
1020    fputs(result_type, fp);
1021    fputs(" ", fp);
1022    bi_disasm_dest_fma(fp, next_regs, last);
1023    fputs(", ", fp);
1024    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1025    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1026    fputs(abs0, fp);
1027    fputs(neg0, fp);
1028    fputs(swz0, fp);
1029    fputs(", ", fp);
1030    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
1031    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
1032    fputs(abs1, fp);
1033    fputs(neg1, fp);
1034    fputs(swz1, fp);
1035}
1036
1037static void
1038bi_disasm_fma_flshift_double_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1039{
1040    static const char *bytes2_table[] = {
1041        "", ".bytes2"
1042    };
1043
1044    const char *bytes2 = bytes2_table[_BITS(bits, 9, 1)];
1045
1046    static const char *lane2_table[] = {
1047        "", ".b2"
1048    };
1049
1050    const char *lane2 = lane2_table[_BITS(bits, 10, 1)];
1051
1052    fputs("*FLSHIFT_DOUBLE.i32", fp);
1053    fputs(" ", fp);
1054    bi_disasm_dest_fma(fp, next_regs, last);
1055    fputs(", ", fp);
1056    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1057    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1058    fputs(", ", fp);
1059    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
1060    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
1061    fputs(", ", fp);
1062    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
1063    fputs(bytes2, fp);
1064    fputs(lane2, fp);
1065}
1066
1067static void
1068bi_disasm_fma_fma_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1069{
1070    static const char *neg1_table[] = {
1071        "", "", "", "", "", "", "", "", ".neg", ".neg", ".neg", ".neg", ".neg", ".neg", ".neg", ".neg"
1072    };
1073    const char *neg1 = neg1_table[(_BITS(bits, 9, 3) << 0) | (_BITS(bits, 17, 1) << 3)];
1074    static const char *neg0_table[] = {
1075        "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""
1076    };
1077    const char *neg0 = neg0_table[(_BITS(bits, 9, 3) << 0) | (_BITS(bits, 17, 1) << 3)];
1078    static const char *widen1_table[] = {
1079        "", ".h0", ".h1", ".h0", ".h1", ".h1", "", "", "", ".h0", ".h1", ".h0", ".h1", ".h1", "", ""
1080    };
1081    const char *widen1 = widen1_table[(_BITS(bits, 9, 3) << 0) | (_BITS(bits, 17, 1) << 3)];
1082    static const char *widen0_table[] = {
1083        "", "", "", ".h0", ".h0", ".h1", ".h0", ".h1", "", "", "", ".h0", ".h0", ".h1", ".h0", ".h1"
1084    };
1085    const char *widen0 = widen0_table[(_BITS(bits, 9, 3) << 0) | (_BITS(bits, 17, 1) << 3)];
1086    static const char *abs0_table[] = {
1087        "", ".abs"
1088    };
1089
1090    const char *abs0 = abs0_table[_BITS(bits, 12, 1)];
1091
1092    static const char *round_table[] = {
1093        "", ".rtp", ".rtn", ".rtz"
1094    };
1095
1096    const char *round = round_table[_BITS(bits, 13, 2)];
1097
1098    static const char *clamp_table[] = {
1099        "", ".clamp_0_inf", ".clamp_m1_1", ".clamp_0_1"
1100    };
1101
1102    const char *clamp = clamp_table[_BITS(bits, 15, 2)];
1103
1104    static const char *abs1_table[] = {
1105        "", ".abs"
1106    };
1107
1108    const char *abs1 = abs1_table[_BITS(bits, 19, 1)];
1109
1110    static const char *neg2_table[] = {
1111        "", ".neg"
1112    };
1113
1114    const char *neg2 = neg2_table[_BITS(bits, 18, 1)];
1115
1116    static const char *abs2_table[] = {
1117        "", ".abs"
1118    };
1119
1120    const char *abs2 = abs2_table[_BITS(bits, 20, 1)];
1121
1122    fputs("*FMA.f32", fp);
1123    fputs(round, fp);
1124    fputs(clamp, fp);
1125    fputs(" ", fp);
1126    bi_disasm_dest_fma(fp, next_regs, last);
1127    fputs(", ", fp);
1128    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1129    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1130    fputs(widen0, fp);
1131    fputs(neg0, fp);
1132    fputs(abs0, fp);
1133    fputs(", ", fp);
1134    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
1135    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
1136    fputs(widen1, fp);
1137    fputs(neg1, fp);
1138    fputs(abs1, fp);
1139    fputs(", ", fp);
1140    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
1141    fputs(neg2, fp);
1142    fputs(abs2, fp);
1143}
1144
1145static void
1146bi_disasm_fma_fma_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1147{
1148    static const char *neg1_table[] = {
1149        "", ".neg"
1150    };
1151    const char *neg1 = neg1_table[(_BITS(bits, 17, 1) << 0)];
1152    static const char *neg0_table[] = {
1153        "", ""
1154    };
1155    const char *neg0 = neg0_table[(_BITS(bits, 17, 1) << 0)];
1156    static const char *swz0_table[] = {
1157        ".h00", ".h10", "", ".h11"
1158    };
1159
1160    const char *swz0 = swz0_table[_BITS(bits, 9, 2)];
1161
1162    static const char *swz1_table[] = {
1163        ".h00", ".h10", "", ".h11"
1164    };
1165
1166    const char *swz1 = swz1_table[_BITS(bits, 11, 2)];
1167
1168    static const char *round_table[] = {
1169        "", ".rtp", ".rtn", ".rtz"
1170    };
1171
1172    const char *round = round_table[_BITS(bits, 13, 2)];
1173
1174    static const char *clamp_table[] = {
1175        "", ".clamp_0_inf", ".clamp_m1_1", ".clamp_0_1"
1176    };
1177
1178    const char *clamp = clamp_table[_BITS(bits, 15, 2)];
1179
1180    static const char *neg2_table[] = {
1181        "", ".neg"
1182    };
1183
1184    const char *neg2 = neg2_table[_BITS(bits, 18, 1)];
1185
1186    static const char *swz2_table[] = {
1187        ".h00", ".h10", "", ".h11"
1188    };
1189
1190    const char *swz2 = swz2_table[_BITS(bits, 19, 2)];
1191
1192    fputs("*FMA.v2f16", fp);
1193    fputs(round, fp);
1194    fputs(clamp, fp);
1195    fputs(" ", fp);
1196    bi_disasm_dest_fma(fp, next_regs, last);
1197    fputs(", ", fp);
1198    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1199    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1200    fputs(neg0, fp);
1201    fputs(swz0, fp);
1202    fputs(", ", fp);
1203    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
1204    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
1205    fputs(neg1, fp);
1206    fputs(swz1, fp);
1207    fputs(", ", fp);
1208    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
1209    fputs(neg2, fp);
1210    fputs(swz2, fp);
1211}
1212
1213static void
1214bi_disasm_fma_fma_rscale_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1215{
1216    static const char *neg1_table[] = {
1217        "", ".neg", "", ".neg", "", ".neg", "", ".neg", "", ".neg", "", ".neg", "", ".neg", "", ".neg"
1218    };
1219    const char *neg1 = neg1_table[(_BITS(bits, 16, 1) << 0) | (_BITS(bits, 12, 3) << 1)];
1220    static const char *neg0_table[] = {
1221        "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""
1222    };
1223    const char *neg0 = neg0_table[(_BITS(bits, 16, 1) << 0) | (_BITS(bits, 12, 3) << 1)];
1224    static const char *round_table[] = {
1225        "", "", "", "", "", "", "", "", "", "", ".rtz", ".rtz", "", "", "", ""
1226    };
1227    const char *round = round_table[(_BITS(bits, 16, 1) << 0) | (_BITS(bits, 12, 3) << 1)];
1228    static const char *special_table[] = {
1229        "", "", "", "", "", "", "", "", ".n", ".n", ".n", ".n", ".scale16", ".scale16", ".left", ".left"
1230    };
1231    const char *special = special_table[(_BITS(bits, 16, 1) << 0) | (_BITS(bits, 12, 3) << 1)];
1232    static const char *clamp_table[] = {
1233        "", "", ".clamp_0_inf", ".clamp_0_inf", ".clamp_m1_1", ".clamp_m1_1", ".clamp_0_1", ".clamp_0_1", "", "", "", "", "", "", "", ""
1234    };
1235    const char *clamp = clamp_table[(_BITS(bits, 16, 1) << 0) | (_BITS(bits, 12, 3) << 1)];
1236    static const char *abs0_table[] = {
1237        "", ".abs"
1238    };
1239
1240    const char *abs0 = abs0_table[_BITS(bits, 15, 1)];
1241
1242    static const char *neg2_table[] = {
1243        "", ".neg"
1244    };
1245
1246    const char *neg2 = neg2_table[_BITS(bits, 17, 1)];
1247
1248    fputs("*FMA_RSCALE.f32", fp);
1249    fputs(round, fp);
1250    fputs(clamp, fp);
1251    fputs(special, fp);
1252    fputs(" ", fp);
1253    bi_disasm_dest_fma(fp, next_regs, last);
1254    fputs(", ", fp);
1255    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1256    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1257    fputs(neg0, fp);
1258    fputs(abs0, fp);
1259    fputs(", ", fp);
1260    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
1261    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
1262    fputs(neg1, fp);
1263    fputs(", ", fp);
1264    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
1265    fputs(neg2, fp);
1266    fputs(", ", fp);
1267    dump_src(fp, _BITS(bits, 9, 3), *srcs, branch_offset, consts, true);
1268}
1269
1270static void
1271bi_disasm_fma_fma_rscale_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1272{
1273    static const char *neg1_table[] = {
1274        "", ".neg", "", ".neg", "", ".neg", "", ".neg", "", ".neg", "", ".neg", ".reserved", ".reserved", "", ".neg"
1275    };
1276    const char *neg1 = neg1_table[(_BITS(bits, 16, 1) << 0) | (_BITS(bits, 12, 3) << 1)];
1277    static const char *neg0_table[] = {
1278        "", "", "", "", "", "", "", "", "", "", "", "", ".reserved", ".reserved", "", ""
1279    };
1280    const char *neg0 = neg0_table[(_BITS(bits, 16, 1) << 0) | (_BITS(bits, 12, 3) << 1)];
1281    static const char *round_table[] = {
1282        "", "", "", "", "", "", "", "", "", "", ".rtz", ".rtz", ".reserved", ".reserved", "", ""
1283    };
1284    const char *round = round_table[(_BITS(bits, 16, 1) << 0) | (_BITS(bits, 12, 3) << 1)];
1285    static const char *special_table[] = {
1286        "", "", "", "", "", "", "", "", ".n", ".n", ".n", ".n", ".reserved", ".reserved", ".left", ".left"
1287    };
1288    const char *special = special_table[(_BITS(bits, 16, 1) << 0) | (_BITS(bits, 12, 3) << 1)];
1289    static const char *clamp_table[] = {
1290        "", "", ".clamp_0_inf", ".clamp_0_inf", ".clamp_m1_1", ".clamp_m1_1", ".clamp_0_1", ".clamp_0_1", "", "", "", "", ".reserved", ".reserved", "", ""
1291    };
1292    const char *clamp = clamp_table[(_BITS(bits, 16, 1) << 0) | (_BITS(bits, 12, 3) << 1)];
1293    static const char *abs0_table[] = {
1294        "", ".abs"
1295    };
1296
1297    const char *abs0 = abs0_table[_BITS(bits, 15, 1)];
1298
1299    static const char *neg2_table[] = {
1300        "", ".neg"
1301    };
1302
1303    const char *neg2 = neg2_table[_BITS(bits, 17, 1)];
1304
1305    fputs("*FMA_RSCALE.v2f16", fp);
1306    fputs(round, fp);
1307    fputs(clamp, fp);
1308    fputs(special, fp);
1309    fputs(" ", fp);
1310    bi_disasm_dest_fma(fp, next_regs, last);
1311    fputs(", ", fp);
1312    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1313    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1314    fputs(neg0, fp);
1315    fputs(abs0, fp);
1316    fputs(", ", fp);
1317    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
1318    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
1319    fputs(neg1, fp);
1320    fputs(", ", fp);
1321    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
1322    fputs(neg2, fp);
1323    fputs(", ", fp);
1324    dump_src(fp, _BITS(bits, 9, 3), *srcs, branch_offset, consts, true);
1325}
1326
1327static void
1328bi_disasm_fma_fmul_cslice(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1329{
1330    static const char *lane0_table[] = {
1331        "", ".h1"
1332    };
1333
1334    const char *lane0 = lane0_table[_BITS(bits, 6, 1)];
1335
1336    static const char *abs0_table[] = {
1337        "", ".abs"
1338    };
1339
1340    const char *abs0 = abs0_table[_BITS(bits, 7, 1)];
1341
1342    static const char *neg0_table[] = {
1343        "", ".neg"
1344    };
1345
1346    const char *neg0 = neg0_table[_BITS(bits, 8, 1)];
1347
1348    fputs("*FMUL_CSLICE", fp);
1349    fputs(" ", fp);
1350    bi_disasm_dest_fma(fp, next_regs, last);
1351    fputs(", ", fp);
1352    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1353    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1354    fputs(lane0, fp);
1355    fputs(abs0, fp);
1356    fputs(neg0, fp);
1357    fputs(", ", fp);
1358    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
1359    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
1360}
1361
1362static void
1363bi_disasm_fma_fmul_slice_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1364{
1365    fputs("*FMUL_SLICE.f32", fp);
1366    fputs(" ", fp);
1367    bi_disasm_dest_fma(fp, next_regs, last);
1368    fputs(", ", fp);
1369    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1370    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1371    fputs(", ", fp);
1372    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
1373    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
1374}
1375
1376static void
1377bi_disasm_fma_frexpe_f32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1378{
1379    static const char *log_table[] = {
1380        ""
1381    };
1382    const char *log = log_table[0];
1383    static const char *neg0_table[] = {
1384        "", ".neg"
1385    };
1386
1387    const char *neg0 = neg0_table[_BITS(bits, 6, 1)];
1388
1389    static const char *sqrt_table[] = {
1390        "", ".sqrt"
1391    };
1392
1393    const char *sqrt = sqrt_table[_BITS(bits, 8, 1)];
1394
1395    static const char *widen0_table[] = {
1396        ".reserved", "", ".h0", ".h1"
1397    };
1398
1399    const char *widen0 = widen0_table[_BITS(bits, 3, 2)];
1400
1401    fputs("*FREXPE.f32", fp);
1402    fputs(sqrt, fp);
1403    fputs(log, fp);
1404    fputs(" ", fp);
1405    bi_disasm_dest_fma(fp, next_regs, last);
1406    fputs(", ", fp);
1407    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1408    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1409    fputs(neg0, fp);
1410    fputs(widen0, fp);
1411}
1412
1413static void
1414bi_disasm_fma_frexpe_f32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1415{
1416    static const char *log_table[] = {
1417        ".log"
1418    };
1419    const char *log = log_table[0];
1420    static const char *neg0_table[] = {
1421        ""
1422    };
1423    const char *neg0 = neg0_table[0];
1424    static const char *sqrt_table[] = {
1425        ""
1426    };
1427    const char *sqrt = sqrt_table[0];
1428    static const char *widen0_table[] = {
1429        ".reserved", "", ".h0", ".h1"
1430    };
1431
1432    const char *widen0 = widen0_table[_BITS(bits, 3, 2)];
1433
1434    fputs("*FREXPE.f32", fp);
1435    fputs(sqrt, fp);
1436    fputs(log, fp);
1437    fputs(" ", fp);
1438    bi_disasm_dest_fma(fp, next_regs, last);
1439    fputs(", ", fp);
1440    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1441    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1442    fputs(neg0, fp);
1443    fputs(widen0, fp);
1444}
1445
1446static void
1447bi_disasm_fma_frexpe_v2f16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1448{
1449    static const char *log_table[] = {
1450        ""
1451    };
1452    const char *log = log_table[0];
1453    static const char *neg0_table[] = {
1454        "", ".neg"
1455    };
1456
1457    const char *neg0 = neg0_table[_BITS(bits, 6, 1)];
1458
1459    static const char *sqrt_table[] = {
1460        "", ".sqrt"
1461    };
1462
1463    const char *sqrt = sqrt_table[_BITS(bits, 8, 1)];
1464
1465    static const char *swz0_table[] = {
1466        ".h00", ".h10", "", ".h11"
1467    };
1468
1469    const char *swz0 = swz0_table[_BITS(bits, 3, 2)];
1470
1471    fputs("*FREXPE.v2f16", fp);
1472    fputs(sqrt, fp);
1473    fputs(log, fp);
1474    fputs(" ", fp);
1475    bi_disasm_dest_fma(fp, next_regs, last);
1476    fputs(", ", fp);
1477    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1478    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1479    fputs(neg0, fp);
1480    fputs(swz0, fp);
1481}
1482
1483static void
1484bi_disasm_fma_frexpe_v2f16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1485{
1486    static const char *log_table[] = {
1487        ".log"
1488    };
1489    const char *log = log_table[0];
1490    static const char *neg0_table[] = {
1491        ""
1492    };
1493    const char *neg0 = neg0_table[0];
1494    static const char *sqrt_table[] = {
1495        ""
1496    };
1497    const char *sqrt = sqrt_table[0];
1498    static const char *swz0_table[] = {
1499        ".h00", ".h10", "", ".h11"
1500    };
1501
1502    const char *swz0 = swz0_table[_BITS(bits, 3, 2)];
1503
1504    fputs("*FREXPE.v2f16", fp);
1505    fputs(sqrt, fp);
1506    fputs(log, fp);
1507    fputs(" ", fp);
1508    bi_disasm_dest_fma(fp, next_regs, last);
1509    fputs(", ", fp);
1510    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1511    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1512    fputs(neg0, fp);
1513    fputs(swz0, fp);
1514}
1515
1516static void
1517bi_disasm_fma_frexpm_f32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1518{
1519    static const char *log_table[] = {
1520        ""
1521    };
1522    const char *log = log_table[0];
1523    static const char *neg0_table[] = {
1524        ""
1525    };
1526    const char *neg0 = neg0_table[0];
1527    static const char *abs0_table[] = {
1528        "", ".abs"
1529    };
1530
1531    const char *abs0 = abs0_table[_BITS(bits, 6, 1)];
1532
1533    static const char *sqrt_table[] = {
1534        "", ".sqrt"
1535    };
1536
1537    const char *sqrt = sqrt_table[_BITS(bits, 7, 1)];
1538
1539    static const char *widen0_table[] = {
1540        ".reserved", "", ".h0", ".h1"
1541    };
1542
1543    const char *widen0 = widen0_table[_BITS(bits, 3, 2)];
1544
1545    fputs("*FREXPM.f32", fp);
1546    fputs(sqrt, fp);
1547    fputs(log, fp);
1548    fputs(" ", fp);
1549    bi_disasm_dest_fma(fp, next_regs, last);
1550    fputs(", ", fp);
1551    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1552    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1553    fputs(abs0, fp);
1554    fputs(widen0, fp);
1555    fputs(neg0, fp);
1556}
1557
1558static void
1559bi_disasm_fma_frexpm_f32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1560{
1561    static const char *log_table[] = {
1562        ".log"
1563    };
1564    const char *log = log_table[0];
1565    static const char *sqrt_table[] = {
1566        ""
1567    };
1568    const char *sqrt = sqrt_table[0];
1569    static const char *abs0_table[] = {
1570        "", ".abs"
1571    };
1572
1573    const char *abs0 = abs0_table[_BITS(bits, 6, 1)];
1574
1575    static const char *widen0_table[] = {
1576        ".reserved", "", ".h0", ".h1"
1577    };
1578
1579    const char *widen0 = widen0_table[_BITS(bits, 3, 2)];
1580
1581    static const char *neg0_table[] = {
1582        "", ".neg"
1583    };
1584
1585    const char *neg0 = neg0_table[_BITS(bits, 7, 1)];
1586
1587    fputs("*FREXPM.f32", fp);
1588    fputs(sqrt, fp);
1589    fputs(log, fp);
1590    fputs(" ", fp);
1591    bi_disasm_dest_fma(fp, next_regs, last);
1592    fputs(", ", fp);
1593    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1594    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1595    fputs(abs0, fp);
1596    fputs(widen0, fp);
1597    fputs(neg0, fp);
1598}
1599
1600static void
1601bi_disasm_fma_frexpm_v2f16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1602{
1603    static const char *log_table[] = {
1604        ""
1605    };
1606    const char *log = log_table[0];
1607    static const char *neg0_table[] = {
1608        ""
1609    };
1610    const char *neg0 = neg0_table[0];
1611    static const char *abs0_table[] = {
1612        "", ".abs"
1613    };
1614
1615    const char *abs0 = abs0_table[_BITS(bits, 6, 1)];
1616
1617    static const char *sqrt_table[] = {
1618        "", ".sqrt"
1619    };
1620
1621    const char *sqrt = sqrt_table[_BITS(bits, 7, 1)];
1622
1623    static const char *swz0_table[] = {
1624        ".h00", ".h10", "", ".h11"
1625    };
1626
1627    const char *swz0 = swz0_table[_BITS(bits, 3, 2)];
1628
1629    fputs("*FREXPM.v2f16", fp);
1630    fputs(sqrt, fp);
1631    fputs(log, fp);
1632    fputs(" ", fp);
1633    bi_disasm_dest_fma(fp, next_regs, last);
1634    fputs(", ", fp);
1635    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1636    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1637    fputs(abs0, fp);
1638    fputs(swz0, fp);
1639    fputs(neg0, fp);
1640}
1641
1642static void
1643bi_disasm_fma_frexpm_v2f16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1644{
1645    static const char *log_table[] = {
1646        ".log"
1647    };
1648    const char *log = log_table[0];
1649    static const char *sqrt_table[] = {
1650        ""
1651    };
1652    const char *sqrt = sqrt_table[0];
1653    static const char *abs0_table[] = {
1654        "", ".abs"
1655    };
1656
1657    const char *abs0 = abs0_table[_BITS(bits, 6, 1)];
1658
1659    static const char *swz0_table[] = {
1660        ".h00", ".h10", "", ".h11"
1661    };
1662
1663    const char *swz0 = swz0_table[_BITS(bits, 3, 2)];
1664
1665    static const char *neg0_table[] = {
1666        "", ".neg"
1667    };
1668
1669    const char *neg0 = neg0_table[_BITS(bits, 7, 1)];
1670
1671    fputs("*FREXPM.v2f16", fp);
1672    fputs(sqrt, fp);
1673    fputs(log, fp);
1674    fputs(" ", fp);
1675    bi_disasm_dest_fma(fp, next_regs, last);
1676    fputs(", ", fp);
1677    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1678    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1679    fputs(abs0, fp);
1680    fputs(swz0, fp);
1681    fputs(neg0, fp);
1682}
1683
1684static void
1685bi_disasm_fma_fround_f32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1686{
1687    static const char *round_table[] = {
1688        "", ".rtp", ".rtn", ".rtz"
1689    };
1690    const char *round = round_table[(_BITS(bits, 9, 2) << 0)];
1691    static const char *abs0_table[] = {
1692        "", ".abs"
1693    };
1694
1695    const char *abs0 = abs0_table[_BITS(bits, 7, 1)];
1696
1697    static const char *neg0_table[] = {
1698        "", ".neg"
1699    };
1700
1701    const char *neg0 = neg0_table[_BITS(bits, 8, 1)];
1702
1703    static const char *widen0_table[] = {
1704        ".reserved", "", ".h0", ".h1"
1705    };
1706
1707    const char *widen0 = widen0_table[_BITS(bits, 3, 2)];
1708
1709    fputs("*FROUND.f32", fp);
1710    fputs(round, fp);
1711    fputs(" ", fp);
1712    bi_disasm_dest_fma(fp, next_regs, last);
1713    fputs(", ", fp);
1714    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1715    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1716    fputs(abs0, fp);
1717    fputs(neg0, fp);
1718    fputs(widen0, fp);
1719}
1720
1721static void
1722bi_disasm_fma_fround_f32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1723{
1724    static const char *round_table[] = {
1725        ".rtna"
1726    };
1727    const char *round = round_table[0];
1728    static const char *abs0_table[] = {
1729        "", ".abs"
1730    };
1731
1732    const char *abs0 = abs0_table[_BITS(bits, 7, 1)];
1733
1734    static const char *neg0_table[] = {
1735        "", ".neg"
1736    };
1737
1738    const char *neg0 = neg0_table[_BITS(bits, 8, 1)];
1739
1740    static const char *widen0_table[] = {
1741        ".reserved", "", ".h0", ".h1"
1742    };
1743
1744    const char *widen0 = widen0_table[_BITS(bits, 3, 2)];
1745
1746    fputs("*FROUND.f32", fp);
1747    fputs(round, fp);
1748    fputs(" ", fp);
1749    bi_disasm_dest_fma(fp, next_regs, last);
1750    fputs(", ", fp);
1751    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1752    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1753    fputs(abs0, fp);
1754    fputs(neg0, fp);
1755    fputs(widen0, fp);
1756}
1757
1758static void
1759bi_disasm_fma_fround_v2f16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1760{
1761    static const char *round_table[] = {
1762        "", ".rtp", ".rtn", ".rtz"
1763    };
1764    const char *round = round_table[(_BITS(bits, 9, 2) << 0)];
1765    static const char *abs0_table[] = {
1766        "", ".abs"
1767    };
1768
1769    const char *abs0 = abs0_table[_BITS(bits, 7, 1)];
1770
1771    static const char *neg0_table[] = {
1772        "", ".neg"
1773    };
1774
1775    const char *neg0 = neg0_table[_BITS(bits, 8, 1)];
1776
1777    static const char *swz0_table[] = {
1778        ".h00", ".h10", "", ".h11"
1779    };
1780
1781    const char *swz0 = swz0_table[_BITS(bits, 3, 2)];
1782
1783    fputs("*FROUND.v2f16", fp);
1784    fputs(round, fp);
1785    fputs(" ", fp);
1786    bi_disasm_dest_fma(fp, next_regs, last);
1787    fputs(", ", fp);
1788    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1789    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1790    fputs(abs0, fp);
1791    fputs(neg0, fp);
1792    fputs(swz0, fp);
1793}
1794
1795static void
1796bi_disasm_fma_fround_v2f16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1797{
1798    static const char *round_table[] = {
1799        ".rtna"
1800    };
1801    const char *round = round_table[0];
1802    static const char *abs0_table[] = {
1803        "", ".abs"
1804    };
1805
1806    const char *abs0 = abs0_table[_BITS(bits, 7, 1)];
1807
1808    static const char *neg0_table[] = {
1809        "", ".neg"
1810    };
1811
1812    const char *neg0 = neg0_table[_BITS(bits, 8, 1)];
1813
1814    static const char *swz0_table[] = {
1815        ".h00", ".h10", "", ".h11"
1816    };
1817
1818    const char *swz0 = swz0_table[_BITS(bits, 3, 2)];
1819
1820    fputs("*FROUND.v2f16", fp);
1821    fputs(round, fp);
1822    fputs(" ", fp);
1823    bi_disasm_dest_fma(fp, next_regs, last);
1824    fputs(", ", fp);
1825    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1826    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1827    fputs(abs0, fp);
1828    fputs(neg0, fp);
1829    fputs(swz0, fp);
1830}
1831
1832static void
1833bi_disasm_fma_frshift_double_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1834{
1835    static const char *bytes2_table[] = {
1836        "", ".bytes2"
1837    };
1838
1839    const char *bytes2 = bytes2_table[_BITS(bits, 9, 1)];
1840
1841    static const char *lane2_table[] = {
1842        "", ".b2"
1843    };
1844
1845    const char *lane2 = lane2_table[_BITS(bits, 10, 1)];
1846
1847    fputs("*FRSHIFT_DOUBLE.i32", fp);
1848    fputs(" ", fp);
1849    bi_disasm_dest_fma(fp, next_regs, last);
1850    fputs(", ", fp);
1851    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1852    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1853    fputs(", ", fp);
1854    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
1855    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
1856    fputs(", ", fp);
1857    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
1858    fputs(bytes2, fp);
1859    fputs(lane2, fp);
1860}
1861
1862static void
1863bi_disasm_fma_iaddc_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1864{
1865    fputs("*IADDC.i32", fp);
1866    fputs(" ", fp);
1867    bi_disasm_dest_fma(fp, next_regs, last);
1868    fputs(", ", fp);
1869    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1870    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1871    fputs(", ", fp);
1872    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
1873    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
1874    fputs(", ", fp);
1875    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
1876}
1877
1878static void
1879bi_disasm_fma_idp_v4i8(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1880{
1881    static const char *sign0_table[] = {
1882        ".zext", ".sext"
1883    };
1884
1885    const char *sign0 = sign0_table[_BITS(bits, 9, 1)];
1886
1887    static const char *sign1_table[] = {
1888        ".zext", ".sext"
1889    };
1890
1891    const char *sign1 = sign1_table[_BITS(bits, 10, 1)];
1892
1893    fputs("*IDP.v4i8", fp);
1894    fputs(" ", fp);
1895    bi_disasm_dest_fma(fp, next_regs, last);
1896    fputs(", ", fp);
1897    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1898    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1899    fputs(sign0, fp);
1900    fputs(", ", fp);
1901    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
1902    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
1903    fputs(sign1, fp);
1904}
1905
1906static void
1907bi_disasm_fma_imul_i32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1908{
1909    static const char *extend_table[] = {
1910        ""
1911    };
1912    const char *extend = extend_table[0];
1913    static const char *widen1_table[] = {
1914        ""
1915    };
1916    const char *widen1 = widen1_table[0];
1917    fputs("*IMUL.i32", fp);
1918    fputs(extend, fp);
1919    fputs(" ", fp);
1920    bi_disasm_dest_fma(fp, next_regs, last);
1921    fputs(", ", fp);
1922    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1923    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1924    fputs(", ", fp);
1925    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
1926    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
1927    fputs(widen1, fp);
1928}
1929
1930static void
1931bi_disasm_fma_imul_i32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1932{
1933    static const char *extend_table[] = {
1934        ".zext", ".zext", ".sext", ".sext"
1935    };
1936    const char *extend = extend_table[(_BITS(bits, 9, 1) << 0) | (_BITS(bits, 10, 1) << 1)];
1937    static const char *widen1_table[] = {
1938        ".h0", ".h1", ".h0", ".h1"
1939    };
1940    const char *widen1 = widen1_table[(_BITS(bits, 9, 1) << 0) | (_BITS(bits, 10, 1) << 1)];
1941    fputs("*IMUL.i32", fp);
1942    fputs(extend, fp);
1943    fputs(" ", fp);
1944    bi_disasm_dest_fma(fp, next_regs, last);
1945    fputs(", ", fp);
1946    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1947    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1948    fputs(", ", fp);
1949    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
1950    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
1951    fputs(widen1, fp);
1952}
1953
1954static void
1955bi_disasm_fma_imul_i32_2(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1956{
1957    static const char *extend_table[] = {
1958        ".zext", ".zext", ".zext", ".zext", ".sext", ".sext", ".sext", ".sext"
1959    };
1960    const char *extend = extend_table[(_BITS(bits, 9, 2) << 0) | (_BITS(bits, 11, 1) << 2)];
1961    static const char *widen1_table[] = {
1962        ".b0", ".b1", ".b2", ".b3", ".b0", ".b1", ".b2", ".b3"
1963    };
1964    const char *widen1 = widen1_table[(_BITS(bits, 9, 2) << 0) | (_BITS(bits, 11, 1) << 2)];
1965    fputs("*IMUL.i32", fp);
1966    fputs(extend, fp);
1967    fputs(" ", fp);
1968    bi_disasm_dest_fma(fp, next_regs, last);
1969    fputs(", ", fp);
1970    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1971    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1972    fputs(", ", fp);
1973    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
1974    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
1975    fputs(widen1, fp);
1976}
1977
1978static void
1979bi_disasm_fma_imul_v2i16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
1980{
1981    static const char *swz0_table[] = {
1982        ".h00", ".h10", "", ".h11"
1983    };
1984
1985    const char *swz0 = swz0_table[_BITS(bits, 9, 2)];
1986
1987    static const char *swz1_table[] = {
1988        ".h00", ".h10", "", ".h11"
1989    };
1990
1991    const char *swz1 = swz1_table[_BITS(bits, 11, 2)];
1992
1993    fputs("*IMUL.v2i16", fp);
1994    fputs(" ", fp);
1995    bi_disasm_dest_fma(fp, next_regs, last);
1996    fputs(", ", fp);
1997    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
1998    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
1999    fputs(swz0, fp);
2000    fputs(", ", fp);
2001    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2002    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2003    fputs(swz1, fp);
2004}
2005
2006static void
2007bi_disasm_fma_imul_v4i8_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2008{
2009    static const char *replicate0_table[] = {
2010        ""
2011    };
2012    const char *replicate0 = replicate0_table[0];
2013    static const char *replicate1_table[] = {
2014        ""
2015    };
2016    const char *replicate1 = replicate1_table[0];
2017    fputs("*IMUL.v4i8", fp);
2018    fputs(" ", fp);
2019    bi_disasm_dest_fma(fp, next_regs, last);
2020    fputs(", ", fp);
2021    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2022    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2023    fputs(replicate0, fp);
2024    fputs(", ", fp);
2025    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2026    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2027    fputs(replicate1, fp);
2028}
2029
2030static void
2031bi_disasm_fma_imul_v4i8_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2032{
2033    static const char *replicate0_table[] = {
2034        "", "", "", ""
2035    };
2036    const char *replicate0 = replicate0_table[(_BITS(bits, 9, 2) << 0)];
2037    static const char *replicate1_table[] = {
2038        ".b0000", ".b1111", ".b2222", ".b3333"
2039    };
2040    const char *replicate1 = replicate1_table[(_BITS(bits, 9, 2) << 0)];
2041    fputs("*IMUL.v4i8", fp);
2042    fputs(" ", fp);
2043    bi_disasm_dest_fma(fp, next_regs, last);
2044    fputs(", ", fp);
2045    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2046    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2047    fputs(replicate0, fp);
2048    fputs(", ", fp);
2049    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2050    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2051    fputs(replicate1, fp);
2052}
2053
2054static void
2055bi_disasm_fma_imuld(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2056{
2057    static const char *threads_table[] = {
2058        ".even", ""
2059    };
2060
2061    const char *threads = threads_table[_BITS(bits, 6, 1)];
2062
2063    fputs("*IMULD", fp);
2064    fputs(threads, fp);
2065    fputs(" ", fp);
2066    bi_disasm_dest_fma(fp, next_regs, last);
2067    fputs(", ", fp);
2068    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2069    if (!(0x33 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2070    fputs(", ", fp);
2071    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2072    if (!(0x33 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2073}
2074
2075static void
2076bi_disasm_fma_isubb_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2077{
2078    fputs("*ISUBB.i32", fp);
2079    fputs(" ", fp);
2080    bi_disasm_dest_fma(fp, next_regs, last);
2081    fputs(", ", fp);
2082    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2083    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2084    fputs(", ", fp);
2085    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2086    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2087    fputs(", ", fp);
2088    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2089}
2090
2091static void
2092bi_disasm_fma_jump_ex(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2093{
2094    static const char *test_mode_table[] = {
2095        "", ".nz"
2096    };
2097
2098    const char *test_mode = test_mode_table[_BITS(bits, 9, 1)];
2099
2100    static const char *stack_mode_table[] = {
2101        ".return", ".call", "", ".replace"
2102    };
2103
2104    const char *stack_mode = stack_mode_table[_BITS(bits, 10, 2)];
2105
2106    fputs("*JUMP_EX", fp);
2107    fputs(test_mode, fp);
2108    fputs(stack_mode, fp);
2109    fputs(" ", fp);
2110    bi_disasm_dest_fma(fp, next_regs, last);
2111    fputs(", ", fp);
2112    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2113    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2114    fputs(", ", fp);
2115    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2116    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2117    fputs(", ", fp);
2118    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2119}
2120
2121static void
2122bi_disasm_fma_lrot_double_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2123{
2124    static const char *bytes2_table[] = {
2125        "", ".bytes2"
2126    };
2127
2128    const char *bytes2 = bytes2_table[_BITS(bits, 9, 1)];
2129
2130    static const char *lane2_table[] = {
2131        "", ".b2"
2132    };
2133
2134    const char *lane2 = lane2_table[_BITS(bits, 10, 1)];
2135
2136    static const char *result_word_table[] = {
2137        "", ".w1"
2138    };
2139
2140    const char *result_word = result_word_table[_BITS(bits, 11, 1)];
2141
2142    fputs("*LROT_DOUBLE.i32", fp);
2143    fputs(result_word, fp);
2144    fputs(" ", fp);
2145    bi_disasm_dest_fma(fp, next_regs, last);
2146    fputs(", ", fp);
2147    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2148    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2149    fputs(", ", fp);
2150    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2151    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2152    fputs(", ", fp);
2153    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2154    fputs(bytes2, fp);
2155    fputs(lane2, fp);
2156}
2157
2158static void
2159bi_disasm_fma_lshift_and_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2160{
2161    static const char *lane2_table[] = {
2162        "", ".b1", ".b2", ".b3"
2163    };
2164
2165    const char *lane2 = lane2_table[_BITS(bits, 9, 2)];
2166
2167    static const char *not1_table[] = {
2168        "", ".not"
2169    };
2170
2171    const char *not1 = not1_table[_BITS(bits, 14, 1)];
2172
2173    static const char *not_result_table[] = {
2174        ".not", ""
2175    };
2176
2177    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
2178
2179    fputs("*LSHIFT_AND.i32", fp);
2180    fputs(not_result, fp);
2181    fputs(" ", fp);
2182    bi_disasm_dest_fma(fp, next_regs, last);
2183    fputs(", ", fp);
2184    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2185    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2186    fputs(", ", fp);
2187    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2188    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2189    fputs(not1, fp);
2190    fputs(", ", fp);
2191    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2192    fputs(lane2, fp);
2193}
2194
2195static void
2196bi_disasm_fma_lshift_and_v2i16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2197{
2198    static const char *lanes2_table[] = {
2199        ".b00", ".b11", ".b22", ".b33"
2200    };
2201    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
2202    static const char *not1_table[] = {
2203        "", ".not"
2204    };
2205
2206    const char *not1 = not1_table[_BITS(bits, 14, 1)];
2207
2208    static const char *not_result_table[] = {
2209        ".not", ""
2210    };
2211
2212    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
2213
2214    fputs("*LSHIFT_AND.v2i16", fp);
2215    fputs(not_result, fp);
2216    fputs(" ", fp);
2217    bi_disasm_dest_fma(fp, next_regs, last);
2218    fputs(", ", fp);
2219    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2220    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2221    fputs(", ", fp);
2222    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2223    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2224    fputs(not1, fp);
2225    fputs(", ", fp);
2226    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2227    fputs(lanes2, fp);
2228}
2229
2230static void
2231bi_disasm_fma_lshift_and_v2i16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2232{
2233    static const char *lanes2_table[] = {
2234        ".reserved", ".b01", ".b23", ""
2235    };
2236    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
2237    static const char *not1_table[] = {
2238        "", ".not"
2239    };
2240
2241    const char *not1 = not1_table[_BITS(bits, 14, 1)];
2242
2243    static const char *not_result_table[] = {
2244        ".not", ""
2245    };
2246
2247    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
2248
2249    fputs("*LSHIFT_AND.v2i16", fp);
2250    fputs(not_result, fp);
2251    fputs(" ", fp);
2252    bi_disasm_dest_fma(fp, next_regs, last);
2253    fputs(", ", fp);
2254    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2255    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2256    fputs(", ", fp);
2257    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2258    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2259    fputs(not1, fp);
2260    fputs(", ", fp);
2261    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2262    fputs(lanes2, fp);
2263}
2264
2265static void
2266bi_disasm_fma_lshift_and_v4i8_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2267{
2268    static const char *lanes2_table[] = {
2269        ".b0000", ".b1111", ".b2222", ".b3333"
2270    };
2271    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
2272    static const char *not1_table[] = {
2273        "", ".not"
2274    };
2275
2276    const char *not1 = not1_table[_BITS(bits, 14, 1)];
2277
2278    static const char *not_result_table[] = {
2279        ".not", ""
2280    };
2281
2282    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
2283
2284    fputs("*LSHIFT_AND.v4i8", fp);
2285    fputs(not_result, fp);
2286    fputs(" ", fp);
2287    bi_disasm_dest_fma(fp, next_regs, last);
2288    fputs(", ", fp);
2289    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2290    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2291    fputs(", ", fp);
2292    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2293    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2294    fputs(not1, fp);
2295    fputs(", ", fp);
2296    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2297    fputs(lanes2, fp);
2298}
2299
2300static void
2301bi_disasm_fma_lshift_and_v4i8_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2302{
2303    static const char *lanes2_table[] = {
2304        ""
2305    };
2306    const char *lanes2 = lanes2_table[0];
2307    static const char *not1_table[] = {
2308        "", ".not"
2309    };
2310
2311    const char *not1 = not1_table[_BITS(bits, 14, 1)];
2312
2313    static const char *not_result_table[] = {
2314        ".not", ""
2315    };
2316
2317    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
2318
2319    fputs("*LSHIFT_AND.v4i8", fp);
2320    fputs(not_result, fp);
2321    fputs(" ", fp);
2322    bi_disasm_dest_fma(fp, next_regs, last);
2323    fputs(", ", fp);
2324    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2325    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2326    fputs(", ", fp);
2327    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2328    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2329    fputs(not1, fp);
2330    fputs(", ", fp);
2331    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2332    fputs(lanes2, fp);
2333}
2334
2335static void
2336bi_disasm_fma_lshift_double_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2337{
2338    static const char *bytes2_table[] = {
2339        "", ".bytes2"
2340    };
2341
2342    const char *bytes2 = bytes2_table[_BITS(bits, 9, 1)];
2343
2344    static const char *lane2_table[] = {
2345        "", ".b2"
2346    };
2347
2348    const char *lane2 = lane2_table[_BITS(bits, 10, 1)];
2349
2350    static const char *result_word_table[] = {
2351        "", ".w1"
2352    };
2353
2354    const char *result_word = result_word_table[_BITS(bits, 11, 1)];
2355
2356    fputs("*LSHIFT_DOUBLE.i32", fp);
2357    fputs(result_word, fp);
2358    fputs(" ", fp);
2359    bi_disasm_dest_fma(fp, next_regs, last);
2360    fputs(", ", fp);
2361    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2362    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2363    fputs(", ", fp);
2364    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2365    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2366    fputs(", ", fp);
2367    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2368    fputs(bytes2, fp);
2369    fputs(lane2, fp);
2370}
2371
2372static void
2373bi_disasm_fma_lshift_or_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2374{
2375    static const char *lane2_table[] = {
2376        "", ".b1", ".b2", ".b3"
2377    };
2378
2379    const char *lane2 = lane2_table[_BITS(bits, 9, 2)];
2380
2381    static const char *not1_table[] = {
2382        ".not", ""
2383    };
2384
2385    const char *not1 = not1_table[_BITS(bits, 14, 1)];
2386
2387    static const char *not_result_table[] = {
2388        "", ".not"
2389    };
2390
2391    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
2392
2393    fputs("*LSHIFT_OR.i32", fp);
2394    fputs(not_result, fp);
2395    fputs(" ", fp);
2396    bi_disasm_dest_fma(fp, next_regs, last);
2397    fputs(", ", fp);
2398    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2399    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2400    fputs(", ", fp);
2401    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2402    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2403    fputs(not1, fp);
2404    fputs(", ", fp);
2405    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2406    fputs(lane2, fp);
2407}
2408
2409static void
2410bi_disasm_fma_lshift_or_v2i16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2411{
2412    static const char *lanes2_table[] = {
2413        ".b00", ".b11", ".b22", ".b33"
2414    };
2415    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
2416    static const char *not1_table[] = {
2417        ".not", ""
2418    };
2419
2420    const char *not1 = not1_table[_BITS(bits, 14, 1)];
2421
2422    static const char *not_result_table[] = {
2423        "", ".not"
2424    };
2425
2426    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
2427
2428    fputs("*LSHIFT_OR.v2i16", fp);
2429    fputs(not_result, fp);
2430    fputs(" ", fp);
2431    bi_disasm_dest_fma(fp, next_regs, last);
2432    fputs(", ", fp);
2433    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2434    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2435    fputs(", ", fp);
2436    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2437    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2438    fputs(not1, fp);
2439    fputs(", ", fp);
2440    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2441    fputs(lanes2, fp);
2442}
2443
2444static void
2445bi_disasm_fma_lshift_or_v2i16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2446{
2447    static const char *lanes2_table[] = {
2448        ".reserved", ".b01", ".b23", ""
2449    };
2450    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
2451    static const char *not1_table[] = {
2452        ".not", ""
2453    };
2454
2455    const char *not1 = not1_table[_BITS(bits, 14, 1)];
2456
2457    static const char *not_result_table[] = {
2458        "", ".not"
2459    };
2460
2461    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
2462
2463    fputs("*LSHIFT_OR.v2i16", fp);
2464    fputs(not_result, fp);
2465    fputs(" ", fp);
2466    bi_disasm_dest_fma(fp, next_regs, last);
2467    fputs(", ", fp);
2468    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2469    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2470    fputs(", ", fp);
2471    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2472    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2473    fputs(not1, fp);
2474    fputs(", ", fp);
2475    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2476    fputs(lanes2, fp);
2477}
2478
2479static void
2480bi_disasm_fma_lshift_or_v4i8_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2481{
2482    static const char *lanes2_table[] = {
2483        ".b0000", ".b1111", ".b2222", ".b3333"
2484    };
2485    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
2486    static const char *not1_table[] = {
2487        ".not", ""
2488    };
2489
2490    const char *not1 = not1_table[_BITS(bits, 14, 1)];
2491
2492    static const char *not_result_table[] = {
2493        "", ".not"
2494    };
2495
2496    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
2497
2498    fputs("*LSHIFT_OR.v4i8", fp);
2499    fputs(not_result, fp);
2500    fputs(" ", fp);
2501    bi_disasm_dest_fma(fp, next_regs, last);
2502    fputs(", ", fp);
2503    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2504    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2505    fputs(", ", fp);
2506    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2507    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2508    fputs(not1, fp);
2509    fputs(", ", fp);
2510    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2511    fputs(lanes2, fp);
2512}
2513
2514static void
2515bi_disasm_fma_lshift_or_v4i8_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2516{
2517    static const char *lanes2_table[] = {
2518        ""
2519    };
2520    const char *lanes2 = lanes2_table[0];
2521    static const char *not1_table[] = {
2522        ".not", ""
2523    };
2524
2525    const char *not1 = not1_table[_BITS(bits, 14, 1)];
2526
2527    static const char *not_result_table[] = {
2528        "", ".not"
2529    };
2530
2531    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
2532
2533    fputs("*LSHIFT_OR.v4i8", fp);
2534    fputs(not_result, fp);
2535    fputs(" ", fp);
2536    bi_disasm_dest_fma(fp, next_regs, last);
2537    fputs(", ", fp);
2538    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2539    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2540    fputs(", ", fp);
2541    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2542    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2543    fputs(not1, fp);
2544    fputs(", ", fp);
2545    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2546    fputs(lanes2, fp);
2547}
2548
2549static void
2550bi_disasm_fma_lshift_xor_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2551{
2552    static const char *lane2_table[] = {
2553        "", ".b1", ".b2", ".b3"
2554    };
2555
2556    const char *lane2 = lane2_table[_BITS(bits, 9, 2)];
2557
2558    static const char *not_result_table[] = {
2559        "", ".not"
2560    };
2561
2562    const char *not_result = not_result_table[_BITS(bits, 13, 1)];
2563
2564    fputs("*LSHIFT_XOR.i32", fp);
2565    fputs(not_result, fp);
2566    fputs(" ", fp);
2567    bi_disasm_dest_fma(fp, next_regs, last);
2568    fputs(", ", fp);
2569    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2570    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2571    fputs(", ", fp);
2572    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2573    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2574    fputs(", ", fp);
2575    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2576    fputs(lane2, fp);
2577}
2578
2579static void
2580bi_disasm_fma_lshift_xor_v2i16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2581{
2582    static const char *lanes2_table[] = {
2583        ".b00", ".b11", ".b22", ".b33"
2584    };
2585    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
2586    static const char *not_result_table[] = {
2587        "", ".not"
2588    };
2589
2590    const char *not_result = not_result_table[_BITS(bits, 13, 1)];
2591
2592    fputs("*LSHIFT_XOR.v2i16", fp);
2593    fputs(not_result, fp);
2594    fputs(" ", fp);
2595    bi_disasm_dest_fma(fp, next_regs, last);
2596    fputs(", ", fp);
2597    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2598    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2599    fputs(", ", fp);
2600    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2601    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2602    fputs(", ", fp);
2603    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2604    fputs(lanes2, fp);
2605}
2606
2607static void
2608bi_disasm_fma_lshift_xor_v2i16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2609{
2610    static const char *lanes2_table[] = {
2611        ".reserved", ".b01", ".b23", ""
2612    };
2613    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
2614    static const char *not_result_table[] = {
2615        "", ".not"
2616    };
2617
2618    const char *not_result = not_result_table[_BITS(bits, 13, 1)];
2619
2620    fputs("*LSHIFT_XOR.v2i16", fp);
2621    fputs(not_result, fp);
2622    fputs(" ", fp);
2623    bi_disasm_dest_fma(fp, next_regs, last);
2624    fputs(", ", fp);
2625    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2626    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2627    fputs(", ", fp);
2628    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2629    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2630    fputs(", ", fp);
2631    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2632    fputs(lanes2, fp);
2633}
2634
2635static void
2636bi_disasm_fma_lshift_xor_v4i8_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2637{
2638    static const char *lanes2_table[] = {
2639        ".b0000", ".b1111", ".b2222", ".b3333"
2640    };
2641    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
2642    static const char *not_result_table[] = {
2643        "", ".not"
2644    };
2645
2646    const char *not_result = not_result_table[_BITS(bits, 13, 1)];
2647
2648    fputs("*LSHIFT_XOR.v4i8", fp);
2649    fputs(not_result, fp);
2650    fputs(" ", fp);
2651    bi_disasm_dest_fma(fp, next_regs, last);
2652    fputs(", ", fp);
2653    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2654    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2655    fputs(", ", fp);
2656    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2657    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2658    fputs(", ", fp);
2659    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2660    fputs(lanes2, fp);
2661}
2662
2663static void
2664bi_disasm_fma_lshift_xor_v4i8_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2665{
2666    static const char *lanes2_table[] = {
2667        ""
2668    };
2669    const char *lanes2 = lanes2_table[0];
2670    static const char *not_result_table[] = {
2671        "", ".not"
2672    };
2673
2674    const char *not_result = not_result_table[_BITS(bits, 13, 1)];
2675
2676    fputs("*LSHIFT_XOR.v4i8", fp);
2677    fputs(not_result, fp);
2678    fputs(" ", fp);
2679    bi_disasm_dest_fma(fp, next_regs, last);
2680    fputs(", ", fp);
2681    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2682    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2683    fputs(", ", fp);
2684    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2685    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2686    fputs(", ", fp);
2687    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2688    fputs(lanes2, fp);
2689}
2690
2691static void
2692bi_disasm_fma_mkvec_v2i16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2693{
2694    static const char *lane0_table[] = {
2695        "", ".h1"
2696    };
2697
2698    const char *lane0 = lane0_table[_BITS(bits, 6, 1)];
2699
2700    static const char *lane1_table[] = {
2701        "", ".h1"
2702    };
2703
2704    const char *lane1 = lane1_table[_BITS(bits, 7, 1)];
2705
2706    fputs("*MKVEC.v2i16", fp);
2707    fputs(" ", fp);
2708    bi_disasm_dest_fma(fp, next_regs, last);
2709    fputs(", ", fp);
2710    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2711    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2712    fputs(lane0, fp);
2713    fputs(", ", fp);
2714    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2715    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2716    fputs(lane1, fp);
2717}
2718
2719static void
2720bi_disasm_fma_mkvec_v4i8(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2721{
2722    static const char *lane0_table[] = {
2723        "", ".b2"
2724    };
2725
2726    const char *lane0 = lane0_table[_BITS(bits, 12, 1)];
2727
2728    static const char *lane1_table[] = {
2729        "", ".b2"
2730    };
2731
2732    const char *lane1 = lane1_table[_BITS(bits, 13, 1)];
2733
2734    static const char *lane2_table[] = {
2735        "", ".b2"
2736    };
2737
2738    const char *lane2 = lane2_table[_BITS(bits, 14, 1)];
2739
2740    static const char *lane3_table[] = {
2741        "", ".b2"
2742    };
2743
2744    const char *lane3 = lane3_table[_BITS(bits, 15, 1)];
2745
2746    fputs("*MKVEC.v4i8", fp);
2747    fputs(" ", fp);
2748    bi_disasm_dest_fma(fp, next_regs, last);
2749    fputs(", ", fp);
2750    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2751    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2752    fputs(lane0, fp);
2753    fputs(", ", fp);
2754    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2755    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2756    fputs(lane1, fp);
2757    fputs(", ", fp);
2758    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2759    fputs(lane2, fp);
2760    fputs(", ", fp);
2761    dump_src(fp, _BITS(bits, 9, 3), *srcs, branch_offset, consts, true);
2762    fputs(lane3, fp);
2763}
2764
2765static void
2766bi_disasm_fma_mov_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2767{
2768    fputs("*MOV.i32", fp);
2769    fputs(" ", fp);
2770    bi_disasm_dest_fma(fp, next_regs, last);
2771    fputs(", ", fp);
2772    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2773    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2774}
2775
2776static void
2777bi_disasm_fma_nop(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2778{
2779    fputs("*NOP", fp);
2780    fputs(" ", fp);
2781    bi_disasm_dest_fma(fp, next_regs, last);
2782}
2783
2784static void
2785bi_disasm_fma_popcount_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2786{
2787    fputs("*POPCOUNT.i32", fp);
2788    fputs(" ", fp);
2789    bi_disasm_dest_fma(fp, next_regs, last);
2790    fputs(", ", fp);
2791    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2792    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2793}
2794
2795static void
2796bi_disasm_fma_quiet_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2797{
2798    fputs("*QUIET.f32", fp);
2799    fputs(" ", fp);
2800    bi_disasm_dest_fma(fp, next_regs, last);
2801    fputs(", ", fp);
2802    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2803    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2804}
2805
2806static void
2807bi_disasm_fma_quiet_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2808{
2809    static const char *swz0_table[] = {
2810        ".h00", ".h10", "", ".h11"
2811    };
2812
2813    const char *swz0 = swz0_table[_BITS(bits, 4, 2)];
2814
2815    fputs("*QUIET.v2f16", fp);
2816    fputs(" ", fp);
2817    bi_disasm_dest_fma(fp, next_regs, last);
2818    fputs(", ", fp);
2819    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2820    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2821    fputs(swz0, fp);
2822}
2823
2824static void
2825bi_disasm_fma_rrot_double_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2826{
2827    static const char *bytes2_table[] = {
2828        "", ".bytes2"
2829    };
2830
2831    const char *bytes2 = bytes2_table[_BITS(bits, 9, 1)];
2832
2833    static const char *lane2_table[] = {
2834        "", ".b2"
2835    };
2836
2837    const char *lane2 = lane2_table[_BITS(bits, 10, 1)];
2838
2839    static const char *result_word_table[] = {
2840        "", ".w1"
2841    };
2842
2843    const char *result_word = result_word_table[_BITS(bits, 11, 1)];
2844
2845    fputs("*RROT_DOUBLE.i32", fp);
2846    fputs(result_word, fp);
2847    fputs(" ", fp);
2848    bi_disasm_dest_fma(fp, next_regs, last);
2849    fputs(", ", fp);
2850    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2851    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2852    fputs(", ", fp);
2853    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2854    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2855    fputs(", ", fp);
2856    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2857    fputs(bytes2, fp);
2858    fputs(lane2, fp);
2859}
2860
2861static void
2862bi_disasm_fma_rshift_and_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2863{
2864    static const char *lane2_table[] = {
2865        "", ".b1", ".b2", ".b3"
2866    };
2867
2868    const char *lane2 = lane2_table[_BITS(bits, 9, 2)];
2869
2870    static const char *not1_table[] = {
2871        "", ".not"
2872    };
2873
2874    const char *not1 = not1_table[_BITS(bits, 14, 1)];
2875
2876    static const char *not_result_table[] = {
2877        ".not", ""
2878    };
2879
2880    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
2881
2882    fputs("*RSHIFT_AND.i32", fp);
2883    fputs(not_result, fp);
2884    fputs(" ", fp);
2885    bi_disasm_dest_fma(fp, next_regs, last);
2886    fputs(", ", fp);
2887    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2888    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2889    fputs(", ", fp);
2890    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2891    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2892    fputs(not1, fp);
2893    fputs(", ", fp);
2894    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2895    fputs(lane2, fp);
2896}
2897
2898static void
2899bi_disasm_fma_rshift_and_v2i16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2900{
2901    static const char *lanes2_table[] = {
2902        ".b00", ".b11", ".b22", ".b33"
2903    };
2904    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
2905    static const char *not1_table[] = {
2906        "", ".not"
2907    };
2908
2909    const char *not1 = not1_table[_BITS(bits, 14, 1)];
2910
2911    static const char *not_result_table[] = {
2912        ".not", ""
2913    };
2914
2915    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
2916
2917    fputs("*RSHIFT_AND.v2i16", fp);
2918    fputs(not_result, fp);
2919    fputs(" ", fp);
2920    bi_disasm_dest_fma(fp, next_regs, last);
2921    fputs(", ", fp);
2922    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2923    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2924    fputs(", ", fp);
2925    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2926    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2927    fputs(not1, fp);
2928    fputs(", ", fp);
2929    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2930    fputs(lanes2, fp);
2931}
2932
2933static void
2934bi_disasm_fma_rshift_and_v2i16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2935{
2936    static const char *lanes2_table[] = {
2937        ".reserved", ".b01", ".b23", ""
2938    };
2939    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
2940    static const char *not1_table[] = {
2941        "", ".not"
2942    };
2943
2944    const char *not1 = not1_table[_BITS(bits, 14, 1)];
2945
2946    static const char *not_result_table[] = {
2947        ".not", ""
2948    };
2949
2950    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
2951
2952    fputs("*RSHIFT_AND.v2i16", fp);
2953    fputs(not_result, fp);
2954    fputs(" ", fp);
2955    bi_disasm_dest_fma(fp, next_regs, last);
2956    fputs(", ", fp);
2957    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2958    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2959    fputs(", ", fp);
2960    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2961    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2962    fputs(not1, fp);
2963    fputs(", ", fp);
2964    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
2965    fputs(lanes2, fp);
2966}
2967
2968static void
2969bi_disasm_fma_rshift_and_v4i8_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
2970{
2971    static const char *lanes2_table[] = {
2972        ".b0000", ".b1111", ".b2222", ".b3333"
2973    };
2974    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
2975    static const char *not1_table[] = {
2976        "", ".not"
2977    };
2978
2979    const char *not1 = not1_table[_BITS(bits, 14, 1)];
2980
2981    static const char *not_result_table[] = {
2982        ".not", ""
2983    };
2984
2985    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
2986
2987    fputs("*RSHIFT_AND.v4i8", fp);
2988    fputs(not_result, fp);
2989    fputs(" ", fp);
2990    bi_disasm_dest_fma(fp, next_regs, last);
2991    fputs(", ", fp);
2992    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
2993    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
2994    fputs(", ", fp);
2995    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
2996    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
2997    fputs(not1, fp);
2998    fputs(", ", fp);
2999    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
3000    fputs(lanes2, fp);
3001}
3002
3003static void
3004bi_disasm_fma_rshift_and_v4i8_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3005{
3006    static const char *lanes2_table[] = {
3007        ""
3008    };
3009    const char *lanes2 = lanes2_table[0];
3010    static const char *not1_table[] = {
3011        "", ".not"
3012    };
3013
3014    const char *not1 = not1_table[_BITS(bits, 14, 1)];
3015
3016    static const char *not_result_table[] = {
3017        ".not", ""
3018    };
3019
3020    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
3021
3022    fputs("*RSHIFT_AND.v4i8", fp);
3023    fputs(not_result, fp);
3024    fputs(" ", fp);
3025    bi_disasm_dest_fma(fp, next_regs, last);
3026    fputs(", ", fp);
3027    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3028    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3029    fputs(", ", fp);
3030    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
3031    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3032    fputs(not1, fp);
3033    fputs(", ", fp);
3034    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
3035    fputs(lanes2, fp);
3036}
3037
3038static void
3039bi_disasm_fma_rshift_double_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3040{
3041    static const char *bytes2_table[] = {
3042        "", ".bytes2"
3043    };
3044
3045    const char *bytes2 = bytes2_table[_BITS(bits, 9, 1)];
3046
3047    static const char *lane2_table[] = {
3048        "", ".b2"
3049    };
3050
3051    const char *lane2 = lane2_table[_BITS(bits, 10, 1)];
3052
3053    static const char *result_word_table[] = {
3054        "", ".w1"
3055    };
3056
3057    const char *result_word = result_word_table[_BITS(bits, 11, 1)];
3058
3059    fputs("*RSHIFT_DOUBLE.i32", fp);
3060    fputs(result_word, fp);
3061    fputs(" ", fp);
3062    bi_disasm_dest_fma(fp, next_regs, last);
3063    fputs(", ", fp);
3064    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3065    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3066    fputs(", ", fp);
3067    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
3068    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3069    fputs(", ", fp);
3070    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
3071    fputs(bytes2, fp);
3072    fputs(lane2, fp);
3073}
3074
3075static void
3076bi_disasm_fma_rshift_or_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3077{
3078    static const char *lane2_table[] = {
3079        "", ".b1", ".b2", ".b3"
3080    };
3081
3082    const char *lane2 = lane2_table[_BITS(bits, 9, 2)];
3083
3084    static const char *not1_table[] = {
3085        ".not", ""
3086    };
3087
3088    const char *not1 = not1_table[_BITS(bits, 14, 1)];
3089
3090    static const char *not_result_table[] = {
3091        "", ".not"
3092    };
3093
3094    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
3095
3096    fputs("*RSHIFT_OR.i32", fp);
3097    fputs(not_result, fp);
3098    fputs(" ", fp);
3099    bi_disasm_dest_fma(fp, next_regs, last);
3100    fputs(", ", fp);
3101    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3102    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3103    fputs(", ", fp);
3104    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
3105    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3106    fputs(not1, fp);
3107    fputs(", ", fp);
3108    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
3109    fputs(lane2, fp);
3110}
3111
3112static void
3113bi_disasm_fma_rshift_or_v2i16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3114{
3115    static const char *lanes2_table[] = {
3116        ".b00", ".b11", ".b22", ".b33"
3117    };
3118    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
3119    static const char *not1_table[] = {
3120        ".not", ""
3121    };
3122
3123    const char *not1 = not1_table[_BITS(bits, 14, 1)];
3124
3125    static const char *not_result_table[] = {
3126        "", ".not"
3127    };
3128
3129    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
3130
3131    fputs("*RSHIFT_OR.v2i16", fp);
3132    fputs(not_result, fp);
3133    fputs(" ", fp);
3134    bi_disasm_dest_fma(fp, next_regs, last);
3135    fputs(", ", fp);
3136    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3137    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3138    fputs(", ", fp);
3139    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
3140    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3141    fputs(not1, fp);
3142    fputs(", ", fp);
3143    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
3144    fputs(lanes2, fp);
3145}
3146
3147static void
3148bi_disasm_fma_rshift_or_v2i16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3149{
3150    static const char *lanes2_table[] = {
3151        ".reserved", ".b01", ".b23", ""
3152    };
3153    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
3154    static const char *not1_table[] = {
3155        ".not", ""
3156    };
3157
3158    const char *not1 = not1_table[_BITS(bits, 14, 1)];
3159
3160    static const char *not_result_table[] = {
3161        "", ".not"
3162    };
3163
3164    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
3165
3166    fputs("*RSHIFT_OR.v2i16", fp);
3167    fputs(not_result, fp);
3168    fputs(" ", fp);
3169    bi_disasm_dest_fma(fp, next_regs, last);
3170    fputs(", ", fp);
3171    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3172    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3173    fputs(", ", fp);
3174    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
3175    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3176    fputs(not1, fp);
3177    fputs(", ", fp);
3178    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
3179    fputs(lanes2, fp);
3180}
3181
3182static void
3183bi_disasm_fma_rshift_or_v4i8_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3184{
3185    static const char *lanes2_table[] = {
3186        ".b0000", ".b1111", ".b2222", ".b3333"
3187    };
3188    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
3189    static const char *not1_table[] = {
3190        ".not", ""
3191    };
3192
3193    const char *not1 = not1_table[_BITS(bits, 14, 1)];
3194
3195    static const char *not_result_table[] = {
3196        "", ".not"
3197    };
3198
3199    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
3200
3201    fputs("*RSHIFT_OR.v4i8", fp);
3202    fputs(not_result, fp);
3203    fputs(" ", fp);
3204    bi_disasm_dest_fma(fp, next_regs, last);
3205    fputs(", ", fp);
3206    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3207    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3208    fputs(", ", fp);
3209    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
3210    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3211    fputs(not1, fp);
3212    fputs(", ", fp);
3213    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
3214    fputs(lanes2, fp);
3215}
3216
3217static void
3218bi_disasm_fma_rshift_or_v4i8_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3219{
3220    static const char *lanes2_table[] = {
3221        ""
3222    };
3223    const char *lanes2 = lanes2_table[0];
3224    static const char *not1_table[] = {
3225        ".not", ""
3226    };
3227
3228    const char *not1 = not1_table[_BITS(bits, 14, 1)];
3229
3230    static const char *not_result_table[] = {
3231        "", ".not"
3232    };
3233
3234    const char *not_result = not_result_table[_BITS(bits, 15, 1)];
3235
3236    fputs("*RSHIFT_OR.v4i8", fp);
3237    fputs(not_result, fp);
3238    fputs(" ", fp);
3239    bi_disasm_dest_fma(fp, next_regs, last);
3240    fputs(", ", fp);
3241    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3242    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3243    fputs(", ", fp);
3244    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
3245    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3246    fputs(not1, fp);
3247    fputs(", ", fp);
3248    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
3249    fputs(lanes2, fp);
3250}
3251
3252static void
3253bi_disasm_fma_rshift_xor_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3254{
3255    static const char *lane2_table[] = {
3256        "", ".b1", ".b2", ".b3"
3257    };
3258
3259    const char *lane2 = lane2_table[_BITS(bits, 9, 2)];
3260
3261    static const char *not_result_table[] = {
3262        "", ".not"
3263    };
3264
3265    const char *not_result = not_result_table[_BITS(bits, 13, 1)];
3266
3267    fputs("*RSHIFT_XOR.i32", fp);
3268    fputs(not_result, fp);
3269    fputs(" ", fp);
3270    bi_disasm_dest_fma(fp, next_regs, last);
3271    fputs(", ", fp);
3272    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3273    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3274    fputs(", ", fp);
3275    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
3276    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3277    fputs(", ", fp);
3278    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
3279    fputs(lane2, fp);
3280}
3281
3282static void
3283bi_disasm_fma_rshift_xor_v2i16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3284{
3285    static const char *lanes2_table[] = {
3286        ".b00", ".b11", ".b22", ".b33"
3287    };
3288    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
3289    static const char *not_result_table[] = {
3290        "", ".not"
3291    };
3292
3293    const char *not_result = not_result_table[_BITS(bits, 13, 1)];
3294
3295    fputs("*RSHIFT_XOR.v2i16", fp);
3296    fputs(not_result, fp);
3297    fputs(" ", fp);
3298    bi_disasm_dest_fma(fp, next_regs, last);
3299    fputs(", ", fp);
3300    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3301    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3302    fputs(", ", fp);
3303    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
3304    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3305    fputs(", ", fp);
3306    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
3307    fputs(lanes2, fp);
3308}
3309
3310static void
3311bi_disasm_fma_rshift_xor_v2i16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3312{
3313    static const char *lanes2_table[] = {
3314        ".reserved", ".b01", ".b23", ""
3315    };
3316    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
3317    static const char *not_result_table[] = {
3318        "", ".not"
3319    };
3320
3321    const char *not_result = not_result_table[_BITS(bits, 13, 1)];
3322
3323    fputs("*RSHIFT_XOR.v2i16", fp);
3324    fputs(not_result, fp);
3325    fputs(" ", fp);
3326    bi_disasm_dest_fma(fp, next_regs, last);
3327    fputs(", ", fp);
3328    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3329    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3330    fputs(", ", fp);
3331    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
3332    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3333    fputs(", ", fp);
3334    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
3335    fputs(lanes2, fp);
3336}
3337
3338static void
3339bi_disasm_fma_rshift_xor_v4i8_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3340{
3341    static const char *lanes2_table[] = {
3342        ".b0000", ".b1111", ".b2222", ".b3333"
3343    };
3344    const char *lanes2 = lanes2_table[(_BITS(bits, 9, 2) << 0)];
3345    static const char *not_result_table[] = {
3346        "", ".not"
3347    };
3348
3349    const char *not_result = not_result_table[_BITS(bits, 13, 1)];
3350
3351    fputs("*RSHIFT_XOR.v4i8", fp);
3352    fputs(not_result, fp);
3353    fputs(" ", fp);
3354    bi_disasm_dest_fma(fp, next_regs, last);
3355    fputs(", ", fp);
3356    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3357    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3358    fputs(", ", fp);
3359    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
3360    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3361    fputs(", ", fp);
3362    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
3363    fputs(lanes2, fp);
3364}
3365
3366static void
3367bi_disasm_fma_rshift_xor_v4i8_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3368{
3369    static const char *lanes2_table[] = {
3370        ""
3371    };
3372    const char *lanes2 = lanes2_table[0];
3373    static const char *not_result_table[] = {
3374        "", ".not"
3375    };
3376
3377    const char *not_result = not_result_table[_BITS(bits, 13, 1)];
3378
3379    fputs("*RSHIFT_XOR.v4i8", fp);
3380    fputs(not_result, fp);
3381    fputs(" ", fp);
3382    bi_disasm_dest_fma(fp, next_regs, last);
3383    fputs(", ", fp);
3384    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3385    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3386    fputs(", ", fp);
3387    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
3388    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3389    fputs(", ", fp);
3390    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
3391    fputs(lanes2, fp);
3392}
3393
3394static void
3395bi_disasm_fma_s16_to_s32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3396{
3397    static const char *lane0_table[] = {
3398        "", ".h1"
3399    };
3400
3401    const char *lane0 = lane0_table[_BITS(bits, 4, 1)];
3402
3403    fputs("*S16_TO_S32", fp);
3404    fputs(" ", fp);
3405    bi_disasm_dest_fma(fp, next_regs, last);
3406    fputs(", ", fp);
3407    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3408    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3409    fputs(lane0, fp);
3410}
3411
3412static void
3413bi_disasm_fma_s8_to_s32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3414{
3415    static const char *lane0_table[] = {
3416        "", ".b1", ".b2", ".b3"
3417    };
3418
3419    const char *lane0 = lane0_table[_BITS(bits, 4, 2)];
3420
3421    fputs("*S8_TO_S32", fp);
3422    fputs(" ", fp);
3423    bi_disasm_dest_fma(fp, next_regs, last);
3424    fputs(", ", fp);
3425    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3426    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3427    fputs(lane0, fp);
3428}
3429
3430static void
3431bi_disasm_fma_seg_add(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3432{
3433    static const char *seg_table[] = {
3434        ".reserved", ".reserved", ".wls", ".reserved", ".reserved", ".reserved", ".reserved", ".tl"
3435    };
3436
3437    const char *seg = seg_table[_BITS(bits, 3, 3)];
3438
3439    static const char *preserve_null_table[] = {
3440        "", ".preserve_null"
3441    };
3442
3443    const char *preserve_null = preserve_null_table[_BITS(bits, 7, 1)];
3444
3445    fputs("*SEG_ADD", fp);
3446    fputs(seg, fp);
3447    fputs(preserve_null, fp);
3448    fputs(" ", fp);
3449    bi_disasm_dest_fma(fp, next_regs, last);
3450    fputs(", ", fp);
3451    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3452    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3453}
3454
3455static void
3456bi_disasm_fma_seg_sub(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3457{
3458    static const char *seg_table[] = {
3459        ".reserved", ".reserved", ".wls", ".reserved", ".reserved", ".reserved", ".reserved", ".tl"
3460    };
3461
3462    const char *seg = seg_table[_BITS(bits, 3, 3)];
3463
3464    static const char *preserve_null_table[] = {
3465        "", ".preserve_null"
3466    };
3467
3468    const char *preserve_null = preserve_null_table[_BITS(bits, 7, 1)];
3469
3470    fputs("*SEG_SUB", fp);
3471    fputs(seg, fp);
3472    fputs(preserve_null, fp);
3473    fputs(" ", fp);
3474    bi_disasm_dest_fma(fp, next_regs, last);
3475    fputs(", ", fp);
3476    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3477    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3478}
3479
3480static void
3481bi_disasm_fma_shaddxl_i64(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3482{
3483    fputs("*SHADDXL.i64", fp);
3484    fputs(" ", fp);
3485    bi_disasm_dest_fma(fp, next_regs, last);
3486    fputs(", ", fp);
3487    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3488    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3489    fputs(", ", fp);
3490    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
3491    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3492    fprintf(fp, ", shift:%u", _BITS(bits, 6, 3));
3493}
3494
3495static void
3496bi_disasm_fma_shaddxl_s32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3497{
3498    static const char *lane1_table[] = {
3499        ".h0", ".h1", "", ".reserved"
3500    };
3501
3502    const char *lane1 = lane1_table[_BITS(bits, 9, 2)];
3503
3504    fputs("*SHADDXL.s32", fp);
3505    fputs(" ", fp);
3506    bi_disasm_dest_fma(fp, next_regs, last);
3507    fputs(", ", fp);
3508    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3509    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3510    fputs(", ", fp);
3511    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
3512    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3513    fputs(lane1, fp);
3514    fprintf(fp, ", shift:%u", _BITS(bits, 6, 3));
3515}
3516
3517static void
3518bi_disasm_fma_shaddxl_u32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3519{
3520    static const char *lane1_table[] = {
3521        ".h0", ".h1", "", ".reserved"
3522    };
3523
3524    const char *lane1 = lane1_table[_BITS(bits, 9, 2)];
3525
3526    fputs("*SHADDXL.u32", fp);
3527    fputs(" ", fp);
3528    bi_disasm_dest_fma(fp, next_regs, last);
3529    fputs(", ", fp);
3530    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3531    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3532    fputs(", ", fp);
3533    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
3534    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3535    fputs(lane1, fp);
3536    fprintf(fp, ", shift:%u", _BITS(bits, 6, 3));
3537}
3538
3539static void
3540bi_disasm_fma_u16_to_u32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3541{
3542    static const char *lane0_table[] = {
3543        "", ".h1"
3544    };
3545
3546    const char *lane0 = lane0_table[_BITS(bits, 4, 1)];
3547
3548    fputs("*U16_TO_U32", fp);
3549    fputs(" ", fp);
3550    bi_disasm_dest_fma(fp, next_regs, last);
3551    fputs(", ", fp);
3552    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3553    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3554    fputs(lane0, fp);
3555}
3556
3557static void
3558bi_disasm_fma_u8_to_u32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3559{
3560    static const char *lane0_table[] = {
3561        "", ".b1", ".b2", ".b3"
3562    };
3563
3564    const char *lane0 = lane0_table[_BITS(bits, 4, 2)];
3565
3566    fputs("*U8_TO_U32", fp);
3567    fputs(" ", fp);
3568    bi_disasm_dest_fma(fp, next_regs, last);
3569    fputs(", ", fp);
3570    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3571    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3572    fputs(lane0, fp);
3573}
3574
3575static void
3576bi_disasm_fma_v2f32_to_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3577{
3578    static const char *neg1_table[] = {
3579        "", "", ".neg", ".neg"
3580    };
3581    const char *neg1 = neg1_table[(_BITS(bits, 6, 1) << 0) | (_BITS(bits, 7, 1) << 1)];
3582    static const char *abs0_table[] = {
3583        "", ".abs", "", ".abs"
3584    };
3585    const char *abs0 = abs0_table[(_BITS(bits, 6, 1) << 0) | (_BITS(bits, 7, 1) << 1)];
3586    static const char *neg0_table[] = {
3587        "", "", ".neg", ".neg"
3588    };
3589    const char *neg0 = neg0_table[(_BITS(bits, 6, 1) << 0) | (_BITS(bits, 7, 1) << 1)];
3590    static const char *abs1_table[] = {
3591        "", ".abs", "", ".abs"
3592    };
3593    const char *abs1 = abs1_table[(_BITS(bits, 6, 1) << 0) | (_BITS(bits, 7, 1) << 1)];
3594    static const char *clamp_table[] = {
3595        "", ".clamp_0_inf", ".clamp_m1_1", ".clamp_0_1"
3596    };
3597
3598    const char *clamp = clamp_table[_BITS(bits, 8, 2)];
3599
3600    static const char *round_table[] = {
3601        "", ".rtp", ".rtn", ".rtz", ".rtna", ".reserved", ".reserved", ".reserved"
3602    };
3603
3604    const char *round = round_table[_BITS(bits, 10, 3)];
3605
3606    fputs("*V2F32_TO_V2F16", fp);
3607    fputs(clamp, fp);
3608    fputs(round, fp);
3609    fputs(" ", fp);
3610    bi_disasm_dest_fma(fp, next_regs, last);
3611    fputs(", ", fp);
3612    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3613    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3614    fputs(abs0, fp);
3615    fputs(neg0, fp);
3616    fputs(", ", fp);
3617    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
3618    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3619    fputs(abs1, fp);
3620    fputs(neg1, fp);
3621}
3622
3623static void
3624bi_disasm_fma_vn_asst1_f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3625{
3626    static const char *h_table[] = {
3627        "", ".h"
3628    };
3629
3630    const char *h = h_table[_BITS(bits, 9, 1)];
3631
3632    static const char *l_table[] = {
3633        "", ".l"
3634    };
3635
3636    const char *l = l_table[_BITS(bits, 10, 1)];
3637
3638    static const char *neg2_table[] = {
3639        "", ".neg"
3640    };
3641
3642    const char *neg2 = neg2_table[_BITS(bits, 11, 1)];
3643
3644    fputs("*VN_ASST1.f16", fp);
3645    fputs(h, fp);
3646    fputs(l, fp);
3647    fputs(" ", fp);
3648    bi_disasm_dest_fma(fp, next_regs, last);
3649    fputs(", ", fp);
3650    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3651    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3652    fputs(", ", fp);
3653    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
3654    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3655    fputs(", ", fp);
3656    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
3657    fputs(neg2, fp);
3658}
3659
3660static void
3661bi_disasm_fma_vn_asst1_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3662{
3663    static const char *neg2_table[] = {
3664        "", ".neg"
3665    };
3666
3667    const char *neg2 = neg2_table[_BITS(bits, 12, 1)];
3668
3669    fputs("*VN_ASST1.f32", fp);
3670    fputs(" ", fp);
3671    bi_disasm_dest_fma(fp, next_regs, last);
3672    fputs(", ", fp);
3673    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, true);
3674    if (!(0xfb & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3675    fputs(", ", fp);
3676    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, true);
3677    if (!(0xfb & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3678    fputs(", ", fp);
3679    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, true);
3680    fputs(neg2, fp);
3681    fputs(", ", fp);
3682    dump_src(fp, _BITS(bits, 9, 3), *srcs, branch_offset, consts, true);
3683}
3684
3685static void
3686bi_disasm_add_acmpstore_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3687{
3688    static const char *seg_table[] = {
3689        "", ".wls"
3690    };
3691
3692    const char *seg = seg_table[_BITS(bits, 9, 1)];
3693
3694    fputs("+ACMPSTORE.i32", fp);
3695    fputs(seg, fp);
3696    fputs(" ", fp);
3697    bi_disasm_dest_add(fp, next_regs, last);
3698    fputs(", ", fp);
3699    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
3700    fputs(", ", fp);
3701    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
3702    fprintf(fp, ", @r%u", staging_register);
3703}
3704
3705static void
3706bi_disasm_add_acmpstore_i64(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3707{
3708    static const char *seg_table[] = {
3709        "", ".wls"
3710    };
3711
3712    const char *seg = seg_table[_BITS(bits, 9, 1)];
3713
3714    fputs("+ACMPSTORE.i64", fp);
3715    fputs(seg, fp);
3716    fputs(" ", fp);
3717    bi_disasm_dest_add(fp, next_regs, last);
3718    fputs(", ", fp);
3719    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
3720    fputs(", ", fp);
3721    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
3722    fprintf(fp, ", @r%u", staging_register);
3723}
3724
3725static void
3726bi_disasm_add_acmpxchg_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3727{
3728    static const char *seg_table[] = {
3729        "", ".wls"
3730    };
3731
3732    const char *seg = seg_table[_BITS(bits, 9, 1)];
3733
3734    fputs("+ACMPXCHG.i32", fp);
3735    fputs(seg, fp);
3736    fputs(" ", fp);
3737    bi_disasm_dest_add(fp, next_regs, last);
3738    fputs(", ", fp);
3739    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
3740    fputs(", ", fp);
3741    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
3742    fprintf(fp, ", @r%u", staging_register);
3743}
3744
3745static void
3746bi_disasm_add_acmpxchg_i64(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3747{
3748    static const char *seg_table[] = {
3749        "", ".wls"
3750    };
3751
3752    const char *seg = seg_table[_BITS(bits, 9, 1)];
3753
3754    fputs("+ACMPXCHG.i64", fp);
3755    fputs(seg, fp);
3756    fputs(" ", fp);
3757    bi_disasm_dest_add(fp, next_regs, last);
3758    fputs(", ", fp);
3759    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
3760    fputs(", ", fp);
3761    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
3762    fprintf(fp, ", @r%u", staging_register);
3763}
3764
3765static void
3766bi_disasm_add_atest(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3767{
3768    static const char *widen1_table[] = {
3769        ".reserved", "", ".h0", ".h1"
3770    };
3771
3772    const char *widen1 = widen1_table[_BITS(bits, 6, 2)];
3773
3774    fputs("+ATEST", fp);
3775    fputs(" ", fp);
3776    bi_disasm_dest_add(fp, next_regs, last);
3777    fputs(", ", fp);
3778    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
3779    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
3780    fputs(", ", fp);
3781    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
3782    if (!(0xf7 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3783    fputs(widen1, fp);
3784    fprintf(fp, ", @r%u", staging_register);
3785}
3786
3787static void
3788bi_disasm_add_atom_cx(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3789{
3790    fputs("+ATOM_CX", fp);
3791    fputs(" ", fp);
3792    bi_disasm_dest_add(fp, next_regs, last);
3793    fputs(", ", fp);
3794    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
3795    fputs(", ", fp);
3796    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
3797    fputs(", ", fp);
3798    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
3799    fprintf(fp, ", @r%u", staging_register);
3800}
3801
3802static void
3803bi_disasm_add_axchg_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3804{
3805    static const char *seg_table[] = {
3806        "", ".wls"
3807    };
3808
3809    const char *seg = seg_table[_BITS(bits, 9, 1)];
3810
3811    fputs("+AXCHG.i32", fp);
3812    fputs(seg, fp);
3813    fputs(" ", fp);
3814    bi_disasm_dest_add(fp, next_regs, last);
3815    fputs(", ", fp);
3816    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
3817    fputs(", ", fp);
3818    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
3819    fprintf(fp, ", @r%u", staging_register);
3820}
3821
3822static void
3823bi_disasm_add_axchg_i64(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3824{
3825    static const char *seg_table[] = {
3826        "", ".wls"
3827    };
3828
3829    const char *seg = seg_table[_BITS(bits, 9, 1)];
3830
3831    fputs("+AXCHG.i64", fp);
3832    fputs(seg, fp);
3833    fputs(" ", fp);
3834    bi_disasm_dest_add(fp, next_regs, last);
3835    fputs(", ", fp);
3836    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
3837    fputs(", ", fp);
3838    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
3839    fprintf(fp, ", @r%u", staging_register);
3840}
3841
3842static void
3843bi_disasm_add_barrier(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3844{
3845    fputs("+BARRIER", fp);
3846    fputs(" ", fp);
3847    bi_disasm_dest_add(fp, next_regs, last);
3848}
3849
3850static void
3851bi_disasm_add_blend(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3852{
3853    fputs("+BLEND", fp);
3854    fputs(" ", fp);
3855    bi_disasm_dest_add(fp, next_regs, last);
3856    fputs(", ", fp);
3857    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
3858    fputs(", ", fp);
3859    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
3860    if (!(0xf7 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
3861    fputs(", ", fp);
3862    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
3863    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
3864    fprintf(fp, ", @r%u", staging_register);
3865}
3866
3867static void
3868bi_disasm_add_branch_f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3869{
3870    bool ordering = (_BITS(bits, 0, 3) > _BITS(bits, 3, 3));
3871    static const char *cmpf_0[] = {
3872        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".eq", ".eq", ".ne", ".eq", ".reserved", ".reserved", ".reserved", ".reserved", ".gt", ".gt", ".ge", ".gt", ".reserved", ".reserved", ".reserved", ".reserved", ".lt", ".lt", ".le", ".lt", ".reserved", ".reserved", ".reserved"
3873    };
3874    static const char *cmpf_1[] = {
3875        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".ne", ".ne", ".ne", ".eq", ".reserved", ".reserved", ".reserved", ".reserved", ".ge", ".ge", ".ge", ".gt", ".reserved", ".reserved", ".reserved", ".reserved", ".le", ".le", ".le", ".lt", ".reserved", ".reserved", ".reserved"
3876    };
3877    const char *cmpf = ordering ? cmpf_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : cmpf_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
3878    static const char *widen1_0[] = {
3879        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h0", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h0", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h0", ".h0", ".reserved", ".reserved", ".reserved"
3880    };
3881    static const char *widen1_1[] = {
3882        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h0", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h0", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h0", ".h0", ".reserved", ".reserved", ".reserved"
3883    };
3884    const char *widen1 = ordering ? widen1_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : widen1_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
3885    static const char *widen0_0[] = {
3886        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h1", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h1", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h1", ".h1", ".reserved", ".reserved", ".reserved"
3887    };
3888    static const char *widen0_1[] = {
3889        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h1", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h1", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h1", ".h1", ".reserved", ".reserved", ".reserved"
3890    };
3891    const char *widen0 = ordering ? widen0_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : widen0_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
3892    fputs("+BRANCH.f16", fp);
3893    fputs(cmpf, fp);
3894    fputs(" ", fp);
3895    bi_disasm_dest_add(fp, next_regs, last);
3896    fputs(", ", fp);
3897    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
3898    fputs(widen0, fp);
3899    fputs(", ", fp);
3900    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
3901    fputs(widen1, fp);
3902    fputs(", ", fp);
3903    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
3904    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
3905}
3906
3907static void
3908bi_disasm_add_branch_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3909{
3910    bool ordering = (_BITS(bits, 0, 3) > _BITS(bits, 3, 3));
3911    static const char *cmpf_0[] = {
3912        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".ne", ".ne", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".ge", ".ge", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".le", ".le", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".eq", ".reserved", ".reserved", ".reserved", ".reserved", ".eq", ".eq", ".reserved", ".gt", ".reserved", ".reserved", ".reserved", ".reserved", ".gt", ".gt", ".reserved", ".lt", ".reserved", ".reserved", ".reserved", ".reserved", ".lt", ".lt", ".reserved"
3913    };
3914    static const char *cmpf_1[] = {
3915        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".ne", ".ne", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".ge", ".ge", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".le", ".le", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".ne", ".reserved", ".reserved", ".reserved", ".reserved", ".eq", ".eq", ".reserved", ".ge", ".reserved", ".reserved", ".reserved", ".reserved", ".gt", ".gt", ".reserved", ".le", ".reserved", ".reserved", ".reserved", ".reserved", ".lt", ".lt", ".reserved"
3916    };
3917    const char *cmpf = ordering ? cmpf_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : cmpf_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
3918    static const char *widen1_0[] = {
3919        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".reserved"
3920    };
3921    static const char *widen1_1[] = {
3922        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".reserved"
3923    };
3924    const char *widen1 = ordering ? widen1_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : widen1_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
3925    static const char *widen0_0[] = {
3926        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", "", "", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", "", "", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", "", "", ".reserved"
3927    };
3928    static const char *widen0_1[] = {
3929        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", "", "", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", "", "", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", "", "", ".reserved"
3930    };
3931    const char *widen0 = ordering ? widen0_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : widen0_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
3932    fputs("+BRANCH.f32", fp);
3933    fputs(cmpf, fp);
3934    fputs(" ", fp);
3935    bi_disasm_dest_add(fp, next_regs, last);
3936    fputs(", ", fp);
3937    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
3938    fputs(widen0, fp);
3939    fputs(", ", fp);
3940    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
3941    fputs(widen1, fp);
3942    fputs(", ", fp);
3943    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
3944    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
3945}
3946
3947static void
3948bi_disasm_add_branch_i16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3949{
3950    bool ordering = (_BITS(bits, 0, 3) > _BITS(bits, 3, 3));
3951    static const char *cmpf_0[] = {
3952        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".eq", ".eq", ".ne", ".eq", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
3953    };
3954    static const char *cmpf_1[] = {
3955        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".ne", ".ne", ".ne", ".eq", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
3956    };
3957    const char *cmpf = ordering ? cmpf_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : cmpf_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
3958    static const char *widen1_0[] = {
3959        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h0", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
3960    };
3961    static const char *widen1_1[] = {
3962        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h0", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
3963    };
3964    const char *widen1 = ordering ? widen1_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : widen1_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
3965    static const char *widen0_0[] = {
3966        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h1", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
3967    };
3968    static const char *widen0_1[] = {
3969        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h1", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
3970    };
3971    const char *widen0 = ordering ? widen0_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : widen0_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
3972    fputs("+BRANCH.i16", fp);
3973    fputs(cmpf, fp);
3974    fputs(" ", fp);
3975    bi_disasm_dest_add(fp, next_regs, last);
3976    fputs(", ", fp);
3977    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
3978    fputs(widen0, fp);
3979    fputs(", ", fp);
3980    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
3981    fputs(widen1, fp);
3982    fputs(", ", fp);
3983    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
3984    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
3985}
3986
3987static void
3988bi_disasm_add_branch_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
3989{
3990    bool ordering = (_BITS(bits, 0, 3) > _BITS(bits, 3, 3));
3991    static const char *cmpf_0[] = {
3992        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".eq", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
3993    };
3994    static const char *cmpf_1[] = {
3995        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".ne", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
3996    };
3997    const char *cmpf = ordering ? cmpf_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : cmpf_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
3998    static const char *widen1_0[] = {
3999        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4000    };
4001    static const char *widen1_1[] = {
4002        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4003    };
4004    const char *widen1 = ordering ? widen1_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : widen1_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
4005    static const char *widen0_0[] = {
4006        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4007    };
4008    static const char *widen0_1[] = {
4009        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4010    };
4011    const char *widen0 = ordering ? widen0_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : widen0_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
4012    fputs("+BRANCH.i32", fp);
4013    fputs(cmpf, fp);
4014    fputs(" ", fp);
4015    bi_disasm_dest_add(fp, next_regs, last);
4016    fputs(", ", fp);
4017    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4018    fputs(widen0, fp);
4019    fputs(", ", fp);
4020    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
4021    fputs(widen1, fp);
4022    fputs(", ", fp);
4023    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4024    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
4025}
4026
4027static void
4028bi_disasm_add_branch_s16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4029{
4030    bool ordering = (_BITS(bits, 0, 3) > _BITS(bits, 3, 3));
4031    static const char *cmpf_0[] = {
4032        ".reserved", ".lt", ".lt", ".reserved", ".lt", ".reserved", ".reserved", ".reserved", ".reserved", ".le", ".le", ".reserved", ".le", ".reserved", ".reserved", ".reserved", ".reserved", ".ge", ".ge", ".reserved", ".ge", ".reserved", ".reserved", ".reserved", ".reserved", ".gt", ".gt", ".reserved", ".gt", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4033    };
4034    static const char *cmpf_1[] = {
4035        ".reserved", ".reserved", ".reserved", ".reserved", ".lt", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".le", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".ge", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".gt", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4036    };
4037    const char *cmpf = ordering ? cmpf_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : cmpf_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
4038    static const char *widen1_0[] = {
4039        ".reserved", ".h0", ".h1", ".reserved", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".reserved", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".reserved", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".reserved", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4040    };
4041    static const char *widen1_1[] = {
4042        ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4043    };
4044    const char *widen1 = ordering ? widen1_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : widen1_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
4045    static const char *widen0_0[] = {
4046        ".reserved", ".h0", ".h1", ".reserved", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".reserved", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".reserved", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".reserved", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4047    };
4048    static const char *widen0_1[] = {
4049        ".reserved", ".reserved", ".reserved", ".reserved", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4050    };
4051    const char *widen0 = ordering ? widen0_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : widen0_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
4052    fputs("+BRANCH.s16", fp);
4053    fputs(cmpf, fp);
4054    fputs(" ", fp);
4055    bi_disasm_dest_add(fp, next_regs, last);
4056    fputs(", ", fp);
4057    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4058    fputs(widen0, fp);
4059    fputs(", ", fp);
4060    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
4061    fputs(widen1, fp);
4062    fputs(", ", fp);
4063    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4064    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
4065}
4066
4067static void
4068bi_disasm_add_branch_s32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4069{
4070    bool ordering = (_BITS(bits, 0, 3) > _BITS(bits, 3, 3));
4071    static const char *cmpf_0[] = {
4072        ".lt", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".le", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".ge", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".gt", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4073    };
4074    static const char *cmpf_1[] = {
4075        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4076    };
4077    const char *cmpf = ordering ? cmpf_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : cmpf_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
4078    static const char *widen1_0[] = {
4079        "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4080    };
4081    static const char *widen1_1[] = {
4082        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4083    };
4084    const char *widen1 = ordering ? widen1_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : widen1_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
4085    static const char *widen0_0[] = {
4086        "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4087    };
4088    static const char *widen0_1[] = {
4089        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4090    };
4091    const char *widen0 = ordering ? widen0_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : widen0_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
4092    fputs("+BRANCH.s32", fp);
4093    fputs(cmpf, fp);
4094    fputs(" ", fp);
4095    bi_disasm_dest_add(fp, next_regs, last);
4096    fputs(", ", fp);
4097    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4098    fputs(widen0, fp);
4099    fputs(", ", fp);
4100    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
4101    fputs(widen1, fp);
4102    fputs(", ", fp);
4103    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4104    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
4105}
4106
4107static void
4108bi_disasm_add_branch_u16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4109{
4110    bool ordering = (_BITS(bits, 0, 3) > _BITS(bits, 3, 3));
4111    static const char *cmpf_0[] = {
4112        ".reserved", ".reserved", ".reserved", ".lt", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".le", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".ge", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".gt", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4113    };
4114    static const char *cmpf_1[] = {
4115        ".reserved", ".lt", ".lt", ".lt", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".le", ".le", ".le", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".ge", ".ge", ".ge", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".gt", ".gt", ".gt", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4116    };
4117    const char *cmpf = ordering ? cmpf_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : cmpf_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
4118    static const char *widen1_0[] = {
4119        ".reserved", ".reserved", ".reserved", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4120    };
4121    static const char *widen1_1[] = {
4122        ".reserved", ".h0", ".h1", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4123    };
4124    const char *widen1 = ordering ? widen1_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : widen1_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
4125    static const char *widen0_0[] = {
4126        ".reserved", ".reserved", ".reserved", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4127    };
4128    static const char *widen0_1[] = {
4129        ".reserved", ".h0", ".h1", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h0", ".h1", ".h1", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4130    };
4131    const char *widen0 = ordering ? widen0_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : widen0_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
4132    fputs("+BRANCH.u16", fp);
4133    fputs(cmpf, fp);
4134    fputs(" ", fp);
4135    bi_disasm_dest_add(fp, next_regs, last);
4136    fputs(", ", fp);
4137    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4138    fputs(widen0, fp);
4139    fputs(", ", fp);
4140    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
4141    fputs(widen1, fp);
4142    fputs(", ", fp);
4143    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4144    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
4145}
4146
4147static void
4148bi_disasm_add_branch_u32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4149{
4150    bool ordering = (_BITS(bits, 0, 3) > _BITS(bits, 3, 3));
4151    static const char *cmpf_0[] = {
4152        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4153    };
4154    static const char *cmpf_1[] = {
4155        ".lt", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".le", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".ge", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".gt", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4156    };
4157    const char *cmpf = ordering ? cmpf_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : cmpf_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
4158    static const char *widen1_0[] = {
4159        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4160    };
4161    static const char *widen1_1[] = {
4162        "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4163    };
4164    const char *widen1 = ordering ? widen1_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : widen1_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
4165    static const char *widen0_0[] = {
4166        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4167    };
4168    static const char *widen0_1[] = {
4169        "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4170    };
4171    const char *widen0 = ordering ? widen0_1[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)] : widen0_0[(_BITS(bits, 12, 3) << 0) | (_BITS(bits, 9, 3) << 3)];
4172    fputs("+BRANCH.u32", fp);
4173    fputs(cmpf, fp);
4174    fputs(" ", fp);
4175    bi_disasm_dest_add(fp, next_regs, last);
4176    fputs(", ", fp);
4177    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4178    fputs(widen0, fp);
4179    fputs(", ", fp);
4180    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
4181    fputs(widen1, fp);
4182    fputs(", ", fp);
4183    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4184    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
4185}
4186
4187static void
4188bi_disasm_add_branchc_i16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4189{
4190    static const char *lane0_table[] = {
4191        ".reserved", ".h1", "", ".reserved"
4192    };
4193    const char *lane0 = lane0_table[(_BITS(bits, 9, 1) << 0) | (_BITS(bits, 3, 1) << 1)];
4194    static const char *combine_table[] = {
4195        ".any", ".all"
4196    };
4197
4198    const char *combine = combine_table[_BITS(bits, 10, 1)];
4199
4200    fputs("+BRANCHC.i16", fp);
4201    fputs(combine, fp);
4202    fputs(" ", fp);
4203    bi_disasm_dest_add(fp, next_regs, last);
4204    fputs(", ", fp);
4205    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4206    fputs(lane0, fp);
4207    fputs(", ", fp);
4208    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4209    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
4210}
4211
4212static void
4213bi_disasm_add_branchc_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4214{
4215    static const char *combine_table[] = {
4216        ".any", ".all"
4217    };
4218
4219    const char *combine = combine_table[_BITS(bits, 10, 1)];
4220
4221    fputs("+BRANCHC.i32", fp);
4222    fputs(combine, fp);
4223    fputs(" ", fp);
4224    bi_disasm_dest_add(fp, next_regs, last);
4225    fputs(", ", fp);
4226    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4227    fputs(", ", fp);
4228    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4229    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
4230}
4231
4232static void
4233bi_disasm_add_branchz_f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4234{
4235    static const char *cmpf_table[] = {
4236        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".ne", ".ne", ".reserved", ".reserved", ".eq", ".eq", ".reserved", ".reserved", ".ge", ".ge", ".reserved", ".reserved", ".gt", ".gt", ".reserved", ".reserved", ".le", ".le", ".reserved", ".reserved", ".lt", ".lt", ".reserved"
4237    };
4238    const char *cmpf = cmpf_table[(_BITS(bits, 4, 2) << 0) | (_BITS(bits, 3, 1) << 2) | (_BITS(bits, 9, 3) << 3)];
4239    static const char *widen0_table[] = {
4240        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".h1", ".h0", ".reserved", ".reserved", ".h1", ".h0", ".reserved", ".reserved", ".h1", ".h0", ".reserved", ".reserved", ".h1", ".h0", ".reserved", ".reserved", ".h1", ".h0", ".reserved", ".reserved", ".h1", ".h0", ".reserved"
4241    };
4242    const char *widen0 = widen0_table[(_BITS(bits, 4, 2) << 0) | (_BITS(bits, 3, 1) << 2) | (_BITS(bits, 9, 3) << 3)];
4243    fputs("+BRANCHZ.f16", fp);
4244    fputs(cmpf, fp);
4245    fputs(" ", fp);
4246    bi_disasm_dest_add(fp, next_regs, last);
4247    fputs(", ", fp);
4248    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4249    fputs(widen0, fp);
4250    fputs(", ", fp);
4251    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4252    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
4253}
4254
4255static void
4256bi_disasm_add_branchz_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4257{
4258    static const char *cmpf_table[] = {
4259        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".ne", ".eq", ".ge", ".gt", ".le", ".lt"
4260    };
4261    const char *cmpf = cmpf_table[(_BITS(bits, 3, 1) << 0) | (_BITS(bits, 9, 3) << 1)];
4262    fputs("+BRANCHZ.f32", fp);
4263    fputs(cmpf, fp);
4264    fputs(" ", fp);
4265    bi_disasm_dest_add(fp, next_regs, last);
4266    fputs(", ", fp);
4267    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4268    fputs(", ", fp);
4269    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4270    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
4271}
4272
4273static void
4274bi_disasm_add_branchz_i16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4275{
4276    static const char *cmpf_table[] = {
4277        ".reserved", ".ne", ".ne", ".reserved", ".reserved", ".eq", ".eq", ".reserved"
4278    };
4279    const char *cmpf = cmpf_table[(_BITS(bits, 4, 2) << 0) | (_BITS(bits, 3, 1) << 2)];
4280    static const char *widen0_table[] = {
4281        ".reserved", ".h1", ".h0", ".reserved", ".reserved", ".h1", ".h0", ".reserved"
4282    };
4283    const char *widen0 = widen0_table[(_BITS(bits, 4, 2) << 0) | (_BITS(bits, 3, 1) << 2)];
4284    fputs("+BRANCHZ.i16", fp);
4285    fputs(cmpf, fp);
4286    fputs(" ", fp);
4287    bi_disasm_dest_add(fp, next_regs, last);
4288    fputs(", ", fp);
4289    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4290    fputs(widen0, fp);
4291    fputs(", ", fp);
4292    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4293    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
4294}
4295
4296static void
4297bi_disasm_add_branchz_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4298{
4299    static const char *cmpf_table[] = {
4300        ".ne", ".eq"
4301    };
4302    const char *cmpf = cmpf_table[(_BITS(bits, 3, 1) << 0)];
4303    fputs("+BRANCHZ.i32", fp);
4304    fputs(cmpf, fp);
4305    fputs(" ", fp);
4306    bi_disasm_dest_add(fp, next_regs, last);
4307    fputs(", ", fp);
4308    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4309    fputs(", ", fp);
4310    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4311    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
4312}
4313
4314static void
4315bi_disasm_add_branchz_s16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4316{
4317    static const char *cmpf_table[] = {
4318        ".reserved", ".lt", ".lt", ".reserved", ".reserved", ".le", ".le", ".reserved", ".reserved", ".ge", ".ge", ".reserved", ".reserved", ".gt", ".gt", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4319    };
4320    const char *cmpf = cmpf_table[(_BITS(bits, 4, 2) << 0) | (_BITS(bits, 9, 3) << 2)];
4321    static const char *widen0_table[] = {
4322        ".reserved", ".h1", ".h0", ".reserved", ".reserved", ".h1", ".h0", ".reserved", ".reserved", ".h1", ".h0", ".reserved", ".reserved", ".h1", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4323    };
4324    const char *widen0 = widen0_table[(_BITS(bits, 4, 2) << 0) | (_BITS(bits, 9, 3) << 2)];
4325    fputs("+BRANCHZ.s16", fp);
4326    fputs(cmpf, fp);
4327    fputs(" ", fp);
4328    bi_disasm_dest_add(fp, next_regs, last);
4329    fputs(", ", fp);
4330    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4331    fputs(widen0, fp);
4332    fputs(", ", fp);
4333    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4334    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
4335}
4336
4337static void
4338bi_disasm_add_branchz_s32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4339{
4340    static const char *cmpf_table[] = {
4341        ".lt", ".le", ".ge", ".gt", ".reserved", ".reserved", ".reserved", ".reserved"
4342    };
4343    const char *cmpf = cmpf_table[(_BITS(bits, 9, 3) << 0)];
4344    fputs("+BRANCHZ.s32", fp);
4345    fputs(cmpf, fp);
4346    fputs(" ", fp);
4347    bi_disasm_dest_add(fp, next_regs, last);
4348    fputs(", ", fp);
4349    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4350    fputs(", ", fp);
4351    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4352    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
4353}
4354
4355static void
4356bi_disasm_add_branchz_u16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4357{
4358    static const char *cmpf_table[] = {
4359        ".reserved", ".lt", ".lt", ".reserved", ".reserved", ".le", ".le", ".reserved", ".reserved", ".ge", ".ge", ".reserved", ".reserved", ".gt", ".gt", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4360    };
4361    const char *cmpf = cmpf_table[(_BITS(bits, 4, 2) << 0) | (_BITS(bits, 9, 3) << 2)];
4362    static const char *widen0_table[] = {
4363        ".reserved", ".h1", ".h0", ".reserved", ".reserved", ".h1", ".h0", ".reserved", ".reserved", ".h1", ".h0", ".reserved", ".reserved", ".h1", ".h0", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4364    };
4365    const char *widen0 = widen0_table[(_BITS(bits, 4, 2) << 0) | (_BITS(bits, 9, 3) << 2)];
4366    fputs("+BRANCHZ.u16", fp);
4367    fputs(cmpf, fp);
4368    fputs(" ", fp);
4369    bi_disasm_dest_add(fp, next_regs, last);
4370    fputs(", ", fp);
4371    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4372    fputs(widen0, fp);
4373    fputs(", ", fp);
4374    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4375    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
4376}
4377
4378static void
4379bi_disasm_add_branchz_u32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4380{
4381    static const char *cmpf_table[] = {
4382        ".lt", ".le", ".ge", ".gt", ".reserved", ".reserved", ".reserved", ".reserved"
4383    };
4384    const char *cmpf = cmpf_table[(_BITS(bits, 9, 3) << 0)];
4385    fputs("+BRANCHZ.u32", fp);
4386    fputs(cmpf, fp);
4387    fputs(" ", fp);
4388    bi_disasm_dest_add(fp, next_regs, last);
4389    fputs(", ", fp);
4390    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4391    fputs(", ", fp);
4392    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4393    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
4394}
4395
4396static void
4397bi_disasm_add_branch_diverg(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4398{
4399    fputs("+BRANCH_DIVERG", fp);
4400    fputs(" ", fp);
4401    bi_disasm_dest_add(fp, next_regs, last);
4402    fputs(", ", fp);
4403    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4404    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
4405}
4406
4407static void
4408bi_disasm_add_branch_lowbits_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4409{
4410    fputs("+BRANCH_LOWBITS.f32", fp);
4411    fputs(" ", fp);
4412    bi_disasm_dest_add(fp, next_regs, last);
4413    fputs(", ", fp);
4414    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4415    fputs(", ", fp);
4416    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4417    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
4418}
4419
4420static void
4421bi_disasm_add_branch_no_diverg(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4422{
4423    fputs("+BRANCH_NO_DIVERG", fp);
4424    fputs(" ", fp);
4425    bi_disasm_dest_add(fp, next_regs, last);
4426    fputs(", ", fp);
4427    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4428    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
4429}
4430
4431static void
4432bi_disasm_add_clper_v6_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4433{
4434    fputs("+CLPER_V6.i32", fp);
4435    fputs(" ", fp);
4436    bi_disasm_dest_add(fp, next_regs, last);
4437    fputs(", ", fp);
4438    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4439    if (!(0x7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
4440    fputs(", ", fp);
4441    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
4442}
4443
4444static void
4445bi_disasm_add_clper_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4446{
4447    static const char *lane_op_table[] = {
4448        "", ".xor", ".accumulate", ".shift"
4449    };
4450
4451    const char *lane_op = lane_op_table[_BITS(bits, 6, 2)];
4452
4453    static const char *subgroup_table[] = {
4454        ".subgroup2", ".subgroup4", ".subgroup8", ".reserved"
4455    };
4456
4457    const char *subgroup = subgroup_table[_BITS(bits, 8, 2)];
4458
4459    static const char *inactive_result_table[] = {
4460        ".zero", ".umax", ".i1", ".v2i1", ".smin", ".smax", ".v2smin", ".v2smax", ".v4smin", ".v4smax", ".f1", ".v2f1", ".infn", ".inf", ".v2infn", ".v2inf"
4461    };
4462
4463    const char *inactive_result = inactive_result_table[_BITS(bits, 10, 4)];
4464
4465    fputs("+CLPER.i32", fp);
4466    fputs(lane_op, fp);
4467    fputs(subgroup, fp);
4468    fputs(inactive_result, fp);
4469    fputs(" ", fp);
4470    bi_disasm_dest_add(fp, next_regs, last);
4471    fputs(", ", fp);
4472    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4473    if (!(0x7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
4474    fputs(", ", fp);
4475    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
4476}
4477
4478static void
4479bi_disasm_add_cubeface2(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4480{
4481    fputs("+CUBEFACE2", fp);
4482    fputs(" ", fp);
4483    bi_disasm_dest_add(fp, next_regs, last);
4484    fputs(", ", fp);
4485    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4486}
4487
4488static void
4489bi_disasm_add_cube_ssel(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4490{
4491    static const char *neg1_table[] = {
4492        "", ".neg"
4493    };
4494    const char *neg1 = neg1_table[(_BITS(bits, 9, 1) << 0)];
4495    static const char *neg0_table[] = {
4496        "", ".neg"
4497    };
4498    const char *neg0 = neg0_table[(_BITS(bits, 9, 1) << 0)];
4499    fputs("+CUBE_SSEL", fp);
4500    fputs(" ", fp);
4501    bi_disasm_dest_add(fp, next_regs, last);
4502    fputs(", ", fp);
4503    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4504    fputs(neg0, fp);
4505    fputs(", ", fp);
4506    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
4507    fputs(neg1, fp);
4508    fputs(", ", fp);
4509    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4510}
4511
4512static void
4513bi_disasm_add_cube_tsel(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4514{
4515    static const char *neg1_table[] = {
4516        "", ".neg"
4517    };
4518    const char *neg1 = neg1_table[(_BITS(bits, 9, 1) << 0)];
4519    static const char *neg0_table[] = {
4520        "", ".neg"
4521    };
4522    const char *neg0 = neg0_table[(_BITS(bits, 9, 1) << 0)];
4523    fputs("+CUBE_TSEL", fp);
4524    fputs(" ", fp);
4525    bi_disasm_dest_add(fp, next_regs, last);
4526    fputs(", ", fp);
4527    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4528    fputs(neg0, fp);
4529    fputs(", ", fp);
4530    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
4531    fputs(neg1, fp);
4532    fputs(", ", fp);
4533    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4534}
4535
4536static void
4537bi_disasm_add_discard_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4538{
4539    static const char *cmpf_table[] = {
4540        ".eq", ".ne", ".lt", ".le", ".eq", ".ne", ".lt", ".le", ".eq", ".ne", ".lt", ".le", ".eq", ".ne", ".lt", ".le", ".eq", ".ne", ".lt", ".le", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4541    };
4542    const char *cmpf = cmpf_table[(_BITS(bits, 6, 2) << 0) | (_BITS(bits, 8, 3) << 2)];
4543    static const char *widen1_table[] = {
4544        ".h0", ".h0", ".h0", ".h0", ".h0", ".h0", ".h0", ".h0", ".h1", ".h1", ".h1", ".h1", ".h1", ".h1", ".h1", ".h1", "", "", "", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4545    };
4546    const char *widen1 = widen1_table[(_BITS(bits, 6, 2) << 0) | (_BITS(bits, 8, 3) << 2)];
4547    static const char *widen0_table[] = {
4548        ".h0", ".h0", ".h0", ".h0", ".h1", ".h1", ".h1", ".h1", ".h0", ".h0", ".h0", ".h0", ".h1", ".h1", ".h1", ".h1", "", "", "", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
4549    };
4550    const char *widen0 = widen0_table[(_BITS(bits, 6, 2) << 0) | (_BITS(bits, 8, 3) << 2)];
4551    fputs("+DISCARD.f32", fp);
4552    fputs(cmpf, fp);
4553    fputs(" ", fp);
4554    bi_disasm_dest_add(fp, next_regs, last);
4555    fputs(", ", fp);
4556    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4557    fputs(widen0, fp);
4558    fputs(", ", fp);
4559    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
4560    fputs(widen1, fp);
4561}
4562
4563static void
4564bi_disasm_add_doorbell(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4565{
4566    fputs("+DOORBELL", fp);
4567    fputs(" ", fp);
4568    bi_disasm_dest_add(fp, next_regs, last);
4569    fputs(", ", fp);
4570    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4571}
4572
4573static void
4574bi_disasm_add_eureka(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4575{
4576    fputs("+EUREKA", fp);
4577    fputs(" ", fp);
4578    bi_disasm_dest_add(fp, next_regs, last);
4579    fputs(", ", fp);
4580    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4581}
4582
4583static void
4584bi_disasm_add_f16_to_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4585{
4586    static const char *lane0_table[] = {
4587        "", ".h1"
4588    };
4589
4590    const char *lane0 = lane0_table[_BITS(bits, 3, 1)];
4591
4592    fputs("+F16_TO_F32", fp);
4593    fputs(" ", fp);
4594    bi_disasm_dest_add(fp, next_regs, last);
4595    fputs(", ", fp);
4596    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4597    fputs(lane0, fp);
4598}
4599
4600static void
4601bi_disasm_add_f16_to_s32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4602{
4603    static const char *round_table[] = {
4604        "", ".rtp", ".rtn", ".rtz"
4605    };
4606    const char *round = round_table[(_BITS(bits, 4, 2) << 0)];
4607    static const char *lane0_table[] = {
4608        "", ".h1"
4609    };
4610
4611    const char *lane0 = lane0_table[_BITS(bits, 7, 1)];
4612
4613    fputs("+F16_TO_S32", fp);
4614    fputs(round, fp);
4615    fputs(" ", fp);
4616    bi_disasm_dest_add(fp, next_regs, last);
4617    fputs(", ", fp);
4618    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4619    fputs(lane0, fp);
4620}
4621
4622static void
4623bi_disasm_add_f16_to_s32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4624{
4625    static const char *round_table[] = {
4626        ".rtna"
4627    };
4628    const char *round = round_table[0];
4629    static const char *lane0_table[] = {
4630        "", ".h1"
4631    };
4632
4633    const char *lane0 = lane0_table[_BITS(bits, 5, 1)];
4634
4635    fputs("+F16_TO_S32", fp);
4636    fputs(round, fp);
4637    fputs(" ", fp);
4638    bi_disasm_dest_add(fp, next_regs, last);
4639    fputs(", ", fp);
4640    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4641    fputs(lane0, fp);
4642}
4643
4644static void
4645bi_disasm_add_f16_to_u32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4646{
4647    static const char *round_table[] = {
4648        "", ".rtp", ".rtn", ".rtz"
4649    };
4650    const char *round = round_table[(_BITS(bits, 4, 2) << 0)];
4651    static const char *lane0_table[] = {
4652        "", ".h1"
4653    };
4654
4655    const char *lane0 = lane0_table[_BITS(bits, 7, 1)];
4656
4657    fputs("+F16_TO_U32", fp);
4658    fputs(round, fp);
4659    fputs(" ", fp);
4660    bi_disasm_dest_add(fp, next_regs, last);
4661    fputs(", ", fp);
4662    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4663    fputs(lane0, fp);
4664}
4665
4666static void
4667bi_disasm_add_f16_to_u32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4668{
4669    static const char *round_table[] = {
4670        ".rtna"
4671    };
4672    const char *round = round_table[0];
4673    static const char *lane0_table[] = {
4674        "", ".h1"
4675    };
4676
4677    const char *lane0 = lane0_table[_BITS(bits, 5, 1)];
4678
4679    fputs("+F16_TO_U32", fp);
4680    fputs(round, fp);
4681    fputs(" ", fp);
4682    bi_disasm_dest_add(fp, next_regs, last);
4683    fputs(", ", fp);
4684    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4685    fputs(lane0, fp);
4686}
4687
4688static void
4689bi_disasm_add_f32_to_s32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4690{
4691    static const char *round_table[] = {
4692        "", ".rtp", ".rtn", ".rtz"
4693    };
4694    const char *round = round_table[(_BITS(bits, 4, 2) << 0)];
4695    fputs("+F32_TO_S32", fp);
4696    fputs(round, fp);
4697    fputs(" ", fp);
4698    bi_disasm_dest_add(fp, next_regs, last);
4699    fputs(", ", fp);
4700    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4701}
4702
4703static void
4704bi_disasm_add_f32_to_s32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4705{
4706    static const char *round_table[] = {
4707        ".rtna"
4708    };
4709    const char *round = round_table[0];
4710    fputs("+F32_TO_S32", fp);
4711    fputs(round, fp);
4712    fputs(" ", fp);
4713    bi_disasm_dest_add(fp, next_regs, last);
4714    fputs(", ", fp);
4715    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4716}
4717
4718static void
4719bi_disasm_add_f32_to_u32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4720{
4721    static const char *round_table[] = {
4722        "", ".rtp", ".rtn", ".rtz"
4723    };
4724    const char *round = round_table[(_BITS(bits, 4, 2) << 0)];
4725    fputs("+F32_TO_U32", fp);
4726    fputs(round, fp);
4727    fputs(" ", fp);
4728    bi_disasm_dest_add(fp, next_regs, last);
4729    fputs(", ", fp);
4730    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4731}
4732
4733static void
4734bi_disasm_add_f32_to_u32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4735{
4736    static const char *round_table[] = {
4737        ".rtna"
4738    };
4739    const char *round = round_table[0];
4740    fputs("+F32_TO_U32", fp);
4741    fputs(round, fp);
4742    fputs(" ", fp);
4743    bi_disasm_dest_add(fp, next_regs, last);
4744    fputs(", ", fp);
4745    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4746}
4747
4748static void
4749bi_disasm_add_fadd_f32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4750{
4751    static const char *round_table[] = {
4752        "", ".rtp", ".rtn", ".rtz", "", ".rtp", ".rtn", ".rtz", "", ".rtp", ".rtn", ".rtz", "", ".rtp", ".rtn", ".rtz"
4753    };
4754    const char *round = round_table[(_BITS(bits, 13, 2) << 0) | (_BITS(bits, 9, 2) << 2)];
4755    static const char *widen1_table[] = {
4756        "", "", "", "", ".h0", ".h0", ".h0", ".h0", ".h1", ".h1", ".h1", ".h1", ".h0", ".h0", ".h0", ".h0"
4757    };
4758    const char *widen1 = widen1_table[(_BITS(bits, 13, 2) << 0) | (_BITS(bits, 9, 2) << 2)];
4759    static const char *widen0_table[] = {
4760        "", "", "", "", "", "", "", "", "", "", "", "", ".h0", ".h0", ".h0", ".h0"
4761    };
4762    const char *widen0 = widen0_table[(_BITS(bits, 13, 2) << 0) | (_BITS(bits, 9, 2) << 2)];
4763    static const char *abs1_table[] = {
4764        "", ".abs"
4765    };
4766
4767    const char *abs1 = abs1_table[_BITS(bits, 6, 1)];
4768
4769    static const char *neg0_table[] = {
4770        "", ".neg"
4771    };
4772
4773    const char *neg0 = neg0_table[_BITS(bits, 7, 1)];
4774
4775    static const char *neg1_table[] = {
4776        "", ".neg"
4777    };
4778
4779    const char *neg1 = neg1_table[_BITS(bits, 8, 1)];
4780
4781    static const char *clamp_table[] = {
4782        "", ".clamp_0_inf", ".clamp_m1_1", ".clamp_0_1"
4783    };
4784
4785    const char *clamp = clamp_table[_BITS(bits, 11, 2)];
4786
4787    static const char *abs0_table[] = {
4788        "", ".abs"
4789    };
4790
4791    const char *abs0 = abs0_table[_BITS(bits, 15, 1)];
4792
4793    fputs("+FADD.f32", fp);
4794    fputs(round, fp);
4795    fputs(clamp, fp);
4796    fputs(" ", fp);
4797    bi_disasm_dest_add(fp, next_regs, last);
4798    fputs(", ", fp);
4799    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4800    fputs(neg0, fp);
4801    fputs(abs0, fp);
4802    fputs(widen0, fp);
4803    fputs(", ", fp);
4804    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
4805    fputs(abs1, fp);
4806    fputs(neg1, fp);
4807    fputs(widen1, fp);
4808}
4809
4810static void
4811bi_disasm_add_fadd_f32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4812{
4813    static const char *abs0_table[] = {
4814        ""
4815    };
4816    const char *abs0 = abs0_table[0];
4817    static const char *round_table[] = {
4818        ".rto"
4819    };
4820    const char *round = round_table[0];
4821    static const char *clamp_table[] = {
4822        ""
4823    };
4824    const char *clamp = clamp_table[0];
4825    static const char *widen1_table[] = {
4826        ""
4827    };
4828    const char *widen1 = widen1_table[0];
4829    static const char *neg1_table[] = {
4830        ""
4831    };
4832    const char *neg1 = neg1_table[0];
4833    static const char *neg0_table[] = {
4834        ""
4835    };
4836    const char *neg0 = neg0_table[0];
4837    static const char *abs1_table[] = {
4838        ""
4839    };
4840    const char *abs1 = abs1_table[0];
4841    static const char *widen0_table[] = {
4842        ""
4843    };
4844    const char *widen0 = widen0_table[0];
4845    fputs("+FADD.f32", fp);
4846    fputs(round, fp);
4847    fputs(clamp, fp);
4848    fputs(" ", fp);
4849    bi_disasm_dest_add(fp, next_regs, last);
4850    fputs(", ", fp);
4851    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4852    fputs(neg0, fp);
4853    fputs(abs0, fp);
4854    fputs(widen0, fp);
4855    fputs(", ", fp);
4856    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
4857    fputs(abs1, fp);
4858    fputs(neg1, fp);
4859    fputs(widen1, fp);
4860}
4861
4862static void
4863bi_disasm_add_fadd_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4864{
4865    static const char *abs1_table[] = {
4866        "", ".abs"
4867    };
4868
4869    const char *abs1 = abs1_table[_BITS(bits, 6, 1)];
4870
4871    static const char *neg0_table[] = {
4872        "", ".neg"
4873    };
4874
4875    const char *neg0 = neg0_table[_BITS(bits, 7, 1)];
4876
4877    static const char *neg1_table[] = {
4878        "", ".neg"
4879    };
4880
4881    const char *neg1 = neg1_table[_BITS(bits, 8, 1)];
4882
4883    static const char *swz0_table[] = {
4884        ".h00", ".h10", "", ".h11"
4885    };
4886
4887    const char *swz0 = swz0_table[_BITS(bits, 9, 2)];
4888
4889    static const char *swz1_table[] = {
4890        ".h00", ".h10", "", ".h11"
4891    };
4892
4893    const char *swz1 = swz1_table[_BITS(bits, 11, 2)];
4894
4895    static const char *round_table[] = {
4896        "", ".rtp", ".rtn", ".rtz"
4897    };
4898
4899    const char *round = round_table[_BITS(bits, 13, 2)];
4900
4901    static const char *abs0_table[] = {
4902        "", ".abs"
4903    };
4904
4905    const char *abs0 = abs0_table[_BITS(bits, 15, 1)];
4906
4907    fputs("+FADD.v2f16", fp);
4908    fputs(round, fp);
4909    fputs(" ", fp);
4910    bi_disasm_dest_add(fp, next_regs, last);
4911    fputs(", ", fp);
4912    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4913    fputs(neg0, fp);
4914    fputs(swz0, fp);
4915    fputs(abs0, fp);
4916    fputs(", ", fp);
4917    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
4918    fputs(abs1, fp);
4919    fputs(neg1, fp);
4920    fputs(swz1, fp);
4921}
4922
4923static void
4924bi_disasm_add_fadd_rscale_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4925{
4926    static const char *round_table[] = {
4927        "", ".reserved", "", ".rtna", "", ".rtp", ".rtn", ".rtz"
4928    };
4929    const char *round = round_table[(_BITS(bits, 9, 3) << 0)];
4930    static const char *special_table[] = {
4931        "", ".reserved", "", ".n", ".n", ".n", ".n", ".n"
4932    };
4933    const char *special = special_table[(_BITS(bits, 9, 3) << 0)];
4934    static const char *clamp_table[] = {
4935        "", ".reserved", ".clamp_0_1", "", "", "", "", ""
4936    };
4937    const char *clamp = clamp_table[(_BITS(bits, 9, 3) << 0)];
4938    static const char *abs1_table[] = {
4939        "", ".abs"
4940    };
4941
4942    const char *abs1 = abs1_table[_BITS(bits, 12, 1)];
4943
4944    static const char *neg0_table[] = {
4945        "", ".neg"
4946    };
4947
4948    const char *neg0 = neg0_table[_BITS(bits, 13, 1)];
4949
4950    static const char *neg1_table[] = {
4951        "", ".neg"
4952    };
4953
4954    const char *neg1 = neg1_table[_BITS(bits, 14, 1)];
4955
4956    static const char *abs0_table[] = {
4957        "", ".abs"
4958    };
4959
4960    const char *abs0 = abs0_table[_BITS(bits, 16, 1)];
4961
4962    fputs("+FADD_RSCALE.f32", fp);
4963    fputs(clamp, fp);
4964    fputs(special, fp);
4965    fputs(round, fp);
4966    fputs(" ", fp);
4967    bi_disasm_dest_add(fp, next_regs, last);
4968    fputs(", ", fp);
4969    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
4970    fputs(neg0, fp);
4971    fputs(abs0, fp);
4972    fputs(", ", fp);
4973    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
4974    fputs(abs1, fp);
4975    fputs(neg1, fp);
4976    fputs(", ", fp);
4977    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
4978}
4979
4980static void
4981bi_disasm_add_fatan_assist_f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
4982{
4983    static const char *lane1_table[] = {
4984        "", ".h1"
4985    };
4986
4987    const char *lane1 = lane1_table[_BITS(bits, 6, 1)];
4988
4989    static const char *lane0_table[] = {
4990        "", ".h1"
4991    };
4992
4993    const char *lane0 = lane0_table[_BITS(bits, 7, 1)];
4994
4995    fputs("+FATAN_ASSIST.f16", fp);
4996    fputs(" ", fp);
4997    bi_disasm_dest_add(fp, next_regs, last);
4998    fputs(", ", fp);
4999    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5000    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5001    fputs(lane0, fp);
5002    fputs(", ", fp);
5003    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
5004    if (!(0xf7 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
5005    fputs(lane1, fp);
5006}
5007
5008static void
5009bi_disasm_add_fatan_assist_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5010{
5011    fputs("+FATAN_ASSIST.f32", fp);
5012    fputs(" ", fp);
5013    bi_disasm_dest_add(fp, next_regs, last);
5014    fputs(", ", fp);
5015    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5016    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5017    fputs(", ", fp);
5018    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
5019    if (!(0xf7 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
5020}
5021
5022static void
5023bi_disasm_add_fatan_table_f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5024{
5025    static const char *lane1_table[] = {
5026        "", ".h1"
5027    };
5028
5029    const char *lane1 = lane1_table[_BITS(bits, 6, 1)];
5030
5031    static const char *lane0_table[] = {
5032        "", ".h1"
5033    };
5034
5035    const char *lane0 = lane0_table[_BITS(bits, 7, 1)];
5036
5037    fputs("+FATAN_TABLE.f16", fp);
5038    fputs(" ", fp);
5039    bi_disasm_dest_add(fp, next_regs, last);
5040    fputs(", ", fp);
5041    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5042    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5043    fputs(lane0, fp);
5044    fputs(", ", fp);
5045    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
5046    if (!(0xf7 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
5047    fputs(lane1, fp);
5048}
5049
5050static void
5051bi_disasm_add_fatan_table_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5052{
5053    fputs("+FATAN_TABLE.f32", fp);
5054    fputs(" ", fp);
5055    bi_disasm_dest_add(fp, next_regs, last);
5056    fputs(", ", fp);
5057    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5058    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5059    fputs(", ", fp);
5060    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
5061    if (!(0xf7 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
5062}
5063
5064static void
5065bi_disasm_add_fcmp_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5066{
5067    static const char *neg1_table[] = {
5068        "", "", "", "", "", "", "", ""
5069    };
5070    const char *neg1 = neg1_table[(_BITS(bits, 9, 2) << 0) | (_BITS(bits, 13, 1) << 2)];
5071    static const char *neg0_table[] = {
5072        "", "", "", "", ".neg", ".neg", ".neg", ".neg"
5073    };
5074    const char *neg0 = neg0_table[(_BITS(bits, 9, 2) << 0) | (_BITS(bits, 13, 1) << 2)];
5075    static const char *widen1_table[] = {
5076        "", ".h0", ".h1", ".h0", "", ".h0", ".h1", ".h0"
5077    };
5078    const char *widen1 = widen1_table[(_BITS(bits, 9, 2) << 0) | (_BITS(bits, 13, 1) << 2)];
5079    static const char *widen0_table[] = {
5080        "", "", "", ".h0", "", "", "", ".h0"
5081    };
5082    const char *widen0 = widen0_table[(_BITS(bits, 9, 2) << 0) | (_BITS(bits, 13, 1) << 2)];
5083    static const char *cmpf_table[] = {
5084        ".eq", ".gt", ".ge", ".ne", ".lt", ".le", ".gtlt", ".total"
5085    };
5086
5087    const char *cmpf = cmpf_table[_BITS(bits, 6, 3)];
5088
5089    static const char *abs0_table[] = {
5090        "", ".abs"
5091    };
5092
5093    const char *abs0 = abs0_table[_BITS(bits, 11, 1)];
5094
5095    static const char *abs1_table[] = {
5096        "", ".abs"
5097    };
5098
5099    const char *abs1 = abs1_table[_BITS(bits, 12, 1)];
5100
5101    static const char *result_type_table[] = {
5102        "", ".f1", ".m1", ".reserved"
5103    };
5104
5105    const char *result_type = result_type_table[_BITS(bits, 14, 2)];
5106
5107    fputs("+FCMP.f32", fp);
5108    fputs(cmpf, fp);
5109    fputs(result_type, fp);
5110    fputs(" ", fp);
5111    bi_disasm_dest_add(fp, next_regs, last);
5112    fputs(", ", fp);
5113    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5114    fputs(widen0, fp);
5115    fputs(neg0, fp);
5116    fputs(abs0, fp);
5117    fputs(", ", fp);
5118    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
5119    fputs(widen1, fp);
5120    fputs(neg1, fp);
5121    fputs(abs1, fp);
5122}
5123
5124static void
5125bi_disasm_add_fcmp_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5126{
5127    static const char *neg1_table[] = {
5128        "", ""
5129    };
5130    const char *neg1 = neg1_table[(_BITS(bits, 13, 1) << 0)];
5131    static const char *neg0_table[] = {
5132        "", ".neg"
5133    };
5134    const char *neg0 = neg0_table[(_BITS(bits, 13, 1) << 0)];
5135    static const char *cmpf_table[] = {
5136        ".eq", ".gt", ".ge", ".ne", ".lt", ".le", ".gtlt", ".total"
5137    };
5138
5139    const char *cmpf = cmpf_table[_BITS(bits, 6, 3)];
5140
5141    static const char *swz0_table[] = {
5142        ".h00", ".h10", "", ".h11"
5143    };
5144
5145    const char *swz0 = swz0_table[_BITS(bits, 9, 2)];
5146
5147    static const char *swz1_table[] = {
5148        ".h00", ".h10", "", ".h11"
5149    };
5150
5151    const char *swz1 = swz1_table[_BITS(bits, 11, 2)];
5152
5153    static const char *result_type_table[] = {
5154        "", ".f1", ".m1", ".reserved"
5155    };
5156
5157    const char *result_type = result_type_table[_BITS(bits, 14, 2)];
5158
5159    fputs("+FCMP.v2f16", fp);
5160    fputs(cmpf, fp);
5161    fputs(result_type, fp);
5162    fputs(" ", fp);
5163    bi_disasm_dest_add(fp, next_regs, last);
5164    fputs(", ", fp);
5165    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5166    fputs(neg0, fp);
5167    fputs(swz0, fp);
5168    fputs(", ", fp);
5169    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
5170    fputs(neg1, fp);
5171    fputs(swz1, fp);
5172}
5173
5174static void
5175bi_disasm_add_fcos_table_u6(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5176{
5177    static const char *offset_table[] = {
5178        "", ".offset"
5179    };
5180
5181    const char *offset = offset_table[_BITS(bits, 4, 1)];
5182
5183    fputs("+FCOS_TABLE.u6", fp);
5184    fputs(offset, fp);
5185    fputs(" ", fp);
5186    bi_disasm_dest_add(fp, next_regs, last);
5187    fputs(", ", fp);
5188    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5189    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5190}
5191
5192static void
5193bi_disasm_add_fexp_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5194{
5195    fputs("+FEXP.f32", fp);
5196    fputs(" ", fp);
5197    bi_disasm_dest_add(fp, next_regs, last);
5198    fputs(", ", fp);
5199    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5200    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5201    fputs(", ", fp);
5202    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
5203    if (!(0xf7 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
5204}
5205
5206static void
5207bi_disasm_add_fexp_table_u4(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5208{
5209    static const char *adj_table[] = {
5210        "", ".small", ".low", ".reserved"
5211    };
5212
5213    const char *adj = adj_table[_BITS(bits, 3, 2)];
5214
5215    fputs("+FEXP_TABLE.u4", fp);
5216    fputs(adj, fp);
5217    fputs(" ", fp);
5218    bi_disasm_dest_add(fp, next_regs, last);
5219    fputs(", ", fp);
5220    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5221    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5222}
5223
5224static void
5225bi_disasm_add_flogd_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5226{
5227    fputs("+FLOGD.f32", fp);
5228    fputs(" ", fp);
5229    bi_disasm_dest_add(fp, next_regs, last);
5230    fputs(", ", fp);
5231    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5232    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5233}
5234
5235static void
5236bi_disasm_add_flog_table_f32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5237{
5238    static const char *precision_table[] = {
5239        ""
5240    };
5241    const char *precision = precision_table[0];
5242    static const char *mode_table[] = {
5243        ".red"
5244    };
5245    const char *mode = mode_table[0];
5246    static const char *widen0_table[] = {
5247        ""
5248    };
5249    const char *widen0 = widen0_table[0];
5250    static const char *neg0_table[] = {
5251        "", ".neg"
5252    };
5253
5254    const char *neg0 = neg0_table[_BITS(bits, 3, 1)];
5255
5256    static const char *abs0_table[] = {
5257        "", ".abs"
5258    };
5259
5260    const char *abs0 = abs0_table[_BITS(bits, 4, 1)];
5261
5262    static const char *divzero_table[] = {
5263        "", ".divzero"
5264    };
5265
5266    const char *divzero = divzero_table[_BITS(bits, 5, 1)];
5267
5268    fputs("+FLOG_TABLE.f32", fp);
5269    fputs(mode, fp);
5270    fputs(precision, fp);
5271    fputs(divzero, fp);
5272    fputs(" ", fp);
5273    bi_disasm_dest_add(fp, next_regs, last);
5274    fputs(", ", fp);
5275    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5276    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5277    fputs(widen0, fp);
5278    fputs(neg0, fp);
5279    fputs(abs0, fp);
5280}
5281
5282static void
5283bi_disasm_add_flog_table_f32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5284{
5285    static const char *precision_table[] = {
5286        "", ""
5287    };
5288    const char *precision = precision_table[(_BITS(bits, 7, 1) << 0)];
5289    static const char *mode_table[] = {
5290        ".red", ".red"
5291    };
5292    const char *mode = mode_table[(_BITS(bits, 7, 1) << 0)];
5293    static const char *widen0_table[] = {
5294        ".h0", ".h1"
5295    };
5296    const char *widen0 = widen0_table[(_BITS(bits, 7, 1) << 0)];
5297    static const char *neg0_table[] = {
5298        "", ".neg"
5299    };
5300
5301    const char *neg0 = neg0_table[_BITS(bits, 3, 1)];
5302
5303    static const char *abs0_table[] = {
5304        "", ".abs"
5305    };
5306
5307    const char *abs0 = abs0_table[_BITS(bits, 4, 1)];
5308
5309    static const char *divzero_table[] = {
5310        "", ".divzero"
5311    };
5312
5313    const char *divzero = divzero_table[_BITS(bits, 5, 1)];
5314
5315    fputs("+FLOG_TABLE.f32", fp);
5316    fputs(mode, fp);
5317    fputs(precision, fp);
5318    fputs(divzero, fp);
5319    fputs(" ", fp);
5320    bi_disasm_dest_add(fp, next_regs, last);
5321    fputs(", ", fp);
5322    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5323    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5324    fputs(widen0, fp);
5325    fputs(neg0, fp);
5326    fputs(abs0, fp);
5327}
5328
5329static void
5330bi_disasm_add_flog_table_f32_2(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5331{
5332    static const char *divzero_table[] = {
5333        "", ""
5334    };
5335    const char *divzero = divzero_table[(_BITS(bits, 5, 1) << 0)];
5336    static const char *mode_table[] = {
5337        ".base2", ".natural"
5338    };
5339    const char *mode = mode_table[(_BITS(bits, 5, 1) << 0)];
5340    static const char *precision_table[] = {
5341        "", ""
5342    };
5343    const char *precision = precision_table[(_BITS(bits, 5, 1) << 0)];
5344    static const char *widen0_table[] = {
5345        "", ""
5346    };
5347    const char *widen0 = widen0_table[(_BITS(bits, 5, 1) << 0)];
5348    static const char *neg0_table[] = {
5349        "", ".neg"
5350    };
5351
5352    const char *neg0 = neg0_table[_BITS(bits, 3, 1)];
5353
5354    static const char *abs0_table[] = {
5355        "", ".abs"
5356    };
5357
5358    const char *abs0 = abs0_table[_BITS(bits, 4, 1)];
5359
5360    fputs("+FLOG_TABLE.f32", fp);
5361    fputs(mode, fp);
5362    fputs(precision, fp);
5363    fputs(divzero, fp);
5364    fputs(" ", fp);
5365    bi_disasm_dest_add(fp, next_regs, last);
5366    fputs(", ", fp);
5367    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5368    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5369    fputs(widen0, fp);
5370    fputs(neg0, fp);
5371    fputs(abs0, fp);
5372}
5373
5374static void
5375bi_disasm_add_flog_table_f32_3(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5376{
5377    static const char *divzero_table[] = {
5378        "", "", "", ""
5379    };
5380    const char *divzero = divzero_table[(_BITS(bits, 5, 1) << 0) | (_BITS(bits, 7, 1) << 1)];
5381    static const char *mode_table[] = {
5382        ".base2", ".natural", ".base2", ".natural"
5383    };
5384    const char *mode = mode_table[(_BITS(bits, 5, 1) << 0) | (_BITS(bits, 7, 1) << 1)];
5385    static const char *precision_table[] = {
5386        "", "", "", ""
5387    };
5388    const char *precision = precision_table[(_BITS(bits, 5, 1) << 0) | (_BITS(bits, 7, 1) << 1)];
5389    static const char *widen0_table[] = {
5390        ".h0", ".h0", ".h1", ".h1"
5391    };
5392    const char *widen0 = widen0_table[(_BITS(bits, 5, 1) << 0) | (_BITS(bits, 7, 1) << 1)];
5393    static const char *neg0_table[] = {
5394        "", ".neg"
5395    };
5396
5397    const char *neg0 = neg0_table[_BITS(bits, 3, 1)];
5398
5399    static const char *abs0_table[] = {
5400        "", ".abs"
5401    };
5402
5403    const char *abs0 = abs0_table[_BITS(bits, 4, 1)];
5404
5405    fputs("+FLOG_TABLE.f32", fp);
5406    fputs(mode, fp);
5407    fputs(precision, fp);
5408    fputs(divzero, fp);
5409    fputs(" ", fp);
5410    bi_disasm_dest_add(fp, next_regs, last);
5411    fputs(", ", fp);
5412    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5413    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5414    fputs(widen0, fp);
5415    fputs(neg0, fp);
5416    fputs(abs0, fp);
5417}
5418
5419static void
5420bi_disasm_add_flog_table_f32_4(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5421{
5422    static const char *abs0_table[] = {
5423        "", "", "", ""
5424    };
5425    const char *abs0 = abs0_table[(_BITS(bits, 3, 1) << 0) | (_BITS(bits, 4, 1) << 1)];
5426    static const char *divzero_table[] = {
5427        "", "", "", ""
5428    };
5429    const char *divzero = divzero_table[(_BITS(bits, 3, 1) << 0) | (_BITS(bits, 4, 1) << 1)];
5430    static const char *mode_table[] = {
5431        ".natural", ".base2", ".natural", ".base2"
5432    };
5433    const char *mode = mode_table[(_BITS(bits, 3, 1) << 0) | (_BITS(bits, 4, 1) << 1)];
5434    static const char *neg0_table[] = {
5435        "", "", "", ""
5436    };
5437    const char *neg0 = neg0_table[(_BITS(bits, 3, 1) << 0) | (_BITS(bits, 4, 1) << 1)];
5438    static const char *precision_table[] = {
5439        ".high", ".high", ".low", ".low"
5440    };
5441    const char *precision = precision_table[(_BITS(bits, 3, 1) << 0) | (_BITS(bits, 4, 1) << 1)];
5442    static const char *widen0_table[] = {
5443        "", "", "", ""
5444    };
5445    const char *widen0 = widen0_table[(_BITS(bits, 3, 1) << 0) | (_BITS(bits, 4, 1) << 1)];
5446    fputs("+FLOG_TABLE.f32", fp);
5447    fputs(mode, fp);
5448    fputs(precision, fp);
5449    fputs(divzero, fp);
5450    fputs(" ", fp);
5451    bi_disasm_dest_add(fp, next_regs, last);
5452    fputs(", ", fp);
5453    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5454    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5455    fputs(widen0, fp);
5456    fputs(neg0, fp);
5457    fputs(abs0, fp);
5458}
5459
5460static void
5461bi_disasm_add_fmax_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5462{
5463    static const char *abs1_table[] = {
5464        "", ".abs"
5465    };
5466
5467    const char *abs1 = abs1_table[_BITS(bits, 6, 1)];
5468
5469    static const char *neg0_table[] = {
5470        "", ".neg"
5471    };
5472
5473    const char *neg0 = neg0_table[_BITS(bits, 7, 1)];
5474
5475    static const char *neg1_table[] = {
5476        "", ".neg"
5477    };
5478
5479    const char *neg1 = neg1_table[_BITS(bits, 8, 1)];
5480
5481    static const char *clamp_table[] = {
5482        "", ".clamp_0_inf", ".clamp_m1_1", ".clamp_0_1"
5483    };
5484
5485    const char *clamp = clamp_table[_BITS(bits, 11, 2)];
5486
5487    static const char *sem_table[] = {
5488        "", ".nan_propagate", ".c", ".inverse_c"
5489    };
5490
5491    const char *sem = sem_table[_BITS(bits, 13, 2)];
5492
5493    static const char *abs0_table[] = {
5494        "", ".abs"
5495    };
5496
5497    const char *abs0 = abs0_table[_BITS(bits, 15, 1)];
5498
5499    fputs("+FMAX.f32", fp);
5500    fputs(clamp, fp);
5501    fputs(sem, fp);
5502    fputs(" ", fp);
5503    bi_disasm_dest_add(fp, next_regs, last);
5504    fputs(", ", fp);
5505    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5506    fputs(neg0, fp);
5507    fputs(abs0, fp);
5508    fputs(", ", fp);
5509    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
5510    fputs(abs1, fp);
5511    fputs(neg1, fp);
5512}
5513
5514static void
5515bi_disasm_add_fmax_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5516{
5517    bool ordering = (_BITS(bits, 0, 3) > _BITS(bits, 3, 3));
5518    static const char *abs0_0[] = {
5519        "", ".abs"
5520    };
5521    static const char *abs0_1[] = {
5522        ".abs", ".abs"
5523    };
5524    const char *abs0 = ordering ? abs0_1[(_BITS(bits, 6, 1) << 0)] : abs0_0[(_BITS(bits, 6, 1) << 0)];
5525    static const char *abs1_0[] = {
5526        "", ""
5527    };
5528    static const char *abs1_1[] = {
5529        "", ".abs"
5530    };
5531    const char *abs1 = ordering ? abs1_1[(_BITS(bits, 6, 1) << 0)] : abs1_0[(_BITS(bits, 6, 1) << 0)];
5532    static const char *neg0_table[] = {
5533        "", ".neg"
5534    };
5535
5536    const char *neg0 = neg0_table[_BITS(bits, 7, 1)];
5537
5538    static const char *neg1_table[] = {
5539        "", ".neg"
5540    };
5541
5542    const char *neg1 = neg1_table[_BITS(bits, 8, 1)];
5543
5544    static const char *swz0_table[] = {
5545        ".h00", ".h10", "", ".h11"
5546    };
5547
5548    const char *swz0 = swz0_table[_BITS(bits, 9, 2)];
5549
5550    static const char *swz1_table[] = {
5551        ".h00", ".h10", "", ".h11"
5552    };
5553
5554    const char *swz1 = swz1_table[_BITS(bits, 11, 2)];
5555
5556    static const char *sem_table[] = {
5557        "", ".nan_propagate", ".c", ".inverse_c"
5558    };
5559
5560    const char *sem = sem_table[_BITS(bits, 13, 2)];
5561
5562    fputs("+FMAX.v2f16", fp);
5563    fputs(sem, fp);
5564    fputs(" ", fp);
5565    bi_disasm_dest_add(fp, next_regs, last);
5566    fputs(", ", fp);
5567    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5568    fputs(abs0, fp);
5569    fputs(neg0, fp);
5570    fputs(swz0, fp);
5571    fputs(", ", fp);
5572    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
5573    fputs(abs1, fp);
5574    fputs(neg1, fp);
5575    fputs(swz1, fp);
5576}
5577
5578static void
5579bi_disasm_add_fmin_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5580{
5581    static const char *abs1_table[] = {
5582        "", ".abs"
5583    };
5584
5585    const char *abs1 = abs1_table[_BITS(bits, 6, 1)];
5586
5587    static const char *neg0_table[] = {
5588        "", ".neg"
5589    };
5590
5591    const char *neg0 = neg0_table[_BITS(bits, 7, 1)];
5592
5593    static const char *neg1_table[] = {
5594        "", ".neg"
5595    };
5596
5597    const char *neg1 = neg1_table[_BITS(bits, 8, 1)];
5598
5599    static const char *clamp_table[] = {
5600        "", ".clamp_0_inf", ".clamp_m1_1", ".clamp_0_1"
5601    };
5602
5603    const char *clamp = clamp_table[_BITS(bits, 11, 2)];
5604
5605    static const char *sem_table[] = {
5606        "", ".nan_propagate", ".c", ".inverse_c"
5607    };
5608
5609    const char *sem = sem_table[_BITS(bits, 13, 2)];
5610
5611    static const char *abs0_table[] = {
5612        "", ".abs"
5613    };
5614
5615    const char *abs0 = abs0_table[_BITS(bits, 15, 1)];
5616
5617    fputs("+FMIN.f32", fp);
5618    fputs(clamp, fp);
5619    fputs(sem, fp);
5620    fputs(" ", fp);
5621    bi_disasm_dest_add(fp, next_regs, last);
5622    fputs(", ", fp);
5623    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5624    fputs(neg0, fp);
5625    fputs(abs0, fp);
5626    fputs(", ", fp);
5627    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
5628    fputs(abs1, fp);
5629    fputs(neg1, fp);
5630}
5631
5632static void
5633bi_disasm_add_fmin_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5634{
5635    bool ordering = (_BITS(bits, 0, 3) > _BITS(bits, 3, 3));
5636    static const char *abs0_0[] = {
5637        "", ".abs"
5638    };
5639    static const char *abs0_1[] = {
5640        ".abs", ".abs"
5641    };
5642    const char *abs0 = ordering ? abs0_1[(_BITS(bits, 6, 1) << 0)] : abs0_0[(_BITS(bits, 6, 1) << 0)];
5643    static const char *abs1_0[] = {
5644        "", ""
5645    };
5646    static const char *abs1_1[] = {
5647        "", ".abs"
5648    };
5649    const char *abs1 = ordering ? abs1_1[(_BITS(bits, 6, 1) << 0)] : abs1_0[(_BITS(bits, 6, 1) << 0)];
5650    static const char *neg0_table[] = {
5651        "", ".neg"
5652    };
5653
5654    const char *neg0 = neg0_table[_BITS(bits, 7, 1)];
5655
5656    static const char *neg1_table[] = {
5657        "", ".neg"
5658    };
5659
5660    const char *neg1 = neg1_table[_BITS(bits, 8, 1)];
5661
5662    static const char *swz0_table[] = {
5663        ".h00", ".h10", "", ".h11"
5664    };
5665
5666    const char *swz0 = swz0_table[_BITS(bits, 9, 2)];
5667
5668    static const char *swz1_table[] = {
5669        ".h00", ".h10", "", ".h11"
5670    };
5671
5672    const char *swz1 = swz1_table[_BITS(bits, 11, 2)];
5673
5674    static const char *sem_table[] = {
5675        "", ".nan_propagate", ".c", ".inverse_c"
5676    };
5677
5678    const char *sem = sem_table[_BITS(bits, 13, 2)];
5679
5680    fputs("+FMIN.v2f16", fp);
5681    fputs(sem, fp);
5682    fputs(" ", fp);
5683    bi_disasm_dest_add(fp, next_regs, last);
5684    fputs(", ", fp);
5685    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5686    fputs(abs0, fp);
5687    fputs(neg0, fp);
5688    fputs(swz0, fp);
5689    fputs(", ", fp);
5690    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
5691    fputs(abs1, fp);
5692    fputs(neg1, fp);
5693    fputs(swz1, fp);
5694}
5695
5696static void
5697bi_disasm_add_fpclass_f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5698{
5699    static const char *lane0_table[] = {
5700        "", ".h1"
5701    };
5702
5703    const char *lane0 = lane0_table[_BITS(bits, 3, 1)];
5704
5705    fputs("+FPCLASS.f16", fp);
5706    fputs(" ", fp);
5707    bi_disasm_dest_add(fp, next_regs, last);
5708    fputs(", ", fp);
5709    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5710    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5711    fputs(lane0, fp);
5712}
5713
5714static void
5715bi_disasm_add_fpclass_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5716{
5717    fputs("+FPCLASS.f32", fp);
5718    fputs(" ", fp);
5719    bi_disasm_dest_add(fp, next_regs, last);
5720    fputs(", ", fp);
5721    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5722    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5723}
5724
5725static void
5726bi_disasm_add_fpow_sc_apply(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5727{
5728    fputs("+FPOW_SC_APPLY", fp);
5729    fputs(" ", fp);
5730    bi_disasm_dest_add(fp, next_regs, last);
5731    fputs(", ", fp);
5732    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5733    fputs(", ", fp);
5734    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
5735}
5736
5737static void
5738bi_disasm_add_fpow_sc_det_f16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5739{
5740    static const char *lane1_table[] = {
5741        ".h0", ".h1", ".h0", ".h1"
5742    };
5743    const char *lane1 = lane1_table[(_BITS(bits, 6, 1) << 0) | (_BITS(bits, 8, 1) << 1)];
5744    static const char *func_table[] = {
5745        ".pow", ".pow", ".powr", ".powr"
5746    };
5747    const char *func = func_table[(_BITS(bits, 6, 1) << 0) | (_BITS(bits, 8, 1) << 1)];
5748    static const char *lane0_table[] = {
5749        "", ".h1"
5750    };
5751
5752    const char *lane0 = lane0_table[_BITS(bits, 7, 1)];
5753
5754    fputs("+FPOW_SC_DET.f16", fp);
5755    fputs(func, fp);
5756    fputs(" ", fp);
5757    bi_disasm_dest_add(fp, next_regs, last);
5758    fputs(", ", fp);
5759    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5760    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5761    fputs(lane0, fp);
5762    fputs(", ", fp);
5763    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
5764    if (!(0xf7 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
5765    fputs(lane1, fp);
5766}
5767
5768static void
5769bi_disasm_add_fpow_sc_det_f16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5770{
5771    static const char *lane1_table[] = {
5772        "", ""
5773    };
5774    const char *lane1 = lane1_table[(_BITS(bits, 8, 1) << 0)];
5775    static const char *func_table[] = {
5776        ".pown", ".rootn"
5777    };
5778    const char *func = func_table[(_BITS(bits, 8, 1) << 0)];
5779    static const char *lane0_table[] = {
5780        "", ".h1"
5781    };
5782
5783    const char *lane0 = lane0_table[_BITS(bits, 7, 1)];
5784
5785    fputs("+FPOW_SC_DET.f16", fp);
5786    fputs(func, fp);
5787    fputs(" ", fp);
5788    bi_disasm_dest_add(fp, next_regs, last);
5789    fputs(", ", fp);
5790    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5791    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5792    fputs(lane0, fp);
5793    fputs(", ", fp);
5794    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
5795    if (!(0xf7 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
5796    fputs(lane1, fp);
5797}
5798
5799static void
5800bi_disasm_add_fpow_sc_det_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5801{
5802    static const char *func_table[] = {
5803        ".pow", ".powr", ".pown", ".rootn"
5804    };
5805
5806    const char *func = func_table[_BITS(bits, 7, 2)];
5807
5808    fputs("+FPOW_SC_DET.f32", fp);
5809    fputs(func, fp);
5810    fputs(" ", fp);
5811    bi_disasm_dest_add(fp, next_regs, last);
5812    fputs(", ", fp);
5813    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5814    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5815    fputs(", ", fp);
5816    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
5817    if (!(0xf7 & (1 << _BITS(bits, 3, 3)))) fputs("(INVALID)", fp);
5818}
5819
5820static void
5821bi_disasm_add_frcbrt_approx_a_f32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5822{
5823    static const char *widen0_table[] = {
5824        ""
5825    };
5826    const char *widen0 = widen0_table[0];
5827    static const char *neg0_table[] = {
5828        "", ".neg"
5829    };
5830
5831    const char *neg0 = neg0_table[_BITS(bits, 3, 1)];
5832
5833    static const char *abs0_table[] = {
5834        "", ".abs"
5835    };
5836
5837    const char *abs0 = abs0_table[_BITS(bits, 4, 1)];
5838
5839    static const char *divzero_table[] = {
5840        "", ".divzero"
5841    };
5842
5843    const char *divzero = divzero_table[_BITS(bits, 5, 1)];
5844
5845    fputs("+FRCBRT_APPROX_A.f32", fp);
5846    fputs(divzero, fp);
5847    fputs(" ", fp);
5848    bi_disasm_dest_add(fp, next_regs, last);
5849    fputs(", ", fp);
5850    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5851    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5852    fputs(widen0, fp);
5853    fputs(neg0, fp);
5854    fputs(abs0, fp);
5855}
5856
5857static void
5858bi_disasm_add_frcbrt_approx_a_f32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5859{
5860    static const char *widen0_table[] = {
5861        ".h0", ".h1"
5862    };
5863    const char *widen0 = widen0_table[(_BITS(bits, 7, 1) << 0)];
5864    static const char *neg0_table[] = {
5865        "", ".neg"
5866    };
5867
5868    const char *neg0 = neg0_table[_BITS(bits, 3, 1)];
5869
5870    static const char *abs0_table[] = {
5871        "", ".abs"
5872    };
5873
5874    const char *abs0 = abs0_table[_BITS(bits, 4, 1)];
5875
5876    static const char *divzero_table[] = {
5877        "", ".divzero"
5878    };
5879
5880    const char *divzero = divzero_table[_BITS(bits, 5, 1)];
5881
5882    fputs("+FRCBRT_APPROX_A.f32", fp);
5883    fputs(divzero, fp);
5884    fputs(" ", fp);
5885    bi_disasm_dest_add(fp, next_regs, last);
5886    fputs(", ", fp);
5887    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5888    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5889    fputs(widen0, fp);
5890    fputs(neg0, fp);
5891    fputs(abs0, fp);
5892}
5893
5894static void
5895bi_disasm_add_frcbrt_approx_b_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5896{
5897    fputs("+FRCBRT_APPROX_B.f32", fp);
5898    fputs(" ", fp);
5899    bi_disasm_dest_add(fp, next_regs, last);
5900    fputs(", ", fp);
5901    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5902    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5903}
5904
5905static void
5906bi_disasm_add_frcbrt_approx_c_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5907{
5908    fputs("+FRCBRT_APPROX_C.f32", fp);
5909    fputs(" ", fp);
5910    bi_disasm_dest_add(fp, next_regs, last);
5911    fputs(", ", fp);
5912    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5913    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5914}
5915
5916static void
5917bi_disasm_add_frcp_f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5918{
5919    static const char *neg0_table[] = {
5920        "", ".neg"
5921    };
5922
5923    const char *neg0 = neg0_table[_BITS(bits, 3, 1)];
5924
5925    static const char *abs0_table[] = {
5926        "", ".abs"
5927    };
5928
5929    const char *abs0 = abs0_table[_BITS(bits, 4, 1)];
5930
5931    static const char *divzero_table[] = {
5932        "", ".divzero"
5933    };
5934
5935    const char *divzero = divzero_table[_BITS(bits, 5, 1)];
5936
5937    static const char *lane0_table[] = {
5938        "", ".h1"
5939    };
5940
5941    const char *lane0 = lane0_table[_BITS(bits, 8, 1)];
5942
5943    fputs("+FRCP.f16", fp);
5944    fputs(divzero, fp);
5945    fputs(" ", fp);
5946    bi_disasm_dest_add(fp, next_regs, last);
5947    fputs(", ", fp);
5948    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5949    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5950    fputs(neg0, fp);
5951    fputs(abs0, fp);
5952    fputs(lane0, fp);
5953}
5954
5955static void
5956bi_disasm_add_frcp_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5957{
5958    static const char *widen0_table[] = {
5959        "", ".reserved"
5960    };
5961    const char *widen0 = widen0_table[(_BITS(bits, 6, 1) << 0)];
5962    static const char *neg0_table[] = {
5963        "", ".neg"
5964    };
5965
5966    const char *neg0 = neg0_table[_BITS(bits, 3, 1)];
5967
5968    static const char *abs0_table[] = {
5969        "", ".abs"
5970    };
5971
5972    const char *abs0 = abs0_table[_BITS(bits, 4, 1)];
5973
5974    fputs("+FRCP.f32", fp);
5975    fputs(" ", fp);
5976    bi_disasm_dest_add(fp, next_regs, last);
5977    fputs(", ", fp);
5978    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
5979    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
5980    fputs(widen0, fp);
5981    fputs(neg0, fp);
5982    fputs(abs0, fp);
5983}
5984
5985static void
5986bi_disasm_add_frcp_approx_f32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
5987{
5988    static const char *widen0_table[] = {
5989        ""
5990    };
5991    const char *widen0 = widen0_table[0];
5992    static const char *neg0_table[] = {
5993        "", ".neg"
5994    };
5995
5996    const char *neg0 = neg0_table[_BITS(bits, 3, 1)];
5997
5998    static const char *abs0_table[] = {
5999        "", ".abs"
6000    };
6001
6002    const char *abs0 = abs0_table[_BITS(bits, 4, 1)];
6003
6004    static const char *divzero_table[] = {
6005        "", ".divzero"
6006    };
6007
6008    const char *divzero = divzero_table[_BITS(bits, 5, 1)];
6009
6010    fputs("+FRCP_APPROX.f32", fp);
6011    fputs(divzero, fp);
6012    fputs(" ", fp);
6013    bi_disasm_dest_add(fp, next_regs, last);
6014    fputs(", ", fp);
6015    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6016    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
6017    fputs(widen0, fp);
6018    fputs(neg0, fp);
6019    fputs(abs0, fp);
6020}
6021
6022static void
6023bi_disasm_add_frcp_approx_f32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6024{
6025    static const char *widen0_table[] = {
6026        ".h0", ".h1"
6027    };
6028    const char *widen0 = widen0_table[(_BITS(bits, 7, 1) << 0)];
6029    static const char *neg0_table[] = {
6030        "", ".neg"
6031    };
6032
6033    const char *neg0 = neg0_table[_BITS(bits, 3, 1)];
6034
6035    static const char *abs0_table[] = {
6036        "", ".abs"
6037    };
6038
6039    const char *abs0 = abs0_table[_BITS(bits, 4, 1)];
6040
6041    static const char *divzero_table[] = {
6042        "", ".divzero"
6043    };
6044
6045    const char *divzero = divzero_table[_BITS(bits, 5, 1)];
6046
6047    fputs("+FRCP_APPROX.f32", fp);
6048    fputs(divzero, fp);
6049    fputs(" ", fp);
6050    bi_disasm_dest_add(fp, next_regs, last);
6051    fputs(", ", fp);
6052    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6053    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
6054    fputs(widen0, fp);
6055    fputs(neg0, fp);
6056    fputs(abs0, fp);
6057}
6058
6059static void
6060bi_disasm_add_frexpe_f32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6061{
6062    static const char *log_table[] = {
6063        ""
6064    };
6065    const char *log = log_table[0];
6066    static const char *neg0_table[] = {
6067        "", ".neg"
6068    };
6069
6070    const char *neg0 = neg0_table[_BITS(bits, 6, 1)];
6071
6072    static const char *sqrt_table[] = {
6073        "", ".sqrt"
6074    };
6075
6076    const char *sqrt = sqrt_table[_BITS(bits, 8, 1)];
6077
6078    static const char *widen0_table[] = {
6079        ".reserved", "", ".h0", ".h1"
6080    };
6081
6082    const char *widen0 = widen0_table[_BITS(bits, 3, 2)];
6083
6084    fputs("+FREXPE.f32", fp);
6085    fputs(sqrt, fp);
6086    fputs(log, fp);
6087    fputs(" ", fp);
6088    bi_disasm_dest_add(fp, next_regs, last);
6089    fputs(", ", fp);
6090    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6091    fputs(neg0, fp);
6092    fputs(widen0, fp);
6093}
6094
6095static void
6096bi_disasm_add_frexpe_f32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6097{
6098    static const char *log_table[] = {
6099        ".log"
6100    };
6101    const char *log = log_table[0];
6102    static const char *neg0_table[] = {
6103        ""
6104    };
6105    const char *neg0 = neg0_table[0];
6106    static const char *sqrt_table[] = {
6107        ""
6108    };
6109    const char *sqrt = sqrt_table[0];
6110    static const char *widen0_table[] = {
6111        ".reserved", "", ".h0", ".h1"
6112    };
6113
6114    const char *widen0 = widen0_table[_BITS(bits, 3, 2)];
6115
6116    fputs("+FREXPE.f32", fp);
6117    fputs(sqrt, fp);
6118    fputs(log, fp);
6119    fputs(" ", fp);
6120    bi_disasm_dest_add(fp, next_regs, last);
6121    fputs(", ", fp);
6122    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6123    fputs(neg0, fp);
6124    fputs(widen0, fp);
6125}
6126
6127static void
6128bi_disasm_add_frexpe_v2f16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6129{
6130    static const char *log_table[] = {
6131        ""
6132    };
6133    const char *log = log_table[0];
6134    static const char *neg0_table[] = {
6135        "", ".neg"
6136    };
6137
6138    const char *neg0 = neg0_table[_BITS(bits, 6, 1)];
6139
6140    static const char *sqrt_table[] = {
6141        "", ".sqrt"
6142    };
6143
6144    const char *sqrt = sqrt_table[_BITS(bits, 8, 1)];
6145
6146    static const char *swz0_table[] = {
6147        ".h00", ".h10", "", ".h11"
6148    };
6149
6150    const char *swz0 = swz0_table[_BITS(bits, 3, 2)];
6151
6152    fputs("+FREXPE.v2f16", fp);
6153    fputs(sqrt, fp);
6154    fputs(log, fp);
6155    fputs(" ", fp);
6156    bi_disasm_dest_add(fp, next_regs, last);
6157    fputs(", ", fp);
6158    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6159    fputs(neg0, fp);
6160    fputs(swz0, fp);
6161}
6162
6163static void
6164bi_disasm_add_frexpe_v2f16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6165{
6166    static const char *log_table[] = {
6167        ".log"
6168    };
6169    const char *log = log_table[0];
6170    static const char *neg0_table[] = {
6171        ""
6172    };
6173    const char *neg0 = neg0_table[0];
6174    static const char *sqrt_table[] = {
6175        ""
6176    };
6177    const char *sqrt = sqrt_table[0];
6178    static const char *swz0_table[] = {
6179        ".h00", ".h10", "", ".h11"
6180    };
6181
6182    const char *swz0 = swz0_table[_BITS(bits, 3, 2)];
6183
6184    fputs("+FREXPE.v2f16", fp);
6185    fputs(sqrt, fp);
6186    fputs(log, fp);
6187    fputs(" ", fp);
6188    bi_disasm_dest_add(fp, next_regs, last);
6189    fputs(", ", fp);
6190    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6191    fputs(neg0, fp);
6192    fputs(swz0, fp);
6193}
6194
6195static void
6196bi_disasm_add_frexpm_f32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6197{
6198    static const char *log_table[] = {
6199        ""
6200    };
6201    const char *log = log_table[0];
6202    static const char *neg0_table[] = {
6203        ""
6204    };
6205    const char *neg0 = neg0_table[0];
6206    static const char *abs0_table[] = {
6207        "", ".abs"
6208    };
6209
6210    const char *abs0 = abs0_table[_BITS(bits, 6, 1)];
6211
6212    static const char *sqrt_table[] = {
6213        "", ".sqrt"
6214    };
6215
6216    const char *sqrt = sqrt_table[_BITS(bits, 7, 1)];
6217
6218    static const char *widen0_table[] = {
6219        ".reserved", "", ".h0", ".h1"
6220    };
6221
6222    const char *widen0 = widen0_table[_BITS(bits, 3, 2)];
6223
6224    fputs("+FREXPM.f32", fp);
6225    fputs(sqrt, fp);
6226    fputs(log, fp);
6227    fputs(" ", fp);
6228    bi_disasm_dest_add(fp, next_regs, last);
6229    fputs(", ", fp);
6230    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6231    fputs(abs0, fp);
6232    fputs(widen0, fp);
6233    fputs(neg0, fp);
6234}
6235
6236static void
6237bi_disasm_add_frexpm_f32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6238{
6239    static const char *log_table[] = {
6240        ".log"
6241    };
6242    const char *log = log_table[0];
6243    static const char *sqrt_table[] = {
6244        ""
6245    };
6246    const char *sqrt = sqrt_table[0];
6247    static const char *abs0_table[] = {
6248        "", ".abs"
6249    };
6250
6251    const char *abs0 = abs0_table[_BITS(bits, 6, 1)];
6252
6253    static const char *widen0_table[] = {
6254        ".reserved", "", ".h0", ".h1"
6255    };
6256
6257    const char *widen0 = widen0_table[_BITS(bits, 3, 2)];
6258
6259    static const char *neg0_table[] = {
6260        "", ".neg"
6261    };
6262
6263    const char *neg0 = neg0_table[_BITS(bits, 7, 1)];
6264
6265    fputs("+FREXPM.f32", fp);
6266    fputs(sqrt, fp);
6267    fputs(log, fp);
6268    fputs(" ", fp);
6269    bi_disasm_dest_add(fp, next_regs, last);
6270    fputs(", ", fp);
6271    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6272    fputs(abs0, fp);
6273    fputs(widen0, fp);
6274    fputs(neg0, fp);
6275}
6276
6277static void
6278bi_disasm_add_frexpm_v2f16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6279{
6280    static const char *log_table[] = {
6281        ""
6282    };
6283    const char *log = log_table[0];
6284    static const char *neg0_table[] = {
6285        ""
6286    };
6287    const char *neg0 = neg0_table[0];
6288    static const char *abs0_table[] = {
6289        "", ".abs"
6290    };
6291
6292    const char *abs0 = abs0_table[_BITS(bits, 6, 1)];
6293
6294    static const char *sqrt_table[] = {
6295        "", ".sqrt"
6296    };
6297
6298    const char *sqrt = sqrt_table[_BITS(bits, 7, 1)];
6299
6300    static const char *swz0_table[] = {
6301        ".h00", ".h10", "", ".h11"
6302    };
6303
6304    const char *swz0 = swz0_table[_BITS(bits, 3, 2)];
6305
6306    fputs("+FREXPM.v2f16", fp);
6307    fputs(sqrt, fp);
6308    fputs(log, fp);
6309    fputs(" ", fp);
6310    bi_disasm_dest_add(fp, next_regs, last);
6311    fputs(", ", fp);
6312    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6313    fputs(abs0, fp);
6314    fputs(swz0, fp);
6315    fputs(neg0, fp);
6316}
6317
6318static void
6319bi_disasm_add_frexpm_v2f16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6320{
6321    static const char *log_table[] = {
6322        ".log"
6323    };
6324    const char *log = log_table[0];
6325    static const char *sqrt_table[] = {
6326        ""
6327    };
6328    const char *sqrt = sqrt_table[0];
6329    static const char *abs0_table[] = {
6330        "", ".abs"
6331    };
6332
6333    const char *abs0 = abs0_table[_BITS(bits, 6, 1)];
6334
6335    static const char *swz0_table[] = {
6336        ".h00", ".h10", "", ".h11"
6337    };
6338
6339    const char *swz0 = swz0_table[_BITS(bits, 3, 2)];
6340
6341    static const char *neg0_table[] = {
6342        "", ".neg"
6343    };
6344
6345    const char *neg0 = neg0_table[_BITS(bits, 7, 1)];
6346
6347    fputs("+FREXPM.v2f16", fp);
6348    fputs(sqrt, fp);
6349    fputs(log, fp);
6350    fputs(" ", fp);
6351    bi_disasm_dest_add(fp, next_regs, last);
6352    fputs(", ", fp);
6353    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6354    fputs(abs0, fp);
6355    fputs(swz0, fp);
6356    fputs(neg0, fp);
6357}
6358
6359static void
6360bi_disasm_add_fround_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6361{
6362    static const char *abs0_table[] = {
6363        "", ".abs"
6364    };
6365
6366    const char *abs0 = abs0_table[_BITS(bits, 7, 1)];
6367
6368    static const char *neg0_table[] = {
6369        "", ".neg"
6370    };
6371
6372    const char *neg0 = neg0_table[_BITS(bits, 8, 1)];
6373
6374    static const char *widen0_table[] = {
6375        ".reserved", "", ".h0", ".h1"
6376    };
6377
6378    const char *widen0 = widen0_table[_BITS(bits, 3, 2)];
6379
6380    static const char *round_table[] = {
6381        "", ".rtp", ".rtn", ".rtz"
6382    };
6383
6384    const char *round = round_table[_BITS(bits, 9, 2)];
6385
6386    fputs("+FROUND.f32", fp);
6387    fputs(round, fp);
6388    fputs(" ", fp);
6389    bi_disasm_dest_add(fp, next_regs, last);
6390    fputs(", ", fp);
6391    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6392    fputs(abs0, fp);
6393    fputs(neg0, fp);
6394    fputs(widen0, fp);
6395}
6396
6397static void
6398bi_disasm_add_fround_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6399{
6400    static const char *abs0_table[] = {
6401        "", ".abs"
6402    };
6403
6404    const char *abs0 = abs0_table[_BITS(bits, 7, 1)];
6405
6406    static const char *neg0_table[] = {
6407        "", ".neg"
6408    };
6409
6410    const char *neg0 = neg0_table[_BITS(bits, 8, 1)];
6411
6412    static const char *swz0_table[] = {
6413        ".h00", ".h10", "", ".h11"
6414    };
6415
6416    const char *swz0 = swz0_table[_BITS(bits, 3, 2)];
6417
6418    static const char *round_table[] = {
6419        "", ".rtp", ".rtn", ".rtz"
6420    };
6421
6422    const char *round = round_table[_BITS(bits, 9, 2)];
6423
6424    fputs("+FROUND.v2f16", fp);
6425    fputs(round, fp);
6426    fputs(" ", fp);
6427    bi_disasm_dest_add(fp, next_regs, last);
6428    fputs(", ", fp);
6429    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6430    fputs(abs0, fp);
6431    fputs(neg0, fp);
6432    fputs(swz0, fp);
6433}
6434
6435static void
6436bi_disasm_add_frsq_f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6437{
6438    static const char *neg0_table[] = {
6439        "", ".neg"
6440    };
6441
6442    const char *neg0 = neg0_table[_BITS(bits, 3, 1)];
6443
6444    static const char *abs0_table[] = {
6445        "", ".abs"
6446    };
6447
6448    const char *abs0 = abs0_table[_BITS(bits, 4, 1)];
6449
6450    static const char *divzero_table[] = {
6451        "", ".divzero"
6452    };
6453
6454    const char *divzero = divzero_table[_BITS(bits, 5, 1)];
6455
6456    static const char *lane0_table[] = {
6457        "", ".h1"
6458    };
6459
6460    const char *lane0 = lane0_table[_BITS(bits, 8, 1)];
6461
6462    fputs("+FRSQ.f16", fp);
6463    fputs(divzero, fp);
6464    fputs(" ", fp);
6465    bi_disasm_dest_add(fp, next_regs, last);
6466    fputs(", ", fp);
6467    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6468    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
6469    fputs(neg0, fp);
6470    fputs(abs0, fp);
6471    fputs(lane0, fp);
6472}
6473
6474static void
6475bi_disasm_add_frsq_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6476{
6477    static const char *widen0_table[] = {
6478        "", ".reserved"
6479    };
6480    const char *widen0 = widen0_table[(_BITS(bits, 6, 1) << 0)];
6481    static const char *neg0_table[] = {
6482        "", ".neg"
6483    };
6484
6485    const char *neg0 = neg0_table[_BITS(bits, 3, 1)];
6486
6487    static const char *abs0_table[] = {
6488        "", ".abs"
6489    };
6490
6491    const char *abs0 = abs0_table[_BITS(bits, 4, 1)];
6492
6493    fputs("+FRSQ.f32", fp);
6494    fputs(" ", fp);
6495    bi_disasm_dest_add(fp, next_regs, last);
6496    fputs(", ", fp);
6497    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6498    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
6499    fputs(widen0, fp);
6500    fputs(neg0, fp);
6501    fputs(abs0, fp);
6502}
6503
6504static void
6505bi_disasm_add_frsq_approx_f32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6506{
6507    static const char *widen0_table[] = {
6508        ""
6509    };
6510    const char *widen0 = widen0_table[0];
6511    static const char *neg0_table[] = {
6512        "", ".neg"
6513    };
6514
6515    const char *neg0 = neg0_table[_BITS(bits, 3, 1)];
6516
6517    static const char *abs0_table[] = {
6518        "", ".abs"
6519    };
6520
6521    const char *abs0 = abs0_table[_BITS(bits, 4, 1)];
6522
6523    static const char *divzero_table[] = {
6524        "", ".divzero"
6525    };
6526
6527    const char *divzero = divzero_table[_BITS(bits, 5, 1)];
6528
6529    fputs("+FRSQ_APPROX.f32", fp);
6530    fputs(divzero, fp);
6531    fputs(" ", fp);
6532    bi_disasm_dest_add(fp, next_regs, last);
6533    fputs(", ", fp);
6534    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6535    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
6536    fputs(widen0, fp);
6537    fputs(neg0, fp);
6538    fputs(abs0, fp);
6539}
6540
6541static void
6542bi_disasm_add_frsq_approx_f32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6543{
6544    static const char *widen0_table[] = {
6545        ".h0", ".h1"
6546    };
6547    const char *widen0 = widen0_table[(_BITS(bits, 7, 1) << 0)];
6548    static const char *neg0_table[] = {
6549        "", ".neg"
6550    };
6551
6552    const char *neg0 = neg0_table[_BITS(bits, 3, 1)];
6553
6554    static const char *abs0_table[] = {
6555        "", ".abs"
6556    };
6557
6558    const char *abs0 = abs0_table[_BITS(bits, 4, 1)];
6559
6560    static const char *divzero_table[] = {
6561        "", ".divzero"
6562    };
6563
6564    const char *divzero = divzero_table[_BITS(bits, 5, 1)];
6565
6566    fputs("+FRSQ_APPROX.f32", fp);
6567    fputs(divzero, fp);
6568    fputs(" ", fp);
6569    bi_disasm_dest_add(fp, next_regs, last);
6570    fputs(", ", fp);
6571    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6572    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
6573    fputs(widen0, fp);
6574    fputs(neg0, fp);
6575    fputs(abs0, fp);
6576}
6577
6578static void
6579bi_disasm_add_fsincos_offset_u6(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6580{
6581    static const char *scale_table[] = {
6582        "", ".scale"
6583    };
6584
6585    const char *scale = scale_table[_BITS(bits, 3, 1)];
6586
6587    fputs("+FSINCOS_OFFSET.u6", fp);
6588    fputs(scale, fp);
6589    fputs(" ", fp);
6590    bi_disasm_dest_add(fp, next_regs, last);
6591    fputs(", ", fp);
6592    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6593    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
6594}
6595
6596static void
6597bi_disasm_add_fsin_table_u6(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6598{
6599    static const char *offset_table[] = {
6600        "", ".offset"
6601    };
6602
6603    const char *offset = offset_table[_BITS(bits, 4, 1)];
6604
6605    fputs("+FSIN_TABLE.u6", fp);
6606    fputs(offset, fp);
6607    fputs(" ", fp);
6608    bi_disasm_dest_add(fp, next_regs, last);
6609    fputs(", ", fp);
6610    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6611    if (!(0xf7 & (1 << _BITS(bits, 0, 3)))) fputs("(INVALID)", fp);
6612}
6613
6614static void
6615bi_disasm_add_hadd_s32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6616{
6617    static const char *round_table[] = {
6618        "", ".rtp"
6619    };
6620
6621    const char *round = round_table[_BITS(bits, 12, 1)];
6622
6623    fputs("+HADD.s32", fp);
6624    fputs(round, fp);
6625    fputs(" ", fp);
6626    bi_disasm_dest_add(fp, next_regs, last);
6627    fputs(", ", fp);
6628    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6629    fputs(", ", fp);
6630    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
6631}
6632
6633static void
6634bi_disasm_add_hadd_u32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6635{
6636    static const char *round_table[] = {
6637        "", ".rtp"
6638    };
6639
6640    const char *round = round_table[_BITS(bits, 12, 1)];
6641
6642    fputs("+HADD.u32", fp);
6643    fputs(round, fp);
6644    fputs(" ", fp);
6645    bi_disasm_dest_add(fp, next_regs, last);
6646    fputs(", ", fp);
6647    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6648    fputs(", ", fp);
6649    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
6650}
6651
6652static void
6653bi_disasm_add_hadd_v2s16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6654{
6655    static const char *round_table[] = {
6656        "", ".rtp"
6657    };
6658
6659    const char *round = round_table[_BITS(bits, 12, 1)];
6660
6661    static const char *swap1_table[] = {
6662        "", ".h10"
6663    };
6664
6665    const char *swap1 = swap1_table[_BITS(bits, 9, 1)];
6666
6667    static const char *swap0_table[] = {
6668        "", ".h10"
6669    };
6670
6671    const char *swap0 = swap0_table[_BITS(bits, 10, 1)];
6672
6673    fputs("+HADD.v2s16", fp);
6674    fputs(round, fp);
6675    fputs(" ", fp);
6676    bi_disasm_dest_add(fp, next_regs, last);
6677    fputs(", ", fp);
6678    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6679    fputs(swap0, fp);
6680    fputs(", ", fp);
6681    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
6682    fputs(swap1, fp);
6683}
6684
6685static void
6686bi_disasm_add_hadd_v2u16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6687{
6688    static const char *round_table[] = {
6689        "", ".rtp"
6690    };
6691
6692    const char *round = round_table[_BITS(bits, 12, 1)];
6693
6694    static const char *swap1_table[] = {
6695        "", ".h10"
6696    };
6697
6698    const char *swap1 = swap1_table[_BITS(bits, 9, 1)];
6699
6700    static const char *swap0_table[] = {
6701        "", ".h10"
6702    };
6703
6704    const char *swap0 = swap0_table[_BITS(bits, 10, 1)];
6705
6706    fputs("+HADD.v2u16", fp);
6707    fputs(round, fp);
6708    fputs(" ", fp);
6709    bi_disasm_dest_add(fp, next_regs, last);
6710    fputs(", ", fp);
6711    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6712    fputs(swap0, fp);
6713    fputs(", ", fp);
6714    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
6715    fputs(swap1, fp);
6716}
6717
6718static void
6719bi_disasm_add_hadd_v4s8(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6720{
6721    static const char *round_table[] = {
6722        "", ".rtp"
6723    };
6724
6725    const char *round = round_table[_BITS(bits, 12, 1)];
6726
6727    fputs("+HADD.v4s8", fp);
6728    fputs(round, fp);
6729    fputs(" ", fp);
6730    bi_disasm_dest_add(fp, next_regs, last);
6731    fputs(", ", fp);
6732    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6733    fputs(", ", fp);
6734    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
6735}
6736
6737static void
6738bi_disasm_add_hadd_v4u8(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6739{
6740    static const char *round_table[] = {
6741        "", ".rtp"
6742    };
6743
6744    const char *round = round_table[_BITS(bits, 12, 1)];
6745
6746    fputs("+HADD.v4u8", fp);
6747    fputs(round, fp);
6748    fputs(" ", fp);
6749    bi_disasm_dest_add(fp, next_regs, last);
6750    fputs(", ", fp);
6751    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6752    fputs(", ", fp);
6753    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
6754}
6755
6756static void
6757bi_disasm_add_iabs_s32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6758{
6759    fputs("+IABS.s32", fp);
6760    fputs(" ", fp);
6761    bi_disasm_dest_add(fp, next_regs, last);
6762    fputs(", ", fp);
6763    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6764}
6765
6766static void
6767bi_disasm_add_iabs_v2s16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6768{
6769    static const char *swz0_table[] = {
6770        ".h00", ".h10", "", ".h11"
6771    };
6772
6773    const char *swz0 = swz0_table[_BITS(bits, 4, 2)];
6774
6775    fputs("+IABS.v2s16", fp);
6776    fputs(" ", fp);
6777    bi_disasm_dest_add(fp, next_regs, last);
6778    fputs(", ", fp);
6779    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6780    fputs(swz0, fp);
6781}
6782
6783static void
6784bi_disasm_add_iabs_v4s8(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6785{
6786    fputs("+IABS.v4s8", fp);
6787    fputs(" ", fp);
6788    bi_disasm_dest_add(fp, next_regs, last);
6789    fputs(", ", fp);
6790    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6791}
6792
6793static void
6794bi_disasm_add_iadd_s32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6795{
6796    static const char *lanes1_table[] = {
6797        ""
6798    };
6799    const char *lanes1 = lanes1_table[0];
6800    static const char *saturate_table[] = {
6801        "", ".sat"
6802    };
6803
6804    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
6805
6806    fputs("+IADD.s32", fp);
6807    fputs(saturate, fp);
6808    fputs(" ", fp);
6809    bi_disasm_dest_add(fp, next_regs, last);
6810    fputs(", ", fp);
6811    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6812    fputs(", ", fp);
6813    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
6814    fputs(lanes1, fp);
6815}
6816
6817static void
6818bi_disasm_add_iadd_s32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6819{
6820    static const char *lanes1_table[] = {
6821        ".h0", ".h1"
6822    };
6823    const char *lanes1 = lanes1_table[(_BITS(bits, 9, 1) << 0)];
6824    static const char *saturate_table[] = {
6825        "", ".sat"
6826    };
6827
6828    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
6829
6830    fputs("+IADD.s32", fp);
6831    fputs(saturate, fp);
6832    fputs(" ", fp);
6833    bi_disasm_dest_add(fp, next_regs, last);
6834    fputs(", ", fp);
6835    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6836    fputs(", ", fp);
6837    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
6838    fputs(lanes1, fp);
6839}
6840
6841static void
6842bi_disasm_add_iadd_s32_2(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6843{
6844    static const char *lanes1_table[] = {
6845        ".b0", ".b1", ".b2", ".b3"
6846    };
6847    const char *lanes1 = lanes1_table[(_BITS(bits, 9, 2) << 0)];
6848    static const char *saturate_table[] = {
6849        "", ".sat"
6850    };
6851
6852    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
6853
6854    fputs("+IADD.s32", fp);
6855    fputs(saturate, fp);
6856    fputs(" ", fp);
6857    bi_disasm_dest_add(fp, next_regs, last);
6858    fputs(", ", fp);
6859    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6860    fputs(", ", fp);
6861    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
6862    fputs(lanes1, fp);
6863}
6864
6865static void
6866bi_disasm_add_iadd_u32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6867{
6868    static const char *lanes1_table[] = {
6869        ".reserved", ""
6870    };
6871    const char *lanes1 = lanes1_table[(_BITS(bits, 7, 1) << 0)];
6872    static const char *saturate_table[] = {
6873        "", ".sat"
6874    };
6875
6876    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
6877
6878    fputs("+IADD.u32", fp);
6879    fputs(saturate, fp);
6880    fputs(" ", fp);
6881    bi_disasm_dest_add(fp, next_regs, last);
6882    fputs(", ", fp);
6883    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6884    fputs(", ", fp);
6885    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
6886    fputs(lanes1, fp);
6887}
6888
6889static void
6890bi_disasm_add_iadd_u32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6891{
6892    static const char *lanes1_table[] = {
6893        ".reserved", ".h0", ".reserved", ".h1"
6894    };
6895    const char *lanes1 = lanes1_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 1) << 1)];
6896    static const char *saturate_table[] = {
6897        "", ".sat"
6898    };
6899
6900    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
6901
6902    fputs("+IADD.u32", fp);
6903    fputs(saturate, fp);
6904    fputs(" ", fp);
6905    bi_disasm_dest_add(fp, next_regs, last);
6906    fputs(", ", fp);
6907    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6908    fputs(", ", fp);
6909    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
6910    fputs(lanes1, fp);
6911}
6912
6913static void
6914bi_disasm_add_iadd_u32_2(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6915{
6916    static const char *lanes1_table[] = {
6917        ".reserved", ".b0", ".reserved", ".b1", ".reserved", ".b2", ".reserved", ".b3"
6918    };
6919    const char *lanes1 = lanes1_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 2) << 1)];
6920    static const char *saturate_table[] = {
6921        "", ".sat"
6922    };
6923
6924    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
6925
6926    fputs("+IADD.u32", fp);
6927    fputs(saturate, fp);
6928    fputs(" ", fp);
6929    bi_disasm_dest_add(fp, next_regs, last);
6930    fputs(", ", fp);
6931    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6932    fputs(", ", fp);
6933    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
6934    fputs(lanes1, fp);
6935}
6936
6937static void
6938bi_disasm_add_iadd_v2s16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6939{
6940    static const char *lanes1_table[] = {
6941        "", ".h10", "", ".h10"
6942    };
6943    const char *lanes1 = lanes1_table[(_BITS(bits, 9, 1) << 0) | (_BITS(bits, 10, 1) << 1)];
6944    static const char *lanes0_table[] = {
6945        "", "", ".h10", ".h10"
6946    };
6947    const char *lanes0 = lanes0_table[(_BITS(bits, 9, 1) << 0) | (_BITS(bits, 10, 1) << 1)];
6948    static const char *saturate_table[] = {
6949        "", ".sat"
6950    };
6951
6952    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
6953
6954    fputs("+IADD.v2s16", fp);
6955    fputs(saturate, fp);
6956    fputs(" ", fp);
6957    bi_disasm_dest_add(fp, next_regs, last);
6958    fputs(", ", fp);
6959    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6960    fputs(lanes0, fp);
6961    fputs(", ", fp);
6962    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
6963    fputs(lanes1, fp);
6964}
6965
6966static void
6967bi_disasm_add_iadd_v2s16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6968{
6969    static const char *lanes1_table[] = {
6970        ".h00", ".h11"
6971    };
6972    const char *lanes1 = lanes1_table[(_BITS(bits, 9, 1) << 0)];
6973    static const char *lanes0_table[] = {
6974        "", ""
6975    };
6976    const char *lanes0 = lanes0_table[(_BITS(bits, 9, 1) << 0)];
6977    static const char *saturate_table[] = {
6978        "", ".sat"
6979    };
6980
6981    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
6982
6983    fputs("+IADD.v2s16", fp);
6984    fputs(saturate, fp);
6985    fputs(" ", fp);
6986    bi_disasm_dest_add(fp, next_regs, last);
6987    fputs(", ", fp);
6988    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
6989    fputs(lanes0, fp);
6990    fputs(", ", fp);
6991    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
6992    fputs(lanes1, fp);
6993}
6994
6995static void
6996bi_disasm_add_iadd_v2s16_2(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
6997{
6998    static const char *lanes1_table[] = {
6999        ".b01", ".b23"
7000    };
7001    const char *lanes1 = lanes1_table[(_BITS(bits, 9, 1) << 0)];
7002    static const char *lanes0_table[] = {
7003        "", ""
7004    };
7005    const char *lanes0 = lanes0_table[(_BITS(bits, 9, 1) << 0)];
7006    static const char *saturate_table[] = {
7007        "", ".sat"
7008    };
7009
7010    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7011
7012    fputs("+IADD.v2s16", fp);
7013    fputs(saturate, fp);
7014    fputs(" ", fp);
7015    bi_disasm_dest_add(fp, next_regs, last);
7016    fputs(", ", fp);
7017    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7018    fputs(lanes0, fp);
7019    fputs(", ", fp);
7020    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7021    fputs(lanes1, fp);
7022}
7023
7024static void
7025bi_disasm_add_iadd_v2u16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7026{
7027    static const char *lanes1_table[] = {
7028        ".reserved", "", ".reserved", ".h10", ".reserved", "", ".reserved", ".h10"
7029    };
7030    const char *lanes1 = lanes1_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 1) << 1) | (_BITS(bits, 10, 1) << 2)];
7031    static const char *lanes0_table[] = {
7032        ".reserved", "", ".reserved", "", ".reserved", ".h10", ".reserved", ".h10"
7033    };
7034    const char *lanes0 = lanes0_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 1) << 1) | (_BITS(bits, 10, 1) << 2)];
7035    static const char *saturate_table[] = {
7036        "", ".sat"
7037    };
7038
7039    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7040
7041    fputs("+IADD.v2u16", fp);
7042    fputs(saturate, fp);
7043    fputs(" ", fp);
7044    bi_disasm_dest_add(fp, next_regs, last);
7045    fputs(", ", fp);
7046    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7047    fputs(lanes0, fp);
7048    fputs(", ", fp);
7049    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7050    fputs(lanes1, fp);
7051}
7052
7053static void
7054bi_disasm_add_iadd_v2u16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7055{
7056    static const char *lanes1_table[] = {
7057        ".reserved", ".h00", ".reserved", ".h11"
7058    };
7059    const char *lanes1 = lanes1_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 1) << 1)];
7060    static const char *lanes0_table[] = {
7061        ".reserved", "", ".reserved", ""
7062    };
7063    const char *lanes0 = lanes0_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 1) << 1)];
7064    static const char *saturate_table[] = {
7065        "", ".sat"
7066    };
7067
7068    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7069
7070    fputs("+IADD.v2u16", fp);
7071    fputs(saturate, fp);
7072    fputs(" ", fp);
7073    bi_disasm_dest_add(fp, next_regs, last);
7074    fputs(", ", fp);
7075    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7076    fputs(lanes0, fp);
7077    fputs(", ", fp);
7078    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7079    fputs(lanes1, fp);
7080}
7081
7082static void
7083bi_disasm_add_iadd_v2u16_2(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7084{
7085    static const char *lanes1_table[] = {
7086        ".reserved", ".b01", ".reserved", ".b23"
7087    };
7088    const char *lanes1 = lanes1_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 1) << 1)];
7089    static const char *lanes0_table[] = {
7090        ".reserved", "", ".reserved", ""
7091    };
7092    const char *lanes0 = lanes0_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 1) << 1)];
7093    static const char *saturate_table[] = {
7094        "", ".sat"
7095    };
7096
7097    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7098
7099    fputs("+IADD.v2u16", fp);
7100    fputs(saturate, fp);
7101    fputs(" ", fp);
7102    bi_disasm_dest_add(fp, next_regs, last);
7103    fputs(", ", fp);
7104    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7105    fputs(lanes0, fp);
7106    fputs(", ", fp);
7107    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7108    fputs(lanes1, fp);
7109}
7110
7111static void
7112bi_disasm_add_iadd_v4s8_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7113{
7114    static const char *lanes1_table[] = {
7115        ""
7116    };
7117    const char *lanes1 = lanes1_table[0];
7118    static const char *lanes0_table[] = {
7119        ""
7120    };
7121    const char *lanes0 = lanes0_table[0];
7122    static const char *saturate_table[] = {
7123        "", ".sat"
7124    };
7125
7126    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7127
7128    fputs("+IADD.v4s8", fp);
7129    fputs(saturate, fp);
7130    fputs(" ", fp);
7131    bi_disasm_dest_add(fp, next_regs, last);
7132    fputs(", ", fp);
7133    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7134    fputs(lanes0, fp);
7135    fputs(", ", fp);
7136    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7137    fputs(lanes1, fp);
7138}
7139
7140static void
7141bi_disasm_add_iadd_v4s8_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7142{
7143    static const char *lanes1_table[] = {
7144        ".b0000", ".b1111", ".b2222", ".b3333"
7145    };
7146    const char *lanes1 = lanes1_table[(_BITS(bits, 9, 2) << 0)];
7147    static const char *lanes0_table[] = {
7148        "", "", "", ""
7149    };
7150    const char *lanes0 = lanes0_table[(_BITS(bits, 9, 2) << 0)];
7151    static const char *saturate_table[] = {
7152        "", ".sat"
7153    };
7154
7155    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7156
7157    fputs("+IADD.v4s8", fp);
7158    fputs(saturate, fp);
7159    fputs(" ", fp);
7160    bi_disasm_dest_add(fp, next_regs, last);
7161    fputs(", ", fp);
7162    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7163    fputs(lanes0, fp);
7164    fputs(", ", fp);
7165    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7166    fputs(lanes1, fp);
7167}
7168
7169static void
7170bi_disasm_add_iadd_v4s8_2(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7171{
7172    static const char *lanes1_table[] = {
7173        ".b0101", ".b2323"
7174    };
7175    const char *lanes1 = lanes1_table[(_BITS(bits, 9, 1) << 0)];
7176    static const char *lanes0_table[] = {
7177        "", ""
7178    };
7179    const char *lanes0 = lanes0_table[(_BITS(bits, 9, 1) << 0)];
7180    static const char *saturate_table[] = {
7181        "", ".sat"
7182    };
7183
7184    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7185
7186    fputs("+IADD.v4s8", fp);
7187    fputs(saturate, fp);
7188    fputs(" ", fp);
7189    bi_disasm_dest_add(fp, next_regs, last);
7190    fputs(", ", fp);
7191    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7192    fputs(lanes0, fp);
7193    fputs(", ", fp);
7194    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7195    fputs(lanes1, fp);
7196}
7197
7198static void
7199bi_disasm_add_iadd_v4u8_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7200{
7201    static const char *lanes1_table[] = {
7202        ".reserved", ""
7203    };
7204    const char *lanes1 = lanes1_table[(_BITS(bits, 7, 1) << 0)];
7205    static const char *lanes0_table[] = {
7206        ".reserved", ""
7207    };
7208    const char *lanes0 = lanes0_table[(_BITS(bits, 7, 1) << 0)];
7209    static const char *saturate_table[] = {
7210        "", ".sat"
7211    };
7212
7213    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7214
7215    fputs("+IADD.v4u8", fp);
7216    fputs(saturate, fp);
7217    fputs(" ", fp);
7218    bi_disasm_dest_add(fp, next_regs, last);
7219    fputs(", ", fp);
7220    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7221    fputs(lanes0, fp);
7222    fputs(", ", fp);
7223    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7224    fputs(lanes1, fp);
7225}
7226
7227static void
7228bi_disasm_add_iadd_v4u8_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7229{
7230    static const char *lanes1_table[] = {
7231        ".reserved", ".b0000", ".reserved", ".b1111", ".reserved", ".b2222", ".reserved", ".b3333"
7232    };
7233    const char *lanes1 = lanes1_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 2) << 1)];
7234    static const char *lanes0_table[] = {
7235        ".reserved", "", ".reserved", "", ".reserved", "", ".reserved", ""
7236    };
7237    const char *lanes0 = lanes0_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 2) << 1)];
7238    static const char *saturate_table[] = {
7239        "", ".sat"
7240    };
7241
7242    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7243
7244    fputs("+IADD.v4u8", fp);
7245    fputs(saturate, fp);
7246    fputs(" ", fp);
7247    bi_disasm_dest_add(fp, next_regs, last);
7248    fputs(", ", fp);
7249    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7250    fputs(lanes0, fp);
7251    fputs(", ", fp);
7252    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7253    fputs(lanes1, fp);
7254}
7255
7256static void
7257bi_disasm_add_iadd_v4u8_2(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7258{
7259    static const char *lanes1_table[] = {
7260        ".reserved", ".b0101", ".reserved", ".b2323"
7261    };
7262    const char *lanes1 = lanes1_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 1) << 1)];
7263    static const char *lanes0_table[] = {
7264        ".reserved", "", ".reserved", ""
7265    };
7266    const char *lanes0 = lanes0_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 1) << 1)];
7267    static const char *saturate_table[] = {
7268        "", ".sat"
7269    };
7270
7271    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7272
7273    fputs("+IADD.v4u8", fp);
7274    fputs(saturate, fp);
7275    fputs(" ", fp);
7276    bi_disasm_dest_add(fp, next_regs, last);
7277    fputs(", ", fp);
7278    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7279    fputs(lanes0, fp);
7280    fputs(", ", fp);
7281    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7282    fputs(lanes1, fp);
7283}
7284
7285static void
7286bi_disasm_add_icmp_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7287{
7288    static const char *result_type_table[] = {
7289        "", ".m1"
7290    };
7291
7292    const char *result_type = result_type_table[_BITS(bits, 10, 1)];
7293
7294    static const char *cmpf_table[] = {
7295        ".eq", ".ne"
7296    };
7297
7298    const char *cmpf = cmpf_table[_BITS(bits, 6, 1)];
7299
7300    fputs("+ICMP.i32", fp);
7301    fputs(result_type, fp);
7302    fputs(cmpf, fp);
7303    fputs(" ", fp);
7304    bi_disasm_dest_add(fp, next_regs, last);
7305    fputs(", ", fp);
7306    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7307    fputs(", ", fp);
7308    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7309}
7310
7311static void
7312bi_disasm_add_icmp_s32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7313{
7314    static const char *cmpf_table[] = {
7315        ".gt", ".ge"
7316    };
7317    const char *cmpf = cmpf_table[(_BITS(bits, 6, 1) << 0)];
7318    static const char *result_type_table[] = {
7319        "", ".m1"
7320    };
7321
7322    const char *result_type = result_type_table[_BITS(bits, 10, 1)];
7323
7324    fputs("+ICMP.s32", fp);
7325    fputs(result_type, fp);
7326    fputs(cmpf, fp);
7327    fputs(" ", fp);
7328    bi_disasm_dest_add(fp, next_regs, last);
7329    fputs(", ", fp);
7330    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7331    fputs(", ", fp);
7332    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7333}
7334
7335static void
7336bi_disasm_add_icmp_u32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7337{
7338    static const char *cmpf_table[] = {
7339        ".gt", ".ge"
7340    };
7341    const char *cmpf = cmpf_table[(_BITS(bits, 6, 1) << 0)];
7342    static const char *result_type_table[] = {
7343        "", ".m1"
7344    };
7345
7346    const char *result_type = result_type_table[_BITS(bits, 10, 1)];
7347
7348    fputs("+ICMP.u32", fp);
7349    fputs(result_type, fp);
7350    fputs(cmpf, fp);
7351    fputs(" ", fp);
7352    bi_disasm_dest_add(fp, next_regs, last);
7353    fputs(", ", fp);
7354    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7355    fputs(", ", fp);
7356    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7357}
7358
7359static void
7360bi_disasm_add_icmp_v2i16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7361{
7362    static const char *swz0_table[] = {
7363        ".h00", ".h10", "", ".h11"
7364    };
7365
7366    const char *swz0 = swz0_table[_BITS(bits, 6, 2)];
7367
7368    static const char *swz1_table[] = {
7369        ".h00", ".h10", "", ".h11"
7370    };
7371
7372    const char *swz1 = swz1_table[_BITS(bits, 8, 2)];
7373
7374    static const char *result_type_table[] = {
7375        "", ".m1"
7376    };
7377
7378    const char *result_type = result_type_table[_BITS(bits, 10, 1)];
7379
7380    static const char *cmpf_table[] = {
7381        ".eq", ".ne"
7382    };
7383
7384    const char *cmpf = cmpf_table[_BITS(bits, 11, 1)];
7385
7386    fputs("+ICMP.v2i16", fp);
7387    fputs(result_type, fp);
7388    fputs(cmpf, fp);
7389    fputs(" ", fp);
7390    bi_disasm_dest_add(fp, next_regs, last);
7391    fputs(", ", fp);
7392    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7393    fputs(swz0, fp);
7394    fputs(", ", fp);
7395    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7396    fputs(swz1, fp);
7397}
7398
7399static void
7400bi_disasm_add_icmp_v2s16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7401{
7402    static const char *cmpf_table[] = {
7403        ".gt", ".ge"
7404    };
7405    const char *cmpf = cmpf_table[(_BITS(bits, 12, 1) << 0)];
7406    static const char *swz0_table[] = {
7407        ".h00", ".h10", "", ".h11"
7408    };
7409
7410    const char *swz0 = swz0_table[_BITS(bits, 6, 2)];
7411
7412    static const char *swz1_table[] = {
7413        ".h00", ".h10", "", ".h11"
7414    };
7415
7416    const char *swz1 = swz1_table[_BITS(bits, 8, 2)];
7417
7418    static const char *result_type_table[] = {
7419        "", ".m1"
7420    };
7421
7422    const char *result_type = result_type_table[_BITS(bits, 10, 1)];
7423
7424    fputs("+ICMP.v2s16", fp);
7425    fputs(result_type, fp);
7426    fputs(cmpf, fp);
7427    fputs(" ", fp);
7428    bi_disasm_dest_add(fp, next_regs, last);
7429    fputs(", ", fp);
7430    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7431    fputs(swz0, fp);
7432    fputs(", ", fp);
7433    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7434    fputs(swz1, fp);
7435}
7436
7437static void
7438bi_disasm_add_icmp_v2u16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7439{
7440    static const char *cmpf_table[] = {
7441        ".gt", ".ge"
7442    };
7443    const char *cmpf = cmpf_table[(_BITS(bits, 12, 1) << 0)];
7444    static const char *swz0_table[] = {
7445        ".h00", ".h10", "", ".h11"
7446    };
7447
7448    const char *swz0 = swz0_table[_BITS(bits, 6, 2)];
7449
7450    static const char *swz1_table[] = {
7451        ".h00", ".h10", "", ".h11"
7452    };
7453
7454    const char *swz1 = swz1_table[_BITS(bits, 8, 2)];
7455
7456    static const char *result_type_table[] = {
7457        "", ".m1"
7458    };
7459
7460    const char *result_type = result_type_table[_BITS(bits, 10, 1)];
7461
7462    fputs("+ICMP.v2u16", fp);
7463    fputs(result_type, fp);
7464    fputs(cmpf, fp);
7465    fputs(" ", fp);
7466    bi_disasm_dest_add(fp, next_regs, last);
7467    fputs(", ", fp);
7468    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7469    fputs(swz0, fp);
7470    fputs(", ", fp);
7471    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7472    fputs(swz1, fp);
7473}
7474
7475static void
7476bi_disasm_add_icmp_v4i8(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7477{
7478    static const char *result_type_table[] = {
7479        "", ".m1"
7480    };
7481
7482    const char *result_type = result_type_table[_BITS(bits, 10, 1)];
7483
7484    static const char *cmpf_table[] = {
7485        ".eq", ".ne"
7486    };
7487
7488    const char *cmpf = cmpf_table[_BITS(bits, 6, 1)];
7489
7490    fputs("+ICMP.v4i8", fp);
7491    fputs(result_type, fp);
7492    fputs(cmpf, fp);
7493    fputs(" ", fp);
7494    bi_disasm_dest_add(fp, next_regs, last);
7495    fputs(", ", fp);
7496    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7497    fputs(", ", fp);
7498    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7499}
7500
7501static void
7502bi_disasm_add_icmp_v4s8(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7503{
7504    static const char *cmpf_table[] = {
7505        ".gt", ".ge"
7506    };
7507    const char *cmpf = cmpf_table[(_BITS(bits, 6, 1) << 0)];
7508    static const char *result_type_table[] = {
7509        "", ".m1"
7510    };
7511
7512    const char *result_type = result_type_table[_BITS(bits, 10, 1)];
7513
7514    fputs("+ICMP.v4s8", fp);
7515    fputs(result_type, fp);
7516    fputs(cmpf, fp);
7517    fputs(" ", fp);
7518    bi_disasm_dest_add(fp, next_regs, last);
7519    fputs(", ", fp);
7520    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7521    fputs(", ", fp);
7522    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7523}
7524
7525static void
7526bi_disasm_add_icmp_v4u8(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7527{
7528    static const char *cmpf_table[] = {
7529        ".gt", ".ge"
7530    };
7531    const char *cmpf = cmpf_table[(_BITS(bits, 6, 1) << 0)];
7532    static const char *result_type_table[] = {
7533        "", ".m1"
7534    };
7535
7536    const char *result_type = result_type_table[_BITS(bits, 10, 1)];
7537
7538    fputs("+ICMP.v4u8", fp);
7539    fputs(result_type, fp);
7540    fputs(cmpf, fp);
7541    fputs(" ", fp);
7542    bi_disasm_dest_add(fp, next_regs, last);
7543    fputs(", ", fp);
7544    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7545    fputs(", ", fp);
7546    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7547}
7548
7549static void
7550bi_disasm_add_icmpf_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7551{
7552    fputs("+ICMPF.i32", fp);
7553    fputs(" ", fp);
7554    bi_disasm_dest_add(fp, next_regs, last);
7555    fputs(", ", fp);
7556    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7557    fputs(", ", fp);
7558    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7559    fputs(", ", fp);
7560    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
7561}
7562
7563static void
7564bi_disasm_add_icmpi_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7565{
7566    static const char *result_type_table[] = {
7567        "", ".m1"
7568    };
7569
7570    const char *result_type = result_type_table[_BITS(bits, 10, 1)];
7571
7572    static const char *cmpf_table[] = {
7573        ".eq", ".ne"
7574    };
7575
7576    const char *cmpf = cmpf_table[_BITS(bits, 6, 1)];
7577
7578    fputs("+ICMPI.i32", fp);
7579    fputs(result_type, fp);
7580    fputs(cmpf, fp);
7581    fputs(" ", fp);
7582    bi_disasm_dest_add(fp, next_regs, last);
7583    fputs(", ", fp);
7584    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7585    fputs(", ", fp);
7586    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7587}
7588
7589static void
7590bi_disasm_add_icmpi_s32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7591{
7592    static const char *result_type_table[] = {
7593        "", ".m1"
7594    };
7595
7596    const char *result_type = result_type_table[_BITS(bits, 10, 1)];
7597
7598    static const char *cmpf_table[] = {
7599        ".gt", ".ge"
7600    };
7601
7602    const char *cmpf = cmpf_table[_BITS(bits, 6, 1)];
7603
7604    fputs("+ICMPI.s32", fp);
7605    fputs(result_type, fp);
7606    fputs(cmpf, fp);
7607    fputs(" ", fp);
7608    bi_disasm_dest_add(fp, next_regs, last);
7609    fputs(", ", fp);
7610    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7611    fputs(", ", fp);
7612    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7613}
7614
7615static void
7616bi_disasm_add_icmpi_u32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7617{
7618    static const char *result_type_table[] = {
7619        "", ".m1"
7620    };
7621
7622    const char *result_type = result_type_table[_BITS(bits, 10, 1)];
7623
7624    static const char *cmpf_table[] = {
7625        ".gt", ".ge"
7626    };
7627
7628    const char *cmpf = cmpf_table[_BITS(bits, 6, 1)];
7629
7630    fputs("+ICMPI.u32", fp);
7631    fputs(result_type, fp);
7632    fputs(cmpf, fp);
7633    fputs(" ", fp);
7634    bi_disasm_dest_add(fp, next_regs, last);
7635    fputs(", ", fp);
7636    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7637    fputs(", ", fp);
7638    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7639}
7640
7641static void
7642bi_disasm_add_icmpm_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7643{
7644    fputs("+ICMPM.i32", fp);
7645    fputs(" ", fp);
7646    bi_disasm_dest_add(fp, next_regs, last);
7647    fputs(", ", fp);
7648    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7649    fputs(", ", fp);
7650    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7651    fputs(", ", fp);
7652    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
7653}
7654
7655static void
7656bi_disasm_add_ilogb_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7657{
7658    static const char *widen0_table[] = {
7659        ".reserved", "", ".h0", ".h1"
7660    };
7661
7662    const char *widen0 = widen0_table[_BITS(bits, 3, 2)];
7663
7664    fputs("+ILOGB.f32", fp);
7665    fputs(" ", fp);
7666    bi_disasm_dest_add(fp, next_regs, last);
7667    fputs(", ", fp);
7668    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7669    fputs(widen0, fp);
7670}
7671
7672static void
7673bi_disasm_add_ilogb_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7674{
7675    static const char *swz0_table[] = {
7676        ".h00", ".h10", "", ".h11"
7677    };
7678
7679    const char *swz0 = swz0_table[_BITS(bits, 3, 2)];
7680
7681    fputs("+ILOGB.v2f16", fp);
7682    fputs(" ", fp);
7683    bi_disasm_dest_add(fp, next_regs, last);
7684    fputs(", ", fp);
7685    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7686    fputs(swz0, fp);
7687}
7688
7689static void
7690bi_disasm_add_imov_fma(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7691{
7692    static const char *threads_table[] = {
7693        ".even", ""
7694    };
7695
7696    const char *threads = threads_table[_BITS(bits, 3, 1)];
7697
7698    fputs("+IMOV_FMA", fp);
7699    fputs(threads, fp);
7700    fputs(" ", fp);
7701    bi_disasm_dest_add(fp, next_regs, last);
7702}
7703
7704static void
7705bi_disasm_add_isub_s32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7706{
7707    static const char *lanes1_table[] = {
7708        ""
7709    };
7710    const char *lanes1 = lanes1_table[0];
7711    static const char *saturate_table[] = {
7712        "", ".sat"
7713    };
7714
7715    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7716
7717    fputs("+ISUB.s32", fp);
7718    fputs(saturate, fp);
7719    fputs(" ", fp);
7720    bi_disasm_dest_add(fp, next_regs, last);
7721    fputs(", ", fp);
7722    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7723    fputs(", ", fp);
7724    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7725    fputs(lanes1, fp);
7726}
7727
7728static void
7729bi_disasm_add_isub_s32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7730{
7731    static const char *lanes1_table[] = {
7732        ".h0", ".h1"
7733    };
7734    const char *lanes1 = lanes1_table[(_BITS(bits, 9, 1) << 0)];
7735    static const char *saturate_table[] = {
7736        "", ".sat"
7737    };
7738
7739    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7740
7741    fputs("+ISUB.s32", fp);
7742    fputs(saturate, fp);
7743    fputs(" ", fp);
7744    bi_disasm_dest_add(fp, next_regs, last);
7745    fputs(", ", fp);
7746    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7747    fputs(", ", fp);
7748    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7749    fputs(lanes1, fp);
7750}
7751
7752static void
7753bi_disasm_add_isub_s32_2(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7754{
7755    static const char *lanes1_table[] = {
7756        ".b0", ".b1", ".b2", ".b3"
7757    };
7758    const char *lanes1 = lanes1_table[(_BITS(bits, 9, 2) << 0)];
7759    static const char *saturate_table[] = {
7760        "", ".sat"
7761    };
7762
7763    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7764
7765    fputs("+ISUB.s32", fp);
7766    fputs(saturate, fp);
7767    fputs(" ", fp);
7768    bi_disasm_dest_add(fp, next_regs, last);
7769    fputs(", ", fp);
7770    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7771    fputs(", ", fp);
7772    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7773    fputs(lanes1, fp);
7774}
7775
7776static void
7777bi_disasm_add_isub_u32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7778{
7779    static const char *lanes1_table[] = {
7780        ".reserved", ""
7781    };
7782    const char *lanes1 = lanes1_table[(_BITS(bits, 7, 1) << 0)];
7783    static const char *saturate_table[] = {
7784        "", ".sat"
7785    };
7786
7787    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7788
7789    fputs("+ISUB.u32", fp);
7790    fputs(saturate, fp);
7791    fputs(" ", fp);
7792    bi_disasm_dest_add(fp, next_regs, last);
7793    fputs(", ", fp);
7794    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7795    fputs(", ", fp);
7796    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7797    fputs(lanes1, fp);
7798}
7799
7800static void
7801bi_disasm_add_isub_u32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7802{
7803    static const char *lanes1_table[] = {
7804        ".reserved", ".h0", ".reserved", ".h1"
7805    };
7806    const char *lanes1 = lanes1_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 1) << 1)];
7807    static const char *saturate_table[] = {
7808        "", ".sat"
7809    };
7810
7811    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7812
7813    fputs("+ISUB.u32", fp);
7814    fputs(saturate, fp);
7815    fputs(" ", fp);
7816    bi_disasm_dest_add(fp, next_regs, last);
7817    fputs(", ", fp);
7818    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7819    fputs(", ", fp);
7820    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7821    fputs(lanes1, fp);
7822}
7823
7824static void
7825bi_disasm_add_isub_u32_2(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7826{
7827    static const char *lanes1_table[] = {
7828        ".reserved", ".b0", ".reserved", ".b1", ".reserved", ".b2", ".reserved", ".b3"
7829    };
7830    const char *lanes1 = lanes1_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 2) << 1)];
7831    static const char *saturate_table[] = {
7832        "", ".sat"
7833    };
7834
7835    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7836
7837    fputs("+ISUB.u32", fp);
7838    fputs(saturate, fp);
7839    fputs(" ", fp);
7840    bi_disasm_dest_add(fp, next_regs, last);
7841    fputs(", ", fp);
7842    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7843    fputs(", ", fp);
7844    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7845    fputs(lanes1, fp);
7846}
7847
7848static void
7849bi_disasm_add_isub_v2s16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7850{
7851    static const char *lanes1_table[] = {
7852        "", ".h10", "", ".h10"
7853    };
7854    const char *lanes1 = lanes1_table[(_BITS(bits, 9, 1) << 0) | (_BITS(bits, 10, 1) << 1)];
7855    static const char *lanes0_table[] = {
7856        "", "", ".h10", ".h10"
7857    };
7858    const char *lanes0 = lanes0_table[(_BITS(bits, 9, 1) << 0) | (_BITS(bits, 10, 1) << 1)];
7859    static const char *saturate_table[] = {
7860        "", ".sat"
7861    };
7862
7863    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7864
7865    fputs("+ISUB.v2s16", fp);
7866    fputs(saturate, fp);
7867    fputs(" ", fp);
7868    bi_disasm_dest_add(fp, next_regs, last);
7869    fputs(", ", fp);
7870    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7871    fputs(lanes0, fp);
7872    fputs(", ", fp);
7873    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7874    fputs(lanes1, fp);
7875}
7876
7877static void
7878bi_disasm_add_isub_v2s16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7879{
7880    static const char *lanes1_table[] = {
7881        ".h00", ".h11"
7882    };
7883    const char *lanes1 = lanes1_table[(_BITS(bits, 9, 1) << 0)];
7884    static const char *lanes0_table[] = {
7885        "", ""
7886    };
7887    const char *lanes0 = lanes0_table[(_BITS(bits, 9, 1) << 0)];
7888    static const char *saturate_table[] = {
7889        "", ".sat"
7890    };
7891
7892    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7893
7894    fputs("+ISUB.v2s16", fp);
7895    fputs(saturate, fp);
7896    fputs(" ", fp);
7897    bi_disasm_dest_add(fp, next_regs, last);
7898    fputs(", ", fp);
7899    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7900    fputs(lanes0, fp);
7901    fputs(", ", fp);
7902    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7903    fputs(lanes1, fp);
7904}
7905
7906static void
7907bi_disasm_add_isub_v2s16_2(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7908{
7909    static const char *lanes1_table[] = {
7910        ".b01", ".b23"
7911    };
7912    const char *lanes1 = lanes1_table[(_BITS(bits, 9, 1) << 0)];
7913    static const char *lanes0_table[] = {
7914        "", ""
7915    };
7916    const char *lanes0 = lanes0_table[(_BITS(bits, 9, 1) << 0)];
7917    static const char *saturate_table[] = {
7918        "", ".sat"
7919    };
7920
7921    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7922
7923    fputs("+ISUB.v2s16", fp);
7924    fputs(saturate, fp);
7925    fputs(" ", fp);
7926    bi_disasm_dest_add(fp, next_regs, last);
7927    fputs(", ", fp);
7928    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7929    fputs(lanes0, fp);
7930    fputs(", ", fp);
7931    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7932    fputs(lanes1, fp);
7933}
7934
7935static void
7936bi_disasm_add_isub_v2u16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7937{
7938    static const char *lanes1_table[] = {
7939        ".reserved", "", ".reserved", ".h10", ".reserved", "", ".reserved", ".h10"
7940    };
7941    const char *lanes1 = lanes1_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 1) << 1) | (_BITS(bits, 10, 1) << 2)];
7942    static const char *lanes0_table[] = {
7943        ".reserved", "", ".reserved", "", ".reserved", ".h10", ".reserved", ".h10"
7944    };
7945    const char *lanes0 = lanes0_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 1) << 1) | (_BITS(bits, 10, 1) << 2)];
7946    static const char *saturate_table[] = {
7947        "", ".sat"
7948    };
7949
7950    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7951
7952    fputs("+ISUB.v2u16", fp);
7953    fputs(saturate, fp);
7954    fputs(" ", fp);
7955    bi_disasm_dest_add(fp, next_regs, last);
7956    fputs(", ", fp);
7957    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7958    fputs(lanes0, fp);
7959    fputs(", ", fp);
7960    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7961    fputs(lanes1, fp);
7962}
7963
7964static void
7965bi_disasm_add_isub_v2u16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7966{
7967    static const char *lanes1_table[] = {
7968        ".reserved", ".h00", ".reserved", ".h11"
7969    };
7970    const char *lanes1 = lanes1_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 1) << 1)];
7971    static const char *lanes0_table[] = {
7972        ".reserved", "", ".reserved", ""
7973    };
7974    const char *lanes0 = lanes0_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 1) << 1)];
7975    static const char *saturate_table[] = {
7976        "", ".sat"
7977    };
7978
7979    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
7980
7981    fputs("+ISUB.v2u16", fp);
7982    fputs(saturate, fp);
7983    fputs(" ", fp);
7984    bi_disasm_dest_add(fp, next_regs, last);
7985    fputs(", ", fp);
7986    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
7987    fputs(lanes0, fp);
7988    fputs(", ", fp);
7989    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
7990    fputs(lanes1, fp);
7991}
7992
7993static void
7994bi_disasm_add_isub_v2u16_2(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
7995{
7996    static const char *lanes1_table[] = {
7997        ".reserved", ".b01", ".reserved", ".b23"
7998    };
7999    const char *lanes1 = lanes1_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 1) << 1)];
8000    static const char *lanes0_table[] = {
8001        ".reserved", "", ".reserved", ""
8002    };
8003    const char *lanes0 = lanes0_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 1) << 1)];
8004    static const char *saturate_table[] = {
8005        "", ".sat"
8006    };
8007
8008    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
8009
8010    fputs("+ISUB.v2u16", fp);
8011    fputs(saturate, fp);
8012    fputs(" ", fp);
8013    bi_disasm_dest_add(fp, next_regs, last);
8014    fputs(", ", fp);
8015    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8016    fputs(lanes0, fp);
8017    fputs(", ", fp);
8018    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8019    fputs(lanes1, fp);
8020}
8021
8022static void
8023bi_disasm_add_isub_v4s8_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8024{
8025    static const char *lanes1_table[] = {
8026        ""
8027    };
8028    const char *lanes1 = lanes1_table[0];
8029    static const char *lanes0_table[] = {
8030        ""
8031    };
8032    const char *lanes0 = lanes0_table[0];
8033    static const char *saturate_table[] = {
8034        "", ".sat"
8035    };
8036
8037    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
8038
8039    fputs("+ISUB.v4s8", fp);
8040    fputs(saturate, fp);
8041    fputs(" ", fp);
8042    bi_disasm_dest_add(fp, next_regs, last);
8043    fputs(", ", fp);
8044    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8045    fputs(lanes0, fp);
8046    fputs(", ", fp);
8047    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8048    fputs(lanes1, fp);
8049}
8050
8051static void
8052bi_disasm_add_isub_v4s8_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8053{
8054    static const char *lanes1_table[] = {
8055        ".b0000", ".b1111", ".b2222", ".b3333"
8056    };
8057    const char *lanes1 = lanes1_table[(_BITS(bits, 9, 2) << 0)];
8058    static const char *lanes0_table[] = {
8059        "", "", "", ""
8060    };
8061    const char *lanes0 = lanes0_table[(_BITS(bits, 9, 2) << 0)];
8062    static const char *saturate_table[] = {
8063        "", ".sat"
8064    };
8065
8066    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
8067
8068    fputs("+ISUB.v4s8", fp);
8069    fputs(saturate, fp);
8070    fputs(" ", fp);
8071    bi_disasm_dest_add(fp, next_regs, last);
8072    fputs(", ", fp);
8073    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8074    fputs(lanes0, fp);
8075    fputs(", ", fp);
8076    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8077    fputs(lanes1, fp);
8078}
8079
8080static void
8081bi_disasm_add_isub_v4s8_2(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8082{
8083    static const char *lanes1_table[] = {
8084        ".b0101", ".b2323"
8085    };
8086    const char *lanes1 = lanes1_table[(_BITS(bits, 9, 1) << 0)];
8087    static const char *lanes0_table[] = {
8088        "", ""
8089    };
8090    const char *lanes0 = lanes0_table[(_BITS(bits, 9, 1) << 0)];
8091    static const char *saturate_table[] = {
8092        "", ".sat"
8093    };
8094
8095    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
8096
8097    fputs("+ISUB.v4s8", fp);
8098    fputs(saturate, fp);
8099    fputs(" ", fp);
8100    bi_disasm_dest_add(fp, next_regs, last);
8101    fputs(", ", fp);
8102    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8103    fputs(lanes0, fp);
8104    fputs(", ", fp);
8105    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8106    fputs(lanes1, fp);
8107}
8108
8109static void
8110bi_disasm_add_isub_v4u8_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8111{
8112    static const char *lanes1_table[] = {
8113        ".reserved", ""
8114    };
8115    const char *lanes1 = lanes1_table[(_BITS(bits, 7, 1) << 0)];
8116    static const char *lanes0_table[] = {
8117        ".reserved", ""
8118    };
8119    const char *lanes0 = lanes0_table[(_BITS(bits, 7, 1) << 0)];
8120    static const char *saturate_table[] = {
8121        "", ".sat"
8122    };
8123
8124    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
8125
8126    fputs("+ISUB.v4u8", fp);
8127    fputs(saturate, fp);
8128    fputs(" ", fp);
8129    bi_disasm_dest_add(fp, next_regs, last);
8130    fputs(", ", fp);
8131    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8132    fputs(lanes0, fp);
8133    fputs(", ", fp);
8134    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8135    fputs(lanes1, fp);
8136}
8137
8138static void
8139bi_disasm_add_isub_v4u8_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8140{
8141    static const char *lanes1_table[] = {
8142        ".reserved", ".b0000", ".reserved", ".b1111", ".reserved", ".b2222", ".reserved", ".b3333"
8143    };
8144    const char *lanes1 = lanes1_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 2) << 1)];
8145    static const char *lanes0_table[] = {
8146        ".reserved", "", ".reserved", "", ".reserved", "", ".reserved", ""
8147    };
8148    const char *lanes0 = lanes0_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 2) << 1)];
8149    static const char *saturate_table[] = {
8150        "", ".sat"
8151    };
8152
8153    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
8154
8155    fputs("+ISUB.v4u8", fp);
8156    fputs(saturate, fp);
8157    fputs(" ", fp);
8158    bi_disasm_dest_add(fp, next_regs, last);
8159    fputs(", ", fp);
8160    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8161    fputs(lanes0, fp);
8162    fputs(", ", fp);
8163    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8164    fputs(lanes1, fp);
8165}
8166
8167static void
8168bi_disasm_add_isub_v4u8_2(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8169{
8170    static const char *lanes1_table[] = {
8171        ".reserved", ".b0101", ".reserved", ".b2323"
8172    };
8173    const char *lanes1 = lanes1_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 1) << 1)];
8174    static const char *lanes0_table[] = {
8175        ".reserved", "", ".reserved", ""
8176    };
8177    const char *lanes0 = lanes0_table[(_BITS(bits, 7, 1) << 0) | (_BITS(bits, 9, 1) << 1)];
8178    static const char *saturate_table[] = {
8179        "", ".sat"
8180    };
8181
8182    const char *saturate = saturate_table[_BITS(bits, 8, 1)];
8183
8184    fputs("+ISUB.v4u8", fp);
8185    fputs(saturate, fp);
8186    fputs(" ", fp);
8187    bi_disasm_dest_add(fp, next_regs, last);
8188    fputs(", ", fp);
8189    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8190    fputs(lanes0, fp);
8191    fputs(", ", fp);
8192    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8193    fputs(lanes1, fp);
8194}
8195
8196static void
8197bi_disasm_add_jump(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8198{
8199    fputs("+JUMP", fp);
8200    fputs(" ", fp);
8201    bi_disasm_dest_add(fp, next_regs, last);
8202    fputs(", ", fp);
8203    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
8204    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
8205}
8206
8207static void
8208bi_disasm_add_kaboom(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8209{
8210    fputs("+KABOOM", fp);
8211    fputs(" ", fp);
8212    bi_disasm_dest_add(fp, next_regs, last);
8213    fputs(", ", fp);
8214    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8215}
8216
8217static void
8218bi_disasm_add_ldexp_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8219{
8220    static const char *round_table[] = {
8221        "", ".rtp", ".rtn", ".rtz", ".rtna", ".reserved", ".inf", ".inf0"
8222    };
8223
8224    const char *round = round_table[_BITS(bits, 6, 3)];
8225
8226    fputs("+LDEXP.f32", fp);
8227    fputs(round, fp);
8228    fputs(" ", fp);
8229    bi_disasm_dest_add(fp, next_regs, last);
8230    fputs(", ", fp);
8231    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8232    fputs(", ", fp);
8233    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8234}
8235
8236static void
8237bi_disasm_add_ldexp_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8238{
8239    static const char *round_table[] = {
8240        "", ".rtp", ".rtn", ".rtz", ".rtna", ".reserved", ".inf", ".inf0"
8241    };
8242
8243    const char *round = round_table[_BITS(bits, 6, 3)];
8244
8245    fputs("+LDEXP.v2f16", fp);
8246    fputs(round, fp);
8247    fputs(" ", fp);
8248    bi_disasm_dest_add(fp, next_regs, last);
8249    fputs(", ", fp);
8250    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8251    fputs(", ", fp);
8252    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8253}
8254
8255static void
8256bi_disasm_add_ld_attr_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8257{
8258    static const char *register_format_table[] = {
8259        ".f16", ".f32", ".s32", ".u32", ".s16", ".u16", ".f64", ".i64"
8260    };
8261    const char *register_format = register_format_table[(_BITS(bits, 13, 3) << 0)];
8262    static const char *vecsize_table[] = {
8263        "", ".v2", ".v3", ".v4"
8264    };
8265
8266    const char *vecsize = vecsize_table[_BITS(bits, 11, 2)];
8267
8268    fputs("+LD_ATTR", fp);
8269    fputs(register_format, fp);
8270    fputs(vecsize, fp);
8271    fputs(" ", fp);
8272    bi_disasm_dest_add(fp, next_regs, last);
8273    fputs(", ", fp);
8274    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8275    fputs(", ", fp);
8276    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8277    fputs(", ", fp);
8278    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
8279    fprintf(fp, ", @r%u", staging_register);
8280}
8281
8282static void
8283bi_disasm_add_ld_attr_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8284{
8285    static const char *register_format_table[] = {
8286        ".auto"
8287    };
8288    const char *register_format = register_format_table[0];
8289    static const char *vecsize_table[] = {
8290        "", ".v2", ".v3", ".v4"
8291    };
8292
8293    const char *vecsize = vecsize_table[_BITS(bits, 11, 2)];
8294
8295    fputs("+LD_ATTR", fp);
8296    fputs(register_format, fp);
8297    fputs(vecsize, fp);
8298    fputs(" ", fp);
8299    bi_disasm_dest_add(fp, next_regs, last);
8300    fputs(", ", fp);
8301    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8302    fputs(", ", fp);
8303    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8304    fputs(", ", fp);
8305    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
8306    fprintf(fp, ", @r%u", staging_register);
8307}
8308
8309static void
8310bi_disasm_add_ld_attr_imm_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8311{
8312    static const char *register_format_table[] = {
8313        ".f16", ".f32", ".s32", ".u32", ".s16", ".u16", ".f64", ".i64"
8314    };
8315    const char *register_format = register_format_table[(_BITS(bits, 13, 3) << 0)];
8316    static const char *vecsize_table[] = {
8317        "", ".v2", ".v3", ".v4"
8318    };
8319
8320    const char *vecsize = vecsize_table[_BITS(bits, 11, 2)];
8321
8322    fputs("+LD_ATTR_IMM", fp);
8323    fputs(register_format, fp);
8324    fputs(vecsize, fp);
8325    fputs(" ", fp);
8326    bi_disasm_dest_add(fp, next_regs, last);
8327    fputs(", ", fp);
8328    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8329    fputs(", ", fp);
8330    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8331    fprintf(fp, ", attribute_index:%u", _BITS(bits, 6, 4));
8332    fprintf(fp, ", @r%u", staging_register);
8333}
8334
8335static void
8336bi_disasm_add_ld_attr_imm_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8337{
8338    static const char *register_format_table[] = {
8339        ".auto"
8340    };
8341    const char *register_format = register_format_table[0];
8342    static const char *vecsize_table[] = {
8343        "", ".v2", ".v3", ".v4"
8344    };
8345
8346    const char *vecsize = vecsize_table[_BITS(bits, 11, 2)];
8347
8348    fputs("+LD_ATTR_IMM", fp);
8349    fputs(register_format, fp);
8350    fputs(vecsize, fp);
8351    fputs(" ", fp);
8352    bi_disasm_dest_add(fp, next_regs, last);
8353    fputs(", ", fp);
8354    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8355    fputs(", ", fp);
8356    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8357    fprintf(fp, ", attribute_index:%u", _BITS(bits, 6, 4));
8358    fprintf(fp, ", @r%u", staging_register);
8359}
8360
8361static void
8362bi_disasm_add_ld_attr_tex_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8363{
8364    static const char *register_format_table[] = {
8365        ".f16", ".f32", ".s32", ".u32", ".s16", ".u16", ".f64", ".i64"
8366    };
8367    const char *register_format = register_format_table[(_BITS(bits, 13, 3) << 0)];
8368    static const char *vecsize_table[] = {
8369        "", ".v2", ".v3", ".v4"
8370    };
8371
8372    const char *vecsize = vecsize_table[_BITS(bits, 11, 2)];
8373
8374    fputs("+LD_ATTR_TEX", fp);
8375    fputs(register_format, fp);
8376    fputs(vecsize, fp);
8377    fputs(" ", fp);
8378    bi_disasm_dest_add(fp, next_regs, last);
8379    fputs(", ", fp);
8380    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8381    fputs(", ", fp);
8382    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8383    fputs(", ", fp);
8384    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
8385    fprintf(fp, ", @r%u", staging_register);
8386}
8387
8388static void
8389bi_disasm_add_ld_attr_tex_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8390{
8391    static const char *register_format_table[] = {
8392        ".auto"
8393    };
8394    const char *register_format = register_format_table[0];
8395    static const char *vecsize_table[] = {
8396        "", ".v2", ".v3", ".v4"
8397    };
8398
8399    const char *vecsize = vecsize_table[_BITS(bits, 11, 2)];
8400
8401    fputs("+LD_ATTR_TEX", fp);
8402    fputs(register_format, fp);
8403    fputs(vecsize, fp);
8404    fputs(" ", fp);
8405    bi_disasm_dest_add(fp, next_regs, last);
8406    fputs(", ", fp);
8407    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8408    fputs(", ", fp);
8409    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8410    fputs(", ", fp);
8411    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
8412    fprintf(fp, ", @r%u", staging_register);
8413}
8414
8415static void
8416bi_disasm_add_ld_cvt(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8417{
8418    static const char *vecsize_table[] = {
8419        "", ".v2", ".v3", ".v4"
8420    };
8421
8422    const char *vecsize = vecsize_table[_BITS(bits, 9, 2)];
8423
8424    fputs("+LD_CVT", fp);
8425    fputs(vecsize, fp);
8426    fputs(" ", fp);
8427    bi_disasm_dest_add(fp, next_regs, last);
8428    fputs(", ", fp);
8429    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8430    fputs(", ", fp);
8431    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8432    fputs(", ", fp);
8433    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
8434    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
8435    fprintf(fp, ", @r%u", staging_register);
8436}
8437
8438static void
8439bi_disasm_add_ld_gclk_u64(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8440{
8441    static const char *source_table[] = {
8442        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".system_timestamp", ".cycle_counter"
8443    };
8444
8445    const char *source = source_table[_BITS(bits, 0, 3)];
8446
8447    fputs("+LD_GCLK.u64", fp);
8448    fputs(source, fp);
8449    fputs(" ", fp);
8450    bi_disasm_dest_add(fp, next_regs, last);
8451    fprintf(fp, ", @r%u", staging_register);
8452}
8453
8454static void
8455bi_disasm_add_ld_tile(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8456{
8457    static const char *vecsize_table[] = {
8458        "", ".v2", ".v3", ".v4"
8459    };
8460
8461    const char *vecsize = vecsize_table[_BITS(bits, 9, 2)];
8462
8463    fputs("+LD_TILE", fp);
8464    fputs(vecsize, fp);
8465    fputs(" ", fp);
8466    bi_disasm_dest_add(fp, next_regs, last);
8467    fputs(", ", fp);
8468    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8469    fputs(", ", fp);
8470    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8471    fputs(", ", fp);
8472    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
8473    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
8474    fprintf(fp, ", @r%u", staging_register);
8475}
8476
8477static void
8478bi_disasm_add_ld_var_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8479{
8480    static const char *update_table[] = {
8481        ".store", ".store", ".store", ".store", ".store", ".store", ".store", ".store", ".retrieve", ".retrieve", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".conditional", ".conditional", ".conditional", ".conditional", ".clobber", ".clobber", ".clobber", ".clobber", ".clobber", ".clobber", ".clobber", ".clobber", ".reserved", ".reserved", ".reserved", ".reserved"
8482    };
8483    const char *update = update_table[(_BITS(bits, 19, 1) << 0) | (_BITS(bits, 10, 4) << 1)];
8484    static const char *sample_table[] = {
8485        ".center", ".center", ".centroid", ".centroid", ".sample", ".sample", ".explicit", ".explicit", "", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".center", ".center", ".centroid", ".centroid", ".center", ".center", ".centroid", ".centroid", ".sample", ".sample", ".explicit", ".explicit", ".reserved", ".reserved", ".reserved", ".reserved"
8486    };
8487    const char *sample = sample_table[(_BITS(bits, 19, 1) << 0) | (_BITS(bits, 10, 4) << 1)];
8488    static const char *register_format_table[] = {
8489        ".f32", ".f16", ".f32", ".f16", ".f32", ".f16", ".f32", ".f16", ".f32", ".f16", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".f32", ".f16", ".f32", ".f16", ".f32", ".f16", ".f32", ".f16", ".f32", ".f16", ".f32", ".f16", ".reserved", ".reserved", ".reserved", ".reserved"
8490    };
8491    const char *register_format = register_format_table[(_BITS(bits, 19, 1) << 0) | (_BITS(bits, 10, 4) << 1)];
8492    static const char *vecsize_table[] = {
8493        "", ".v2", ".v3", ".v4"
8494    };
8495
8496    const char *vecsize = vecsize_table[_BITS(bits, 8, 2)];
8497
8498    fputs("+LD_VAR", fp);
8499    fputs(vecsize, fp);
8500    fputs(update, fp);
8501    fputs(register_format, fp);
8502    fputs(sample, fp);
8503    fputs(" ", fp);
8504    bi_disasm_dest_add(fp, next_regs, last);
8505    fputs(", ", fp);
8506    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8507    fputs(", ", fp);
8508    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8509    fprintf(fp, ", @r%u", staging_register);
8510}
8511
8512static void
8513bi_disasm_add_ld_var_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8514{
8515    static const char *update_table[] = {
8516        ".store", ".store", ".store", ".store", ".retrieve", ".reserved", ".reserved", ".reserved", ".conditional", ".conditional", ".clobber", ".clobber", ".clobber", ".clobber", ".reserved", ".reserved"
8517    };
8518    const char *update = update_table[(_BITS(bits, 10, 4) << 0)];
8519    static const char *sample_table[] = {
8520        ".center", ".centroid", ".sample", ".explicit", "", ".reserved", ".reserved", ".reserved", ".center", ".centroid", ".center", ".centroid", ".sample", ".explicit", ".reserved", ".reserved"
8521    };
8522    const char *sample = sample_table[(_BITS(bits, 10, 4) << 0)];
8523    static const char *register_format_table[] = {
8524        ".auto", ".auto", ".auto", ".auto", ".auto", ".reserved", ".reserved", ".reserved", ".auto", ".auto", ".auto", ".auto", ".auto", ".auto", ".reserved", ".reserved"
8525    };
8526    const char *register_format = register_format_table[(_BITS(bits, 10, 4) << 0)];
8527    static const char *vecsize_table[] = {
8528        "", ".v2", ".v3", ".v4"
8529    };
8530
8531    const char *vecsize = vecsize_table[_BITS(bits, 8, 2)];
8532
8533    fputs("+LD_VAR", fp);
8534    fputs(vecsize, fp);
8535    fputs(update, fp);
8536    fputs(register_format, fp);
8537    fputs(sample, fp);
8538    fputs(" ", fp);
8539    bi_disasm_dest_add(fp, next_regs, last);
8540    fputs(", ", fp);
8541    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8542    fputs(", ", fp);
8543    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8544    fprintf(fp, ", @r%u", staging_register);
8545}
8546
8547static void
8548bi_disasm_add_ld_var_flat_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8549{
8550    static const char *register_format_table[] = {
8551        ".f32", ".u32", ".f16", ".s32"
8552    };
8553    const char *register_format = register_format_table[(_BITS(bits, 10, 1) << 0) | (_BITS(bits, 19, 1) << 1)];
8554    static const char *vecsize_table[] = {
8555        "", ".v2", ".v3", ".v4"
8556    };
8557
8558    const char *vecsize = vecsize_table[_BITS(bits, 8, 2)];
8559
8560    static const char *function_table[] = {
8561        ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".and", ".or"
8562    };
8563
8564    const char *function = function_table[_BITS(bits, 0, 3)];
8565
8566    fputs("+LD_VAR_FLAT", fp);
8567    fputs(vecsize, fp);
8568    fputs(register_format, fp);
8569    fputs(function, fp);
8570    fputs(" ", fp);
8571    bi_disasm_dest_add(fp, next_regs, last);
8572    fputs(", ", fp);
8573    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8574    fprintf(fp, ", @r%u", staging_register);
8575}
8576
8577static void
8578bi_disasm_add_ld_var_flat_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8579{
8580    static const char *register_format_table[] = {
8581        ".auto"
8582    };
8583    const char *register_format = register_format_table[0];
8584    static const char *vecsize_table[] = {
8585        "", ".v2", ".v3", ".v4"
8586    };
8587
8588    const char *vecsize = vecsize_table[_BITS(bits, 8, 2)];
8589
8590    static const char *function_table[] = {
8591        ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".and", ".or"
8592    };
8593
8594    const char *function = function_table[_BITS(bits, 0, 3)];
8595
8596    fputs("+LD_VAR_FLAT", fp);
8597    fputs(vecsize, fp);
8598    fputs(register_format, fp);
8599    fputs(function, fp);
8600    fputs(" ", fp);
8601    bi_disasm_dest_add(fp, next_regs, last);
8602    fputs(", ", fp);
8603    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8604    fprintf(fp, ", @r%u", staging_register);
8605}
8606
8607static void
8608bi_disasm_add_ld_var_flat_imm_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8609{
8610    static const char *register_format_table[] = {
8611        ".f32", ".u32", ".f16", ".s32"
8612    };
8613    const char *register_format = register_format_table[(_BITS(bits, 10, 1) << 0) | (_BITS(bits, 19, 1) << 1)];
8614    static const char *vecsize_table[] = {
8615        "", ".v2", ".v3", ".v4"
8616    };
8617
8618    const char *vecsize = vecsize_table[_BITS(bits, 8, 2)];
8619
8620    static const char *function_table[] = {
8621        ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".and", ".or"
8622    };
8623
8624    const char *function = function_table[_BITS(bits, 0, 3)];
8625
8626    fputs("+LD_VAR_FLAT_IMM", fp);
8627    fputs(vecsize, fp);
8628    fputs(register_format, fp);
8629    fputs(function, fp);
8630    fputs(" ", fp);
8631    bi_disasm_dest_add(fp, next_regs, last);
8632    fprintf(fp, ", index:%u", _BITS(bits, 3, 5));
8633    fprintf(fp, ", @r%u", staging_register);
8634}
8635
8636static void
8637bi_disasm_add_ld_var_flat_imm_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8638{
8639    static const char *register_format_table[] = {
8640        ".auto"
8641    };
8642    const char *register_format = register_format_table[0];
8643    static const char *vecsize_table[] = {
8644        "", ".v2", ".v3", ".v4"
8645    };
8646
8647    const char *vecsize = vecsize_table[_BITS(bits, 8, 2)];
8648
8649    static const char *function_table[] = {
8650        ".reserved", ".reserved", ".reserved", "", ".reserved", ".reserved", ".and", ".or"
8651    };
8652
8653    const char *function = function_table[_BITS(bits, 0, 3)];
8654
8655    fputs("+LD_VAR_FLAT_IMM", fp);
8656    fputs(vecsize, fp);
8657    fputs(register_format, fp);
8658    fputs(function, fp);
8659    fputs(" ", fp);
8660    bi_disasm_dest_add(fp, next_regs, last);
8661    fprintf(fp, ", index:%u", _BITS(bits, 3, 5));
8662    fprintf(fp, ", @r%u", staging_register);
8663}
8664
8665static void
8666bi_disasm_add_ld_var_imm_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8667{
8668    static const char *update_table[] = {
8669        ".store", ".store", ".store", ".store", ".store", ".store", ".store", ".store", ".retrieve", ".retrieve", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".conditional", ".conditional", ".conditional", ".conditional", ".clobber", ".clobber", ".clobber", ".clobber", ".clobber", ".clobber", ".clobber", ".clobber", ".reserved", ".reserved", ".reserved", ".reserved"
8670    };
8671    const char *update = update_table[(_BITS(bits, 19, 1) << 0) | (_BITS(bits, 10, 4) << 1)];
8672    static const char *sample_table[] = {
8673        ".center", ".center", ".centroid", ".centroid", ".sample", ".sample", ".explicit", ".explicit", "", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".center", ".center", ".centroid", ".centroid", ".center", ".center", ".centroid", ".centroid", ".sample", ".sample", ".explicit", ".explicit", ".reserved", ".reserved", ".reserved", ".reserved"
8674    };
8675    const char *sample = sample_table[(_BITS(bits, 19, 1) << 0) | (_BITS(bits, 10, 4) << 1)];
8676    static const char *register_format_table[] = {
8677        ".f32", ".f16", ".f32", ".f16", ".f32", ".f16", ".f32", ".f16", ".f32", ".f16", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".f32", ".f16", ".f32", ".f16", ".f32", ".f16", ".f32", ".f16", ".f32", ".f16", ".f32", ".f16", ".reserved", ".reserved", ".reserved", ".reserved"
8678    };
8679    const char *register_format = register_format_table[(_BITS(bits, 19, 1) << 0) | (_BITS(bits, 10, 4) << 1)];
8680    static const char *vecsize_table[] = {
8681        "", ".v2", ".v3", ".v4"
8682    };
8683
8684    const char *vecsize = vecsize_table[_BITS(bits, 8, 2)];
8685
8686    fputs("+LD_VAR_IMM", fp);
8687    fputs(vecsize, fp);
8688    fputs(update, fp);
8689    fputs(register_format, fp);
8690    fputs(sample, fp);
8691    fputs(" ", fp);
8692    bi_disasm_dest_add(fp, next_regs, last);
8693    fputs(", ", fp);
8694    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8695    fprintf(fp, ", index:%u", _BITS(bits, 3, 5));
8696    fprintf(fp, ", @r%u", staging_register);
8697}
8698
8699static void
8700bi_disasm_add_ld_var_imm_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8701{
8702    static const char *update_table[] = {
8703        ".store", ".store", ".store", ".store", ".retrieve", ".reserved", ".reserved", ".reserved", ".conditional", ".conditional", ".clobber", ".clobber", ".clobber", ".clobber", ".reserved", ".reserved"
8704    };
8705    const char *update = update_table[(_BITS(bits, 10, 4) << 0)];
8706    static const char *sample_table[] = {
8707        ".center", ".centroid", ".sample", ".explicit", "", ".reserved", ".reserved", ".reserved", ".center", ".centroid", ".center", ".centroid", ".sample", ".explicit", ".reserved", ".reserved"
8708    };
8709    const char *sample = sample_table[(_BITS(bits, 10, 4) << 0)];
8710    static const char *register_format_table[] = {
8711        ".auto", ".auto", ".auto", ".auto", ".auto", ".reserved", ".reserved", ".reserved", ".auto", ".auto", ".auto", ".auto", ".auto", ".auto", ".reserved", ".reserved"
8712    };
8713    const char *register_format = register_format_table[(_BITS(bits, 10, 4) << 0)];
8714    static const char *vecsize_table[] = {
8715        "", ".v2", ".v3", ".v4"
8716    };
8717
8718    const char *vecsize = vecsize_table[_BITS(bits, 8, 2)];
8719
8720    fputs("+LD_VAR_IMM", fp);
8721    fputs(vecsize, fp);
8722    fputs(update, fp);
8723    fputs(register_format, fp);
8724    fputs(sample, fp);
8725    fputs(" ", fp);
8726    bi_disasm_dest_add(fp, next_regs, last);
8727    fputs(", ", fp);
8728    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8729    fprintf(fp, ", index:%u", _BITS(bits, 3, 5));
8730    fprintf(fp, ", @r%u", staging_register);
8731}
8732
8733static void
8734bi_disasm_add_ld_var_special_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8735{
8736    static const char *update_table[] = {
8737        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".clobber", ".reserved", ".clobber", ".clobber", ".clobber", ".reserved", ".clobber", ".clobber", ".clobber", ".reserved", ".clobber", ".clobber", ".clobber", ".reserved", ".clobber", ".clobber", ".clobber", ".reserved", ".clobber", ".clobber", ".clobber", ".reserved", ".clobber", ".clobber", ".clobber", ".reserved", ".clobber", ".reserved", ".clobber", ".reserved", ".clobber", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
8738    };
8739    const char *update = update_table[(_BITS(bits, 3, 2) << 0) | (_BITS(bits, 19, 1) << 2) | (_BITS(bits, 10, 4) << 3)];
8740    static const char *register_format_table[] = {
8741        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".f32", ".reserved", ".f32", ".f32", ".f16", ".reserved", ".f16", ".f16", ".f32", ".reserved", ".f32", ".f32", ".f16", ".reserved", ".f16", ".f16", ".f32", ".reserved", ".f32", ".f32", ".f16", ".reserved", ".f16", ".f16", ".f32", ".reserved", ".f32", ".reserved", ".f16", ".reserved", ".f16", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
8742    };
8743    const char *register_format = register_format_table[(_BITS(bits, 3, 2) << 0) | (_BITS(bits, 19, 1) << 2) | (_BITS(bits, 10, 4) << 3)];
8744    static const char *sample_table[] = {
8745        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".center", ".reserved", ".center", ".center", ".center", ".reserved", ".center", ".center", ".centroid", ".reserved", ".centroid", ".centroid", ".centroid", ".reserved", ".centroid", ".centroid", ".sample", ".reserved", ".sample", ".sample", ".sample", ".reserved", ".sample", ".sample", ".explicit", ".reserved", ".explicit", ".reserved", ".explicit", ".reserved", ".explicit", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
8746    };
8747    const char *sample = sample_table[(_BITS(bits, 3, 2) << 0) | (_BITS(bits, 19, 1) << 2) | (_BITS(bits, 10, 4) << 3)];
8748    static const char *varying_name_table[] = {
8749        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".point", ".reserved", ".frag_w", ".frag_z", ".point", ".reserved", ".frag_w", ".frag_z", ".point", ".reserved", ".frag_w", ".frag_z", ".point", ".reserved", ".frag_w", ".frag_z", ".point", ".reserved", ".frag_w", ".frag_z", ".point", ".reserved", ".frag_w", ".frag_z", ".point", ".reserved", ".frag_w", ".reserved", ".point", ".reserved", ".frag_w", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
8750    };
8751    const char *varying_name = varying_name_table[(_BITS(bits, 3, 2) << 0) | (_BITS(bits, 19, 1) << 2) | (_BITS(bits, 10, 4) << 3)];
8752    static const char *vecsize_table[] = {
8753        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".v2", ".reserved", "", "", ".v2", ".reserved", "", "", ".v2", ".reserved", "", "", ".v2", ".reserved", "", "", ".v2", ".reserved", "", "", ".v2", ".reserved", "", "", ".v2", ".reserved", "", ".reserved", ".v2", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
8754    };
8755    const char *vecsize = vecsize_table[(_BITS(bits, 3, 2) << 0) | (_BITS(bits, 19, 1) << 2) | (_BITS(bits, 10, 4) << 3)];
8756    fputs("+LD_VAR_SPECIAL", fp);
8757    fputs(varying_name, fp);
8758    fputs(vecsize, fp);
8759    fputs(update, fp);
8760    fputs(register_format, fp);
8761    fputs(sample, fp);
8762    fputs(" ", fp);
8763    bi_disasm_dest_add(fp, next_regs, last);
8764    fputs(", ", fp);
8765    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8766    fprintf(fp, ", @r%u", staging_register);
8767}
8768
8769static void
8770bi_disasm_add_ld_var_special_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8771{
8772    static const char *update_table[] = {
8773        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".clobber", ".reserved", ".clobber", ".reserved", ".clobber", ".reserved", ".clobber", ".reserved", ".clobber", ".reserved", ".clobber", ".reserved", ".clobber", ".reserved", ".clobber", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
8774    };
8775    const char *update = update_table[(_BITS(bits, 3, 2) << 0) | (_BITS(bits, 10, 4) << 2)];
8776    static const char *register_format_table[] = {
8777        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".auto", ".reserved", ".auto", ".reserved", ".auto", ".reserved", ".auto", ".reserved", ".auto", ".reserved", ".auto", ".reserved", ".auto", ".reserved", ".auto", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
8778    };
8779    const char *register_format = register_format_table[(_BITS(bits, 3, 2) << 0) | (_BITS(bits, 10, 4) << 2)];
8780    static const char *sample_table[] = {
8781        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".center", ".reserved", ".center", ".reserved", ".centroid", ".reserved", ".centroid", ".reserved", ".sample", ".reserved", ".sample", ".reserved", ".explicit", ".reserved", ".explicit", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
8782    };
8783    const char *sample = sample_table[(_BITS(bits, 3, 2) << 0) | (_BITS(bits, 10, 4) << 2)];
8784    static const char *varying_name_table[] = {
8785        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".point", ".reserved", ".frag_w", ".reserved", ".point", ".reserved", ".frag_w", ".reserved", ".point", ".reserved", ".frag_w", ".reserved", ".point", ".reserved", ".frag_w", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
8786    };
8787    const char *varying_name = varying_name_table[(_BITS(bits, 3, 2) << 0) | (_BITS(bits, 10, 4) << 2)];
8788    static const char *vecsize_table[] = {
8789        ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".v2", ".reserved", "", ".reserved", ".v2", ".reserved", "", ".reserved", ".v2", ".reserved", "", ".reserved", ".v2", ".reserved", "", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved", ".reserved"
8790    };
8791    const char *vecsize = vecsize_table[(_BITS(bits, 3, 2) << 0) | (_BITS(bits, 10, 4) << 2)];
8792    fputs("+LD_VAR_SPECIAL", fp);
8793    fputs(varying_name, fp);
8794    fputs(vecsize, fp);
8795    fputs(update, fp);
8796    fputs(register_format, fp);
8797    fputs(sample, fp);
8798    fputs(" ", fp);
8799    bi_disasm_dest_add(fp, next_regs, last);
8800    fputs(", ", fp);
8801    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8802    fprintf(fp, ", @r%u", staging_register);
8803}
8804
8805static void
8806bi_disasm_add_lea_attr_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8807{
8808    static const char *register_format_table[] = {
8809        ".f16", ".f32", ".s32", ".u32", ".s16", ".u16", ".f64", ".i64"
8810    };
8811    const char *register_format = register_format_table[(_BITS(bits, 11, 3) << 0)];
8812    fputs("+LEA_ATTR", fp);
8813    fputs(register_format, fp);
8814    fputs(" ", fp);
8815    bi_disasm_dest_add(fp, next_regs, last);
8816    fputs(", ", fp);
8817    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8818    fputs(", ", fp);
8819    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8820    fputs(", ", fp);
8821    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
8822    fprintf(fp, ", @r%u", staging_register);
8823}
8824
8825static void
8826bi_disasm_add_lea_attr_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8827{
8828    static const char *register_format_table[] = {
8829        ".auto"
8830    };
8831    const char *register_format = register_format_table[0];
8832    fputs("+LEA_ATTR", fp);
8833    fputs(register_format, fp);
8834    fputs(" ", fp);
8835    bi_disasm_dest_add(fp, next_regs, last);
8836    fputs(", ", fp);
8837    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8838    fputs(", ", fp);
8839    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8840    fputs(", ", fp);
8841    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
8842    fprintf(fp, ", @r%u", staging_register);
8843}
8844
8845static void
8846bi_disasm_add_lea_attr_imm_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8847{
8848    static const char *register_format_table[] = {
8849        ".f16", ".f32", ".s32", ".u32", ".s16", ".u16", ".f64", ".i64"
8850    };
8851    const char *register_format = register_format_table[(_BITS(bits, 11, 3) << 0)];
8852    fputs("+LEA_ATTR_IMM", fp);
8853    fputs(register_format, fp);
8854    fputs(" ", fp);
8855    bi_disasm_dest_add(fp, next_regs, last);
8856    fputs(", ", fp);
8857    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8858    fputs(", ", fp);
8859    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8860    fprintf(fp, ", attribute_index:%u", _BITS(bits, 6, 4));
8861    fprintf(fp, ", @r%u", staging_register);
8862}
8863
8864static void
8865bi_disasm_add_lea_attr_imm_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8866{
8867    static const char *register_format_table[] = {
8868        ".auto"
8869    };
8870    const char *register_format = register_format_table[0];
8871    fputs("+LEA_ATTR_IMM", fp);
8872    fputs(register_format, fp);
8873    fputs(" ", fp);
8874    bi_disasm_dest_add(fp, next_regs, last);
8875    fputs(", ", fp);
8876    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8877    fputs(", ", fp);
8878    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8879    fprintf(fp, ", attribute_index:%u", _BITS(bits, 6, 4));
8880    fprintf(fp, ", @r%u", staging_register);
8881}
8882
8883static void
8884bi_disasm_add_lea_attr_tex_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8885{
8886    static const char *register_format_table[] = {
8887        ".f16", ".f32", ".s32", ".u32", ".s16", ".u16", ".f64", ".i64"
8888    };
8889    const char *register_format = register_format_table[(_BITS(bits, 11, 3) << 0)];
8890    fputs("+LEA_ATTR_TEX", fp);
8891    fputs(register_format, fp);
8892    fputs(" ", fp);
8893    bi_disasm_dest_add(fp, next_regs, last);
8894    fputs(", ", fp);
8895    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8896    fputs(", ", fp);
8897    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8898    fputs(", ", fp);
8899    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
8900    fprintf(fp, ", @r%u", staging_register);
8901}
8902
8903static void
8904bi_disasm_add_lea_attr_tex_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8905{
8906    static const char *register_format_table[] = {
8907        ".auto"
8908    };
8909    const char *register_format = register_format_table[0];
8910    fputs("+LEA_ATTR_TEX", fp);
8911    fputs(register_format, fp);
8912    fputs(" ", fp);
8913    bi_disasm_dest_add(fp, next_regs, last);
8914    fputs(", ", fp);
8915    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8916    fputs(", ", fp);
8917    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8918    fputs(", ", fp);
8919    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
8920    fprintf(fp, ", @r%u", staging_register);
8921}
8922
8923static void
8924bi_disasm_add_lea_tex(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8925{
8926    static const char *format_table[] = {
8927        ".u16", ".u32"
8928    };
8929
8930    const char *format = format_table[_BITS(bits, 11, 1)];
8931
8932    fputs("+LEA_TEX", fp);
8933    fputs(format, fp);
8934    fputs(" ", fp);
8935    bi_disasm_dest_add(fp, next_regs, last);
8936    fputs(", ", fp);
8937    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8938    fputs(", ", fp);
8939    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8940    fputs(", ", fp);
8941    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
8942    fprintf(fp, ", @r%u", staging_register);
8943}
8944
8945static void
8946bi_disasm_add_lea_tex_imm(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8947{
8948    static const char *format_table[] = {
8949        ".u16", ".u32"
8950    };
8951
8952    const char *format = format_table[_BITS(bits, 11, 1)];
8953
8954    fputs("+LEA_TEX_IMM", fp);
8955    fputs(format, fp);
8956    fputs(" ", fp);
8957    bi_disasm_dest_add(fp, next_regs, last);
8958    fputs(", ", fp);
8959    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8960    fputs(", ", fp);
8961    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8962    fprintf(fp, ", texture_index:%u", _BITS(bits, 6, 5));
8963    fprintf(fp, ", @r%u", staging_register);
8964}
8965
8966static void
8967bi_disasm_add_load_i128(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8968{
8969    static const char *seg_table[] = {
8970        ".reserved", "", ".wls", ".stream", ".ubo", ".reserved", ".reserved", ".tl"
8971    };
8972
8973    const char *seg = seg_table[_BITS(bits, 6, 3)];
8974
8975    fputs("+LOAD.i128", fp);
8976    fputs(seg, fp);
8977    fputs(" ", fp);
8978    bi_disasm_dest_add(fp, next_regs, last);
8979    fputs(", ", fp);
8980    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
8981    fputs(", ", fp);
8982    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
8983    fprintf(fp, ", @r%u", staging_register);
8984}
8985
8986static void
8987bi_disasm_add_load_i16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
8988{
8989    static const char *lane_dest_table[] = {
8990        "", ".h1"
8991    };
8992    const char *lane_dest = lane_dest_table[(_BITS(bits, 9, 1) << 0)];
8993    static const char *extend_table[] = {
8994        "", ""
8995    };
8996    const char *extend = extend_table[(_BITS(bits, 9, 1) << 0)];
8997    static const char *seg_table[] = {
8998        ".reserved", "", ".wls", ".stream", ".ubo", ".reserved", ".reserved", ".tl"
8999    };
9000
9001    const char *seg = seg_table[_BITS(bits, 6, 3)];
9002
9003    fputs("+LOAD.i16", fp);
9004    fputs(seg, fp);
9005    fputs(lane_dest, fp);
9006    fputs(extend, fp);
9007    fputs(" ", fp);
9008    bi_disasm_dest_add(fp, next_regs, last);
9009    fputs(", ", fp);
9010    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9011    fputs(", ", fp);
9012    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9013    fprintf(fp, ", @r%u", staging_register);
9014}
9015
9016static void
9017bi_disasm_add_load_i16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9018{
9019    static const char *lane_dest_table[] = {
9020        ".w0", ".w0"
9021    };
9022    const char *lane_dest = lane_dest_table[(_BITS(bits, 9, 1) << 0)];
9023    static const char *extend_table[] = {
9024        ".sext", ".zext"
9025    };
9026    const char *extend = extend_table[(_BITS(bits, 9, 1) << 0)];
9027    static const char *seg_table[] = {
9028        ".reserved", "", ".wls", ".stream", ".ubo", ".reserved", ".reserved", ".tl"
9029    };
9030
9031    const char *seg = seg_table[_BITS(bits, 6, 3)];
9032
9033    fputs("+LOAD.i16", fp);
9034    fputs(seg, fp);
9035    fputs(lane_dest, fp);
9036    fputs(extend, fp);
9037    fputs(" ", fp);
9038    bi_disasm_dest_add(fp, next_regs, last);
9039    fputs(", ", fp);
9040    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9041    fputs(", ", fp);
9042    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9043    fprintf(fp, ", @r%u", staging_register);
9044}
9045
9046static void
9047bi_disasm_add_load_i16_2(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9048{
9049    static const char *lane_dest_table[] = {
9050        ".d0", ".d0"
9051    };
9052    const char *lane_dest = lane_dest_table[(_BITS(bits, 9, 1) << 0)];
9053    static const char *extend_table[] = {
9054        ".sext", ".zext"
9055    };
9056    const char *extend = extend_table[(_BITS(bits, 9, 1) << 0)];
9057    static const char *seg_table[] = {
9058        ".reserved", "", ".wls", ".stream", ".ubo", ".reserved", ".reserved", ".tl"
9059    };
9060
9061    const char *seg = seg_table[_BITS(bits, 6, 3)];
9062
9063    fputs("+LOAD.i16", fp);
9064    fputs(seg, fp);
9065    fputs(lane_dest, fp);
9066    fputs(extend, fp);
9067    fputs(" ", fp);
9068    bi_disasm_dest_add(fp, next_regs, last);
9069    fputs(", ", fp);
9070    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9071    fputs(", ", fp);
9072    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9073    fprintf(fp, ", @r%u", staging_register);
9074}
9075
9076static void
9077bi_disasm_add_load_i24(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9078{
9079    static const char *seg_table[] = {
9080        ".reserved", "", ".wls", ".stream", ".ubo", ".reserved", ".reserved", ".tl"
9081    };
9082
9083    const char *seg = seg_table[_BITS(bits, 6, 3)];
9084
9085    fputs("+LOAD.i24", fp);
9086    fputs(seg, fp);
9087    fputs(" ", fp);
9088    bi_disasm_dest_add(fp, next_regs, last);
9089    fputs(", ", fp);
9090    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9091    fputs(", ", fp);
9092    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9093    fprintf(fp, ", @r%u", staging_register);
9094}
9095
9096static void
9097bi_disasm_add_load_i32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9098{
9099    static const char *lane_dest_table[] = {
9100        ""
9101    };
9102    const char *lane_dest = lane_dest_table[0];
9103    static const char *extend_table[] = {
9104        ""
9105    };
9106    const char *extend = extend_table[0];
9107    static const char *seg_table[] = {
9108        ".reserved", "", ".wls", ".stream", ".ubo", ".reserved", ".reserved", ".tl"
9109    };
9110
9111    const char *seg = seg_table[_BITS(bits, 6, 3)];
9112
9113    fputs("+LOAD.i32", fp);
9114    fputs(seg, fp);
9115    fputs(lane_dest, fp);
9116    fputs(extend, fp);
9117    fputs(" ", fp);
9118    bi_disasm_dest_add(fp, next_regs, last);
9119    fputs(", ", fp);
9120    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9121    fputs(", ", fp);
9122    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9123    fprintf(fp, ", @r%u", staging_register);
9124}
9125
9126static void
9127bi_disasm_add_load_i32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9128{
9129    static const char *lane_dest_table[] = {
9130        ".d0", ".d0"
9131    };
9132    const char *lane_dest = lane_dest_table[(_BITS(bits, 9, 1) << 0)];
9133    static const char *extend_table[] = {
9134        ".sext", ".zext"
9135    };
9136    const char *extend = extend_table[(_BITS(bits, 9, 1) << 0)];
9137    static const char *seg_table[] = {
9138        ".reserved", "", ".wls", ".stream", ".ubo", ".reserved", ".reserved", ".tl"
9139    };
9140
9141    const char *seg = seg_table[_BITS(bits, 6, 3)];
9142
9143    fputs("+LOAD.i32", fp);
9144    fputs(seg, fp);
9145    fputs(lane_dest, fp);
9146    fputs(extend, fp);
9147    fputs(" ", fp);
9148    bi_disasm_dest_add(fp, next_regs, last);
9149    fputs(", ", fp);
9150    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9151    fputs(", ", fp);
9152    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9153    fprintf(fp, ", @r%u", staging_register);
9154}
9155
9156static void
9157bi_disasm_add_load_i48(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9158{
9159    static const char *seg_table[] = {
9160        ".reserved", "", ".wls", ".stream", ".ubo", ".reserved", ".reserved", ".tl"
9161    };
9162
9163    const char *seg = seg_table[_BITS(bits, 6, 3)];
9164
9165    fputs("+LOAD.i48", fp);
9166    fputs(seg, fp);
9167    fputs(" ", fp);
9168    bi_disasm_dest_add(fp, next_regs, last);
9169    fputs(", ", fp);
9170    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9171    fputs(", ", fp);
9172    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9173    fprintf(fp, ", @r%u", staging_register);
9174}
9175
9176static void
9177bi_disasm_add_load_i64(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9178{
9179    static const char *seg_table[] = {
9180        ".reserved", "", ".wls", ".stream", ".ubo", ".reserved", ".reserved", ".tl"
9181    };
9182
9183    const char *seg = seg_table[_BITS(bits, 6, 3)];
9184
9185    fputs("+LOAD.i64", fp);
9186    fputs(seg, fp);
9187    fputs(" ", fp);
9188    bi_disasm_dest_add(fp, next_regs, last);
9189    fputs(", ", fp);
9190    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9191    fputs(", ", fp);
9192    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9193    fprintf(fp, ", @r%u", staging_register);
9194}
9195
9196static void
9197bi_disasm_add_load_i8_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9198{
9199    static const char *lane_dest_table[] = {
9200        "", ".b1", ".b2", ".b3"
9201    };
9202    const char *lane_dest = lane_dest_table[(_BITS(bits, 9, 2) << 0)];
9203    static const char *extend_table[] = {
9204        "", "", "", ""
9205    };
9206    const char *extend = extend_table[(_BITS(bits, 9, 2) << 0)];
9207    static const char *seg_table[] = {
9208        ".reserved", "", ".wls", ".stream", ".ubo", ".reserved", ".reserved", ".tl"
9209    };
9210
9211    const char *seg = seg_table[_BITS(bits, 6, 3)];
9212
9213    fputs("+LOAD.i8", fp);
9214    fputs(seg, fp);
9215    fputs(lane_dest, fp);
9216    fputs(extend, fp);
9217    fputs(" ", fp);
9218    bi_disasm_dest_add(fp, next_regs, last);
9219    fputs(", ", fp);
9220    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9221    fputs(", ", fp);
9222    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9223    fprintf(fp, ", @r%u", staging_register);
9224}
9225
9226static void
9227bi_disasm_add_load_i8_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9228{
9229    static const char *lane_dest_table[] = {
9230        ".h0", ".h0", ".h1", ".h1"
9231    };
9232    const char *lane_dest = lane_dest_table[(_BITS(bits, 9, 1) << 0) | (_BITS(bits, 10, 1) << 1)];
9233    static const char *extend_table[] = {
9234        ".sext", ".zext", ".sext", ".zext"
9235    };
9236    const char *extend = extend_table[(_BITS(bits, 9, 1) << 0) | (_BITS(bits, 10, 1) << 1)];
9237    static const char *seg_table[] = {
9238        ".reserved", "", ".wls", ".stream", ".ubo", ".reserved", ".reserved", ".tl"
9239    };
9240
9241    const char *seg = seg_table[_BITS(bits, 6, 3)];
9242
9243    fputs("+LOAD.i8", fp);
9244    fputs(seg, fp);
9245    fputs(lane_dest, fp);
9246    fputs(extend, fp);
9247    fputs(" ", fp);
9248    bi_disasm_dest_add(fp, next_regs, last);
9249    fputs(", ", fp);
9250    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9251    fputs(", ", fp);
9252    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9253    fprintf(fp, ", @r%u", staging_register);
9254}
9255
9256static void
9257bi_disasm_add_load_i8_2(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9258{
9259    static const char *lane_dest_table[] = {
9260        ".w0", ".w0"
9261    };
9262    const char *lane_dest = lane_dest_table[(_BITS(bits, 9, 1) << 0)];
9263    static const char *extend_table[] = {
9264        ".sext", ".zext"
9265    };
9266    const char *extend = extend_table[(_BITS(bits, 9, 1) << 0)];
9267    static const char *seg_table[] = {
9268        ".reserved", "", ".wls", ".stream", ".ubo", ".reserved", ".reserved", ".tl"
9269    };
9270
9271    const char *seg = seg_table[_BITS(bits, 6, 3)];
9272
9273    fputs("+LOAD.i8", fp);
9274    fputs(seg, fp);
9275    fputs(lane_dest, fp);
9276    fputs(extend, fp);
9277    fputs(" ", fp);
9278    bi_disasm_dest_add(fp, next_regs, last);
9279    fputs(", ", fp);
9280    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9281    fputs(", ", fp);
9282    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9283    fprintf(fp, ", @r%u", staging_register);
9284}
9285
9286static void
9287bi_disasm_add_load_i8_3(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9288{
9289    static const char *lane_dest_table[] = {
9290        ".d0", ".d0"
9291    };
9292    const char *lane_dest = lane_dest_table[(_BITS(bits, 9, 1) << 0)];
9293    static const char *extend_table[] = {
9294        ".sext", ".zext"
9295    };
9296    const char *extend = extend_table[(_BITS(bits, 9, 1) << 0)];
9297    static const char *seg_table[] = {
9298        ".reserved", "", ".wls", ".stream", ".ubo", ".reserved", ".reserved", ".tl"
9299    };
9300
9301    const char *seg = seg_table[_BITS(bits, 6, 3)];
9302
9303    fputs("+LOAD.i8", fp);
9304    fputs(seg, fp);
9305    fputs(lane_dest, fp);
9306    fputs(extend, fp);
9307    fputs(" ", fp);
9308    bi_disasm_dest_add(fp, next_regs, last);
9309    fputs(", ", fp);
9310    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9311    fputs(", ", fp);
9312    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9313    fprintf(fp, ", @r%u", staging_register);
9314}
9315
9316static void
9317bi_disasm_add_load_i96(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9318{
9319    static const char *seg_table[] = {
9320        ".reserved", "", ".wls", ".stream", ".ubo", ".reserved", ".reserved", ".tl"
9321    };
9322
9323    const char *seg = seg_table[_BITS(bits, 6, 3)];
9324
9325    fputs("+LOAD.i96", fp);
9326    fputs(seg, fp);
9327    fputs(" ", fp);
9328    bi_disasm_dest_add(fp, next_regs, last);
9329    fputs(", ", fp);
9330    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9331    fputs(", ", fp);
9332    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9333    fprintf(fp, ", @r%u", staging_register);
9334}
9335
9336static void
9337bi_disasm_add_logb_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9338{
9339    static const char *widen0_table[] = {
9340        ".reserved", "", ".h0", ".h1"
9341    };
9342
9343    const char *widen0 = widen0_table[_BITS(bits, 3, 2)];
9344
9345    fputs("+LOGB.f32", fp);
9346    fputs(" ", fp);
9347    bi_disasm_dest_add(fp, next_regs, last);
9348    fputs(", ", fp);
9349    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9350    fputs(widen0, fp);
9351}
9352
9353static void
9354bi_disasm_add_logb_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9355{
9356    static const char *swz0_table[] = {
9357        ".h00", ".h10", "", ".h11"
9358    };
9359
9360    const char *swz0 = swz0_table[_BITS(bits, 3, 2)];
9361
9362    fputs("+LOGB.v2f16", fp);
9363    fputs(" ", fp);
9364    bi_disasm_dest_add(fp, next_regs, last);
9365    fputs(", ", fp);
9366    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9367    fputs(swz0, fp);
9368}
9369
9370static void
9371bi_disasm_add_mkvec_v2i16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9372{
9373    static const char *lane0_table[] = {
9374        "", ".h1"
9375    };
9376
9377    const char *lane0 = lane0_table[_BITS(bits, 6, 1)];
9378
9379    static const char *lane1_table[] = {
9380        "", ".h1"
9381    };
9382
9383    const char *lane1 = lane1_table[_BITS(bits, 7, 1)];
9384
9385    fputs("+MKVEC.v2i16", fp);
9386    fputs(" ", fp);
9387    bi_disasm_dest_add(fp, next_regs, last);
9388    fputs(", ", fp);
9389    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9390    fputs(lane0, fp);
9391    fputs(", ", fp);
9392    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9393    fputs(lane1, fp);
9394}
9395
9396static void
9397bi_disasm_add_mov_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9398{
9399    fputs("+MOV.i32", fp);
9400    fputs(" ", fp);
9401    bi_disasm_dest_add(fp, next_regs, last);
9402    fputs(", ", fp);
9403    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9404}
9405
9406static void
9407bi_disasm_add_mux_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9408{
9409    static const char *mux_table[] = {
9410        ".neg", "", ".fp_zero", ".bit"
9411    };
9412
9413    const char *mux = mux_table[_BITS(bits, 9, 2)];
9414
9415    fputs("+MUX.i32", fp);
9416    fputs(mux, fp);
9417    fputs(" ", fp);
9418    bi_disasm_dest_add(fp, next_regs, last);
9419    fputs(", ", fp);
9420    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9421    fputs(", ", fp);
9422    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9423    fputs(", ", fp);
9424    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
9425}
9426
9427static void
9428bi_disasm_add_mux_v2i16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9429{
9430    static const char *mux_table[] = {
9431        ".neg", "", ".fp_zero", ".bit"
9432    };
9433
9434    const char *mux = mux_table[_BITS(bits, 9, 2)];
9435
9436    static const char *swap2_table[] = {
9437        "", ".h10"
9438    };
9439
9440    const char *swap2 = swap2_table[_BITS(bits, 11, 1)];
9441
9442    static const char *swap1_table[] = {
9443        "", ".h10"
9444    };
9445
9446    const char *swap1 = swap1_table[_BITS(bits, 12, 1)];
9447
9448    static const char *swap0_table[] = {
9449        "", ".h10"
9450    };
9451
9452    const char *swap0 = swap0_table[_BITS(bits, 13, 1)];
9453
9454    fputs("+MUX.v2i16", fp);
9455    fputs(mux, fp);
9456    fputs(" ", fp);
9457    bi_disasm_dest_add(fp, next_regs, last);
9458    fputs(", ", fp);
9459    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9460    fputs(swap0, fp);
9461    fputs(", ", fp);
9462    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9463    fputs(swap1, fp);
9464    fputs(", ", fp);
9465    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
9466    fputs(swap2, fp);
9467}
9468
9469static void
9470bi_disasm_add_mux_v4i8(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9471{
9472    static const char *mux_table[] = {
9473        ".neg", ""
9474    };
9475
9476    const char *mux = mux_table[_BITS(bits, 9, 1)];
9477
9478    fputs("+MUX.v4i8", fp);
9479    fputs(mux, fp);
9480    fputs(" ", fp);
9481    bi_disasm_dest_add(fp, next_regs, last);
9482    fputs(", ", fp);
9483    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9484    fputs(", ", fp);
9485    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9486    fputs(", ", fp);
9487    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
9488}
9489
9490static void
9491bi_disasm_add_nop(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9492{
9493    fputs("+NOP", fp);
9494    fputs(" ", fp);
9495    bi_disasm_dest_add(fp, next_regs, last);
9496}
9497
9498static void
9499bi_disasm_add_quiet_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9500{
9501    fputs("+QUIET.f32", fp);
9502    fputs(" ", fp);
9503    bi_disasm_dest_add(fp, next_regs, last);
9504    fputs(", ", fp);
9505    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9506}
9507
9508static void
9509bi_disasm_add_quiet_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9510{
9511    static const char *swz0_table[] = {
9512        ".h00", ".h10", "", ".h11"
9513    };
9514
9515    const char *swz0 = swz0_table[_BITS(bits, 4, 2)];
9516
9517    fputs("+QUIET.v2f16", fp);
9518    fputs(" ", fp);
9519    bi_disasm_dest_add(fp, next_regs, last);
9520    fputs(", ", fp);
9521    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9522    fputs(swz0, fp);
9523}
9524
9525static void
9526bi_disasm_add_s16_to_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9527{
9528    static const char *lane0_table[] = {
9529        "", ".h1"
9530    };
9531
9532    const char *lane0 = lane0_table[_BITS(bits, 4, 1)];
9533
9534    fputs("+S16_TO_F32", fp);
9535    fputs(" ", fp);
9536    bi_disasm_dest_add(fp, next_regs, last);
9537    fputs(", ", fp);
9538    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9539    fputs(lane0, fp);
9540}
9541
9542static void
9543bi_disasm_add_s16_to_s32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9544{
9545    static const char *lane0_table[] = {
9546        "", ".h1"
9547    };
9548
9549    const char *lane0 = lane0_table[_BITS(bits, 4, 1)];
9550
9551    fputs("+S16_TO_S32", fp);
9552    fputs(" ", fp);
9553    bi_disasm_dest_add(fp, next_regs, last);
9554    fputs(", ", fp);
9555    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9556    fputs(lane0, fp);
9557}
9558
9559static void
9560bi_disasm_add_s32_to_f32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9561{
9562    static const char *round_table[] = {
9563        "", ".rtp", ".rtn", ".rtz"
9564    };
9565    const char *round = round_table[(_BITS(bits, 4, 2) << 0)];
9566    fputs("+S32_TO_F32", fp);
9567    fputs(round, fp);
9568    fputs(" ", fp);
9569    bi_disasm_dest_add(fp, next_regs, last);
9570    fputs(", ", fp);
9571    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9572}
9573
9574static void
9575bi_disasm_add_s32_to_f32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9576{
9577    static const char *round_table[] = {
9578        ".rtna"
9579    };
9580    const char *round = round_table[0];
9581    fputs("+S32_TO_F32", fp);
9582    fputs(round, fp);
9583    fputs(" ", fp);
9584    bi_disasm_dest_add(fp, next_regs, last);
9585    fputs(", ", fp);
9586    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9587}
9588
9589static void
9590bi_disasm_add_s8_to_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9591{
9592    static const char *lane0_table[] = {
9593        "", ".b1", ".b2", ".b3"
9594    };
9595
9596    const char *lane0 = lane0_table[_BITS(bits, 4, 2)];
9597
9598    fputs("+S8_TO_F32", fp);
9599    fputs(" ", fp);
9600    bi_disasm_dest_add(fp, next_regs, last);
9601    fputs(", ", fp);
9602    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9603    fputs(lane0, fp);
9604}
9605
9606static void
9607bi_disasm_add_s8_to_s32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9608{
9609    static const char *lane0_table[] = {
9610        "", ".b1", ".b2", ".b3"
9611    };
9612
9613    const char *lane0 = lane0_table[_BITS(bits, 4, 2)];
9614
9615    fputs("+S8_TO_S32", fp);
9616    fputs(" ", fp);
9617    bi_disasm_dest_add(fp, next_regs, last);
9618    fputs(", ", fp);
9619    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9620    fputs(lane0, fp);
9621}
9622
9623static void
9624bi_disasm_add_seg_add(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9625{
9626    static const char *seg_table[] = {
9627        ".reserved", ".reserved", ".wls", ".reserved", ".reserved", ".reserved", ".reserved", ".tl"
9628    };
9629
9630    const char *seg = seg_table[_BITS(bits, 3, 3)];
9631
9632    static const char *preserve_null_table[] = {
9633        "", ".preserve_null"
9634    };
9635
9636    const char *preserve_null = preserve_null_table[_BITS(bits, 7, 1)];
9637
9638    fputs("+SEG_ADD", fp);
9639    fputs(seg, fp);
9640    fputs(preserve_null, fp);
9641    fputs(" ", fp);
9642    bi_disasm_dest_add(fp, next_regs, last);
9643    fputs(", ", fp);
9644    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9645}
9646
9647static void
9648bi_disasm_add_seg_sub(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9649{
9650    static const char *seg_table[] = {
9651        ".reserved", ".reserved", ".wls", ".reserved", ".reserved", ".reserved", ".reserved", ".tl"
9652    };
9653
9654    const char *seg = seg_table[_BITS(bits, 3, 3)];
9655
9656    static const char *preserve_null_table[] = {
9657        "", ".preserve_null"
9658    };
9659
9660    const char *preserve_null = preserve_null_table[_BITS(bits, 7, 1)];
9661
9662    fputs("+SEG_SUB", fp);
9663    fputs(seg, fp);
9664    fputs(preserve_null, fp);
9665    fputs(" ", fp);
9666    bi_disasm_dest_add(fp, next_regs, last);
9667    fputs(", ", fp);
9668    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9669}
9670
9671static void
9672bi_disasm_add_shaddxh_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9673{
9674    fputs("+SHADDXH.i32", fp);
9675    fputs(" ", fp);
9676    bi_disasm_dest_add(fp, next_regs, last);
9677    fputs(", ", fp);
9678    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9679    fputs(", ", fp);
9680    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9681}
9682
9683static void
9684bi_disasm_add_shift_double_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9685{
9686    fputs("+SHIFT_DOUBLE.i32", fp);
9687    fputs(" ", fp);
9688    bi_disasm_dest_add(fp, next_regs, last);
9689    fputs(", ", fp);
9690    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9691    fputs(", ", fp);
9692    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9693    fputs(", ", fp);
9694    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
9695}
9696
9697static void
9698bi_disasm_add_store_i128(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9699{
9700    static const char *seg_table[] = {
9701        ".reserved", "", ".wls", ".stream", ".reserved", ".reserved", ".reserved", ".tl"
9702    };
9703
9704    const char *seg = seg_table[_BITS(bits, 6, 3)];
9705
9706    fputs("+STORE.i128", fp);
9707    fputs(seg, fp);
9708    fputs(" ", fp);
9709    bi_disasm_dest_add(fp, next_regs, last);
9710    fputs(", ", fp);
9711    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9712    fputs(", ", fp);
9713    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9714    fprintf(fp, ", @r%u", staging_register);
9715}
9716
9717static void
9718bi_disasm_add_store_i16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9719{
9720    static const char *seg_table[] = {
9721        ".reserved", "", ".wls", ".stream", ".reserved", ".reserved", ".reserved", ".tl"
9722    };
9723
9724    const char *seg = seg_table[_BITS(bits, 6, 3)];
9725
9726    fputs("+STORE.i16", fp);
9727    fputs(seg, fp);
9728    fputs(" ", fp);
9729    bi_disasm_dest_add(fp, next_regs, last);
9730    fputs(", ", fp);
9731    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9732    fputs(", ", fp);
9733    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9734    fprintf(fp, ", @r%u", staging_register);
9735}
9736
9737static void
9738bi_disasm_add_store_i24(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9739{
9740    static const char *seg_table[] = {
9741        ".reserved", "", ".wls", ".stream", ".reserved", ".reserved", ".reserved", ".tl"
9742    };
9743
9744    const char *seg = seg_table[_BITS(bits, 6, 3)];
9745
9746    fputs("+STORE.i24", fp);
9747    fputs(seg, fp);
9748    fputs(" ", fp);
9749    bi_disasm_dest_add(fp, next_regs, last);
9750    fputs(", ", fp);
9751    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9752    fputs(", ", fp);
9753    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9754    fprintf(fp, ", @r%u", staging_register);
9755}
9756
9757static void
9758bi_disasm_add_store_i32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9759{
9760    static const char *seg_table[] = {
9761        ".reserved", "", ".wls", ".stream", ".reserved", ".reserved", ".reserved", ".tl"
9762    };
9763
9764    const char *seg = seg_table[_BITS(bits, 6, 3)];
9765
9766    fputs("+STORE.i32", fp);
9767    fputs(seg, fp);
9768    fputs(" ", fp);
9769    bi_disasm_dest_add(fp, next_regs, last);
9770    fputs(", ", fp);
9771    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9772    fputs(", ", fp);
9773    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9774    fprintf(fp, ", @r%u", staging_register);
9775}
9776
9777static void
9778bi_disasm_add_store_i48(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9779{
9780    static const char *seg_table[] = {
9781        ".reserved", "", ".wls", ".stream", ".reserved", ".reserved", ".reserved", ".tl"
9782    };
9783
9784    const char *seg = seg_table[_BITS(bits, 6, 3)];
9785
9786    fputs("+STORE.i48", fp);
9787    fputs(seg, fp);
9788    fputs(" ", fp);
9789    bi_disasm_dest_add(fp, next_regs, last);
9790    fputs(", ", fp);
9791    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9792    fputs(", ", fp);
9793    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9794    fprintf(fp, ", @r%u", staging_register);
9795}
9796
9797static void
9798bi_disasm_add_store_i64(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9799{
9800    static const char *seg_table[] = {
9801        ".reserved", "", ".wls", ".stream", ".reserved", ".reserved", ".reserved", ".tl"
9802    };
9803
9804    const char *seg = seg_table[_BITS(bits, 6, 3)];
9805
9806    fputs("+STORE.i64", fp);
9807    fputs(seg, fp);
9808    fputs(" ", fp);
9809    bi_disasm_dest_add(fp, next_regs, last);
9810    fputs(", ", fp);
9811    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9812    fputs(", ", fp);
9813    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9814    fprintf(fp, ", @r%u", staging_register);
9815}
9816
9817static void
9818bi_disasm_add_store_i8(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9819{
9820    static const char *seg_table[] = {
9821        ".reserved", "", ".wls", ".stream", ".reserved", ".reserved", ".reserved", ".tl"
9822    };
9823
9824    const char *seg = seg_table[_BITS(bits, 6, 3)];
9825
9826    fputs("+STORE.i8", fp);
9827    fputs(seg, fp);
9828    fputs(" ", fp);
9829    bi_disasm_dest_add(fp, next_regs, last);
9830    fputs(", ", fp);
9831    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9832    fputs(", ", fp);
9833    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9834    fprintf(fp, ", @r%u", staging_register);
9835}
9836
9837static void
9838bi_disasm_add_store_i96(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9839{
9840    static const char *seg_table[] = {
9841        ".reserved", "", ".wls", ".stream", ".reserved", ".reserved", ".reserved", ".tl"
9842    };
9843
9844    const char *seg = seg_table[_BITS(bits, 6, 3)];
9845
9846    fputs("+STORE.i96", fp);
9847    fputs(seg, fp);
9848    fputs(" ", fp);
9849    bi_disasm_dest_add(fp, next_regs, last);
9850    fputs(", ", fp);
9851    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9852    fputs(", ", fp);
9853    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9854    fprintf(fp, ", @r%u", staging_register);
9855}
9856
9857static void
9858bi_disasm_add_st_cvt(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9859{
9860    static const char *vecsize_table[] = {
9861        "", ".v2", ".v3", ".v4"
9862    };
9863
9864    const char *vecsize = vecsize_table[_BITS(bits, 9, 2)];
9865
9866    fputs("+ST_CVT", fp);
9867    fputs(vecsize, fp);
9868    fputs(" ", fp);
9869    bi_disasm_dest_add(fp, next_regs, last);
9870    fputs(", ", fp);
9871    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9872    fputs(", ", fp);
9873    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9874    fputs(", ", fp);
9875    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
9876    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
9877    fprintf(fp, ", @r%u", staging_register);
9878}
9879
9880static void
9881bi_disasm_add_st_tile(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9882{
9883    static const char *vecsize_table[] = {
9884        "", ".v2", ".v3", ".v4"
9885    };
9886
9887    const char *vecsize = vecsize_table[_BITS(bits, 9, 2)];
9888
9889    fputs("+ST_TILE", fp);
9890    fputs(vecsize, fp);
9891    fputs(" ", fp);
9892    bi_disasm_dest_add(fp, next_regs, last);
9893    fputs(", ", fp);
9894    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9895    fputs(", ", fp);
9896    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9897    fputs(", ", fp);
9898    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
9899    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
9900    fprintf(fp, ", @r%u", staging_register);
9901}
9902
9903static void
9904bi_disasm_add_swz_v2i16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9905{
9906    static const char *swz0_table[] = {
9907        ".h00", ".h10", ".reserved", ".h11"
9908    };
9909
9910    const char *swz0 = swz0_table[_BITS(bits, 4, 2)];
9911
9912    fputs("+SWZ.v2i16", fp);
9913    fputs(" ", fp);
9914    bi_disasm_dest_add(fp, next_regs, last);
9915    fputs(", ", fp);
9916    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9917    fputs(swz0, fp);
9918}
9919
9920static void
9921bi_disasm_add_swz_v4i8(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9922{
9923    static const char *swz0_table[] = {
9924        ".b0000", ".b1111", ".b2222", ".b3333", ".b0011", ".b2233", ".b1032", ".b3210"
9925    };
9926
9927    const char *swz0 = swz0_table[_BITS(bits, 3, 3)];
9928
9929    fputs("+SWZ.v4i8", fp);
9930    fputs(" ", fp);
9931    bi_disasm_dest_add(fp, next_regs, last);
9932    fputs(", ", fp);
9933    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9934    fputs(swz0, fp);
9935}
9936
9937static void
9938bi_disasm_add_texc(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9939{
9940    static const char *skip_table[] = {
9941        "", ".skip"
9942    };
9943
9944    const char *skip = skip_table[_BITS(bits, 9, 1)];
9945
9946    fputs("+TEXC", fp);
9947    fputs(skip, fp);
9948    fputs(" ", fp);
9949    bi_disasm_dest_add(fp, next_regs, last);
9950    fputs(", ", fp);
9951    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9952    fputs(", ", fp);
9953    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9954    fputs(", ", fp);
9955    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
9956    if (!(0xf7 & (1 << _BITS(bits, 6, 3)))) fputs("(INVALID)", fp);
9957    fprintf(fp, ", @r%u", staging_register);
9958}
9959
9960static void
9961bi_disasm_add_texs_2d_f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9962{
9963    static const char *skip_table[] = {
9964        "", ".skip"
9965    };
9966
9967    const char *skip = skip_table[_BITS(bits, 9, 1)];
9968
9969    static const char *lod_mode_table[] = {
9970        ".computed_lod", ""
9971    };
9972
9973    const char *lod_mode = lod_mode_table[_BITS(bits, 13, 1)];
9974
9975    fputs("+TEXS_2D.f16", fp);
9976    fputs(skip, fp);
9977    fputs(lod_mode, fp);
9978    fputs(" ", fp);
9979    bi_disasm_dest_add(fp, next_regs, last);
9980    fputs(", ", fp);
9981    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
9982    fputs(", ", fp);
9983    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
9984    fprintf(fp, ", texture_index:%u", _BITS(bits, 6, 3));
9985    fprintf(fp, ", sampler_index:%u", _BITS(bits, 10, 3));
9986    fprintf(fp, ", @r%u", staging_register);
9987}
9988
9989static void
9990bi_disasm_add_texs_2d_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
9991{
9992    static const char *skip_table[] = {
9993        "", ".skip"
9994    };
9995
9996    const char *skip = skip_table[_BITS(bits, 9, 1)];
9997
9998    static const char *lod_mode_table[] = {
9999        ".computed_lod", ""
10000    };
10001
10002    const char *lod_mode = lod_mode_table[_BITS(bits, 13, 1)];
10003
10004    fputs("+TEXS_2D.f32", fp);
10005    fputs(skip, fp);
10006    fputs(lod_mode, fp);
10007    fputs(" ", fp);
10008    bi_disasm_dest_add(fp, next_regs, last);
10009    fputs(", ", fp);
10010    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10011    fputs(", ", fp);
10012    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
10013    fprintf(fp, ", texture_index:%u", _BITS(bits, 6, 3));
10014    fprintf(fp, ", sampler_index:%u", _BITS(bits, 10, 3));
10015    fprintf(fp, ", @r%u", staging_register);
10016}
10017
10018static void
10019bi_disasm_add_texs_cube_f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10020{
10021    static const char *skip_table[] = {
10022        "", ".skip"
10023    };
10024
10025    const char *skip = skip_table[_BITS(bits, 9, 1)];
10026
10027    fputs("+TEXS_CUBE.f16", fp);
10028    fputs(skip, fp);
10029    fputs(" ", fp);
10030    bi_disasm_dest_add(fp, next_regs, last);
10031    fputs(", ", fp);
10032    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10033    fputs(", ", fp);
10034    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
10035    fputs(", ", fp);
10036    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
10037    fprintf(fp, ", sampler_index:%u", _BITS(bits, 10, 2));
10038    fprintf(fp, ", texture_index:%u", _BITS(bits, 12, 2));
10039    fprintf(fp, ", @r%u", staging_register);
10040}
10041
10042static void
10043bi_disasm_add_texs_cube_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10044{
10045    static const char *skip_table[] = {
10046        "", ".skip"
10047    };
10048
10049    const char *skip = skip_table[_BITS(bits, 9, 1)];
10050
10051    fputs("+TEXS_CUBE.f32", fp);
10052    fputs(skip, fp);
10053    fputs(" ", fp);
10054    bi_disasm_dest_add(fp, next_regs, last);
10055    fputs(", ", fp);
10056    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10057    fputs(", ", fp);
10058    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
10059    fputs(", ", fp);
10060    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
10061    fprintf(fp, ", sampler_index:%u", _BITS(bits, 10, 2));
10062    fprintf(fp, ", texture_index:%u", _BITS(bits, 12, 2));
10063    fprintf(fp, ", @r%u", staging_register);
10064}
10065
10066static void
10067bi_disasm_add_u16_to_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10068{
10069    static const char *lane0_table[] = {
10070        "", ".h1"
10071    };
10072
10073    const char *lane0 = lane0_table[_BITS(bits, 4, 1)];
10074
10075    fputs("+U16_TO_F32", fp);
10076    fputs(" ", fp);
10077    bi_disasm_dest_add(fp, next_regs, last);
10078    fputs(", ", fp);
10079    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10080    fputs(lane0, fp);
10081}
10082
10083static void
10084bi_disasm_add_u16_to_u32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10085{
10086    static const char *lane0_table[] = {
10087        "", ".h1"
10088    };
10089
10090    const char *lane0 = lane0_table[_BITS(bits, 4, 1)];
10091
10092    fputs("+U16_TO_U32", fp);
10093    fputs(" ", fp);
10094    bi_disasm_dest_add(fp, next_regs, last);
10095    fputs(", ", fp);
10096    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10097    fputs(lane0, fp);
10098}
10099
10100static void
10101bi_disasm_add_u32_to_f32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10102{
10103    static const char *round_table[] = {
10104        "", ".rtp", ".rtn", ".rtz"
10105    };
10106    const char *round = round_table[(_BITS(bits, 4, 2) << 0)];
10107    fputs("+U32_TO_F32", fp);
10108    fputs(round, fp);
10109    fputs(" ", fp);
10110    bi_disasm_dest_add(fp, next_regs, last);
10111    fputs(", ", fp);
10112    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10113}
10114
10115static void
10116bi_disasm_add_u32_to_f32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10117{
10118    static const char *round_table[] = {
10119        ".rtna"
10120    };
10121    const char *round = round_table[0];
10122    fputs("+U32_TO_F32", fp);
10123    fputs(round, fp);
10124    fputs(" ", fp);
10125    bi_disasm_dest_add(fp, next_regs, last);
10126    fputs(", ", fp);
10127    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10128}
10129
10130static void
10131bi_disasm_add_u8_to_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10132{
10133    static const char *lane0_table[] = {
10134        "", ".b1", ".b2", ".b3"
10135    };
10136
10137    const char *lane0 = lane0_table[_BITS(bits, 4, 2)];
10138
10139    fputs("+U8_TO_F32", fp);
10140    fputs(" ", fp);
10141    bi_disasm_dest_add(fp, next_regs, last);
10142    fputs(", ", fp);
10143    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10144    fputs(lane0, fp);
10145}
10146
10147static void
10148bi_disasm_add_u8_to_u32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10149{
10150    static const char *lane0_table[] = {
10151        "", ".b1", ".b2", ".b3"
10152    };
10153
10154    const char *lane0 = lane0_table[_BITS(bits, 4, 2)];
10155
10156    fputs("+U8_TO_U32", fp);
10157    fputs(" ", fp);
10158    bi_disasm_dest_add(fp, next_regs, last);
10159    fputs(", ", fp);
10160    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10161    fputs(lane0, fp);
10162}
10163
10164static void
10165bi_disasm_add_v2f16_to_v2s16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10166{
10167    static const char *round_table[] = {
10168        "", ".rtp", ".rtn", ".rtz"
10169    };
10170    const char *round = round_table[(_BITS(bits, 4, 2) << 0)];
10171    static const char *swz0_table[] = {
10172        ".h00", ".h10", "", ".h11"
10173    };
10174
10175    const char *swz0 = swz0_table[_BITS(bits, 6, 2)];
10176
10177    fputs("+V2F16_TO_V2S16", fp);
10178    fputs(round, fp);
10179    fputs(" ", fp);
10180    bi_disasm_dest_add(fp, next_regs, last);
10181    fputs(", ", fp);
10182    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10183    fputs(swz0, fp);
10184}
10185
10186static void
10187bi_disasm_add_v2f16_to_v2s16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10188{
10189    static const char *round_table[] = {
10190        ".rtna"
10191    };
10192    const char *round = round_table[0];
10193    static const char *swz0_table[] = {
10194        ".h00", ".h10", "", ".h11"
10195    };
10196
10197    const char *swz0 = swz0_table[_BITS(bits, 4, 2)];
10198
10199    fputs("+V2F16_TO_V2S16", fp);
10200    fputs(round, fp);
10201    fputs(" ", fp);
10202    bi_disasm_dest_add(fp, next_regs, last);
10203    fputs(", ", fp);
10204    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10205    fputs(swz0, fp);
10206}
10207
10208static void
10209bi_disasm_add_v2f16_to_v2u16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10210{
10211    static const char *round_table[] = {
10212        "", ".rtp", ".rtn", ".rtz"
10213    };
10214    const char *round = round_table[(_BITS(bits, 4, 2) << 0)];
10215    static const char *swz0_table[] = {
10216        ".h00", ".h10", "", ".h11"
10217    };
10218
10219    const char *swz0 = swz0_table[_BITS(bits, 6, 2)];
10220
10221    fputs("+V2F16_TO_V2U16", fp);
10222    fputs(round, fp);
10223    fputs(" ", fp);
10224    bi_disasm_dest_add(fp, next_regs, last);
10225    fputs(", ", fp);
10226    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10227    fputs(swz0, fp);
10228}
10229
10230static void
10231bi_disasm_add_v2f16_to_v2u16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10232{
10233    static const char *round_table[] = {
10234        ".rtna"
10235    };
10236    const char *round = round_table[0];
10237    static const char *swz0_table[] = {
10238        ".h00", ".h10", "", ".h11"
10239    };
10240
10241    const char *swz0 = swz0_table[_BITS(bits, 4, 2)];
10242
10243    fputs("+V2F16_TO_V2U16", fp);
10244    fputs(round, fp);
10245    fputs(" ", fp);
10246    bi_disasm_dest_add(fp, next_regs, last);
10247    fputs(", ", fp);
10248    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10249    fputs(swz0, fp);
10250}
10251
10252static void
10253bi_disasm_add_v2f32_to_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10254{
10255    static const char *neg1_table[] = {
10256        "", "", ".neg", ".neg"
10257    };
10258    const char *neg1 = neg1_table[(_BITS(bits, 6, 1) << 0) | (_BITS(bits, 7, 1) << 1)];
10259    static const char *abs0_table[] = {
10260        "", ".abs", "", ".abs"
10261    };
10262    const char *abs0 = abs0_table[(_BITS(bits, 6, 1) << 0) | (_BITS(bits, 7, 1) << 1)];
10263    static const char *neg0_table[] = {
10264        "", "", ".neg", ".neg"
10265    };
10266    const char *neg0 = neg0_table[(_BITS(bits, 6, 1) << 0) | (_BITS(bits, 7, 1) << 1)];
10267    static const char *abs1_table[] = {
10268        "", ".abs", "", ".abs"
10269    };
10270    const char *abs1 = abs1_table[(_BITS(bits, 6, 1) << 0) | (_BITS(bits, 7, 1) << 1)];
10271    static const char *clamp_table[] = {
10272        "", ".clamp_0_inf", ".clamp_m1_1", ".clamp_0_1"
10273    };
10274
10275    const char *clamp = clamp_table[_BITS(bits, 8, 2)];
10276
10277    static const char *round_table[] = {
10278        "", ".rtp", ".rtn", ".rtz", ".rtna", ".reserved", ".reserved", ".reserved"
10279    };
10280
10281    const char *round = round_table[_BITS(bits, 10, 3)];
10282
10283    fputs("+V2F32_TO_V2F16", fp);
10284    fputs(clamp, fp);
10285    fputs(round, fp);
10286    fputs(" ", fp);
10287    bi_disasm_dest_add(fp, next_regs, last);
10288    fputs(", ", fp);
10289    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10290    fputs(abs0, fp);
10291    fputs(neg0, fp);
10292    fputs(", ", fp);
10293    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
10294    fputs(abs1, fp);
10295    fputs(neg1, fp);
10296}
10297
10298static void
10299bi_disasm_add_v2s16_to_v2f16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10300{
10301    static const char *round_table[] = {
10302        "", ".rtp", ".rtn", ".rtz"
10303    };
10304    const char *round = round_table[(_BITS(bits, 4, 2) << 0)];
10305    static const char *swz0_table[] = {
10306        ".h00", ".h10", "", ".h11"
10307    };
10308
10309    const char *swz0 = swz0_table[_BITS(bits, 6, 2)];
10310
10311    fputs("+V2S16_TO_V2F16", fp);
10312    fputs(round, fp);
10313    fputs(" ", fp);
10314    bi_disasm_dest_add(fp, next_regs, last);
10315    fputs(", ", fp);
10316    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10317    fputs(swz0, fp);
10318}
10319
10320static void
10321bi_disasm_add_v2s16_to_v2f16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10322{
10323    static const char *round_table[] = {
10324        ".rtna"
10325    };
10326    const char *round = round_table[0];
10327    static const char *swz0_table[] = {
10328        ".h00", ".h10", "", ".h11"
10329    };
10330
10331    const char *swz0 = swz0_table[_BITS(bits, 4, 2)];
10332
10333    fputs("+V2S16_TO_V2F16", fp);
10334    fputs(round, fp);
10335    fputs(" ", fp);
10336    bi_disasm_dest_add(fp, next_regs, last);
10337    fputs(", ", fp);
10338    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10339    fputs(swz0, fp);
10340}
10341
10342static void
10343bi_disasm_add_v2s8_to_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10344{
10345    static const char *swz0_table[] = {
10346        ".b00", ".b10", ".b20", ".b30", "", ".b11", ".b21", ".b31", ".b02", ".b12", ".b22", ".b32", ".b03", ".b13", ".b23", ".b33"
10347    };
10348
10349    const char *swz0 = swz0_table[_BITS(bits, 4, 4)];
10350
10351    fputs("+V2S8_TO_V2F16", fp);
10352    fputs(" ", fp);
10353    bi_disasm_dest_add(fp, next_regs, last);
10354    fputs(", ", fp);
10355    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10356    fputs(swz0, fp);
10357}
10358
10359static void
10360bi_disasm_add_v2s8_to_v2s16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10361{
10362    static const char *swz0_table[] = {
10363        ".b00", ".b10", ".b20", ".b30", "", ".b11", ".b21", ".b31", ".b02", ".b12", ".b22", ".b32", ".b03", ".b13", ".b23", ".b33"
10364    };
10365
10366    const char *swz0 = swz0_table[_BITS(bits, 4, 4)];
10367
10368    fputs("+V2S8_TO_V2S16", fp);
10369    fputs(" ", fp);
10370    bi_disasm_dest_add(fp, next_regs, last);
10371    fputs(", ", fp);
10372    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10373    fputs(swz0, fp);
10374}
10375
10376static void
10377bi_disasm_add_v2u16_to_v2f16_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10378{
10379    static const char *round_table[] = {
10380        "", ".rtp", ".rtn", ".rtz"
10381    };
10382    const char *round = round_table[(_BITS(bits, 4, 2) << 0)];
10383    static const char *swz0_table[] = {
10384        ".h00", ".h10", "", ".h11"
10385    };
10386
10387    const char *swz0 = swz0_table[_BITS(bits, 6, 2)];
10388
10389    fputs("+V2U16_TO_V2F16", fp);
10390    fputs(round, fp);
10391    fputs(" ", fp);
10392    bi_disasm_dest_add(fp, next_regs, last);
10393    fputs(", ", fp);
10394    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10395    fputs(swz0, fp);
10396}
10397
10398static void
10399bi_disasm_add_v2u16_to_v2f16_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10400{
10401    static const char *round_table[] = {
10402        ".rtna"
10403    };
10404    const char *round = round_table[0];
10405    static const char *swz0_table[] = {
10406        ".h00", ".h10", "", ".h11"
10407    };
10408
10409    const char *swz0 = swz0_table[_BITS(bits, 4, 2)];
10410
10411    fputs("+V2U16_TO_V2F16", fp);
10412    fputs(round, fp);
10413    fputs(" ", fp);
10414    bi_disasm_dest_add(fp, next_regs, last);
10415    fputs(", ", fp);
10416    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10417    fputs(swz0, fp);
10418}
10419
10420static void
10421bi_disasm_add_v2u8_to_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10422{
10423    static const char *swz0_table[] = {
10424        ".b00", ".b10", ".b20", ".b30", "", ".b11", ".b21", ".b31", ".b02", ".b12", ".b22", ".b32", ".b03", ".b13", ".b23", ".b33"
10425    };
10426
10427    const char *swz0 = swz0_table[_BITS(bits, 4, 4)];
10428
10429    fputs("+V2U8_TO_V2F16", fp);
10430    fputs(" ", fp);
10431    bi_disasm_dest_add(fp, next_regs, last);
10432    fputs(", ", fp);
10433    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10434    fputs(swz0, fp);
10435}
10436
10437static void
10438bi_disasm_add_v2u8_to_v2u16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10439{
10440    static const char *swz0_table[] = {
10441        ".b00", ".b10", ".b20", ".b30", "", ".b11", ".b21", ".b31", ".b02", ".b12", ".b22", ".b32", ".b03", ".b13", ".b23", ".b33"
10442    };
10443
10444    const char *swz0 = swz0_table[_BITS(bits, 4, 4)];
10445
10446    fputs("+V2U8_TO_V2U16", fp);
10447    fputs(" ", fp);
10448    bi_disasm_dest_add(fp, next_regs, last);
10449    fputs(", ", fp);
10450    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10451    fputs(swz0, fp);
10452}
10453
10454static void
10455bi_disasm_add_var_tex_f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10456{
10457    static const char *update_table[] = {
10458        ".store", ".retrieve", ".reserved", ".reserved"
10459    };
10460    const char *update = update_table[(_BITS(bits, 5, 2) << 0)];
10461    static const char *sample_table[] = {
10462        ".center", "", ".reserved", ".reserved"
10463    };
10464    const char *sample = sample_table[(_BITS(bits, 5, 2) << 0)];
10465    static const char *skip_table[] = {
10466        "", ".skip"
10467    };
10468
10469    const char *skip = skip_table[_BITS(bits, 7, 1)];
10470
10471    static const char *lod_mode_table[] = {
10472        ".computed_lod", ""
10473    };
10474
10475    const char *lod_mode = lod_mode_table[_BITS(bits, 9, 1)];
10476
10477    fputs("+VAR_TEX.f16", fp);
10478    fputs(update, fp);
10479    fputs(skip, fp);
10480    fputs(lod_mode, fp);
10481    fputs(sample, fp);
10482    fputs(" ", fp);
10483    bi_disasm_dest_add(fp, next_regs, last);
10484    fprintf(fp, ", varying_index:%u", _BITS(bits, 0, 3));
10485    fprintf(fp, ", texture_index:%u", _BITS(bits, 3, 2));
10486    fprintf(fp, ", @r%u", staging_register);
10487}
10488
10489static void
10490bi_disasm_add_var_tex_f32(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10491{
10492    static const char *update_table[] = {
10493        ".store", ".retrieve", ".reserved", ".reserved"
10494    };
10495    const char *update = update_table[(_BITS(bits, 5, 2) << 0)];
10496    static const char *sample_table[] = {
10497        ".center", "", ".reserved", ".reserved"
10498    };
10499    const char *sample = sample_table[(_BITS(bits, 5, 2) << 0)];
10500    static const char *skip_table[] = {
10501        "", ".skip"
10502    };
10503
10504    const char *skip = skip_table[_BITS(bits, 7, 1)];
10505
10506    static const char *lod_mode_table[] = {
10507        ".computed_lod", ""
10508    };
10509
10510    const char *lod_mode = lod_mode_table[_BITS(bits, 9, 1)];
10511
10512    fputs("+VAR_TEX.f32", fp);
10513    fputs(update, fp);
10514    fputs(skip, fp);
10515    fputs(lod_mode, fp);
10516    fputs(sample, fp);
10517    fputs(" ", fp);
10518    bi_disasm_dest_add(fp, next_regs, last);
10519    fprintf(fp, ", varying_index:%u", _BITS(bits, 0, 3));
10520    fprintf(fp, ", texture_index:%u", _BITS(bits, 3, 2));
10521    fprintf(fp, ", @r%u", staging_register);
10522}
10523
10524static void
10525bi_disasm_add_vn_asst2_f32_0(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10526{
10527    static const char *scale_table[] = {
10528        ""
10529    };
10530    const char *scale = scale_table[0];
10531    static const char *neg0_table[] = {
10532        "", ".neg"
10533    };
10534
10535    const char *neg0 = neg0_table[_BITS(bits, 3, 1)];
10536
10537    fputs("+VN_ASST2.f32", fp);
10538    fputs(scale, fp);
10539    fputs(" ", fp);
10540    bi_disasm_dest_add(fp, next_regs, last);
10541    fputs(", ", fp);
10542    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10543    fputs(neg0, fp);
10544}
10545
10546static void
10547bi_disasm_add_vn_asst2_f32_1(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10548{
10549    static const char *scale_table[] = {
10550        ".scale"
10551    };
10552    const char *scale = scale_table[0];
10553    static const char *neg0_table[] = {
10554        "", ".neg"
10555    };
10556
10557    const char *neg0 = neg0_table[_BITS(bits, 4, 1)];
10558
10559    fputs("+VN_ASST2.f32", fp);
10560    fputs(scale, fp);
10561    fputs(" ", fp);
10562    bi_disasm_dest_add(fp, next_regs, last);
10563    fputs(", ", fp);
10564    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10565    fputs(neg0, fp);
10566}
10567
10568static void
10569bi_disasm_add_vn_asst2_v2f16(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10570{
10571    static const char *neg0_table[] = {
10572        "", ".neg"
10573    };
10574
10575    const char *neg0 = neg0_table[_BITS(bits, 3, 1)];
10576
10577    fputs("+VN_ASST2.v2f16", fp);
10578    fputs(" ", fp);
10579    bi_disasm_dest_add(fp, next_regs, last);
10580    fputs(", ", fp);
10581    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10582    fputs(neg0, fp);
10583}
10584
10585static void
10586bi_disasm_add_wmask(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10587{
10588    static const char *subgroup_table[] = {
10589        ".subgroup2", ".subgroup4", ".subgroup8", ".reserved"
10590    };
10591
10592    const char *subgroup = subgroup_table[_BITS(bits, 4, 2)];
10593
10594    fputs("+WMASK", fp);
10595    fputs(subgroup, fp);
10596    fputs(" ", fp);
10597    bi_disasm_dest_add(fp, next_regs, last);
10598    fputs(", ", fp);
10599    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10600    fprintf(fp, ", fill:%u", _BITS(bits, 3, 1));
10601}
10602
10603static void
10604bi_disasm_add_zs_emit(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10605{
10606    static const char *z_table[] = {
10607        ".reserved", "", ".z", ".z"
10608    };
10609    const char *z = z_table[(_BITS(bits, 9, 2) << 0)];
10610    static const char *stencil_table[] = {
10611        ".reserved", ".stencil", "", ".stencil"
10612    };
10613    const char *stencil = stencil_table[(_BITS(bits, 9, 2) << 0)];
10614    fputs("+ZS_EMIT", fp);
10615    fputs(stencil, fp);
10616    fputs(z, fp);
10617    fputs(" ", fp);
10618    bi_disasm_dest_add(fp, next_regs, last);
10619    fputs(", ", fp);
10620    dump_src(fp, _BITS(bits, 0, 3), *srcs, branch_offset, consts, false);
10621    fputs(", ", fp);
10622    dump_src(fp, _BITS(bits, 3, 3), *srcs, branch_offset, consts, false);
10623    fputs(", ", fp);
10624    dump_src(fp, _BITS(bits, 6, 3), *srcs, branch_offset, consts, false);
10625    fprintf(fp, ", @r%u", staging_register);
10626}
10627
10628void
10629bi_disasm_fma(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10630{
10631    fputs("    ", fp);
10632
10633    if (unlikely(((bits & 0x7fffff) == 0x701963)))
10634        bi_disasm_fma_nop(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10635    else if (unlikely(((bits & 0x7ffff8) == 0x701fc0)))
10636        bi_disasm_fma_bitrev_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10637    else if (unlikely(((bits & 0x7ffff8) == 0x701968)))
10638        bi_disasm_fma_mov_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10639    else if (unlikely(((bits & 0x7ffff8) == 0x73c6d8)))
10640        bi_disasm_fma_popcount_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10641    else if (unlikely(((bits & 0x7ffff8) == 0x701970)))
10642        bi_disasm_fma_quiet_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10643    else if (unlikely(((bits & 0x7ffff0) == 0x701fd0)))
10644        bi_disasm_fma_clz_u32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10645    else if (unlikely(((bits & 0x7ffff0) == 0x701f90)))
10646        bi_disasm_fma_clz_v4u8(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10647    else if (unlikely(((bits & 0x7ffff0) == 0x700d10)))
10648        bi_disasm_fma_f16_to_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10649    else if (unlikely(((bits & 0x7fffe8) == 0x700cc0)))
10650        bi_disasm_fma_s16_to_s32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10651    else if (unlikely(((bits & 0x7fffe8) == 0x700cc8)))
10652        bi_disasm_fma_u16_to_u32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10653    else if (unlikely(((bits & 0x7fffe0) == 0x70f3e0)))
10654        bi_disasm_fma_dtsel_imm(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10655    else if (unlikely(((bits & 0x7fffe0) == 0x701e20)))
10656        bi_disasm_fma_frexpe_f32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10657    else if (unlikely(((bits & 0x7fffe0) == 0x701e00)))
10658        bi_disasm_fma_frexpe_v2f16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10659    else if (unlikely(((bits & 0x7fffc8) == 0x701900)))
10660        bi_disasm_fma_quiet_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10661    else if (unlikely(((bits & 0x7fffc8) == 0x700b40)))
10662        bi_disasm_fma_s8_to_s32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10663    else if (unlikely(((bits & 0x7fffc8) == 0x700b48)))
10664        bi_disasm_fma_u8_to_u32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10665    else if (unlikely(((bits & 0x7fffc0) == 0x701ec0)))
10666        bi_disasm_fma_clz_v2u16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10667    else if (unlikely(((bits & 0x7fffc0) == 0x70cb40)))
10668        bi_disasm_fma_fmul_slice_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10669    else if (unlikely(((bits & 0x7fffc0) == 0x73c0c0)))
10670        bi_disasm_fma_imul_i32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10671    else if (unlikely(((bits & 0x7fffc0) == 0x73e0c0)))
10672        bi_disasm_fma_imul_v4i8_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10673    else if (unlikely(((bits & 0x7fff80) == 0x70f100)))
10674        bi_disasm_fma_imuld(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10675    else if (unlikely(((bits & 0x7fff40) == 0x701500)))
10676        bi_disasm_fma_seg_add(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10677    else if (unlikely(((bits & 0x7fff40) == 0x701540)))
10678        bi_disasm_fma_seg_sub(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10679    else if (unlikely(((bits & 0x7fff20) == 0x701b20)))
10680        bi_disasm_fma_frexpm_f32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10681    else if (unlikely(((bits & 0x7fff20) == 0x701a20)))
10682        bi_disasm_fma_frexpm_f32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10683    else if (unlikely(((bits & 0x7fff20) == 0x701b00)))
10684        bi_disasm_fma_frexpm_v2f16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10685    else if (unlikely(((bits & 0x7fff20) == 0x701a00)))
10686        bi_disasm_fma_frexpm_v2f16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10687    else if (unlikely(((bits & 0x7fff00) == 0x70f000)))
10688        bi_disasm_fma_mkvec_v2i16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10689    else if (unlikely(((bits & 0x7ffea0) == 0x701c20)))
10690        bi_disasm_fma_frexpe_f32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10691    else if (unlikely(((bits & 0x7ffea0) == 0x701c00)))
10692        bi_disasm_fma_frexpe_v2f16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10693    else if (unlikely(((bits & 0x7ffe60) == 0x707620)))
10694        bi_disasm_fma_fround_f32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10695    else if (unlikely(((bits & 0x7ffe60) == 0x707600)))
10696        bi_disasm_fma_fround_v2f16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10697    else if (unlikely(((bits & 0x7ffe38) == 0x335818)))
10698        bi_disasm_fma_arshift_v4i8_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10699    else if (unlikely(((bits & 0x7ffe00) == 0x2f5e00)))
10700        bi_disasm_fma_atom_c1_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10701    else if (unlikely(((bits & 0x7ffe00) == 0x2f1e00)))
10702        bi_disasm_fma_atom_c1_i64(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10703    else if (unlikely(((bits & 0x7ffe00) == 0x2f7e00)))
10704        bi_disasm_fma_atom_c1_return_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10705    else if (unlikely(((bits & 0x7ffe00) == 0x2f3e00)))
10706        bi_disasm_fma_atom_c1_return_i64(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10707    else if (unlikely(((bits & 0x7ffe00) == 0x70d000)))
10708        bi_disasm_fma_fmul_cslice(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10709    else if (unlikely(((bits & 0x7ffe00) == 0x27fc00)))
10710        bi_disasm_fma_iaddc_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10711    else if (unlikely(((bits & 0x7ffe00) == 0x27fe00)))
10712        bi_disasm_fma_isubb_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10713    else if (unlikely(((bits & 0x7ffe00) == 0x70e600)))
10714        bi_disasm_fma_shaddxl_i64(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10715    else if (unlikely(((bits & 0x7ffc00) == 0x6ee400)))
10716        bi_disasm_fma_atom_post_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10717    else if (unlikely(((bits & 0x7ffc00) == 0x6ee000)))
10718        bi_disasm_fma_atom_post_i64(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10719    else if (unlikely(((bits & 0x7ffc00) == 0x706800)))
10720        bi_disasm_fma_cubeface1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10721    else if (unlikely(((bits & 0x7ffc00) == 0x70f400)))
10722        bi_disasm_fma_fadd_lscale_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10723    else if (unlikely(((bits & 0x7ff9c0) == 0x73e8c0)))
10724        bi_disasm_fma_idp_v4i8(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10725    else if (unlikely(((bits & 0x7ff9c0) == 0x73c8c0)))
10726        bi_disasm_fma_imul_i32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10727    else if (unlikely(((bits & 0x7ff9c0) == 0x7380c0)))
10728        bi_disasm_fma_imul_v4i8_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10729    else if (unlikely(((bits & 0x7ff860) == 0x70c020)))
10730        bi_disasm_fma_fround_f32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10731    else if (unlikely(((bits & 0x7ff860) == 0x70c000)))
10732        bi_disasm_fma_fround_v2f16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10733    else if (unlikely(((bits & 0x7ff838) == 0x335018)))
10734        bi_disasm_fma_arshift_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10735    else if (unlikely(((bits & 0x7ff838) == 0x334818)))
10736        bi_disasm_fma_arshift_v2i16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10737    else if (unlikely(((bits & 0x7ff838) == 0x335818)
10738        && !(0x1 & (1 << _BITS(bits, 9, 2)))
10739    ))
10740        bi_disasm_fma_arshift_v2i16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10741    else if (unlikely(((bits & 0x7ff838) == 0x334018)))
10742        bi_disasm_fma_arshift_v4i8_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10743    else if (unlikely(((bits & 0x7ff800) == 0x33f800)))
10744        bi_disasm_fma_flshift_double_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10745    else if (unlikely(((bits & 0x7ff800) == 0x33f000)))
10746        bi_disasm_fma_frshift_double_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10747    else if (unlikely(((bits & 0x7ff800) == 0x70e800)))
10748        bi_disasm_fma_shaddxl_s32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10749    else if (unlikely(((bits & 0x7ff800) == 0x70e000)))
10750        bi_disasm_fma_shaddxl_u32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10751    else if (unlikely(((bits & 0x7ff1c0) == 0x73b0c0)))
10752        bi_disasm_fma_imul_i32_2(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10753    else if (unlikely(((bits & 0x7ff000) == 0x33e000)))
10754        bi_disasm_fma_arshift_double_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10755    else if (unlikely(((bits & 0x7ff000) == 0x2eb000)))
10756        bi_disasm_fma_jump_ex(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10757    else if (unlikely(((bits & 0x7ff000) == 0x33b000)))
10758        bi_disasm_fma_lrot_double_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10759    else if (unlikely(((bits & 0x7ff000) == 0x33c000)))
10760        bi_disasm_fma_lshift_double_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10761    else if (unlikely(((bits & 0x7ff000) == 0x33a000)))
10762        bi_disasm_fma_rrot_double_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10763    else if (unlikely(((bits & 0x7ff000) == 0x33d000)))
10764        bi_disasm_fma_rshift_double_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10765    else if (unlikely(((bits & 0x7ff000) == 0x6eb000)))
10766        bi_disasm_fma_vn_asst1_f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10767    else if (unlikely(((bits & 0x7fe1c0) == 0x7240c0)))
10768        bi_disasm_fma_imul_v2i16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10769    else if (unlikely(((bits & 0x7fe000) == 0x2f4000)))
10770        bi_disasm_fma_atom_c_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10771    else if (unlikely(((bits & 0x7fe000) == 0x2f0000)))
10772        bi_disasm_fma_atom_c_i64(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10773    else if (unlikely(((bits & 0x7fe000) == 0x2f6000)))
10774        bi_disasm_fma_atom_c_return_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10775    else if (unlikely(((bits & 0x7fe000) == 0x2f2000)))
10776        bi_disasm_fma_atom_c_return_i64(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10777    else if (unlikely(((bits & 0x7fe000) == 0x6ec000)))
10778        bi_disasm_fma_atom_pre_i64(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10779    else if (unlikely(((bits & 0x7fe000) == 0x2e4000)))
10780        bi_disasm_fma_csel_s32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10781    else if (unlikely(((bits & 0x7fe000) == 0x2e6000)))
10782        bi_disasm_fma_csel_u32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10783    else if (unlikely(((bits & 0x7fe000) == 0x6e4000)))
10784        bi_disasm_fma_csel_v2s16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10785    else if (unlikely(((bits & 0x7fe000) == 0x6e6000)))
10786        bi_disasm_fma_csel_v2u16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10787    else if (unlikely(((bits & 0x7fe000) == 0x6e8000)))
10788        bi_disasm_fma_v2f32_to_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10789    else if (unlikely(((bits & 0x7fe000) == 0x27c000)))
10790        bi_disasm_fma_vn_asst1_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10791    else if (unlikely(((bits & 0x7fde00) == 0x325800)))
10792        bi_disasm_fma_lshift_xor_v4i8_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10793    else if (unlikely(((bits & 0x7fde00) == 0x321800)))
10794        bi_disasm_fma_rshift_xor_v4i8_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10795    else if (unlikely(((bits & 0x7fd800) == 0x325000)))
10796        bi_disasm_fma_lshift_xor_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10797    else if (unlikely(((bits & 0x7fd800) == 0x324800)))
10798        bi_disasm_fma_lshift_xor_v2i16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10799    else if (unlikely(((bits & 0x7fd800) == 0x325800)
10800        && !(0x1 & (1 << _BITS(bits, 9, 2)))
10801    ))
10802        bi_disasm_fma_lshift_xor_v2i16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10803    else if (unlikely(((bits & 0x7fd800) == 0x324000)))
10804        bi_disasm_fma_lshift_xor_v4i8_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10805    else if (unlikely(((bits & 0x7fd800) == 0x321000)))
10806        bi_disasm_fma_rshift_xor_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10807    else if (unlikely(((bits & 0x7fd800) == 0x320800)))
10808        bi_disasm_fma_rshift_xor_v2i16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10809    else if (unlikely(((bits & 0x7fd800) == 0x321800)
10810        && !(0x1 & (1 << _BITS(bits, 9, 2)))
10811    ))
10812        bi_disasm_fma_rshift_xor_v2i16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10813    else if (unlikely(((bits & 0x7fd800) == 0x320000)))
10814        bi_disasm_fma_rshift_xor_v4i8_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10815    else if (unlikely(((bits & 0x7fc000) == 0x2e0000)
10816        && !(0x8 & (1 << _BITS(bits, 12, 2)))
10817    ))
10818        bi_disasm_fma_csel_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10819    else if (unlikely(((bits & 0x7fc000) == 0x6e0000)
10820        && !(0x8 & (1 << _BITS(bits, 12, 2)))
10821    ))
10822        bi_disasm_fma_csel_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10823    else if (unlikely(((bits & 0x7f8000) == 0x2e0000)
10824        && !(0xf7 & (1 << _BITS(bits, 12, 3)))
10825    ))
10826        bi_disasm_fma_csel_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10827    else if (unlikely(((bits & 0x7f8000) == 0x6e0000)
10828        && !(0xf7 & (1 << _BITS(bits, 12, 3)))
10829    ))
10830        bi_disasm_fma_csel_v2i16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10831    else if (unlikely(((bits & 0x7f3e00) == 0x311800)))
10832        bi_disasm_fma_lshift_and_v4i8_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10833    else if (unlikely(((bits & 0x7f3e00) == 0x313800)))
10834        bi_disasm_fma_lshift_or_v4i8_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10835    else if (unlikely(((bits & 0x7f3e00) == 0x301800)))
10836        bi_disasm_fma_rshift_and_v4i8_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10837    else if (unlikely(((bits & 0x7f3e00) == 0x303800)))
10838        bi_disasm_fma_rshift_or_v4i8_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10839    else if (unlikely(((bits & 0x7f3800) == 0x311000)))
10840        bi_disasm_fma_lshift_and_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10841    else if (unlikely(((bits & 0x7f3800) == 0x310800)))
10842        bi_disasm_fma_lshift_and_v2i16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10843    else if (unlikely(((bits & 0x7f3800) == 0x311800)
10844        && !(0x1 & (1 << _BITS(bits, 9, 2)))
10845    ))
10846        bi_disasm_fma_lshift_and_v2i16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10847    else if (unlikely(((bits & 0x7f3800) == 0x310000)))
10848        bi_disasm_fma_lshift_and_v4i8_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10849    else if (unlikely(((bits & 0x7f3800) == 0x313000)))
10850        bi_disasm_fma_lshift_or_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10851    else if (unlikely(((bits & 0x7f3800) == 0x312800)))
10852        bi_disasm_fma_lshift_or_v2i16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10853    else if (unlikely(((bits & 0x7f3800) == 0x313800)
10854        && !(0x1 & (1 << _BITS(bits, 9, 2)))
10855    ))
10856        bi_disasm_fma_lshift_or_v2i16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10857    else if (unlikely(((bits & 0x7f3800) == 0x312000)))
10858        bi_disasm_fma_lshift_or_v4i8_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10859    else if (unlikely(((bits & 0x7f3800) == 0x301000)))
10860        bi_disasm_fma_rshift_and_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10861    else if (unlikely(((bits & 0x7f3800) == 0x300800)))
10862        bi_disasm_fma_rshift_and_v2i16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10863    else if (unlikely(((bits & 0x7f3800) == 0x301800)
10864        && !(0x1 & (1 << _BITS(bits, 9, 2)))
10865    ))
10866        bi_disasm_fma_rshift_and_v2i16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10867    else if (unlikely(((bits & 0x7f3800) == 0x300000)))
10868        bi_disasm_fma_rshift_and_v4i8_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10869    else if (unlikely(((bits & 0x7f3800) == 0x303000)))
10870        bi_disasm_fma_rshift_or_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10871    else if (unlikely(((bits & 0x7f3800) == 0x302800)))
10872        bi_disasm_fma_rshift_or_v2i16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10873    else if (unlikely(((bits & 0x7f3800) == 0x303800)
10874        && !(0x1 & (1 << _BITS(bits, 9, 2)))
10875    ))
10876        bi_disasm_fma_rshift_or_v2i16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10877    else if (unlikely(((bits & 0x7f3800) == 0x302000)))
10878        bi_disasm_fma_rshift_or_v4i8_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10879    else if (unlikely(((bits & 0x7f0000) == 0x710000)))
10880        bi_disasm_fma_mkvec_v4i8(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10881    else if (unlikely(((bits & 0x7e0000) == 0x2c0000)))
10882        bi_disasm_fma_fadd_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10883    else if (unlikely(((bits & 0x7e0000) == 0x6c0000)))
10884        bi_disasm_fma_fadd_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10885    else if (unlikely(((bits & 0x7c0000) == 0x240000)))
10886        bi_disasm_fma_fcmp_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10887    else if (unlikely(((bits & 0x7c0000) == 0x640000)))
10888        bi_disasm_fma_fcmp_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10889    else if (unlikely(((bits & 0x7c0000) == 0x280000)))
10890        bi_disasm_fma_fma_rscale_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10891    else if (unlikely(((bits & 0x7c0000) == 0x680000)
10892        && !(0x40 & (1 << _BITS(bits, 12, 3)))
10893    ))
10894        bi_disasm_fma_fma_rscale_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10895    else if (unlikely(((bits & 0x600000) == 0x0)))
10896        bi_disasm_fma_fma_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10897    else if (unlikely(((bits & 0x600000) == 0x400000)))
10898        bi_disasm_fma_fma_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10899    else
10900        fprintf(fp, "INSTR_INVALID_ENC fma %X", bits);
10901
10902    fputs("\n", fp);
10903}
10904void
10905bi_disasm_add(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool last)
10906{
10907    fputs("    ", fp);
10908
10909    if (unlikely(((bits & 0xfffff) == 0xd7874)))
10910        bi_disasm_add_barrier(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10911    else if (unlikely(((bits & 0xfffff) == 0x3d964)))
10912        bi_disasm_add_nop(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10913    else if (unlikely(((bits & 0xffff8) == 0x3de58)))
10914        bi_disasm_add_cubeface2(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10915    else if (unlikely(((bits & 0xffff8) == 0xd7860)))
10916        bi_disasm_add_doorbell(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10917    else if (unlikely(((bits & 0xffff8) == 0xd7850)))
10918        bi_disasm_add_eureka(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10919    else if (unlikely(((bits & 0xffff8) == 0x3cca0)))
10920        bi_disasm_add_f32_to_s32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10921    else if (unlikely(((bits & 0xffff8) == 0x3cca8)))
10922        bi_disasm_add_f32_to_u32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10923    else if (unlikely(((bits & 0xffff8) == 0x66340)))
10924        bi_disasm_add_flogd_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10925    else if (unlikely(((bits & 0xffff8) == 0x67c50)))
10926        bi_disasm_add_fpclass_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10927    else if (unlikely(((bits & 0xffff8) == 0x67ab0)))
10928        bi_disasm_add_frcbrt_approx_b_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10929    else if (unlikely(((bits & 0xffff8) == 0x67ab8)))
10930        bi_disasm_add_frcbrt_approx_c_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10931    else if (unlikely(((bits & 0xffff8) == 0x3dea0)))
10932        bi_disasm_add_iabs_s32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10933    else if (unlikely(((bits & 0xffff8) == 0x3deb0)))
10934        bi_disasm_add_iabs_v4s8(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10935    else if (unlikely(((bits & 0xffff8) == 0xd7858)))
10936        bi_disasm_add_kaboom(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10937    else if (unlikely(((bits & 0xffff8) == 0xd7800)))
10938        bi_disasm_add_ld_gclk_u64(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10939    else if (unlikely(((bits & 0xffff8) == 0x3d968)))
10940        bi_disasm_add_mov_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10941    else if (unlikely(((bits & 0xffff8) == 0x3d970)))
10942        bi_disasm_add_quiet_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10943    else if (unlikely(((bits & 0xffff8) == 0x3cd00)))
10944        bi_disasm_add_s32_to_f32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10945    else if (unlikely(((bits & 0xffff8) == 0x3cd08)))
10946        bi_disasm_add_u32_to_f32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10947    else if (unlikely(((bits & 0xffff7) == 0xd7820)))
10948        bi_disasm_add_imov_fma(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10949    else if (unlikely(((bits & 0xffff0) == 0x3cd10)))
10950        bi_disasm_add_f16_to_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10951    else if (unlikely(((bits & 0xffff0) == 0x67c40)))
10952        bi_disasm_add_fpclass_f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10953    else if (unlikely(((bits & 0xffff0) == 0x67aa0)))
10954        bi_disasm_add_fsincos_offset_u6(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10955    else if (unlikely(((bits & 0xffff0) == 0x3df80)))
10956        bi_disasm_add_vn_asst2_f32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10957    else if (unlikely(((bits & 0xffff0) == 0x3dfa0)))
10958        bi_disasm_add_vn_asst2_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10959    else if (unlikely(((bits & 0xfffe8) == 0x67a88)))
10960        bi_disasm_add_fcos_table_u6(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10961    else if (unlikely(((bits & 0xfffe8) == 0x67a80)))
10962        bi_disasm_add_fsin_table_u6(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10963    else if (unlikely(((bits & 0xfffe8) == 0x3cce0)))
10964        bi_disasm_add_s16_to_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10965    else if (unlikely(((bits & 0xfffe8) == 0x3ccc0)))
10966        bi_disasm_add_s16_to_s32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10967    else if (unlikely(((bits & 0xfffe8) == 0x3cce8)))
10968        bi_disasm_add_u16_to_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10969    else if (unlikely(((bits & 0xfffe8) == 0x3ccc8)))
10970        bi_disasm_add_u16_to_u32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10971    else if (unlikely(((bits & 0xfffe8) == 0x3de80)))
10972        bi_disasm_add_vn_asst2_f32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10973    else if (unlikely(((bits & 0xfffe0) == 0x67ac0)))
10974        bi_disasm_add_fexp_table_u4(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10975    else if (unlikely(((bits & 0xfffe0) == 0x67ae0)))
10976        bi_disasm_add_flog_table_f32_4(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10977    else if (unlikely(((bits & 0xfffe0) == 0x3de20)))
10978        bi_disasm_add_frexpe_f32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10979    else if (unlikely(((bits & 0xfffe0) == 0x3de00)))
10980        bi_disasm_add_frexpe_v2f16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10981    else if (unlikely(((bits & 0xfffe0) == 0x3d9e0)))
10982        bi_disasm_add_ilogb_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10983    else if (unlikely(((bits & 0xfffe0) == 0x3d9c0)))
10984        bi_disasm_add_ilogb_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10985    else if (unlikely(((bits & 0xfffe0) == 0x3d9a0)))
10986        bi_disasm_add_logb_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10987    else if (unlikely(((bits & 0xfffe0) == 0x3d980)))
10988        bi_disasm_add_logb_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10989    else if (unlikely(((bits & 0xfffd8) == 0x3cc40)))
10990        bi_disasm_add_f16_to_s32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10991    else if (unlikely(((bits & 0xfffd8) == 0x3cc48)))
10992        bi_disasm_add_f16_to_u32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10993    else if (unlikely(((bits & 0xfffc8) == 0x3c980)))
10994        bi_disasm_add_f32_to_s32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10995    else if (unlikely(((bits & 0xfffc8) == 0x3c988)))
10996        bi_disasm_add_f32_to_u32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10997    else if (unlikely(((bits & 0xfffc8) == 0x3de88)))
10998        bi_disasm_add_iabs_v2s16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
10999    else if (unlikely(((bits & 0xfffc8) == 0x3d900)))
11000        bi_disasm_add_quiet_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11001    else if (unlikely(((bits & 0xfffc8) == 0x3cbc0)))
11002        bi_disasm_add_s32_to_f32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11003    else if (unlikely(((bits & 0xfffc8) == 0x3cb80)))
11004        bi_disasm_add_s8_to_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11005    else if (unlikely(((bits & 0xfffc8) == 0x3cb40)))
11006        bi_disasm_add_s8_to_s32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11007    else if (unlikely(((bits & 0xfffc8) == 0x3d948)))
11008        bi_disasm_add_swz_v2i16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11009    else if (unlikely(((bits & 0xfffc8) == 0x3cbc8)))
11010        bi_disasm_add_u32_to_f32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11011    else if (unlikely(((bits & 0xfffc8) == 0x3cb88)))
11012        bi_disasm_add_u8_to_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11013    else if (unlikely(((bits & 0xfffc8) == 0x3cb48)))
11014        bi_disasm_add_u8_to_u32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11015    else if (unlikely(((bits & 0xfffc8) == 0x3ca80)))
11016        bi_disasm_add_v2f16_to_v2s16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11017    else if (unlikely(((bits & 0xfffc8) == 0x3ca88)))
11018        bi_disasm_add_v2f16_to_v2u16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11019    else if (unlikely(((bits & 0xfffc8) == 0x3cb00)))
11020        bi_disasm_add_v2s16_to_v2f16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11021    else if (unlikely(((bits & 0xfffc8) == 0x3cb08)))
11022        bi_disasm_add_v2u16_to_v2f16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11023    else if (unlikely(((bits & 0xfffc0) == 0x3f0c0)))
11024        bi_disasm_add_clper_v6_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11025    else if (unlikely(((bits & 0xfffc0) == 0x75200)))
11026        bi_disasm_add_fadd_f32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11027    else if (unlikely(((bits & 0xfffc0) == 0x67a00)))
11028        bi_disasm_add_fatan_assist_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11029    else if (unlikely(((bits & 0xfffc0) == 0x67a40)))
11030        bi_disasm_add_fatan_table_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11031    else if (unlikely(((bits & 0xfffc0) == 0x66ac0)))
11032        bi_disasm_add_fexp_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11033    else if (unlikely(((bits & 0xfffc0) == 0x67300)))
11034        bi_disasm_add_flog_table_f32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11035    else if (unlikely(((bits & 0xfffc0) == 0x67b00)))
11036        bi_disasm_add_flog_table_f32_2(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11037    else if (unlikely(((bits & 0xfffc0) == 0x75080)))
11038        bi_disasm_add_fpow_sc_apply(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11039    else if (unlikely(((bits & 0xfffc0) == 0x67200)))
11040        bi_disasm_add_frcbrt_approx_a_f32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11041    else if (unlikely(((bits & 0xfffc0) == 0x67000)))
11042        bi_disasm_add_frcp_approx_f32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11043    else if (unlikely(((bits & 0xfffc0) == 0x67100)))
11044        bi_disasm_add_frsq_approx_f32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11045    else if (unlikely(((bits & 0xfffc0) == 0x3f8c0)))
11046        bi_disasm_add_shaddxh_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11047    else if (unlikely(((bits & 0xfffc0) == 0x3df40)))
11048        bi_disasm_add_swz_v4i8(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11049    else if (unlikely(((bits & 0xfffc0) == 0x3d700)))
11050        bi_disasm_add_wmask(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11051    else if (unlikely(((bits & 0xfffa0) == 0x66000)
11052        && !(0x2 & (1 << _BITS(bits, 6, 1)))
11053    ))
11054        bi_disasm_add_frcp_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11055    else if (unlikely(((bits & 0xfffa0) == 0x66100)
11056        && !(0x2 & (1 << _BITS(bits, 6, 1)))
11057    ))
11058        bi_disasm_add_frsq_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11059    else if (unlikely(((bits & 0xfff48) == 0x3c500)))
11060        bi_disasm_add_f16_to_s32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11061    else if (unlikely(((bits & 0xfff48) == 0x3c508)))
11062        bi_disasm_add_f16_to_u32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11063    else if (unlikely(((bits & 0xfff40) == 0x67340)))
11064        bi_disasm_add_flog_table_f32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11065    else if (unlikely(((bits & 0xfff40) == 0x67b40)))
11066        bi_disasm_add_flog_table_f32_3(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11067    else if (unlikely(((bits & 0xfff40) == 0x67240)))
11068        bi_disasm_add_frcbrt_approx_a_f32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11069    else if (unlikely(((bits & 0xfff40) == 0x67040)))
11070        bi_disasm_add_frcp_approx_f32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11071    else if (unlikely(((bits & 0xfff40) == 0x67140)))
11072        bi_disasm_add_frsq_approx_f32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11073    else if (unlikely(((bits & 0xfff40) == 0x3d500)))
11074        bi_disasm_add_seg_add(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11075    else if (unlikely(((bits & 0xfff40) == 0x3d540)))
11076        bi_disasm_add_seg_sub(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11077    else if (unlikely(((bits & 0xfff20) == 0x3db20)))
11078        bi_disasm_add_frexpm_f32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11079    else if (unlikely(((bits & 0xfff20) == 0x3da20)))
11080        bi_disasm_add_frexpm_f32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11081    else if (unlikely(((bits & 0xfff20) == 0x3db00)))
11082        bi_disasm_add_frexpm_v2f16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11083    else if (unlikely(((bits & 0xfff20) == 0x3da00)))
11084        bi_disasm_add_frexpm_v2f16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11085    else if (unlikely(((bits & 0xfff08) == 0x3c200)))
11086        bi_disasm_add_v2f16_to_v2s16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11087    else if (unlikely(((bits & 0xfff08) == 0x3c208)))
11088        bi_disasm_add_v2f16_to_v2u16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11089    else if (unlikely(((bits & 0xfff08) == 0x3c600)))
11090        bi_disasm_add_v2s16_to_v2f16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11091    else if (unlikely(((bits & 0xfff08) == 0x3c800)))
11092        bi_disasm_add_v2s8_to_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11093    else if (unlikely(((bits & 0xfff08) == 0x3c700)))
11094        bi_disasm_add_v2s8_to_v2s16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11095    else if (unlikely(((bits & 0xfff08) == 0x3c608)))
11096        bi_disasm_add_v2u16_to_v2f16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11097    else if (unlikely(((bits & 0xfff08) == 0x3c808)))
11098        bi_disasm_add_v2u8_to_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11099    else if (unlikely(((bits & 0xfff08) == 0x3c708)))
11100        bi_disasm_add_v2u8_to_v2u16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11101    else if (unlikely(((bits & 0xfff00) == 0xc8f00)))
11102        bi_disasm_add_atest(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11103    else if (unlikely(((bits & 0xfff00) == 0x67800)))
11104        bi_disasm_add_fatan_assist_f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11105    else if (unlikely(((bits & 0xfff00) == 0x67900)))
11106        bi_disasm_add_fatan_table_f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11107    else if (unlikely(((bits & 0xfff00) == 0x75300)))
11108        bi_disasm_add_mkvec_v2i16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11109    else if (unlikely(((bits & 0xffec0) == 0x67080)))
11110        bi_disasm_add_frcp_f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11111    else if (unlikely(((bits & 0xffec0) == 0x67280)))
11112        bi_disasm_add_frsq_f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11113    else if (unlikely(((bits & 0xffec0) == 0xbc600)))
11114        bi_disasm_add_iadd_s32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11115    else if (unlikely(((bits & 0xffec0) == 0xbc400)))
11116        bi_disasm_add_iadd_v4s8_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11117    else if (unlikely(((bits & 0xffec0) == 0xbd600)))
11118        bi_disasm_add_isub_s32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11119    else if (unlikely(((bits & 0xffec0) == 0xbd400)))
11120        bi_disasm_add_isub_v4s8_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11121    else if (unlikely(((bits & 0xffea0) == 0x3dc20)))
11122        bi_disasm_add_frexpe_f32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11123    else if (unlikely(((bits & 0xffea0) == 0x3dc00)))
11124        bi_disasm_add_frexpe_v2f16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11125    else if (unlikely(((bits & 0xffe40) == 0x67600)))
11126        bi_disasm_add_fpow_sc_det_f16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11127    else if (unlikely(((bits & 0xffe40) == 0x67640)))
11128        bi_disasm_add_fpow_sc_det_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11129    else if (unlikely(((bits & 0xffe40) == 0xbc600)))
11130        bi_disasm_add_iadd_u32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11131    else if (unlikely(((bits & 0xffe40) == 0xbc400)))
11132        bi_disasm_add_iadd_v4u8_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11133    else if (unlikely(((bits & 0xffe40) == 0xbd600)))
11134        bi_disasm_add_isub_u32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11135    else if (unlikely(((bits & 0xffe40) == 0xbd400)))
11136        bi_disasm_add_isub_v4u8_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11137    else if (unlikely(((bits & 0xffe3f) == 0x6f83c)))
11138        bi_disasm_add_branch_diverg(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11139    else if (unlikely(((bits & 0xffe3f) == 0x6fa34)))
11140        bi_disasm_add_branch_no_diverg(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11141    else if (unlikely(((bits & 0xffe3f) == 0x6fe34)))
11142        bi_disasm_add_jump(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11143    else if (unlikely(((bits & 0xffe38) == 0x6fa38)))
11144        bi_disasm_add_branch_lowbits_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11145    else if (unlikely(((bits & 0xffe30) == 0x6f800)))
11146        bi_disasm_add_branchz_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11147    else if (unlikely(((bits & 0xffe00) == 0xd7400)))
11148        bi_disasm_add_atom_cx(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11149    else if (unlikely(((bits & 0xffe00) == 0xca800)))
11150        bi_disasm_add_blend(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11151    else if (unlikely(((bits & 0xffe00) == 0x6f800)
11152        && !(0x9 & (1 << _BITS(bits, 4, 2)))
11153    ))
11154        bi_disasm_add_branchz_i16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11155    else if (unlikely(((bits & 0xffe00) == 0x67400)))
11156        bi_disasm_add_fpow_sc_det_f16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11157    else if (unlikely(((bits & 0xffe00) == 0x7be00)))
11158        bi_disasm_add_icmpf_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11159    else if (unlikely(((bits & 0xffe00) == 0x7ba00)))
11160        bi_disasm_add_icmpm_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11161    else if (unlikely(((bits & 0xffe00) == 0x74c00)))
11162        bi_disasm_add_ldexp_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11163    else if (unlikely(((bits & 0xffe00) == 0x74e00)))
11164        bi_disasm_add_ldexp_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11165    else if (unlikely(((bits & 0xffe00) == 0xc8400)))
11166        bi_disasm_add_lea_attr_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11167    else if (unlikely(((bits & 0xffe00) == 0xc8600)))
11168        bi_disasm_add_lea_attr_tex_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11169    else if (unlikely(((bits & 0xffe00) == 0x61000)))
11170        bi_disasm_add_load_i128(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11171    else if (unlikely(((bits & 0xffe00) == 0x65000)))
11172        bi_disasm_add_load_i24(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11173    else if (unlikely(((bits & 0xffe00) == 0x60c00)))
11174        bi_disasm_add_load_i32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11175    else if (unlikely(((bits & 0xffe00) == 0x65200)))
11176        bi_disasm_add_load_i48(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11177    else if (unlikely(((bits & 0xffe00) == 0x60e00)))
11178        bi_disasm_add_load_i64(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11179    else if (unlikely(((bits & 0xffe00) == 0x65400)))
11180        bi_disasm_add_load_i96(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11181    else if (unlikely(((bits & 0xffe00) == 0xefe00)))
11182        bi_disasm_add_shift_double_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11183    else if (unlikely(((bits & 0xffe00) == 0x61200)))
11184        bi_disasm_add_store_i128(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11185    else if (unlikely(((bits & 0xffe00) == 0x62800)))
11186        bi_disasm_add_store_i16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11187    else if (unlikely(((bits & 0xffe00) == 0x65800)))
11188        bi_disasm_add_store_i24(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11189    else if (unlikely(((bits & 0xffe00) == 0x62c00)))
11190        bi_disasm_add_store_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11191    else if (unlikely(((bits & 0xffe00) == 0x65a00)))
11192        bi_disasm_add_store_i48(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11193    else if (unlikely(((bits & 0xffe00) == 0x62e00)))
11194        bi_disasm_add_store_i64(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11195    else if (unlikely(((bits & 0xffe00) == 0x62000)))
11196        bi_disasm_add_store_i8(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11197    else if (unlikely(((bits & 0xffe00) == 0x65c00)))
11198        bi_disasm_add_store_i96(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11199    else if (unlikely(((bits & 0xffdc0) == 0x648c0)))
11200        bi_disasm_add_acmpstore_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11201    else if (unlikely(((bits & 0xffdc0) == 0x64900)))
11202        bi_disasm_add_acmpstore_i64(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11203    else if (unlikely(((bits & 0xffdc0) == 0x644c0)))
11204        bi_disasm_add_acmpxchg_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11205    else if (unlikely(((bits & 0xffdc0) == 0x64500)))
11206        bi_disasm_add_acmpxchg_i64(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11207    else if (unlikely(((bits & 0xffdc0) == 0x640c0)))
11208        bi_disasm_add_axchg_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11209    else if (unlikely(((bits & 0xffdc0) == 0x64100)))
11210        bi_disasm_add_axchg_i64(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11211    else if (unlikely(((bits & 0xffd00) == 0xca100)
11212        && !(0xc & (1 << _BITS(bits, 5, 2)))
11213    ))
11214        bi_disasm_add_var_tex_f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11215    else if (unlikely(((bits & 0xffd00) == 0xca000)
11216        && !(0xc & (1 << _BITS(bits, 5, 2)))
11217    ))
11218        bi_disasm_add_var_tex_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11219    else if (unlikely(((bits & 0xffcc0) == 0xbec00)))
11220        bi_disasm_add_iadd_s32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11221    else if (unlikely(((bits & 0xffcc0) == 0xbec40)))
11222        bi_disasm_add_iadd_v2s16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11223    else if (unlikely(((bits & 0xffcc0) == 0xbe800)))
11224        bi_disasm_add_iadd_v2s16_2(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11225    else if (unlikely(((bits & 0xffcc0) == 0xbe840)))
11226        bi_disasm_add_iadd_v4s8_2(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11227    else if (unlikely(((bits & 0xffcc0) == 0xbfc00)))
11228        bi_disasm_add_isub_s32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11229    else if (unlikely(((bits & 0xffcc0) == 0xbfc40)))
11230        bi_disasm_add_isub_v2s16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11231    else if (unlikely(((bits & 0xffcc0) == 0xbf800)))
11232        bi_disasm_add_isub_v2s16_2(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11233    else if (unlikely(((bits & 0xffcc0) == 0xbf840)))
11234        bi_disasm_add_isub_v4s8_2(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11235    else if (unlikely(((bits & 0xffcc0) == 0xcf8c0)))
11236        bi_disasm_add_ld_var_flat_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11237    else if (unlikely(((bits & 0xffc40) == 0xbec00)))
11238        bi_disasm_add_iadd_u32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11239    else if (unlikely(((bits & 0xffc40) == 0xbec40)))
11240        bi_disasm_add_iadd_v2u16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11241    else if (unlikely(((bits & 0xffc40) == 0xbe800)))
11242        bi_disasm_add_iadd_v2u16_2(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11243    else if (unlikely(((bits & 0xffc40) == 0xbe840)))
11244        bi_disasm_add_iadd_v4u8_2(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11245    else if (unlikely(((bits & 0xffc40) == 0xbfc00)))
11246        bi_disasm_add_isub_u32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11247    else if (unlikely(((bits & 0xffc40) == 0xbfc40)))
11248        bi_disasm_add_isub_v2u16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11249    else if (unlikely(((bits & 0xffc40) == 0xbf800)))
11250        bi_disasm_add_isub_v2u16_2(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11251    else if (unlikely(((bits & 0xffc40) == 0xbf840)))
11252        bi_disasm_add_isub_v4u8_2(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11253    else if (unlikely(((bits & 0xffc00) == 0x3e000)))
11254        bi_disasm_add_cube_ssel(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11255    else if (unlikely(((bits & 0xffc00) == 0x3e400)))
11256        bi_disasm_add_cube_tsel(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11257    else if (unlikely(((bits & 0xffc00) == 0xcf800)))
11258        bi_disasm_add_ld_var_flat_imm_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11259    else if (unlikely(((bits & 0xffc00) == 0xc8000)))
11260        bi_disasm_add_lea_attr_imm_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11261    else if (unlikely(((bits & 0xffc00) == 0x60800)))
11262        bi_disasm_add_load_i16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11263    else if (unlikely(((bits & 0xffc00) == 0x63000)))
11264        bi_disasm_add_load_i16_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11265    else if (unlikely(((bits & 0xffc00) == 0x61800)))
11266        bi_disasm_add_load_i16_2(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11267    else if (unlikely(((bits & 0xffc00) == 0x61c00)))
11268        bi_disasm_add_load_i32_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11269    else if (unlikely(((bits & 0xffc00) == 0x63400)))
11270        bi_disasm_add_load_i8_2(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11271    else if (unlikely(((bits & 0xffc00) == 0x61400)))
11272        bi_disasm_add_load_i8_3(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11273    else if (unlikely(((bits & 0xffc00) == 0x74800)))
11274        bi_disasm_add_mux_v4i8(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11275    else if (unlikely(((bits & 0xffc00) == 0xd7000)))
11276        bi_disasm_add_texc(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11277    else if (unlikely(((bits & 0xffb80) == 0x7b300)))
11278        bi_disasm_add_icmp_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11279    else if (unlikely(((bits & 0xffb80) == 0x7b200)))
11280        bi_disasm_add_icmp_s32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11281    else if (unlikely(((bits & 0xffb80) == 0x7b280)))
11282        bi_disasm_add_icmp_u32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11283    else if (unlikely(((bits & 0xffb80) == 0x7b100)))
11284        bi_disasm_add_icmp_v4i8(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11285    else if (unlikely(((bits & 0xffb80) == 0x7b000)))
11286        bi_disasm_add_icmp_v4s8(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11287    else if (unlikely(((bits & 0xffb80) == 0x7b080)))
11288        bi_disasm_add_icmp_v4u8(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11289    else if (unlikely(((bits & 0xffb80) == 0x7b900)))
11290        bi_disasm_add_icmpi_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11291    else if (unlikely(((bits & 0xffb80) == 0x7b800)))
11292        bi_disasm_add_icmpi_s32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11293    else if (unlikely(((bits & 0xffb80) == 0x7b880)))
11294        bi_disasm_add_icmpi_u32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11295    else if (unlikely(((bits & 0xffa38) == 0x6f238)))
11296        bi_disasm_add_branchc_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11297    else if (unlikely(((bits & 0xff8c0) == 0xbe000)))
11298        bi_disasm_add_iadd_s32_2(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11299    else if (unlikely(((bits & 0xff8c0) == 0xbc800)))
11300        bi_disasm_add_iadd_v2s16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11301    else if (unlikely(((bits & 0xff8c0) == 0xbe040)))
11302        bi_disasm_add_iadd_v4s8_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11303    else if (unlikely(((bits & 0xff8c0) == 0xbf000)))
11304        bi_disasm_add_isub_s32_2(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11305    else if (unlikely(((bits & 0xff8c0) == 0xbd800)))
11306        bi_disasm_add_isub_v2s16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11307    else if (unlikely(((bits & 0xff8c0) == 0xbf040)))
11308        bi_disasm_add_isub_v4s8_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11309    else if (unlikely(((bits & 0xff860) == 0x3e820)))
11310        bi_disasm_add_fround_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11311    else if (unlikely(((bits & 0xff860) == 0x3e800)))
11312        bi_disasm_add_fround_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11313    else if (unlikely(((bits & 0xff840) == 0xbe000)))
11314        bi_disasm_add_iadd_u32_2(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11315    else if (unlikely(((bits & 0xff840) == 0xbc800)))
11316        bi_disasm_add_iadd_v2u16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11317    else if (unlikely(((bits & 0xff840) == 0xbe040)))
11318        bi_disasm_add_iadd_v4u8_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11319    else if (unlikely(((bits & 0xff840) == 0xbf000)))
11320        bi_disasm_add_isub_u32_2(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11321    else if (unlikely(((bits & 0xff840) == 0xbd800)))
11322        bi_disasm_add_isub_v2u16_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11323    else if (unlikely(((bits & 0xff840) == 0xbf040)))
11324        bi_disasm_add_isub_v4u8_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11325    else if (unlikely(((bits & 0xff830) == 0x6f030)))
11326        bi_disasm_add_branchc_i16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11327    else if (unlikely(((bits & 0xff800) == 0xc8800)
11328        && !(0xe0 & (1 << _BITS(bits, 8, 3)))
11329    ))
11330        bi_disasm_add_discard_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11331    else if (unlikely(((bits & 0xff800) == 0xc9000)))
11332        bi_disasm_add_ld_cvt(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11333    else if (unlikely(((bits & 0xff800) == 0xcb000)))
11334        bi_disasm_add_ld_tile(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11335    else if (unlikely(((bits & 0xff800) == 0x60000)))
11336        bi_disasm_add_load_i8_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11337    else if (unlikely(((bits & 0xff800) == 0x63800)))
11338        bi_disasm_add_load_i8_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11339    else if (unlikely(((bits & 0xff800) == 0x74000)))
11340        bi_disasm_add_mux_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11341    else if (unlikely(((bits & 0xff800) == 0xc9800)))
11342        bi_disasm_add_st_cvt(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11343    else if (unlikely(((bits & 0xff800) == 0xcb800)))
11344        bi_disasm_add_st_tile(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11345    else if (unlikely(((bits & 0xff800) == 0xd7800)
11346        && !(0x1 & (1 << _BITS(bits, 9, 2)))
11347    ))
11348        bi_disasm_add_zs_emit(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11349    else if (unlikely(((bits & 0xff600) == 0xd6600)))
11350        bi_disasm_add_lea_tex(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11351    else if (unlikely(((bits & 0xff038) == 0x6f008)
11352        && !(0xf0 & (1 << _BITS(bits, 9, 3)))
11353    ))
11354        bi_disasm_add_branchz_s32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11355    else if (unlikely(((bits & 0xff038) == 0x6f000)
11356        && !(0xf0 & (1 << _BITS(bits, 9, 3)))
11357    ))
11358        bi_disasm_add_branchz_u32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11359    else if (unlikely(((bits & 0xff030) == 0x6f000)
11360        && !(0x1f & (1 << _BITS(bits, 9, 3)))
11361    ))
11362        bi_disasm_add_branchz_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11363    else if (unlikely(((bits & 0xff008) == 0x6f008)
11364        && !(0x9 & (1 << _BITS(bits, 4, 2)))
11365        && !(0xf0 & (1 << _BITS(bits, 9, 3)))
11366    ))
11367        bi_disasm_add_branchz_s16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11368    else if (unlikely(((bits & 0xff008) == 0x6f000)
11369        && !(0x9 & (1 << _BITS(bits, 4, 2)))
11370        && !(0xf0 & (1 << _BITS(bits, 9, 3)))
11371    ))
11372        bi_disasm_add_branchz_u16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11373    else if (unlikely(((bits & 0xff000) == 0x6f000)
11374        && !(0x9 & (1 << _BITS(bits, 4, 2)))
11375        && !(0x1f & (1 << _BITS(bits, 9, 3)))
11376    ))
11377        bi_disasm_add_branchz_f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11378    else if (unlikely(((bits & 0xff000) == 0x7a000)))
11379        bi_disasm_add_icmp_v2i16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11380    else if (unlikely(((bits & 0xff000) == 0xd6000)))
11381        bi_disasm_add_lea_tex_imm(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11382    else if (unlikely(((bits & 0xfefc0) == 0xbc640)))
11383        bi_disasm_add_hadd_s32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11384    else if (unlikely(((bits & 0xfefc0) == 0xbc6c0)))
11385        bi_disasm_add_hadd_u32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11386    else if (unlikely(((bits & 0xfefc0) == 0xbc440)))
11387        bi_disasm_add_hadd_v4s8(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11388    else if (unlikely(((bits & 0xfefc0) == 0xbc4c0)))
11389        bi_disasm_add_hadd_v4u8(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11390    else if (unlikely(((bits & 0xfe9c0) == 0xbc840)))
11391        bi_disasm_add_hadd_v2s16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11392    else if (unlikely(((bits & 0xfe9c0) == 0xbc8c0)))
11393        bi_disasm_add_hadd_v2u16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11394    else if (unlikely(((bits & 0xfe800) == 0x78000)))
11395        bi_disasm_add_icmp_v2s16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11396    else if (unlikely(((bits & 0xfe800) == 0x78800)))
11397        bi_disasm_add_icmp_v2u16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11398    else if (unlikely(((bits & 0xfe600) == 0xc4400)))
11399        bi_disasm_add_ld_attr_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11400    else if (unlikely(((bits & 0xfe600) == 0xc4600)))
11401        bi_disasm_add_ld_attr_tex_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11402    else if (unlikely(((bits & 0xfe400) == 0xc4000)))
11403        bi_disasm_add_ld_attr_imm_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11404    else if (unlikely(((bits & 0xfe000) == 0x76000)))
11405        bi_disasm_add_v2f32_to_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11406    else if (unlikely(((bits & 0xfc600) == 0xc0400)))
11407        bi_disasm_add_lea_attr_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11408    else if (unlikely(((bits & 0xfc600) == 0xc0600)))
11409        bi_disasm_add_lea_attr_tex_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11410    else if (unlikely(((bits & 0xfc400) == 0xc0000)))
11411        bi_disasm_add_lea_attr_imm_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11412    else if (unlikely(((bits & 0xfc3e0) == 0xcc0a0)
11413        && !(0x2 & (1 << _BITS(bits, 3, 2)))
11414        && !(0xc0e0 & (1 << _BITS(bits, 10, 4)))
11415    ))
11416        bi_disasm_add_ld_var_special_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11417    else if (unlikely(((bits & 0xfc0c0) == 0xcc0c0)
11418        && !(0xc0e0 & (1 << _BITS(bits, 10, 4)))
11419    ))
11420        bi_disasm_add_ld_var_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11421    else if (unlikely(((bits & 0xfc000) == 0x7c000)))
11422        bi_disasm_add_clper_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11423    else if (unlikely(((bits & 0xfc000) == 0xcc000)
11424        && !(0xc0e0 & (1 << _BITS(bits, 10, 4)))
11425    ))
11426        bi_disasm_add_ld_var_imm_1(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11427    else if (unlikely(((bits & 0xfc000) == 0x70000)))
11428        bi_disasm_add_mux_v2i16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11429    else if (unlikely(((bits & 0xfc000) == 0xd8000)))
11430        bi_disasm_add_texs_2d_f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11431    else if (unlikely(((bits & 0xfc000) == 0x58000)))
11432        bi_disasm_add_texs_2d_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11433    else if (unlikely(((bits & 0xfc000) == 0xdc000)))
11434        bi_disasm_add_texs_cube_f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11435    else if (unlikely(((bits & 0xfc000) == 0x5c000)))
11436        bi_disasm_add_texs_cube_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11437    else if (unlikely(((bits & 0xf8000) == 0x68000)
11438        && !(0xe1 & (1 << _BITS(bits, 12, 3)))
11439        && !(0xf & (1 << _BITS(bits, 9, 3)))
11440    ))
11441        bi_disasm_add_branch_f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11442    else if (unlikely(((bits & 0xf8000) == 0x68000)
11443        && !(0x9e & (1 << _BITS(bits, 12, 3)))
11444        && !(0x1 & (1 << _BITS(bits, 9, 3)))
11445    ))
11446        bi_disasm_add_branch_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11447    else if (unlikely(((bits & 0xf8000) == 0x68000)
11448        && !(0xe1 & (1 << _BITS(bits, 12, 3)))
11449        && !(0xed & (1 << _BITS(bits, 9, 3)))
11450    ))
11451        bi_disasm_add_branch_i16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11452    else if (unlikely(((bits & 0xf8000) == 0x68000)
11453        && !(0xfe & (1 << _BITS(bits, 12, 3)))
11454        && !(0xed & (1 << _BITS(bits, 9, 3)))
11455    ))
11456        bi_disasm_add_branch_i32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11457    else if (unlikely(((bits & 0xf8000) == 0x68000)
11458        && !(0xe9 & (1 << _BITS(bits, 12, 3)))
11459        && !(0xe0 & (1 << _BITS(bits, 9, 3)))
11460    ))
11461        bi_disasm_add_branch_s16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11462    else if (unlikely(((bits & 0xf8000) == 0x68000)
11463        && !(0xfe & (1 << _BITS(bits, 12, 3)))
11464        && !(0xe0 & (1 << _BITS(bits, 9, 3)))
11465    ))
11466        bi_disasm_add_branch_s32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11467    else if (unlikely(((bits & 0xf8000) == 0x68000)
11468        && !(0xf1 & (1 << _BITS(bits, 12, 3)))
11469        && !(0xf0 & (1 << _BITS(bits, 9, 3)))
11470    ))
11471        bi_disasm_add_branch_u16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11472    else if (unlikely(((bits & 0xf8000) == 0x68000)
11473        && !(0xfe & (1 << _BITS(bits, 12, 3)))
11474        && !(0xf0 & (1 << _BITS(bits, 9, 3)))
11475    ))
11476        bi_disasm_add_branch_u32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11477    else if (unlikely(((bits & 0xf8000) == 0x80000)))
11478        bi_disasm_add_fmax_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11479    else if (unlikely(((bits & 0xf8000) == 0x90000)))
11480        bi_disasm_add_fmin_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11481    else if (unlikely(((bits & 0xf0600) == 0x0)))
11482        bi_disasm_add_fmax_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11483    else if (unlikely(((bits & 0xf0600) == 0x10000)))
11484        bi_disasm_add_fmin_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11485    else if (unlikely(((bits & 0xf0600) == 0x40400)))
11486        bi_disasm_add_ld_attr_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11487    else if (unlikely(((bits & 0xf0600) == 0x40600)))
11488        bi_disasm_add_ld_attr_tex_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11489    else if (unlikely(((bits & 0xf0400) == 0x40000)))
11490        bi_disasm_add_ld_attr_imm_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11491    else if (unlikely(((bits & 0xf0000) == 0x20000)))
11492        bi_disasm_add_fadd_f32_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11493    else if (unlikely(((bits & 0xf0000) == 0xa0000)))
11494        bi_disasm_add_fadd_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11495    else if (unlikely(((bits & 0xf0000) == 0x30000)))
11496        bi_disasm_add_fcmp_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11497    else if (unlikely(((bits & 0xf0000) == 0xb0000)))
11498        bi_disasm_add_fcmp_v2f16(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11499    else if (unlikely(((bits & 0xe8000) == 0x88000)
11500        && !(0x2 & (1 << _BITS(bits, 9, 3)))
11501    ))
11502        bi_disasm_add_fadd_rscale_f32(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11503    else if (unlikely(((bits & 0x7f8c0) == 0x538c0)))
11504        bi_disasm_add_ld_var_flat_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11505    else if (unlikely(((bits & 0x7f800) == 0x53800)))
11506        bi_disasm_add_ld_var_flat_imm_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11507    else if (unlikely(((bits & 0x7c3e0) == 0x500a0)
11508        && !(0x2 & (1 << _BITS(bits, 3, 2)))
11509        && !(0xc0e0 & (1 << _BITS(bits, 10, 4)))
11510    ))
11511        bi_disasm_add_ld_var_special_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11512    else if (unlikely(((bits & 0x7c0c0) == 0x500c0)
11513        && !(0xc0e0 & (1 << _BITS(bits, 10, 4)))
11514    ))
11515        bi_disasm_add_ld_var_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11516    else if (unlikely(((bits & 0x7c000) == 0x50000)
11517        && !(0xc0e0 & (1 << _BITS(bits, 10, 4)))
11518    ))
11519        bi_disasm_add_ld_var_imm_0(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, last);
11520    else
11521        fprintf(fp, "INSTR_INVALID_ENC add %X", bits);
11522
11523    fputs("\n", fp);
11524}
11525