[Mesa-dev] [PATCH 3/6] nir: Switch the arguments to nir_foreach_parallel_copy_entry

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


This matches the "foreach x in container" pattern found in many other
programming languages.
---
 src/compiler/nir/nir.c          | 4 ++--
 src/compiler/nir/nir.h          | 2 +-
 src/compiler/nir/nir_from_ssa.c | 6 +++---
 src/compiler/nir/nir_print.c    | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 4c283ef..f0c5d59 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -981,7 +981,7 @@ static bool
 visit_parallel_copy_dest(nir_parallel_copy_instr *instr,
                          nir_foreach_dest_cb cb, void *state)
 {
-   nir_foreach_parallel_copy_entry(instr, entry) {
+   nir_foreach_parallel_copy_entry(entry, instr) {
       if (!cb(&entry->dest, state))
          return false;
    }
@@ -1174,7 +1174,7 @@ static bool
 visit_parallel_copy_src(nir_parallel_copy_instr *instr,
                         nir_foreach_src_cb cb, void *state)
 {
-   nir_foreach_parallel_copy_entry(instr, entry) {
+   nir_foreach_parallel_copy_entry(entry, instr) {
       if (!visit_src(&entry->src, cb, state))
          return false;
    }
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index ee6abdd..0e3c84b 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1323,7 +1323,7 @@ typedef struct {
    nir_dest dest;
 } nir_parallel_copy_entry;
 
-#define nir_foreach_parallel_copy_entry(pcopy, entry) \
+#define nir_foreach_parallel_copy_entry(entry, pcopy) \
    foreach_list_typed(nir_parallel_copy_entry, entry, node, &(pcopy)->entries)
 
 typedef struct {
diff --git a/src/compiler/nir/nir_from_ssa.c b/src/compiler/nir/nir_from_ssa.c
index d333752..067e66f 100644
--- a/src/compiler/nir/nir_from_ssa.c
+++ b/src/compiler/nir/nir_from_ssa.c
@@ -395,7 +395,7 @@ static void
 aggressive_coalesce_parallel_copy(nir_parallel_copy_instr *pcopy,
                                  struct from_ssa_state *state)
 {
-   nir_foreach_parallel_copy_entry(pcopy, entry) {
+   nir_foreach_parallel_copy_entry(entry, pcopy) {
       if (!entry->src.is_ssa)
          continue;
 
@@ -582,7 +582,7 @@ resolve_parallel_copy(nir_parallel_copy_instr *pcopy,
                       struct from_ssa_state *state)
 {
    unsigned num_copies = 0;
-   nir_foreach_parallel_copy_entry(pcopy, entry) {
+   nir_foreach_parallel_copy_entry(entry, pcopy) {
       /* Sources may be SSA */
       if (!entry->src.is_ssa && entry->src.reg.reg == entry->dest.reg.reg)
          continue;
@@ -615,7 +615,7 @@ resolve_parallel_copy(nir_parallel_copy_instr *pcopy,
     *  - Predicessors are recorded from sources and destinations
     */
    int num_vals = 0;
-   nir_foreach_parallel_copy_entry(pcopy, entry) {
+   nir_foreach_parallel_copy_entry(entry, pcopy) {
       /* Sources may be SSA */
       if (!entry->src.is_ssa && entry->src.reg.reg == entry->dest.reg.reg)
          continue;
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index e504d88..9a77faf 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -806,7 +806,7 @@ static void
 print_parallel_copy_instr(nir_parallel_copy_instr *instr, print_state *state)
 {
    FILE *fp = state->fp;
-   nir_foreach_parallel_copy_entry(instr, entry) {
+   nir_foreach_parallel_copy_entry(entry, instr) {
       if (&entry->node != exec_list_get_head(&instr->entries))
          fprintf(fp, "; ");
 
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list