ir3: Improve register printing for SSA
authorConnor Abbott <cwabbott0@gmail.com>
Fri, 5 Mar 2021 21:09:41 +0000 (22:09 +0100)
committerEmma Anholt <emma@anholt.net>
Thu, 10 Jun 2021 19:20:38 +0000 (12:20 -0700)
Print the ssa name for array destinations, and handle printing undef SSA
sources.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9842>

src/freedreno/ir3/ir3_print.c

index 6ddb5d7..8814f76 100644 (file)
@@ -162,6 +162,23 @@ static void print_instr_name(struct ir3_instruction *instr, bool flags)
        }
 }
 
+static void print_ssa_def_name(struct ir3_register *reg)
+{
+       printf(SYN_SSA("ssa_%u"), reg->instr->serialno);
+}
+
+static void print_ssa_name(struct ir3_register *reg, bool dst)
+{
+       if (!dst) {
+               if (!reg->def)
+                       printf(SYN_SSA("undef"));
+               else
+                       print_ssa_def_name(reg->def);
+       } else {
+               print_ssa_def_name(reg);
+       }
+}
+
 static void print_reg_name(struct ir3_instruction *instr, struct ir3_register *reg)
 {
        if ((reg->flags & (IR3_REG_FABS | IR3_REG_SABS)) &&
@@ -183,22 +200,19 @@ static void print_reg_name(struct ir3_instruction *instr, struct ir3_register *r
        if (reg->flags & IR3_REG_IMMED) {
                printf(SYN_IMMED("imm[%f,%d,0x%x]"), reg->fim_val, reg->iim_val, reg->iim_val);
        } else if (reg->flags & IR3_REG_ARRAY) {
+               if (reg->flags & IR3_REG_SSA) {
+                       print_ssa_name(reg, reg->flags & IR3_REG_DEST);
+                       printf(":");
+               }
                printf(SYN_ARRAY("arr[id=%u, offset=%d, size=%u"), reg->array.id,
                                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->def && (reg->def->instr->block == instr->block)) {
+               if (reg->flags & IR3_REG_DEST) {
                        printf(SYN_ARRAY(", "));
-                       printf(SYN_SSA("ssa_%u"), reg->def->instr->serialno);
+                       print_ssa_name(reg, false);
                }
                printf(SYN_ARRAY("]"));
        } else if (reg->flags & IR3_REG_SSA) {
-               /* For dst regs, reg->def will be NULL: */
-               printf(SYN_SSA("ssa_%u"), (reg->flags & IR3_REG_DEST) ? instr->serialno : reg->def->instr->serialno);
+               print_ssa_name(reg, reg->flags & IR3_REG_DEST);
        } else if (reg->flags & IR3_REG_RELATIV) {
                if (reg->flags & IR3_REG_CONST)
                        printf(SYN_CONST("c<a0.x + %d>"), reg->array.offset);