freedreno/ir3/print: More sane ssa src/dst display
authorRob Clark <robdclark@chromium.org>
Thu, 18 Feb 2021 23:28:17 +0000 (15:28 -0800)
committerMarge Bot <eric+marge@anholt.net>
Fri, 19 Feb 2021 22:56:56 +0000 (22:56 +0000)
Give src/dst a "ssa_%u" name generated from the instruction's unique
serialno.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9142>

src/freedreno/ir3/ir3.c
src/freedreno/ir3/ir3.h
src/freedreno/ir3/ir3_print.c

index cb7a507..c75033b 100644 (file)
@@ -217,9 +217,9 @@ static void insert_instr(struct ir3_block *block,
                struct ir3_instruction *instr)
 {
        struct ir3 *shader = block->shader;
-#ifdef DEBUG
+
        instr->serialno = ++shader->instr_count;
-#endif
+
        list_addtail(&instr->node, &block->instr_list);
 
        if (is_input(instr))
index 0b9c389..50eee63 100644 (file)
@@ -414,9 +414,7 @@ struct ir3_instruction {
        /* Entry in ir3_block's instruction list: */
        struct list_head node;
 
-#ifdef DEBUG
        uint32_t serialno;
-#endif
 
        // TODO only computerator/assembler:
        int line;
@@ -499,8 +497,9 @@ struct ir3 {
        struct list_head array_list;
 
 #ifdef DEBUG
-       unsigned block_count, instr_count;
+       unsigned block_count;
 #endif
+       unsigned instr_count;
 };
 
 struct ir3_array {
index dc1e6a9..fe601cf 100644 (file)
@@ -160,7 +160,7 @@ static void print_instr_name(struct ir3_instruction *instr, bool flags)
        }
 }
 
-static void print_reg_name(struct ir3_register *reg)
+static void print_reg_name(struct ir3_instruction *instr, struct ir3_register *reg)
 {
        if ((reg->flags & (IR3_REG_FABS | IR3_REG_SABS)) &&
                        (reg->flags & (IR3_REG_FNEG | IR3_REG_SNEG | IR3_REG_BNOT)))
@@ -185,18 +185,18 @@ static void print_reg_name(struct ir3_register *reg)
                                reg->array.offset, reg->size);
                /* for ARRAY we could have null src, for example first write
                 * instruction..
+                *
+                * Note for array writes from another block, we aren't really
+                * sure who wrote it so skip trying to show this
                 */
-               if (reg->instr) {
+               if (reg->instr && (reg->instr->block == instr->block)) {
                        printf(SYN_ARRAY(", "));
-                       printf(SYN_SSA("_["));
-                       print_instr_name(reg->instr, false);
-                       printf(SYN_SSA("]"));
+                       printf(SYN_SSA("ssa_%u"), reg->instr->serialno);
                }
                printf(SYN_ARRAY("]"));
        } else if (reg->flags & IR3_REG_SSA) {
-               printf(SYN_SSA("_["));
-               print_instr_name(reg->instr, false);
-               printf(SYN_SSA("]"));
+               /* For dst regs, reg->instr will be NULL: */
+               printf(SYN_SSA("ssa_%u"), reg->instr ? reg->instr->serialno : instr->serialno);
        } else if (reg->flags & IR3_REG_RELATIV) {
                if (reg->flags & IR3_REG_CONST)
                        printf(SYN_CONST("c<a0.x + %d>"), reg->array.offset);
@@ -243,7 +243,7 @@ print_instr(struct ir3_instruction *instr, int lvl)
                struct ir3_register *reg = instr->regs[i];
 
                printf(i ? ", " : "");
-               print_reg_name(reg);
+               print_reg_name(instr, reg);
        }
 
        if (is_tex(instr) && !(instr->flags & IR3_INSTR_S2EN)) {
@@ -324,12 +324,13 @@ print_instr(struct ir3_instruction *instr, int lvl)
 
        if (instr->deps_count) {
                printf(", false-deps:");
+               unsigned n = 0;
                for (unsigned i = 0; i < instr->deps_count; i++) {
-                       if (i > 0)
+                       if (!instr->deps[i])
+                               continue;
+                       if (n++ > 0)
                                printf(", ");
-                       printf("_[");
-                       print_instr_name(instr->deps[i], false);
-                       printf("]");
+                       printf(SYN_SSA("ssa_%u"), instr->deps[i]->serialno);
                }
        }
 
@@ -375,9 +376,8 @@ print_block(struct ir3_block *block, int lvl)
        if (block->successors[1]) {
                /* leading into if/else: */
                tab(lvl+1);
-               printf("/* succs: if _[");
-               print_instr_name(block->condition, false);
-               printf("] block%u; else block%u; */\n",
+               printf("/* succs: if "SYN_SSA("ssa_%u")" block%u; else block%u */\n",
+                               block->condition->serialno,
                                block_id(block->successors[0]),
                                block_id(block->successors[1]));
        } else if (block->successors[0]) {