diff options
Diffstat (limited to 'src/glsl')
39 files changed, 184 insertions, 291 deletions
diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 8e91a1e67f6..394d6dced43 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -82,9 +82,7 @@ prototype_string(const glsl_type *return_type, const char *name, ralloc_asprintf_append(&str, "%s(", name); const char *comma = ""; - foreach_list(node, parameters) { - const ir_variable *const param = (ir_variable *) node; - + foreach_in_list(const ir_variable, param, parameters) { ralloc_asprintf_append(&str, "%s%s", comma, param->type->name); comma = ", "; } @@ -158,12 +156,11 @@ verify_parameter_modes(_mesa_glsl_parse_state *state, exec_node *actual_ir_node = actual_ir_parameters.head; exec_node *actual_ast_node = actual_ast_parameters.head; - foreach_list(formal_node, &sig->parameters) { + foreach_in_list(const ir_variable, formal, &sig->parameters) { /* The lists must be the same length. */ assert(!actual_ir_node->is_tail_sentinel()); assert(!actual_ast_node->is_tail_sentinel()); - const ir_variable *const formal = (ir_variable *) formal_node; const ir_rvalue *const actual = (ir_rvalue *) actual_ir_node; const ast_expression *const actual_ast = exec_node_data(ast_expression, actual_ast_node, link); @@ -478,9 +475,7 @@ print_function_prototypes(_mesa_glsl_parse_state *state, YYLTYPE *loc, if (f == NULL) return; - foreach_list (node, &f->signatures) { - ir_function_signature *sig = (ir_function_signature *) node; - + foreach_in_list(ir_function_signature, sig, &f->signatures) { if (sig->is_builtin() && !sig->is_builtin_available(state)) continue; @@ -749,8 +744,7 @@ process_vec_mat_constructor(exec_list *instructions, instructions->push_tail(var); int i = 0; - foreach_list(node, &actual_parameters) { - ir_rvalue *rhs = (ir_rvalue *) node; + foreach_in_list(ir_rvalue, rhs, &actual_parameters) { ir_rvalue *lhs = new(ctx) ir_dereference_array(var, new(ctx) ir_constant(i)); @@ -870,8 +864,7 @@ process_array_constructor(exec_list *instructions, instructions->push_tail(var); int i = 0; - foreach_list(node, &actual_parameters) { - ir_rvalue *rhs = (ir_rvalue *) node; + foreach_in_list(ir_rvalue, rhs, &actual_parameters) { ir_rvalue *lhs = new(ctx) ir_dereference_array(var, new(ctx) ir_constant(i)); @@ -892,8 +885,8 @@ static ir_constant * constant_record_constructor(const glsl_type *constructor_type, exec_list *parameters, void *mem_ctx) { - foreach_list(node, parameters) { - ir_constant *constant = ((ir_instruction *) node)->as_constant(); + foreach_in_list(ir_instruction, node, parameters) { + ir_constant *constant = node->as_constant(); if (constant == NULL) return NULL; node->replace_with(constant); @@ -967,8 +960,7 @@ emit_inline_vector_constructor(const glsl_type *type, memset(&data, 0, sizeof(data)); - foreach_list(node, parameters) { - ir_rvalue *param = (ir_rvalue *) node; + foreach_in_list(ir_rvalue, param, parameters) { unsigned rhs_components = param->type->components(); /* Do not try to assign more components to the vector than it has! @@ -1025,8 +1017,7 @@ emit_inline_vector_constructor(const glsl_type *type, } base_component = 0; - foreach_list(node, parameters) { - ir_rvalue *param = (ir_rvalue *) node; + foreach_in_list(ir_rvalue, param, parameters) { unsigned rhs_components = param->type->components(); /* Do not try to assign more components to the vector than it has! @@ -1312,8 +1303,7 @@ emit_inline_matrix_constructor(const glsl_type *type, unsigned col_idx = 0; unsigned row_idx = 0; - foreach_list (node, parameters) { - ir_rvalue *const rhs = (ir_rvalue *) node; + foreach_in_list(ir_rvalue, rhs, parameters) { const unsigned components_remaining_this_column = rows - row_idx; unsigned rhs_components = rhs->type->components(); unsigned rhs_base = 0; diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 042ef243b64..eb9fe4b97b7 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -4210,10 +4210,8 @@ ast_function_definition::hir(exec_list *instructions, * Add these to the symbol table. */ state->symbols->push_scope(); - foreach_list(n, &signature->parameters) { - ir_variable *const var = ((ir_instruction *) n)->as_variable(); - - assert(var != NULL); + foreach_in_list(ir_variable, var, &signature->parameters) { + assert(var->as_variable() != NULL); /* The only way a parameter would "exist" is if two parameters have * the same name. @@ -5678,8 +5676,8 @@ ast_gs_input_layout::hir(exec_list *instructions, /* If any shader inputs occurred before this declaration and did not * specify an array size, their size is determined now. */ - foreach_list (node, instructions) { - ir_variable *var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, instructions) { + ir_variable *var = node->as_variable(); if (var == NULL || var->data.mode != ir_var_shader_in) continue; @@ -5796,8 +5794,8 @@ detect_conflicting_assignments(struct _mesa_glsl_parse_state *state, YYLTYPE loc; memset(&loc, 0, sizeof(loc)); - foreach_list(node, instructions) { - ir_variable *var = ((ir_instruction *)node)->as_variable(); + foreach_in_list(ir_instruction, node, instructions) { + ir_variable *var = node->as_variable(); if (!var || !var->data.assigned) continue; diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp index 94b57810720..258b83142c0 100644 --- a/src/glsl/builtin_functions.cpp +++ b/src/glsl/builtin_functions.cpp @@ -2575,8 +2575,7 @@ builtin_builder::call(ir_function *f, ir_variable *ret, exec_list params) { exec_list actual_params; - foreach_list(node, ¶ms) { - ir_variable *var = (ir_variable *) node; + foreach_in_list(ir_variable, var, ¶ms) { actual_params.push_tail(var_ref(var)); } diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 10c00068e87..9fb41574422 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -699,8 +699,7 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) if (type->is_array()) { this->array_elements = ralloc_array(this, ir_constant *, type->length); unsigned i = 0; - foreach_list(node, value_list) { - ir_constant *value = (ir_constant *) node; + foreach_in_list(ir_constant, value, value_list) { assert(value->as_constant() != NULL); this->array_elements[i++] = value; @@ -1001,9 +1000,7 @@ ir_constant::copy_offset(ir_constant *src, int offset) case GLSL_TYPE_STRUCT: { assert (src->type == this->type); this->components.make_empty(); - foreach_list(node, &src->components) { - ir_constant *const orig = (ir_constant *) node; - + foreach_in_list(ir_constant, orig, &src->components) { this->components.push_tail(orig->clone(this, NULL)); } break; @@ -1702,8 +1699,7 @@ ir_function::ir_function(const char *name) bool ir_function::has_user_signature() { - foreach_list(n, &this->signatures) { - ir_function_signature *const sig = (ir_function_signature *) n; + foreach_in_list(ir_function_signature, sig, &this->signatures) { if (!sig->is_builtin()) return true; } @@ -1746,8 +1742,7 @@ steal_memory(ir_instruction *ir, void *new_ctx) */ if (constant != NULL) { if (constant->type->is_record()) { - foreach_list(n, &constant->components) { - ir_constant *field = (ir_constant *) n; + foreach_in_list(ir_constant, field, &constant->components) { steal_memory(field, ir); } } else if (constant->type->is_array()) { @@ -1764,8 +1759,8 @@ steal_memory(ir_instruction *ir, void *new_ctx) void reparent_ir(exec_list *list, void *mem_ctx) { - foreach_list(node, list) { - visit_tree((ir_instruction *) node, steal_memory, mem_ctx); + foreach_in_list(ir_instruction, node, list) { + visit_tree(node, steal_memory, mem_ctx); } } diff --git a/src/glsl/ir_basic_block.cpp b/src/glsl/ir_basic_block.cpp index 74ee4b69622..15481aa47f6 100644 --- a/src/glsl/ir_basic_block.cpp +++ b/src/glsl/ir_basic_block.cpp @@ -56,8 +56,7 @@ void call_for_basic_blocks(exec_list *instructions, ir_instruction *leader = NULL; ir_instruction *last = NULL; - foreach_list(n, instructions) { - ir_instruction *ir = (ir_instruction *) n; + foreach_in_list(ir_instruction, ir, instructions) { ir_if *ir_if; ir_loop *ir_loop; ir_function *ir_function; @@ -88,9 +87,7 @@ void call_for_basic_blocks(exec_list *instructions, * and the body of main(). Perhaps those instructions ought * to live inside of main(). */ - foreach_list(func_node, &ir_function->signatures) { - ir_function_signature *ir_sig = (ir_function_signature *) func_node; - + foreach_in_list(ir_function_signature, ir_sig, &ir_function->signatures) { call_for_basic_blocks(&ir_sig->body, callback, data); } } diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index c00adc5643f..86a620552aa 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -123,13 +123,11 @@ 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_list(n, &this->then_instructions) { - ir_instruction *ir = (ir_instruction *) n; + foreach_in_list(ir_instruction, ir, &this->then_instructions) { new_if->then_instructions.push_tail(ir->clone(mem_ctx, ht)); } - foreach_list(n, &this->else_instructions) { - ir_instruction *ir = (ir_instruction *) n; + foreach_in_list(ir_instruction, ir, &this->else_instructions) { new_if->else_instructions.push_tail(ir->clone(mem_ctx, ht)); } @@ -141,8 +139,7 @@ ir_loop::clone(void *mem_ctx, struct hash_table *ht) const { ir_loop *new_loop = new(mem_ctx) ir_loop(); - foreach_list(n, &this->body_instructions) { - ir_instruction *ir = (ir_instruction *) n; + foreach_in_list(ir_instruction, ir, &this->body_instructions) { new_loop->body_instructions.push_tail(ir->clone(mem_ctx, ht)); } @@ -158,8 +155,7 @@ ir_call::clone(void *mem_ctx, struct hash_table *ht) const exec_list new_parameters; - foreach_list(n, &this->actual_parameters) { - ir_instruction *ir = (ir_instruction *) n; + foreach_in_list(ir_instruction, ir, &this->actual_parameters) { new_parameters.push_tail(ir->clone(mem_ctx, ht)); } diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 7b4a22df43f..7f83eb134fa 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -1782,8 +1782,7 @@ bool ir_function_signature::constant_expression_evaluate_expression_list(const s struct hash_table *variable_context, ir_constant **result) { - foreach_list(n, &body) { - ir_instruction *inst = (ir_instruction *)n; + foreach_in_list(ir_instruction, inst, &body) { switch(inst->ir_type) { /* (declare () type symbol) */ @@ -1922,8 +1921,8 @@ ir_function_signature::constant_expression_value(exec_list *actual_parameters, s */ const exec_node *parameter_info = origin ? origin->parameters.head : parameters.head; - foreach_list(n, actual_parameters) { - ir_constant *constant = ((ir_rvalue *) n)->constant_expression_value(variable_context); + foreach_in_list(ir_rvalue, n, actual_parameters) { + ir_constant *constant = n->constant_expression_value(variable_context); if (constant == NULL) { hash_table_dtor(deref_hash); return NULL; diff --git a/src/glsl/ir_expression_flattening.cpp b/src/glsl/ir_expression_flattening.cpp index 0b1ada519a8..c13ae811d78 100644 --- a/src/glsl/ir_expression_flattening.cpp +++ b/src/glsl/ir_expression_flattening.cpp @@ -57,9 +57,7 @@ do_expression_flattening(exec_list *instructions, { ir_expression_flattening_visitor v(predicate); - foreach_list(n, instructions) { - ir_instruction *ir = (ir_instruction *) n; - + foreach_in_list(ir_instruction, ir, instructions) { ir->accept(&v); } } diff --git a/src/glsl/ir_function.cpp b/src/glsl/ir_function.cpp index deec1dfe860..7d6c2f45133 100644 --- a/src/glsl/ir_function.cpp +++ b/src/glsl/ir_function.cpp @@ -306,9 +306,7 @@ 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_list(n, &this->signatures) { - ir_function_signature *const sig = (ir_function_signature *) n; - + foreach_in_list(ir_function_signature, sig, &this->signatures) { /* Skip over any built-ins that aren't available in this shader. */ if (sig->is_builtin() && !sig->is_builtin_available(state)) continue; @@ -380,9 +378,7 @@ ir_function_signature * ir_function::exact_matching_signature(_mesa_glsl_parse_state *state, const exec_list *actual_parameters) { - foreach_list(n, &this->signatures) { - ir_function_signature *const sig = (ir_function_signature *) n; - + foreach_in_list(ir_function_signature, sig, &this->signatures) { /* Skip over any built-ins that aren't available in this shader. */ if (sig->is_builtin() && !sig->is_builtin_available(state)) continue; diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp index 72ad4223f56..bd398052c3f 100644 --- a/src/glsl/ir_print_visitor.cpp +++ b/src/glsl/ir_print_visitor.cpp @@ -67,8 +67,7 @@ _mesa_print_ir(FILE *f, exec_list *instructions, } fprintf(f, "(\n"); - foreach_list(n, instructions) { - ir_instruction *ir = (ir_instruction *) n; + foreach_in_list(ir_instruction, ir, instructions) { ir->fprint(f); if (ir->ir_type != ir_type_function) fprintf(f, "\n"); @@ -196,9 +195,7 @@ void ir_print_visitor::visit(ir_function_signature *ir) fprintf(f, "(parameters\n"); indentation++; - foreach_list(n, &ir->parameters) { - ir_variable *const inst = (ir_variable *) n; - + foreach_in_list(ir_variable, inst, &ir->parameters) { indent(); inst->accept(this); fprintf(f, "\n"); @@ -213,9 +210,7 @@ void ir_print_visitor::visit(ir_function_signature *ir) fprintf(f, "(\n"); indentation++; - foreach_list(n, &ir->body) { - ir_instruction *const inst = (ir_instruction *) n; - + foreach_in_list(ir_instruction, inst, &ir->body) { indent(); inst->accept(this); fprintf(f, "\n"); @@ -232,8 +227,7 @@ void ir_print_visitor::visit(ir_function *ir) { fprintf(f, "(function %s\n", ir->name); indentation++; - foreach_list(n, &ir->signatures) { - ir_function_signature *const sig = (ir_function_signature *) n; + foreach_in_list(ir_function_signature, sig, &ir->signatures) { indent(); sig->accept(this); fprintf(f, "\n"); @@ -457,9 +451,7 @@ ir_print_visitor::visit(ir_call *ir) if (ir->return_deref) ir->return_deref->accept(this); fprintf(f, " ("); - foreach_list(n, &ir->actual_parameters) { - ir_rvalue *const param = (ir_rvalue *) n; - + foreach_in_list(ir_rvalue, param, &ir->actual_parameters) { param->accept(this); } fprintf(f, "))\n"); @@ -504,9 +496,7 @@ ir_print_visitor::visit(ir_if *ir) fprintf(f, "(\n"); indentation++; - foreach_list(n, &ir->then_instructions) { - ir_instruction *const inst = (ir_instruction *) n; - + foreach_in_list(ir_instruction, inst, &ir->then_instructions) { indent(); inst->accept(this); fprintf(f, "\n"); @@ -521,9 +511,7 @@ ir_print_visitor::visit(ir_if *ir) fprintf(f, "(\n"); indentation++; - foreach_list(n, &ir->else_instructions) { - ir_instruction *const inst = (ir_instruction *) n; - + foreach_in_list(ir_instruction, inst, &ir->else_instructions) { indent(); inst->accept(this); fprintf(f, "\n"); @@ -543,9 +531,7 @@ ir_print_visitor::visit(ir_loop *ir) fprintf(f, "(loop (\n"); indentation++; - foreach_list(n, &ir->body_instructions) { - ir_instruction *const inst = (ir_instruction *) n; - + foreach_in_list(ir_instruction, inst, &ir->body_instructions) { indent(); inst->accept(this); fprintf(f, "\n"); diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index a178c82b536..445d381cf50 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -317,8 +317,7 @@ ir_reader::read_instructions(exec_list *instructions, s_expression *expr, return; } - foreach_list(n, &list->subexpressions) { - s_expression *sub = (s_expression *) n; + foreach_in_list(s_expression, sub, &list->subexpressions) { ir_instruction *ir = read_instruction(sub, loop_ctx); if (ir != NULL) { /* Global variable declarations should be moved to the top, before @@ -664,11 +663,10 @@ ir_reader::read_call(s_expression *expr) exec_list parameters; - foreach_list(n, ¶ms->subexpressions) { - s_expression *expr = (s_expression *) n; - ir_rvalue *param = read_rvalue(expr); + foreach_in_list(s_expression, e, ¶ms->subexpressions) { + ir_rvalue *param = read_rvalue(e); if (param == NULL) { - ir_read_error(expr, "when reading parameter to function call"); + ir_read_error(e, "when reading parameter to function call"); return NULL; } parameters.push_tail(param); @@ -729,7 +727,7 @@ ir_reader::read_expression(s_expression *expr) } int num_operands = -3; /* skip "expression" <type> <operation> */ - foreach_list(n, &((s_list *) expr)->subexpressions) + foreach_in_list(s_expression, e, &((s_list *) expr)->subexpressions) ++num_operands; int expected_operands = ir_expression::get_num_operands(op); @@ -804,8 +802,7 @@ ir_reader::read_constant(s_expression *expr) if (type->is_array()) { unsigned elements_supplied = 0; exec_list elements; - foreach_list(n, &values->subexpressions) { - s_expression *elt = (s_expression *) n; + foreach_in_list(s_expression, elt, &values->subexpressions) { ir_constant *ir_elt = read_constant(elt); if (ir_elt == NULL) return NULL; @@ -825,14 +822,12 @@ ir_reader::read_constant(s_expression *expr) // Read in list of values (at most 16). unsigned k = 0; - foreach_list(n, &values->subexpressions) { + foreach_in_list(s_expression, expr, &values->subexpressions) { if (k >= 16) { ir_read_error(values, "expected at most 16 numbers"); return NULL; } - s_expression *expr = (s_expression *) n; - if (type->base_type == GLSL_TYPE_FLOAT) { s_number *value = SX_AS_NUMBER(expr); if (value == NULL) { diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 17a74ea55f5..271dbe0960a 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -172,9 +172,7 @@ ir_validate::visit_enter(ir_function *ir) /* Verify that all of the things stored in the list of signatures are, * in fact, function signatures. */ - foreach_list(node, &ir->signatures) { - ir_instruction *sig = (ir_instruction *) node; - + foreach_in_list(ir_instruction, sig, &ir->signatures) { if (sig->ir_type != ir_type_function_signature) { printf("Non-signature in signature list of function `%s'\n", ir->name); @@ -816,9 +814,7 @@ validate_ir_tree(exec_list *instructions) v.run(instructions); - foreach_list(n, instructions) { - ir_instruction *ir = (ir_instruction *) n; - + foreach_in_list(ir_instruction, ir, instructions) { visit_tree(ir, check_node_type, NULL); } #endif diff --git a/src/glsl/link_atomics.cpp b/src/glsl/link_atomics.cpp index fbe4e7364ae..75699fd9391 100644 --- a/src/glsl/link_atomics.cpp +++ b/src/glsl/link_atomics.cpp @@ -110,8 +110,8 @@ namespace { if (sh == NULL) continue; - foreach_list(node, sh->ir) { - ir_variable *var = ((ir_instruction *)node)->as_variable(); + foreach_in_list(ir_instruction, node, sh->ir) { + ir_variable *var = node->as_variable(); if (var && var->type->contains_atomic()) { unsigned id = 0; diff --git a/src/glsl/link_interface_blocks.cpp b/src/glsl/link_interface_blocks.cpp index 52552cc682a..0ce502d4fdd 100644 --- a/src/glsl/link_interface_blocks.cpp +++ b/src/glsl/link_interface_blocks.cpp @@ -259,8 +259,8 @@ validate_intrastage_interface_blocks(struct gl_shader_program *prog, if (shader_list[i] == NULL) continue; - foreach_list(node, shader_list[i]->ir) { - ir_variable *var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, shader_list[i]->ir) { + ir_variable *var = node->as_variable(); if (!var) continue; @@ -316,8 +316,8 @@ validate_interstage_inout_blocks(struct gl_shader_program *prog, const bool extra_array_level = consumer->Stage == MESA_SHADER_GEOMETRY; /* Add input interfaces from the consumer to the symbol table. */ - foreach_list(node, consumer->ir) { - ir_variable *var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, consumer->ir) { + ir_variable *var = node->as_variable(); if (!var || !var->get_interface_type() || var->data.mode != ir_var_shader_in) continue; @@ -325,8 +325,8 @@ validate_interstage_inout_blocks(struct gl_shader_program *prog, } /* Verify that the producer's output interfaces match. */ - foreach_list(node, producer->ir) { - ir_variable *var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, producer->ir) { + ir_variable *var = node->as_variable(); if (!var || !var->get_interface_type() || var->data.mode != ir_var_shader_out) continue; @@ -359,8 +359,8 @@ validate_interstage_uniform_blocks(struct gl_shader_program *prog, continue; const gl_shader *stage = stages[i]; - foreach_list(node, stage->ir) { - ir_variable *var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, stage->ir) { + ir_variable *var = node->as_variable(); if (!var || !var->get_interface_type() || var->data.mode != ir_var_uniform) continue; diff --git a/src/glsl/link_uniform_initializers.cpp b/src/glsl/link_uniform_initializers.cpp index d755cec98c9..c6fe6a9ad67 100644 --- a/src/glsl/link_uniform_initializers.cpp +++ b/src/glsl/link_uniform_initializers.cpp @@ -242,8 +242,8 @@ link_set_uniform_initializers(struct gl_shader_program *prog) if (shader == NULL) continue; - foreach_list(node, shader->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, shader->ir) { + ir_variable *const var = node->as_variable(); if (!var || var->data.mode != ir_var_uniform) continue; diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp index 66f6d4db3a5..6c731976b74 100644 --- a/src/glsl/link_uniforms.cpp +++ b/src/glsl/link_uniforms.cpp @@ -702,8 +702,8 @@ link_cross_validate_uniform_block(void *mem_ctx, static void link_update_uniform_buffer_variables(struct gl_shader *shader) { - foreach_list(node, shader->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, shader->ir) { + ir_variable *const var = node->as_variable(); if ((var == NULL) || !var->is_in_uniform_block()) continue; @@ -804,8 +804,8 @@ link_set_image_access_qualifiers(struct gl_shader_program *prog) if (sh == NULL) continue; - foreach_list(node, sh->ir) { - ir_variable *var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, sh->ir) { + ir_variable *var = node->as_variable(); if (var && var->data.mode == ir_var_uniform && var->type->contains_image()) { @@ -871,8 +871,8 @@ link_assign_uniform_locations(struct gl_shader_program *prog) */ uniform_size.start_shader(); - foreach_list(node, sh->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, sh->ir) { + ir_variable *const var = node->as_variable(); if ((var == NULL) || (var->data.mode != ir_var_uniform)) continue; @@ -923,8 +923,8 @@ link_assign_uniform_locations(struct gl_shader_program *prog) parcel.start_shader((gl_shader_stage)i); - foreach_list(node, prog->_LinkedShaders[i]->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, prog->_LinkedShaders[i]->ir) { + ir_variable *const var = node->as_variable(); if ((var == NULL) || (var->data.mode != ir_var_uniform)) continue; diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp index 520a51a278e..a3fc2ae3489 100644 --- a/src/glsl/link_varyings.cpp +++ b/src/glsl/link_varyings.cpp @@ -175,8 +175,8 @@ cross_validate_outputs_to_inputs(struct gl_shader_program *prog, /* Find all shader outputs in the "producer" stage. */ - foreach_list(node, producer->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, producer->ir) { + ir_variable *const var = node->as_variable(); if ((var == NULL) || (var->data.mode != ir_var_shader_out)) continue; @@ -212,8 +212,8 @@ cross_validate_outputs_to_inputs(struct gl_shader_program *prog, * should be arrays and the type of the array element should match the type * of the corresponding producer output. */ - foreach_list(node, consumer->ir) { - ir_variable *const input = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, consumer->ir) { + ir_variable *const input = node->as_variable(); if ((input == NULL) || (input->data.mode != ir_var_shader_in)) continue; @@ -1121,8 +1121,8 @@ populate_consumer_input_sets(void *mem_ctx, exec_list *ir, 0, sizeof(consumer_inputs_with_locations[0]) * VARYING_SLOT_MAX); - foreach_list(node, ir) { - ir_variable *const input_var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, ir) { + ir_variable *const input_var = node->as_variable(); if ((input_var != NULL) && (input_var->data.mode == ir_var_shader_in)) { if (input_var->type->is_interface()) @@ -1227,8 +1227,8 @@ canonicalize_shader_io(exec_list *ir, enum ir_variable_mode io_mode) ir_variable *var_table[MAX_PROGRAM_OUTPUTS * 4]; unsigned num_variables = 0; - foreach_list(node, ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, ir) { + ir_variable *const var = node->as_variable(); if (var == NULL || var->data.mode != io_mode) continue; @@ -1339,9 +1339,8 @@ assign_varying_locations(struct gl_context *ctx, } if (producer) { - foreach_list(node, producer->ir) { - ir_variable *const output_var = - ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, producer->ir) { + ir_variable *const output_var = node->as_variable(); if ((output_var == NULL) || (output_var->data.mode != ir_var_shader_out)) @@ -1383,9 +1382,8 @@ assign_varying_locations(struct gl_context *ctx, * geometry) shader program. This means that locations must be assigned * for all the inputs. */ - foreach_list(node, consumer->ir) { - ir_variable *const input_var = - ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, consumer->ir) { + ir_variable *const input_var = node->as_variable(); if ((input_var == NULL) || (input_var->data.mode != ir_var_shader_in)) @@ -1450,8 +1448,8 @@ assign_varying_locations(struct gl_context *ctx, } if (consumer && producer) { - foreach_list(node, consumer->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, consumer->ir) { + ir_variable *const var = node->as_variable(); if (var && var->data.mode == ir_var_shader_in && var->data.is_unmatched_generic_inout) { @@ -1494,8 +1492,8 @@ check_against_output_limit(struct gl_context *ctx, { unsigned output_vectors = 0; - foreach_list(node, producer->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, producer->ir) { + ir_variable *const var = node->as_variable(); if (var && var->data.mode == ir_var_shader_out && var_counts_against_varying_limit(producer->Stage, var)) { @@ -1533,8 +1531,8 @@ check_against_input_limit(struct gl_context *ctx, { unsigned input_vectors = 0; - foreach_list(node, consumer->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, consumer->ir) { + ir_variable *const var = node->as_variable(); if (var && var->data.mode == ir_var_shader_in && var_counts_against_varying_limit(consumer->Stage, var)) { diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 3036ebcb33e..8bb1104961a 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -437,8 +437,8 @@ parse_program_resource_name(const GLchar *name, void link_invalidate_variable_locations(exec_list *ir) { - foreach_list(node, ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, ir) { + ir_variable *const var = node->as_variable(); if (var == NULL) continue; @@ -692,8 +692,8 @@ cross_validate_globals(struct gl_shader_program *prog, if (shader_list[i] == NULL) continue; - foreach_list(node, shader_list[i]->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, shader_list[i]->ir) { + ir_variable *const var = node->as_variable(); if (var == NULL) continue; @@ -962,8 +962,7 @@ populate_symbol_table(gl_shader *sh) { sh->symbols = new(sh) glsl_symbol_table; - foreach_list(node, sh->ir) { - ir_instruction *const inst = (ir_instruction *) node; + foreach_in_list(ir_instruction, inst, sh->ir) { ir_variable *var; ir_function *func; @@ -1603,8 +1602,8 @@ link_intrastage_shaders(void *mem_ctx, * across all shaders. */ for (unsigned i = 0; i < (num_shaders - 1); i++) { - foreach_list(node, shader_list[i]->ir) { - ir_function *const f = ((ir_instruction *) node)->as_function(); + foreach_in_list(ir_instruction, node, shader_list[i]->ir) { + ir_function *const f = node->as_function(); if (f == NULL) continue; @@ -1619,9 +1618,7 @@ link_intrastage_shaders(void *mem_ctx, if (other == NULL) continue; - foreach_list(n, &f->signatures) { - ir_function_signature *sig = (ir_function_signature *) n; - + foreach_in_list(ir_function_signature, sig, &f->signatures) { if (!sig->is_defined || sig->is_builtin()) continue; @@ -1735,8 +1732,7 @@ 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_list(n, linked->ir) { - ir_instruction *ir = (ir_instruction *) n; + foreach_in_list(ir_instruction, ir, linked->ir) { ir->accept(&input_resize_visitor); } } @@ -1774,8 +1770,8 @@ update_array_sizes(struct gl_shader_program *prog) if (prog->_LinkedShaders[i] == NULL) continue; - foreach_list(node, prog->_LinkedShaders[i]->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, prog->_LinkedShaders[i]->ir) { + ir_variable *const var = node->as_variable(); if ((var == NULL) || (var->data.mode != ir_var_uniform) || !var->type->is_array()) @@ -1797,8 +1793,8 @@ update_array_sizes(struct gl_shader_program *prog) if (prog->_LinkedShaders[j] == NULL) continue; - foreach_list(node2, prog->_LinkedShaders[j]->ir) { - ir_variable *other_var = ((ir_instruction *) node2)->as_variable(); + foreach_in_list(ir_instruction, node2, prog->_LinkedShaders[j]->ir) { + ir_variable *other_var = node2->as_variable(); if (!other_var) continue; @@ -1940,8 +1936,8 @@ assign_attribute_or_color_locations(gl_shader_program *prog, unsigned num_attr = 0; - foreach_list(node, sh->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, sh->ir) { + ir_variable *const var = node->as_variable(); if ((var == NULL) || (var->data.mode != (unsigned) direction)) continue; @@ -2159,8 +2155,8 @@ assign_attribute_or_color_locations(gl_shader_program *prog, void demote_shader_inputs_and_outputs(gl_shader *sh, enum ir_variable_mode mode) { - foreach_list(node, sh->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, sh->ir) { + ir_variable *const var = node->as_variable(); if ((var == NULL) || (var->data.mode != int(mode))) continue; @@ -2195,8 +2191,8 @@ store_fragdepth_layout(struct gl_shader_program *prog) * We're only interested in the cases where the variable is NOT removed * from the IR. */ - foreach_list(node, ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, ir) { + ir_variable *const var = node->as_variable(); if (var == NULL || var->data.mode != ir_var_shader_out) { continue; @@ -2327,8 +2323,8 @@ check_image_resources(struct gl_context *ctx, struct gl_shader_program *prog) total_image_units += sh->NumImages; if (i == MESA_SHADER_FRAGMENT) { - foreach_list(node, sh->ir) { - ir_variable *var = ((ir_instruction *)node)->as_variable(); + foreach_in_list(ir_instruction, node, sh->ir) { + ir_variable *var = node->as_variable(); if (var && var->data.mode == ir_var_shader_out) fragment_outputs += var->type->count_attribute_slots(); } @@ -2440,8 +2436,8 @@ check_explicit_uniform_locations(struct gl_context *ctx, if (!sh) continue; - foreach_list(node, sh->ir) { - ir_variable *var = ((ir_instruction *)node)->as_variable(); + foreach_in_list(ir_instruction, node, sh->ir) { + ir_variable *var = node->as_variable(); if ((var && var->data.mode == ir_var_uniform) && var->data.explicit_location) { if (!reserve_explicit_locations(prog, uniform_map, var)) diff --git a/src/glsl/loop_analysis.cpp b/src/glsl/loop_analysis.cpp index 78ac30044ad..0e232e7b514 100644 --- a/src/glsl/loop_analysis.cpp +++ b/src/glsl/loop_analysis.cpp @@ -227,8 +227,7 @@ loop_analysis::visit_enter(ir_call *) /* Mark every loop that we're currently analyzing as containing an ir_call * (even those at outer nesting levels). */ - foreach_list(node, &this->state) { - loop_variable_state *const ls = (loop_variable_state *) node; + foreach_in_list(loop_variable_state, ls, &this->state) { ls->contains_calls = true; } @@ -246,9 +245,7 @@ loop_analysis::visit(ir_dereference_variable *ir) bool nested = false; - foreach_list(node, &this->state) { - loop_variable_state *const ls = (loop_variable_state *) node; - + foreach_in_list(loop_variable_state, ls, &this->state) { ir_variable *var = ir->variable_referenced(); loop_variable *lv = ls->get_or_insert(var, this->in_assignee); @@ -288,10 +285,10 @@ loop_analysis::visit_leave(ir_loop *ir) if (ls->contains_calls) return visit_continue; - foreach_list(node, &ir->body_instructions) { + foreach_in_list(ir_instruction, node, &ir->body_instructions) { /* Skip over declarations at the start of a loop. */ - if (((ir_instruction *) node)->as_variable()) + if (node->as_variable()) continue; ir_if *if_stmt = ((ir_instruction *) node)->as_if(); @@ -402,8 +399,7 @@ loop_analysis::visit_leave(ir_loop *ir) * Also figure out which terminator (if any) produces the smallest * iteration count--this is the limiting terminator. */ - foreach_list(node, &ls->terminators) { - loop_terminator *t = (loop_terminator *) node; + foreach_in_list(loop_terminator, t, &ls->terminators) { ir_if *if_stmt = t->ir; /* If-statements can be either 'if (expr)' or 'if (deref)'. We only care diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp index 3db06ad18c1..36b49eb462e 100644 --- a/src/glsl/loop_controls.cpp +++ b/src/glsl/loop_controls.cpp @@ -202,9 +202,7 @@ loop_control_visitor::visit_leave(ir_loop *ir) * bound, then that terminates the loop, so we don't even need the limiting * terminator. */ - foreach_list(node, &ls->terminators) { - loop_terminator *t = (loop_terminator *) node; - + foreach_in_list(loop_terminator, t, &ls->terminators) { if (t->iterations < 0) continue; diff --git a/src/glsl/loop_unroll.cpp b/src/glsl/loop_unroll.cpp index da532804a4a..ce795f6cd24 100644 --- a/src/glsl/loop_unroll.cpp +++ b/src/glsl/loop_unroll.cpp @@ -347,10 +347,8 @@ loop_unroll_visitor::visit_leave(ir_loop *ir) return visit_continue; } - foreach_list(node, &ir->body_instructions) { - /* recognize loops in the form produced by ir_lower_jumps */ - ir_instruction *cur_ir = (ir_instruction *) node; - + /* recognize loops in the form produced by ir_lower_jumps */ + foreach_in_list(ir_instruction, cur_ir, &ir->body_instructions) { /* Skip the limiting terminator, since it will go away when we * unroll. */ diff --git a/src/glsl/lower_discard.cpp b/src/glsl/lower_discard.cpp index f2757d12048..b44d2a6d28d 100644 --- a/src/glsl/lower_discard.cpp +++ b/src/glsl/lower_discard.cpp @@ -138,8 +138,8 @@ lower_discard(exec_list *instructions) static ir_discard * find_discard(exec_list &instructions) { - foreach_list(n, &instructions) { - ir_discard *ir = ((ir_instruction *) n)->as_discard(); + foreach_in_list(ir_instruction, node, &instructions) { + ir_discard *ir = node->as_discard(); if (ir != NULL) return ir; } diff --git a/src/glsl/lower_if_to_cond_assign.cpp b/src/glsl/lower_if_to_cond_assign.cpp index f15b217e09d..89b4a4a297c 100644 --- a/src/glsl/lower_if_to_cond_assign.cpp +++ b/src/glsl/lower_if_to_cond_assign.cpp @@ -178,12 +178,10 @@ 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_list(n, &ir->then_instructions) { - ir_instruction *then_ir = (ir_instruction *) n; + foreach_in_list(ir_instruction, then_ir, &ir->then_instructions) { visit_tree(then_ir, check_control_flow, &found_control_flow); } - foreach_list(n, &ir->else_instructions) { - ir_instruction *else_ir = (ir_instruction *) n; + foreach_in_list(ir_instruction, else_ir, &ir->else_instructions) { visit_tree(else_ir, check_control_flow, &found_control_flow); } if (found_control_flow) diff --git a/src/glsl/lower_jumps.cpp b/src/glsl/lower_jumps.cpp index 02f65f097cc..ec7a0c537ff 100644 --- a/src/glsl/lower_jumps.cpp +++ b/src/glsl/lower_jumps.cpp @@ -500,16 +500,16 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor { /* Note: since visiting a node may change that node's next * pointer, we can't use visit_exec_list(), because * visit_exec_list() caches the node's next pointer before - * visiting it. So we use foreach_list() instead. + * visiting it. So we use foreach_in_list() instead. * - * foreach_list() isn't safe if the node being visited gets + * foreach_in_list() isn't safe if the node being visited gets * removed, but fortunately this visitor doesn't do that. */ block_record saved_block = this->block; this->block = block_record(); - foreach_list(node, list) { - ((ir_instruction *) node)->accept(this); + foreach_in_list(ir_instruction, node, list) { + node->accept(this); } block_record ret = this->block; this->block = saved_block; diff --git a/src/glsl/lower_packed_varyings.cpp b/src/glsl/lower_packed_varyings.cpp index eda56a97b14..c72b80a32fd 100644 --- a/src/glsl/lower_packed_varyings.cpp +++ b/src/glsl/lower_packed_varyings.cpp @@ -242,8 +242,8 @@ lower_packed_varyings_visitor::lower_packed_varyings_visitor( void lower_packed_varyings_visitor::run(exec_list *instructions) { - foreach_list (node, instructions) { - ir_variable *var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, instructions) { + ir_variable *var = node->as_variable(); if (var == NULL) continue; @@ -639,8 +639,7 @@ lower_packed_varyings_gs_splicer::lower_packed_varyings_gs_splicer( ir_visitor_status lower_packed_varyings_gs_splicer::visit_leave(ir_emit_vertex *ev) { - foreach_list(node, this->instructions) { - ir_instruction *ir = (ir_instruction *) node; + foreach_in_list(ir_instruction, ir, this->instructions) { ev->insert_before(ir->clone(this->mem_ctx, NULL)); } return visit_continue; diff --git a/src/glsl/opt_array_splitting.cpp b/src/glsl/opt_array_splitting.cpp index 97d3a57e994..7d29fbcddae 100644 --- a/src/glsl/opt_array_splitting.cpp +++ b/src/glsl/opt_array_splitting.cpp @@ -135,8 +135,7 @@ ir_array_reference_visitor::get_variable_entry(ir_variable *var) if (var->type->is_unsized_array()) return NULL; - foreach_list(n, &this->variable_list) { - variable_entry *entry = (variable_entry *) n; + foreach_in_list(variable_entry, entry, &this->variable_list) { if (entry->var == var) return entry; } @@ -213,8 +212,8 @@ ir_array_reference_visitor::get_split_list(exec_list *instructions, * declarations, which need to be matched by name across shaders. */ if (!linked) { - foreach_list(node, instructions) { - ir_variable *var = ((ir_instruction *)node)->as_variable(); + foreach_in_list(ir_instruction, node, instructions) { + ir_variable *var = node->as_variable(); if (var) { variable_entry *entry = get_variable_entry(var); if (entry) @@ -270,8 +269,7 @@ ir_array_splitting_visitor::get_splitting_entry(ir_variable *var) { assert(var); - foreach_list(n, this->variable_list) { - variable_entry *entry = (variable_entry *) n; + foreach_in_list(variable_entry, entry, this->variable_list) { if (entry->var == var) { return entry; } @@ -368,8 +366,7 @@ optimize_split_arrays(exec_list *instructions, bool linked) /* Replace the decls of the arrays to be split with their split * components. */ - foreach_list(n, &refs.variable_list) { - variable_entry *entry = (variable_entry *) n; + foreach_in_list(variable_entry, entry, &refs.variable_list) { const struct glsl_type *type = entry->var->type; const struct glsl_type *subtype; diff --git a/src/glsl/opt_constant_propagation.cpp b/src/glsl/opt_constant_propagation.cpp index 18f5da68907..42bdad4eb0b 100644 --- a/src/glsl/opt_constant_propagation.cpp +++ b/src/glsl/opt_constant_propagation.cpp @@ -172,8 +172,7 @@ ir_constant_propagation_visitor::handle_rvalue(ir_rvalue **rvalue) channel = i; } - foreach_list(n, this->acp) { - acp_entry *entry = (acp_entry *) n; + foreach_in_list(acp_entry, entry, this->acp) { if (entry->var == deref->var && entry->write_mask & (1 << channel)) { found = entry; break; @@ -317,8 +316,7 @@ 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_list(n, orig_acp) { - acp_entry *a = (acp_entry *) n; + foreach_in_list(acp_entry, a, orig_acp) { this->acp->push_tail(new(this->mem_ctx) acp_entry(a)); } @@ -333,8 +331,7 @@ ir_constant_propagation_visitor::handle_if_block(exec_list *instructions) this->acp = orig_acp; this->killed_all = this->killed_all || orig_killed_all; - foreach_list(n, new_kills) { - kill_entry *k = (kill_entry *) n; + foreach_in_list(kill_entry, k, new_kills) { kill(k->var, k->write_mask); } } @@ -378,8 +375,7 @@ ir_constant_propagation_visitor::visit_enter(ir_loop *ir) this->acp = orig_acp; this->killed_all = this->killed_all || orig_killed_all; - foreach_list(n, new_kills) { - kill_entry *k = (kill_entry *) n; + foreach_in_list(kill_entry, k, new_kills) { kill(k->var, k->write_mask); } @@ -410,9 +406,7 @@ 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_list(n, this->kills) { - kill_entry *entry = (kill_entry *) n; - + foreach_in_list(kill_entry, entry, this->kills) { if (entry->var == var) { entry->write_mask |= write_mask; return; diff --git a/src/glsl/opt_constant_variable.cpp b/src/glsl/opt_constant_variable.cpp index 961b8aa0660..7222eb92a7d 100644 --- a/src/glsl/opt_constant_variable.cpp +++ b/src/glsl/opt_constant_variable.cpp @@ -193,12 +193,10 @@ do_constant_variable_unlinked(exec_list *instructions) { bool progress = false; - foreach_list(n, instructions) { - ir_instruction *ir = (ir_instruction *) n; + foreach_in_list(ir_instruction, ir, instructions) { ir_function *f = ir->as_function(); if (f) { - foreach_list(signode, &f->signatures) { - ir_function_signature *sig = (ir_function_signature *) signode; + foreach_in_list(ir_function_signature, sig, &f->signatures) { if (do_constant_variable(&sig->body)) progress = true; } diff --git a/src/glsl/opt_copy_propagation.cpp b/src/glsl/opt_copy_propagation.cpp index 195cc8baae6..c78cf0cdc08 100644 --- a/src/glsl/opt_copy_propagation.cpp +++ b/src/glsl/opt_copy_propagation.cpp @@ -167,9 +167,7 @@ ir_copy_propagation_visitor::visit(ir_dereference_variable *ir) ir_variable *var = ir->var; - foreach_list(n, this->acp) { - acp_entry *entry = (acp_entry *) n; - + foreach_in_list(acp_entry, entry, this->acp) { if (var == entry->lhs) { ir->var = entry->rhs; this->progress = true; @@ -216,8 +214,7 @@ 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_list(n, orig_acp) { - acp_entry *a = (acp_entry *) n; + foreach_in_list(acp_entry, a, orig_acp) { this->acp->push_tail(new(this->mem_ctx) acp_entry(a->lhs, a->rhs)); } @@ -232,8 +229,7 @@ ir_copy_propagation_visitor::handle_if_block(exec_list *instructions) this->acp = orig_acp; this->killed_all = this->killed_all || orig_killed_all; - foreach_list(n, new_kills) { - kill_entry *k = (kill_entry *) n; + foreach_in_list(kill_entry, k, new_kills) { kill(k->var); } } @@ -276,8 +272,7 @@ ir_copy_propagation_visitor::visit_enter(ir_loop *ir) this->acp = orig_acp; this->killed_all = this->killed_all || orig_killed_all; - foreach_list(n, new_kills) { - kill_entry *k = (kill_entry *) n; + foreach_in_list(kill_entry, k, new_kills) { kill(k->var); } diff --git a/src/glsl/opt_copy_propagation_elements.cpp b/src/glsl/opt_copy_propagation_elements.cpp index 4d8f476a89c..bcd79187a4d 100644 --- a/src/glsl/opt_copy_propagation_elements.cpp +++ b/src/glsl/opt_copy_propagation_elements.cpp @@ -244,9 +244,7 @@ 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_list(n, this->acp) { - acp_entry *entry = (acp_entry *) n; - + foreach_in_list(acp_entry, entry, this->acp) { if (var == entry->lhs) { for (int c = 0; c < chans; c++) { if (entry->write_mask & (1 << swizzle_chan[c])) { @@ -324,8 +322,7 @@ 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_list(n, orig_acp) { - acp_entry *a = (acp_entry *) n; + foreach_in_list(acp_entry, a, orig_acp) { this->acp->push_tail(new(this->mem_ctx) acp_entry(a)); } diff --git a/src/glsl/opt_cse.cpp b/src/glsl/opt_cse.cpp index 1b8782bcb2b..0e720cc2686 100644 --- a/src/glsl/opt_cse.cpp +++ b/src/glsl/opt_cse.cpp @@ -173,9 +173,7 @@ dump_ae(exec_list *ae) int i = 0; printf("CSE: AE contents:\n"); - foreach_list(node, ae) { - ae_entry *entry = (ae_entry *)node; - + foreach_in_list(ae_entry, entry, ae) { printf("CSE: AE %2d (%p): ", i, entry); (*entry->val)->print(); printf("\n"); @@ -254,9 +252,7 @@ is_cse_candidate(ir_rvalue *ir) ir_rvalue * cse_visitor::try_cse(ir_rvalue *rvalue) { - foreach_list(node, ae) { - ae_entry *entry = (ae_entry *)node; - + foreach_in_list(ae_entry, entry, ae) { if (debug) { printf("Comparing to AE %p: ", entry); (*entry->val)->print(); @@ -303,8 +299,7 @@ cse_visitor::try_cse(ir_rvalue *rvalue) * updated so that any further elimination from inside gets its new * assignments put before our new assignment. */ - foreach_list(fixup_node, ae) { - ae_entry *fixup_entry = (ae_entry *)fixup_node; + foreach_in_list(ae_entry, fixup_entry, ae) { if (contains_rvalue(assignment->rhs, *fixup_entry->val)) fixup_entry->base_ir = assignment; } diff --git a/src/glsl/opt_dead_code.cpp b/src/glsl/opt_dead_code.cpp index af53d94fdea..da90bfb4045 100644 --- a/src/glsl/opt_dead_code.cpp +++ b/src/glsl/opt_dead_code.cpp @@ -129,12 +129,10 @@ do_dead_code_unlinked(exec_list *instructions) { bool progress = false; - foreach_list(n, instructions) { - ir_instruction *ir = (ir_instruction *) n; + foreach_in_list(ir_instruction, ir, instructions) { ir_function *f = ir->as_function(); if (f) { - foreach_list(signode, &f->signatures) { - ir_function_signature *sig = (ir_function_signature *) signode; + foreach_in_list(ir_function_signature, sig, &f->signatures) { /* 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/src/glsl/opt_dead_code_local.cpp b/src/glsl/opt_dead_code_local.cpp index 88895fb0e87..d9bc5ed7c1b 100644 --- a/src/glsl/opt_dead_code_local.cpp +++ b/src/glsl/opt_dead_code_local.cpp @@ -280,9 +280,7 @@ process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments) printf("add %s\n", var->name); printf("current entries\n"); - foreach_list(n, assignments) { - assignment_entry *entry = (assignment_entry *) n; - + foreach_in_list(assignment_entry, entry, assignments) { printf(" %s (0x%01x)\n", entry->lhs->name, entry->unused); } } diff --git a/src/glsl/opt_dead_functions.cpp b/src/glsl/opt_dead_functions.cpp index 8bb278e4537..81c46d58217 100644 --- a/src/glsl/opt_dead_functions.cpp +++ b/src/glsl/opt_dead_functions.cpp @@ -74,8 +74,7 @@ public: signature_entry * ir_dead_functions_visitor::get_signature_entry(ir_function_signature *sig) { - foreach_list(n, &this->signature_list) { - signature_entry *entry = (signature_entry *) n; + foreach_in_list(signature_entry, entry, &this->signature_list) { if (entry->signature == sig) return entry; } diff --git a/src/glsl/opt_flip_matrices.cpp b/src/glsl/opt_flip_matrices.cpp index 9044fd68066..04c6170b845 100644 --- a/src/glsl/opt_flip_matrices.cpp +++ b/src/glsl/opt_flip_matrices.cpp @@ -45,8 +45,7 @@ public: mvp_transpose = NULL; texmat_transpose = NULL; - foreach_list(n, instructions) { - ir_instruction *ir = (ir_instruction *) n; + foreach_in_list(ir_instruction, ir, instructions) { ir_variable *var = ir->as_variable(); if (!var) continue; diff --git a/src/glsl/opt_function_inlining.cpp b/src/glsl/opt_function_inlining.cpp index 9649598dd2b..7212123a741 100644 --- a/src/glsl/opt_function_inlining.cpp +++ b/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_list(n, &this->callee->parameters) + foreach_in_list(ir_rvalue, param, &this->callee->parameters) num_parameters++; parameters = new ir_variable *[num_parameters]; @@ -159,8 +159,7 @@ ir_call::generate_inline(ir_instruction *next_ir) exec_list new_instructions; /* Generate the inlined body of the function to a new list */ - foreach_list(n, &callee->body) { - ir_instruction *ir = (ir_instruction *) n; + foreach_in_list(ir_instruction, ir, &callee->body) { ir_instruction *new_ir = ir->clone(ctx, ht); new_instructions.push_tail(new_ir); diff --git a/src/glsl/opt_structure_splitting.cpp b/src/glsl/opt_structure_splitting.cpp index 1ec537b132b..2abd7e42f99 100644 --- a/src/glsl/opt_structure_splitting.cpp +++ b/src/glsl/opt_structure_splitting.cpp @@ -107,8 +107,7 @@ 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_list(n, &this->variable_list) { - variable_entry *entry = (variable_entry *) n; + foreach_in_list(variable_entry, entry, &this->variable_list) { if (entry->var == var) return entry; } @@ -209,8 +208,7 @@ ir_structure_splitting_visitor::get_splitting_entry(ir_variable *var) if (!var->type->is_record()) return NULL; - foreach_list(n, this->variable_list) { - variable_entry *entry = (variable_entry *) n; + foreach_in_list(variable_entry, entry, this->variable_list) { if (entry->var == var) { return entry; } diff --git a/src/glsl/s_expression.cpp b/src/glsl/s_expression.cpp index 6906ff0eb67..1a28e1d5248 100644 --- a/src/glsl/s_expression.cpp +++ b/src/glsl/s_expression.cpp @@ -162,8 +162,7 @@ void s_symbol::print() void s_list::print() { printf("("); - foreach_list(n, &this->subexpressions) { - s_expression *expr = (s_expression *) n; + foreach_in_list(s_expression, expr, &this->subexpressions) { expr->print(); if (!expr->next->is_tail_sentinel()) printf(" "); @@ -201,11 +200,10 @@ s_match(s_expression *top, unsigned n, s_pattern *pattern, bool partial) return false; unsigned i = 0; - foreach_list(node, &list->subexpressions) { + foreach_in_list(s_expression, expr, &list->subexpressions) { if (i >= n) return partial; /* More actual items than the pattern expected */ - s_expression *expr = (s_expression *) node; if (expr == NULL || !pattern[i].match(expr)) return false; diff --git a/src/glsl/tests/builtin_variable_test.cpp b/src/glsl/tests/builtin_variable_test.cpp index 3fdfce57d4f..5076f8c54f4 100644 --- a/src/glsl/tests/builtin_variable_test.cpp +++ b/src/glsl/tests/builtin_variable_test.cpp @@ -98,8 +98,8 @@ common_builtin::string_starts_with_prefix(const char *str, const char *prefix) void common_builtin::names_start_with_gl() { - foreach_list(node, &this->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, &this->ir) { + ir_variable *const var = node->as_variable(); string_starts_with_prefix(var->name, "gl_"); } @@ -108,8 +108,8 @@ common_builtin::names_start_with_gl() void common_builtin::uniforms_and_system_values_dont_have_explicit_location() { - foreach_list(node, &this->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, &this->ir) { + ir_variable *const var = node->as_variable(); if (var->data.mode != ir_var_uniform && var->data.mode != ir_var_system_value) continue; @@ -122,8 +122,8 @@ common_builtin::uniforms_and_system_values_dont_have_explicit_location() void common_builtin::constants_are_constant() { - foreach_list(node, &this->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, &this->ir) { + ir_variable *const var = node->as_variable(); if (var->data.mode != ir_var_auto) continue; @@ -137,8 +137,8 @@ common_builtin::constants_are_constant() void common_builtin::no_invalid_variable_modes() { - foreach_list(node, &this->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, &this->ir) { + ir_variable *const var = node->as_variable(); switch (var->data.mode) { case ir_var_auto: @@ -174,8 +174,8 @@ TEST_F(vertex_builtin, names_start_with_gl) TEST_F(vertex_builtin, inputs_have_explicit_location) { - foreach_list(node, &this->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, &this->ir) { + ir_variable *const var = node->as_variable(); if (var->data.mode != ir_var_shader_in) continue; @@ -189,8 +189,8 @@ TEST_F(vertex_builtin, inputs_have_explicit_location) TEST_F(vertex_builtin, outputs_have_explicit_location) { - foreach_list(node, &this->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, &this->ir) { + ir_variable *const var = node->as_variable(); if (var->data.mode != ir_var_shader_out) continue; @@ -242,8 +242,8 @@ TEST_F(fragment_builtin, names_start_with_gl) TEST_F(fragment_builtin, inputs_have_explicit_location) { - foreach_list(node, &this->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, &this->ir) { + ir_variable *const var = node->as_variable(); if (var->data.mode != ir_var_shader_in) continue; @@ -262,8 +262,8 @@ TEST_F(fragment_builtin, inputs_have_explicit_location) TEST_F(fragment_builtin, outputs_have_explicit_location) { - foreach_list(node, &this->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, &this->ir) { + ir_variable *const var = node->as_variable(); if (var->data.mode != ir_var_shader_out) continue; @@ -313,8 +313,8 @@ TEST_F(geometry_builtin, names_start_with_gl) TEST_F(geometry_builtin, inputs_have_explicit_location) { - foreach_list(node, &this->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, &this->ir) { + ir_variable *const var = node->as_variable(); if (var->data.mode != ir_var_shader_in) continue; @@ -359,8 +359,8 @@ TEST_F(geometry_builtin, inputs_have_explicit_location) TEST_F(geometry_builtin, outputs_have_explicit_location) { - foreach_list(node, &this->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); + foreach_in_list(ir_instruction, node, &this->ir) { + ir_variable *const var = node->as_variable(); if (var->data.mode != ir_var_shader_out) continue; |