From 7434f31e09450ef7d46ecae5ef19d2eb7e817059 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 21 Dec 2020 15:44:51 -0500 Subject: [PATCH] pan/bi: Factor nir_function_impl out of the context Unnecessary and complicates unit testing. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/bifrost/bifrost_compile.c | 4 +++- src/panfrost/bifrost/compiler.h | 14 +++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index cb095ec..248c985 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -2356,7 +2356,9 @@ bifrost_compile_shader_nir(void *mem_ctx, nir_shader *nir, if (!func->impl) continue; - ctx->impl = func->impl; + ctx->ssa_alloc += func->impl->ssa_alloc; + ctx->reg_alloc += func->impl->reg_alloc; + emit_cf_list(ctx, &func->impl->body); break; /* TODO: Multi-function shaders */ } diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index 94d4ee3..dbedda7 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -494,7 +494,6 @@ typedef struct { uint64_t blend_desc; /* During NIR->BIR */ - nir_function_impl *impl; bi_block *current_block; bi_block *after_block; bi_block *break_block; @@ -503,7 +502,8 @@ typedef struct { nir_alu_type *blend_types; /* For creating temporaries */ - unsigned temp_alloc; + unsigned ssa_alloc; + unsigned reg_alloc; /* Analysis results */ bool has_liveness; @@ -550,25 +550,21 @@ bi_fau(enum bir_fau value, bool hi) static inline unsigned bi_max_temp(bi_context *ctx) { - unsigned alloc = MAX2(ctx->impl->reg_alloc, ctx->impl->ssa_alloc); - return ((alloc + 2 + ctx->temp_alloc) << 1); + return (MAX2(ctx->reg_alloc, ctx->ssa_alloc) + 2) << 1; } static inline bi_index bi_temp(bi_context *ctx) { - unsigned alloc = (ctx->impl->ssa_alloc + ctx->temp_alloc++); - return bi_get_index(alloc, false, 0); + return bi_get_index(ctx->ssa_alloc++, false, 0); } static inline bi_index bi_temp_reg(bi_context *ctx) { - unsigned alloc = (ctx->impl->reg_alloc + ctx->temp_alloc++); - return bi_get_index(alloc, true, 0); + return bi_get_index(ctx->reg_alloc++, true, 0); } - /* Inline constants automatically, will be lowered out by bi_lower_fau where a * constant is not allowed. load_const_to_scalar gaurantees that this makes * sense */ -- 2.7.4