From d86659ca57ebe9d1752e33ed6ffe1e1b70c5f50d Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 6 Mar 2020 09:43:43 -0500 Subject: [PATCH] pan/bi: Add helpers for creating temporaries Also from Midgard, adapted to our addressing scheme. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bifrost_compile.c | 1 + src/panfrost/bifrost/compiler.h | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 2ebba1b9e29..a22d6420117 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -533,6 +533,7 @@ bifrost_compile_shader_nir(nir_shader *nir, bifrost_program *program, unsigned p if (!func->impl) continue; + ctx->impl = func->impl; 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 cbd76d5e2d0..18127bacfd8 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -325,6 +325,7 @@ typedef struct { uint32_t quirks; /* During NIR->BIR */ + nir_function_impl *impl; bi_block *current_block; unsigned block_name_count; bi_block *after_block; @@ -332,6 +333,9 @@ typedef struct { bi_block *continue_block; bool emitted_atest; + /* For creating temporaries */ + unsigned temp_alloc; + /* Stats for shader-db */ unsigned instruction_count; unsigned loop_count; @@ -375,6 +379,18 @@ bi_remove_instruction(bi_instruction *ins) #define BIR_SPECIAL ((BIR_INDEX_REGISTER | BIR_INDEX_UNIFORM) | \ (BIR_INDEX_CONSTANT | BIR_INDEX_ZERO) +static inline unsigned +bi_make_temp(bi_context *ctx) +{ + return (ctx->impl->ssa_alloc + 1 + ctx->temp_alloc++) << 1; +} + +static inline unsigned +bi_make_temp_reg(bi_context *ctx) +{ + return ((ctx->impl->reg_alloc + ctx->temp_alloc++) << 1) | BIR_IS_REG; +} + static inline unsigned bir_ssa_index(nir_ssa_def *ssa) { -- 2.30.2