aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/glsl')
-rw-r--r--mesalib/src/glsl/ast_function.cpp16
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp4
-rw-r--r--mesalib/src/glsl/builtin_functions.cpp4
-rw-r--r--mesalib/src/glsl/ir.cpp20
-rw-r--r--mesalib/src/glsl/ir.h24
-rw-r--r--mesalib/src/glsl/ir_basic_block.cpp10
-rw-r--r--mesalib/src/glsl/ir_clone.cpp16
-rw-r--r--mesalib/src/glsl/ir_expression_flattening.cpp4
-rw-r--r--mesalib/src/glsl/ir_function.cpp10
-rw-r--r--mesalib/src/glsl/ir_print_visitor.cpp34
-rw-r--r--mesalib/src/glsl/ir_reader.cpp42
-rw-r--r--mesalib/src/glsl/ir_rvalue_visitor.cpp4
-rw-r--r--mesalib/src/glsl/ir_validate.cpp4
-rw-r--r--mesalib/src/glsl/linker.cpp18
-rw-r--r--mesalib/src/glsl/list.h80
-rw-r--r--mesalib/src/glsl/lower_if_to_cond_assign.cpp8
-rw-r--r--mesalib/src/glsl/lower_vec_index_to_cond_assign.cpp4
-rw-r--r--mesalib/src/glsl/lower_vec_index_to_swizzle.cpp4
-rw-r--r--mesalib/src/glsl/opt_array_splitting.cpp16
-rw-r--r--mesalib/src/glsl/opt_constant_folding.cpp9
-rw-r--r--mesalib/src/glsl/opt_constant_propagation.cpp33
-rw-r--r--mesalib/src/glsl/opt_constant_variable.cpp18
-rw-r--r--mesalib/src/glsl/opt_copy_propagation.cpp29
-rw-r--r--mesalib/src/glsl/opt_copy_propagation_elements.cpp17
-rw-r--r--mesalib/src/glsl/opt_dead_code.cpp9
-rw-r--r--mesalib/src/glsl/opt_dead_code_local.cpp20
-rw-r--r--mesalib/src/glsl/opt_dead_functions.cpp12
-rw-r--r--mesalib/src/glsl/opt_function_inlining.cpp45
-rw-r--r--mesalib/src/glsl/opt_if_simplification.cpp8
-rw-r--r--mesalib/src/glsl/opt_structure_splitting.cpp16
-rw-r--r--mesalib/src/glsl/opt_tree_grafting.cpp10
-rw-r--r--mesalib/src/glsl/s_expression.cpp8
32 files changed, 225 insertions, 331 deletions
diff --git a/mesalib/src/glsl/ast_function.cpp b/mesalib/src/glsl/ast_function.cpp
index e4c0fd1c4..2d05d0723 100644
--- a/mesalib/src/glsl/ast_function.cpp
+++ b/mesalib/src/glsl/ast_function.cpp
@@ -293,15 +293,10 @@ generate_call(exec_list *instructions, ir_function_signature *sig,
* call takes place. Since we haven't emitted the call yet, we'll place
* the post-call conversions in a temporary exec_list, and emit them later.
*/
- exec_list_iterator actual_iter = actual_parameters->iterator();
- exec_list_iterator formal_iter = sig->parameters.iterator();
-
- while (actual_iter.has_next()) {
- ir_rvalue *actual = (ir_rvalue *) actual_iter.get();
- ir_variable *formal = (ir_variable *) formal_iter.get();
-
- assert(actual != NULL);
- assert(formal != NULL);
+ foreach_two_lists(formal_node, &sig->parameters,
+ actual_node, actual_parameters) {
+ ir_rvalue *actual = (ir_rvalue *) actual_node;
+ ir_variable *formal = (ir_variable *) formal_node;
if (formal->type->is_numeric() || formal->type->is_boolean()) {
switch (formal->data.mode) {
@@ -323,9 +318,6 @@ generate_call(exec_list *instructions, ir_function_signature *sig,
break;
}
}
-
- actual_iter.next();
- formal_iter.next();
}
/* If the function call is a constant expression, don't generate any
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index ef8e699e0..4cc8eb18d 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -3818,8 +3818,8 @@ ast_function_definition::hir(exec_list *instructions,
* Add these to the symbol table.
*/
state->symbols->push_scope();
- foreach_iter(exec_list_iterator, iter, signature->parameters) {
- ir_variable *const var = ((ir_instruction *) iter.get())->as_variable();
+ foreach_list(n, &signature->parameters) {
+ ir_variable *const var = ((ir_instruction *) n)->as_variable();
assert(var != NULL);
diff --git a/mesalib/src/glsl/builtin_functions.cpp b/mesalib/src/glsl/builtin_functions.cpp
index 038e47363..662ff4cea 100644
--- a/mesalib/src/glsl/builtin_functions.cpp
+++ b/mesalib/src/glsl/builtin_functions.cpp
@@ -2398,8 +2398,8 @@ builtin_builder::call(ir_function *f, ir_variable *ret, exec_list params)
{
exec_list actual_params;
- foreach_iter(exec_list_iterator, it, params) {
- ir_variable *var = ((ir_instruction *)it.get())->as_variable();
+ foreach_list(node, &params) {
+ ir_variable *var = (ir_variable *) node;
actual_params.push_tail(var_ref(var));
}
diff --git a/mesalib/src/glsl/ir.cpp b/mesalib/src/glsl/ir.cpp
index ba6903d8a..1a36bd631 100644
--- a/mesalib/src/glsl/ir.cpp
+++ b/mesalib/src/glsl/ir.cpp
@@ -1649,13 +1649,10 @@ modes_match(unsigned a, unsigned b)
const char *
ir_function_signature::qualifiers_match(exec_list *params)
{
- exec_list_iterator iter_a = parameters.iterator();
- exec_list_iterator iter_b = params->iterator();
-
/* check that the qualifiers match. */
- while (iter_a.has_next()) {
- ir_variable *a = (ir_variable *)iter_a.get();
- ir_variable *b = (ir_variable *)iter_b.get();
+ foreach_two_lists(a_node, &this->parameters, b_node, params) {
+ ir_variable *a = (ir_variable *) a_node;
+ ir_variable *b = (ir_variable *) b_node;
if (a->data.read_only != b->data.read_only ||
!modes_match(a->data.mode, b->data.mode) ||
@@ -1666,9 +1663,6 @@ ir_function_signature::qualifiers_match(exec_list *params)
/* parameter a's qualifiers don't match */
return a->name;
}
-
- iter_a.next();
- iter_b.next();
}
return NULL;
}
@@ -1717,8 +1711,8 @@ ir_rvalue::error_value(void *mem_ctx)
void
visit_exec_list(exec_list *list, ir_visitor *visitor)
{
- foreach_iter(exec_list_iterator, iter, *list) {
- ((ir_instruction *)iter.get())->accept(visitor);
+ foreach_list_safe(n, list) {
+ ((ir_instruction *) n)->accept(visitor);
}
}
@@ -1739,8 +1733,8 @@ steal_memory(ir_instruction *ir, void *new_ctx)
*/
if (constant != NULL) {
if (constant->type->is_record()) {
- foreach_iter(exec_list_iterator, iter, constant->components) {
- ir_constant *field = (ir_constant *)iter.get();
+ foreach_list(n, &constant->components) {
+ ir_constant *field = (ir_constant *) n;
steal_memory(field, ir);
}
} else if (constant->type->is_array()) {
diff --git a/mesalib/src/glsl/ir.h b/mesalib/src/glsl/ir.h
index aff679826..2ae8513a6 100644
--- a/mesalib/src/glsl/ir.h
+++ b/mesalib/src/glsl/ir.h
@@ -914,14 +914,6 @@ public:
}
/**
- * Get an iterator for the set of function signatures
- */
- exec_list_iterator iterator()
- {
- return signatures.iterator();
- }
-
- /**
* Find a signature that matches a set of actual parameters, taking implicit
* conversions into account. Also flags whether the match was exact.
*/
@@ -1018,14 +1010,6 @@ public:
return this;
}
- /**
- * Get an iterator for the instructions of the loop body
- */
- exec_list_iterator iterator()
- {
- return body_instructions.iterator();
- }
-
/** List of ir_instruction that make up the body of the loop. */
exec_list body_instructions;
};
@@ -1521,14 +1505,6 @@ public:
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
/**
- * Get an iterator for the set of acutal parameters
- */
- exec_list_iterator iterator()
- {
- return actual_parameters.iterator();
- }
-
- /**
* Get the name of the function being called.
*/
const char *callee_name() const
diff --git a/mesalib/src/glsl/ir_basic_block.cpp b/mesalib/src/glsl/ir_basic_block.cpp
index 2cbc682d4..426fda2f2 100644
--- a/mesalib/src/glsl/ir_basic_block.cpp
+++ b/mesalib/src/glsl/ir_basic_block.cpp
@@ -58,8 +58,8 @@ void call_for_basic_blocks(exec_list *instructions,
ir_instruction *leader = NULL;
ir_instruction *last = NULL;
- foreach_iter(exec_list_iterator, iter, *instructions) {
- ir_instruction *ir = (ir_instruction *)iter.get();
+ foreach_list(n, instructions) {
+ ir_instruction *ir = (ir_instruction *) n;
ir_if *ir_if;
ir_loop *ir_loop;
ir_function *ir_function;
@@ -90,10 +90,8 @@ void call_for_basic_blocks(exec_list *instructions,
* and the body of main(). Perhaps those instructions ought
* to live inside of main().
*/
- foreach_iter(exec_list_iterator, fun_iter, *ir_function) {
- ir_function_signature *ir_sig;
-
- ir_sig = (ir_function_signature *)fun_iter.get();
+ foreach_list(func_node, &ir_function->signatures) {
+ ir_function_signature *ir_sig = (ir_function_signature *) func_node;
call_for_basic_blocks(&ir_sig->body, callback, data);
}
diff --git a/mesalib/src/glsl/ir_clone.cpp b/mesalib/src/glsl/ir_clone.cpp
index 4e5cf68ca..cb732a51a 100644
--- a/mesalib/src/glsl/ir_clone.cpp
+++ b/mesalib/src/glsl/ir_clone.cpp
@@ -123,13 +123,13 @@ ir_if::clone(void *mem_ctx, struct hash_table *ht) const
{
ir_if *new_if = new(mem_ctx) ir_if(this->condition->clone(mem_ctx, ht));
- foreach_iter(exec_list_iterator, iter, this->then_instructions) {
- ir_instruction *ir = (ir_instruction *)iter.get();
+ foreach_list(n, &this->then_instructions) {
+ ir_instruction *ir = (ir_instruction *) n;
new_if->then_instructions.push_tail(ir->clone(mem_ctx, ht));
}
- foreach_iter(exec_list_iterator, iter, this->else_instructions) {
- ir_instruction *ir = (ir_instruction *)iter.get();
+ foreach_list(n, &this->else_instructions) {
+ ir_instruction *ir = (ir_instruction *) n;
new_if->else_instructions.push_tail(ir->clone(mem_ctx, ht));
}
@@ -141,8 +141,8 @@ ir_loop::clone(void *mem_ctx, struct hash_table *ht) const
{
ir_loop *new_loop = new(mem_ctx) ir_loop();
- foreach_iter(exec_list_iterator, iter, this->body_instructions) {
- ir_instruction *ir = (ir_instruction *)iter.get();
+ foreach_list(n, &this->body_instructions) {
+ ir_instruction *ir = (ir_instruction *) n;
new_loop->body_instructions.push_tail(ir->clone(mem_ctx, ht));
}
@@ -158,8 +158,8 @@ ir_call::clone(void *mem_ctx, struct hash_table *ht) const
exec_list new_parameters;
- foreach_iter(exec_list_iterator, iter, this->actual_parameters) {
- ir_instruction *ir = (ir_instruction *)iter.get();
+ foreach_list(n, &this->actual_parameters) {
+ ir_instruction *ir = (ir_instruction *) n;
new_parameters.push_tail(ir->clone(mem_ctx, ht));
}
diff --git a/mesalib/src/glsl/ir_expression_flattening.cpp b/mesalib/src/glsl/ir_expression_flattening.cpp
index b44e68ca3..c1cadb122 100644
--- a/mesalib/src/glsl/ir_expression_flattening.cpp
+++ b/mesalib/src/glsl/ir_expression_flattening.cpp
@@ -59,8 +59,8 @@ do_expression_flattening(exec_list *instructions,
{
ir_expression_flattening_visitor v(predicate);
- foreach_iter(exec_list_iterator, iter, *instructions) {
- ir_instruction *ir = (ir_instruction *)iter.get();
+ foreach_list(n, instructions) {
+ ir_instruction *ir = (ir_instruction *) n;
ir->accept(&v);
}
diff --git a/mesalib/src/glsl/ir_function.cpp b/mesalib/src/glsl/ir_function.cpp
index bd5318d23..40cf5894a 100644
--- a/mesalib/src/glsl/ir_function.cpp
+++ b/mesalib/src/glsl/ir_function.cpp
@@ -141,9 +141,8 @@ ir_function::matching_signature(_mesa_glsl_parse_state *state,
* multiple ways to apply these conversions to the actual arguments of a
* call such that the call can be made to match multiple signatures."
*/
- foreach_iter(exec_list_iterator, iter, signatures) {
- ir_function_signature *const sig =
- (ir_function_signature *) iter.get();
+ foreach_list(n, &this->signatures) {
+ ir_function_signature *const sig = (ir_function_signature *) n;
/* Skip over any built-ins that aren't available in this shader. */
if (sig->is_builtin() && !sig->is_builtin_available(state))
@@ -212,9 +211,8 @@ ir_function_signature *
ir_function::exact_matching_signature(_mesa_glsl_parse_state *state,
const exec_list *actual_parameters)
{
- foreach_iter(exec_list_iterator, iter, signatures) {
- ir_function_signature *const sig =
- (ir_function_signature *) iter.get();
+ foreach_list(n, &this->signatures) {
+ ir_function_signature *const sig = (ir_function_signature *) n;
/* Skip over any built-ins that aren't available in this shader. */
if (sig->is_builtin() && !sig->is_builtin_available(state))
diff --git a/mesalib/src/glsl/ir_print_visitor.cpp b/mesalib/src/glsl/ir_print_visitor.cpp
index 01c5f7f1c..935782184 100644
--- a/mesalib/src/glsl/ir_print_visitor.cpp
+++ b/mesalib/src/glsl/ir_print_visitor.cpp
@@ -61,8 +61,8 @@ _mesa_print_ir(exec_list *instructions,
}
printf("(\n");
- foreach_iter(exec_list_iterator, iter, *instructions) {
- ir_instruction *ir = (ir_instruction *)iter.get();
+ foreach_list(n, instructions) {
+ ir_instruction *ir = (ir_instruction *) n;
ir->print();
if (ir->ir_type != ir_type_function)
printf("\n");
@@ -179,8 +179,8 @@ void ir_print_visitor::visit(ir_function_signature *ir)
printf("(parameters\n");
indentation++;
- foreach_iter(exec_list_iterator, iter, ir->parameters) {
- ir_variable *const inst = (ir_variable *) iter.get();
+ foreach_list(n, &ir->parameters) {
+ ir_variable *const inst = (ir_variable *) n;
indent();
inst->accept(this);
@@ -196,8 +196,8 @@ void ir_print_visitor::visit(ir_function_signature *ir)
printf("(\n");
indentation++;
- foreach_iter(exec_list_iterator, iter, ir->body) {
- ir_instruction *const inst = (ir_instruction *) iter.get();
+ foreach_list(n, &ir->body) {
+ ir_instruction *const inst = (ir_instruction *) n;
indent();
inst->accept(this);
@@ -215,8 +215,8 @@ void ir_print_visitor::visit(ir_function *ir)
{
printf("(function %s\n", ir->name);
indentation++;
- foreach_iter(exec_list_iterator, iter, *ir) {
- ir_function_signature *const sig = (ir_function_signature *) iter.get();
+ foreach_list(n, &ir->signatures) {
+ ir_function_signature *const sig = (ir_function_signature *) n;
indent();
sig->accept(this);
printf("\n");
@@ -440,10 +440,10 @@ ir_print_visitor::visit(ir_call *ir)
if (ir->return_deref)
ir->return_deref->accept(this);
printf(" (");
- foreach_iter(exec_list_iterator, iter, *ir) {
- ir_instruction *const inst = (ir_instruction *) iter.get();
+ foreach_list(n, &ir->actual_parameters) {
+ ir_rvalue *const param = (ir_rvalue *) n;
- inst->accept(this);
+ param->accept(this);
}
printf("))\n");
}
@@ -487,8 +487,8 @@ ir_print_visitor::visit(ir_if *ir)
printf("(\n");
indentation++;
- foreach_iter(exec_list_iterator, iter, ir->then_instructions) {
- ir_instruction *const inst = (ir_instruction *) iter.get();
+ foreach_list(n, &ir->then_instructions) {
+ ir_instruction *const inst = (ir_instruction *) n;
indent();
inst->accept(this);
@@ -504,8 +504,8 @@ ir_print_visitor::visit(ir_if *ir)
printf("(\n");
indentation++;
- foreach_iter(exec_list_iterator, iter, ir->else_instructions) {
- ir_instruction *const inst = (ir_instruction *) iter.get();
+ foreach_list(n, &ir->else_instructions) {
+ ir_instruction *const inst = (ir_instruction *) n;
indent();
inst->accept(this);
@@ -526,8 +526,8 @@ ir_print_visitor::visit(ir_loop *ir)
printf("(loop (\n");
indentation++;
- foreach_iter(exec_list_iterator, iter, ir->body_instructions) {
- ir_instruction *const inst = (ir_instruction *) iter.get();
+ foreach_list(n, &ir->body_instructions) {
+ ir_instruction *const inst = (ir_instruction *) n;
indent();
inst->accept(this);
diff --git a/mesalib/src/glsl/ir_reader.cpp b/mesalib/src/glsl/ir_reader.cpp
index 7970112ec..28923f3b8 100644
--- a/mesalib/src/glsl/ir_reader.cpp
+++ b/mesalib/src/glsl/ir_reader.cpp
@@ -170,8 +170,8 @@ ir_reader::scan_for_prototypes(exec_list *instructions, s_expression *expr)
return;
}
- foreach_iter(exec_list_iterator, it, list->subexpressions) {
- s_list *sub = SX_AS_LIST(it.get());
+ foreach_list(n, &list->subexpressions) {
+ s_list *sub = SX_AS_LIST(n);
if (sub == NULL)
continue; // not a (function ...); ignore it.
@@ -205,11 +205,12 @@ ir_reader::read_function(s_expression *expr, bool skip_body)
assert(added);
}
- exec_list_iterator it = ((s_list *) expr)->subexpressions.iterator();
- it.next(); // skip "function" tag
- it.next(); // skip function name
- for (/* nothing */; it.has_next(); it.next()) {
- s_expression *s_sig = (s_expression *) it.get();
+ /* Skip over "function" tag and function name (which are guaranteed to be
+ * present by the above PARTIAL_MATCH call).
+ */
+ exec_node *node = ((s_list *) expr)->subexpressions.head->next->next;
+ for (/* nothing */; !node->is_tail_sentinel(); node = node->next) {
+ s_expression *s_sig = (s_expression *) node;
read_function_sig(f, s_sig, skip_body);
}
return added ? f : NULL;
@@ -249,9 +250,10 @@ ir_reader::read_function_sig(ir_function *f, s_expression *expr, bool skip_body)
exec_list hir_parameters;
state->symbols->push_scope();
- exec_list_iterator it = paramlist->subexpressions.iterator();
- for (it.next() /* skip "parameters" */; it.has_next(); it.next()) {
- ir_variable *var = read_declaration((s_expression *) it.get());
+ /* Skip over the "parameters" tag. */
+ exec_node *node = paramlist->subexpressions.head->next;
+ for (/* nothing */; !node->is_tail_sentinel(); node = node->next) {
+ ir_variable *var = read_declaration((s_expression *) node);
if (var == NULL)
return;
@@ -315,8 +317,8 @@ ir_reader::read_instructions(exec_list *instructions, s_expression *expr,
return;
}
- foreach_iter(exec_list_iterator, it, list->subexpressions) {
- s_expression *sub = (s_expression*) it.get();
+ foreach_list(n, &list->subexpressions) {
+ s_expression *sub = (s_expression *) n;
ir_instruction *ir = read_instruction(sub, loop_ctx);
if (ir != NULL) {
/* Global variable declarations should be moved to the top, before
@@ -403,8 +405,8 @@ ir_reader::read_declaration(s_expression *expr)
ir_variable *var = new(mem_ctx) ir_variable(type, s_name->value(),
ir_var_auto);
- foreach_iter(exec_list_iterator, it, s_quals->subexpressions) {
- s_symbol *qualifier = SX_AS_SYMBOL(it.get());
+ foreach_list(n, &s_quals->subexpressions) {
+ s_symbol *qualifier = SX_AS_SYMBOL(n);
if (qualifier == NULL) {
ir_read_error(expr, "qualifier list must contain only symbols");
return NULL;
@@ -656,8 +658,8 @@ ir_reader::read_call(s_expression *expr)
exec_list parameters;
- foreach_iter(exec_list_iterator, it, params->subexpressions) {
- s_expression *expr = (s_expression*) it.get();
+ foreach_list(n, &params->subexpressions) {
+ s_expression *expr = (s_expression *) n;
ir_rvalue *param = read_rvalue(expr);
if (param == NULL) {
ir_read_error(expr, "when reading parameter to function call");
@@ -796,8 +798,8 @@ ir_reader::read_constant(s_expression *expr)
if (type->is_array()) {
unsigned elements_supplied = 0;
exec_list elements;
- foreach_iter(exec_list_iterator, it, values->subexpressions) {
- s_expression *elt = (s_expression *) it.get();
+ foreach_list(n, &values->subexpressions) {
+ s_expression *elt = (s_expression *) n;
ir_constant *ir_elt = read_constant(elt);
if (ir_elt == NULL)
return NULL;
@@ -817,13 +819,13 @@ ir_reader::read_constant(s_expression *expr)
// Read in list of values (at most 16).
unsigned k = 0;
- foreach_iter(exec_list_iterator, it, values->subexpressions) {
+ foreach_list(n, &values->subexpressions) {
if (k >= 16) {
ir_read_error(values, "expected at most 16 numbers");
return NULL;
}
- s_expression *expr = (s_expression*) it.get();
+ s_expression *expr = (s_expression *) n;
if (type->base_type == GLSL_TYPE_FLOAT) {
s_number *value = SX_AS_NUMBER(expr);
diff --git a/mesalib/src/glsl/ir_rvalue_visitor.cpp b/mesalib/src/glsl/ir_rvalue_visitor.cpp
index 9d8ccd94a..fcbe9448d 100644
--- a/mesalib/src/glsl/ir_rvalue_visitor.cpp
+++ b/mesalib/src/glsl/ir_rvalue_visitor.cpp
@@ -123,8 +123,8 @@ ir_rvalue_base_visitor::rvalue_visit(ir_assignment *ir)
ir_visitor_status
ir_rvalue_base_visitor::rvalue_visit(ir_call *ir)
{
- foreach_iter(exec_list_iterator, iter, *ir) {
- ir_rvalue *param = (ir_rvalue *)iter.get();
+ foreach_list_safe(n, &ir->actual_parameters) {
+ ir_rvalue *param = (ir_rvalue *) n;
ir_rvalue *new_param = param;
handle_rvalue(&new_param);
diff --git a/mesalib/src/glsl/ir_validate.cpp b/mesalib/src/glsl/ir_validate.cpp
index 4bbb3ce65..527acea4c 100644
--- a/mesalib/src/glsl/ir_validate.cpp
+++ b/mesalib/src/glsl/ir_validate.cpp
@@ -813,8 +813,8 @@ validate_ir_tree(exec_list *instructions)
v.run(instructions);
- foreach_iter(exec_list_iterator, iter, *instructions) {
- ir_instruction *ir = (ir_instruction *)iter.get();
+ foreach_list(n, instructions) {
+ ir_instruction *ir = (ir_instruction *) n;
visit_tree(ir, check_node_type, NULL);
}
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index e820f0f9f..85a4d3883 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -109,10 +109,10 @@ public:
virtual ir_visitor_status visit_enter(ir_call *ir)
{
- exec_list_iterator sig_iter = ir->callee->parameters.iterator();
- foreach_iter(exec_list_iterator, iter, *ir) {
- ir_rvalue *param_rval = (ir_rvalue *)iter.get();
- ir_variable *sig_param = (ir_variable *)sig_iter.get();
+ foreach_two_lists(formal_node, &ir->callee->parameters,
+ actual_node, &ir->actual_parameters) {
+ ir_rvalue *param_rval = (ir_rvalue *) actual_node;
+ ir_variable *sig_param = (ir_variable *) formal_node;
if (sig_param->data.mode == ir_var_function_out ||
sig_param->data.mode == ir_var_function_inout) {
@@ -122,7 +122,6 @@ public:
return visit_stop;
}
}
- sig_iter.next();
}
if (ir->return_deref != NULL) {
@@ -1338,9 +1337,8 @@ link_intrastage_shaders(void *mem_ctx,
if (other == NULL)
continue;
- foreach_iter (exec_list_iterator, iter, *f) {
- ir_function_signature *sig =
- (ir_function_signature *) iter.get();
+ foreach_list(n, &f->signatures) {
+ ir_function_signature *sig = (ir_function_signature *) n;
if (!sig->is_defined || sig->is_builtin())
continue;
@@ -1453,8 +1451,8 @@ link_intrastage_shaders(void *mem_ctx,
if (linked->Stage == MESA_SHADER_GEOMETRY) {
unsigned num_vertices = vertices_per_prim(prog->Geom.InputType);
geom_array_resize_visitor input_resize_visitor(num_vertices, prog);
- foreach_iter(exec_list_iterator, iter, *linked->ir) {
- ir_instruction *ir = (ir_instruction *)iter.get();
+ foreach_list(n, linked->ir) {
+ ir_instruction *ir = (ir_instruction *) n;
ir->accept(&input_resize_visitor);
}
}
diff --git a/mesalib/src/glsl/list.h b/mesalib/src/glsl/list.h
index 5ac17cb37..694b686b0 100644
--- a/mesalib/src/glsl/list.h
+++ b/mesalib/src/glsl/list.h
@@ -206,62 +206,8 @@ struct exec_node {
#ifdef __cplusplus
struct exec_node;
-
-class iterator {
-public:
- void next()
- {
- }
-
- void *get()
- {
- return NULL;
- }
-
- bool has_next() const
- {
- return false;
- }
-};
-
-class exec_list_iterator : public iterator {
-public:
- exec_list_iterator(exec_node *n) : node(n), _next(n->next)
- {
- /* empty */
- }
-
- void next()
- {
- node = _next;
- _next = node->next;
- }
-
- void remove()
- {
- node->remove();
- }
-
- exec_node *get()
- {
- return node;
- }
-
- bool has_next() const
- {
- return _next != NULL;
- }
-
-private:
- exec_node *node;
- exec_node *_next;
-};
-
-#define foreach_iter(iter_type, iter, container) \
- for (iter_type iter = (container) . iterator(); iter.has_next(); iter.next())
#endif
-
struct exec_list {
struct exec_node *head;
struct exec_node *tail;
@@ -404,16 +350,6 @@ struct exec_list {
*/
source->make_empty();
}
-
- exec_list_iterator iterator()
- {
- return exec_list_iterator(head);
- }
-
- exec_list_iterator iterator() const
- {
- return exec_list_iterator((exec_node *) head);
- }
#endif
};
@@ -447,6 +383,22 @@ inline void exec_node::insert_before(exec_list *before)
; (__node)->next != NULL \
; (__node) = (__node)->next)
+/**
+ * Iterate through two lists at once. Stops at the end of the shorter list.
+ *
+ * This is safe against either current node being removed or replaced.
+ */
+#define foreach_two_lists(__node1, __list1, __node2, __list2) \
+ for (exec_node * __node1 = (__list1)->head, \
+ * __node2 = (__list2)->head, \
+ * __next1 = __node1->next, \
+ * __next2 = __node2->next \
+ ; __next1 != NULL && __next2 != NULL \
+ ; __node1 = __next1, \
+ __node2 = __next2, \
+ __next1 = __next1->next, \
+ __next2 = __next2->next)
+
#define foreach_list_const(__node, __list) \
for (const exec_node * __node = (__list)->head \
; (__node)->next != NULL \
diff --git a/mesalib/src/glsl/lower_if_to_cond_assign.cpp b/mesalib/src/glsl/lower_if_to_cond_assign.cpp
index 1e7ce51c7..f15b217e0 100644
--- a/mesalib/src/glsl/lower_if_to_cond_assign.cpp
+++ b/mesalib/src/glsl/lower_if_to_cond_assign.cpp
@@ -178,12 +178,12 @@ ir_if_to_cond_assign_visitor::visit_leave(ir_if *ir)
ir_assignment *assign;
/* Check that both blocks don't contain anything we can't support. */
- foreach_iter(exec_list_iterator, then_iter, ir->then_instructions) {
- ir_instruction *then_ir = (ir_instruction *)then_iter.get();
+ foreach_list(n, &ir->then_instructions) {
+ ir_instruction *then_ir = (ir_instruction *) n;
visit_tree(then_ir, check_control_flow, &found_control_flow);
}
- foreach_iter(exec_list_iterator, else_iter, ir->else_instructions) {
- ir_instruction *else_ir = (ir_instruction *)else_iter.get();
+ foreach_list(n, &ir->else_instructions) {
+ ir_instruction *else_ir = (ir_instruction *) n;
visit_tree(else_ir, check_control_flow, &found_control_flow);
}
if (found_control_flow)
diff --git a/mesalib/src/glsl/lower_vec_index_to_cond_assign.cpp b/mesalib/src/glsl/lower_vec_index_to_cond_assign.cpp
index 8080006c1..fe6a3f208 100644
--- a/mesalib/src/glsl/lower_vec_index_to_cond_assign.cpp
+++ b/mesalib/src/glsl/lower_vec_index_to_cond_assign.cpp
@@ -197,8 +197,8 @@ ir_vec_index_to_cond_assign_visitor::visit_leave(ir_assignment *ir)
ir_visitor_status
ir_vec_index_to_cond_assign_visitor::visit_enter(ir_call *ir)
{
- foreach_iter(exec_list_iterator, iter, *ir) {
- ir_rvalue *param = (ir_rvalue *)iter.get();
+ foreach_list_safe(n, &ir->actual_parameters) {
+ ir_rvalue *param = (ir_rvalue *) n;
ir_rvalue *new_param = convert_vector_extract_to_cond_assign(param);
if (new_param != param) {
diff --git a/mesalib/src/glsl/lower_vec_index_to_swizzle.cpp b/mesalib/src/glsl/lower_vec_index_to_swizzle.cpp
index 46985791e..b5bb00c30 100644
--- a/mesalib/src/glsl/lower_vec_index_to_swizzle.cpp
+++ b/mesalib/src/glsl/lower_vec_index_to_swizzle.cpp
@@ -131,8 +131,8 @@ ir_vec_index_to_swizzle_visitor::visit_enter(ir_assignment *ir)
ir_visitor_status
ir_vec_index_to_swizzle_visitor::visit_enter(ir_call *ir)
{
- foreach_iter(exec_list_iterator, iter, *ir) {
- ir_rvalue *param = (ir_rvalue *)iter.get();
+ foreach_list_safe(n, &ir->actual_parameters) {
+ ir_rvalue *param = (ir_rvalue *) n;
ir_rvalue *new_param = convert_vector_extract_to_swizzle(param);
if (new_param != param) {
diff --git a/mesalib/src/glsl/opt_array_splitting.cpp b/mesalib/src/glsl/opt_array_splitting.cpp
index e946e0ae5..f37d09022 100644
--- a/mesalib/src/glsl/opt_array_splitting.cpp
+++ b/mesalib/src/glsl/opt_array_splitting.cpp
@@ -135,8 +135,8 @@ ir_array_reference_visitor::get_variable_entry(ir_variable *var)
if (var->type->is_unsized_array())
return NULL;
- foreach_iter(exec_list_iterator, iter, this->variable_list) {
- variable_entry *entry = (variable_entry *)iter.get();
+ foreach_list(n, &this->variable_list) {
+ variable_entry *entry = (variable_entry *) n;
if (entry->var == var)
return entry;
}
@@ -224,8 +224,8 @@ ir_array_reference_visitor::get_split_list(exec_list *instructions,
}
/* Trim out variables we found that we can't split. */
- foreach_iter(exec_list_iterator, iter, variable_list) {
- variable_entry *entry = (variable_entry *)iter.get();
+ foreach_list_safe(n, &variable_list) {
+ variable_entry *entry = (variable_entry *) n;
if (debug) {
printf("array %s@%p: decl %d, split %d\n",
@@ -270,8 +270,8 @@ ir_array_splitting_visitor::get_splitting_entry(ir_variable *var)
{
assert(var);
- foreach_iter(exec_list_iterator, iter, *this->variable_list) {
- variable_entry *entry = (variable_entry *)iter.get();
+ foreach_list(n, this->variable_list) {
+ variable_entry *entry = (variable_entry *) n;
if (entry->var == var) {
return entry;
}
@@ -368,8 +368,8 @@ optimize_split_arrays(exec_list *instructions, bool linked)
/* Replace the decls of the arrays to be split with their split
* components.
*/
- foreach_iter(exec_list_iterator, iter, refs.variable_list) {
- variable_entry *entry = (variable_entry *)iter.get();
+ foreach_list(n, &refs.variable_list) {
+ variable_entry *entry = (variable_entry *) n;
const struct glsl_type *type = entry->var->type;
const struct glsl_type *subtype;
diff --git a/mesalib/src/glsl/opt_constant_folding.cpp b/mesalib/src/glsl/opt_constant_folding.cpp
index 08a47b96b..d0e575460 100644
--- a/mesalib/src/glsl/opt_constant_folding.cpp
+++ b/mesalib/src/glsl/opt_constant_folding.cpp
@@ -122,10 +122,10 @@ ir_visitor_status
ir_constant_folding_visitor::visit_enter(ir_call *ir)
{
/* Attempt to constant fold parameters */
- exec_list_iterator sig_iter = ir->callee->parameters.iterator();
- foreach_iter(exec_list_iterator, iter, *ir) {
- ir_rvalue *param_rval = (ir_rvalue *)iter.get();
- ir_variable *sig_param = (ir_variable *)sig_iter.get();
+ foreach_two_lists(formal_node, &ir->callee->parameters,
+ actual_node, &ir->actual_parameters) {
+ ir_rvalue *param_rval = (ir_rvalue *) actual_node;
+ ir_variable *sig_param = (ir_variable *) formal_node;
if (sig_param->data.mode == ir_var_function_in
|| sig_param->data.mode == ir_var_const_in) {
@@ -136,7 +136,6 @@ ir_constant_folding_visitor::visit_enter(ir_call *ir)
param_rval->replace_with(new_param);
}
}
- sig_iter.next();
}
/* Next, see if the call can be replaced with an assignment of a constant */
diff --git a/mesalib/src/glsl/opt_constant_propagation.cpp b/mesalib/src/glsl/opt_constant_propagation.cpp
index f1a6fbdaa..18f5da689 100644
--- a/mesalib/src/glsl/opt_constant_propagation.cpp
+++ b/mesalib/src/glsl/opt_constant_propagation.cpp
@@ -172,8 +172,8 @@ ir_constant_propagation_visitor::handle_rvalue(ir_rvalue **rvalue)
channel = i;
}
- foreach_iter(exec_list_iterator, iter, *this->acp) {
- acp_entry *entry = (acp_entry *)iter.get();
+ foreach_list(n, this->acp) {
+ acp_entry *entry = (acp_entry *) n;
if (entry->var == deref->var && entry->write_mask & (1 << channel)) {
found = entry;
break;
@@ -281,10 +281,10 @@ ir_visitor_status
ir_constant_propagation_visitor::visit_enter(ir_call *ir)
{
/* Do constant propagation on call parameters, but skip any out params */
- exec_list_iterator sig_param_iter = ir->callee->parameters.iterator();
- foreach_iter(exec_list_iterator, iter, ir->actual_parameters) {
- ir_variable *sig_param = (ir_variable *)sig_param_iter.get();
- ir_rvalue *param = (ir_rvalue *)iter.get();
+ foreach_two_lists(formal_node, &ir->callee->parameters,
+ actual_node, &ir->actual_parameters) {
+ ir_variable *sig_param = (ir_variable *) formal_node;
+ ir_rvalue *param = (ir_rvalue *) actual_node;
if (sig_param->data.mode != ir_var_function_out
&& sig_param->data.mode != ir_var_function_inout) {
ir_rvalue *new_param = param;
@@ -294,7 +294,6 @@ ir_constant_propagation_visitor::visit_enter(ir_call *ir)
else
param->accept(this);
}
- sig_param_iter.next();
}
/* Since we're unlinked, we don't (necssarily) know the side effects of
@@ -318,8 +317,8 @@ ir_constant_propagation_visitor::handle_if_block(exec_list *instructions)
this->killed_all = false;
/* Populate the initial acp with a constant of the original */
- foreach_iter(exec_list_iterator, iter, *orig_acp) {
- acp_entry *a = (acp_entry *)iter.get();
+ foreach_list(n, orig_acp) {
+ acp_entry *a = (acp_entry *) n;
this->acp->push_tail(new(this->mem_ctx) acp_entry(a));
}
@@ -334,8 +333,8 @@ ir_constant_propagation_visitor::handle_if_block(exec_list *instructions)
this->acp = orig_acp;
this->killed_all = this->killed_all || orig_killed_all;
- foreach_iter(exec_list_iterator, iter, *new_kills) {
- kill_entry *k = (kill_entry *)iter.get();
+ foreach_list(n, new_kills) {
+ kill_entry *k = (kill_entry *) n;
kill(k->var, k->write_mask);
}
}
@@ -379,8 +378,8 @@ ir_constant_propagation_visitor::visit_enter(ir_loop *ir)
this->acp = orig_acp;
this->killed_all = this->killed_all || orig_killed_all;
- foreach_iter(exec_list_iterator, iter, *new_kills) {
- kill_entry *k = (kill_entry *)iter.get();
+ foreach_list(n, new_kills) {
+ kill_entry *k = (kill_entry *) n;
kill(k->var, k->write_mask);
}
@@ -398,8 +397,8 @@ ir_constant_propagation_visitor::kill(ir_variable *var, unsigned write_mask)
return;
/* Remove any entries currently in the ACP for this kill. */
- foreach_iter(exec_list_iterator, iter, *this->acp) {
- acp_entry *entry = (acp_entry *)iter.get();
+ foreach_list_safe(n, this->acp) {
+ acp_entry *entry = (acp_entry *) n;
if (entry->var == var) {
entry->write_mask &= ~write_mask;
@@ -411,8 +410,8 @@ ir_constant_propagation_visitor::kill(ir_variable *var, unsigned write_mask)
/* Add this writemask of the variable to the list of killed
* variables in this block.
*/
- foreach_iter(exec_list_iterator, iter, *this->kills) {
- kill_entry *entry = (kill_entry *)iter.get();
+ foreach_list(n, this->kills) {
+ kill_entry *entry = (kill_entry *) n;
if (entry->var == var) {
entry->write_mask |= write_mask;
diff --git a/mesalib/src/glsl/opt_constant_variable.cpp b/mesalib/src/glsl/opt_constant_variable.cpp
index a026c51c3..961b8aa06 100644
--- a/mesalib/src/glsl/opt_constant_variable.cpp
+++ b/mesalib/src/glsl/opt_constant_variable.cpp
@@ -132,10 +132,10 @@ ir_visitor_status
ir_constant_variable_visitor::visit_enter(ir_call *ir)
{
/* Mark any out parameters as assigned to */
- exec_list_iterator sig_iter = ir->callee->parameters.iterator();
- foreach_iter(exec_list_iterator, iter, *ir) {
- ir_rvalue *param_rval = (ir_rvalue *)iter.get();
- ir_variable *param = (ir_variable *)sig_iter.get();
+ foreach_two_lists(formal_node, &ir->callee->parameters,
+ actual_node, &ir->actual_parameters) {
+ ir_rvalue *param_rval = (ir_rvalue *) actual_node;
+ ir_variable *param = (ir_variable *) formal_node;
if (param->data.mode == ir_var_function_out ||
param->data.mode == ir_var_function_inout) {
@@ -146,7 +146,6 @@ ir_constant_variable_visitor::visit_enter(ir_call *ir)
entry = get_assignment_entry(var, &this->list);
entry->assignment_count++;
}
- sig_iter.next();
}
/* Mark the return storage as having been assigned to */
@@ -194,13 +193,12 @@ do_constant_variable_unlinked(exec_list *instructions)
{
bool progress = false;
- foreach_iter(exec_list_iterator, iter, *instructions) {
- ir_instruction *ir = (ir_instruction *)iter.get();
+ foreach_list(n, instructions) {
+ ir_instruction *ir = (ir_instruction *) n;
ir_function *f = ir->as_function();
if (f) {
- foreach_iter(exec_list_iterator, sigiter, *f) {
- ir_function_signature *sig =
- (ir_function_signature *) sigiter.get();
+ foreach_list(signode, &f->signatures) {
+ ir_function_signature *sig = (ir_function_signature *) signode;
if (do_constant_variable(&sig->body))
progress = true;
}
diff --git a/mesalib/src/glsl/opt_copy_propagation.cpp b/mesalib/src/glsl/opt_copy_propagation.cpp
index db5dfc153..195cc8baa 100644
--- a/mesalib/src/glsl/opt_copy_propagation.cpp
+++ b/mesalib/src/glsl/opt_copy_propagation.cpp
@@ -167,8 +167,8 @@ ir_copy_propagation_visitor::visit(ir_dereference_variable *ir)
ir_variable *var = ir->var;
- foreach_iter(exec_list_iterator, iter, *this->acp) {
- acp_entry *entry = (acp_entry *)iter.get();
+ foreach_list(n, this->acp) {
+ acp_entry *entry = (acp_entry *) n;
if (var == entry->lhs) {
ir->var = entry->rhs;
@@ -185,15 +185,14 @@ ir_visitor_status
ir_copy_propagation_visitor::visit_enter(ir_call *ir)
{
/* Do copy propagation on call parameters, but skip any out params */
- exec_list_iterator sig_param_iter = ir->callee->parameters.iterator();
- foreach_iter(exec_list_iterator, iter, ir->actual_parameters) {
- ir_variable *sig_param = (ir_variable *)sig_param_iter.get();
- ir_instruction *ir = (ir_instruction *)iter.get();
+ foreach_two_lists(formal_node, &ir->callee->parameters,
+ actual_node, &ir->actual_parameters) {
+ ir_variable *sig_param = (ir_variable *) formal_node;
+ ir_rvalue *ir = (ir_rvalue *) actual_node;
if (sig_param->data.mode != ir_var_function_out
&& sig_param->data.mode != ir_var_function_inout) {
ir->accept(this);
}
- sig_param_iter.next();
}
/* Since we're unlinked, we don't (necessarily) know the side effects of
@@ -217,8 +216,8 @@ ir_copy_propagation_visitor::handle_if_block(exec_list *instructions)
this->killed_all = false;
/* Populate the initial acp with a copy of the original */
- foreach_iter(exec_list_iterator, iter, *orig_acp) {
- acp_entry *a = (acp_entry *)iter.get();
+ foreach_list(n, orig_acp) {
+ acp_entry *a = (acp_entry *) n;
this->acp->push_tail(new(this->mem_ctx) acp_entry(a->lhs, a->rhs));
}
@@ -233,8 +232,8 @@ ir_copy_propagation_visitor::handle_if_block(exec_list *instructions)
this->acp = orig_acp;
this->killed_all = this->killed_all || orig_killed_all;
- foreach_iter(exec_list_iterator, iter, *new_kills) {
- kill_entry *k = (kill_entry *)iter.get();
+ foreach_list(n, new_kills) {
+ kill_entry *k = (kill_entry *) n;
kill(k->var);
}
}
@@ -277,8 +276,8 @@ ir_copy_propagation_visitor::visit_enter(ir_loop *ir)
this->acp = orig_acp;
this->killed_all = this->killed_all || orig_killed_all;
- foreach_iter(exec_list_iterator, iter, *new_kills) {
- kill_entry *k = (kill_entry *)iter.get();
+ foreach_list(n, new_kills) {
+ kill_entry *k = (kill_entry *) n;
kill(k->var);
}
@@ -292,8 +291,8 @@ ir_copy_propagation_visitor::kill(ir_variable *var)
assert(var != NULL);
/* Remove any entries currently in the ACP for this kill. */
- foreach_iter(exec_list_iterator, iter, *acp) {
- acp_entry *entry = (acp_entry *)iter.get();
+ foreach_list_safe(n, acp) {
+ acp_entry *entry = (acp_entry *) n;
if (entry->lhs == var || entry->rhs == var) {
entry->remove();
diff --git a/mesalib/src/glsl/opt_copy_propagation_elements.cpp b/mesalib/src/glsl/opt_copy_propagation_elements.cpp
index ba8a0f532..cc53e0dd0 100644
--- a/mesalib/src/glsl/opt_copy_propagation_elements.cpp
+++ b/mesalib/src/glsl/opt_copy_propagation_elements.cpp
@@ -244,8 +244,8 @@ ir_copy_propagation_elements_visitor::handle_rvalue(ir_rvalue **ir)
/* Try to find ACP entries covering swizzle_chan[], hoping they're
* the same source variable.
*/
- foreach_iter(exec_list_iterator, iter, *this->acp) {
- acp_entry *entry = (acp_entry *)iter.get();
+ foreach_list(n, this->acp) {
+ acp_entry *entry = (acp_entry *) n;
if (var == entry->lhs) {
for (int c = 0; c < chans; c++) {
@@ -293,15 +293,14 @@ ir_visitor_status
ir_copy_propagation_elements_visitor::visit_enter(ir_call *ir)
{
/* Do copy propagation on call parameters, but skip any out params */
- exec_list_iterator sig_param_iter = ir->callee->parameters.iterator();
- foreach_iter(exec_list_iterator, iter, ir->actual_parameters) {
- ir_variable *sig_param = (ir_variable *)sig_param_iter.get();
- ir_instruction *ir = (ir_instruction *)iter.get();
+ foreach_two_lists(formal_node, &ir->callee->parameters,
+ actual_node, &ir->actual_parameters) {
+ ir_variable *sig_param = (ir_variable *) formal_node;
+ ir_rvalue *ir = (ir_rvalue *) actual_node;
if (sig_param->data.mode != ir_var_function_out
&& sig_param->data.mode != ir_var_function_inout) {
ir->accept(this);
}
- sig_param_iter.next();
}
/* Since we're unlinked, we don't (necessarily) know the side effects of
@@ -325,8 +324,8 @@ ir_copy_propagation_elements_visitor::handle_if_block(exec_list *instructions)
this->killed_all = false;
/* Populate the initial acp with a copy of the original */
- foreach_iter(exec_list_iterator, iter, *orig_acp) {
- acp_entry *a = (acp_entry *)iter.get();
+ foreach_list(n, orig_acp) {
+ acp_entry *a = (acp_entry *) n;
this->acp->push_tail(new(this->mem_ctx) acp_entry(a));
}
diff --git a/mesalib/src/glsl/opt_dead_code.cpp b/mesalib/src/glsl/opt_dead_code.cpp
index a8d8b4a39..af53d94fd 100644
--- a/mesalib/src/glsl/opt_dead_code.cpp
+++ b/mesalib/src/glsl/opt_dead_code.cpp
@@ -129,13 +129,12 @@ do_dead_code_unlinked(exec_list *instructions)
{
bool progress = false;
- foreach_iter(exec_list_iterator, iter, *instructions) {
- ir_instruction *ir = (ir_instruction *)iter.get();
+ foreach_list(n, instructions) {
+ ir_instruction *ir = (ir_instruction *) n;
ir_function *f = ir->as_function();
if (f) {
- foreach_iter(exec_list_iterator, sigiter, *f) {
- ir_function_signature *sig =
- (ir_function_signature *) sigiter.get();
+ foreach_list(signode, &f->signatures) {
+ ir_function_signature *sig = (ir_function_signature *) signode;
/* The setting of the uniform_locations_assigned flag here is
* irrelevent. If there is a uniform declaration encountered
* inside the body of the function, something has already gone
diff --git a/mesalib/src/glsl/opt_dead_code_local.cpp b/mesalib/src/glsl/opt_dead_code_local.cpp
index 43a01662a..e7d46edbe 100644
--- a/mesalib/src/glsl/opt_dead_code_local.cpp
+++ b/mesalib/src/glsl/opt_dead_code_local.cpp
@@ -70,8 +70,8 @@ public:
void kill_channels(ir_variable *const var, int used)
{
- foreach_iter(exec_list_iterator, iter, *this->assignments) {
- assignment_entry *entry = (assignment_entry *)iter.get();
+ foreach_list_safe(n, this->assignments) {
+ assignment_entry *entry = (assignment_entry *) n;
if (entry->lhs == var) {
if (var->type->is_scalar() || var->type->is_vector()) {
@@ -119,8 +119,8 @@ public:
/* For the purpose of dead code elimination, emitting a vertex counts as
* "reading" all of the currently assigned output variables.
*/
- foreach_iter(exec_list_iterator, iter, *this->assignments) {
- assignment_entry *entry = (assignment_entry *)iter.get();
+ foreach_list_safe(n, this->assignments) {
+ assignment_entry *entry = (assignment_entry *) n;
if (entry->lhs->data.mode == ir_var_shader_out) {
if (debug)
printf("kill %s\n", entry->lhs->name);
@@ -196,8 +196,8 @@ process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments)
printf("looking for %s.0x%01x to remove\n", var->name,
ir->write_mask);
- foreach_iter(exec_list_iterator, iter, *assignments) {
- assignment_entry *entry = (assignment_entry *)iter.get();
+ foreach_list_safe(n, assignments) {
+ assignment_entry *entry = (assignment_entry *) n;
if (entry->lhs != var)
continue;
@@ -258,8 +258,8 @@ process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments)
*/
if (debug)
printf("looking for %s to remove\n", var->name);
- foreach_iter(exec_list_iterator, iter, *assignments) {
- assignment_entry *entry = (assignment_entry *)iter.get();
+ foreach_list_safe(n, assignments) {
+ assignment_entry *entry = (assignment_entry *) n;
if (entry->lhs == var) {
if (debug)
@@ -280,8 +280,8 @@ process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments)
printf("add %s\n", var->name);
printf("current entries\n");
- foreach_iter(exec_list_iterator, iter, *assignments) {
- assignment_entry *entry = (assignment_entry *)iter.get();
+ foreach_list(n, assignments) {
+ assignment_entry *entry = (assignment_entry *) n;
printf(" %s (0x%01x)\n", entry->lhs->name, entry->available);
}
diff --git a/mesalib/src/glsl/opt_dead_functions.cpp b/mesalib/src/glsl/opt_dead_functions.cpp
index cd3b2c12e..8bb278e45 100644
--- a/mesalib/src/glsl/opt_dead_functions.cpp
+++ b/mesalib/src/glsl/opt_dead_functions.cpp
@@ -74,8 +74,8 @@ public:
signature_entry *
ir_dead_functions_visitor::get_signature_entry(ir_function_signature *sig)
{
- foreach_iter(exec_list_iterator, iter, this->signature_list) {
- signature_entry *entry = (signature_entry *)iter.get();
+ foreach_list(n, &this->signature_list) {
+ signature_entry *entry = (signature_entry *) n;
if (entry->signature == sig)
return entry;
}
@@ -123,8 +123,8 @@ do_dead_functions(exec_list *instructions)
* the unused ones, and remove function definitions that have no more
* signatures.
*/
- foreach_iter(exec_list_iterator, iter, v.signature_list) {
- signature_entry *entry = (signature_entry *)iter.get();
+ foreach_list_safe(n, &v.signature_list) {
+ signature_entry *entry = (signature_entry *) n;
if (!entry->used) {
entry->signature->remove();
@@ -137,8 +137,8 @@ do_dead_functions(exec_list *instructions)
/* We don't just do this above when we nuked a signature because of
* const pointers.
*/
- foreach_iter(exec_list_iterator, iter, *instructions) {
- ir_instruction *ir = (ir_instruction *)iter.get();
+ foreach_list_safe(n, instructions) {
+ ir_instruction *ir = (ir_instruction *) n;
ir_function *func = ir->as_function();
if (func && func->signatures.is_empty()) {
diff --git a/mesalib/src/glsl/opt_function_inlining.cpp b/mesalib/src/glsl/opt_function_inlining.cpp
index c8f42a424..9649598dd 100644
--- a/mesalib/src/glsl/opt_function_inlining.cpp
+++ b/mesalib/src/glsl/opt_function_inlining.cpp
@@ -107,7 +107,7 @@ ir_call::generate_inline(ir_instruction *next_ir)
ht = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare);
num_parameters = 0;
- foreach_iter(exec_list_iterator, iter_sig, this->callee->parameters)
+ foreach_list(n, &this->callee->parameters)
num_parameters++;
parameters = new ir_variable *[num_parameters];
@@ -116,11 +116,10 @@ ir_call::generate_inline(ir_instruction *next_ir)
* and set up the mapping of real function body variables to ours.
*/
i = 0;
- exec_list_iterator sig_param_iter = this->callee->parameters.iterator();
- exec_list_iterator param_iter = this->actual_parameters.iterator();
- for (i = 0; i < num_parameters; i++) {
- ir_variable *sig_param = (ir_variable *) sig_param_iter.get();
- ir_rvalue *param = (ir_rvalue *) param_iter.get();
+ foreach_two_lists(formal_node, &this->callee->parameters,
+ actual_node, &this->actual_parameters) {
+ ir_variable *sig_param = (ir_variable *) formal_node;
+ ir_rvalue *param = (ir_rvalue *) actual_node;
/* Generate a new variable for the parameter. */
if (sig_param->type->contains_opaque()) {
@@ -154,15 +153,14 @@ ir_call::generate_inline(ir_instruction *next_ir)
next_ir->insert_before(assign);
}
- sig_param_iter.next();
- param_iter.next();
+ ++i;
}
exec_list new_instructions;
/* Generate the inlined body of the function to a new list */
- foreach_iter(exec_list_iterator, iter, callee->body) {
- ir_instruction *ir = (ir_instruction *)iter.get();
+ foreach_list(n, &callee->body) {
+ ir_instruction *ir = (ir_instruction *) n;
ir_instruction *new_ir = ir->clone(ctx, ht);
new_instructions.push_tail(new_ir);
@@ -172,11 +170,10 @@ ir_call::generate_inline(ir_instruction *next_ir)
/* If any opaque types were passed in, replace any deref of the
* opaque variable with a deref of the argument.
*/
- param_iter = this->actual_parameters.iterator();
- sig_param_iter = this->callee->parameters.iterator();
- for (i = 0; i < num_parameters; i++) {
- ir_instruction *const param = (ir_instruction *) param_iter.get();
- ir_variable *sig_param = (ir_variable *) sig_param_iter.get();
+ foreach_two_lists(formal_node, &this->callee->parameters,
+ actual_node, &this->actual_parameters) {
+ ir_rvalue *const param = (ir_rvalue *) actual_node;
+ ir_variable *sig_param = (ir_variable *) formal_node;
if (sig_param->type->contains_opaque()) {
ir_dereference *deref = param->as_dereference();
@@ -184,8 +181,6 @@ ir_call::generate_inline(ir_instruction *next_ir)
assert(deref);
do_variable_replacement(&new_instructions, sig_param, deref);
}
- param_iter.next();
- sig_param_iter.next();
}
/* Now push those new instructions in. */
@@ -195,11 +190,10 @@ ir_call::generate_inline(ir_instruction *next_ir)
* variables to our own.
*/
i = 0;
- param_iter = this->actual_parameters.iterator();
- sig_param_iter = this->callee->parameters.iterator();
- for (i = 0; i < num_parameters; i++) {
- ir_instruction *const param = (ir_instruction *) param_iter.get();
- const ir_variable *const sig_param = (ir_variable *) sig_param_iter.get();
+ foreach_two_lists(formal_node, &this->callee->parameters,
+ actual_node, &this->actual_parameters) {
+ ir_rvalue *const param = (ir_rvalue *) actual_node;
+ const ir_variable *const sig_param = (ir_variable *) formal_node;
/* Move our param variable into the actual param if it's an 'out' type. */
if (parameters[i] && (sig_param->data.mode == ir_var_function_out ||
@@ -212,8 +206,7 @@ ir_call::generate_inline(ir_instruction *next_ir)
next_ir->insert_before(assign);
}
- param_iter.next();
- sig_param_iter.next();
+ ++i;
}
delete [] parameters;
@@ -349,8 +342,8 @@ ir_variable_replacement_visitor::visit_leave(ir_dereference_record *ir)
ir_visitor_status
ir_variable_replacement_visitor::visit_leave(ir_call *ir)
{
- foreach_iter(exec_list_iterator, iter, *ir) {
- ir_rvalue *param = (ir_rvalue *)iter.get();
+ foreach_list_safe(n, &ir->actual_parameters) {
+ ir_rvalue *param = (ir_rvalue *) n;
ir_rvalue *new_param = param;
replace_rvalue(&new_param);
diff --git a/mesalib/src/glsl/opt_if_simplification.cpp b/mesalib/src/glsl/opt_if_simplification.cpp
index db59b131d..2bec8252e 100644
--- a/mesalib/src/glsl/opt_if_simplification.cpp
+++ b/mesalib/src/glsl/opt_if_simplification.cpp
@@ -90,13 +90,13 @@ ir_if_simplification_visitor::visit_leave(ir_if *ir)
* that matters out.
*/
if (condition_constant->value.b[0]) {
- foreach_iter(exec_list_iterator, then_iter, ir->then_instructions) {
- ir_instruction *then_ir = (ir_instruction *)then_iter.get();
+ foreach_list_safe(n, &ir->then_instructions) {
+ ir_instruction *then_ir = (ir_instruction *) n;
ir->insert_before(then_ir);
}
} else {
- foreach_iter(exec_list_iterator, else_iter, ir->else_instructions) {
- ir_instruction *else_ir = (ir_instruction *)else_iter.get();
+ foreach_list_safe(n, &ir->else_instructions) {
+ ir_instruction *else_ir = (ir_instruction *) n;
ir->insert_before(else_ir);
}
}
diff --git a/mesalib/src/glsl/opt_structure_splitting.cpp b/mesalib/src/glsl/opt_structure_splitting.cpp
index 414f0000d..1ec537b13 100644
--- a/mesalib/src/glsl/opt_structure_splitting.cpp
+++ b/mesalib/src/glsl/opt_structure_splitting.cpp
@@ -107,8 +107,8 @@ ir_structure_reference_visitor::get_variable_entry(ir_variable *var)
|| var->data.mode == ir_var_shader_in || var->data.mode == ir_var_shader_out)
return NULL;
- foreach_iter(exec_list_iterator, iter, this->variable_list) {
- variable_entry *entry = (variable_entry *)iter.get();
+ foreach_list(n, &this->variable_list) {
+ variable_entry *entry = (variable_entry *) n;
if (entry->var == var)
return entry;
}
@@ -209,8 +209,8 @@ ir_structure_splitting_visitor::get_splitting_entry(ir_variable *var)
if (!var->type->is_record())
return NULL;
- foreach_iter(exec_list_iterator, iter, *this->variable_list) {
- variable_entry *entry = (variable_entry *)iter.get();
+ foreach_list(n, this->variable_list) {
+ variable_entry *entry = (variable_entry *) n;
if (entry->var == var) {
return entry;
}
@@ -315,8 +315,8 @@ do_structure_splitting(exec_list *instructions)
visit_list_elements(&refs, instructions);
/* Trim out variables we can't split. */
- foreach_iter(exec_list_iterator, iter, refs.variable_list) {
- variable_entry *entry = (variable_entry *)iter.get();
+ foreach_list_safe(n, &refs.variable_list) {
+ variable_entry *entry = (variable_entry *) n;
if (debug) {
printf("structure %s@%p: decl %d, whole_access %d\n",
@@ -337,8 +337,8 @@ do_structure_splitting(exec_list *instructions)
/* Replace the decls of the structures to be split with their split
* components.
*/
- foreach_iter(exec_list_iterator, iter, refs.variable_list) {
- variable_entry *entry = (variable_entry *)iter.get();
+ foreach_list_safe(n, &refs.variable_list) {
+ variable_entry *entry = (variable_entry *) n;
const struct glsl_type *type = entry->var->type;
entry->mem_ctx = ralloc_parent(entry->var);
diff --git a/mesalib/src/glsl/opt_tree_grafting.cpp b/mesalib/src/glsl/opt_tree_grafting.cpp
index 6d75a1573..f3bd580af 100644
--- a/mesalib/src/glsl/opt_tree_grafting.cpp
+++ b/mesalib/src/glsl/opt_tree_grafting.cpp
@@ -204,11 +204,10 @@ ir_tree_grafting_visitor::visit_enter(ir_function_signature *ir)
ir_visitor_status
ir_tree_grafting_visitor::visit_enter(ir_call *ir)
{
- exec_list_iterator sig_iter = ir->callee->parameters.iterator();
- /* Reminder: iterating ir_call iterates its parameters. */
- foreach_iter(exec_list_iterator, iter, *ir) {
- ir_variable *sig_param = (ir_variable *)sig_iter.get();
- ir_rvalue *ir = (ir_rvalue *)iter.get();
+ foreach_two_lists(formal_node, &ir->callee->parameters,
+ actual_node, &ir->actual_parameters) {
+ ir_variable *sig_param = (ir_variable *) formal_node;
+ ir_rvalue *ir = (ir_rvalue *) actual_node;
ir_rvalue *new_ir = ir;
if (sig_param->data.mode != ir_var_function_in
@@ -222,7 +221,6 @@ ir_tree_grafting_visitor::visit_enter(ir_call *ir)
ir->replace_with(new_ir);
return visit_stop;
}
- sig_iter.next();
}
if (ir->return_deref && check_graft(ir, ir->return_deref->var) == visit_stop)
diff --git a/mesalib/src/glsl/s_expression.cpp b/mesalib/src/glsl/s_expression.cpp
index 1bdf6bca6..6906ff0eb 100644
--- a/mesalib/src/glsl/s_expression.cpp
+++ b/mesalib/src/glsl/s_expression.cpp
@@ -162,8 +162,8 @@ void s_symbol::print()
void s_list::print()
{
printf("(");
- foreach_iter(exec_list_iterator, it, this->subexpressions) {
- s_expression *expr = (s_expression*) it.get();
+ foreach_list(n, &this->subexpressions) {
+ s_expression *expr = (s_expression *) n;
expr->print();
if (!expr->next->is_tail_sentinel())
printf(" ");
@@ -201,11 +201,11 @@ s_match(s_expression *top, unsigned n, s_pattern *pattern, bool partial)
return false;
unsigned i = 0;
- foreach_iter(exec_list_iterator, it, list->subexpressions) {
+ foreach_list(node, &list->subexpressions) {
if (i >= n)
return partial; /* More actual items than the pattern expected */
- s_expression *expr = (s_expression *) it.get();
+ s_expression *expr = (s_expression *) node;
if (expr == NULL || !pattern[i].match(expr))
return false;