Mesa (main): nir/algebraic: Mark the automaton's filter tables as const.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Dec 7 07:49:39 UTC 2021


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

Author: Emma Anholt <emma at anholt.net>
Date:   Wed Dec  1 14:20:55 2021 -0800

nir/algebraic: Mark the automaton's filter tables as const.

Moves it to .rodata instead of .data.

Reviewed-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13987>

---

 src/compiler/nir/nir_algebraic.py | 8 ++++++--
 src/compiler/nir/nir_search.c     | 5 +++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py
index 47040d2b121..0f1f3e0612a 100644
--- a/src/compiler/nir/nir_algebraic.py
+++ b/src/compiler/nir/nir_algebraic.py
@@ -1085,16 +1085,20 @@ static const struct transform ${pass_name}_state${state_id}_xforms[] = {
 static const struct per_op_table ${pass_name}_pass_op_table[nir_num_search_ops] = {
 % for op in automaton.opcodes:
    [${get_c_opcode(op)}] = {
-      .filter = (uint16_t []) {
+% if all(e == 0 for e in automaton.filter[op]):
+      .filter = NULL,
+% else:
+      .filter = (const uint16_t []) {
       % for e in automaton.filter[op]:
          ${e},
       % endfor
       },
+% endif
       <%
         num_filtered = len(automaton.rep[op])
       %>
       .num_filtered_states = ${num_filtered},
-      .table = (uint16_t []) {
+      .table = (const uint16_t []) {
       <%
         num_srcs = len(next(iter(automaton.table[op])))
       %>
diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c
index 4e20de1397e..9e13452008d 100644
--- a/src/compiler/nir/nir_search.c
+++ b/src/compiler/nir/nir_search.c
@@ -829,8 +829,9 @@ nir_algebraic_automaton(nir_instr *instr, struct util_dynarray *states,
       unsigned index = 0;
       for (unsigned i = 0; i < nir_op_infos[op].num_inputs; i++) {
          index *= tbl->num_filtered_states;
-         index += tbl->filter[*util_dynarray_element(states, uint16_t,
-                                                     alu->src[i].src.ssa->index)];
+         if (tbl->filter)
+            index += tbl->filter[*util_dynarray_element(states, uint16_t,
+                                                        alu->src[i].src.ssa->index)];
       }
 
       uint16_t *state = util_dynarray_element(states, uint16_t,



More information about the mesa-commit mailing list