[Mesa-dev] [PATCH 13/13] SQUASH: nir: Update various components for the new list-based use/def sets
--- src/glsl/nir/nir_from_ssa.c | 11 +-- src/glsl/nir/nir_lower_locals_to_regs.c | 14 ++ src/glsl/nir/nir_lower_to_source_mods.c | 20 src/glsl/nir/nir_lower_vars_to_ssa.c| 3 ++- src/glsl/nir/nir_opt_gcm.c | 14 ++ src/glsl/nir/nir_opt_global_to_local.c | 13 ++--- src/glsl/nir/nir_opt_peephole_ffma.c| 9 - src/glsl/nir/nir_opt_peephole_select.c | 10 -- src/glsl/nir/nir_to_ssa.c | 19 ++- 9 files changed, 55 insertions(+), 58 deletions(-) diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c index 5e7deca..94d1ced 100644 --- a/src/glsl/nir/nir_from_ssa.c +++ b/src/glsl/nir/nir_from_ssa.c @@ -345,6 +345,7 @@ isolate_phi_nodes_block(nir_block *block, void *void_state) nir_parallel_copy_entry *entry = rzalloc(state->dead_ctx, nir_parallel_copy_entry); + entry->src.parent_instr = &pcopy->instr; nir_ssa_dest_init(&pcopy->instr, &entry->dest, phi->dest.ssa.num_components, src->src.ssa->name); exec_list_push_tail(&pcopy->entries, &entry->node); @@ -358,6 +359,7 @@ isolate_phi_nodes_block(nir_block *block, void *void_state) nir_parallel_copy_entry *entry = rzalloc(state->dead_ctx, nir_parallel_copy_entry); + entry->src.parent_instr = &block_pcopy->instr; nir_ssa_dest_init(&block_pcopy->instr, &entry->dest, phi->dest.ssa.num_components, phi->dest.ssa.name); exec_list_push_tail(&block_pcopy->entries, &entry->node); @@ -503,7 +505,7 @@ rewrite_ssa_def(nir_ssa_def *def, void *void_state) } nir_ssa_def_rewrite_uses(def, nir_src_for_reg(reg), state->mem_ctx); - assert(def->uses->entries == 0 && def->if_uses->entries == 0); + assert(list_empty(&def->uses) && list_empty(&def->if_uses)); if (def->parent_instr->type == nir_instr_type_ssa_undef) return true; @@ -515,12 +517,9 @@ rewrite_ssa_def(nir_ssa_def *def, void *void_state) */ nir_dest *dest = exec_node_data(nir_dest, def, ssa); - _mesa_set_destroy(dest->ssa.uses, NULL); - _mesa_set_destroy(dest->ssa.if_uses, NULL); - *dest = nir_dest_for_reg(reg); - - _mesa_set_add(reg->defs, state->instr); + dest->reg.parent_instr = state->instr; + list_addtail(&dest->reg.def_link, ®->defs); return true; } diff --git a/src/glsl/nir/nir_lower_locals_to_regs.c b/src/glsl/nir/nir_lower_locals_to_regs.c index bc6a3d3..28fdec5 100644 --- a/src/glsl/nir/nir_lower_locals_to_regs.c +++ b/src/glsl/nir/nir_lower_locals_to_regs.c @@ -269,18 +269,16 @@ lower_locals_to_regs_block(nir_block *block, void *void_state) static nir_block * compute_reg_usedef_lca(nir_register *reg) { - struct set_entry *entry; nir_block *lca = NULL; - set_foreach(reg->defs, entry) - lca = nir_dominance_lca(lca, ((nir_instr *)entry->key)->block); + list_for_each_entry(nir_dest, def_dest, ®->defs, reg.def_link) + lca = nir_dominance_lca(lca, def_dest->reg.parent_instr->block); - set_foreach(reg->uses, entry) - lca = nir_dominance_lca(lca, ((nir_instr *)entry->key)->block); + list_for_each_entry(nir_src, use_src, ®->uses, use_link) + lca = nir_dominance_lca(lca, use_src->parent_instr->block); - set_foreach(reg->if_uses, entry) { - nir_if *if_stmt = (nir_if *)entry->key; - nir_cf_node *prev_node = nir_cf_node_prev(&if_stmt->cf_node); + list_for_each_entry(nir_src, use_src, ®->if_uses, use_link) { + nir_cf_node *prev_node = nir_cf_node_prev(&use_src->parent_if->cf_node); assert(prev_node->type == nir_cf_node_block); lca = nir_dominance_lca(lca, nir_cf_node_as_block(prev_node)); } diff --git a/src/glsl/nir/nir_lower_to_source_mods.c b/src/glsl/nir/nir_lower_to_source_mods.c index 7b4a0f6..94c7e36 100644 --- a/src/glsl/nir/nir_lower_to_source_mods.c +++ b/src/glsl/nir/nir_lower_to_source_mods.c @@ -88,8 +88,8 @@ nir_lower_to_source_mods_block(nir_block *block, void *state) alu->src[i].swizzle[j] = parent->src[0].swizzle[alu->src[i].swizzle[j]]; } - if (parent->dest.dest.ssa.uses->entries == 0 && - parent->dest.dest.ssa.if_uses->entries == 0) + if (list_empty(&parent->dest.dest.ssa.uses) && + list_empty(&parent->dest.dest.ssa.if_uses)) nir_instr_remove(&parent->instr); } @@ -131,13 +131,13 @@ nir_lower_to_source_mods_block(nir_block *block, void *state) if (nir_op_infos[alu->op].output_type != nir_type_float) continue; - if (alu->dest.dest.ssa.if_uses->entries != 0) + if (!list_empty(&alu->dest.dest.ssa.if_uses)) continue; bool all_children_are_sat = true; - struct set_entry *entry; - set_foreach(alu->dest.dest.ssa.uses, entry) { - const nir_instr *child =
Re: [Mesa-dev] [PATCH 13/13] SQUASH: nir: Update various components for the new list-based use/def sets
On Tue, Apr 28, 2015 at 12:03 AM, Jason Ekstrand wrote: > --- > src/glsl/nir/nir_from_ssa.c | 11 +-- > src/glsl/nir/nir_lower_locals_to_regs.c | 14 ++ > src/glsl/nir/nir_lower_to_source_mods.c | 20 > src/glsl/nir/nir_lower_vars_to_ssa.c| 3 ++- > src/glsl/nir/nir_opt_gcm.c | 14 ++ > src/glsl/nir/nir_opt_global_to_local.c | 13 ++--- > src/glsl/nir/nir_opt_peephole_ffma.c| 9 - > src/glsl/nir/nir_opt_peephole_select.c | 10 -- > src/glsl/nir/nir_to_ssa.c | 19 ++- > 9 files changed, 55 insertions(+), 58 deletions(-) > > diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c > index 5e7deca..94d1ced 100644 > --- a/src/glsl/nir/nir_from_ssa.c > +++ b/src/glsl/nir/nir_from_ssa.c > @@ -345,6 +345,7 @@ isolate_phi_nodes_block(nir_block *block, void > *void_state) > > nir_parallel_copy_entry *entry = rzalloc(state->dead_ctx, >nir_parallel_copy_entry); > + entry->src.parent_instr = &pcopy->instr; I don't think this change, or the one immediately below, are needed since nir_instr_rewrite_uses() will already set the parent_instr. > nir_ssa_dest_init(&pcopy->instr, &entry->dest, > phi->dest.ssa.num_components, src->src.ssa->name); > exec_list_push_tail(&pcopy->entries, &entry->node); > @@ -358,6 +359,7 @@ isolate_phi_nodes_block(nir_block *block, void > *void_state) > >nir_parallel_copy_entry *entry = rzalloc(state->dead_ctx, > nir_parallel_copy_entry); > + entry->src.parent_instr = &block_pcopy->instr; >nir_ssa_dest_init(&block_pcopy->instr, &entry->dest, > phi->dest.ssa.num_components, phi->dest.ssa.name); >exec_list_push_tail(&block_pcopy->entries, &entry->node); > @@ -503,7 +505,7 @@ rewrite_ssa_def(nir_ssa_def *def, void *void_state) > } > > nir_ssa_def_rewrite_uses(def, nir_src_for_reg(reg), state->mem_ctx); > - assert(def->uses->entries == 0 && def->if_uses->entries == 0); > + assert(list_empty(&def->uses) && list_empty(&def->if_uses)); > > if (def->parent_instr->type == nir_instr_type_ssa_undef) >return true; > @@ -515,12 +517,9 @@ rewrite_ssa_def(nir_ssa_def *def, void *void_state) > */ > nir_dest *dest = exec_node_data(nir_dest, def, ssa); > > - _mesa_set_destroy(dest->ssa.uses, NULL); > - _mesa_set_destroy(dest->ssa.if_uses, NULL); > - > *dest = nir_dest_for_reg(reg); > - > - _mesa_set_add(reg->defs, state->instr); > + dest->reg.parent_instr = state->instr; > + list_addtail(&dest->reg.def_link, ®->defs); > > return true; > } > diff --git a/src/glsl/nir/nir_lower_locals_to_regs.c > b/src/glsl/nir/nir_lower_locals_to_regs.c > index bc6a3d3..28fdec5 100644 > --- a/src/glsl/nir/nir_lower_locals_to_regs.c > +++ b/src/glsl/nir/nir_lower_locals_to_regs.c > @@ -269,18 +269,16 @@ lower_locals_to_regs_block(nir_block *block, void > *void_state) > static nir_block * > compute_reg_usedef_lca(nir_register *reg) > { > - struct set_entry *entry; > nir_block *lca = NULL; > > - set_foreach(reg->defs, entry) > - lca = nir_dominance_lca(lca, ((nir_instr *)entry->key)->block); > + list_for_each_entry(nir_dest, def_dest, ®->defs, reg.def_link) > + lca = nir_dominance_lca(lca, def_dest->reg.parent_instr->block); > > - set_foreach(reg->uses, entry) > - lca = nir_dominance_lca(lca, ((nir_instr *)entry->key)->block); > + list_for_each_entry(nir_src, use_src, ®->uses, use_link) > + lca = nir_dominance_lca(lca, use_src->parent_instr->block); > > - set_foreach(reg->if_uses, entry) { > - nir_if *if_stmt = (nir_if *)entry->key; > - nir_cf_node *prev_node = nir_cf_node_prev(&if_stmt->cf_node); > + list_for_each_entry(nir_src, use_src, ®->if_uses, use_link) { > + nir_cf_node *prev_node = > nir_cf_node_prev(&use_src->parent_if->cf_node); >assert(prev_node->type == nir_cf_node_block); >lca = nir_dominance_lca(lca, nir_cf_node_as_block(prev_node)); > } > diff --git a/src/glsl/nir/nir_lower_to_source_mods.c > b/src/glsl/nir/nir_lower_to_source_mods.c > index 7b4a0f6..94c7e36 100644 > --- a/src/glsl/nir/nir_lower_to_source_mods.c > +++ b/src/glsl/nir/nir_lower_to_source_mods.c > @@ -88,8 +88,8 @@ nir_lower_to_source_mods_block(nir_block *block, void > *state) > alu->src[i].swizzle[j] = > parent->src[0].swizzle[alu->src[i].swizzle[j]]; > } > > - if (parent->dest.dest.ssa.uses->entries == 0 && > - parent->dest.dest.ssa.if_uses->entries == 0) > + if (list_empty(&parent->dest.dest.ssa.uses) && > + list_empty(&parent->dest.dest.ssa.if_uses)) > nir_instr_remove(&parent->instr); >} > > @@ -131,13 +131,13 @@ nir_lower_to_source_mods_block(nir_block *bloc