summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2015-09-17 12:29:49 -0700
committerKenneth Graunke <[email protected]>2015-09-21 13:46:57 -0700
commitcfae0f8a3ae98ae10bcf9e4f1429f66165a17d95 (patch)
tree3f9aaad782663ae519dfb8b8231a244b4b4209d6 /src
parent1adde5b87e43b1512c0744c412d51cbc0078329b (diff)
nir: Report progress from nir_lower_locals_to_regs().
Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/glsl/nir/nir.h2
-rw-r--r--src/glsl/nir/nir_lower_locals_to_regs.c18
2 files changed, 16 insertions, 4 deletions
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 5be5bfa2ab8..26b3c75c140 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1811,7 +1811,7 @@ void nir_lower_var_copies(nir_shader *shader);
bool nir_lower_global_vars_to_local(nir_shader *shader);
-void nir_lower_locals_to_regs(nir_shader *shader);
+bool nir_lower_locals_to_regs(nir_shader *shader);
void nir_lower_outputs_to_temporaries(nir_shader *shader);
diff --git a/src/glsl/nir/nir_lower_locals_to_regs.c b/src/glsl/nir/nir_lower_locals_to_regs.c
index 87d2498dd79..17b53ca36f3 100644
--- a/src/glsl/nir/nir_lower_locals_to_regs.c
+++ b/src/glsl/nir/nir_lower_locals_to_regs.c
@@ -40,6 +40,8 @@ struct locals_to_regs_state {
* used to make adding register initialization code deterministic.
*/
nir_array derefs_array;
+
+ bool progress;
};
/* The following two functions implement a hash and equality check for
@@ -228,6 +230,7 @@ lower_locals_to_regs_block(nir_block *block, void *void_state)
nir_instr_insert_before(&intrin->instr, &mov->instr);
nir_instr_remove(&intrin->instr);
+ state->progress = true;
break;
}
@@ -249,6 +252,7 @@ lower_locals_to_regs_block(nir_block *block, void *void_state)
nir_instr_insert_before(&intrin->instr, &mov->instr);
nir_instr_remove(&intrin->instr);
+ state->progress = true;
break;
}
@@ -336,15 +340,17 @@ insert_constant_initializer(nir_deref_var *deref_head, nir_deref *deref_tail,
mov->dest.dest.reg.indirect = reg_src.reg.indirect;
nir_instr_insert_after(&load->instr, &mov->instr);
+ state->progress = true;
}
-static void
+static bool
nir_lower_locals_to_regs_impl(nir_function_impl *impl)
{
struct locals_to_regs_state state;
state.shader = impl->overload->function->shader;
state.impl = impl;
+ state.progress = false;
state.regs_table = _mesa_hash_table_create(NULL, hash_deref, derefs_equal);
nir_array_init(&state.derefs_array, NULL);
@@ -372,13 +378,19 @@ nir_lower_locals_to_regs_impl(nir_function_impl *impl)
nir_array_fini(&state.derefs_array);
_mesa_hash_table_destroy(state.regs_table, NULL);
+
+ return state.progress;
}
-void
+bool
nir_lower_locals_to_regs(nir_shader *shader)
{
+ bool progress = false;
+
nir_foreach_overload(shader, overload) {
if (overload->impl)
- nir_lower_locals_to_regs_impl(overload->impl);
+ progress = nir_lower_locals_to_regs_impl(overload->impl) || progress;
}
+
+ return progress;
}