From 12cc22af4c6bb4313b50d07c642c82c28c26bd46 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 25 Nov 2024 07:52:27 -0500 Subject: [PATCH] nir: add nir_remove_entrypoints helper opposite of nir_remove_non_entrypoint. this operation comes up with precompiling. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Konstantin Seurer Reviewed-by: Mary Guillemard Part-of: --- src/compiler/nir/nir.c | 13 +++++++++++++ src/compiler/nir/nir.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 502846c3886..8b099b80cf3 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -3550,6 +3550,19 @@ nir_remove_non_exported(nir_shader *nir) } } +/* + * After precompiling entrypoints from a kernel library, we want to garbage + * collect the NIR entrypoints but leave the exported library functions. This + * helper does that. + */ +void +nir_remove_entrypoints(nir_shader *nir) +{ + nir_foreach_entrypoint_safe(func, nir) { + exec_node_remove(&func->node); + } +} + unsigned nir_static_workgroup_size(const nir_shader *s) { diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 0d775271323..f3ec0c896b5 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -4582,6 +4582,7 @@ nir_shader_get_function_for_name(const nir_shader *shader, const char *name) */ void nir_remove_non_entrypoints(nir_shader *shader); void nir_remove_non_exported(nir_shader *shader); +void nir_remove_entrypoints(nir_shader *shader); void nir_fixup_is_exported(nir_shader *shader); nir_shader *nir_shader_create(void *mem_ctx,