nir: Switch the arguments to nir_foreach_phi_src
This matches the "foreach x in container" pattern found in many other programming languages. Generated by the following regular expression: s/nir_foreach_phi_src(\([^,]*\),\s*\([^,]*\))/nir_foreach_phi_src(\2, \1)/ and a similar expression for nir_foreach_phi_src_safe. Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
This commit is contained in:
@@ -1162,7 +1162,7 @@ visit_load_const_src(nir_load_const_instr *instr, nir_foreach_src_cb cb,
|
|||||||
static bool
|
static bool
|
||||||
visit_phi_src(nir_phi_instr *instr, nir_foreach_src_cb cb, void *state)
|
visit_phi_src(nir_phi_instr *instr, nir_foreach_src_cb cb, void *state)
|
||||||
{
|
{
|
||||||
nir_foreach_phi_src(instr, src) {
|
nir_foreach_phi_src(src, instr) {
|
||||||
if (!visit_src(&src->src, cb, state))
|
if (!visit_src(&src->src, cb, state))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -1304,10 +1304,10 @@ typedef struct {
|
|||||||
nir_src src;
|
nir_src src;
|
||||||
} nir_phi_src;
|
} nir_phi_src;
|
||||||
|
|
||||||
#define nir_foreach_phi_src(phi, entry) \
|
#define nir_foreach_phi_src(phi_src, phi) \
|
||||||
foreach_list_typed(nir_phi_src, entry, node, &(phi)->srcs)
|
foreach_list_typed(nir_phi_src, phi_src, node, &(phi)->srcs)
|
||||||
#define nir_foreach_phi_src_safe(phi, entry) \
|
#define nir_foreach_phi_src_safe(phi_src, phi) \
|
||||||
foreach_list_typed_safe(nir_phi_src, entry, node, &(phi)->srcs)
|
foreach_list_typed_safe(nir_phi_src, phi_src, node, &(phi)->srcs)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
nir_instr instr;
|
nir_instr instr;
|
||||||
|
@@ -261,7 +261,7 @@ rewrite_phi_preds(nir_block *block, nir_block *old_pred, nir_block *new_pred)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
nir_phi_instr *phi = nir_instr_as_phi(instr);
|
nir_phi_instr *phi = nir_instr_as_phi(instr);
|
||||||
nir_foreach_phi_src(phi, src) {
|
nir_foreach_phi_src(src, phi) {
|
||||||
if (src->pred == old_pred) {
|
if (src->pred == old_pred) {
|
||||||
src->pred = new_pred;
|
src->pred = new_pred;
|
||||||
break;
|
break;
|
||||||
@@ -542,7 +542,7 @@ remove_phi_src(nir_block *block, nir_block *pred)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
nir_phi_instr *phi = nir_instr_as_phi(instr);
|
nir_phi_instr *phi = nir_instr_as_phi(instr);
|
||||||
nir_foreach_phi_src_safe(phi, src) {
|
nir_foreach_phi_src_safe(src, phi) {
|
||||||
if (src->pred == pred) {
|
if (src->pred == pred) {
|
||||||
list_del(&src->src.use_link);
|
list_del(&src->src.use_link);
|
||||||
exec_node_remove(&src->node);
|
exec_node_remove(&src->node);
|
||||||
|
@@ -331,7 +331,7 @@ isolate_phi_nodes_block(nir_block *block, void *dead_ctx)
|
|||||||
|
|
||||||
nir_phi_instr *phi = nir_instr_as_phi(instr);
|
nir_phi_instr *phi = nir_instr_as_phi(instr);
|
||||||
assert(phi->dest.is_ssa);
|
assert(phi->dest.is_ssa);
|
||||||
nir_foreach_phi_src(phi, src) {
|
nir_foreach_phi_src(src, phi) {
|
||||||
nir_parallel_copy_instr *pcopy =
|
nir_parallel_copy_instr *pcopy =
|
||||||
get_parallel_copy_at_end_of_block(src->pred);
|
get_parallel_copy_at_end_of_block(src->pred);
|
||||||
assert(pcopy);
|
assert(pcopy);
|
||||||
@@ -380,7 +380,7 @@ coalesce_phi_nodes_block(nir_block *block, struct from_ssa_state *state)
|
|||||||
assert(phi->dest.is_ssa);
|
assert(phi->dest.is_ssa);
|
||||||
merge_node *dest_node = get_merge_node(&phi->dest.ssa, state);
|
merge_node *dest_node = get_merge_node(&phi->dest.ssa, state);
|
||||||
|
|
||||||
nir_foreach_phi_src(phi, src) {
|
nir_foreach_phi_src(src, phi) {
|
||||||
assert(src->src.is_ssa);
|
assert(src->src.is_ssa);
|
||||||
merge_node *src_node = get_merge_node(src->src.ssa, state);
|
merge_node *src_node = get_merge_node(src->src.ssa, state);
|
||||||
if (src_node->set != dest_node->set)
|
if (src_node->set != dest_node->set)
|
||||||
|
@@ -106,7 +106,7 @@ hash_phi(uint32_t hash, const nir_phi_instr *instr)
|
|||||||
unsigned num_preds = instr->instr.block->predecessors->entries;
|
unsigned num_preds = instr->instr.block->predecessors->entries;
|
||||||
NIR_VLA(nir_phi_src *, srcs, num_preds);
|
NIR_VLA(nir_phi_src *, srcs, num_preds);
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
nir_foreach_phi_src(instr, src) {
|
nir_foreach_phi_src(src, instr) {
|
||||||
srcs[i++] = src;
|
srcs[i++] = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,8 +343,8 @@ nir_instrs_equal(const nir_instr *instr1, const nir_instr *instr2)
|
|||||||
if (phi1->instr.block != phi2->instr.block)
|
if (phi1->instr.block != phi2->instr.block)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
nir_foreach_phi_src(phi1, src1) {
|
nir_foreach_phi_src(src1, phi1) {
|
||||||
nir_foreach_phi_src(phi2, src2) {
|
nir_foreach_phi_src(src2, phi2) {
|
||||||
if (src1->pred == src2->pred) {
|
if (src1->pred == src2->pred) {
|
||||||
if (!nir_srcs_equal(src1->src, src2->src))
|
if (!nir_srcs_equal(src1->src, src2->src))
|
||||||
return false;
|
return false;
|
||||||
|
@@ -138,7 +138,7 @@ propagate_across_edge(nir_block *pred, nir_block *succ,
|
|||||||
break;
|
break;
|
||||||
nir_phi_instr *phi = nir_instr_as_phi(instr);
|
nir_phi_instr *phi = nir_instr_as_phi(instr);
|
||||||
|
|
||||||
nir_foreach_phi_src(phi, src) {
|
nir_foreach_phi_src(src, phi) {
|
||||||
if (src->pred == pred) {
|
if (src->pred == pred) {
|
||||||
set_src_live(&src->src, live);
|
set_src_live(&src->src, live);
|
||||||
break;
|
break;
|
||||||
|
@@ -146,7 +146,7 @@ should_lower_phi(nir_phi_instr *phi, struct lower_phis_to_scalar_state *state)
|
|||||||
|
|
||||||
bool scalarizable = true;
|
bool scalarizable = true;
|
||||||
|
|
||||||
nir_foreach_phi_src(phi, src) {
|
nir_foreach_phi_src(src, phi) {
|
||||||
scalarizable = is_phi_src_scalarizable(src, state);
|
scalarizable = is_phi_src_scalarizable(src, state);
|
||||||
if (!scalarizable)
|
if (!scalarizable)
|
||||||
break;
|
break;
|
||||||
@@ -214,7 +214,7 @@ lower_phis_to_scalar_block(nir_block *block,
|
|||||||
|
|
||||||
vec->src[i].src = nir_src_for_ssa(&new_phi->dest.ssa);
|
vec->src[i].src = nir_src_for_ssa(&new_phi->dest.ssa);
|
||||||
|
|
||||||
nir_foreach_phi_src(phi, src) {
|
nir_foreach_phi_src(src, phi) {
|
||||||
/* We need to insert a mov to grab the i'th component of src */
|
/* We need to insert a mov to grab the i'th component of src */
|
||||||
nir_alu_instr *mov = nir_alu_instr_create(state->mem_ctx,
|
nir_alu_instr *mov = nir_alu_instr_create(state->mem_ctx,
|
||||||
nir_op_imov);
|
nir_op_imov);
|
||||||
|
@@ -97,7 +97,7 @@ opt_constant_if(nir_if *if_stmt, bool condition)
|
|||||||
|
|
||||||
nir_phi_instr *phi = nir_instr_as_phi(instr);
|
nir_phi_instr *phi = nir_instr_as_phi(instr);
|
||||||
nir_ssa_def *def = NULL;
|
nir_ssa_def *def = NULL;
|
||||||
nir_foreach_phi_src(phi, phi_src) {
|
nir_foreach_phi_src(phi_src, phi) {
|
||||||
if (phi_src->pred != last_block)
|
if (phi_src->pred != last_block)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@@ -292,7 +292,7 @@ gcm_schedule_late_def(nir_ssa_def *def, void *void_state)
|
|||||||
if (use_instr->type == nir_instr_type_phi) {
|
if (use_instr->type == nir_instr_type_phi) {
|
||||||
nir_phi_instr *phi = nir_instr_as_phi(use_instr);
|
nir_phi_instr *phi = nir_instr_as_phi(use_instr);
|
||||||
|
|
||||||
nir_foreach_phi_src(phi, phi_src) {
|
nir_foreach_phi_src(phi_src, phi) {
|
||||||
if (phi_src->src.ssa == def)
|
if (phi_src->src.ssa == def)
|
||||||
lca = nir_dominance_lca(lca, phi_src->pred);
|
lca = nir_dominance_lca(lca, phi_src->pred);
|
||||||
}
|
}
|
||||||
|
@@ -194,7 +194,7 @@ nir_opt_peephole_select_block(nir_block *block, void *mem_ctx)
|
|||||||
memset(sel->src[0].swizzle, 0, sizeof sel->src[0].swizzle);
|
memset(sel->src[0].swizzle, 0, sizeof sel->src[0].swizzle);
|
||||||
|
|
||||||
assert(exec_list_length(&phi->srcs) == 2);
|
assert(exec_list_length(&phi->srcs) == 2);
|
||||||
nir_foreach_phi_src(phi, src) {
|
nir_foreach_phi_src(src, phi) {
|
||||||
assert(src->pred == then_block || src->pred == else_block);
|
assert(src->pred == then_block || src->pred == else_block);
|
||||||
assert(src->src.is_ssa);
|
assert(src->src.is_ssa);
|
||||||
|
|
||||||
|
@@ -56,7 +56,7 @@ remove_phis_block(nir_block *block)
|
|||||||
nir_ssa_def *def = NULL;
|
nir_ssa_def *def = NULL;
|
||||||
bool srcs_same = true;
|
bool srcs_same = true;
|
||||||
|
|
||||||
nir_foreach_phi_src(phi, src) {
|
nir_foreach_phi_src(src, phi) {
|
||||||
assert(src->src.is_ssa);
|
assert(src->src.is_ssa);
|
||||||
|
|
||||||
/* For phi nodes at the beginning of loops, we may encounter some
|
/* For phi nodes at the beginning of loops, we may encounter some
|
||||||
|
@@ -793,7 +793,7 @@ print_phi_instr(nir_phi_instr *instr, print_state *state)
|
|||||||
FILE *fp = state->fp;
|
FILE *fp = state->fp;
|
||||||
print_dest(&instr->dest, state);
|
print_dest(&instr->dest, state);
|
||||||
fprintf(fp, " = phi ");
|
fprintf(fp, " = phi ");
|
||||||
nir_foreach_phi_src(instr, src) {
|
nir_foreach_phi_src(src, instr) {
|
||||||
if (&src->node != exec_list_get_head(&instr->srcs))
|
if (&src->node != exec_list_get_head(&instr->srcs))
|
||||||
fprintf(fp, ", ");
|
fprintf(fp, ", ");
|
||||||
|
|
||||||
|
@@ -389,7 +389,7 @@ rewrite_phi_sources(nir_block *block, nir_block *pred, rewrite_state *state)
|
|||||||
|
|
||||||
state->parent_instr = instr;
|
state->parent_instr = instr;
|
||||||
|
|
||||||
nir_foreach_phi_src(phi_instr, src) {
|
nir_foreach_phi_src(src, phi_instr) {
|
||||||
if (src->pred == pred) {
|
if (src->pred == pred) {
|
||||||
rewrite_use(&src->src, state);
|
rewrite_use(&src->src, state);
|
||||||
break;
|
break;
|
||||||
|
@@ -588,7 +588,7 @@ validate_phi_src(nir_phi_instr *instr, nir_block *pred, validate_state *state)
|
|||||||
assert(instr->dest.is_ssa);
|
assert(instr->dest.is_ssa);
|
||||||
|
|
||||||
exec_list_validate(&instr->srcs);
|
exec_list_validate(&instr->srcs);
|
||||||
nir_foreach_phi_src(instr, src) {
|
nir_foreach_phi_src(src, instr) {
|
||||||
if (src->pred == pred) {
|
if (src->pred == pred) {
|
||||||
assert(src->src.is_ssa);
|
assert(src->src.is_ssa);
|
||||||
assert(src->src.ssa->num_components ==
|
assert(src->src.ssa->num_components ==
|
||||||
|
@@ -281,7 +281,7 @@ lower_if_else_block(nir_block *block, void *void_state)
|
|||||||
memset(sel->src[0].swizzle, 0, sizeof sel->src[0].swizzle);
|
memset(sel->src[0].swizzle, 0, sizeof sel->src[0].swizzle);
|
||||||
|
|
||||||
assert(exec_list_length(&phi->srcs) == 2);
|
assert(exec_list_length(&phi->srcs) == 2);
|
||||||
nir_foreach_phi_src(phi, src) {
|
nir_foreach_phi_src(src, phi) {
|
||||||
assert(src->pred == then_block || src->pred == else_block);
|
assert(src->pred == then_block || src->pred == else_block);
|
||||||
assert(src->src.is_ssa);
|
assert(src->src.is_ssa);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user