From 469b8bbf3c906946ee6044aa19140111f4499fb2 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 24 Feb 2025 13:55:19 -0500 Subject: [PATCH] nir: add nir_progress/nir_no_progress helpers These will replace nir_metadata_preserve as more ergonomic replacements that convey a notion of impl progress instead of simply updating metadata. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Georg Lehmann Reviewed-by: Faith Ekstrand Part-of: --- src/compiler/nir/nir.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index b8d859d5b4e..f573fb1ab15 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -3903,6 +3903,25 @@ void nir_shader_preserve_all_metadata(nir_shader *shader); /** dirties all metadata and fills it with obviously wrong information */ void nir_metadata_invalidate(nir_shader *shader); +static inline bool +nir_progress(bool progress, nir_function_impl *impl, nir_metadata preserved) +{ + if (progress) { + nir_metadata_preserve(impl, preserved); + } else { + nir_metadata_preserve(impl, nir_metadata_all); + } + + return progress; +} + +/** Indicate that there is no progress. All metadata is preserved. */ +static inline bool +nir_no_progress(nir_function_impl *impl) +{ + return nir_progress(false, impl, nir_metadata_none /* ignored */); +} + /** creates an instruction with default swizzle/writemask/etc. with NULL registers */ nir_alu_instr *nir_alu_instr_create(nir_shader *shader, nir_op op);