Module: Mesa
Branch: main
Commit: eab4d6a96f3bf85aaec68f614e50eeec45aa6a92
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=eab4d6a96f3bf85aaec68f614e50eeec45aa6a92

Author: Alyssa Rosenzweig <[email protected]>
Date:   Fri Feb 17 18:35:20 2023 -0500

agx: Add and use agx_nir_ssa_index helper

Common subexpression that we'll repeat once more in the next patch.

Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21431>

---

 src/asahi/compiler/agx_compile.c  |  3 +--
 src/asahi/compiler/agx_compiler.h | 15 ++++++++-------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c
index 7b135a297be..b5e8c3f69e3 100644
--- a/src/asahi/compiler/agx_compile.c
+++ b/src/asahi/compiler/agx_compile.c
@@ -294,8 +294,7 @@ agx_emit_load_const(agx_builder *b, nir_load_const_instr 
*instr)
    assert(instr->def.num_components == 1);
 
    /* Emit move, later passes can inline/push if useful */
-   agx_mov_imm_to(b,
-                  agx_get_index(instr->def.index, agx_size_for_bits(bit_size)),
+   agx_mov_imm_to(b, agx_nir_ssa_index(&instr->def),
                   nir_const_value_as_uint(instr->value[0], bit_size));
 }
 
diff --git a/src/asahi/compiler/agx_compiler.h 
b/src/asahi/compiler/agx_compiler.h
index 69d9dcc41c6..a6786e0ae1d 100644
--- a/src/asahi/compiler/agx_compiler.h
+++ b/src/asahi/compiler/agx_compiler.h
@@ -474,22 +474,23 @@ agx_size_for_bits(unsigned bits)
    }
 }
 
+static inline agx_index
+agx_nir_ssa_index(nir_ssa_def *ssa)
+{
+   return agx_get_index(ssa->index, agx_size_for_bits(ssa->bit_size));
+}
+
 static inline agx_index
 agx_src_index(nir_src *src)
 {
    assert(src->is_ssa);
-
-   return agx_get_index(src->ssa->index,
-                        agx_size_for_bits(nir_src_bit_size(*src)));
+   return agx_nir_ssa_index(src->ssa);
 }
 
 static inline agx_index
 agx_dest_index(nir_dest *dst)
 {
-   assert(dst->is_ssa);
-
-   return agx_get_index(dst->ssa.index,
-                        agx_size_for_bits(nir_dest_bit_size(*dst)));
+   return agx_nir_ssa_index(&dst->ssa);
 }
 
 static inline agx_index

Reply via email to