nir: Remove the mem_ctx parameter from ssa_def_rewrite_uses
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 9 Sep 2015 20:24:35 +0000 (13:24 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 11 Sep 2015 16:21:20 +0000 (09:21 -0700)
Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
20 files changed:
src/glsl/nir/nir.c
src/glsl/nir/nir.h
src/glsl/nir/nir_control_flow.c
src/glsl/nir/nir_from_ssa.c
src/glsl/nir/nir_lower_alu_to_scalar.c
src/glsl/nir/nir_lower_atomics.c
src/glsl/nir/nir_lower_idiv.c
src/glsl/nir/nir_lower_io.c
src/glsl/nir/nir_lower_load_const_to_scalar.c
src/glsl/nir/nir_lower_locals_to_regs.c
src/glsl/nir/nir_lower_phis_to_scalar.c
src/glsl/nir/nir_lower_system_values.c
src/glsl/nir/nir_lower_vars_to_ssa.c
src/glsl/nir/nir_opt_constant_folding.c
src/glsl/nir/nir_opt_cse.c
src/glsl/nir/nir_opt_dead_cf.c
src/glsl/nir/nir_opt_peephole_ffma.c
src/glsl/nir/nir_opt_peephole_select.c
src/glsl/nir/nir_opt_remove_phis.c
src/glsl/nir/nir_search.c

index fd67532..13489f0 100644 (file)
@@ -1205,7 +1205,7 @@ nir_ssa_dest_init(nir_instr *instr, nir_dest *dest,
 }
 
 void
-nir_ssa_def_rewrite_uses(nir_ssa_def *def, nir_src new_src, void *mem_ctx)
+nir_ssa_def_rewrite_uses(nir_ssa_def *def, nir_src new_src)
 {
    assert(!new_src.is_ssa || def != new_src.ssa);
 
index 92945f9..05cc42c 100644 (file)
@@ -1740,7 +1740,7 @@ void nir_ssa_dest_init(nir_instr *instr, nir_dest *dest,
                        unsigned num_components, const char *name);
 void nir_ssa_def_init(nir_instr *instr, nir_ssa_def *def,
                       unsigned num_components, const char *name);
-void nir_ssa_def_rewrite_uses(nir_ssa_def *def, nir_src new_src, void *mem_ctx);
+void nir_ssa_def_rewrite_uses(nir_ssa_def *def, nir_src new_src);
 
 /* visits basic blocks in source-code order */
 typedef bool (*nir_foreach_block_cb)(nir_block *block, void *state);
index 5c03375..768dfd2 100644 (file)
@@ -654,7 +654,7 @@ replace_ssa_def_uses(nir_ssa_def *def, void *void_impl)
    nir_ssa_undef_instr *undef =
       nir_ssa_undef_instr_create(mem_ctx, def->num_components);
    nir_instr_insert_before_cf_list(&impl->body, &undef->instr);
-   nir_ssa_def_rewrite_uses(def, nir_src_for_ssa(&undef->def), mem_ctx);
+   nir_ssa_def_rewrite_uses(def, nir_src_for_ssa(&undef->def));
    return true;
 }
 
index d6569d8..084f43d 100644 (file)
@@ -359,8 +359,7 @@ isolate_phi_nodes_block(nir_block *block, void *void_state)
       exec_list_push_tail(&block_pcopy->entries, &entry->node);
 
       nir_ssa_def_rewrite_uses(&phi->dest.ssa,
-                               nir_src_for_ssa(&entry->dest.ssa),
-                               state->mem_ctx);
+                               nir_src_for_ssa(&entry->dest.ssa));
 
       nir_instr_rewrite_src(&block_pcopy->instr, &entry->src,
                             nir_src_for_ssa(&phi->dest.ssa));
@@ -493,7 +492,7 @@ rewrite_ssa_def(nir_ssa_def *def, void *void_state)
       reg->num_array_elems = 0;
    }
 
-   nir_ssa_def_rewrite_uses(def, nir_src_for_reg(reg), state->mem_ctx);
+   nir_ssa_def_rewrite_uses(def, nir_src_for_reg(reg));
    assert(list_empty(&def->uses) && list_empty(&def->if_uses));
 
    if (def->parent_instr->type == nir_instr_type_ssa_undef) {
index 1607308..710bb37 100644 (file)
@@ -70,8 +70,7 @@ lower_reduction(nir_alu_instr *instr, nir_op chan_op, nir_op merge_op,
    }
 
    assert(instr->dest.write_mask == 1);
-   nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa, nir_src_for_ssa(last),
-                            mem_ctx);
+   nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa, nir_src_for_ssa(last));
    nir_instr_remove(&instr->instr);
 }
 
@@ -168,8 +167,7 @@ lower_alu_instr_scalar(nir_alu_instr *instr, void *mem_ctx)
    nir_instr_insert_before(&instr->instr, &vec_instr->instr);
 
    nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa,
-                            nir_src_for_ssa(&vec_instr->dest.dest.ssa),
-                            mem_ctx);
+                            nir_src_for_ssa(&vec_instr->dest.dest.ssa));
 
    nir_instr_remove(&instr->instr);
 }
index 7ae8462..6f9ecc0 100644 (file)
@@ -116,8 +116,7 @@ lower_instr(nir_intrinsic_instr *instr, nir_function_impl *impl)
       nir_ssa_dest_init(&new_instr->instr, &new_instr->dest,
                         instr->dest.ssa.num_components, NULL);
       nir_ssa_def_rewrite_uses(&instr->dest.ssa,
-                               nir_src_for_ssa(&new_instr->dest.ssa),
-                               mem_ctx);
+                               nir_src_for_ssa(&new_instr->dest.ssa));
    } else {
       nir_dest_copy(&new_instr->dest, &instr->dest, mem_ctx);
    }
index 0e1653d..c961178 100644 (file)
@@ -116,9 +116,7 @@ convert_instr(nir_builder *bld, nir_alu_instr *alu)
    }
 
    assert(alu->dest.dest.is_ssa);
-   nir_ssa_def_rewrite_uses(&alu->dest.dest.ssa,
-                            nir_src_for_ssa(q),
-                            ralloc_parent(alu));
+   nir_ssa_def_rewrite_uses(&alu->dest.dest.ssa, nir_src_for_ssa(q));
 }
 
 static bool
index 3739fc8..9f79c56 100644 (file)
@@ -186,8 +186,7 @@ nir_lower_io_block(nir_block *block, void *void_state)
             nir_ssa_dest_init(&load->instr, &load->dest,
                               intrin->num_components, NULL);
             nir_ssa_def_rewrite_uses(&intrin->dest.ssa,
-                                     nir_src_for_ssa(&load->dest.ssa),
-                                     state->mem_ctx);
+                                     nir_src_for_ssa(&load->dest.ssa));
          } else {
             nir_dest_copy(&load->dest, &intrin->dest, state->mem_ctx);
          }
index b83ef05..704f8ce 100644 (file)
@@ -71,8 +71,7 @@ lower_load_const_instr_scalar(nir_load_const_instr *lower)
    }
 
    /* Replace the old load with a reference to our reconstructed vector. */
-   nir_ssa_def_rewrite_uses(&lower->def, nir_src_for_ssa(vec),
-                            ralloc_parent(b.impl));
+   nir_ssa_def_rewrite_uses(&lower->def, nir_src_for_ssa(vec));
    nir_instr_remove(&lower->instr);
 }
 
index b77d974..87d2498 100644 (file)
@@ -221,8 +221,7 @@ lower_locals_to_regs_block(nir_block *block, void *void_state)
             nir_ssa_dest_init(&mov->instr, &mov->dest.dest,
                               intrin->num_components, NULL);
             nir_ssa_def_rewrite_uses(&intrin->dest.ssa,
-                                     nir_src_for_ssa(&mov->dest.dest.ssa),
-                                     state->shader);
+                                     nir_src_for_ssa(&mov->dest.dest.ssa));
          } else {
             nir_dest_copy(&mov->dest.dest, &intrin->dest, &mov->instr);
          }
index 739170d..d72a71d 100644 (file)
@@ -242,8 +242,7 @@ lower_phis_to_scalar_block(nir_block *block, void *void_state)
       nir_instr_insert_after(&last_phi->instr, &vec->instr);
 
       nir_ssa_def_rewrite_uses(&phi->dest.ssa,
-                               nir_src_for_ssa(&vec->dest.dest.ssa),
-                               state->mem_ctx);
+                               nir_src_for_ssa(&vec->dest.dest.ssa));
 
       ralloc_steal(state->dead_ctx, phi);
       nir_instr_remove(&phi->instr);
index a6eec65..440fb0b 100644 (file)
@@ -80,8 +80,7 @@ convert_instr(nir_intrinsic_instr *instr)
       nir_ssa_dest_init(&new_instr->instr, &new_instr->dest,
                         instr->dest.ssa.num_components, NULL);
       nir_ssa_def_rewrite_uses(&instr->dest.ssa,
-                               nir_src_for_ssa(&new_instr->dest.ssa),
-                               mem_ctx);
+                               nir_src_for_ssa(&new_instr->dest.ssa));
    } else {
       nir_dest_copy(&new_instr->dest, &instr->dest, mem_ctx);
    }
index 4ff2166..5971507 100644 (file)
@@ -625,8 +625,7 @@ rename_variables_block(nir_block *block, struct lower_variables_state *state)
                nir_instr_remove(&intrin->instr);
 
                nir_ssa_def_rewrite_uses(&intrin->dest.ssa,
-                                        nir_src_for_ssa(&undef->def),
-                                        state->shader);
+                                        nir_src_for_ssa(&undef->def));
                continue;
             }
 
@@ -650,8 +649,7 @@ rename_variables_block(nir_block *block, struct lower_variables_state *state)
             nir_instr_remove(&intrin->instr);
 
             nir_ssa_def_rewrite_uses(&intrin->dest.ssa,
-                                     nir_src_for_ssa(&mov->dest.dest.ssa),
-                                     state->shader);
+                                     nir_src_for_ssa(&mov->dest.dest.ssa));
             break;
          }
 
index 85c09fc..007b81c 100644 (file)
@@ -80,8 +80,8 @@ constant_fold_alu_instr(nir_alu_instr *instr, void *mem_ctx)
 
    nir_instr_insert_before(&instr->instr, &new_instr->instr);
 
-   nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa, nir_src_for_ssa(&new_instr->def),
-                            mem_ctx);
+   nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa,
+                            nir_src_for_ssa(&new_instr->def));
 
    nir_instr_remove(&instr->instr);
    ralloc_free(instr);
index 864795c..64c94af 100644 (file)
@@ -272,8 +272,7 @@ nir_opt_cse_instr(nir_instr *instr, struct cse_state *state)
       if (nir_instrs_equal(instr, other)) {
          nir_ssa_def *other_def = nir_instr_get_dest_ssa_def(other);
          nir_ssa_def_rewrite_uses(nir_instr_get_dest_ssa_def(instr),
-                                  nir_src_for_ssa(other_def),
-                                  state->mem_ctx);
+                                  nir_src_for_ssa(other_def));
          nir_instr_remove(instr);
          state->progress = true;
          return;
@@ -286,8 +285,7 @@ nir_opt_cse_instr(nir_instr *instr, struct cse_state *state)
          if (nir_instrs_equal(instr, other)) {
             nir_ssa_def *other_def = nir_instr_get_dest_ssa_def(other);
             nir_ssa_def_rewrite_uses(nir_instr_get_dest_ssa_def(instr),
-                                     nir_src_for_ssa(other_def),
-                                     state->mem_ctx);
+                                     nir_src_for_ssa(other_def));
             nir_instr_remove(instr);
             state->progress = true;
             return;
index 5c55104..317bbc5 100644 (file)
@@ -83,8 +83,6 @@ remove_after_cf_node(nir_cf_node *node)
 static void
 opt_constant_if(nir_if *if_stmt, bool condition)
 {
-   void *mem_ctx = ralloc_parent(if_stmt);
-
    /* First, we need to remove any phi nodes after the if by rewriting uses to
     * point to the correct source.
     */
@@ -109,7 +107,7 @@ opt_constant_if(nir_if *if_stmt, bool condition)
 
       assert(def);
       assert(phi->dest.is_ssa);
-      nir_ssa_def_rewrite_uses(&phi->dest.ssa, nir_src_for_ssa(def), mem_ctx);
+      nir_ssa_def_rewrite_uses(&phi->dest.ssa, nir_src_for_ssa(def));
       nir_instr_remove(instr);
    }
 
index a23123e..4f0f0da 100644 (file)
@@ -224,8 +224,7 @@ nir_opt_peephole_ffma_block(nir_block *block, void *void_state)
                         add->dest.dest.ssa.num_components,
                         add->dest.dest.ssa.name);
       nir_ssa_def_rewrite_uses(&add->dest.dest.ssa,
-                               nir_src_for_ssa(&ffma->dest.dest.ssa),
-                               state->mem_ctx);
+                               nir_src_for_ssa(&ffma->dest.dest.ssa));
 
       nir_instr_insert_before(&add->instr, &ffma->instr);
       assert(list_empty(&add->dest.dest.ssa.uses));
index 5b6037a..90902b9 100644 (file)
@@ -214,8 +214,7 @@ nir_opt_peephole_select_block(nir_block *block, void *void_state)
       sel->dest.write_mask = (1 << phi->dest.ssa.num_components) - 1;
 
       nir_ssa_def_rewrite_uses(&phi->dest.ssa,
-                               nir_src_for_ssa(&sel->dest.dest.ssa),
-                               state->mem_ctx);
+                               nir_src_for_ssa(&sel->dest.dest.ssa));
 
       nir_instr_insert_before(&phi->instr, &sel->instr);
       nir_instr_remove(&phi->instr);
index 7896584..bf4a67e 100644 (file)
@@ -47,8 +47,6 @@ remove_phis_block(nir_block *block, void *state)
 {
    bool *progress = state;
 
-   void *mem_ctx = ralloc_parent(block);
-
    nir_foreach_instr_safe(block, instr) {
       if (instr->type != nir_instr_type_phi)
          break;
@@ -75,8 +73,7 @@ remove_phis_block(nir_block *block, void *state)
          continue;
 
       assert(phi->dest.is_ssa);
-      nir_ssa_def_rewrite_uses(&phi->dest.ssa, nir_src_for_ssa(def),
-                               mem_ctx);
+      nir_ssa_def_rewrite_uses(&phi->dest.ssa, nir_src_for_ssa(def));
       nir_instr_remove(instr);
 
       *progress = true;
index 51e69b0..bb15440 100644 (file)
@@ -367,7 +367,7 @@ nir_replace_instr(nir_alu_instr *instr, const nir_search_expression *search,
    nir_instr_insert_before(&instr->instr, &mov->instr);
 
    nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa,
-                            nir_src_for_ssa(&mov->dest.dest.ssa), mem_ctx);
+                            nir_src_for_ssa(&mov->dest.dest.ssa));
 
    /* We know this one has no more uses because we just rewrote them all,
     * so we can remove it.  The rest of the matched expression, however, we