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 = ", ";
}
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);
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;
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));
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));
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);
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!
}
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!
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;
* 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.
/* 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;
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;
{
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));
}
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;
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;
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;
}
*/
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()) {
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);
}
}
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;
* 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);
}
}
{
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));
}
{
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));
}
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));
}
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) */
*/
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;
{
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);
}
}
* 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;
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;
}
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");
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");
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");
{
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");
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");
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");
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");
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");
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
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);
}
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);
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;
// 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) {
/* 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);
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
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;
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;
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;
}
/* 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;
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;
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;
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;
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()) {
*/
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;
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;
/* 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;
* 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;
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())
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;
}
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))
* 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))
}
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) {
{
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)) {
{
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)) {
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;
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;
{
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;
* 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;
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;
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);
}
}
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())
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;
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;
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;
* 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;
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();
}
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))
/* 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;
}
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);
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();
* 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
* 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;
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.
*/
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;
}
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)
/* 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;
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;
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;
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;
}
* 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)
{
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;
}
/* 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;
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;
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));
}
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);
}
}
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);
}
/* 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;
{
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;
}
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;
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));
}
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);
}
}
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);
}
/* 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])) {
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));
}
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");
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();
* 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;
}
{
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
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);
}
}
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;
}
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;
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];
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);
|| 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;
}
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;
}
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(" ");
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;
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_");
}
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;
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;
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:
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;
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;
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;
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;
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;
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;