diff options
author | Jason Ekstrand <[email protected]> | 2016-04-26 20:16:21 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2016-04-28 15:54:48 -0700 |
commit | 8564916d01b31ca5665a27366e483738541ba5a3 (patch) | |
tree | 5b0563e838824f90ed398c0bf64ab3e3339fe7ce /src/compiler/nir | |
parent | 707e72f13bb78869ee95d3286980bf1709cba6cf (diff) |
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 <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r-- | src/compiler/nir/nir.c | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir.h | 8 | ||||
-rw-r--r-- | src/compiler/nir/nir_control_flow.c | 4 | ||||
-rw-r--r-- | src/compiler/nir/nir_from_ssa.c | 4 | ||||
-rw-r--r-- | src/compiler/nir/nir_instr_set.c | 6 | ||||
-rw-r--r-- | src/compiler/nir/nir_liveness.c | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir_lower_phis_to_scalar.c | 4 | ||||
-rw-r--r-- | src/compiler/nir/nir_opt_dead_cf.c | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir_opt_gcm.c | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir_opt_peephole_select.c | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir_opt_remove_phis.c | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir_print.c | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir_to_ssa.c | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir_validate.c | 2 |
14 files changed, 22 insertions, 22 deletions
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 37a15cf5bc5..238f5257602 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -1162,7 +1162,7 @@ visit_load_const_src(nir_load_const_instr *instr, nir_foreach_src_cb cb, static bool 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)) return false; } diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 604eb4e11fe..e2585c65bfb 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -1304,10 +1304,10 @@ typedef struct { nir_src src; } nir_phi_src; -#define nir_foreach_phi_src(phi, entry) \ - foreach_list_typed(nir_phi_src, entry, node, &(phi)->srcs) -#define nir_foreach_phi_src_safe(phi, entry) \ - foreach_list_typed_safe(nir_phi_src, entry, node, &(phi)->srcs) +#define nir_foreach_phi_src(phi_src, phi) \ + foreach_list_typed(nir_phi_src, phi_src, node, &(phi)->srcs) +#define nir_foreach_phi_src_safe(phi_src, phi) \ + foreach_list_typed_safe(nir_phi_src, phi_src, node, &(phi)->srcs) typedef struct { nir_instr instr; diff --git a/src/compiler/nir/nir_control_flow.c b/src/compiler/nir/nir_control_flow.c index 64d9a86cde7..a485e713fa4 100644 --- a/src/compiler/nir/nir_control_flow.c +++ b/src/compiler/nir/nir_control_flow.c @@ -261,7 +261,7 @@ rewrite_phi_preds(nir_block *block, nir_block *old_pred, nir_block *new_pred) break; 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) { src->pred = new_pred; break; @@ -542,7 +542,7 @@ remove_phi_src(nir_block *block, nir_block *pred) break; 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) { list_del(&src->src.use_link); exec_node_remove(&src->node); diff --git a/src/compiler/nir/nir_from_ssa.c b/src/compiler/nir/nir_from_ssa.c index 947ebe1ccb7..d333752b371 100644 --- a/src/compiler/nir/nir_from_ssa.c +++ b/src/compiler/nir/nir_from_ssa.c @@ -331,7 +331,7 @@ isolate_phi_nodes_block(nir_block *block, void *dead_ctx) nir_phi_instr *phi = nir_instr_as_phi(instr); assert(phi->dest.is_ssa); - nir_foreach_phi_src(phi, src) { + nir_foreach_phi_src(src, phi) { nir_parallel_copy_instr *pcopy = get_parallel_copy_at_end_of_block(src->pred); assert(pcopy); @@ -380,7 +380,7 @@ coalesce_phi_nodes_block(nir_block *block, struct from_ssa_state *state) assert(phi->dest.is_ssa); 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); merge_node *src_node = get_merge_node(src->src.ssa, state); if (src_node->set != dest_node->set) diff --git a/src/compiler/nir/nir_instr_set.c b/src/compiler/nir/nir_instr_set.c index c6161433516..fe312a048bd 100644 --- a/src/compiler/nir/nir_instr_set.c +++ b/src/compiler/nir/nir_instr_set.c @@ -106,7 +106,7 @@ hash_phi(uint32_t hash, const nir_phi_instr *instr) unsigned num_preds = instr->instr.block->predecessors->entries; NIR_VLA(nir_phi_src *, srcs, num_preds); unsigned i = 0; - nir_foreach_phi_src(instr, src) { + nir_foreach_phi_src(src, instr) { 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) return false; - nir_foreach_phi_src(phi1, src1) { - nir_foreach_phi_src(phi2, src2) { + nir_foreach_phi_src(src1, phi1) { + nir_foreach_phi_src(src2, phi2) { if (src1->pred == src2->pred) { if (!nir_srcs_equal(src1->src, src2->src)) return false; diff --git a/src/compiler/nir/nir_liveness.c b/src/compiler/nir/nir_liveness.c index 69c6fd93b58..1fcb01d5ef6 100644 --- a/src/compiler/nir/nir_liveness.c +++ b/src/compiler/nir/nir_liveness.c @@ -138,7 +138,7 @@ propagate_across_edge(nir_block *pred, nir_block *succ, break; 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) { set_src_live(&src->src, live); break; diff --git a/src/compiler/nir/nir_lower_phis_to_scalar.c b/src/compiler/nir/nir_lower_phis_to_scalar.c index a1a679bfcc2..0e27e6dd7f4 100644 --- a/src/compiler/nir/nir_lower_phis_to_scalar.c +++ b/src/compiler/nir/nir_lower_phis_to_scalar.c @@ -146,7 +146,7 @@ should_lower_phi(nir_phi_instr *phi, struct lower_phis_to_scalar_state *state) bool scalarizable = true; - nir_foreach_phi_src(phi, src) { + nir_foreach_phi_src(src, phi) { scalarizable = is_phi_src_scalarizable(src, state); if (!scalarizable) 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); - 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 */ nir_alu_instr *mov = nir_alu_instr_create(state->mem_ctx, nir_op_imov); diff --git a/src/compiler/nir/nir_opt_dead_cf.c b/src/compiler/nir/nir_opt_dead_cf.c index ca73e50061b..4b62e55d030 100644 --- a/src/compiler/nir/nir_opt_dead_cf.c +++ b/src/compiler/nir/nir_opt_dead_cf.c @@ -97,7 +97,7 @@ opt_constant_if(nir_if *if_stmt, bool condition) nir_phi_instr *phi = nir_instr_as_phi(instr); 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) continue; diff --git a/src/compiler/nir/nir_opt_gcm.c b/src/compiler/nir/nir_opt_gcm.c index d79235d1719..a87a0067230 100644 --- a/src/compiler/nir/nir_opt_gcm.c +++ b/src/compiler/nir/nir_opt_gcm.c @@ -292,7 +292,7 @@ gcm_schedule_late_def(nir_ssa_def *def, void *void_state) if (use_instr->type == nir_instr_type_phi) { 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) lca = nir_dominance_lca(lca, phi_src->pred); } diff --git a/src/compiler/nir/nir_opt_peephole_select.c b/src/compiler/nir/nir_opt_peephole_select.c index b31cc35ba71..4d2b74dc7ff 100644 --- a/src/compiler/nir/nir_opt_peephole_select.c +++ b/src/compiler/nir/nir_opt_peephole_select.c @@ -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); 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->src.is_ssa); diff --git a/src/compiler/nir/nir_opt_remove_phis.c b/src/compiler/nir/nir_opt_remove_phis.c index 5234c0f667a..5d015c243de 100644 --- a/src/compiler/nir/nir_opt_remove_phis.c +++ b/src/compiler/nir/nir_opt_remove_phis.c @@ -56,7 +56,7 @@ remove_phis_block(nir_block *block) nir_ssa_def *def = NULL; bool srcs_same = true; - nir_foreach_phi_src(phi, src) { + nir_foreach_phi_src(src, phi) { assert(src->src.is_ssa); /* For phi nodes at the beginning of loops, we may encounter some diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index 76effa99e8c..e504d88484e 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -793,7 +793,7 @@ print_phi_instr(nir_phi_instr *instr, print_state *state) FILE *fp = state->fp; print_dest(&instr->dest, state); fprintf(fp, " = phi "); - nir_foreach_phi_src(instr, src) { + nir_foreach_phi_src(src, instr) { if (&src->node != exec_list_get_head(&instr->srcs)) fprintf(fp, ", "); diff --git a/src/compiler/nir/nir_to_ssa.c b/src/compiler/nir/nir_to_ssa.c index 766849192ff..7dc283d045b 100644 --- a/src/compiler/nir/nir_to_ssa.c +++ b/src/compiler/nir/nir_to_ssa.c @@ -389,7 +389,7 @@ rewrite_phi_sources(nir_block *block, nir_block *pred, rewrite_state *state) state->parent_instr = instr; - nir_foreach_phi_src(phi_instr, src) { + nir_foreach_phi_src(src, phi_instr) { if (src->pred == pred) { rewrite_use(&src->src, state); break; diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 10a78323550..e928c41607b 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -588,7 +588,7 @@ validate_phi_src(nir_phi_instr *instr, nir_block *pred, validate_state *state) assert(instr->dest.is_ssa); exec_list_validate(&instr->srcs); - nir_foreach_phi_src(instr, src) { + nir_foreach_phi_src(src, instr) { if (src->pred == pred) { assert(src->src.is_ssa); assert(src->src.ssa->num_components == |