i965/cfg: Add a foreach_inst_in_block_safe macro.
authorMatt Turner <mattst88@gmail.com>
Fri, 11 Jul 2014 00:30:40 +0000 (17:30 -0700)
committerMatt Turner <mattst88@gmail.com>
Tue, 19 Aug 2014 02:05:59 +0000 (19:05 -0700)
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/brw_cfg.h

index a5d2df58fa47679bf0f09dc0b6a1db4980416b74..913a1ed85de247194ad996161aeb87ddd4f0799e 100644 (file)
@@ -120,6 +120,14 @@ struct cfg_t {
         __inst != __block->end->next;                          \
         __inst = (__type *)__inst->next)
 
+#define foreach_inst_in_block_safe(__type, __inst, __block)    \
+   for (__type *__inst = (__type *)__block->start,             \
+               *__next = (__type *)__inst->next,               \
+               *__end = (__type *)__block->end->next->next;    \
+        __next != __end;                                       \
+        __inst = __next,                                       \
+        __next = (__type *)__next->next)
+
 #define foreach_inst_in_block_reverse(__type, __inst, __block) \
    for (__type *__inst = (__type *)__block->end;               \
         __inst != __block->start->prev;                        \