mesa: Add and use foreach_in_list_use_after.
authorMatt Turner <mattst88@gmail.com>
Wed, 25 Jun 2014 17:32:38 +0000 (10:32 -0700)
committerMatt Turner <mattst88@gmail.com>
Tue, 1 Jul 2014 15:55:51 +0000 (08:55 -0700)
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/list.h
src/mesa/drivers/dri/i965/brw_fs_cse.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index a4c64082122ecca2d942655451962d00a6d24ad8..77e3aaf26e40927d64f7d50012b283a4d59ef938 100644 (file)
@@ -592,6 +592,11 @@ inline void exec_node::insert_before(exec_list *before)
         __next != NULL;                              \
         __node = __next, __next = (__type *)__next->next)
 
+#define foreach_in_list_use_after(__type, __inst, __list) \
+   __type *(__inst);                                      \
+   for ((__inst) = (__type *)(__list)->head;              \
+        !(__inst)->is_tail_sentinel();                    \
+        (__inst) = (__type *)(__inst)->next)
 /**
  * Iterate through two lists at once.  Stops at the end of the shorter list.
  *
index 7828c27e806d7fbd5b50994d8124055d268c9985..26873b8427d299b555df29a517b384b65a0fe6a0 100644 (file)
@@ -183,10 +183,7 @@ fs_visitor::opt_cse_local(bblock_t *block, exec_list *aeb)
       {
          bool found = false;
 
-         aeb_entry *entry;
-         foreach_list(entry_node, aeb) {
-            entry = (aeb_entry *) entry_node;
-
+         foreach_in_list_use_after(aeb_entry, entry, aeb) {
             /* Match current instruction's expression against those in AEB. */
             if (instructions_match(inst, entry->generator)) {
                found = true;
index 1f89ca573647818b543d27a79002b242b7d57409..9e194313942cff82af29fce2fb28b35daed933f6 100644 (file)
@@ -2660,11 +2660,7 @@ glsl_to_tgsi_visitor::visit(ir_constant *ir)
 function_entry *
 glsl_to_tgsi_visitor::get_function_signature(ir_function_signature *sig)
 {
-   function_entry *entry;
-
-   foreach_list(node, &this->function_signatures) {
-      entry = (function_entry *) node;
-
+   foreach_in_list_use_after(function_entry, entry, &this->function_signatures) {
       if (entry->sig == sig)
          return entry;
    }