summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-09-09 13:24:35 -0700
committerJason Ekstrand <[email protected]>2015-09-11 09:21:20 -0700
commita4aa25be1e0a27b1a6a6b0bcf576beb9dfe1ea7a (patch)
tree30cefc1dcba792fba83755d8149fff8182a0c7a8
parent8c8fc5f8336c8c79e5890265ae6c03271aa94075 (diff)
nir: Remove the mem_ctx parameter from ssa_def_rewrite_uses
Reviewed-by: Thomas Helland <[email protected]>
-rw-r--r--src/glsl/nir/nir.c2
-rw-r--r--src/glsl/nir/nir.h2
-rw-r--r--src/glsl/nir/nir_control_flow.c2
-rw-r--r--src/glsl/nir/nir_from_ssa.c5
-rw-r--r--src/glsl/nir/nir_lower_alu_to_scalar.c6
-rw-r--r--src/glsl/nir/nir_lower_atomics.c3
-rw-r--r--src/glsl/nir/nir_lower_idiv.c4
-rw-r--r--src/glsl/nir/nir_lower_io.c3
-rw-r--r--src/glsl/nir/nir_lower_load_const_to_scalar.c3
-rw-r--r--src/glsl/nir/nir_lower_locals_to_regs.c3
-rw-r--r--src/glsl/nir/nir_lower_phis_to_scalar.c3
-rw-r--r--src/glsl/nir/nir_lower_system_values.c3
-rw-r--r--src/glsl/nir/nir_lower_vars_to_ssa.c6
-rw-r--r--src/glsl/nir/nir_opt_constant_folding.c4
-rw-r--r--src/glsl/nir/nir_opt_cse.c6
-rw-r--r--src/glsl/nir/nir_opt_dead_cf.c4
-rw-r--r--src/glsl/nir/nir_opt_peephole_ffma.c3
-rw-r--r--src/glsl/nir/nir_opt_peephole_select.c3
-rw-r--r--src/glsl/nir/nir_opt_remove_phis.c5
-rw-r--r--src/glsl/nir/nir_search.c2
20 files changed, 25 insertions, 47 deletions
diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
index fd675322b12..13489f0d38e 100644
--- a/src/glsl/nir/nir.c
+++ b/src/glsl/nir/nir.c
@@ -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);
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 92945f9df7f..05cc42ca26d 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -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);
diff --git a/src/glsl/nir/nir_control_flow.c b/src/glsl/nir/nir_control_flow.c
index 5c03375ac77..768dfd2aff3 100644
--- a/src/glsl/nir/nir_control_flow.c
+++ b/src/glsl/nir/nir_control_flow.c
@@ -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;
}
diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
index d6569d8994a..084f43da87c 100644
--- a/src/glsl/nir/nir_from_ssa.c
+++ b/src/glsl/nir/nir_from_ssa.c
@@ -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) {
diff --git a/src/glsl/nir/nir_lower_alu_to_scalar.c b/src/glsl/nir/nir_lower_alu_to_scalar.c
index 1607308abb1..710bb37409f 100644
--- a/src/glsl/nir/nir_lower_alu_to_scalar.c
+++ b/src/glsl/nir/nir_lower_alu_to_scalar.c
@@ -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);
}
diff --git a/src/glsl/nir/nir_lower_atomics.c b/src/glsl/nir/nir_lower_atomics.c
index 7ae8462882a..6f9ecc019ec 100644
--- a/src/glsl/nir/nir_lower_atomics.c
+++ b/src/glsl/nir/nir_lower_atomics.c
@@ -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);
}
diff --git a/src/glsl/nir/nir_lower_idiv.c b/src/glsl/nir/nir_lower_idiv.c
index 0e1653dd274..c961178c53a 100644
--- a/src/glsl/nir/nir_lower_idiv.c
+++ b/src/glsl/nir/nir_lower_idiv.c
@@ -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
diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c
index 3739fc83f91..9f79c5606ca 100644
--- a/src/glsl/nir/nir_lower_io.c
+++ b/src/glsl/nir/nir_lower_io.c
@@ -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);
}
diff --git a/src/glsl/nir/nir_lower_load_const_to_scalar.c b/src/glsl/nir/nir_lower_load_const_to_scalar.c
index b83ef052ea9..704f8cebfd8 100644
--- a/src/glsl/nir/nir_lower_load_const_to_scalar.c
+++ b/src/glsl/nir/nir_lower_load_const_to_scalar.c
@@ -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);
}
diff --git a/src/glsl/nir/nir_lower_locals_to_regs.c b/src/glsl/nir/nir_lower_locals_to_regs.c
index b77d974f568..87d2498dd79 100644
--- a/src/glsl/nir/nir_lower_locals_to_regs.c
+++ b/src/glsl/nir/nir_lower_locals_to_regs.c
@@ -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);
}
diff --git a/src/glsl/nir/nir_lower_phis_to_scalar.c b/src/glsl/nir/nir_lower_phis_to_scalar.c
index 739170d61fd..d72a71dfb6c 100644
--- a/src/glsl/nir/nir_lower_phis_to_scalar.c
+++ b/src/glsl/nir/nir_lower_phis_to_scalar.c
@@ -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);
diff --git a/src/glsl/nir/nir_lower_system_values.c b/src/glsl/nir/nir_lower_system_values.c
index a6eec653e33..440fb0b1b8e 100644
--- a/src/glsl/nir/nir_lower_system_values.c
+++ b/src/glsl/nir/nir_lower_system_values.c
@@ -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);
}
diff --git a/src/glsl/nir/nir_lower_vars_to_ssa.c b/src/glsl/nir/nir_lower_vars_to_ssa.c
index 4ff21663e57..59715072c15 100644
--- a/src/glsl/nir/nir_lower_vars_to_ssa.c
+++ b/src/glsl/nir/nir_lower_vars_to_ssa.c
@@ -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;
}
diff --git a/src/glsl/nir/nir_opt_constant_folding.c b/src/glsl/nir/nir_opt_constant_folding.c
index 85c09fc4800..007b81cfd41 100644
--- a/src/glsl/nir/nir_opt_constant_folding.c
+++ b/src/glsl/nir/nir_opt_constant_folding.c
@@ -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);
diff --git a/src/glsl/nir/nir_opt_cse.c b/src/glsl/nir/nir_opt_cse.c
index 864795ce5ed..64c94afd480 100644
--- a/src/glsl/nir/nir_opt_cse.c
+++ b/src/glsl/nir/nir_opt_cse.c
@@ -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;
diff --git a/src/glsl/nir/nir_opt_dead_cf.c b/src/glsl/nir/nir_opt_dead_cf.c
index 5c5510484af..317bbc5ba63 100644
--- a/src/glsl/nir/nir_opt_dead_cf.c
+++ b/src/glsl/nir/nir_opt_dead_cf.c
@@ -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);
}
diff --git a/src/glsl/nir/nir_opt_peephole_ffma.c b/src/glsl/nir/nir_opt_peephole_ffma.c
index a23123ea58c..4f0f0dae04e 100644
--- a/src/glsl/nir/nir_opt_peephole_ffma.c
+++ b/src/glsl/nir/nir_opt_peephole_ffma.c
@@ -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));
diff --git a/src/glsl/nir/nir_opt_peephole_select.c b/src/glsl/nir/nir_opt_peephole_select.c
index 5b6037a6c46..90902b97ffc 100644
--- a/src/glsl/nir/nir_opt_peephole_select.c
+++ b/src/glsl/nir/nir_opt_peephole_select.c
@@ -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);
diff --git a/src/glsl/nir/nir_opt_remove_phis.c b/src/glsl/nir/nir_opt_remove_phis.c
index 7896584b4e4..bf4a67e70ea 100644
--- a/src/glsl/nir/nir_opt_remove_phis.c
+++ b/src/glsl/nir/nir_opt_remove_phis.c
@@ -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;
diff --git a/src/glsl/nir/nir_search.c b/src/glsl/nir/nir_search.c
index 51e69b06d8c..bb154407914 100644
--- a/src/glsl/nir/nir_search.c
+++ b/src/glsl/nir/nir_search.c
@@ -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