pan/bi: Add helpers for creating temporaries

Also from Midgard, adapted to our addressing scheme.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4097>
This commit is contained in:
Alyssa Rosenzweig 2020-03-06 09:43:43 -05:00 committed by Marge Bot
parent 59b476e11a
commit d86659ca57
2 changed files with 17 additions and 0 deletions

View File

@ -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 */
}

View File

@ -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)
{