From 63863de9231f2067e180255b6cf9f9c5dd8d3bab Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 7 Dec 2020 19:15:24 -0500 Subject: [PATCH] pan/bi: Implement bi_emit_load_const via the builder Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bifrost_compile.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index b85db36..d93d0d7 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -1038,6 +1038,24 @@ emit_intrinsic(bi_context *ctx, nir_intrinsic_instr *instr) } static void +bi_emit_load_const(bi_builder *b, nir_load_const_instr *instr) +{ + /* Make sure we've been lowered */ + assert(instr->def.num_components <= (32 / instr->def.bit_size)); + + /* Accumulate all the channels of the constant, as if we did an + * implicit SEL over them */ + uint32_t acc = 0; + + for (unsigned i = 0; i < instr->def.num_components; ++i) { + unsigned v = nir_const_value_as_uint(instr->value[i], instr->def.bit_size); + acc |= (v << (i * instr->def.bit_size)); + } + + bi_mov_i32_to(b, bi_get_index(instr->def.index, false, 0), bi_imm_u32(acc)); +} + +static void emit_load_const(bi_context *ctx, nir_load_const_instr *instr) { /* Make sure we've been lowered */ -- 2.7.4