Module: Mesa
Branch: main
Commit: 6cad2fc23085596f3b9d40d721eb2da304af79f4
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6cad2fc23085596f3b9d40d721eb2da304af79f4

Author: Job Noorman <jnoor...@igalia.com>
Date:   Fri Dec 15 11:42:41 2023 +0100

nir: add helper to create cursor after all @decl_regs

@decl_reg intrinsics must be in the first block so it's convenient to be
able to create an insertion point after all @decl_regs when the first
block needs to be split.

Signed-off-by: Job Noorman <jnoor...@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26737>

---

 src/compiler/nir/nir.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 23246e1577d..3f9f7f8c29e 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -6555,6 +6555,18 @@ nir_next_decl_reg(nir_intrinsic_instr *prev, 
nir_function_impl *impl)
                             *next_ = nir_next_decl_reg(reg, NULL); \
         reg; reg = next_, next_ = nir_next_decl_reg(next_, NULL))
 
+static inline nir_cursor
+nir_after_reg_decls(nir_function_impl *impl)
+{
+   nir_intrinsic_instr *last_reg_decl = NULL;
+   nir_foreach_reg_decl(reg_decl, impl)
+      last_reg_decl = reg_decl;
+
+   if (last_reg_decl != NULL)
+      return nir_after_instr(&last_reg_decl->instr);
+   return nir_before_impl(impl);
+}
+
 static inline bool
 nir_is_load_reg(nir_intrinsic_instr *intr)
 {

Reply via email to