• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 Rob Clark <robclark@freedesktop.org>
3  *
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:
10  *
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
13  * Software.
14  *
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
21  * SOFTWARE.
22  *
23  * Authors:
24  *    Rob Clark <robclark@freedesktop.org>
25  */
26 
27 #include <stdarg.h>
28 #include <stdio.h>
29 
30 #include "util/log.h"
31 #include "ir3.h"
32 
33 #define PTRID(x) ((unsigned long)(x))
34 
35 /* ansi escape sequences: */
36 #define RESET   "\x1b[0m"
37 #define RED     "\x1b[0;31m"
38 #define GREEN   "\x1b[0;32m"
39 #define BLUE    "\x1b[0;34m"
40 #define MAGENTA "\x1b[0;35m"
41 
42 /* syntax coloring, mostly to make it easier to see different sorts of
43  * srcs (immediate, constant, ssa, array, ...)
44  */
45 #define SYN_REG(x)   RED x RESET
46 #define SYN_IMMED(x) GREEN x RESET
47 #define SYN_CONST(x) GREEN x RESET
48 #define SYN_SSA(x)   BLUE x RESET
49 #define SYN_ARRAY(x) MAGENTA x RESET
50 
51 static const char *
type_name(type_t type)52 type_name(type_t type)
53 {
54    static const char *type_names[] = {
55       /* clang-format off */
56       [TYPE_F16] = "f16",
57       [TYPE_F32] = "f32",
58       [TYPE_U16] = "u16",
59       [TYPE_U32] = "u32",
60       [TYPE_S16] = "s16",
61       [TYPE_S32] = "s32",
62       [TYPE_U8]  = "u8",
63       [TYPE_S8]  = "s8",
64       /* clang-format on */
65    };
66    return type_names[type];
67 }
68 
69 static void
print_instr_name(struct log_stream * stream,struct ir3_instruction * instr,bool flags)70 print_instr_name(struct log_stream *stream, struct ir3_instruction *instr,
71                  bool flags)
72 {
73    if (!instr)
74       return;
75 #ifdef DEBUG
76    mesa_log_stream_printf(stream, "%04u:", instr->serialno);
77 #endif
78    mesa_log_stream_printf(stream, "%04u:", instr->ip);
79    if (instr->flags & IR3_INSTR_UNUSED) {
80       mesa_log_stream_printf(stream, "XXX: ");
81    } else {
82       mesa_log_stream_printf(stream, "%03u: ", instr->use_count);
83    }
84 
85    if (flags) {
86       mesa_log_stream_printf(stream, "\t");
87       if (instr->flags & IR3_INSTR_SY)
88          mesa_log_stream_printf(stream, "(sy)");
89       if (instr->flags & IR3_INSTR_SS)
90          mesa_log_stream_printf(stream, "(ss)");
91       if (instr->flags & IR3_INSTR_JP)
92          mesa_log_stream_printf(stream, "(jp)");
93       if (instr->repeat)
94          mesa_log_stream_printf(stream, "(rpt%d)", instr->repeat);
95       if (instr->nop)
96          mesa_log_stream_printf(stream, "(nop%d)", instr->nop);
97       if (instr->flags & IR3_INSTR_UL)
98          mesa_log_stream_printf(stream, "(ul)");
99    } else {
100       mesa_log_stream_printf(stream, " ");
101    }
102 
103    if (is_meta(instr)) {
104       switch (instr->opc) {
105       case OPC_META_INPUT:
106          mesa_log_stream_printf(stream, "_meta:in");
107          break;
108       case OPC_META_SPLIT:
109          mesa_log_stream_printf(stream, "_meta:split");
110          break;
111       case OPC_META_COLLECT:
112          mesa_log_stream_printf(stream, "_meta:collect");
113          break;
114       case OPC_META_TEX_PREFETCH:
115          mesa_log_stream_printf(stream, "_meta:tex_prefetch");
116          break;
117       case OPC_META_PARALLEL_COPY:
118          mesa_log_stream_printf(stream, "_meta:parallel_copy");
119          break;
120       case OPC_META_PHI:
121          mesa_log_stream_printf(stream, "_meta:phi");
122          break;
123 
124       /* shouldn't hit here.. just for debugging: */
125       default:
126          mesa_log_stream_printf(stream, "_meta:%d", instr->opc);
127          break;
128       }
129    } else if (opc_cat(instr->opc) == 1) {
130       if (instr->opc == OPC_MOV) {
131          if (instr->cat1.src_type == instr->cat1.dst_type)
132             mesa_log_stream_printf(stream, "mov");
133          else
134             mesa_log_stream_printf(stream, "cov");
135       } else {
136          mesa_log_stream_printf(stream, "%s",
137                                 disasm_a3xx_instr_name(instr->opc));
138       }
139 
140       if (instr->opc == OPC_SCAN_MACRO ||
141           instr->opc == OPC_SCAN_CLUSTERS_MACRO) {
142          switch (instr->cat1.reduce_op) {
143          case REDUCE_OP_ADD_U:
144             mesa_log_stream_printf(stream, ".add.u");
145             break;
146          case REDUCE_OP_ADD_F:
147             mesa_log_stream_printf(stream, ".add.f");
148             break;
149          case REDUCE_OP_MUL_U:
150             mesa_log_stream_printf(stream, ".mul.u");
151             break;
152          case REDUCE_OP_MUL_F:
153             mesa_log_stream_printf(stream, ".mul.f");
154             break;
155          case REDUCE_OP_MIN_U:
156             mesa_log_stream_printf(stream, ".min.u");
157             break;
158          case REDUCE_OP_MIN_S:
159             mesa_log_stream_printf(stream, ".min.s");
160             break;
161          case REDUCE_OP_MIN_F:
162             mesa_log_stream_printf(stream, ".min.f");
163             break;
164          case REDUCE_OP_MAX_U:
165             mesa_log_stream_printf(stream, ".max.u");
166             break;
167          case REDUCE_OP_MAX_S:
168             mesa_log_stream_printf(stream, ".max.s");
169             break;
170          case REDUCE_OP_MAX_F:
171             mesa_log_stream_printf(stream, ".max.f");
172             break;
173          case REDUCE_OP_AND_B:
174             mesa_log_stream_printf(stream, ".and.b");
175             break;
176          case REDUCE_OP_OR_B:
177             mesa_log_stream_printf(stream, ".or.b");
178             break;
179          case REDUCE_OP_XOR_B:
180             mesa_log_stream_printf(stream, ".xor.b");
181             break;
182          }
183       }
184 
185       if (instr->opc != OPC_MOVMSK && instr->opc != OPC_SCAN_MACRO &&
186           instr->opc != OPC_PUSH_CONSTS_LOAD_MACRO) {
187          mesa_log_stream_printf(stream, ".%s%s",
188                                 type_name(instr->cat1.src_type),
189                                 type_name(instr->cat1.dst_type));
190       }
191    } else if (instr->opc == OPC_B) {
192       const char *name[8] = {
193          /* clang-format off */
194          [BRANCH_PLAIN] = "br",
195          [BRANCH_OR]    = "brao",
196          [BRANCH_AND]   = "braa",
197          [BRANCH_CONST] = "brac",
198          [BRANCH_ANY]   = "bany",
199          [BRANCH_ALL]   = "ball",
200          [BRANCH_X]     = "brax",
201          /* clang-format on */
202       };
203       mesa_log_stream_printf(stream, "%s", name[instr->cat0.brtype]);
204    } else {
205       mesa_log_stream_printf(stream, "%s", disasm_a3xx_instr_name(instr->opc));
206       if (instr->flags & IR3_INSTR_3D)
207          mesa_log_stream_printf(stream, ".3d");
208       if (instr->flags & IR3_INSTR_A)
209          mesa_log_stream_printf(stream, ".a");
210       if (instr->flags & IR3_INSTR_O)
211          mesa_log_stream_printf(stream, ".o");
212       if (instr->flags & IR3_INSTR_P)
213          mesa_log_stream_printf(stream, ".p");
214       if (instr->flags & IR3_INSTR_S)
215          mesa_log_stream_printf(stream, ".s");
216       if (instr->flags & IR3_INSTR_A1EN)
217          mesa_log_stream_printf(stream, ".a1en");
218       if (instr->opc == OPC_LDC)
219          mesa_log_stream_printf(stream, ".offset%d", instr->cat6.d);
220       if (instr->opc == OPC_LDC_K)
221          mesa_log_stream_printf(stream, ".%d", instr->cat6.iim_val);
222       if (instr->flags & IR3_INSTR_B) {
223          mesa_log_stream_printf(
224             stream, ".base%d",
225             is_tex(instr) ? instr->cat5.tex_base : instr->cat6.base);
226       }
227       if (instr->flags & IR3_INSTR_S2EN)
228          mesa_log_stream_printf(stream, ".s2en");
229 
230       static const char *cond[0x7] = {
231          "lt", "le", "gt", "ge", "eq", "ne",
232       };
233 
234       switch (instr->opc) {
235       case OPC_CMPS_F:
236       case OPC_CMPS_U:
237       case OPC_CMPS_S:
238       case OPC_CMPV_F:
239       case OPC_CMPV_U:
240       case OPC_CMPV_S:
241          mesa_log_stream_printf(stream, ".%s",
242                                 cond[instr->cat2.condition & 0x7]);
243          break;
244       default:
245          break;
246       }
247    }
248 }
249 
250 static void
print_ssa_def_name(struct log_stream * stream,struct ir3_register * reg)251 print_ssa_def_name(struct log_stream *stream, struct ir3_register *reg)
252 {
253    mesa_log_stream_printf(stream, SYN_SSA("ssa_%u"), reg->instr->serialno);
254    if (reg->name != 0)
255       mesa_log_stream_printf(stream, ":%u", reg->name);
256 }
257 
258 static void
print_ssa_name(struct log_stream * stream,struct ir3_register * reg,bool dst)259 print_ssa_name(struct log_stream *stream, struct ir3_register *reg, bool dst)
260 {
261    if (!dst) {
262       if (!reg->def)
263          mesa_log_stream_printf(stream, SYN_SSA("undef"));
264       else
265          print_ssa_def_name(stream, reg->def);
266    } else {
267       print_ssa_def_name(stream, reg);
268    }
269 
270    if (reg->num != INVALID_REG && !(reg->flags & IR3_REG_ARRAY))
271       mesa_log_stream_printf(stream, "(" SYN_REG("r%u.%c") ")", reg_num(reg),
272                              "xyzw"[reg_comp(reg)]);
273 }
274 
275 static void
print_reg_name(struct log_stream * stream,struct ir3_instruction * instr,struct ir3_register * reg,bool dest)276 print_reg_name(struct log_stream *stream, struct ir3_instruction *instr,
277                struct ir3_register *reg, bool dest)
278 {
279    if ((reg->flags & (IR3_REG_FABS | IR3_REG_SABS)) &&
280        (reg->flags & (IR3_REG_FNEG | IR3_REG_SNEG | IR3_REG_BNOT)))
281       mesa_log_stream_printf(stream, "(absneg)");
282    else if (reg->flags & (IR3_REG_FNEG | IR3_REG_SNEG | IR3_REG_BNOT))
283       mesa_log_stream_printf(stream, "(neg)");
284    else if (reg->flags & (IR3_REG_FABS | IR3_REG_SABS))
285       mesa_log_stream_printf(stream, "(abs)");
286 
287    if (reg->flags & IR3_REG_FIRST_KILL)
288       mesa_log_stream_printf(stream, "(kill)");
289    if (reg->flags & IR3_REG_UNUSED)
290       mesa_log_stream_printf(stream, "(unused)");
291 
292    if (reg->flags & IR3_REG_R)
293       mesa_log_stream_printf(stream, "(r)");
294 
295    if (reg->flags & IR3_REG_EARLY_CLOBBER)
296       mesa_log_stream_printf(stream, "(early_clobber)");
297 
298    /* Right now all instructions that use tied registers only have one
299     * destination register, so we can just print (tied) as if it's a flag,
300     * although it's more convenient for RA if it's a pointer.
301     */
302    if (reg->tied)
303       mesa_log_stream_printf(stream, "(tied)");
304 
305    if (reg->flags & IR3_REG_SHARED)
306       mesa_log_stream_printf(stream, "s");
307    if (reg->flags & IR3_REG_HALF)
308       mesa_log_stream_printf(stream, "h");
309 
310    if (reg->flags & IR3_REG_IMMED) {
311       mesa_log_stream_printf(stream, SYN_IMMED("imm[%f,%d,0x%x]"), reg->fim_val,
312                              reg->iim_val, reg->iim_val);
313    } else if (reg->flags & IR3_REG_ARRAY) {
314       if (reg->flags & IR3_REG_SSA) {
315          print_ssa_name(stream, reg, dest);
316          mesa_log_stream_printf(stream, ":");
317       }
318       mesa_log_stream_printf(stream,
319                              SYN_ARRAY("arr[id=%u, offset=%d, size=%u]"),
320                              reg->array.id, reg->array.offset, reg->size);
321       if (reg->array.base != INVALID_REG)
322          mesa_log_stream_printf(stream, "(" SYN_REG("r%u.%c") ")",
323                                 reg->array.base >> 2,
324                                 "xyzw"[reg->array.base & 0x3]);
325    } else if (reg->flags & IR3_REG_SSA) {
326       print_ssa_name(stream, reg, dest);
327    } else if (reg->flags & IR3_REG_RELATIV) {
328       if (reg->flags & IR3_REG_CONST)
329          mesa_log_stream_printf(stream, SYN_CONST("c<a0.x + %d>"),
330                                 reg->array.offset);
331       else
332          mesa_log_stream_printf(stream, SYN_REG("r<a0.x + %d>") " (%u)",
333                                 reg->array.offset, reg->size);
334    } else {
335       if (reg->flags & IR3_REG_CONST)
336          mesa_log_stream_printf(stream, SYN_CONST("c%u.%c"), reg_num(reg),
337                                 "xyzw"[reg_comp(reg)]);
338       else
339          mesa_log_stream_printf(stream, SYN_REG("r%u.%c"), reg_num(reg),
340                                 "xyzw"[reg_comp(reg)]);
341    }
342 
343    if (reg->wrmask > 0x1)
344       mesa_log_stream_printf(stream, " (wrmask=0x%x)", reg->wrmask);
345 }
346 
347 static void
tab(struct log_stream * stream,int lvl)348 tab(struct log_stream *stream, int lvl)
349 {
350    for (int i = 0; i < lvl; i++)
351       mesa_log_stream_printf(stream, "\t");
352 }
353 
354 static void
print_instr(struct log_stream * stream,struct ir3_instruction * instr,int lvl)355 print_instr(struct log_stream *stream, struct ir3_instruction *instr, int lvl)
356 {
357    tab(stream, lvl);
358 
359    print_instr_name(stream, instr, true);
360 
361    if (is_tex(instr)) {
362       if (instr->opc == OPC_BRCST_ACTIVE)
363          mesa_log_stream_printf(stream, ".w%d", instr->cat5.cluster_size);
364       mesa_log_stream_printf(stream, " (%s)(", type_name(instr->cat5.type));
365       for (unsigned i = 0; i < 4; i++)
366          if (instr->dsts[0]->wrmask & (1 << i))
367             mesa_log_stream_printf(stream, "%c", "xyzw"[i]);
368       mesa_log_stream_printf(stream, ")");
369    } else if ((instr->srcs_count > 0 || instr->dsts_count > 0) &&
370               (instr->opc != OPC_B)) {
371       /* NOTE the b(ranch) instruction has a suffix, which is
372        * handled below
373        */
374       mesa_log_stream_printf(stream, " ");
375    }
376 
377    if (!is_flow(instr) || instr->opc == OPC_END || instr->opc == OPC_CHMASK) {
378       bool first = true;
379       foreach_dst (reg, instr) {
380          if (reg->wrmask == 0)
381             continue;
382          if (!first)
383             mesa_log_stream_printf(stream, ", ");
384          print_reg_name(stream, instr, reg, true);
385          first = false;
386       }
387       foreach_src_n (reg, n, instr) {
388          if (!first)
389             mesa_log_stream_printf(stream, ", ");
390          print_reg_name(stream, instr, reg, false);
391          if (instr->opc == OPC_END || instr->opc == OPC_CHMASK)
392             mesa_log_stream_printf(stream, " (%u)", instr->end.outidxs[n]);
393          first = false;
394       }
395    }
396 
397    if (is_tex(instr) && !(instr->flags & IR3_INSTR_S2EN) &&
398        !is_tex_shuffle(instr)) {
399       if (!!(instr->flags & IR3_INSTR_B) && !!(instr->flags & IR3_INSTR_A1EN)) {
400          mesa_log_stream_printf(stream, ", s#%d", instr->cat5.samp);
401       } else {
402          mesa_log_stream_printf(stream, ", s#%d, t#%d", instr->cat5.samp,
403                                 instr->cat5.tex);
404       }
405    }
406 
407    if (instr->opc == OPC_META_SPLIT) {
408       mesa_log_stream_printf(stream, ", off=%d", instr->split.off);
409    } else if (instr->opc == OPC_META_TEX_PREFETCH) {
410       mesa_log_stream_printf(stream, ", tex=%d, samp=%d, input_offset=%d",
411                              instr->prefetch.tex, instr->prefetch.samp,
412                              instr->prefetch.input_offset);
413    } else if (instr->opc == OPC_PUSH_CONSTS_LOAD_MACRO) {
414       mesa_log_stream_printf(
415          stream, " dst_offset=%d, src_offset = %d, src_size = %d",
416          instr->push_consts.dst_base, instr->push_consts.src_base,
417          instr->push_consts.src_size);
418    }
419 
420    if (is_flow(instr) && instr->cat0.target) {
421       /* the predicate register src is implied: */
422       if (instr->opc == OPC_B) {
423          static const struct {
424             int nsrc;
425             bool idx;
426          } brinfo[7] = {
427             /* clang-format off */
428             [BRANCH_PLAIN] = {1, false},
429             [BRANCH_OR]    = {2, false},
430             [BRANCH_AND]   = {2, false},
431             [BRANCH_CONST] = {0, true},
432             [BRANCH_ANY]   = {1, false},
433             [BRANCH_ALL]   = {1, false},
434             [BRANCH_X]     = {0, false},
435             /* clang-format on */
436          };
437 
438          if (brinfo[instr->cat0.brtype].idx) {
439             mesa_log_stream_printf(stream, ".%u", instr->cat0.idx);
440          }
441          if (brinfo[instr->cat0.brtype].nsrc >= 1) {
442             mesa_log_stream_printf(stream, " %sp0.%c (",
443                                    instr->cat0.inv1 ? "!" : "",
444                                    "xyzw"[instr->cat0.comp1 & 0x3]);
445             print_reg_name(stream, instr, instr->srcs[0], false);
446             mesa_log_stream_printf(stream, "), ");
447          }
448          if (brinfo[instr->cat0.brtype].nsrc >= 2) {
449             mesa_log_stream_printf(stream, " %sp0.%c (",
450                                    instr->cat0.inv2 ? "!" : "",
451                                    "xyzw"[instr->cat0.comp2 & 0x3]);
452             print_reg_name(stream, instr, instr->srcs[1], false);
453             mesa_log_stream_printf(stream, "), ");
454          }
455       }
456       mesa_log_stream_printf(stream, " target=block%u",
457                              block_id(instr->cat0.target));
458    }
459 
460    if (instr->deps_count) {
461       mesa_log_stream_printf(stream, ", false-deps:");
462       unsigned n = 0;
463       for (unsigned i = 0; i < instr->deps_count; i++) {
464          if (!instr->deps[i])
465             continue;
466          if (n++ > 0)
467             mesa_log_stream_printf(stream, ", ");
468          mesa_log_stream_printf(stream, SYN_SSA("ssa_%u"),
469                                 instr->deps[i]->serialno);
470       }
471    }
472 
473    mesa_log_stream_printf(stream, "\n");
474 }
475 
476 void
ir3_print_instr_stream(struct log_stream * stream,struct ir3_instruction * instr)477 ir3_print_instr_stream(struct log_stream *stream, struct ir3_instruction *instr)
478 {
479    print_instr(stream, instr, 0);
480 }
481 
482 void
ir3_print_instr(struct ir3_instruction * instr)483 ir3_print_instr(struct ir3_instruction *instr)
484 {
485    struct log_stream *stream = mesa_log_streami();
486    print_instr(stream, instr, 0);
487    mesa_log_stream_destroy(stream);
488 }
489 
490 static void
print_block(struct ir3_block * block,int lvl)491 print_block(struct ir3_block *block, int lvl)
492 {
493    struct log_stream *stream = mesa_log_streami();
494 
495    tab(stream, lvl);
496    mesa_log_stream_printf(stream, "%sblock%u {\n",
497                           block->reconvergence_point ? "(jp)" : "",
498                           block_id(block));
499 
500    if (block->predecessors_count > 0) {
501       tab(stream, lvl + 1);
502       mesa_log_stream_printf(stream, "pred: ");
503       for (unsigned i = 0; i < block->predecessors_count; i++) {
504          struct ir3_block *pred = block->predecessors[i];
505          if (i != 0)
506             mesa_log_stream_printf(stream, ", ");
507          mesa_log_stream_printf(stream, "block%u", block_id(pred));
508       }
509       mesa_log_stream_printf(stream, "\n");
510    }
511 
512    if (block->physical_predecessors_count > 0) {
513       tab(stream, lvl + 1);
514       mesa_log_stream_printf(stream, "physical pred: ");
515       for (unsigned i = 0; i < block->physical_predecessors_count; i++) {
516          struct ir3_block *pred = block->physical_predecessors[i];
517          if (i != 0)
518             mesa_log_stream_printf(stream, ", ");
519          mesa_log_stream_printf(stream, "block%u", block_id(pred));
520       }
521       mesa_log_stream_printf(stream, "\n");
522    }
523 
524    foreach_instr (instr, &block->instr_list) {
525       print_instr(stream, instr, lvl + 1);
526    }
527 
528    tab(stream, lvl + 1);
529    mesa_log_stream_printf(stream, "/* keeps:\n");
530    for (unsigned i = 0; i < block->keeps_count; i++) {
531       print_instr(stream, block->keeps[i], lvl + 2);
532    }
533    tab(stream, lvl + 1);
534    mesa_log_stream_printf(stream, " */\n");
535 
536    if (block->successors[1]) {
537       /* leading into if/else: */
538       tab(stream, lvl + 1);
539       mesa_log_stream_printf(stream, "/* succs: if ");
540       switch (block->brtype) {
541       case IR3_BRANCH_COND:
542          break;
543       case IR3_BRANCH_ANY:
544          mesa_log_stream_printf(stream, "any ");
545          break;
546       case IR3_BRANCH_ALL:
547          mesa_log_stream_printf(stream, "all ");
548          break;
549       case IR3_BRANCH_GETONE:
550          mesa_log_stream_printf(stream, "getone ");
551          break;
552       case IR3_BRANCH_GETLAST:
553          mesa_log_stream_printf(stream, "getlast ");
554          break;
555       case IR3_BRANCH_SHPS:
556          mesa_log_stream_printf(stream, "shps ");
557          break;
558       }
559       if (block->condition)
560          mesa_log_stream_printf(stream, SYN_SSA("ssa_%u") " ",
561                                 block->condition->serialno);
562       mesa_log_stream_printf(stream, "block%u; else block%u; */\n",
563                              block_id(block->successors[0]),
564                              block_id(block->successors[1]));
565    } else if (block->successors[0]) {
566       tab(stream, lvl + 1);
567       mesa_log_stream_printf(stream, "/* succs: block%u; */\n",
568                              block_id(block->successors[0]));
569    }
570    if (block->physical_successors_count > 0) {
571       tab(stream, lvl + 1);
572       mesa_log_stream_printf(stream, "/* physical succs: ");
573       for (unsigned i = 0; i < block->physical_successors_count; i++) {
574          mesa_log_stream_printf(stream, "block%u",
575                                 block_id(block->physical_successors[i]));
576          if (i < block->physical_successors_count - 1)
577             mesa_log_stream_printf(stream, ", ");
578       }
579       mesa_log_stream_printf(stream, " */\n");
580    }
581    tab(stream, lvl);
582    mesa_log_stream_printf(stream, "}\n");
583 }
584 
585 void
ir3_print(struct ir3 * ir)586 ir3_print(struct ir3 *ir)
587 {
588    foreach_block (block, &ir->block_list)
589       print_block(block, 0);
590 }
591