[Mesa-dev] [PATCH 1/6] nir: Switch the arguments to nir_foreach_instr

Jason Ekstrand jason at jlekstrand.net
Wed Apr 27 03:41:45 UTC 2016


This matches the "foreach x in container" pattern found in many other
programming languages.  Generated by the following regular expression:

s/nir_foreach_instr(\([^,]*\),\s*\([^,]*\))/nir_foreach_instr(\2, \1)/

and similar expressions for nir_foreach_instr_safe etc.
---
 src/compiler/nir/nir.c                                       |  4 ++--
 src/compiler/nir/nir.h                                       | 10 +++++-----
 src/compiler/nir/nir_algebraic.py                            |  2 +-
 src/compiler/nir/nir_clone.c                                 |  2 +-
 src/compiler/nir/nir_control_flow.c                          | 12 ++++++------
 src/compiler/nir/nir_from_ssa.c                              | 10 +++++-----
 src/compiler/nir/nir_gather_info.c                           |  2 +-
 src/compiler/nir/nir_gs_count_vertices.c                     |  2 +-
 src/compiler/nir/nir_inline_functions.c                      |  6 +++---
 src/compiler/nir/nir_liveness.c                              |  8 ++++----
 src/compiler/nir/nir_lower_alu_to_scalar.c                   |  2 +-
 src/compiler/nir/nir_lower_atomics.c                         |  2 +-
 src/compiler/nir/nir_lower_clip.c                            |  2 +-
 src/compiler/nir/nir_lower_double_packing.c                  |  2 +-
 src/compiler/nir/nir_lower_global_vars_to_local.c            |  2 +-
 src/compiler/nir/nir_lower_gs_intrinsics.c                   |  2 +-
 src/compiler/nir/nir_lower_idiv.c                            |  2 +-
 src/compiler/nir/nir_lower_indirect_derefs.c                 |  2 +-
 src/compiler/nir/nir_lower_io.c                              |  2 +-
 src/compiler/nir/nir_lower_load_const_to_scalar.c            |  2 +-
 src/compiler/nir/nir_lower_locals_to_regs.c                  |  2 +-
 src/compiler/nir/nir_lower_outputs_to_temporaries.c          |  2 +-
 src/compiler/nir/nir_lower_phis_to_scalar.c                  |  4 ++--
 src/compiler/nir/nir_lower_samplers.c                        |  2 +-
 src/compiler/nir/nir_lower_system_values.c                   |  2 +-
 src/compiler/nir/nir_lower_tex.c                             |  2 +-
 src/compiler/nir/nir_lower_to_source_mods.c                  |  2 +-
 src/compiler/nir/nir_lower_two_sided_color.c                 |  2 +-
 src/compiler/nir/nir_lower_var_copies.c                      |  2 +-
 src/compiler/nir/nir_lower_vars_to_ssa.c                     |  4 ++--
 src/compiler/nir/nir_lower_vec_to_movs.c                     |  2 +-
 src/compiler/nir/nir_move_vec_src_uses_to_dest.c             |  2 +-
 src/compiler/nir/nir_normalize_cubemap_coords.c              |  2 +-
 src/compiler/nir/nir_opt_constant_folding.c                  |  2 +-
 src/compiler/nir/nir_opt_copy_propagate.c                    |  2 +-
 src/compiler/nir/nir_opt_cse.c                               |  4 ++--
 src/compiler/nir/nir_opt_dce.c                               |  4 ++--
 src/compiler/nir/nir_opt_dead_cf.c                           |  6 +++---
 src/compiler/nir/nir_opt_gcm.c                               |  2 +-
 src/compiler/nir/nir_opt_peephole_select.c                   |  8 ++++----
 src/compiler/nir/nir_opt_remove_phis.c                       |  2 +-
 src/compiler/nir/nir_opt_undef.c                             |  2 +-
 src/compiler/nir/nir_print.c                                 |  2 +-
 src/compiler/nir/nir_remove_dead_variables.c                 |  2 +-
 src/compiler/nir/nir_repair_ssa.c                            |  2 +-
 src/compiler/nir/nir_split_var_copies.c                      |  2 +-
 src/compiler/nir/nir_sweep.c                                 |  2 +-
 src/compiler/nir/nir_to_ssa.c                                |  6 +++---
 src/compiler/nir/nir_validate.c                              |  6 +++---
 src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c         |  2 +-
 src/gallium/drivers/freedreno/ir3/ir3_nir_lower_if_else.c    |  6 +++---
 src/gallium/drivers/vc4/vc4_nir_lower_blend.c                |  2 +-
 src/gallium/drivers/vc4/vc4_nir_lower_io.c                   |  2 +-
 src/gallium/drivers/vc4/vc4_nir_lower_txf_ms.c               |  2 +-
 src/gallium/drivers/vc4/vc4_program.c                        |  4 ++--
 src/intel/vulkan/anv_nir_apply_dynamic_offsets.c             |  2 +-
 src/intel/vulkan/anv_nir_apply_pipeline_layout.c             |  4 ++--
 src/intel/vulkan/anv_nir_lower_push_constants.c              |  2 +-
 src/mesa/drivers/dri/i965/brw_fs_nir.cpp                     |  4 ++--
 src/mesa/drivers/dri/i965/brw_nir.c                          |  8 ++++----
 src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c |  2 +-
 src/mesa/drivers/dri/i965/brw_nir_attribute_workarounds.c    |  2 +-
 src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c        |  2 +-
 src/mesa/drivers/dri/i965/brw_vec4_nir.cpp                   |  4 ++--
 64 files changed, 105 insertions(+), 105 deletions(-)

diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index cc1de15..6c1b129 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -1683,7 +1683,7 @@ nir_index_ssa_defs(nir_function_impl *impl)
    unsigned index = 0;
 
    nir_foreach_block(block, impl) {
-      nir_foreach_instr(block, instr)
+      nir_foreach_instr(instr, block)
          nir_foreach_ssa_def(instr, index_ssa_def_cb, &index);
    }
 
@@ -1700,7 +1700,7 @@ nir_index_instrs(nir_function_impl *impl)
    unsigned index = 0;
 
    nir_foreach_block(block, impl) {
-      nir_foreach_instr(block, instr)
+      nir_foreach_instr(instr, block)
          instr->index = index++;
    }
 
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 6ed2dc8..113073f 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1434,13 +1434,13 @@ nir_block_last_instr(nir_block *block)
    return exec_node_data(nir_instr, tail, node);
 }
 
-#define nir_foreach_instr(block, instr) \
+#define nir_foreach_instr(instr, block) \
    foreach_list_typed(nir_instr, instr, node, &(block)->instr_list)
-#define nir_foreach_instr_reverse(block, instr) \
+#define nir_foreach_instr_reverse(instr, block) \
    foreach_list_typed_reverse(nir_instr, instr, node, &(block)->instr_list)
-#define nir_foreach_instr_safe(block, instr) \
+#define nir_foreach_instr_safe(instr, block) \
    foreach_list_typed_safe(nir_instr, instr, node, &(block)->instr_list)
-#define nir_foreach_instr_reverse_safe(block, instr) \
+#define nir_foreach_instr_reverse_safe(instr, block) \
    foreach_list_typed_reverse_safe(nir_instr, instr, node, &(block)->instr_list)
 
 typedef struct nir_if {
@@ -2016,7 +2016,7 @@ nir_after_cf_node_and_phis(nir_cf_node *node)
    nir_block *block = nir_cf_node_as_block(nir_cf_node_next(node));
    assert(block->cf_node.type == nir_cf_node_block);
 
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       if (instr->type != nir_instr_type_phi)
          return nir_before_instr(instr);
    }
diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py
index f7c83cb..9d91b20 100644
--- a/src/compiler/nir/nir_algebraic.py
+++ b/src/compiler/nir/nir_algebraic.py
@@ -231,7 +231,7 @@ ${pass_name}_block(nir_block *block, const bool *condition_flags,
 {
    bool progress = false;
 
-   nir_foreach_instr_reverse_safe(block, instr) {
+   nir_foreach_instr_reverse_safe(instr, block) {
       if (instr->type != nir_instr_type_alu)
          continue;
 
diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c
index e231387..1827223 100644
--- a/src/compiler/nir/nir_clone.c
+++ b/src/compiler/nir/nir_clone.c
@@ -523,7 +523,7 @@ clone_block(clone_state *state, struct exec_list *cf_list, const nir_block *blk)
    /* We need this for phi sources */
    add_remap(state, nblk, blk);
 
-   nir_foreach_instr(blk, instr) {
+   nir_foreach_instr(instr, blk) {
       if (instr->type == nir_instr_type_phi) {
          /* Phi instructions are a bit of a special case when cloning because
           * we don't want inserting the instruction to automatically handle
diff --git a/src/compiler/nir/nir_control_flow.c b/src/compiler/nir/nir_control_flow.c
index ea57412..64d9a86 100644
--- a/src/compiler/nir/nir_control_flow.c
+++ b/src/compiler/nir/nir_control_flow.c
@@ -241,7 +241,7 @@ split_block_beginning(nir_block *block)
     * sourcse will be messed up. This will reverse the order of the phi's, but
     * order shouldn't matter.
     */
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_phi)
          break;
 
@@ -256,7 +256,7 @@ split_block_beginning(nir_block *block)
 static void
 rewrite_phi_preds(nir_block *block, nir_block *old_pred, nir_block *new_pred)
 {
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_phi)
          break;
 
@@ -274,7 +274,7 @@ static void
 insert_phi_undef(nir_block *block, nir_block *pred)
 {
    nir_function_impl *impl = nir_cf_node_get_function(&block->cf_node);
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       if (instr->type != nir_instr_type_phi)
          break;
 
@@ -404,7 +404,7 @@ split_block_before_instr(nir_instr *instr)
    assert(instr->type != nir_instr_type_phi);
    nir_block *new_block = split_block_beginning(instr->block);
 
-   nir_foreach_instr_safe(instr->block, cur_instr) {
+   nir_foreach_instr_safe(cur_instr, instr->block) {
       if (cur_instr == instr)
          break;
 
@@ -537,7 +537,7 @@ nir_handle_add_jump(nir_block *block)
 static void
 remove_phi_src(nir_block *block, nir_block *pred)
 {
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       if (instr->type != nir_instr_type_phi)
          break;
 
@@ -706,7 +706,7 @@ cleanup_cf_node(nir_cf_node *node, nir_function_impl *impl)
    case nir_cf_node_block: {
       nir_block *block = nir_cf_node_as_block(node);
       /* We need to walk the instructions and clean up defs/uses */
-      nir_foreach_instr_safe(block, instr) {
+      nir_foreach_instr_safe(instr, block) {
          if (instr->type == nir_instr_type_jump) {
             nir_jump_type jump_type = nir_instr_as_jump(instr)->type;
             unlink_jump(block, jump_type, false);
diff --git a/src/compiler/nir/nir_from_ssa.c b/src/compiler/nir/nir_from_ssa.c
index 6d92130..947ebe1 100644
--- a/src/compiler/nir/nir_from_ssa.c
+++ b/src/compiler/nir/nir_from_ssa.c
@@ -305,7 +305,7 @@ static bool
 isolate_phi_nodes_block(nir_block *block, void *dead_ctx)
 {
    nir_instr *last_phi_instr = NULL;
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       /* Phi nodes only ever come at the start of a block */
       if (instr->type != nir_instr_type_phi)
          break;
@@ -324,7 +324,7 @@ isolate_phi_nodes_block(nir_block *block, void *dead_ctx)
       nir_parallel_copy_instr_create(dead_ctx);
    nir_instr_insert_after(last_phi_instr, &block_pcopy->instr);
 
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       /* Phi nodes only ever come at the start of a block */
       if (instr->type != nir_instr_type_phi)
          break;
@@ -370,7 +370,7 @@ isolate_phi_nodes_block(nir_block *block, void *dead_ctx)
 static bool
 coalesce_phi_nodes_block(nir_block *block, struct from_ssa_state *state)
 {
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       /* Phi nodes only ever come at the start of a block */
       if (instr->type != nir_instr_type_phi)
          break;
@@ -424,7 +424,7 @@ static bool
 aggressive_coalesce_block(nir_block *block, struct from_ssa_state *state)
 {
    nir_parallel_copy_instr *start_pcopy = NULL;
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       /* Phi nodes only ever come at the start of a block */
       if (instr->type != nir_instr_type_phi) {
          if (instr->type != nir_instr_type_parallel_copy)
@@ -520,7 +520,7 @@ rewrite_ssa_def(nir_ssa_def *def, void *void_state)
 static bool
 resolve_registers_block(nir_block *block, struct from_ssa_state *state)
 {
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       state->instr = instr;
       nir_foreach_ssa_def(instr, rewrite_ssa_def, state);
 
diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c
index 090eb08..d45b1a2 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -71,7 +71,7 @@ gather_tex_info(nir_tex_instr *instr, nir_shader *shader)
 static void
 gather_info_block(nir_block *block, nir_shader *shader)
 {
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       switch (instr->type) {
       case nir_instr_type_intrinsic:
          gather_intrinsic_info(nir_instr_as_intrinsic(instr), shader);
diff --git a/src/compiler/nir/nir_gs_count_vertices.c b/src/compiler/nir/nir_gs_count_vertices.c
index 3c1bd2a..9e7c4a1 100644
--- a/src/compiler/nir/nir_gs_count_vertices.c
+++ b/src/compiler/nir/nir_gs_count_vertices.c
@@ -66,7 +66,7 @@ nir_gs_count_vertices(const nir_shader *shader)
       set_foreach(function->impl->end_block->predecessors, entry) {
          nir_block *block = (nir_block *) entry->key;
 
-         nir_foreach_instr_reverse(block, instr) {
+         nir_foreach_instr_reverse(instr, block) {
             nir_intrinsic_instr *intrin = as_set_vertex_count(instr);
             if (!intrin)
                continue;
diff --git a/src/compiler/nir/nir_inline_functions.c b/src/compiler/nir/nir_inline_functions.c
index a639814..c56dc3c 100644
--- a/src/compiler/nir/nir_inline_functions.c
+++ b/src/compiler/nir/nir_inline_functions.c
@@ -30,7 +30,7 @@ static bool inline_function_impl(nir_function_impl *impl, struct set *inlined);
 static bool
 rewrite_param_derefs_block(nir_block *block, nir_call_instr *call)
 {
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
@@ -89,7 +89,7 @@ lower_param_to_local(nir_variable *param, nir_function_impl *impl, bool write)
 static bool
 lower_params_to_locals_block(nir_block *block, nir_function_impl *impl)
 {
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
@@ -135,7 +135,7 @@ inline_functions_block(nir_block *block, nir_builder *b,
     * properly get moved to the next block when it gets split, and we
     * continue iterating there.
     */
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_call)
          continue;
 
diff --git a/src/compiler/nir/nir_liveness.c b/src/compiler/nir/nir_liveness.c
index 67913ca..69c6fd9 100644
--- a/src/compiler/nir/nir_liveness.c
+++ b/src/compiler/nir/nir_liveness.c
@@ -124,7 +124,7 @@ propagate_across_edge(nir_block *pred, nir_block *succ,
    NIR_VLA(BITSET_WORD, live, state->bitset_words);
    memcpy(live, succ->live_in, state->bitset_words * sizeof *live);
 
-   nir_foreach_instr(succ, instr) {
+   nir_foreach_instr(instr, succ) {
       if (instr->type != nir_instr_type_phi)
          break;
       nir_phi_instr *phi = nir_instr_as_phi(instr);
@@ -133,7 +133,7 @@ propagate_across_edge(nir_block *pred, nir_block *succ,
       set_ssa_def_dead(&phi->dest.ssa, live);
    }
 
-   nir_foreach_instr(succ, instr) {
+   nir_foreach_instr(instr, succ) {
       if (instr->type != nir_instr_type_phi)
          break;
       nir_phi_instr *phi = nir_instr_as_phi(instr);
@@ -165,7 +165,7 @@ nir_live_ssa_defs_impl(nir_function_impl *impl)
     */
    state.num_ssa_defs = 1;
    nir_foreach_block(block, impl) {
-      nir_foreach_instr(block, instr)
+      nir_foreach_instr(instr, block)
          nir_foreach_ssa_def(instr, index_ssa_def, &state);
    }
 
@@ -201,7 +201,7 @@ nir_live_ssa_defs_impl(nir_function_impl *impl)
       if (following_if)
          set_src_live(&following_if->condition, block->live_in);
 
-      nir_foreach_instr_reverse(block, instr) {
+      nir_foreach_instr_reverse(instr, block) {
          /* Phi nodes are handled seperately so we want to skip them.  Since
           * we are going backwards and they are at the beginning, we can just
           * break as soon as we see one.
diff --git a/src/compiler/nir/nir_lower_alu_to_scalar.c b/src/compiler/nir/nir_lower_alu_to_scalar.c
index a5fc734..ddf5eb5 100644
--- a/src/compiler/nir/nir_lower_alu_to_scalar.c
+++ b/src/compiler/nir/nir_lower_alu_to_scalar.c
@@ -247,7 +247,7 @@ nir_lower_alu_to_scalar_impl(nir_function_impl *impl)
    nir_builder_init(&builder, impl);
 
    nir_foreach_block(block, impl) {
-      nir_foreach_instr_safe(block, instr) {
+      nir_foreach_instr_safe(instr, block) {
          if (instr->type == nir_instr_type_alu)
             lower_alu_instr_scalar(nir_instr_as_alu(instr), &builder);
       }
diff --git a/src/compiler/nir/nir_lower_atomics.c b/src/compiler/nir/nir_lower_atomics.c
index f00cef7..1e2d65b 100644
--- a/src/compiler/nir/nir_lower_atomics.c
+++ b/src/compiler/nir/nir_lower_atomics.c
@@ -140,7 +140,7 @@ nir_lower_atomics(nir_shader *shader,
    nir_foreach_function(shader, function) {
       if (function->impl) {
          nir_foreach_block(block, function->impl) {
-            nir_foreach_instr_safe(block, instr) {
+            nir_foreach_instr_safe(instr, block) {
                if (instr->type == nir_instr_type_intrinsic)
                   lower_instr(nir_instr_as_intrinsic(instr),
                               shader_program, shader);
diff --git a/src/compiler/nir/nir_lower_clip.c b/src/compiler/nir/nir_lower_clip.c
index 5d949de..25ded16 100644
--- a/src/compiler/nir/nir_lower_clip.c
+++ b/src/compiler/nir/nir_lower_clip.c
@@ -100,7 +100,7 @@ load_clipdist_input(nir_builder *b, nir_variable *in, nir_ssa_def **val)
 static nir_ssa_def *
 find_output_in_block(nir_block *block, unsigned drvloc)
 {
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
 
       if (instr->type == nir_instr_type_intrinsic) {
          nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
diff --git a/src/compiler/nir/nir_lower_double_packing.c b/src/compiler/nir/nir_lower_double_packing.c
index b5cafbc..e3ebd3c 100644
--- a/src/compiler/nir/nir_lower_double_packing.c
+++ b/src/compiler/nir/nir_lower_double_packing.c
@@ -53,7 +53,7 @@ lower_double_pack_impl(nir_function_impl *impl)
    nir_builder_init(&b, impl);
 
    nir_foreach_block(block, impl) {
-      nir_foreach_instr_safe(block, instr) {
+      nir_foreach_instr_safe(instr, block) {
          if (instr->type != nir_instr_type_alu)
             continue;
 
diff --git a/src/compiler/nir/nir_lower_global_vars_to_local.c b/src/compiler/nir/nir_lower_global_vars_to_local.c
index e49e67a..e118e04 100644
--- a/src/compiler/nir/nir_lower_global_vars_to_local.c
+++ b/src/compiler/nir/nir_lower_global_vars_to_local.c
@@ -36,7 +36,7 @@ static bool
 mark_global_var_uses_block(nir_block *block, nir_function_impl *impl,
                            struct hash_table *var_func_table)
 {
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
diff --git a/src/compiler/nir/nir_lower_gs_intrinsics.c b/src/compiler/nir/nir_lower_gs_intrinsics.c
index 406d7f0..293aeac 100644
--- a/src/compiler/nir/nir_lower_gs_intrinsics.c
+++ b/src/compiler/nir/nir_lower_gs_intrinsics.c
@@ -133,7 +133,7 @@ rewrite_end_primitive(nir_intrinsic_instr *intrin, struct state *state)
 static bool
 rewrite_intrinsics(nir_block *block, struct state *state)
 {
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
diff --git a/src/compiler/nir/nir_lower_idiv.c b/src/compiler/nir/nir_lower_idiv.c
index f5dafa7..83e265b 100644
--- a/src/compiler/nir/nir_lower_idiv.c
+++ b/src/compiler/nir/nir_lower_idiv.c
@@ -124,7 +124,7 @@ convert_impl(nir_function_impl *impl)
    nir_builder_init(&b, impl);
 
    nir_foreach_block(block, impl) {
-      nir_foreach_instr_safe(block, instr) {
+      nir_foreach_instr_safe(instr, block) {
          if (instr->type == nir_instr_type_alu)
             convert_instr(&b, nir_instr_as_alu(instr));
       }
diff --git a/src/compiler/nir/nir_lower_indirect_derefs.c b/src/compiler/nir/nir_lower_indirect_derefs.c
index 9045adc..5c2aac3 100644
--- a/src/compiler/nir/nir_lower_indirect_derefs.c
+++ b/src/compiler/nir/nir_lower_indirect_derefs.c
@@ -165,7 +165,7 @@ lower_indirect_block(nir_block *block, nir_builder *b,
 {
    bool progress = false;
 
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c
index e0ba934..1c1ad51 100644
--- a/src/compiler/nir/nir_lower_io.c
+++ b/src/compiler/nir/nir_lower_io.c
@@ -216,7 +216,7 @@ nir_lower_io_block(nir_block *block,
 {
    nir_builder *b = &state->builder;
 
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
diff --git a/src/compiler/nir/nir_lower_load_const_to_scalar.c b/src/compiler/nir/nir_lower_load_const_to_scalar.c
index 06cdd5a..4857902 100644
--- a/src/compiler/nir/nir_lower_load_const_to_scalar.c
+++ b/src/compiler/nir/nir_lower_load_const_to_scalar.c
@@ -71,7 +71,7 @@ static void
 nir_lower_load_const_to_scalar_impl(nir_function_impl *impl)
 {
    nir_foreach_block(block, impl) {
-      nir_foreach_instr_safe(block, instr) {
+      nir_foreach_instr_safe(instr, block) {
          if (instr->type == nir_instr_type_load_const)
             lower_load_const_instr_scalar(nir_instr_as_load_const(instr));
       }
diff --git a/src/compiler/nir/nir_lower_locals_to_regs.c b/src/compiler/nir/nir_lower_locals_to_regs.c
index 3465d54..f1ad171 100644
--- a/src/compiler/nir/nir_lower_locals_to_regs.c
+++ b/src/compiler/nir/nir_lower_locals_to_regs.c
@@ -204,7 +204,7 @@ static bool
 lower_locals_to_regs_block(nir_block *block,
                            struct locals_to_regs_state *state)
 {
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
diff --git a/src/compiler/nir/nir_lower_outputs_to_temporaries.c b/src/compiler/nir/nir_lower_outputs_to_temporaries.c
index 6aff13f..1078fbc 100644
--- a/src/compiler/nir/nir_lower_outputs_to_temporaries.c
+++ b/src/compiler/nir/nir_lower_outputs_to_temporaries.c
@@ -102,7 +102,7 @@ nir_lower_outputs_to_temporaries(nir_shader *shader, nir_function *entrypoint)
           * before each EmitVertex call.
           */
          nir_foreach_block(block, function->impl) {
-            nir_foreach_instr(block, instr) {
+            nir_foreach_instr(instr, block) {
                if (instr->type != nir_instr_type_intrinsic)
                   continue;
 
diff --git a/src/compiler/nir/nir_lower_phis_to_scalar.c b/src/compiler/nir/nir_lower_phis_to_scalar.c
index f6c0d1c..a1a679b 100644
--- a/src/compiler/nir/nir_lower_phis_to_scalar.c
+++ b/src/compiler/nir/nir_lower_phis_to_scalar.c
@@ -168,7 +168,7 @@ lower_phis_to_scalar_block(nir_block *block,
 {
    /* Find the last phi node in the block */
    nir_phi_instr *last_phi = NULL;
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       if (instr->type != nir_instr_type_phi)
          break;
 
@@ -178,7 +178,7 @@ lower_phis_to_scalar_block(nir_block *block,
    /* We have to handle the phi nodes in their own pass due to the way
     * we're modifying the linked list of instructions.
     */
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_phi)
          break;
 
diff --git a/src/compiler/nir/nir_lower_samplers.c b/src/compiler/nir/nir_lower_samplers.c
index 9bff20b..43a9723 100644
--- a/src/compiler/nir/nir_lower_samplers.c
+++ b/src/compiler/nir/nir_lower_samplers.c
@@ -160,7 +160,7 @@ lower_impl(nir_function_impl *impl, const struct gl_shader_program *shader_progr
    nir_builder_init(&b, impl);
 
    nir_foreach_block(block, impl) {
-      nir_foreach_instr(block, instr) {
+      nir_foreach_instr(instr, block) {
          if (instr->type == nir_instr_type_tex)
             lower_sampler(nir_instr_as_tex(instr), shader_program, stage, &b);
       }
diff --git a/src/compiler/nir/nir_lower_system_values.c b/src/compiler/nir/nir_lower_system_values.c
index 3f6d8df..12a8524 100644
--- a/src/compiler/nir/nir_lower_system_values.c
+++ b/src/compiler/nir/nir_lower_system_values.c
@@ -33,7 +33,7 @@ convert_block(nir_block *block, nir_builder *b)
 {
    bool progress = false;
 
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c
index 479aec7..fe67803 100644
--- a/src/compiler/nir/nir_lower_tex.c
+++ b/src/compiler/nir/nir_lower_tex.c
@@ -314,7 +314,7 @@ nir_lower_tex_block(nir_block *block, nir_builder *b,
 {
    bool progress = false;
 
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_tex)
          continue;
 
diff --git a/src/compiler/nir/nir_lower_to_source_mods.c b/src/compiler/nir/nir_lower_to_source_mods.c
index b641908..6fe8465 100644
--- a/src/compiler/nir/nir_lower_to_source_mods.c
+++ b/src/compiler/nir/nir_lower_to_source_mods.c
@@ -36,7 +36,7 @@
 static bool
 nir_lower_to_source_mods_block(nir_block *block)
 {
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       if (instr->type != nir_instr_type_alu)
          continue;
 
diff --git a/src/compiler/nir/nir_lower_two_sided_color.c b/src/compiler/nir/nir_lower_two_sided_color.c
index b6c7057..723a97c 100644
--- a/src/compiler/nir/nir_lower_two_sided_color.c
+++ b/src/compiler/nir/nir_lower_two_sided_color.c
@@ -138,7 +138,7 @@ nir_lower_two_sided_color_block(nir_block *block,
 {
    nir_builder *b = &state->b;
 
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
diff --git a/src/compiler/nir/nir_lower_var_copies.c b/src/compiler/nir/nir_lower_var_copies.c
index d0d6452..3fe1c83 100644
--- a/src/compiler/nir/nir_lower_var_copies.c
+++ b/src/compiler/nir/nir_lower_var_copies.c
@@ -160,7 +160,7 @@ lower_var_copies_impl(nir_function_impl *impl)
    void *mem_ctx = ralloc_parent(impl);
 
    nir_foreach_block(block, impl) {
-      nir_foreach_instr_safe(block, instr) {
+      nir_foreach_instr_safe(instr, block) {
          if (instr->type != nir_instr_type_intrinsic)
             continue;
 
diff --git a/src/compiler/nir/nir_lower_vars_to_ssa.c b/src/compiler/nir/nir_lower_vars_to_ssa.c
index 66e0edb..00ed56e 100644
--- a/src/compiler/nir/nir_lower_vars_to_ssa.c
+++ b/src/compiler/nir/nir_lower_vars_to_ssa.c
@@ -407,7 +407,7 @@ static bool
 register_variable_uses_block(nir_block *block,
                              struct lower_variables_state *state)
 {
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
@@ -484,7 +484,7 @@ rename_variables_block(nir_block *block, struct lower_variables_state *state)
    nir_builder b;
    nir_builder_init(&b, state->impl);
 
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
diff --git a/src/compiler/nir/nir_lower_vec_to_movs.c b/src/compiler/nir/nir_lower_vec_to_movs.c
index 0ba3749..002ebf3 100644
--- a/src/compiler/nir/nir_lower_vec_to_movs.c
+++ b/src/compiler/nir/nir_lower_vec_to_movs.c
@@ -215,7 +215,7 @@ lower_vec_to_movs_block(nir_block *block, nir_function_impl *impl)
    bool progress = false;
    nir_shader *shader = impl->function->shader;
 
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_alu)
          continue;
 
diff --git a/src/compiler/nir/nir_move_vec_src_uses_to_dest.c b/src/compiler/nir/nir_move_vec_src_uses_to_dest.c
index a437fe8..8edf091 100644
--- a/src/compiler/nir/nir_move_vec_src_uses_to_dest.c
+++ b/src/compiler/nir/nir_move_vec_src_uses_to_dest.c
@@ -64,7 +64,7 @@ ssa_def_dominates_instr(nir_ssa_def *def, nir_instr *instr)
 static bool
 move_vec_src_uses_to_dest_block(nir_block *block)
 {
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       if (instr->type != nir_instr_type_alu)
          continue;
 
diff --git a/src/compiler/nir/nir_normalize_cubemap_coords.c b/src/compiler/nir/nir_normalize_cubemap_coords.c
index ab17467..002b9cf 100644
--- a/src/compiler/nir/nir_normalize_cubemap_coords.c
+++ b/src/compiler/nir/nir_normalize_cubemap_coords.c
@@ -38,7 +38,7 @@ normalize_cubemap_coords_block(nir_block *block, nir_builder *b)
 {
    bool progress = false;
 
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       if (instr->type != nir_instr_type_tex)
          continue;
 
diff --git a/src/compiler/nir/nir_opt_constant_folding.c b/src/compiler/nir/nir_opt_constant_folding.c
index a3adaec..b10bb23 100644
--- a/src/compiler/nir/nir_opt_constant_folding.c
+++ b/src/compiler/nir/nir_opt_constant_folding.c
@@ -177,7 +177,7 @@ constant_fold_block(nir_block *block, void *mem_ctx)
 {
    bool progress = false;
 
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       switch (instr->type) {
       case nir_instr_type_alu:
          progress |= constant_fold_alu_instr(nir_instr_as_alu(instr), mem_ctx);
diff --git a/src/compiler/nir/nir_opt_copy_propagate.c b/src/compiler/nir/nir_opt_copy_propagate.c
index 99aebae..6e88077 100644
--- a/src/compiler/nir/nir_opt_copy_propagate.c
+++ b/src/compiler/nir/nir_opt_copy_propagate.c
@@ -246,7 +246,7 @@ nir_copy_prop_impl(nir_function_impl *impl)
    bool progress = false;
 
    nir_foreach_block(block, impl) {
-      nir_foreach_instr(block, instr) {
+      nir_foreach_instr(instr, block) {
          if (copy_prop_instr(instr))
             progress = true;
       }
diff --git a/src/compiler/nir/nir_opt_cse.c b/src/compiler/nir/nir_opt_cse.c
index 364fb02..109b629 100644
--- a/src/compiler/nir/nir_opt_cse.c
+++ b/src/compiler/nir/nir_opt_cse.c
@@ -43,7 +43,7 @@ cse_block(nir_block *block, struct set *instr_set)
 {
    bool progress = false;
 
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (nir_instr_set_add_or_rewrite(instr_set, instr)) {
          progress = true;
          nir_instr_remove(instr);
@@ -55,7 +55,7 @@ cse_block(nir_block *block, struct set *instr_set)
       progress |= cse_block(child, instr_set);
    }
 
-   nir_foreach_instr(block, instr)
+   nir_foreach_instr(instr, block)
      nir_instr_set_remove(instr_set, instr);
 
    return progress;
diff --git a/src/compiler/nir/nir_opt_dce.c b/src/compiler/nir/nir_opt_dce.c
index d94f4be..f7dd7be 100644
--- a/src/compiler/nir/nir_opt_dce.c
+++ b/src/compiler/nir/nir_opt_dce.c
@@ -115,7 +115,7 @@ init_instr(nir_instr *instr, struct exec_list *worklist)
 static bool
 init_block(nir_block *block, struct exec_list *worklist)
 {
-   nir_foreach_instr(block, instr)
+   nir_foreach_instr(instr, block)
       init_instr(instr, worklist);
 
    nir_if *following_if = nir_block_get_following_if(block);
@@ -148,7 +148,7 @@ nir_opt_dce_impl(nir_function_impl *impl)
    bool progress = false;
 
    nir_foreach_block(block, impl) {
-      nir_foreach_instr_safe(block, instr) {
+      nir_foreach_instr_safe(instr, block) {
          if (!instr->pass_flags) {
             nir_instr_remove(instr);
             progress = true;
diff --git a/src/compiler/nir/nir_opt_dead_cf.c b/src/compiler/nir/nir_opt_dead_cf.c
index a8506b7..ca73e50 100644
--- a/src/compiler/nir/nir_opt_dead_cf.c
+++ b/src/compiler/nir/nir_opt_dead_cf.c
@@ -91,7 +91,7 @@ opt_constant_if(nir_if *if_stmt, bool condition)
       nir_cf_node_as_block(condition ? nir_if_last_then_node(if_stmt)
                                      : nir_if_last_else_node(if_stmt));
 
-   nir_foreach_instr_safe(after, instr) {
+   nir_foreach_instr_safe(instr, after) {
       if (instr->type != nir_instr_type_phi)
          break;
 
@@ -138,7 +138,7 @@ static bool
 cf_node_has_side_effects(nir_cf_node *node)
 {
    nir_foreach_block_in_cf_node(block, node) {
-      nir_foreach_instr(block, instr) {
+      nir_foreach_instr(instr, block) {
          if (instr->type == nir_instr_type_call)
             return true;
 
@@ -207,7 +207,7 @@ loop_is_dead(nir_loop *loop)
                               nir_metadata_dominance);
 
    for (nir_block *cur = after->imm_dom; cur != before; cur = cur->imm_dom) {
-      nir_foreach_instr(cur, instr) {
+      nir_foreach_instr(instr, cur) {
          if (!nir_foreach_ssa_def(instr, def_not_live_out, after))
             return false;
       }
diff --git a/src/compiler/nir/nir_opt_gcm.c b/src/compiler/nir/nir_opt_gcm.c
index 33278d8..d79235d 100644
--- a/src/compiler/nir/nir_opt_gcm.c
+++ b/src/compiler/nir/nir_opt_gcm.c
@@ -107,7 +107,7 @@ gcm_build_block_info(struct exec_list *cf_list, struct gcm_state *state,
 static bool
 gcm_pin_instructions_block(nir_block *block, struct gcm_state *state)
 {
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       switch (instr->type) {
       case nir_instr_type_alu:
          switch (nir_instr_as_alu(instr)->op) {
diff --git a/src/compiler/nir/nir_opt_peephole_select.c b/src/compiler/nir/nir_opt_peephole_select.c
index d783f7b..b31cc35 100644
--- a/src/compiler/nir/nir_opt_peephole_select.c
+++ b/src/compiler/nir/nir_opt_peephole_select.c
@@ -50,7 +50,7 @@
 static bool
 block_check_for_allowed_instrs(nir_block *block)
 {
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       switch (instr->type) {
       case nir_instr_type_intrinsic: {
          nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
@@ -171,19 +171,19 @@ nir_opt_peephole_select_block(nir_block *block, void *mem_ctx)
     * block before.  We have already guaranteed that this is safe by
     * calling block_check_for_allowed_instrs()
     */
-   nir_foreach_instr_safe(then_block, instr) {
+   nir_foreach_instr_safe(instr, then_block) {
       exec_node_remove(&instr->node);
       instr->block = prev_block;
       exec_list_push_tail(&prev_block->instr_list, &instr->node);
    }
 
-   nir_foreach_instr_safe(else_block, instr) {
+   nir_foreach_instr_safe(instr, else_block) {
       exec_node_remove(&instr->node);
       instr->block = prev_block;
       exec_list_push_tail(&prev_block->instr_list, &instr->node);
    }
 
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_phi)
          break;
 
diff --git a/src/compiler/nir/nir_opt_remove_phis.c b/src/compiler/nir/nir_opt_remove_phis.c
index 0625297..5234c0f 100644
--- a/src/compiler/nir/nir_opt_remove_phis.c
+++ b/src/compiler/nir/nir_opt_remove_phis.c
@@ -47,7 +47,7 @@ remove_phis_block(nir_block *block)
 {
    bool progress = false;
 
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_phi)
          break;
 
diff --git a/src/compiler/nir/nir_opt_undef.c b/src/compiler/nir/nir_opt_undef.c
index 87c23b3..f4c41c1 100644
--- a/src/compiler/nir/nir_opt_undef.c
+++ b/src/compiler/nir/nir_opt_undef.c
@@ -79,7 +79,7 @@ nir_opt_undef(nir_shader *shader)
    nir_foreach_function(shader, function) {
       if (function->impl) {
          nir_foreach_block(block, function->impl) {
-            nir_foreach_instr_safe(block, instr) {
+            nir_foreach_instr_safe(instr, block) {
                if (instr->type == nir_instr_type_alu)
                   if (opt_undef_alu(nir_instr_as_alu(instr)))
                       progress = true;
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index 229539d..76effa9 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -908,7 +908,7 @@ print_block(nir_block *block, print_state *state, unsigned tabs)
 
    free(preds);
 
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       print_instr(instr, state, tabs);
       fprintf(fp, "\n");
    }
diff --git a/src/compiler/nir/nir_remove_dead_variables.c b/src/compiler/nir/nir_remove_dead_variables.c
index c48fa40..1f3561d 100644
--- a/src/compiler/nir/nir_remove_dead_variables.c
+++ b/src/compiler/nir/nir_remove_dead_variables.c
@@ -71,7 +71,7 @@ add_var_use_shader(nir_shader *shader, struct set *live)
    nir_foreach_function(shader, function) {
       if (function->impl) {
          nir_foreach_block(block, function->impl) {
-            nir_foreach_instr(block, instr) {
+            nir_foreach_instr(instr, block) {
                switch(instr->type) {
                case nir_instr_type_intrinsic:
                   add_var_use_intrinsic(nir_instr_as_intrinsic(instr), live);
diff --git a/src/compiler/nir/nir_repair_ssa.c b/src/compiler/nir/nir_repair_ssa.c
index ac0bce1..7dd4065 100644
--- a/src/compiler/nir/nir_repair_ssa.c
+++ b/src/compiler/nir/nir_repair_ssa.c
@@ -114,7 +114,7 @@ nir_repair_ssa_impl(nir_function_impl *impl)
                               nir_metadata_dominance);
 
    nir_foreach_block(block, impl) {
-      nir_foreach_instr_safe(block, instr) {
+      nir_foreach_instr_safe(instr, block) {
          nir_foreach_ssa_def(instr, repair_ssa_def, &state);
       }
    }
diff --git a/src/compiler/nir/nir_split_var_copies.c b/src/compiler/nir/nir_split_var_copies.c
index da82e7c..8ac65bf 100644
--- a/src/compiler/nir/nir_split_var_copies.c
+++ b/src/compiler/nir/nir_split_var_copies.c
@@ -208,7 +208,7 @@ split_var_copy_instr(nir_intrinsic_instr *old_copy,
 static bool
 split_var_copies_block(nir_block *block, struct split_var_copies_state *state)
 {
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
diff --git a/src/compiler/nir/nir_sweep.c b/src/compiler/nir/nir_sweep.c
index b22f0f5..0f1debc 100644
--- a/src/compiler/nir/nir_sweep.c
+++ b/src/compiler/nir/nir_sweep.c
@@ -63,7 +63,7 @@ sweep_block(nir_shader *nir, nir_block *block)
 {
    ralloc_steal(nir, block);
 
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       ralloc_steal(nir, instr);
 
       nir_foreach_src(instr, sweep_src_indirect, nir);
diff --git a/src/compiler/nir/nir_to_ssa.c b/src/compiler/nir/nir_to_ssa.c
index 1a772ff..7668491 100644
--- a/src/compiler/nir/nir_to_ssa.c
+++ b/src/compiler/nir/nir_to_ssa.c
@@ -381,7 +381,7 @@ rewrite_instr_forward(nir_instr *instr, rewrite_state *state)
 static void
 rewrite_phi_sources(nir_block *block, nir_block *pred, rewrite_state *state)
 {
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       if (instr->type != nir_instr_type_phi)
          break;
 
@@ -434,7 +434,7 @@ rewrite_block(nir_block *block, rewrite_state *state)
     * what we want because those instructions (vector gather, conditional
     * select) will already be in SSA form.
     */
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       rewrite_instr_forward(instr, state);
    }
 
@@ -455,7 +455,7 @@ rewrite_block(nir_block *block, rewrite_state *state)
    for (unsigned i = 0; i < block->num_dom_children; i++)
       rewrite_block(block->dom_children[i], state);
 
-   nir_foreach_instr_reverse(block, instr) {
+   nir_foreach_instr_reverse(instr, block) {
       rewrite_instr_backwards(instr, state);
    }
 }
diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c
index c7cef6a..10a7832 100644
--- a/src/compiler/nir/nir_validate.c
+++ b/src/compiler/nir/nir_validate.c
@@ -606,7 +606,7 @@ validate_phi_src(nir_phi_instr *instr, nir_block *pred, validate_state *state)
 static void
 validate_phi_srcs(nir_block *block, nir_block *succ, validate_state *state)
 {
-   nir_foreach_instr(succ, instr) {
+   nir_foreach_instr(instr, succ) {
       if (instr->type != nir_instr_type_phi)
          break;
 
@@ -624,7 +624,7 @@ validate_block(nir_block *block, validate_state *state)
    state->block = block;
 
    exec_list_validate(&block->instr_list);
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       if (instr->type == nir_instr_type_phi) {
          assert(instr == nir_block_first_instr(block) ||
                 nir_instr_prev(instr)->type == nir_instr_type_phi);
@@ -1017,7 +1017,7 @@ validate_function_impl(nir_function_impl *impl, validate_state *state)
    }
 
    nir_foreach_block(block, impl) {
-      nir_foreach_instr(block, instr)
+      nir_foreach_instr(instr, block)
          nir_foreach_ssa_def(instr, postvalidate_ssa_def, state);
    }
 }
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
index abdb1c2..9bac664 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
@@ -1811,7 +1811,7 @@ emit_block(struct ir3_compile *ctx, nir_block *nblock)
 	_mesa_hash_table_destroy(ctx->addr_ht, NULL);
 	ctx->addr_ht = NULL;
 
-	nir_foreach_instr(nblock, instr) {
+	nir_foreach_instr(instr, nblock) {
 		emit_instr(ctx, instr);
 		if (ctx->error)
 			return;
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir_lower_if_else.c b/src/gallium/drivers/freedreno/ir3/ir3_nir_lower_if_else.c
index 4beba34..09c93da 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_nir_lower_if_else.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_nir_lower_if_else.c
@@ -90,7 +90,7 @@ valid_dest(nir_block *block, nir_dest *dest)
 static bool
 block_check_for_allowed_instrs(nir_block *block)
 {
-	nir_foreach_instr(block, instr) {
+	nir_foreach_instr(instr, block) {
 		switch (instr->type) {
 		case nir_instr_type_intrinsic: {
 			nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
@@ -159,7 +159,7 @@ static void
 flatten_block(nir_builder *bld, nir_block *if_block, nir_block *prev_block,
 		nir_ssa_def *condition, bool invert)
 {
-	nir_foreach_instr_safe(if_block, instr) {
+	nir_foreach_instr_safe(instr, if_block) {
 		if (instr->type == nir_instr_type_intrinsic) {
 			nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
 			if ((intr->intrinsic == nir_intrinsic_discard) ||
@@ -262,7 +262,7 @@ lower_if_else_block(nir_block *block, nir_builder *b, void *mem_ctx)
 	flatten_block(b, else_block, prev_block,
 			if_stmt->condition.ssa, true);
 
-	nir_foreach_instr_safe(block, instr) {
+	nir_foreach_instr_safe(instr, block) {
 		if (instr->type != nir_instr_type_phi)
 			break;
 
diff --git a/src/gallium/drivers/vc4/vc4_nir_lower_blend.c b/src/gallium/drivers/vc4/vc4_nir_lower_blend.c
index c278405..7dea043 100644
--- a/src/gallium/drivers/vc4/vc4_nir_lower_blend.c
+++ b/src/gallium/drivers/vc4/vc4_nir_lower_blend.c
@@ -676,7 +676,7 @@ vc4_nir_lower_blend_instr(struct vc4_compile *c, nir_builder *b,
 static bool
 vc4_nir_lower_blend_block(nir_block *block, struct vc4_compile *c)
 {
-        nir_foreach_instr_safe(block, instr) {
+        nir_foreach_instr_safe(instr, block) {
                 if (instr->type != nir_instr_type_intrinsic)
                         continue;
                 nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
diff --git a/src/gallium/drivers/vc4/vc4_nir_lower_io.c b/src/gallium/drivers/vc4/vc4_nir_lower_io.c
index 53f462f..f709cb1 100644
--- a/src/gallium/drivers/vc4/vc4_nir_lower_io.c
+++ b/src/gallium/drivers/vc4/vc4_nir_lower_io.c
@@ -434,7 +434,7 @@ vc4_nir_lower_io_impl(struct vc4_compile *c, nir_function_impl *impl)
         nir_builder_init(&b, impl);
 
         nir_foreach_block(block, impl) {
-                nir_foreach_instr_safe(block, instr)
+                nir_foreach_instr_safe(instr, block)
                         vc4_nir_lower_io_instr(c, &b, instr);
         }
 
diff --git a/src/gallium/drivers/vc4/vc4_nir_lower_txf_ms.c b/src/gallium/drivers/vc4/vc4_nir_lower_txf_ms.c
index 1b4946d..b1c370e 100644
--- a/src/gallium/drivers/vc4/vc4_nir_lower_txf_ms.c
+++ b/src/gallium/drivers/vc4/vc4_nir_lower_txf_ms.c
@@ -136,7 +136,7 @@ vc4_nir_lower_txf_ms_impl(struct vc4_compile *c, nir_function_impl *impl)
         nir_builder_init(&b, impl);
 
         nir_foreach_block(block, impl) {
-                nir_foreach_instr_safe(block, instr) {
+                nir_foreach_instr_safe(instr, block) {
                         if (instr->type == nir_instr_type_tex) {
                                 vc4_nir_lower_txf_ms_instr(c, &b,
                                                 nir_instr_as_tex(instr));
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index da38431..96ed2af 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -1694,7 +1694,7 @@ ntq_emit_instr(struct vc4_compile *c, nir_instr *instr)
 static void
 ntq_emit_block(struct vc4_compile *c, nir_block *block)
 {
-        nir_foreach_instr(block, instr) {
+        nir_foreach_instr(instr, block) {
                 ntq_emit_instr(c, instr);
         }
 }
@@ -1785,7 +1785,7 @@ count_nir_instrs(nir_shader *nir)
                 if (!function->impl)
                         continue;
                 nir_foreach_block(block, function->impl) {
-                        nir_foreach_instr(block, instr)
+                        nir_foreach_instr(instr, block)
                                 count++;
                 }
         }
diff --git a/src/intel/vulkan/anv_nir_apply_dynamic_offsets.c b/src/intel/vulkan/anv_nir_apply_dynamic_offsets.c
index a5a7f63..3252a5e 100644
--- a/src/intel/vulkan/anv_nir_apply_dynamic_offsets.c
+++ b/src/intel/vulkan/anv_nir_apply_dynamic_offsets.c
@@ -31,7 +31,7 @@ apply_dynamic_offsets_block(nir_block *block, nir_builder *b,
 {
    struct anv_descriptor_set_layout *set_layout;
 
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
diff --git a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
index dc3f989..e1fec77 100644
--- a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
+++ b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
@@ -54,7 +54,7 @@ static void
 get_used_bindings_block(nir_block *block,
                         struct apply_pipeline_layout_state *state)
 {
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       switch (instr->type) {
       case nir_instr_type_intrinsic: {
          nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
@@ -212,7 +212,7 @@ static void
 apply_pipeline_layout_block(nir_block *block,
                             struct apply_pipeline_layout_state *state)
 {
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       switch (instr->type) {
       case nir_instr_type_intrinsic: {
          nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
diff --git a/src/intel/vulkan/anv_nir_lower_push_constants.c b/src/intel/vulkan/anv_nir_lower_push_constants.c
index 2d84100..ea39dc3 100644
--- a/src/intel/vulkan/anv_nir_lower_push_constants.c
+++ b/src/intel/vulkan/anv_nir_lower_push_constants.c
@@ -31,7 +31,7 @@ anv_nir_lower_push_constants(nir_shader *shader)
          continue;
 
       nir_foreach_block(block, function->impl) {
-         nir_foreach_instr(block, instr) {
+         nir_foreach_instr(instr, block) {
             if (instr->type != nir_instr_type_intrinsic)
                continue;
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index f22742d..beadb28 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -185,7 +185,7 @@ emit_system_values_block(nir_block *block, fs_visitor *v)
 {
    fs_reg *reg;
 
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
@@ -432,7 +432,7 @@ fs_visitor::nir_emit_loop(nir_loop *loop)
 void
 fs_visitor::nir_emit_block(nir_block *block)
 {
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       nir_emit_instr(instr);
    }
 }
diff --git a/src/mesa/drivers/dri/i965/brw_nir.c b/src/mesa/drivers/dri/i965/brw_nir.c
index 3dd5f07..7ee2a8f 100644
--- a/src/mesa/drivers/dri/i965/brw_nir.c
+++ b/src/mesa/drivers/dri/i965/brw_nir.c
@@ -59,7 +59,7 @@ static bool
 add_const_offset_to_base_block(nir_block *block, nir_builder *b,
                                nir_variable_mode mode)
 {
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
@@ -98,7 +98,7 @@ add_const_offset_to_base(nir_shader *nir, nir_variable_mode mode)
 static bool
 remap_vs_attrs(nir_block *block, GLbitfield64 inputs_read)
 {
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
@@ -122,7 +122,7 @@ remap_vs_attrs(nir_block *block, GLbitfield64 inputs_read)
 static bool
 remap_inputs_with_vue_map(nir_block *block, const struct brw_vue_map *vue_map)
 {
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
@@ -142,7 +142,7 @@ static bool
 remap_patch_urb_offsets(nir_block *block, nir_builder *b,
                         const struct brw_vue_map *vue_map)
 {
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
diff --git a/src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c b/src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c
index e09329f..16eaacd 100644
--- a/src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c
+++ b/src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c
@@ -86,7 +86,7 @@ src_mark_needs_resolve(nir_src *src, void *void_state)
 static bool
 analyze_boolean_resolves_block(nir_block *block)
 {
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       switch (instr->type) {
       case nir_instr_type_alu: {
          /* For ALU instructions, the resolve status is handled in a
diff --git a/src/mesa/drivers/dri/i965/brw_nir_attribute_workarounds.c b/src/mesa/drivers/dri/i965/brw_nir_attribute_workarounds.c
index c21e16d..93beab4 100644
--- a/src/mesa/drivers/dri/i965/brw_nir_attribute_workarounds.c
+++ b/src/mesa/drivers/dri/i965/brw_nir_attribute_workarounds.c
@@ -43,7 +43,7 @@ apply_attr_wa_block(nir_block *block, struct attr_wa_state *state)
 {
    nir_builder *b = &state->builder;
 
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
diff --git a/src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c b/src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c
index b571bb9..acc9e80 100644
--- a/src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c
+++ b/src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c
@@ -171,7 +171,7 @@ brw_nir_opt_peephole_ffma_block(nir_block *block, void *mem_ctx)
 {
    bool progress = false;
 
-   nir_foreach_instr_safe(block, instr) {
+   nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_alu)
          continue;
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
index 2694905..c988942 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
@@ -100,7 +100,7 @@ vec4_visitor::nir_setup_system_value_intrinsic(nir_intrinsic_instr *instr)
 static bool
 setup_system_values_block(nir_block *block, vec4_visitor *v)
 {
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       if (instr->type != nir_instr_type_intrinsic)
          continue;
 
@@ -213,7 +213,7 @@ vec4_visitor::nir_emit_loop(nir_loop *loop)
 void
 vec4_visitor::nir_emit_block(nir_block *block)
 {
-   nir_foreach_instr(block, instr) {
+   nir_foreach_instr(instr, block) {
       nir_emit_instr(instr);
    }
 }
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list