bool all_parameters_are_constant = true;
/* Type cast each parameter and, if possible, fold constants. */
- foreach_list_safe(n, &actual_parameters) {
- ir_rvalue *ir = (ir_rvalue *) n;
+ foreach_in_list_safe(ir_rvalue, ir, &actual_parameters) {
ir_rvalue *result = ir;
/* Apply implicit conversions (not the scalar constructor rules!). See
bool all_parameters_are_constant = true;
/* Type cast each parameter and, if possible, fold constants. */
- foreach_list_safe(n, &actual_parameters) {
- ir_rvalue *ir = (ir_rvalue *) n;
+ foreach_in_list_safe(ir_rvalue, ir, &actual_parameters) {
ir_rvalue *result = ir;
/* Apply implicit conversions (not the scalar constructor rules!). See
* need to break them up into a series of column vectors.
*/
if (constructor_type->base_type != GLSL_TYPE_FLOAT) {
- foreach_list_safe(n, &actual_parameters) {
- ir_rvalue *matrix = (ir_rvalue *) n;
-
+ foreach_in_list_safe(ir_rvalue, matrix, &actual_parameters) {
if (!matrix->type->is_matrix())
continue;
bool all_parameters_are_constant = true;
/* Type cast each parameter and, if possible, fold constants.*/
- foreach_list_safe(n, &actual_parameters) {
- ir_rvalue *ir = (ir_rvalue *) n;
-
+ foreach_in_list_safe(ir_rvalue, ir, &actual_parameters) {
const glsl_type *desired_type =
glsl_type::get_instance(constructor_type->base_type,
ir->type->vector_elements,
* applications depend on this behavior, and it matches what nearly all
* other drivers do.
*/
- foreach_list_safe(node, instructions) {
- ir_variable *const var = ((ir_instruction *) node)->as_variable();
+ foreach_in_list_safe(ir_instruction, node, instructions) {
+ ir_variable *const var = node->as_variable();
if (var == NULL)
continue;
* thinking there are conflicting definitions of gl_PerVertex in the
* shader.
*/
- foreach_list_safe(node, instructions) {
- ir_variable *const var = ((ir_instruction *) node)->as_variable();
+ foreach_in_list_safe(ir_instruction, node, instructions) {
+ ir_variable *const var = node->as_variable();
if (var != NULL &&
var->get_interface_type() == earlier_per_vertex &&
var->data.mode == var_mode) {
/* Remove any ir_variable declarations that refer to the interface block
* we're removing.
*/
- foreach_list_safe(node, instructions) {
- ir_variable *const var = ((ir_instruction *) node)->as_variable();
+ foreach_in_list_safe(ir_instruction, node, instructions) {
+ ir_variable *const var = node->as_variable();
if (var != NULL && var->get_interface_type() == per_vertex &&
var->data.mode == mode) {
state->symbols->disable_variable(var->name);
void
visit_exec_list(exec_list *list, ir_visitor *visitor)
{
- foreach_list_safe(n, list) {
- ((ir_instruction *) n)->accept(visitor);
+ foreach_in_list_safe(ir_instruction, node, list) {
+ node->accept(visitor);
}
}
static void
destroy_links(exec_list *list, function *f)
{
- foreach_list_safe(node, list) {
- struct call_node *n = (struct call_node *) node;
-
+ foreach_in_list_safe(call_node, node, list) {
/* If this is the right function, remove it. Note that the loop cannot
* terminate now. There can be multiple links to a function if it is
* either called multiple times or calls multiple times.
*/
- if (n->func == f)
- n->remove();
+ if (node->func == f)
+ node->remove();
}
}
{
ir_instruction *prev_base_ir = v->base_ir;
- foreach_list_safe(n, l) {
- ir_instruction *const ir = (ir_instruction *) n;
+ foreach_in_list_safe(ir_instruction, ir, l) {
if (statement_list)
v->base_ir = ir;
ir_visitor_status s = ir->accept(v);
ir_visitor_status
ir_rvalue_base_visitor::rvalue_visit(ir_call *ir)
{
- foreach_list_safe(n, &ir->actual_parameters) {
- ir_rvalue *param = (ir_rvalue *) n;
+ foreach_in_list_safe(ir_rvalue, param, &ir->actual_parameters) {
ir_rvalue *new_param = param;
handle_rvalue(&new_param);
temps = hash_table_ctor(0, hash_table_pointer_hash,
hash_table_pointer_compare);
- foreach_list_safe(node, instructions) {
- ir_instruction *inst = (ir_instruction *) node;
-
+ foreach_in_list_safe(ir_instruction, inst, instructions) {
if (inst->as_function())
continue;
}
- foreach_list_safe(node, &ls->variables) {
- loop_variable *lv = (loop_variable *) node;
-
+ foreach_in_list_safe(loop_variable, lv, &ls->variables) {
/* Move variables that are already marked as being loop constant to
* a separate list. These trivially don't need to be tested.
*/
do {
progress = false;
- foreach_list_safe(node, &ls->variables) {
- loop_variable *lv = (loop_variable *) node;
-
+ foreach_in_list_safe(loop_variable, lv, &ls->variables) {
if (lv->conditional_or_nested_assignment || (lv->num_assignments > 1))
continue;
/* The remaining variables that are not loop invariant might be loop
* induction variables.
*/
- foreach_list_safe(node, &ls->variables) {
- loop_variable *lv = (loop_variable *) node;
-
+ foreach_in_list_safe(loop_variable, lv, &ls->variables) {
/* If there is more than one assignment to a variable, it cannot be a
* loop induction variable. This isn't strictly true, but this is a
* very simple induction variable detector, and it can't handle more
exec_list *instructions,
struct hash_table *ht)
{
- foreach_list_safe(node, instructions) {
- ir_instruction *ir = (ir_instruction *) node;
-
+ foreach_in_list_safe(ir_instruction, ir, instructions) {
if (ir->ir_type == ir_type_assignment) {
ir_assignment *assign = (ir_assignment *)ir;
* The interface block variables are stored in the interface_namespace
* hash table so they can be used in the second pass.
*/
- foreach_list_safe(node, instructions) {
- ir_variable *var = ((ir_instruction *) node)->as_variable();
+ foreach_in_list_safe(ir_instruction, node, instructions) {
+ ir_variable *var = node->as_variable();
if (!var || !var->is_interface_instance())
continue;
ir_visitor_status
ir_vec_index_to_cond_assign_visitor::visit_enter(ir_call *ir)
{
- foreach_list_safe(n, &ir->actual_parameters) {
- ir_rvalue *param = (ir_rvalue *) n;
+ foreach_in_list_safe(ir_rvalue, param, &ir->actual_parameters) {
ir_rvalue *new_param = convert_vector_extract_to_cond_assign(param);
if (new_param != param) {
ir_visitor_status
ir_vec_index_to_swizzle_visitor::visit_enter(ir_call *ir)
{
- foreach_list_safe(n, &ir->actual_parameters) {
- ir_rvalue *param = (ir_rvalue *) n;
+ foreach_in_list_safe(ir_rvalue, param, &ir->actual_parameters) {
ir_rvalue *new_param = convert_vector_extract_to_swizzle(param);
if (new_param != param) {
}
/* Trim out variables we found that we can't split. */
- foreach_list_safe(n, &variable_list) {
- variable_entry *entry = (variable_entry *) n;
-
+ foreach_in_list_safe(variable_entry, entry, &variable_list) {
if (debug) {
printf("array %s@%p: decl %d, split %d\n",
entry->var->name, (void *) entry->var, entry->declaration,
return;
/* Remove any entries currently in the ACP for this kill. */
- foreach_list_safe(n, this->acp) {
- acp_entry *entry = (acp_entry *) n;
-
+ foreach_in_list_safe(acp_entry, entry, this->acp) {
if (entry->var == var) {
entry->write_mask &= ~write_mask;
if (entry->write_mask == 0)
assert(var != NULL);
/* Remove any entries currently in the ACP for this kill. */
- foreach_list_safe(n, acp) {
- acp_entry *entry = (acp_entry *) n;
-
+ foreach_in_list_safe(acp_entry, entry, acp) {
if (entry->lhs == var || entry->rhs == var) {
entry->remove();
}
/* Move the new kills into the parent block's list, removing them
* from the parent's ACP list in the process.
*/
- foreach_list_safe(node, new_kills) {
- kill_entry *k = (kill_entry *)node;
+ foreach_in_list_safe(kill_entry, k, new_kills) {
kill(k);
}
}
this->acp = orig_acp;
this->killed_all = this->killed_all || orig_killed_all;
- foreach_list_safe(node, new_kills) {
- kill_entry *k = (kill_entry *)node;
+ foreach_in_list_safe(kill_entry, k, new_kills) {
kill(k);
}
void
ir_copy_propagation_elements_visitor::kill(kill_entry *k)
{
- foreach_list_safe(node, acp) {
- acp_entry *entry = (acp_entry *)node;
-
+ foreach_in_list_safe(acp_entry, entry, acp) {
if (entry->lhs == k->var) {
entry->write_mask = entry->write_mask & ~k->write_mask;
if (entry->write_mask == 0) {
void use_channels(ir_variable *const var, int used)
{
- foreach_list_safe(n, this->assignments) {
- assignment_entry *entry = (assignment_entry *) n;
-
+ foreach_in_list_safe(assignment_entry, entry, this->assignments) {
if (entry->lhs == var) {
if (var->type->is_scalar() || var->type->is_vector()) {
if (debug)
/* For the purpose of dead code elimination, emitting a vertex counts as
* "reading" all of the currently assigned output variables.
*/
- foreach_list_safe(n, this->assignments) {
- assignment_entry *entry = (assignment_entry *) n;
+ foreach_in_list_safe(assignment_entry, entry, this->assignments) {
if (entry->lhs->data.mode == ir_var_shader_out) {
if (debug)
printf("kill %s\n", entry->lhs->name);
printf("looking for %s.0x%01x to remove\n", var->name,
ir->write_mask);
- foreach_list_safe(n, assignments) {
- assignment_entry *entry = (assignment_entry *) n;
-
+ foreach_in_list_safe(assignment_entry, entry, assignments) {
if (entry->lhs != var)
continue;
*/
if (debug)
printf("looking for %s to remove\n", var->name);
- foreach_list_safe(n, assignments) {
- assignment_entry *entry = (assignment_entry *) n;
-
+ foreach_in_list_safe(assignment_entry, entry, assignments) {
if (entry->lhs == var) {
if (debug)
printf("removing %s\n", var->name);
* the unused ones, and remove function definitions that have no more
* signatures.
*/
- foreach_list_safe(n, &v.signature_list) {
- signature_entry *entry = (signature_entry *) n;
-
+ foreach_in_list_safe(signature_entry, entry, &v.signature_list) {
if (!entry->used) {
entry->signature->remove();
delete entry->signature;
/* We don't just do this above when we nuked a signature because of
* const pointers.
*/
- foreach_list_safe(n, instructions) {
- ir_instruction *ir = (ir_instruction *) n;
+ foreach_in_list_safe(ir_instruction, ir, instructions) {
ir_function *func = ir->as_function();
if (func && func->signatures.is_empty()) {
ir_visitor_status
ir_variable_replacement_visitor::visit_leave(ir_call *ir)
{
- foreach_list_safe(n, &ir->actual_parameters) {
- ir_rvalue *param = (ir_rvalue *) n;
+ foreach_in_list_safe(ir_rvalue, param, &ir->actual_parameters) {
ir_rvalue *new_param = param;
replace_rvalue(&new_param);
visit_list_elements(&refs, instructions);
/* Trim out variables we can't split. */
- foreach_list_safe(n, &refs.variable_list) {
- variable_entry *entry = (variable_entry *) n;
-
+ foreach_in_list_safe(variable_entry, entry, &refs.variable_list) {
if (debug) {
printf("structure %s@%p: decl %d, whole_access %d\n",
entry->var->name, (void *) entry->var, entry->declaration,
/* Replace the decls of the structures to be split with their split
* components.
*/
- foreach_list_safe(n, &refs.variable_list) {
- variable_entry *entry = (variable_entry *) n;
+ foreach_in_list_safe(variable_entry, entry, &refs.variable_list) {
const struct glsl_type *type = entry->var->type;
entry->mem_ctx = ralloc_parent(entry->var);