freedreno/ir3: add dumping for use/def/live-in/live-out
authorRob Clark <robclark@freedesktop.org>
Mon, 4 Apr 2016 18:16:12 +0000 (14:16 -0400)
committerRob Clark <robclark@freedesktop.org>
Tue, 5 Apr 2016 00:18:18 +0000 (20:18 -0400)
Turned out to be useful to debug an issue in RA.  Let's keep it.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/drivers/freedreno/ir3/ir3.h
src/gallium/drivers/freedreno/ir3/ir3_print.c
src/gallium/drivers/freedreno/ir3/ir3_ra.c

index f268c2b38e9441ade124226ec48d85a70294f1fe..23e43b1e13dc5b98074817e0d33c8ad3c90be09b 100644 (file)
@@ -434,6 +434,16 @@ struct ir3_block {
 #endif
 };
 
+static inline uint32_t
+block_id(struct ir3_block *block)
+{
+#ifdef DEBUG
+       return block->serialno;
+#else
+       return (uint32_t)(unsigned long)block;
+#endif
+}
+
 struct ir3 * ir3_create(struct ir3_compiler *compiler,
                unsigned nin, unsigned nout);
 void ir3_destroy(struct ir3 *shader);
index 86418b898204391454f9dd8c3113b08a40dbd071..8aebf21a1be250ce2d74a0d38cbb5d64c3b4eebb 100644 (file)
@@ -40,6 +40,7 @@ static void print_instr_name(struct ir3_instruction *instr)
 #ifdef DEBUG
        printf("%04u:", instr->serialno);
 #endif
+       printf("%04u:", instr->name);
        printf("%03u: ", instr->depth);
 
        if (instr->flags & IR3_INSTR_SY)
@@ -148,16 +149,6 @@ tab(int lvl)
                printf("\t");
 }
 
-static uint32_t
-block_id(struct ir3_block *block)
-{
-#ifdef DEBUG
-       return block->serialno;
-#else
-       return (uint32_t)(unsigned long)block;
-#endif
-}
-
 static void
 print_instr(struct ir3_instruction *instr, int lvl)
 {
index 2f369e677e08b0c9004ce30391d212282a13b929..f06b27e9dd2a2a3674534c17979a658bac5a3da8 100644 (file)
@@ -31,6 +31,8 @@
 #include "util/ralloc.h"
 #include "util/bitset.h"
 
+#include "freedreno_util.h"
+
 #include "ir3.h"
 #include "ir3_compiler.h"
 
@@ -809,6 +811,22 @@ ra_compute_livein_liveout(struct ir3_ra_ctx *ctx)
        return progress;
 }
 
+static void
+print_bitset(const char *name, BITSET_WORD *bs, unsigned cnt)
+{
+       bool first = true;
+       debug_printf("  %s:", name);
+       for (unsigned i = 0; i < cnt; i++) {
+               if (BITSET_TEST(bs, i)) {
+                       if (!first)
+                               debug_printf(",");
+                       debug_printf(" %04u", i);
+                       first = false;
+               }
+       }
+       debug_printf("\n");
+}
+
 static void
 ra_add_interference(struct ir3_ra_ctx *ctx)
 {
@@ -831,6 +849,19 @@ ra_add_interference(struct ir3_ra_ctx *ctx)
        /* update per-block livein/liveout: */
        while (ra_compute_livein_liveout(ctx)) {}
 
+       if (fd_mesa_debug & FD_DBG_OPTMSGS) {
+               debug_printf("AFTER LIVEIN/OUT:\n");
+               ir3_print(ir);
+               list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+                       struct ir3_ra_block_data *bd = block->data;
+                       debug_printf("block%u:\n", block_id(block));
+                       print_bitset("def", bd->def, ctx->alloc_count);
+                       print_bitset("use", bd->use, ctx->alloc_count);
+                       print_bitset("l/i", bd->livein, ctx->alloc_count);
+                       print_bitset("l/o", bd->liveout, ctx->alloc_count);
+               }
+       }
+
        /* extend start/end ranges based on livein/liveout info from cfg: */
        unsigned bitset_words = BITSET_WORDS(ctx->alloc_count);
        list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {