From: Alyssa Rosenzweig Date: Wed, 24 Jul 2019 19:52:27 +0000 (-0700) Subject: pan/midgard: Add emit_explicit_constant helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e169301bd85644edb97591fae3790e9442ea4721;p=mesa.git pan/midgard: Add emit_explicit_constant helper We generalize the constant emission helper used in fragment writeout as we'll also need it for vertex outputs. Signed-off-by: Alyssa Rosenzweig --- diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c index 7fa9c4b598f..6cd06bc001f 100644 --- a/src/panfrost/midgard/midgard_compile.c +++ b/src/panfrost/midgard/midgard_compile.c @@ -530,6 +530,21 @@ emit_load_const(compiler_context *ctx, nir_load_const_instr *instr) _mesa_hash_table_u64_insert(ctx->ssa_constants, def.index + 1, v); } +/* Normally constants are embedded implicitly, but for I/O and such we have to + * explicitly emit a move with the constant source */ + +static void +emit_explicit_constant(compiler_context *ctx, unsigned node, unsigned to) +{ + void *constant_value = _mesa_hash_table_u64_search(ctx->ssa_constants, node + 1); + + if (constant_value) { + midgard_instruction ins = v_mov(SSA_FIXED_REGISTER(REGISTER_CONSTANT), blank_alu_src, to); + attach_constants(ctx, &ins, constant_value, node + 1); + emit_mir_instruction(ctx, ins); + } +} + static unsigned nir_src_index(compiler_context *ctx, nir_src *src) { @@ -2077,16 +2092,7 @@ midgard_opt_pos_propagate(compiler_context *ctx, midgard_block *block) static void emit_fragment_epilogue(compiler_context *ctx) { - /* Special case: writing out constants requires us to include the move - * explicitly now, so shove it into r0 */ - - void *constant_value = _mesa_hash_table_u64_search(ctx->ssa_constants, ctx->fragment_output + 1); - - if (constant_value) { - midgard_instruction ins = v_mov(SSA_FIXED_REGISTER(REGISTER_CONSTANT), blank_alu_src, SSA_FIXED_REGISTER(0)); - attach_constants(ctx, &ins, constant_value, ctx->fragment_output + 1); - emit_mir_instruction(ctx, ins); - } + emit_explicit_constant(ctx, ctx->fragment_output, SSA_FIXED_REGISTER(0)); /* Perform the actual fragment writeout. We have two writeout/branch * instructions, forming a loop until writeout is successful as per the