2 * Copyright (c) 2013 Rob Clark <robdclark@gmail.com>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 #include <util/u_debug.h>
33 #include "instr-a3xx.h"
35 /* bitmask of debug flags */
37 PRINT_RAW
= 0x1, /* dump raw hexdump */
42 static enum debug_t debug
;
44 #define printf debug_printf
46 static const char *levels
[] = {
65 static const char *component
= "xyzw";
67 static const char *type
[] = {
83 /* current instruction repeat flag: */
85 /* current instruction repeat indx/offset (for --expand): */
89 static void print_reg(struct disasm_ctx
*ctx
, reg_t reg
, bool full
, bool r
,
90 bool c
, bool im
, bool neg
, bool abs
, bool addr_rel
)
92 const char type
= c
? 'c' : 'r';
94 // XXX I prefer - and || for neg/abs, but preserving format used
95 // by libllvm-a3xx for easy diffing..
98 fprintf(ctx
->out
, "(absneg)");
100 fprintf(ctx
->out
, "(neg)");
102 fprintf(ctx
->out
, "(abs)");
105 fprintf(ctx
->out
, "(r)");
108 fprintf(ctx
->out
, "%d", reg
.iim_val
);
109 } else if (addr_rel
) {
110 /* I would just use %+d but trying to make it diff'able with
114 fprintf(ctx
->out
, "%s%c<a0.x - %d>", full
? "" : "h", type
, -reg
.iim_val
);
115 else if (reg
.iim_val
> 0)
116 fprintf(ctx
->out
, "%s%c<a0.x + %d>", full
? "" : "h", type
, reg
.iim_val
);
118 fprintf(ctx
->out
, "%s%c<a0.x>", full
? "" : "h", type
);
119 } else if ((reg
.num
== REG_A0
) && !c
) {
120 /* This matches libllvm output, the second (scalar) address register
121 * seems to be called a1.x instead of a0.y.
123 fprintf(ctx
->out
, "a%d.x", reg
.comp
);
124 } else if ((reg
.num
== REG_P0
) && !c
) {
125 fprintf(ctx
->out
, "p0.%c", component
[reg
.comp
]);
127 fprintf(ctx
->out
, "%s%c%d.%c", full
? "" : "h", type
, reg
.num
, component
[reg
.comp
]);
131 static unsigned regidx(reg_t reg
)
133 return (4 * reg
.num
) + reg
.comp
;
136 static reg_t
idxreg(unsigned idx
)
144 static void print_reg_dst(struct disasm_ctx
*ctx
, reg_t reg
, bool full
, bool addr_rel
)
146 reg
= idxreg(regidx(reg
) + ctx
->repeatidx
);
147 print_reg(ctx
, reg
, full
, false, false, false, false, false, addr_rel
);
150 static void print_reg_src(struct disasm_ctx
*ctx
, reg_t reg
, bool full
, bool r
,
151 bool c
, bool im
, bool neg
, bool abs
, bool addr_rel
)
154 reg
= idxreg(regidx(reg
) + ctx
->repeatidx
);
156 print_reg(ctx
, reg
, full
, r
, c
, im
, neg
, abs
, addr_rel
);
159 /* TODO switch to using reginfo struct everywhere, since more readable
160 * than passing a bunch of bools to print_reg_src
174 static void print_src(struct disasm_ctx
*ctx
, struct reginfo
*info
)
176 print_reg_src(ctx
, info
->reg
, info
->full
, info
->r
, info
->c
, info
->im
,
177 info
->neg
, info
->abs
, info
->addr_rel
);
180 //static void print_dst(struct disasm_ctx *ctx, struct reginfo *info)
182 // print_reg_dst(ctx, info->reg, info->full, info->addr_rel);
185 static void print_instr_cat0(struct disasm_ctx
*ctx
, instr_t
*instr
)
187 instr_cat0_t
*cat0
= &instr
->cat0
;
192 fprintf(ctx
->out
, " %sp0.%c", cat0
->inv
? "!" : "",
193 component
[cat0
->comp
]);
196 fprintf(ctx
->out
, " %sp0.%c, #%d", cat0
->inv
? "!" : "",
197 component
[cat0
->comp
], cat0
->a3xx
.immed
);
201 fprintf(ctx
->out
, " #%d", cat0
->a3xx
.immed
);
205 if ((debug
& PRINT_VERBOSE
) && (cat0
->dummy2
|cat0
->dummy3
|cat0
->dummy4
))
206 fprintf(ctx
->out
, "\t{0: %x,%x,%x}", cat0
->dummy2
, cat0
->dummy3
, cat0
->dummy4
);
209 static void print_instr_cat1(struct disasm_ctx
*ctx
, instr_t
*instr
)
211 instr_cat1_t
*cat1
= &instr
->cat1
;
214 fprintf(ctx
->out
, "(ul)");
216 if (cat1
->src_type
== cat1
->dst_type
) {
217 if ((cat1
->src_type
== TYPE_S16
) && (((reg_t
)cat1
->dst
).num
== REG_A0
)) {
218 /* special case (nmemonic?): */
219 fprintf(ctx
->out
, "mova");
221 fprintf(ctx
->out
, "mov.%s%s", type
[cat1
->src_type
], type
[cat1
->dst_type
]);
224 fprintf(ctx
->out
, "cov.%s%s", type
[cat1
->src_type
], type
[cat1
->dst_type
]);
227 fprintf(ctx
->out
, " ");
230 fprintf(ctx
->out
, "(even)");
233 fprintf(ctx
->out
, "(pos_infinity)");
235 print_reg_dst(ctx
, (reg_t
)(cat1
->dst
), type_size(cat1
->dst_type
) == 32,
238 fprintf(ctx
->out
, ", ");
240 /* ugg, have to special case this.. vs print_reg().. */
242 if (type_float(cat1
->src_type
))
243 fprintf(ctx
->out
, "(%f)", cat1
->fim_val
);
244 else if (type_uint(cat1
->src_type
))
245 fprintf(ctx
->out
, "0x%08x", cat1
->uim_val
);
247 fprintf(ctx
->out
, "%d", cat1
->iim_val
);
248 } else if (cat1
->src_rel
&& !cat1
->src_c
) {
249 /* I would just use %+d but trying to make it diff'able with
252 char type
= cat1
->src_rel_c
? 'c' : 'r';
253 const char *full
= (type_size(cat1
->src_type
) == 32) ? "" : "h";
255 fprintf(ctx
->out
, "%s%c<a0.x - %d>", full
, type
, -cat1
->off
);
256 else if (cat1
->off
> 0)
257 fprintf(ctx
->out
, "%s%c<a0.x + %d>", full
, type
, cat1
->off
);
259 fprintf(ctx
->out
, "%s%c<a0.x>", full
, type
);
261 print_reg_src(ctx
, (reg_t
)(cat1
->src
), type_size(cat1
->src_type
) == 32,
262 cat1
->src_r
, cat1
->src_c
, cat1
->src_im
, false, false, false);
265 if ((debug
& PRINT_VERBOSE
) && (cat1
->must_be_0
))
266 fprintf(ctx
->out
, "\t{1: %x}", cat1
->must_be_0
);
269 static void print_instr_cat2(struct disasm_ctx
*ctx
, instr_t
*instr
)
271 instr_cat2_t
*cat2
= &instr
->cat2
;
272 static const char *cond
[] = {
282 switch (_OPC(2, cat2
->opc
)) {
289 fprintf(ctx
->out
, ".%s", cond
[cat2
->cond
]);
293 fprintf(ctx
->out
, " ");
295 fprintf(ctx
->out
, "(ei)");
296 print_reg_dst(ctx
, (reg_t
)(cat2
->dst
), cat2
->full
^ cat2
->dst_half
, false);
297 fprintf(ctx
->out
, ", ");
299 unsigned src1_r
= cat2
->repeat
? cat2
->src1_r
: 0;
300 if (cat2
->c1
.src1_c
) {
301 print_reg_src(ctx
, (reg_t
)(cat2
->c1
.src1
), cat2
->full
, src1_r
,
302 cat2
->c1
.src1_c
, cat2
->src1_im
, cat2
->src1_neg
,
303 cat2
->src1_abs
, false);
304 } else if (cat2
->rel1
.src1_rel
) {
305 print_reg_src(ctx
, (reg_t
)(cat2
->rel1
.src1
), cat2
->full
, src1_r
,
306 cat2
->rel1
.src1_c
, cat2
->src1_im
, cat2
->src1_neg
,
307 cat2
->src1_abs
, cat2
->rel1
.src1_rel
);
309 print_reg_src(ctx
, (reg_t
)(cat2
->src1
), cat2
->full
, src1_r
,
310 false, cat2
->src1_im
, cat2
->src1_neg
,
311 cat2
->src1_abs
, false);
314 unsigned src2_r
= cat2
->repeat
? cat2
->src2_r
: 0;
315 switch (_OPC(2, cat2
->opc
)) {
330 /* these only have one src reg */
333 fprintf(ctx
->out
, ", ");
334 if (cat2
->c2
.src2_c
) {
335 print_reg_src(ctx
, (reg_t
)(cat2
->c2
.src2
), cat2
->full
, src2_r
,
336 cat2
->c2
.src2_c
, cat2
->src2_im
, cat2
->src2_neg
,
337 cat2
->src2_abs
, false);
338 } else if (cat2
->rel2
.src2_rel
) {
339 print_reg_src(ctx
, (reg_t
)(cat2
->rel2
.src2
), cat2
->full
, src2_r
,
340 cat2
->rel2
.src2_c
, cat2
->src2_im
, cat2
->src2_neg
,
341 cat2
->src2_abs
, cat2
->rel2
.src2_rel
);
343 print_reg_src(ctx
, (reg_t
)(cat2
->src2
), cat2
->full
, src2_r
,
344 false, cat2
->src2_im
, cat2
->src2_neg
,
345 cat2
->src2_abs
, false);
351 static void print_instr_cat3(struct disasm_ctx
*ctx
, instr_t
*instr
)
353 instr_cat3_t
*cat3
= &instr
->cat3
;
354 bool full
= instr_cat3_full(cat3
);
356 fprintf(ctx
->out
, " ");
357 print_reg_dst(ctx
, (reg_t
)(cat3
->dst
), full
^ cat3
->dst_half
, false);
358 fprintf(ctx
->out
, ", ");
359 unsigned src1_r
= cat3
->repeat
? cat3
->src1_r
: 0;
360 if (cat3
->c1
.src1_c
) {
361 print_reg_src(ctx
, (reg_t
)(cat3
->c1
.src1
), full
,
362 src1_r
, cat3
->c1
.src1_c
, false, cat3
->src1_neg
,
364 } else if (cat3
->rel1
.src1_rel
) {
365 print_reg_src(ctx
, (reg_t
)(cat3
->rel1
.src1
), full
,
366 src1_r
, cat3
->rel1
.src1_c
, false, cat3
->src1_neg
,
367 false, cat3
->rel1
.src1_rel
);
369 print_reg_src(ctx
, (reg_t
)(cat3
->src1
), full
,
370 src1_r
, false, false, cat3
->src1_neg
,
373 fprintf(ctx
->out
, ", ");
374 unsigned src2_r
= cat3
->repeat
? cat3
->src2_r
: 0;
375 print_reg_src(ctx
, (reg_t
)cat3
->src2
, full
,
376 src2_r
, cat3
->src2_c
, false, cat3
->src2_neg
,
378 fprintf(ctx
->out
, ", ");
379 if (cat3
->c2
.src3_c
) {
380 print_reg_src(ctx
, (reg_t
)(cat3
->c2
.src3
), full
,
381 cat3
->src3_r
, cat3
->c2
.src3_c
, false, cat3
->src3_neg
,
383 } else if (cat3
->rel2
.src3_rel
) {
384 print_reg_src(ctx
, (reg_t
)(cat3
->rel2
.src3
), full
,
385 cat3
->src3_r
, cat3
->rel2
.src3_c
, false, cat3
->src3_neg
,
386 false, cat3
->rel2
.src3_rel
);
388 print_reg_src(ctx
, (reg_t
)(cat3
->src3
), full
,
389 cat3
->src3_r
, false, false, cat3
->src3_neg
,
394 static void print_instr_cat4(struct disasm_ctx
*ctx
, instr_t
*instr
)
396 instr_cat4_t
*cat4
= &instr
->cat4
;
398 fprintf(ctx
->out
, " ");
399 print_reg_dst(ctx
, (reg_t
)(cat4
->dst
), cat4
->full
^ cat4
->dst_half
, false);
400 fprintf(ctx
->out
, ", ");
403 print_reg_src(ctx
, (reg_t
)(cat4
->c
.src
), cat4
->full
,
404 cat4
->src_r
, cat4
->c
.src_c
, cat4
->src_im
,
405 cat4
->src_neg
, cat4
->src_abs
, false);
406 } else if (cat4
->rel
.src_rel
) {
407 print_reg_src(ctx
, (reg_t
)(cat4
->rel
.src
), cat4
->full
,
408 cat4
->src_r
, cat4
->rel
.src_c
, cat4
->src_im
,
409 cat4
->src_neg
, cat4
->src_abs
, cat4
->rel
.src_rel
);
411 print_reg_src(ctx
, (reg_t
)(cat4
->src
), cat4
->full
,
412 cat4
->src_r
, false, cat4
->src_im
,
413 cat4
->src_neg
, cat4
->src_abs
, false);
416 if ((debug
& PRINT_VERBOSE
) && (cat4
->dummy1
|cat4
->dummy2
))
417 fprintf(ctx
->out
, "\t{4: %x,%x}", cat4
->dummy1
, cat4
->dummy2
);
420 static void print_instr_cat5(struct disasm_ctx
*ctx
, instr_t
*instr
)
422 static const struct {
423 bool src1
, src2
, samp
, tex
;
425 [opc_op(OPC_ISAM
)] = { true, false, true, true, },
426 [opc_op(OPC_ISAML
)] = { true, true, true, true, },
427 [opc_op(OPC_ISAMM
)] = { true, false, true, true, },
428 [opc_op(OPC_SAM
)] = { true, false, true, true, },
429 [opc_op(OPC_SAMB
)] = { true, true, true, true, },
430 [opc_op(OPC_SAML
)] = { true, true, true, true, },
431 [opc_op(OPC_SAMGQ
)] = { true, false, true, true, },
432 [opc_op(OPC_GETLOD
)] = { true, false, true, true, },
433 [opc_op(OPC_CONV
)] = { true, true, true, true, },
434 [opc_op(OPC_CONVM
)] = { true, true, true, true, },
435 [opc_op(OPC_GETSIZE
)] = { true, false, false, true, },
436 [opc_op(OPC_GETBUF
)] = { false, false, false, true, },
437 [opc_op(OPC_GETPOS
)] = { true, false, false, true, },
438 [opc_op(OPC_GETINFO
)] = { false, false, false, true, },
439 [opc_op(OPC_DSX
)] = { true, false, false, false, },
440 [opc_op(OPC_DSY
)] = { true, false, false, false, },
441 [opc_op(OPC_GATHER4R
)] = { true, false, true, true, },
442 [opc_op(OPC_GATHER4G
)] = { true, false, true, true, },
443 [opc_op(OPC_GATHER4B
)] = { true, false, true, true, },
444 [opc_op(OPC_GATHER4A
)] = { true, false, true, true, },
445 [opc_op(OPC_SAMGP0
)] = { true, false, true, true, },
446 [opc_op(OPC_SAMGP1
)] = { true, false, true, true, },
447 [opc_op(OPC_SAMGP2
)] = { true, false, true, true, },
448 [opc_op(OPC_SAMGP3
)] = { true, false, true, true, },
449 [opc_op(OPC_DSXPP_1
)] = { true, false, false, false, },
450 [opc_op(OPC_DSYPP_1
)] = { true, false, false, false, },
451 [opc_op(OPC_RGETPOS
)] = { true, false, false, false, },
452 [opc_op(OPC_RGETINFO
)] = { false, false, false, false, },
455 static const struct {
460 } desc_features
[8] = {
461 [CAT5_NONUNIFORM
] = { .indirect
= true, },
462 [CAT5_UNIFORM
] = { .indirect
= true, .uniform
= true, },
463 [CAT5_BINDLESS_IMM
] = { .bindless
= true, },
464 [CAT5_BINDLESS_UNIFORM
] = {
469 [CAT5_BINDLESS_NONUNIFORM
] = {
473 [CAT5_BINDLESS_A1_IMM
] = {
477 [CAT5_BINDLESS_A1_UNIFORM
] = {
483 [CAT5_BINDLESS_A1_NONUNIFORM
] = {
490 instr_cat5_t
*cat5
= &instr
->cat5
;
494 cat5
->is_s2en_bindless
&&
495 desc_features
[cat5
->s2en_bindless
.desc_mode
].indirect
;
497 cat5
->is_s2en_bindless
&&
498 desc_features
[cat5
->s2en_bindless
.desc_mode
].bindless
;
500 cat5
->is_s2en_bindless
&&
501 desc_features
[cat5
->s2en_bindless
.desc_mode
].use_a1
;
503 cat5
->is_s2en_bindless
&&
504 desc_features
[cat5
->s2en_bindless
.desc_mode
].uniform
;
506 if (cat5
->is_3d
) fprintf(ctx
->out
, ".3d");
507 if (cat5
->is_a
) fprintf(ctx
->out
, ".a");
508 if (cat5
->is_o
) fprintf(ctx
->out
, ".o");
509 if (cat5
->is_p
) fprintf(ctx
->out
, ".p");
510 if (cat5
->is_s
) fprintf(ctx
->out
, ".s");
511 if (desc_indirect
) fprintf(ctx
->out
, ".s2en");
512 if (uniform
) fprintf(ctx
->out
, ".uniform");
515 unsigned base
= (cat5
->s2en_bindless
.base_hi
<< 1) | cat5
->base_lo
;
516 fprintf(ctx
->out
, ".base%d", base
);
519 fprintf(ctx
->out
, " ");
521 switch (_OPC(5, cat5
->opc
)) {
526 fprintf(ctx
->out
, "(%s)", type
[cat5
->type
]);
530 fprintf(ctx
->out
, "(");
531 for (i
= 0; i
< 4; i
++)
532 if (cat5
->wrmask
& (1 << i
))
533 fprintf(ctx
->out
, "%c", "xyzw"[i
]);
534 fprintf(ctx
->out
, ")");
536 print_reg_dst(ctx
, (reg_t
)(cat5
->dst
), type_size(cat5
->type
) == 32, false);
538 if (info
[cat5
->opc
].src1
) {
539 fprintf(ctx
->out
, ", ");
540 print_reg_src(ctx
, (reg_t
)(cat5
->src1
), cat5
->full
, false, false, false,
541 false, false, false);
544 if (cat5
->is_o
|| info
[cat5
->opc
].src2
) {
545 fprintf(ctx
->out
, ", ");
546 print_reg_src(ctx
, (reg_t
)(cat5
->src2
), cat5
->full
,
547 false, false, false, false, false, false);
549 if (cat5
->is_s2en_bindless
) {
550 if (!desc_indirect
) {
551 if (info
[cat5
->opc
].samp
) {
553 fprintf(ctx
->out
, ", s#%d", cat5
->s2en_bindless
.src3
);
555 fprintf(ctx
->out
, ", s#%d", cat5
->s2en_bindless
.src3
& 0xf);
558 if (info
[cat5
->opc
].tex
&& !use_a1
) {
559 fprintf(ctx
->out
, ", t#%d", cat5
->s2en_bindless
.src3
>> 4);
563 if (info
[cat5
->opc
].samp
)
564 fprintf(ctx
->out
, ", s#%d", cat5
->norm
.samp
);
565 if (info
[cat5
->opc
].tex
)
566 fprintf(ctx
->out
, ", t#%d", cat5
->norm
.tex
);
570 fprintf(ctx
->out
, ", ");
571 print_reg_src(ctx
, (reg_t
)(cat5
->s2en_bindless
.src3
), bindless
,
572 false, false, false, false, false, false);
576 fprintf(ctx
->out
, ", a1.x");
578 if (debug
& PRINT_VERBOSE
) {
579 if (cat5
->is_s2en_bindless
) {
580 if ((debug
& PRINT_VERBOSE
) && cat5
->s2en_bindless
.dummy1
)
581 fprintf(ctx
->out
, "\t{5: %x}", cat5
->s2en_bindless
.dummy1
);
583 if ((debug
& PRINT_VERBOSE
) && cat5
->norm
.dummy1
)
584 fprintf(ctx
->out
, "\t{5: %x}", cat5
->norm
.dummy1
);
589 static void print_instr_cat6_a3xx(struct disasm_ctx
*ctx
, instr_t
*instr
)
591 instr_cat6_t
*cat6
= &instr
->cat6
;
592 char sd
= 0, ss
= 0; /* dst/src address space */
594 struct reginfo dst
, src1
, src2
;
595 int src1off
= 0, dstoff
= 0;
597 memset(&dst
, 0, sizeof(dst
));
598 memset(&src1
, 0, sizeof(src1
));
599 memset(&src2
, 0, sizeof(src2
));
601 switch (_OPC(6, cat6
->opc
)) {
604 dst
.full
= type_size(cat6
->type
) == 32;
605 src1
.full
= type_size(cat6
->type
) == 32;
606 src2
.full
= type_size(cat6
->type
) == 32;
620 src1
.full
= type_size(cat6
->type
) == 32;
621 src2
.full
= type_size(cat6
->type
) == 32;
624 dst
.full
= type_size(cat6
->type
) == 32;
630 switch (_OPC(6, cat6
->opc
)) {
634 fprintf(ctx
->out
, ".%dd", cat6
->ldgb
.d
+ 1);
637 fprintf(ctx
->out
, ".%s", cat6
->ldgb
.typed
? "typed" : "untyped");
638 fprintf(ctx
->out
, ".%dd", cat6
->ldgb
.d
+ 1);
639 fprintf(ctx
->out
, ".%s", type
[cat6
->type
]);
640 fprintf(ctx
->out
, ".%d", cat6
->ldgb
.type_size
+ 1);
644 fprintf(ctx
->out
, ".%s", cat6
->stgb
.typed
? "typed" : "untyped");
645 fprintf(ctx
->out
, ".%dd", cat6
->stgb
.d
+ 1);
646 fprintf(ctx
->out
, ".%s", type
[cat6
->type
]);
647 fprintf(ctx
->out
, ".%d", cat6
->stgb
.type_size
+ 1);
651 case OPC_ATOMIC_XCHG
:
654 case OPC_ATOMIC_CMPXCHG
:
660 ss
= cat6
->g
? 'g' : 'l';
661 fprintf(ctx
->out
, ".%s", cat6
->ldgb
.typed
? "typed" : "untyped");
662 fprintf(ctx
->out
, ".%dd", cat6
->ldgb
.d
+ 1);
663 fprintf(ctx
->out
, ".%s", type
[cat6
->type
]);
664 fprintf(ctx
->out
, ".%d", cat6
->ldgb
.type_size
+ 1);
665 fprintf(ctx
->out
, ".%c", ss
);
668 dst
.im
= cat6
->g
&& !cat6
->dst_off
;
669 fprintf(ctx
->out
, ".%s", type
[cat6
->type
]);
672 fprintf(ctx
->out
, " ");
674 switch (_OPC(6, cat6
->opc
)) {
715 if ((_OPC(6, cat6
->opc
) == OPC_STGB
) || (_OPC(6, cat6
->opc
) == OPC_STIB
)) {
718 memset(&src3
, 0, sizeof(src3
));
720 src1
.reg
= (reg_t
)(cat6
->stgb
.src1
);
721 src2
.reg
= (reg_t
)(cat6
->stgb
.src2
);
722 src2
.im
= cat6
->stgb
.src2_im
;
723 src3
.reg
= (reg_t
)(cat6
->stgb
.src3
);
724 src3
.im
= cat6
->stgb
.src3_im
;
727 fprintf(ctx
->out
, "g[%u], ", cat6
->stgb
.dst_ssbo
);
728 print_src(ctx
, &src1
);
729 fprintf(ctx
->out
, ", ");
730 print_src(ctx
, &src2
);
731 fprintf(ctx
->out
, ", ");
732 print_src(ctx
, &src3
);
734 if (debug
& PRINT_VERBOSE
)
735 fprintf(ctx
->out
, " (pad0=%x, pad3=%x)", cat6
->stgb
.pad0
, cat6
->stgb
.pad3
);
740 if (is_atomic(_OPC(6, cat6
->opc
))) {
742 src1
.reg
= (reg_t
)(cat6
->ldgb
.src1
);
743 src1
.im
= cat6
->ldgb
.src1_im
;
744 src2
.reg
= (reg_t
)(cat6
->ldgb
.src2
);
745 src2
.im
= cat6
->ldgb
.src2_im
;
746 dst
.reg
= (reg_t
)(cat6
->ldgb
.dst
);
748 print_src(ctx
, &dst
);
749 fprintf(ctx
->out
, ", ");
752 memset(&src3
, 0, sizeof(src3
));
754 src3
.reg
= (reg_t
)(cat6
->ldgb
.src3
);
757 /* For images, the ".typed" variant is used and src2 is
758 * the ivecN coordinates, ie ivec2 for 2d.
760 * For SSBOs, the ".untyped" variant is used and src2 is
761 * a simple dword offset.. src3 appears to be
762 * uvec2(offset * 4, 0). Not sure the point of that.
765 fprintf(ctx
->out
, "g[%u], ", cat6
->ldgb
.src_ssbo
);
766 print_src(ctx
, &src1
); /* value */
767 fprintf(ctx
->out
, ", ");
768 print_src(ctx
, &src2
); /* offset/coords */
769 fprintf(ctx
->out
, ", ");
770 print_src(ctx
, &src3
); /* 64b byte offset.. */
772 if (debug
& PRINT_VERBOSE
) {
773 fprintf(ctx
->out
, " (pad0=%x, pad3=%x, mustbe0=%x)", cat6
->ldgb
.pad0
,
774 cat6
->ldgb
.pad3
, cat6
->ldgb
.mustbe0
);
776 } else { /* ss == 'l' */
777 fprintf(ctx
->out
, "l[");
778 print_src(ctx
, &src1
); /* simple byte offset */
779 fprintf(ctx
->out
, "], ");
780 print_src(ctx
, &src2
); /* value */
782 if (debug
& PRINT_VERBOSE
) {
783 fprintf(ctx
->out
, " (src3=%x, pad0=%x, pad3=%x, mustbe0=%x)",
784 cat6
->ldgb
.src3
, cat6
->ldgb
.pad0
,
785 cat6
->ldgb
.pad3
, cat6
->ldgb
.mustbe0
);
790 } else if (_OPC(6, cat6
->opc
) == OPC_RESINFO
) {
791 dst
.reg
= (reg_t
)(cat6
->ldgb
.dst
);
793 print_src(ctx
, &dst
);
794 fprintf(ctx
->out
, ", ");
795 fprintf(ctx
->out
, "g[%u]", cat6
->ldgb
.src_ssbo
);
798 } else if (_OPC(6, cat6
->opc
) == OPC_LDGB
) {
800 src1
.reg
= (reg_t
)(cat6
->ldgb
.src1
);
801 src1
.im
= cat6
->ldgb
.src1_im
;
802 src2
.reg
= (reg_t
)(cat6
->ldgb
.src2
);
803 src2
.im
= cat6
->ldgb
.src2_im
;
804 dst
.reg
= (reg_t
)(cat6
->ldgb
.dst
);
806 print_src(ctx
, &dst
);
807 fprintf(ctx
->out
, ", ");
808 fprintf(ctx
->out
, "g[%u], ", cat6
->ldgb
.src_ssbo
);
809 print_src(ctx
, &src1
);
810 fprintf(ctx
->out
, ", ");
811 print_src(ctx
, &src2
);
813 if (debug
& PRINT_VERBOSE
)
814 fprintf(ctx
->out
, " (pad0=%x, pad3=%x, mustbe0=%x)", cat6
->ldgb
.pad0
, cat6
->ldgb
.pad3
, cat6
->ldgb
.mustbe0
);
817 } else if (_OPC(6, cat6
->opc
) == OPC_LDG
&& cat6
->a
.src1_im
&& cat6
->a
.src2_im
) {
820 memset(&src3
, 0, sizeof(src3
));
821 src1
.reg
= (reg_t
)(cat6
->a
.src1
);
822 src2
.reg
= (reg_t
)(cat6
->a
.src2
);
823 src2
.im
= cat6
->a
.src2_im
;
824 src3
.reg
= (reg_t
)(cat6
->a
.off
);
826 dst
.reg
= (reg_t
)(cat6
->d
.dst
);
828 print_src(ctx
, &dst
);
829 fprintf(ctx
->out
, ", g[");
830 print_src(ctx
, &src1
);
831 fprintf(ctx
->out
, "+");
832 print_src(ctx
, &src3
);
833 fprintf(ctx
->out
, "], ");
834 print_src(ctx
, &src2
);
839 dst
.reg
= (reg_t
)(cat6
->c
.dst
);
840 dstoff
= cat6
->c
.off
;
842 dst
.reg
= (reg_t
)(cat6
->d
.dst
);
846 src1
.reg
= (reg_t
)(cat6
->a
.src1
);
847 src1
.im
= cat6
->a
.src1_im
;
848 src2
.reg
= (reg_t
)(cat6
->a
.src2
);
849 src2
.im
= cat6
->a
.src2_im
;
850 src1off
= cat6
->a
.off
;
852 src1
.reg
= (reg_t
)(cat6
->b
.src1
);
853 src1
.im
= cat6
->b
.src1_im
;
854 src2
.reg
= (reg_t
)(cat6
->b
.src2
);
855 src2
.im
= cat6
->b
.src2_im
;
860 fprintf(ctx
->out
, "%c[", sd
);
861 /* note: dst might actually be a src (ie. address to store to) */
862 print_src(ctx
, &dst
);
863 if (cat6
->dst_off
&& cat6
->g
) {
864 struct reginfo dstoff_reg
= {0};
865 dstoff_reg
.reg
= (reg_t
) cat6
->c
.off
;
866 dstoff_reg
.full
= true;
867 fprintf(ctx
->out
, "+");
868 print_src(ctx
, &dstoff_reg
);
870 fprintf(ctx
->out
, "%+d", dstoff
);
872 fprintf(ctx
->out
, "]");
873 fprintf(ctx
->out
, ", ");
877 fprintf(ctx
->out
, "%c[", ss
);
879 /* can have a larger than normal immed, so hack: */
881 fprintf(ctx
->out
, "%u", src1
.reg
.dummy13
);
883 print_src(ctx
, &src1
);
886 if (cat6
->src_off
&& cat6
->g
)
887 print_src(ctx
, &src2
);
889 fprintf(ctx
->out
, "%+d", src1off
);
891 fprintf(ctx
->out
, "]");
893 switch (_OPC(6, cat6
->opc
)) {
898 fprintf(ctx
->out
, ", ");
899 print_src(ctx
, &src2
);
904 static void print_instr_cat6_a6xx(struct disasm_ctx
*ctx
, instr_t
*instr
)
906 instr_cat6_a6xx_t
*cat6
= &instr
->cat6_a6xx
;
907 struct reginfo src1
, src2
, ssbo
;
908 bool uses_type
= _OPC(6, cat6
->opc
) != OPC_LDC
;
910 static const struct {
914 } desc_features
[8] = {
915 [CAT6_IMM
] = { false },
916 [CAT6_BINDLESS_IMM
] = { .bindless
= true, },
917 [CAT6_BINDLESS_UNIFORM
] = {
922 [CAT6_BINDLESS_NONUNIFORM
] = {
928 bool indirect_ssbo
= desc_features
[cat6
->desc_mode
].indirect
;
929 bool bindless
= desc_features
[cat6
->desc_mode
].bindless
;
930 bool uniform
= desc_features
[cat6
->desc_mode
].uniform
;
933 memset(&src1
, 0, sizeof(src1
));
934 memset(&src2
, 0, sizeof(src2
));
935 memset(&ssbo
, 0, sizeof(ssbo
));
938 fprintf(ctx
->out
, ".%s", cat6
->typed
? "typed" : "untyped");
939 fprintf(ctx
->out
, ".%dd", cat6
->d
+ 1);
940 fprintf(ctx
->out
, ".%s", type
[cat6
->type
]);
942 fprintf(ctx
->out
, ".%u", cat6
->type_size
+ 1);
945 fprintf(ctx
->out
, ".base%d", cat6
->base
);
947 fprintf(ctx
->out
, ".uniform");
948 fprintf(ctx
->out
, " ");
950 src2
.reg
= (reg_t
)(cat6
->src2
);
951 src2
.full
= true; // XXX
952 print_src(ctx
, &src2
);
953 fprintf(ctx
->out
, ", ");
955 src1
.reg
= (reg_t
)(cat6
->src1
);
956 src1
.full
= true; // XXX
957 print_src(ctx
, &src1
);
958 fprintf(ctx
->out
, ", ");
959 ssbo
.reg
= (reg_t
)(cat6
->ssbo
);
960 ssbo
.im
= !indirect_ssbo
;
962 print_src(ctx
, &ssbo
);
964 if (debug
& PRINT_VERBOSE
) {
965 fprintf(ctx
->out
, " (pad1=%x, pad2=%x, pad3=%x, pad4=%x, pad5=%x)",
966 cat6
->pad1
, cat6
->pad2
, cat6
->pad3
, cat6
->pad4
, cat6
->pad5
);
970 static void print_instr_cat6(struct disasm_ctx
*ctx
, instr_t
*instr
)
972 if (!is_cat6_legacy(instr
, ctx
->gpu_id
)) {
973 print_instr_cat6_a6xx(ctx
, instr
);
974 if (debug
& PRINT_VERBOSE
)
975 fprintf(ctx
->out
, " NEW");
977 print_instr_cat6_a3xx(ctx
, instr
);
978 if (debug
& PRINT_VERBOSE
)
979 fprintf(ctx
->out
, " LEGACY");
982 static void print_instr_cat7(struct disasm_ctx
*ctx
, instr_t
*instr
)
984 instr_cat7_t
*cat7
= &instr
->cat7
;
987 fprintf(ctx
->out
, ".g");
989 fprintf(ctx
->out
, ".l");
991 if (_OPC(7, cat7
->opc
) == OPC_FENCE
) {
993 fprintf(ctx
->out
, ".r");
995 fprintf(ctx
->out
, ".w");
999 /* size of largest OPC field of all the instruction categories: */
1002 static const struct opc_info
{
1006 void (*print
)(struct disasm_ctx
*ctx
, instr_t
*instr
);
1007 } opcs
[1 << (3+NOPC_BITS
)] = {
1008 #define OPC(cat, opc, name) [(opc)] = { (cat), (opc), #name, print_instr_cat##cat }
1010 OPC(0, OPC_NOP
, nop
),
1012 OPC(0, OPC_JUMP
, jump
),
1013 OPC(0, OPC_CALL
, call
),
1014 OPC(0, OPC_RET
, ret
),
1015 OPC(0, OPC_KILL
, kill
),
1016 OPC(0, OPC_END
, end
),
1017 OPC(0, OPC_EMIT
, emit
),
1018 OPC(0, OPC_CUT
, cut
),
1019 OPC(0, OPC_CHMASK
, chmask
),
1020 OPC(0, OPC_CHSH
, chsh
),
1021 OPC(0, OPC_FLOW_REV
, flow_rev
),
1023 OPC(0, OPC_ELSE
, else),
1024 OPC(0, OPC_ENDIF
, endif
),
1030 OPC(2, OPC_ADD_F
, add
.f
),
1031 OPC(2, OPC_MIN_F
, min
.f
),
1032 OPC(2, OPC_MAX_F
, max
.f
),
1033 OPC(2, OPC_MUL_F
, mul
.f
),
1034 OPC(2, OPC_SIGN_F
, sign
.f
),
1035 OPC(2, OPC_CMPS_F
, cmps
.f
),
1036 OPC(2, OPC_ABSNEG_F
, absneg
.f
),
1037 OPC(2, OPC_CMPV_F
, cmpv
.f
),
1038 OPC(2, OPC_FLOOR_F
, floor
.f
),
1039 OPC(2, OPC_CEIL_F
, ceil
.f
),
1040 OPC(2, OPC_RNDNE_F
, rndne
.f
),
1041 OPC(2, OPC_RNDAZ_F
, rndaz
.f
),
1042 OPC(2, OPC_TRUNC_F
, trunc
.f
),
1043 OPC(2, OPC_ADD_U
, add
.u
),
1044 OPC(2, OPC_ADD_S
, add
.s
),
1045 OPC(2, OPC_SUB_U
, sub
.u
),
1046 OPC(2, OPC_SUB_S
, sub
.s
),
1047 OPC(2, OPC_CMPS_U
, cmps
.u
),
1048 OPC(2, OPC_CMPS_S
, cmps
.s
),
1049 OPC(2, OPC_MIN_U
, min
.u
),
1050 OPC(2, OPC_MIN_S
, min
.s
),
1051 OPC(2, OPC_MAX_U
, max
.u
),
1052 OPC(2, OPC_MAX_S
, max
.s
),
1053 OPC(2, OPC_ABSNEG_S
, absneg
.s
),
1054 OPC(2, OPC_AND_B
, and.b
),
1055 OPC(2, OPC_OR_B
, or.b
),
1056 OPC(2, OPC_NOT_B
, not.b
),
1057 OPC(2, OPC_XOR_B
, xor.b
),
1058 OPC(2, OPC_CMPV_U
, cmpv
.u
),
1059 OPC(2, OPC_CMPV_S
, cmpv
.s
),
1060 OPC(2, OPC_MUL_U24
, mul
.u24
),
1061 OPC(2, OPC_MUL_S24
, mul
.s24
),
1062 OPC(2, OPC_MULL_U
, mull
.u
),
1063 OPC(2, OPC_BFREV_B
, bfrev
.b
),
1064 OPC(2, OPC_CLZ_S
, clz
.s
),
1065 OPC(2, OPC_CLZ_B
, clz
.b
),
1066 OPC(2, OPC_SHL_B
, shl
.b
),
1067 OPC(2, OPC_SHR_B
, shr
.b
),
1068 OPC(2, OPC_ASHR_B
, ashr
.b
),
1069 OPC(2, OPC_BARY_F
, bary
.f
),
1070 OPC(2, OPC_MGEN_B
, mgen
.b
),
1071 OPC(2, OPC_GETBIT_B
, getbit
.b
),
1072 OPC(2, OPC_SETRM
, setrm
),
1073 OPC(2, OPC_CBITS_B
, cbits
.b
),
1074 OPC(2, OPC_SHB
, shb
),
1075 OPC(2, OPC_MSAD
, msad
),
1078 OPC(3, OPC_MAD_U16
, mad
.u16
),
1079 OPC(3, OPC_MADSH_U16
, madsh
.u16
),
1080 OPC(3, OPC_MAD_S16
, mad
.s16
),
1081 OPC(3, OPC_MADSH_M16
, madsh
.m16
),
1082 OPC(3, OPC_MAD_U24
, mad
.u24
),
1083 OPC(3, OPC_MAD_S24
, mad
.s24
),
1084 OPC(3, OPC_MAD_F16
, mad
.f16
),
1085 OPC(3, OPC_MAD_F32
, mad
.f32
),
1086 OPC(3, OPC_SEL_B16
, sel
.b16
),
1087 OPC(3, OPC_SEL_B32
, sel
.b32
),
1088 OPC(3, OPC_SEL_S16
, sel
.s16
),
1089 OPC(3, OPC_SEL_S32
, sel
.s32
),
1090 OPC(3, OPC_SEL_F16
, sel
.f16
),
1091 OPC(3, OPC_SEL_F32
, sel
.f32
),
1092 OPC(3, OPC_SAD_S16
, sad
.s16
),
1093 OPC(3, OPC_SAD_S32
, sad
.s32
),
1096 OPC(4, OPC_RCP
, rcp
),
1097 OPC(4, OPC_RSQ
, rsq
),
1098 OPC(4, OPC_LOG2
, log2
),
1099 OPC(4, OPC_EXP2
, exp2
),
1100 OPC(4, OPC_SIN
, sin
),
1101 OPC(4, OPC_COS
, cos
),
1102 OPC(4, OPC_SQRT
, sqrt
),
1103 OPC(4, OPC_HRSQ
, hrsq
),
1104 OPC(4, OPC_HLOG2
, hlog2
),
1105 OPC(4, OPC_HEXP2
, hexp2
),
1108 OPC(5, OPC_ISAM
, isam
),
1109 OPC(5, OPC_ISAML
, isaml
),
1110 OPC(5, OPC_ISAMM
, isamm
),
1111 OPC(5, OPC_SAM
, sam
),
1112 OPC(5, OPC_SAMB
, samb
),
1113 OPC(5, OPC_SAML
, saml
),
1114 OPC(5, OPC_SAMGQ
, samgq
),
1115 OPC(5, OPC_GETLOD
, getlod
),
1116 OPC(5, OPC_CONV
, conv
),
1117 OPC(5, OPC_CONVM
, convm
),
1118 OPC(5, OPC_GETSIZE
, getsize
),
1119 OPC(5, OPC_GETBUF
, getbuf
),
1120 OPC(5, OPC_GETPOS
, getpos
),
1121 OPC(5, OPC_GETINFO
, getinfo
),
1122 OPC(5, OPC_DSX
, dsx
),
1123 OPC(5, OPC_DSY
, dsy
),
1124 OPC(5, OPC_GATHER4R
, gather4r
),
1125 OPC(5, OPC_GATHER4G
, gather4g
),
1126 OPC(5, OPC_GATHER4B
, gather4b
),
1127 OPC(5, OPC_GATHER4A
, gather4a
),
1128 OPC(5, OPC_SAMGP0
, samgp0
),
1129 OPC(5, OPC_SAMGP1
, samgp1
),
1130 OPC(5, OPC_SAMGP2
, samgp2
),
1131 OPC(5, OPC_SAMGP3
, samgp3
),
1132 OPC(5, OPC_DSXPP_1
, dsxpp
.1),
1133 OPC(5, OPC_DSYPP_1
, dsypp
.1),
1134 OPC(5, OPC_RGETPOS
, rgetpos
),
1135 OPC(5, OPC_RGETINFO
, rgetinfo
),
1139 OPC(6, OPC_LDG
, ldg
),
1140 OPC(6, OPC_LDL
, ldl
),
1141 OPC(6, OPC_LDP
, ldp
),
1142 OPC(6, OPC_STG
, stg
),
1143 OPC(6, OPC_STL
, stl
),
1144 OPC(6, OPC_STP
, stp
),
1145 OPC(6, OPC_LDIB
, ldib
),
1146 OPC(6, OPC_G2L
, g2l
),
1147 OPC(6, OPC_L2G
, l2g
),
1148 OPC(6, OPC_PREFETCH
, prefetch
),
1149 OPC(6, OPC_LDLW
, ldlw
),
1150 OPC(6, OPC_STLW
, stlw
),
1151 OPC(6, OPC_RESFMT
, resfmt
),
1152 OPC(6, OPC_RESINFO
, resinfo
),
1153 OPC(6, OPC_ATOMIC_ADD
, atomic
.add
),
1154 OPC(6, OPC_ATOMIC_SUB
, atomic
.sub
),
1155 OPC(6, OPC_ATOMIC_XCHG
, atomic
.xchg
),
1156 OPC(6, OPC_ATOMIC_INC
, atomic
.inc
),
1157 OPC(6, OPC_ATOMIC_DEC
, atomic
.dec
),
1158 OPC(6, OPC_ATOMIC_CMPXCHG
, atomic
.cmpxchg
),
1159 OPC(6, OPC_ATOMIC_MIN
, atomic
.min
),
1160 OPC(6, OPC_ATOMIC_MAX
, atomic
.max
),
1161 OPC(6, OPC_ATOMIC_AND
, atomic
.and),
1162 OPC(6, OPC_ATOMIC_OR
, atomic
.or),
1163 OPC(6, OPC_ATOMIC_XOR
, atomic
.xor),
1164 OPC(6, OPC_LDGB
, ldgb
),
1165 OPC(6, OPC_STGB
, stgb
),
1166 OPC(6, OPC_STIB
, stib
),
1167 OPC(6, OPC_LDC
, ldc
),
1168 OPC(6, OPC_LDLV
, ldlv
),
1170 OPC(7, OPC_BAR
, bar
),
1171 OPC(7, OPC_FENCE
, fence
),
1176 #define GETINFO(instr) (&(opcs[((instr)->opc_cat << NOPC_BITS) | instr_opc(instr, ctx->gpu_id)]))
1178 // XXX hack.. probably should move this table somewhere common:
1180 const char *ir3_instr_name(struct ir3_instruction
*instr
)
1182 if (opc_cat(instr
->opc
) == -1) return "??meta??";
1183 return opcs
[instr
->opc
].name
;
1186 static void print_single_instr(struct disasm_ctx
*ctx
, instr_t
*instr
)
1188 const char *name
= GETINFO(instr
)->name
;
1189 uint32_t opc
= instr_opc(instr
, ctx
->gpu_id
);
1192 fprintf(ctx
->out
, "%s", name
);
1193 GETINFO(instr
)->print(ctx
, instr
);
1195 fprintf(ctx
->out
, "unknown(%d,%d)", instr
->opc_cat
, opc
);
1197 switch (instr
->opc_cat
) {
1198 case 0: print_instr_cat0(ctx
, instr
); break;
1199 case 1: print_instr_cat1(ctx
, instr
); break;
1200 case 2: print_instr_cat2(ctx
, instr
); break;
1201 case 3: print_instr_cat3(ctx
, instr
); break;
1202 case 4: print_instr_cat4(ctx
, instr
); break;
1203 case 5: print_instr_cat5(ctx
, instr
); break;
1204 case 6: print_instr_cat6(ctx
, instr
); break;
1205 case 7: print_instr_cat7(ctx
, instr
); break;
1210 static bool print_instr(struct disasm_ctx
*ctx
, uint32_t *dwords
, int n
)
1212 instr_t
*instr
= (instr_t
*)dwords
;
1213 uint32_t opc
= instr_opc(instr
, ctx
->gpu_id
);
1216 if (debug
& PRINT_VERBOSE
)
1217 fprintf(ctx
->out
, "%s%04d[%08xx_%08xx] ", levels
[ctx
->level
], n
, dwords
[1], dwords
[0]);
1219 /* NOTE: order flags are printed is a bit fugly.. but for now I
1220 * try to match the order in llvm-a3xx disassembler for easy
1224 ctx
->repeat
= instr_repeat(instr
);
1227 fprintf(ctx
->out
, "(sy)");
1229 if (instr
->ss
&& ((instr
->opc_cat
<= 4) || (instr
->opc_cat
== 7))) {
1230 fprintf(ctx
->out
, "(ss)");
1233 fprintf(ctx
->out
, "(jp)");
1234 if (instr_sat(instr
))
1235 fprintf(ctx
->out
, "(sat)");
1237 fprintf(ctx
->out
, "(rpt%d)", ctx
->repeat
);
1238 else if ((instr
->opc_cat
== 2) && (instr
->cat2
.src1_r
|| instr
->cat2
.src2_r
))
1239 nop
= (instr
->cat2
.src2_r
* 2) + instr
->cat2
.src1_r
;
1240 else if ((instr
->opc_cat
== 3) && (instr
->cat3
.src1_r
|| instr
->cat3
.src2_r
))
1241 nop
= (instr
->cat3
.src2_r
* 2) + instr
->cat3
.src1_r
;
1243 fprintf(ctx
->out
, "(nop%d)", nop
);
1245 if (instr
->ul
&& ((2 <= instr
->opc_cat
) && (instr
->opc_cat
<= 4)))
1246 fprintf(ctx
->out
, "(ul)");
1248 print_single_instr(ctx
, instr
);
1249 fprintf(ctx
->out
, "\n");
1251 if ((instr
->opc_cat
<= 4) && (debug
& EXPAND_REPEAT
)) {
1253 for (i
= 0; i
< nop
; i
++) {
1254 fprintf(ctx
->out
, "%s%04d[ ] ", levels
[ctx
->level
], n
);
1255 fprintf(ctx
->out
, "nop\n");
1257 for (i
= 0; i
< ctx
->repeat
; i
++) {
1258 ctx
->repeatidx
= i
+ 1;
1259 fprintf(ctx
->out
, "%s%04d[ ] ", levels
[ctx
->level
], n
);
1261 print_single_instr(ctx
, instr
);
1262 fprintf(ctx
->out
, "\n");
1267 return (instr
->opc_cat
== 0) && (opc
== OPC_END
);
1270 int disasm_a3xx(uint32_t *dwords
, int sizedwords
, int level
, FILE *out
, unsigned gpu_id
)
1272 struct disasm_ctx ctx
;
1276 assert((sizedwords
% 2) == 0);
1278 memset(&ctx
, 0, sizeof(ctx
));
1281 ctx
.gpu_id
= gpu_id
;
1283 for (i
= 0; i
< sizedwords
; i
+= 2) {
1284 print_instr(&ctx
, &dwords
[i
], i
/2);
1285 if (dwords
[i
] == 0 && dwords
[i
+ 1] == 0)