summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorConnor Abbott <[email protected]>2019-05-02 22:22:01 +0200
committerConnor Abbott <[email protected]>2019-05-04 00:13:21 +0200
commitd0ea9877b830ab2fe8948e70846efb5fff78cf0c (patch)
treef4f889a21ecf31667a7b25c918fafa457953350c /src/compiler
parent8987152ac16153999c972f08b6864c5e5ec9bdfb (diff)
nir/algebraic: Don't emit empty initializers for MSVC
Just don't emit the transform array at all if there are no transforms v2: - Don't use len(array) > 0 (Dylan) - Keep using ARRAY_SIZE to make the generated C code easier to read (Jason).
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir_algebraic.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py
index 6db749e9248..47f374bfabd 100644
--- a/src/compiler/nir/nir_algebraic.py
+++ b/src/compiler/nir/nir_algebraic.py
@@ -993,11 +993,13 @@ static const uint16_t CONST_STATE = 1;
% endfor
% for state_id, state_xforms in enumerate(automaton.state_patterns):
+% if state_xforms: # avoid emitting a 0-length array for MSVC
static const struct transform ${pass_name}_state${state_id}_xforms[] = {
% for i in state_xforms:
{ ${xforms[i].search.c_ptr(cache)}, ${xforms[i].replace.c_value_ptr(cache)}, ${xforms[i].condition_index} },
% endfor
};
+% endif
% endfor
static const struct per_op_table ${pass_name}_table[nir_num_search_ops] = {
@@ -1080,6 +1082,7 @@ ${pass_name}_block(nir_builder *build, nir_block *block,
switch (states[alu->dest.dest.ssa.index]) {
% for i in range(len(automaton.state_patterns)):
case ${i}:
+ % if automaton.state_patterns[i]:
for (unsigned i = 0; i < ARRAY_SIZE(${pass_name}_state${i}_xforms); i++) {
const struct transform *xform = &${pass_name}_state${i}_xforms[i];
if (condition_flags[xform->condition_offset] &&
@@ -1088,6 +1091,7 @@ ${pass_name}_block(nir_builder *build, nir_block *block,
break;
}
}
+ % endif
break;
% endfor
default: assert(0);