/* Optimization passes */
if (!state.error) {
/* Constant folding */
- foreach_iter(exec_list_iterator, iter, instructions) {
- ir_constant_folding_visitor v;
- ((ir_instruction *)iter.get())->accept(& v);
- }
+ ir_constant_folding_visitor constant_folding;
+ visit_exec_list(&instructions, &constant_folding);
}
/* Print out the resulting IR */
#include "main/imports.h"
#include "main/simple_list.h"
#include "ir.h"
+#include "ir_visitor.h"
#include "glsl_types.h"
ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs,
call->type = glsl_type::error_type;
return call;
}
+
+void
+visit_exec_list(exec_list *list, ir_visitor *visitor)
+{
+ foreach_iter(exec_list_iterator, iter, *list) {
+ ((ir_instruction *)iter.get())->accept(visitor);
+ }
+}
+
} value;
};
+void
+visit_exec_list(exec_list *list, ir_visitor *visitor);
extern void
_mesa_glsl_initialize_variables(exec_list *instructions,
ir->condition = const_val;
else
ir->condition->accept(this);
+
+ visit_exec_list(&ir->then_instructions, this);
+ visit_exec_list(&ir->else_instructions, this);
}