summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConnor Abbott <[email protected]>2016-04-12 15:30:22 -0400
committerJason Ekstrand <[email protected]>2016-04-28 15:52:17 -0700
commit3a8688fb4103ed6f21d1311a9331efff456294b0 (patch)
tree4f8672220208b7d9cc0dc1a2d1be536fd1c376a3
parent1f8c1006140cf755f35f4196bd703c4a586d7609 (diff)
nir/algebraic: fixup for new foreach_block()
Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r--src/compiler/nir/nir_algebraic.py34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py
index 1fc0289f0dd..4388c5f21f9 100644
--- a/src/compiler/nir/nir_algebraic.py
+++ b/src/compiler/nir/nir_algebraic.py
@@ -503,12 +503,6 @@ struct transform {
unsigned condition_offset;
};
-struct opt_state {
- void *mem_ctx;
- bool progress;
- const bool *condition_flags;
-};
-
#endif
% for (opcode, xform_list) in xform_dict.iteritems():
@@ -525,9 +519,10 @@ static const struct transform ${pass_name}_${opcode}_xforms[] = {
% endfor
static bool
-${pass_name}_block(nir_block *block, void *void_state)
+${pass_name}_block(nir_block *block, const bool *condition_flags,
+ void *mem_ctx)
{
- struct opt_state *state = void_state;
+ bool progress = false;
nir_foreach_instr_reverse_safe(block, instr) {
if (instr->type != nir_instr_type_alu)
@@ -542,10 +537,10 @@ ${pass_name}_block(nir_block *block, void *void_state)
case nir_op_${opcode}:
for (unsigned i = 0; i < ARRAY_SIZE(${pass_name}_${opcode}_xforms); i++) {
const struct transform *xform = &${pass_name}_${opcode}_xforms[i];
- if (state->condition_flags[xform->condition_offset] &&
+ if (condition_flags[xform->condition_offset] &&
nir_replace_instr(alu, xform->search, xform->replace,
- state->mem_ctx)) {
- state->progress = true;
+ mem_ctx)) {
+ progress = true;
break;
}
}
@@ -556,25 +551,24 @@ ${pass_name}_block(nir_block *block, void *void_state)
}
}
- return true;
+ return progress;
}
static bool
${pass_name}_impl(nir_function_impl *impl, const bool *condition_flags)
{
- struct opt_state state;
-
- state.mem_ctx = ralloc_parent(impl);
- state.progress = false;
- state.condition_flags = condition_flags;
+ void *mem_ctx = ralloc_parent(impl);
+ bool progress = false;
- nir_foreach_block_reverse_call(impl, ${pass_name}_block, &state);
+ nir_foreach_block_reverse(block, impl) {
+ progress |= ${pass_name}_block(block, condition_flags, mem_ctx);
+ }
- if (state.progress)
+ if (progress)
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
- return state.progress;
+ return progress;
}