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);
* 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
nir_instr_insert_before(&intrin->instr, &mov->instr);
nir_instr_remove(&intrin->instr);
+ state->progress = true;
break;
}
nir_instr_insert_before(&intrin->instr, &mov->instr);
nir_instr_remove(&intrin->instr);
+ state->progress = true;
break;
}
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);
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;
}