glsl: Use a new foreach_two_lists macro for walking two lists at once.
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 11 Jan 2014 00:39:17 +0000 (16:39 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 13 Jan 2014 19:49:42 +0000 (11:49 -0800)
commit48d0faaa4388f411ea64fef8f4be04c22d02a4cf
tree437426abb4ce6ec3e6c67cd0758d8831f1b38dc0
parent02ff2a275892aa180c84fa2fbb5b44409218c0f3
glsl: Use a new foreach_two_lists macro for walking two lists at once.

When handling function calls, we often want to walk through the list of
formal parameters and list of actual parameters at the same time.
(Both are guaranteed to be the same length.)

Previously, we used a pattern of:

   exec_list_iterator 1st_iter = <1st list>.iterator();
   foreach_iter(exec_list_iterator, 2nd_iter, <2nd list>) {
      ...
      1st_iter.next();
   }

This was awkward, since you had to manually iterate through one of
the two lists.

This patch introduces a foreach_two_lists macro which safely walks
through two lists at the same time, so you can simply do:

   foreach_two_lists(1st_node, <1st list>, 2nd_node, <2nd list>) {
      ...
   }

v2: Rename macro from foreach_list2 to foreach_two_lists, as suggested
    by Ian Romanick.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
12 files changed:
src/glsl/ast_function.cpp
src/glsl/ir.cpp
src/glsl/linker.cpp
src/glsl/list.h
src/glsl/opt_constant_folding.cpp
src/glsl/opt_constant_propagation.cpp
src/glsl/opt_constant_variable.cpp
src/glsl/opt_copy_propagation.cpp
src/glsl/opt_copy_propagation_elements.cpp
src/glsl/opt_function_inlining.cpp
src/glsl/opt_tree_grafting.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp