glsl: Convert piles of foreach_iter to foreach_list_safe.
In these cases, we edit the list (or at least might be), so we use the foreach_list_safe variant. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
@@ -1717,8 +1717,8 @@ ir_rvalue::error_value(void *mem_ctx)
|
|||||||
void
|
void
|
||||||
visit_exec_list(exec_list *list, ir_visitor *visitor)
|
visit_exec_list(exec_list *list, ir_visitor *visitor)
|
||||||
{
|
{
|
||||||
foreach_iter(exec_list_iterator, iter, *list) {
|
foreach_list_safe(n, list) {
|
||||||
((ir_instruction *)iter.get())->accept(visitor);
|
((ir_instruction *) n)->accept(visitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -123,8 +123,8 @@ ir_rvalue_base_visitor::rvalue_visit(ir_assignment *ir)
|
|||||||
ir_visitor_status
|
ir_visitor_status
|
||||||
ir_rvalue_base_visitor::rvalue_visit(ir_call *ir)
|
ir_rvalue_base_visitor::rvalue_visit(ir_call *ir)
|
||||||
{
|
{
|
||||||
foreach_iter(exec_list_iterator, iter, *ir) {
|
foreach_list_safe(n, &ir->actual_parameters) {
|
||||||
ir_rvalue *param = (ir_rvalue *)iter.get();
|
ir_rvalue *param = (ir_rvalue *) n;
|
||||||
ir_rvalue *new_param = param;
|
ir_rvalue *new_param = param;
|
||||||
handle_rvalue(&new_param);
|
handle_rvalue(&new_param);
|
||||||
|
|
||||||
|
@@ -197,8 +197,8 @@ ir_vec_index_to_cond_assign_visitor::visit_leave(ir_assignment *ir)
|
|||||||
ir_visitor_status
|
ir_visitor_status
|
||||||
ir_vec_index_to_cond_assign_visitor::visit_enter(ir_call *ir)
|
ir_vec_index_to_cond_assign_visitor::visit_enter(ir_call *ir)
|
||||||
{
|
{
|
||||||
foreach_iter(exec_list_iterator, iter, *ir) {
|
foreach_list_safe(n, &ir->actual_parameters) {
|
||||||
ir_rvalue *param = (ir_rvalue *)iter.get();
|
ir_rvalue *param = (ir_rvalue *) n;
|
||||||
ir_rvalue *new_param = convert_vector_extract_to_cond_assign(param);
|
ir_rvalue *new_param = convert_vector_extract_to_cond_assign(param);
|
||||||
|
|
||||||
if (new_param != param) {
|
if (new_param != param) {
|
||||||
|
@@ -131,8 +131,8 @@ ir_vec_index_to_swizzle_visitor::visit_enter(ir_assignment *ir)
|
|||||||
ir_visitor_status
|
ir_visitor_status
|
||||||
ir_vec_index_to_swizzle_visitor::visit_enter(ir_call *ir)
|
ir_vec_index_to_swizzle_visitor::visit_enter(ir_call *ir)
|
||||||
{
|
{
|
||||||
foreach_iter(exec_list_iterator, iter, *ir) {
|
foreach_list_safe(n, &ir->actual_parameters) {
|
||||||
ir_rvalue *param = (ir_rvalue *)iter.get();
|
ir_rvalue *param = (ir_rvalue *) n;
|
||||||
ir_rvalue *new_param = convert_vector_extract_to_swizzle(param);
|
ir_rvalue *new_param = convert_vector_extract_to_swizzle(param);
|
||||||
|
|
||||||
if (new_param != param) {
|
if (new_param != param) {
|
||||||
|
@@ -224,8 +224,8 @@ ir_array_reference_visitor::get_split_list(exec_list *instructions,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Trim out variables we found that we can't split. */
|
/* Trim out variables we found that we can't split. */
|
||||||
foreach_iter(exec_list_iterator, iter, variable_list) {
|
foreach_list_safe(n, &variable_list) {
|
||||||
variable_entry *entry = (variable_entry *)iter.get();
|
variable_entry *entry = (variable_entry *) n;
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
printf("array %s@%p: decl %d, split %d\n",
|
printf("array %s@%p: decl %d, split %d\n",
|
||||||
|
@@ -398,8 +398,8 @@ ir_constant_propagation_visitor::kill(ir_variable *var, unsigned write_mask)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Remove any entries currently in the ACP for this kill. */
|
/* Remove any entries currently in the ACP for this kill. */
|
||||||
foreach_iter(exec_list_iterator, iter, *this->acp) {
|
foreach_list_safe(n, this->acp) {
|
||||||
acp_entry *entry = (acp_entry *)iter.get();
|
acp_entry *entry = (acp_entry *) n;
|
||||||
|
|
||||||
if (entry->var == var) {
|
if (entry->var == var) {
|
||||||
entry->write_mask &= ~write_mask;
|
entry->write_mask &= ~write_mask;
|
||||||
|
@@ -292,8 +292,8 @@ ir_copy_propagation_visitor::kill(ir_variable *var)
|
|||||||
assert(var != NULL);
|
assert(var != NULL);
|
||||||
|
|
||||||
/* Remove any entries currently in the ACP for this kill. */
|
/* Remove any entries currently in the ACP for this kill. */
|
||||||
foreach_iter(exec_list_iterator, iter, *acp) {
|
foreach_list_safe(n, acp) {
|
||||||
acp_entry *entry = (acp_entry *)iter.get();
|
acp_entry *entry = (acp_entry *) n;
|
||||||
|
|
||||||
if (entry->lhs == var || entry->rhs == var) {
|
if (entry->lhs == var || entry->rhs == var) {
|
||||||
entry->remove();
|
entry->remove();
|
||||||
|
@@ -70,8 +70,8 @@ public:
|
|||||||
|
|
||||||
void kill_channels(ir_variable *const var, int used)
|
void kill_channels(ir_variable *const var, int used)
|
||||||
{
|
{
|
||||||
foreach_iter(exec_list_iterator, iter, *this->assignments) {
|
foreach_list_safe(n, this->assignments) {
|
||||||
assignment_entry *entry = (assignment_entry *)iter.get();
|
assignment_entry *entry = (assignment_entry *) n;
|
||||||
|
|
||||||
if (entry->lhs == var) {
|
if (entry->lhs == var) {
|
||||||
if (var->type->is_scalar() || var->type->is_vector()) {
|
if (var->type->is_scalar() || var->type->is_vector()) {
|
||||||
@@ -119,8 +119,8 @@ public:
|
|||||||
/* For the purpose of dead code elimination, emitting a vertex counts as
|
/* For the purpose of dead code elimination, emitting a vertex counts as
|
||||||
* "reading" all of the currently assigned output variables.
|
* "reading" all of the currently assigned output variables.
|
||||||
*/
|
*/
|
||||||
foreach_iter(exec_list_iterator, iter, *this->assignments) {
|
foreach_list_safe(n, this->assignments) {
|
||||||
assignment_entry *entry = (assignment_entry *)iter.get();
|
assignment_entry *entry = (assignment_entry *) n;
|
||||||
if (entry->lhs->data.mode == ir_var_shader_out) {
|
if (entry->lhs->data.mode == ir_var_shader_out) {
|
||||||
if (debug)
|
if (debug)
|
||||||
printf("kill %s\n", entry->lhs->name);
|
printf("kill %s\n", entry->lhs->name);
|
||||||
@@ -196,8 +196,8 @@ process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments)
|
|||||||
printf("looking for %s.0x%01x to remove\n", var->name,
|
printf("looking for %s.0x%01x to remove\n", var->name,
|
||||||
ir->write_mask);
|
ir->write_mask);
|
||||||
|
|
||||||
foreach_iter(exec_list_iterator, iter, *assignments) {
|
foreach_list_safe(n, assignments) {
|
||||||
assignment_entry *entry = (assignment_entry *)iter.get();
|
assignment_entry *entry = (assignment_entry *) n;
|
||||||
|
|
||||||
if (entry->lhs != var)
|
if (entry->lhs != var)
|
||||||
continue;
|
continue;
|
||||||
@@ -258,8 +258,8 @@ process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments)
|
|||||||
*/
|
*/
|
||||||
if (debug)
|
if (debug)
|
||||||
printf("looking for %s to remove\n", var->name);
|
printf("looking for %s to remove\n", var->name);
|
||||||
foreach_iter(exec_list_iterator, iter, *assignments) {
|
foreach_list_safe(n, assignments) {
|
||||||
assignment_entry *entry = (assignment_entry *)iter.get();
|
assignment_entry *entry = (assignment_entry *) n;
|
||||||
|
|
||||||
if (entry->lhs == var) {
|
if (entry->lhs == var) {
|
||||||
if (debug)
|
if (debug)
|
||||||
|
@@ -123,8 +123,8 @@ do_dead_functions(exec_list *instructions)
|
|||||||
* the unused ones, and remove function definitions that have no more
|
* the unused ones, and remove function definitions that have no more
|
||||||
* signatures.
|
* signatures.
|
||||||
*/
|
*/
|
||||||
foreach_iter(exec_list_iterator, iter, v.signature_list) {
|
foreach_list_safe(n, &v.signature_list) {
|
||||||
signature_entry *entry = (signature_entry *)iter.get();
|
signature_entry *entry = (signature_entry *) n;
|
||||||
|
|
||||||
if (!entry->used) {
|
if (!entry->used) {
|
||||||
entry->signature->remove();
|
entry->signature->remove();
|
||||||
@@ -137,8 +137,8 @@ do_dead_functions(exec_list *instructions)
|
|||||||
/* We don't just do this above when we nuked a signature because of
|
/* We don't just do this above when we nuked a signature because of
|
||||||
* const pointers.
|
* const pointers.
|
||||||
*/
|
*/
|
||||||
foreach_iter(exec_list_iterator, iter, *instructions) {
|
foreach_list_safe(n, instructions) {
|
||||||
ir_instruction *ir = (ir_instruction *)iter.get();
|
ir_instruction *ir = (ir_instruction *) n;
|
||||||
ir_function *func = ir->as_function();
|
ir_function *func = ir->as_function();
|
||||||
|
|
||||||
if (func && func->signatures.is_empty()) {
|
if (func && func->signatures.is_empty()) {
|
||||||
|
@@ -349,8 +349,8 @@ ir_variable_replacement_visitor::visit_leave(ir_dereference_record *ir)
|
|||||||
ir_visitor_status
|
ir_visitor_status
|
||||||
ir_variable_replacement_visitor::visit_leave(ir_call *ir)
|
ir_variable_replacement_visitor::visit_leave(ir_call *ir)
|
||||||
{
|
{
|
||||||
foreach_iter(exec_list_iterator, iter, *ir) {
|
foreach_list_safe(n, &ir->actual_parameters) {
|
||||||
ir_rvalue *param = (ir_rvalue *)iter.get();
|
ir_rvalue *param = (ir_rvalue *) n;
|
||||||
ir_rvalue *new_param = param;
|
ir_rvalue *new_param = param;
|
||||||
replace_rvalue(&new_param);
|
replace_rvalue(&new_param);
|
||||||
|
|
||||||
|
@@ -90,13 +90,13 @@ ir_if_simplification_visitor::visit_leave(ir_if *ir)
|
|||||||
* that matters out.
|
* that matters out.
|
||||||
*/
|
*/
|
||||||
if (condition_constant->value.b[0]) {
|
if (condition_constant->value.b[0]) {
|
||||||
foreach_iter(exec_list_iterator, then_iter, ir->then_instructions) {
|
foreach_list_safe(n, &ir->then_instructions) {
|
||||||
ir_instruction *then_ir = (ir_instruction *)then_iter.get();
|
ir_instruction *then_ir = (ir_instruction *) n;
|
||||||
ir->insert_before(then_ir);
|
ir->insert_before(then_ir);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach_iter(exec_list_iterator, else_iter, ir->else_instructions) {
|
foreach_list_safe(n, &ir->else_instructions) {
|
||||||
ir_instruction *else_ir = (ir_instruction *)else_iter.get();
|
ir_instruction *else_ir = (ir_instruction *) n;
|
||||||
ir->insert_before(else_ir);
|
ir->insert_before(else_ir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -315,8 +315,8 @@ do_structure_splitting(exec_list *instructions)
|
|||||||
visit_list_elements(&refs, instructions);
|
visit_list_elements(&refs, instructions);
|
||||||
|
|
||||||
/* Trim out variables we can't split. */
|
/* Trim out variables we can't split. */
|
||||||
foreach_iter(exec_list_iterator, iter, refs.variable_list) {
|
foreach_list_safe(n, &refs.variable_list) {
|
||||||
variable_entry *entry = (variable_entry *)iter.get();
|
variable_entry *entry = (variable_entry *) n;
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
printf("structure %s@%p: decl %d, whole_access %d\n",
|
printf("structure %s@%p: decl %d, whole_access %d\n",
|
||||||
@@ -337,8 +337,8 @@ do_structure_splitting(exec_list *instructions)
|
|||||||
/* Replace the decls of the structures to be split with their split
|
/* Replace the decls of the structures to be split with their split
|
||||||
* components.
|
* components.
|
||||||
*/
|
*/
|
||||||
foreach_iter(exec_list_iterator, iter, refs.variable_list) {
|
foreach_list_safe(n, &refs.variable_list) {
|
||||||
variable_entry *entry = (variable_entry *)iter.get();
|
variable_entry *entry = (variable_entry *) n;
|
||||||
const struct glsl_type *type = entry->var->type;
|
const struct glsl_type *type = entry->var->type;
|
||||||
|
|
||||||
entry->mem_ctx = ralloc_parent(entry->var);
|
entry->mem_ctx = ralloc_parent(entry->var);
|
||||||
|
Reference in New Issue
Block a user