summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConnor Abbott <[email protected]>2016-04-08 15:12:40 -0400
committerJason Ekstrand <[email protected]>2016-04-28 15:52:17 -0700
commitb23e59e1726d75790d0e2f8c8bab54446a50a6bf (patch)
tree06d8fb32968a56f208e930f0aee1e311c4b6a9a8
parentd6a6c729caae6d49a5ee6692b56f8d9c1c5334fc (diff)
nir/from_ssa: fixup for new foreach_block()
Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r--src/compiler/nir/nir_from_ssa.c57
1 files changed, 30 insertions, 27 deletions
diff --git a/src/compiler/nir/nir_from_ssa.c b/src/compiler/nir/nir_from_ssa.c
index b24d60633a4..6d92130b859 100644
--- a/src/compiler/nir/nir_from_ssa.c
+++ b/src/compiler/nir/nir_from_ssa.c
@@ -224,9 +224,8 @@ merge_sets_interfere(merge_set *a, merge_set *b)
}
static bool
-add_parallel_copy_to_end_of_block(nir_block *block, void *void_state)
+add_parallel_copy_to_end_of_block(nir_block *block, void *dead_ctx)
{
- struct from_ssa_state *state = void_state;
bool need_end_copy = false;
if (block->successors[0]) {
@@ -247,7 +246,7 @@ add_parallel_copy_to_end_of_block(nir_block *block, void *void_state)
* (if there is one).
*/
nir_parallel_copy_instr *pcopy =
- nir_parallel_copy_instr_create(state->dead_ctx);
+ nir_parallel_copy_instr_create(dead_ctx);
nir_instr_insert(nir_after_block_before_jump(block), &pcopy->instr);
}
@@ -303,10 +302,8 @@ get_parallel_copy_at_end_of_block(nir_block *block)
* time because of potential back-edges in the CFG.
*/
static bool
-isolate_phi_nodes_block(nir_block *block, void *void_state)
+isolate_phi_nodes_block(nir_block *block, void *dead_ctx)
{
- struct from_ssa_state *state = void_state;
-
nir_instr *last_phi_instr = NULL;
nir_foreach_instr(block, instr) {
/* Phi nodes only ever come at the start of a block */
@@ -324,7 +321,7 @@ isolate_phi_nodes_block(nir_block *block, void *void_state)
* start of this block but after the phi nodes.
*/
nir_parallel_copy_instr *block_pcopy =
- nir_parallel_copy_instr_create(state->dead_ctx);
+ nir_parallel_copy_instr_create(dead_ctx);
nir_instr_insert_after(last_phi_instr, &block_pcopy->instr);
nir_foreach_instr(block, instr) {
@@ -339,7 +336,7 @@ isolate_phi_nodes_block(nir_block *block, void *void_state)
get_parallel_copy_at_end_of_block(src->pred);
assert(pcopy);
- nir_parallel_copy_entry *entry = rzalloc(state->dead_ctx,
+ nir_parallel_copy_entry *entry = rzalloc(dead_ctx,
nir_parallel_copy_entry);
nir_ssa_dest_init(&pcopy->instr, &entry->dest,
phi->dest.ssa.num_components,
@@ -353,7 +350,7 @@ isolate_phi_nodes_block(nir_block *block, void *void_state)
nir_src_for_ssa(&entry->dest.ssa));
}
- nir_parallel_copy_entry *entry = rzalloc(state->dead_ctx,
+ nir_parallel_copy_entry *entry = rzalloc(dead_ctx,
nir_parallel_copy_entry);
nir_ssa_dest_init(&block_pcopy->instr, &entry->dest,
phi->dest.ssa.num_components, phi->dest.ssa.bit_size,
@@ -371,10 +368,8 @@ isolate_phi_nodes_block(nir_block *block, void *void_state)
}
static bool
-coalesce_phi_nodes_block(nir_block *block, void *void_state)
+coalesce_phi_nodes_block(nir_block *block, struct from_ssa_state *state)
{
- struct from_ssa_state *state = void_state;
-
nir_foreach_instr(block, instr) {
/* Phi nodes only ever come at the start of a block */
if (instr->type != nir_instr_type_phi)
@@ -426,10 +421,8 @@ aggressive_coalesce_parallel_copy(nir_parallel_copy_instr *pcopy,
}
static bool
-aggressive_coalesce_block(nir_block *block, void *void_state)
+aggressive_coalesce_block(nir_block *block, struct from_ssa_state *state)
{
- struct from_ssa_state *state = void_state;
-
nir_parallel_copy_instr *start_pcopy = NULL;
nir_foreach_instr(block, instr) {
/* Phi nodes only ever come at the start of a block */
@@ -525,10 +518,8 @@ rewrite_ssa_def(nir_ssa_def *def, void *void_state)
* remove phi nodes.
*/
static bool
-resolve_registers_block(nir_block *block, void *void_state)
+resolve_registers_block(nir_block *block, struct from_ssa_state *state)
{
- struct from_ssa_state *state = void_state;
-
nir_foreach_instr_safe(block, instr) {
state->instr = instr;
nir_foreach_ssa_def(instr, rewrite_ssa_def, state);
@@ -731,10 +722,8 @@ resolve_parallel_copy(nir_parallel_copy_instr *pcopy,
* the end (or right before the final jump if it exists).
*/
static bool
-resolve_parallel_copies_block(nir_block *block, void *void_state)
+resolve_parallel_copies_block(nir_block *block, struct from_ssa_state *state)
{
- struct from_ssa_state *state = void_state;
-
/* At this point, we have removed all of the phi nodes. If a parallel
* copy existed right after the phi nodes in this block, it is now the
* first instruction.
@@ -774,8 +763,13 @@ nir_convert_from_ssa_impl(nir_function_impl *impl, bool phi_webs_only)
state.merge_node_table = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
_mesa_key_pointer_equal);
- nir_foreach_block_call(impl, add_parallel_copy_to_end_of_block, &state);
- nir_foreach_block_call(impl, isolate_phi_nodes_block, &state);
+ nir_foreach_block(block, impl) {
+ add_parallel_copy_to_end_of_block(block, state.dead_ctx);
+ }
+
+ nir_foreach_block(block, impl) {
+ isolate_phi_nodes_block(block, state.dead_ctx);
+ }
/* Mark metadata as dirty before we ask for liveness analysis */
nir_metadata_preserve(impl, nir_metadata_block_index |
@@ -784,12 +778,21 @@ nir_convert_from_ssa_impl(nir_function_impl *impl, bool phi_webs_only)
nir_metadata_require(impl, nir_metadata_live_ssa_defs |
nir_metadata_dominance);
- nir_foreach_block_call(impl, coalesce_phi_nodes_block, &state);
- nir_foreach_block_call(impl, aggressive_coalesce_block, &state);
+ nir_foreach_block(block, impl) {
+ coalesce_phi_nodes_block(block, &state);
+ }
- nir_foreach_block_call(impl, resolve_registers_block, &state);
+ nir_foreach_block(block, impl) {
+ aggressive_coalesce_block(block, &state);
+ }
+
+ nir_foreach_block(block, impl) {
+ resolve_registers_block(block, &state);
+ }
- nir_foreach_block_call(impl, resolve_parallel_copies_block, &state);
+ nir_foreach_block(block, impl) {
+ resolve_parallel_copies_block(block, &state);
+ }
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);