From 5f5a9737096aedf6f2b88f333228e86f8f9d3086 Mon Sep 17 00:00:00 2001 From: Icecream95 Date: Sat, 6 Jun 2020 00:20:52 +1200 Subject: [PATCH] pan/mdg: Add a macro for printing instruction source information Reviewed-by: Alyssa Rosenzweig Part-of: --- src/panfrost/midgard/midgard_print.c | 33 ++++++++++------------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/panfrost/midgard/midgard_print.c b/src/panfrost/midgard/midgard_print.c index 7a41dcab5ca..64dceda3d5e 100644 --- a/src/panfrost/midgard/midgard_print.c +++ b/src/panfrost/midgard/midgard_print.c @@ -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) -- 2.30.2