pan/mdg: Add a macro for printing instruction source information
authorIcecream95 <ixn@keemail.me>
Fri, 5 Jun 2020 12:20:52 +0000 (00:20 +1200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 10 Jun 2020 13:54:03 +0000 (13:54 +0000)
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5065>

src/panfrost/midgard/midgard_print.c

index 7a41dcab5ca879accf560d6c3aeed36d9bc4ab65..64dceda3d5e390c4cc06bd095b93bddce1b9349b 100644 (file)
@@ -272,6 +272,13 @@ mir_print_embedded_constant(midgard_instruction *ins, unsigned src_idx)
                 printf(")");
 }
 
+#define PRINT_SRC(ins, c) \
+        do { mir_print_index(ins->src[c]); \
+             if (ins->src[c] != ~0 && ins->src_types[c] != nir_type_invalid) { \
+                     pan_print_alu_type(ins->src_types[c], stdout); \
+                     mir_print_swizzle(ins->swizzle[c], ins->src_types[c]); \
+             } } while (0)
+
 void
 mir_print_instruction(midgard_instruction *ins)
 {
@@ -363,37 +370,21 @@ mir_print_instruction(midgard_instruction *ins)
 
         if (ins->src[0] == r_constant)
                 mir_print_embedded_constant(ins, 0);
-        else {
-                mir_print_index(ins->src[0]);
+        else
+                PRINT_SRC(ins, 0);
 
-                if (ins->src[0] != ~0) {
-                        pan_print_alu_type(ins->src_types[0], stdout);
-                        mir_print_swizzle(ins->swizzle[0], ins->src_types[0]);
-                }
-        }
         printf(", ");
 
         if (ins->has_inline_constant)
                 printf("#%d", ins->inline_constant);
         else if (ins->src[1] == r_constant)
                 mir_print_embedded_constant(ins, 1);
-        else {
-                mir_print_index(ins->src[1]);
-
-                if (ins->src[1] != ~0) {
-                        pan_print_alu_type(ins->src_types[1], stdout);
-                        mir_print_swizzle(ins->swizzle[1], ins->src_types[1]);
-                }
-        }
+        else
+                PRINT_SRC(ins, 1);
 
         for (unsigned c = 2; c <= 3; ++c) {
                 printf(", ");
-                mir_print_index(ins->src[c]);
-
-                if (ins->src[c] != ~0) {
-                        pan_print_alu_type(ins->src_types[c], stdout);
-                        mir_print_swizzle(ins->swizzle[c], ins->src_types[c]);
-                }
+                PRINT_SRC(ins, c);
         }
 
         if (ins->no_spill)