From 3a0e152de23717a0684617fcb0305e93f9dfb7f3 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sun, 22 Sep 2024 17:17:25 -0400 Subject: [PATCH] agx: add helper to visualize reg file I used to do these by hand. Example print: ---- ---- 1... .... 22.1 4444 2222 2222 2222 2222 Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_register_allocate.c | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/asahi/compiler/agx_register_allocate.c b/src/asahi/compiler/agx_register_allocate.c index 6337e324085..52eec9814de 100644 --- a/src/asahi/compiler/agx_register_allocate.c +++ b/src/asahi/compiler/agx_register_allocate.c @@ -144,6 +144,49 @@ reserved_size(agx_context *ctx) return 0; } +UNUSED static void +print_reg_file(struct ra_ctx *rctx, FILE *fp) +{ + unsigned reserved = reserved_size(rctx->shader); + + /* Dump the contents */ + for (unsigned i = reserved; i < rctx->bound[RA_GPR]; ++i) { + if (BITSET_TEST(rctx->used_regs[RA_GPR], i)) { + uint32_t ssa = rctx->reg_to_ssa[i]; + unsigned n = rctx->ncomps[ssa]; + fprintf(fp, "h%u...%u: %u\n", i, i + n - 1, ssa); + i += (n - 1); + } + } + fprintf(fp, "\n"); + + /* Dump a visualization of the sizes to understand what live range + * splitting is up against. + */ + for (unsigned i = 0; i < rctx->bound[RA_GPR]; ++i) { + /* Space out 16-bit vec4s */ + if (i && (i % 4) == 0) { + fprintf(fp, " "); + } + + if (i < reserved) { + fprintf(fp, "-"); + } else if (BITSET_TEST(rctx->used_regs[RA_GPR], i)) { + uint32_t ssa = rctx->reg_to_ssa[i]; + unsigned n = rctx->ncomps[ssa]; + for (unsigned j = 0; j < n; ++j) { + assert(n < 10); + fprintf(fp, "%u", n); + } + + i += (n - 1); + } else { + fprintf(fp, "."); + } + } + fprintf(fp, "\n\n"); +} + enum agx_size agx_split_width(const agx_instr *I) {