[Mesa-dev] [PATCH 10/16] mesa: Add and use foreach_in_list_use_after.
Matt Turner
mattst88 at gmail.com
Wed Jun 25 11:51:11 PDT 2014
---
src/glsl/list.h | 5 +++++
src/mesa/drivers/dri/i965/brw_fs_cse.cpp | 5 +----
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 6 +-----
3 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/src/glsl/list.h b/src/glsl/list.h
index a4c6408..77e3aaf 100644
--- a/src/glsl/list.h
+++ b/src/glsl/list.h
@@ -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.
*
diff --git a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
index 7828c27..26873b8 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
@@ -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;
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 00d16cf..7663afb 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -2657,11 +2657,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;
}
--
1.8.3.2
More information about the mesa-dev
mailing list