diff options
author | Alyssa Rosenzweig <alyssa@rosenzweig.io> | 2023-05-27 21:51:00 -0400 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2023-06-09 12:06:00 +0000 |
commit | 13535d3f9ddef4f51b4414518a3f7e7ae4143cad (patch) | |
tree | 07685ee0c16193754baec848e7fc851b01c660d9 | |
parent | 5a55ef2fd13bb05e5c6bc1392fc245e40c508887 (diff) | |
download | mesa-13535d3f9ddef4f51b4414518a3f7e7ae4143cad.tar.gz mesa-13535d3f9ddef4f51b4414518a3f7e7ae4143cad.tar.bz2 mesa-13535d3f9ddef4f51b4414518a3f7e7ae4143cad.zip |
agx: Refactor expressions in agx_nir_lower_address
So we can add more instructions without duplication.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Acked-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23529>
-rw-r--r-- | src/asahi/compiler/agx_nir_lower_address.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/asahi/compiler/agx_nir_lower_address.c b/src/asahi/compiler/agx_nir_lower_address.c index f5dddf6589b..a6980ff0e20 100644 --- a/src/asahi/compiler/agx_nir_lower_address.c +++ b/src/asahi/compiler/agx_nir_lower_address.c @@ -293,28 +293,31 @@ pass(struct nir_builder *b, nir_instr *instr, UNUSED void *data) assert(match.shift >= 0); nir_ssa_def *new_base = nir_channel(b, match.base.def, match.base.comp); + nir_ssa_def *repl = NULL; + bool has_dest = (intr->intrinsic != nir_intrinsic_store_global); + unsigned num_components = has_dest ? nir_dest_num_components(intr->dest) : 0; + unsigned bit_size = has_dest ? nir_dest_bit_size(intr->dest) : 0; + if (intr->intrinsic == nir_intrinsic_load_global) { - nir_ssa_def *repl = - nir_load_agx(b, nir_dest_num_components(intr->dest), - nir_dest_bit_size(intr->dest), new_base, offset, + repl = + nir_load_agx(b, num_components, bit_size, new_base, offset, .access = nir_intrinsic_access(intr), .base = match.shift, .format = format, .sign_extend = match.sign_extend); - nir_ssa_def_rewrite_uses(&intr->dest.ssa, repl); } else if (intr->intrinsic == nir_intrinsic_load_global_constant) { - nir_ssa_def *repl = nir_load_constant_agx( - b, nir_dest_num_components(intr->dest), nir_dest_bit_size(intr->dest), - new_base, offset, .access = nir_intrinsic_access(intr), - .base = match.shift, .format = format, - .sign_extend = match.sign_extend); - - nir_ssa_def_rewrite_uses(&intr->dest.ssa, repl); + repl = nir_load_constant_agx(b, num_components, bit_size, new_base, + offset, .access = nir_intrinsic_access(intr), + .base = match.shift, .format = format, + .sign_extend = match.sign_extend); } else { nir_store_agx(b, intr->src[0].ssa, new_base, offset, .access = nir_intrinsic_access(intr), .base = match.shift, .format = format, .sign_extend = match.sign_extend); } + if (repl) + nir_ssa_def_rewrite_uses(&intr->dest.ssa, repl); + nir_instr_remove(instr); return true; } |