From ba30eb9f400c99ded98d6a4d4bd4297ed6782e95 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sun, 17 Nov 2024 19:42:02 -0400 Subject: [PATCH] nir: add nir_foreach_entrypoint macros for compiling libraries full of kernels. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Karol Herbst Reviewed-by: Konstantin Seurer Reviewed-by: Lionel Landwerlin Reviewed-by: Mary Guillemard Part-of: --- src/.clang-format | 3 +++ src/compiler/nir/nir.h | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/.clang-format b/src/.clang-format index 187dd8c8c28..1c12340fc78 100644 --- a/src/.clang-format +++ b/src/.clang-format @@ -153,6 +153,9 @@ ForEachMacros: - nir_foreach_function_impl + - nir_foreach_entrypoint + - nir_foreach_entrypoint_safe + - nir_foreach_block_unstructured - nir_foreach_block_unstructured_safe diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index e23ee2e2bbc..f2319ff5909 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -4479,6 +4479,14 @@ typedef struct nir_shader { #define nir_foreach_function_safe(func, shader) \ foreach_list_typed_safe(nir_function, func, node, &(shader)->functions) +#define nir_foreach_entrypoint(func, lib) \ + nir_foreach_function(func, lib) \ + if (func->is_entrypoint) + +#define nir_foreach_entrypoint_safe(func, lib) \ + nir_foreach_function_safe(func, lib) \ + if (func->is_entrypoint) + static inline nir_function * nir_foreach_function_with_impl_first(const nir_shader *shader) {