From a29b54f01464dc2e5154a9701826465e8281487c Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Wed, 1 Dec 2021 14:20:55 -0800 Subject: [PATCH] nir/algebraic: Mark the automaton's filter tables as const. Moves it to .rodata instead of .data. Reviewed-by: Adam Jackson Part-of: --- 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,