[Mesa-dev] [PATCH 03/47] nir/from_ssa: fixup for new foreach_block()
Connor Abbott
cwabbott0 at gmail.com
Wed Apr 13 04:34:42 UTC 2016
Signed-off-by: Connor Abbott <cwabbott0 at gmail.com>
---
src/compiler/nir/nir_from_ssa.c | 57 ++++++++++++++++++++++-------------------
1 file changed, 30 insertions(+), 27 deletions(-)
diff --git a/src/compiler/nir/nir_from_ssa.c b/src/compiler/nir/nir_from_ssa.c
index 82317c2..7b27fda 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 */
@@ -523,10 +516,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);
@@ -729,10 +720,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.
@@ -772,8 +761,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(impl, add_parallel_copy_to_end_of_block, &state);
- nir_foreach_block(impl, isolate_phi_nodes_block, &state);
+ nir_foreach_block(impl, block) {
+ add_parallel_copy_to_end_of_block(block, state.dead_ctx);
+ }
+
+ nir_foreach_block(impl, block) {
+ 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 |
@@ -782,12 +776,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(impl, coalesce_phi_nodes_block, &state);
- nir_foreach_block(impl, aggressive_coalesce_block, &state);
+ nir_foreach_block(impl, block) {
+ coalesce_phi_nodes_block(block, &state);
+ }
- nir_foreach_block(impl, resolve_registers_block, &state);
+ nir_foreach_block(impl, block) {
+ aggressive_coalesce_block(block, &state);
+ }
+
+ nir_foreach_block(impl, block) {
+ resolve_registers_block(block, &state);
+ }
- nir_foreach_block(impl, resolve_parallel_copies_block, &state);
+ nir_foreach_block(impl, block) {
+ resolve_parallel_copies_block(block, &state);
+ }
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
--
2.5.0
More information about the mesa-dev
mailing list