From d57934fdec603a8361872f089cee89a6112badee Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 24 Jun 2024 11:38:39 -0400 Subject: [PATCH] nir: add nir_break_if helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I see people open-coding this all over the tree and it makes nir_builder loops really annoying. Make them slightly less annoying with a helper. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Daniel Schürmann Part-of: --- src/compiler/nir/nir_builder.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index 82964479f0f..009de525f98 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -2123,6 +2123,16 @@ nir_goto_if(nir_builder *build, struct nir_block *target, nir_def *cond, nir_builder_instr_insert(build, &jump->instr); } +static inline void +nir_break_if(nir_builder *build, nir_def *cond) +{ + nir_if *nif = nir_push_if(build, cond); + { + nir_jump(build, nir_jump_break); + } + nir_pop_if(build, nif); +} + static inline void nir_build_call(nir_builder *build, nir_function *func, size_t count, nir_def **args)