From f29fa1e9df225914ab50426aaaad321111a6f4dc Mon Sep 17 00:00:00 2001 From: Christoph Pillmayer Date: Fri, 12 Dec 2025 11:15:38 +0000 Subject: [PATCH] pan/bi: Fixup bi_reindex_ssa.c for bi Reviewed-by: Eric R. Smith Part-of: --- .../compiler/bifrost/bi_reindex_ssa.c | 20 +++++++++---------- src/panfrost/compiler/bifrost/compiler.h | 3 +++ src/panfrost/compiler/bifrost/meson.build | 1 + 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/panfrost/compiler/bifrost/bi_reindex_ssa.c b/src/panfrost/compiler/bifrost/bi_reindex_ssa.c index 5b2967adfb2..fd8a3a2d5d1 100644 --- a/src/panfrost/compiler/bifrost/bi_reindex_ssa.c +++ b/src/panfrost/compiler/bifrost/bi_reindex_ssa.c @@ -4,27 +4,25 @@ */ #include -#include "agx_compiler.h" - -/* Reindex SSA to reduce memory usage */ +#include "compiler.h" void -agx_reindex_ssa(agx_context *ctx) +bi_reindex_ssa(bi_context *ctx) { - unsigned *remap = calloc(ctx->alloc, sizeof(*remap)); + unsigned *remap = calloc(ctx->ssa_alloc, sizeof(*remap)); - ctx->alloc = 0; + ctx->ssa_alloc = 0; - agx_foreach_instr_global(ctx, I) { - agx_foreach_ssa_dest(I, d) { + bi_foreach_instr_global(ctx, I) { + bi_foreach_ssa_dest(I, d) { assert(!remap[I->dest[d].value] && "input is SSA"); - remap[I->dest[d].value] = ctx->alloc++; + remap[I->dest[d].value] = ctx->ssa_alloc++; I->dest[d].value = remap[I->dest[d].value]; } } - agx_foreach_instr_global(ctx, I) { - agx_foreach_ssa_src(I, s) { + bi_foreach_instr_global(ctx, I) { + bi_foreach_ssa_src(I, s) { I->src[s].value = remap[I->src[s].value]; } } diff --git a/src/panfrost/compiler/bifrost/compiler.h b/src/panfrost/compiler/bifrost/compiler.h index c5e7a753f98..2981518aa68 100644 --- a/src/panfrost/compiler/bifrost/compiler.h +++ b/src/panfrost/compiler/bifrost/compiler.h @@ -1476,6 +1476,9 @@ uint64_t MUST_CHECK bi_postra_liveness_ins(uint64_t live, bi_instr *ins); /* SSA spilling; returns number of spilled registers */ unsigned bi_spill_ssa(bi_context *ctx, unsigned num_registers, unsigned tls_size); +/* Reindex SSA to reduce memory usage */ +void bi_reindex_ssa(bi_context *ctx); + /* Layout */ signed bi_block_offset(bi_context *ctx, bi_clause *start, bi_block *target); diff --git a/src/panfrost/compiler/bifrost/meson.build b/src/panfrost/compiler/bifrost/meson.build index 06d7a0b7f6e..1197dfaa2f6 100644 --- a/src/panfrost/compiler/bifrost/meson.build +++ b/src/panfrost/compiler/bifrost/meson.build @@ -26,6 +26,7 @@ libpanfrost_bifrost_files = files( 'bi_ra.c', 'bi_ra_ssa.c', 'bi_spill_ssa.c', + 'bi_reindex_ssa.c', 'bi_validate.c', 'bi_dominance.c', 'bir.c',