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 <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31532>
This commit is contained in:
Alyssa Rosenzweig
2024-09-22 17:17:25 -04:00
committed by Marge Bot
parent 4f5637c873
commit 3a0e152de2
@@ -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)
{