From: Alyssa Rosenzweig Date: Sat, 12 Dec 2020 01:03:02 +0000 (-0500) Subject: pan/bi: Add helpers to generate bi_index from NIR X-Git-Tag: upstream/21.0.0~1071 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2d9147dae45115fbd5481a9811fe0b8de400d1e2;p=platform%2Fupstream%2Fmesa.git pan/bi: Add helpers to generate bi_index from NIR Corresponding to the existing pan_{...}_index helpers, except returning a new-style index instead. Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index 8928044..d1609bc 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -741,6 +741,34 @@ bi_make_temp_reg(bi_context *ctx) return ((ctx->impl->reg_alloc + ctx->temp_alloc++) << 1) | PAN_IS_REG; } +/* 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 */ + +static inline bi_index +bi_src_index(nir_src *src) +{ + if (nir_src_is_const(*src)) + return bi_imm_u32(nir_src_as_uint(*src)); + else if (src->is_ssa) + return bi_get_index(src->ssa->index, false, 0); + else { + assert(!src->reg.indirect); + return bi_get_index(src->reg.reg->index, true, 0); + } +} + +static inline bi_index +bi_dest_index(nir_dest *dst) +{ + if (dst->is_ssa) + return bi_get_index(dst->ssa.index, false, 0); + else { + assert(!dst->reg.indirect); + return bi_get_index(dst->reg.reg->index, true, 0); + } +} + /* Iterators for Bifrost IR */ #define bi_foreach_block(ctx, v) \