nir/cursor: Add a helper for getting the current block
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 31 Aug 2015 21:48:10 +0000 (14:48 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 1 Sep 2015 00:05:23 +0000 (17:05 -0700)
src/glsl/nir/nir.h

index ac80af37bae3deadb375c1f0211f41e01e5ff958..2ad739523baa189d346a2a1b4410d9b2ca2c4d4a 100644 (file)
@@ -1580,6 +1580,17 @@ typedef struct {
    };
 } nir_cursor;
 
+static inline nir_block *
+nir_cursor_current_block(nir_cursor cursor)
+{
+   if (cursor.option == nir_cursor_before_instr ||
+       cursor.option == nir_cursor_after_instr) {
+      return cursor.instr->block;
+   } else {
+      return cursor.block;
+   }
+}
+
 static inline nir_cursor
 nir_before_block(nir_block *block)
 {