summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-05-25 10:36:23 -0700
committerJason Ekstrand <[email protected]>2016-05-27 10:28:27 -0700
commitd19c406395925778d71584ba5730ade59dcea977 (patch)
tree89b7b01d65732a653db7fa2577686f2e1bb092a1 /src
parent2fcba404f80c4c83a76dfef03d7cf427ed17415b (diff)
nir/inline: Make the rewrite_param_derefs helper work on instructions
Now that we have the better nir_foreach_block macro, there's no reason to use the archaic block version for everything. Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/nir/nir_inline_functions.c53
1 files changed, 25 insertions, 28 deletions
diff --git a/src/compiler/nir/nir_inline_functions.c b/src/compiler/nir/nir_inline_functions.c
index 5f9dae40994..a4365b5db23 100644
--- a/src/compiler/nir/nir_inline_functions.c
+++ b/src/compiler/nir/nir_inline_functions.c
@@ -27,40 +27,36 @@
static bool inline_function_impl(nir_function_impl *impl, struct set *inlined);
-static bool
-rewrite_param_derefs_block(nir_block *block, nir_call_instr *call)
+static void
+rewrite_param_derefs(nir_instr *instr, nir_call_instr *call)
{
- nir_foreach_instr(instr, block) {
- if (instr->type != nir_instr_type_intrinsic)
- continue;
-
- nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
+ if (instr->type != nir_instr_type_intrinsic)
+ return;
- for (unsigned i = 0;
- i < nir_intrinsic_infos[intrin->intrinsic].num_variables; i++) {
- if (intrin->variables[i]->var->data.mode != nir_var_param)
- continue;
+ nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
- int param_idx = intrin->variables[i]->var->data.location;
+ for (unsigned i = 0;
+ i < nir_intrinsic_infos[intrin->intrinsic].num_variables; i++) {
+ if (intrin->variables[i]->var->data.mode != nir_var_param)
+ continue;
- nir_deref_var *call_deref;
- if (param_idx >= 0) {
- assert(param_idx < call->callee->num_params);
- call_deref = call->params[param_idx];
- } else {
- call_deref = call->return_deref;
- }
- assert(call_deref);
+ int param_idx = intrin->variables[i]->var->data.location;
- nir_deref_var *new_deref = nir_deref_as_var(nir_copy_deref(intrin, &call_deref->deref));
- nir_deref *new_tail = nir_deref_tail(&new_deref->deref);
- new_tail->child = intrin->variables[i]->deref.child;
- ralloc_steal(new_tail, new_tail->child);
- intrin->variables[i] = new_deref;
+ nir_deref_var *call_deref;
+ if (param_idx >= 0) {
+ assert(param_idx < call->callee->num_params);
+ call_deref = call->params[param_idx];
+ } else {
+ call_deref = call->return_deref;
}
- }
+ assert(call_deref);
- return true;
+ nir_deref_var *new_deref = nir_deref_as_var(nir_copy_deref(intrin, &call_deref->deref));
+ nir_deref *new_tail = nir_deref_tail(&new_deref->deref);
+ new_tail->child = intrin->variables[i]->deref.child;
+ ralloc_steal(new_tail, new_tail->child);
+ intrin->variables[i] = new_deref;
+ }
}
static void
@@ -184,7 +180,8 @@ inline_functions_block(nir_block *block, nir_builder *b,
}
nir_foreach_block(block, callee_copy) {
- rewrite_param_derefs_block(block, call);
+ nir_foreach_instr(instr, block)
+ rewrite_param_derefs(instr, call);
}
/* Pluck the body out of the function and place it here */