pan/bi: Clean up destination printing
authorAlyssa Rosenzweig <alyssa@collabora.com>
Thu, 21 Jul 2022 18:45:49 +0000 (14:45 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 2 Sep 2022 16:03:23 +0000 (16:03 +0000)
Now we can trust in I->nr_dests, avoiding a bunch of special cases and incorrect
printing for instructions without a destination. To compensate for those
instructions being hard to scan now, indent.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17794>

src/panfrost/bifrost/bi_printer.c.py

index d00659f..024df69 100644 (file)
@@ -160,22 +160,18 @@ bi_${mod}_as_str(enum bi_${mod} ${mod})
 void
 bi_print_instr(const bi_instr *I, FILE *fp)
 {
-    if (I->op == BI_OPCODE_SPLIT_I32) {
-        for (unsigned d = 0; d < I->nr_dests; ++d) {
-            if (d > 0) fprintf(fp, ", ");
+    fputs("   ", fp);
 
-            bi_print_index(fp, I->dest[d]);
-        }
-    } else {
-        bi_foreach_dest(I, d) {
-            if (bi_is_null(I->dest[d])) break;
-            if (d > 0) fprintf(fp, ", ");
+    bi_foreach_dest(I, d) {
+        if (d > 0) fprintf(fp, ", ");
 
-            bi_print_index(fp, I->dest[d]);
-        }
+        bi_print_index(fp, I->dest[d]);
     }
 
-    fprintf(fp, " = %s", bi_opcode_props[I->op].name);
+    if (I->nr_dests > 0)
+        fputs(" = ", fp);
+
+    fprintf(fp, "%s", bi_opcode_props[I->op].name);
 
     if (I->table)
         fprintf(fp, ".table%u", I->table);