v3dv: move all our NIR pre-processing to preprocess_nir

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12034>
This commit is contained in:
Iago Toral Quiroga 2021-07-23 12:42:27 +02:00 committed by Marge Bot
parent f5e67e1ce7
commit 9da26af074
1 changed files with 21 additions and 21 deletions

View File

@ -328,6 +328,27 @@ nir_optimize(nir_shader *nir, bool allow_copies)
static void
preprocess_nir(nir_shader *nir)
{
/* We have to lower away local variable initializers right before we
* inline functions. That way they get properly initialized at the top
* of the function and not at the top of its caller.
*/
NIR_PASS_V(nir, nir_lower_variable_initializers, nir_var_function_temp);
NIR_PASS_V(nir, nir_lower_returns);
NIR_PASS_V(nir, nir_inline_functions);
NIR_PASS_V(nir, nir_opt_deref);
/* Pick off the single entrypoint that we want */
foreach_list_typed_safe(nir_function, func, node, &nir->functions) {
if (func->is_entrypoint)
func->name = ralloc_strdup(func, "main");
else
exec_node_remove(&func->node);
}
assert(exec_list_length(&nir->functions) == 1);
/* Vulkan uses the separate-shader linking model */
nir->info.separate_shader = true;
/* Make sure we lower variable initializers on output variables so that
* nir_remove_dead_variables below sees the corresponding stores
*/
@ -493,27 +514,6 @@ shader_module_compile_to_nir(struct v3dv_device *device,
fprintf(stderr, "\n");
}
/* We have to lower away local variable initializers right before we
* inline functions. That way they get properly initialized at the top
* of the function and not at the top of its caller.
*/
NIR_PASS_V(nir, nir_lower_variable_initializers, nir_var_function_temp);
NIR_PASS_V(nir, nir_lower_returns);
NIR_PASS_V(nir, nir_inline_functions);
NIR_PASS_V(nir, nir_opt_deref);
/* Pick off the single entrypoint that we want */
foreach_list_typed_safe(nir_function, func, node, &nir->functions) {
if (func->is_entrypoint)
func->name = ralloc_strdup(func, "main");
else
exec_node_remove(&func->node);
}
assert(exec_list_length(&nir->functions) == 1);
/* Vulkan uses the separate-shader linking model */
nir->info.separate_shader = true;
preprocess_nir(nir);
return nir;