diff options
author | Alyssa Rosenzweig <[email protected]> | 2020-03-19 17:21:49 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-03-22 03:32:35 +0000 |
commit | 50d3f4df452d870858ed5165eb917921273f241f (patch) | |
tree | 0e48960d52f3a79ca5ae403db287704b2061d49f /src/panfrost/bifrost | |
parent | 58a51c49bbf48e92a78355401a07fd3870c1746c (diff) |
pan/bi: Add move lowering pass
We need ALU mostly scalarized, but we get vector moves created from
lower_vec_to_mov so let's scalarize that ourselves rather than bother
NIR.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4276>
Diffstat (limited to 'src/panfrost/bifrost')
-rw-r--r-- | src/panfrost/bifrost/bifrost_compile.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 7d050678115..a1040eb6f0f 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -838,6 +838,44 @@ bi_optimize_nir(nir_shader *nir) NIR_PASS(progress, nir, nir_opt_dce); } +static void +bi_insert_mov32(bi_context *ctx, bi_instruction *parent, unsigned comp) +{ + bi_instruction move = { + .type = BI_MOV, + .dest = parent->dest, + .dest_type = nir_type_uint32, + .writemask = (0xF << (4 * comp)), + .src = { parent->src[0] }, + .src_types = { nir_type_uint32 }, + .swizzle = { { comp } } + }; + + bi_emit_before(ctx, parent, move); +} + +static void +bi_lower_mov(bi_context *ctx, bi_block *block) +{ + bi_foreach_instr_in_block_safe(block, ins) { + if (ins->type != BI_MOV) continue; + if (util_bitcount(ins->writemask) <= 4) continue; + + for (unsigned i = 0; i < 4; ++i) { + unsigned quad = (ins->writemask >> (4 * i)) & 0xF; + + if (quad == 0) + continue; + else if (quad == 0xF) + bi_insert_mov32(ctx, ins, i); + else + unreachable("TODO: Lowering <32bit moves"); + } + + bi_remove_instruction(ins); + } +} + void bifrost_compile_shader_nir(nir_shader *nir, panfrost_program *program, unsigned product_id) { @@ -881,6 +919,11 @@ bifrost_compile_shader_nir(nir_shader *nir, panfrost_program *program, unsigned break; /* TODO: Multi-function shaders */ } + bi_foreach_block(ctx, _block) { + bi_block *block = (bi_block *) _block; + bi_lower_mov(ctx, block); + } + bool progress = false; do { |