aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-04-26 20:30:10 -0700
committerJason Ekstrand <[email protected]>2016-04-28 15:54:48 -0700
commit5015260a0598ada4865b2c6086fc669505f64749 (patch)
tree5525c401e8a64983d4db83fd08d61209aae24700 /src/compiler/nir
parent9464d8c49813aba77285e7465b96e92a91ed327c (diff)
nir: Switch the arguments to nir_foreach_use and friends
This matches the "foreach x in container" pattern found in many other programming languages. Generated by the following regular expression: s/nir_foreach_use(\([^,]*\),\s*\([^,]*\))/nir_foreach_use(\2, \1)/ and similar expressions for nir_foreach_use_safe, etc. Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r--src/compiler/nir/nir.c10
-rw-r--r--src/compiler/nir/nir.h8
-rw-r--r--src/compiler/nir/nir_lower_to_source_mods.c4
-rw-r--r--src/compiler/nir/nir_lower_vec_to_movs.c2
-rw-r--r--src/compiler/nir/nir_move_vec_src_uses_to_dest.c2
-rw-r--r--src/compiler/nir/nir_opt_gcm.c6
-rw-r--r--src/compiler/nir/nir_opt_global_to_local.c4
-rw-r--r--src/compiler/nir/nir_opt_peephole_select.c2
-rw-r--r--src/compiler/nir/nir_repair_ssa.c4
-rw-r--r--src/compiler/nir/nir_validate.c8
10 files changed, 25 insertions, 25 deletions
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 0a8b0836ab0..867a43cefbd 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -1419,10 +1419,10 @@ nir_ssa_def_rewrite_uses(nir_ssa_def *def, nir_src new_src)
{
assert(!new_src.is_ssa || def != new_src.ssa);
- nir_foreach_use_safe(def, use_src)
+ nir_foreach_use_safe(use_src, def)
nir_instr_rewrite_src(use_src->parent_instr, use_src, new_src);
- nir_foreach_if_use_safe(def, use_src)
+ nir_foreach_if_use_safe(use_src, def)
nir_if_rewrite_condition(use_src->parent_if, new_src);
}
@@ -1462,7 +1462,7 @@ nir_ssa_def_rewrite_uses_after(nir_ssa_def *def, nir_src new_src,
{
assert(!new_src.is_ssa || def != new_src.ssa);
- nir_foreach_use_safe(def, use_src) {
+ nir_foreach_use_safe(use_src, def) {
assert(use_src->parent_instr != def->parent_instr);
/* Since def already dominates all of its uses, the only way a use can
* not be dominated by after_me is if it is between def and after_me in
@@ -1472,7 +1472,7 @@ nir_ssa_def_rewrite_uses_after(nir_ssa_def *def, nir_src new_src,
nir_instr_rewrite_src(use_src->parent_instr, use_src, new_src);
}
- nir_foreach_if_use_safe(def, use_src)
+ nir_foreach_if_use_safe(use_src, def)
nir_if_rewrite_condition(use_src->parent_if, new_src);
}
@@ -1480,7 +1480,7 @@ uint8_t
nir_ssa_def_components_read(nir_ssa_def *def)
{
uint8_t read_mask = 0;
- nir_foreach_use(def, use) {
+ nir_foreach_use(use, def) {
if (use->parent_instr->type == nir_instr_type_alu) {
nir_alu_instr *alu = nir_instr_as_alu(use->parent_instr);
nir_alu_src *alu_src = exec_node_data(nir_alu_src, use, src);
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index da502bf05c0..215b25a70be 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -516,16 +516,16 @@ nir_src_init(void)
#define NIR_SRC_INIT nir_src_init()
-#define nir_foreach_use(reg_or_ssa_def, src) \
+#define nir_foreach_use(src, reg_or_ssa_def) \
list_for_each_entry(nir_src, src, &(reg_or_ssa_def)->uses, use_link)
-#define nir_foreach_use_safe(reg_or_ssa_def, src) \
+#define nir_foreach_use_safe(src, reg_or_ssa_def) \
list_for_each_entry_safe(nir_src, src, &(reg_or_ssa_def)->uses, use_link)
-#define nir_foreach_if_use(reg_or_ssa_def, src) \
+#define nir_foreach_if_use(src, reg_or_ssa_def) \
list_for_each_entry(nir_src, src, &(reg_or_ssa_def)->if_uses, use_link)
-#define nir_foreach_if_use_safe(reg_or_ssa_def, src) \
+#define nir_foreach_if_use_safe(src, reg_or_ssa_def) \
list_for_each_entry_safe(nir_src, src, &(reg_or_ssa_def)->if_uses, use_link)
typedef struct {
diff --git a/src/compiler/nir/nir_lower_to_source_mods.c b/src/compiler/nir/nir_lower_to_source_mods.c
index b5f165002d1..7a1507ced5f 100644
--- a/src/compiler/nir/nir_lower_to_source_mods.c
+++ b/src/compiler/nir/nir_lower_to_source_mods.c
@@ -136,7 +136,7 @@ nir_lower_to_source_mods_block(nir_block *block)
continue;
bool all_children_are_sat = true;
- nir_foreach_use(&alu->dest.dest.ssa, child_src) {
+ nir_foreach_use(child_src, &alu->dest.dest.ssa) {
assert(child_src->is_ssa);
nir_instr *child = child_src->parent_instr;
if (child->type != nir_instr_type_alu) {
@@ -162,7 +162,7 @@ nir_lower_to_source_mods_block(nir_block *block)
alu->dest.saturate = true;
- nir_foreach_use(&alu->dest.dest.ssa, child_src) {
+ nir_foreach_use(child_src, &alu->dest.dest.ssa) {
assert(child_src->is_ssa);
nir_instr *child = child_src->parent_instr;
assert(child->type == nir_instr_type_alu);
diff --git a/src/compiler/nir/nir_lower_vec_to_movs.c b/src/compiler/nir/nir_lower_vec_to_movs.c
index 90619c9fa3a..b383fb8ccf2 100644
--- a/src/compiler/nir/nir_lower_vec_to_movs.c
+++ b/src/compiler/nir/nir_lower_vec_to_movs.c
@@ -131,7 +131,7 @@ try_coalesce(nir_alu_instr *vec, unsigned start_idx, nir_shader *shader)
/* If we are going to do a reswizzle, then the vecN operation must be the
* only use of the source value. We also can't have any source modifiers.
*/
- nir_foreach_use(vec->src[start_idx].src.ssa, src) {
+ nir_foreach_use(src, vec->src[start_idx].src.ssa) {
if (src->parent_instr != &vec->instr)
return 0;
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 30752a2e716..76917752ca4 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
@@ -121,7 +121,7 @@ move_vec_src_uses_to_dest_block(nir_block *block)
swizzle[vec->src[j].swizzle[0]] = j;
}
- nir_foreach_use_safe(vec->src[i].src.ssa, use) {
+ nir_foreach_use_safe(use, vec->src[i].src.ssa) {
if (use->parent_instr == &vec->instr)
continue;
diff --git a/src/compiler/nir/nir_opt_gcm.c b/src/compiler/nir/nir_opt_gcm.c
index 119b74d58bb..ff079b9535b 100644
--- a/src/compiler/nir/nir_opt_gcm.c
+++ b/src/compiler/nir/nir_opt_gcm.c
@@ -277,7 +277,7 @@ gcm_schedule_late_def(nir_ssa_def *def, void *void_state)
nir_block *lca = NULL;
- nir_foreach_use(def, use_src) {
+ nir_foreach_use(use_src, def) {
nir_instr *use_instr = use_src->parent_instr;
gcm_schedule_late_instr(use_instr, state);
@@ -301,7 +301,7 @@ gcm_schedule_late_def(nir_ssa_def *def, void *void_state)
}
}
- nir_foreach_if_use(def, use_src) {
+ nir_foreach_if_use(use_src, def) {
nir_if *if_stmt = use_src->parent_if;
/* For if statements, we consider the block to be the one immediately
@@ -374,7 +374,7 @@ gcm_place_instr(nir_instr *instr, struct gcm_state *state);
static bool
gcm_place_instr_def(nir_ssa_def *def, void *state)
{
- nir_foreach_use(def, use_src)
+ nir_foreach_use(use_src, def)
gcm_place_instr(use_src->parent_instr, state);
return false;
diff --git a/src/compiler/nir/nir_opt_global_to_local.c b/src/compiler/nir/nir_opt_global_to_local.c
index bccb45b6237..3555c7b3179 100644
--- a/src/compiler/nir/nir_opt_global_to_local.c
+++ b/src/compiler/nir/nir_opt_global_to_local.c
@@ -46,7 +46,7 @@ global_to_local(nir_register *reg)
}
}
- nir_foreach_use(reg, use_src) {
+ nir_foreach_use(use_src, reg) {
nir_instr *instr = use_src->parent_instr;
nir_function_impl *instr_impl =
nir_cf_node_get_function(&instr->block->cf_node);
@@ -58,7 +58,7 @@ global_to_local(nir_register *reg)
}
}
- nir_foreach_if_use(reg, use_src) {
+ nir_foreach_if_use(use_src, reg) {
nir_if *if_stmt = use_src->parent_if;
nir_function_impl *if_impl = nir_cf_node_get_function(&if_stmt->cf_node);
if (impl != NULL) {
diff --git a/src/compiler/nir/nir_opt_peephole_select.c b/src/compiler/nir/nir_opt_peephole_select.c
index e06820d3e17..7fcc71ea9d7 100644
--- a/src/compiler/nir/nir_opt_peephole_select.c
+++ b/src/compiler/nir/nir_opt_peephole_select.c
@@ -108,7 +108,7 @@ block_check_for_allowed_instrs(nir_block *block)
return false;
/* The only uses of this definition must be phi's in the successor */
- nir_foreach_use(&mov->dest.dest.ssa, use) {
+ nir_foreach_use(use, &mov->dest.dest.ssa) {
if (use->parent_instr->type != nir_instr_type_phi ||
use->parent_instr->block != block->successors[0])
return false;
diff --git a/src/compiler/nir/nir_repair_ssa.c b/src/compiler/nir/nir_repair_ssa.c
index 7dd23979fcd..b4d22d91c27 100644
--- a/src/compiler/nir/nir_repair_ssa.c
+++ b/src/compiler/nir/nir_repair_ssa.c
@@ -70,7 +70,7 @@ repair_ssa_def(nir_ssa_def *def, void *void_state)
struct repair_ssa_state *state = void_state;
bool is_valid = true;
- nir_foreach_use(def, src) {
+ nir_foreach_use(src, def) {
if (!nir_block_dominates(def->parent_instr->block, get_src_block(src))) {
is_valid = false;
break;
@@ -90,7 +90,7 @@ repair_ssa_def(nir_ssa_def *def, void *void_state)
nir_phi_builder_value_set_block_def(val, def->parent_instr->block, def);
- nir_foreach_use_safe(def, src) {
+ nir_foreach_use_safe(src, def) {
nir_block *src_block = get_src_block(src);
if (!nir_block_dominates(def->parent_instr->block, src_block)) {
nir_instr_rewrite_src(src->parent_instr, src, nir_src_for_ssa(
diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c
index e928c41607b..53cdbc4e324 100644
--- a/src/compiler/nir/nir_validate.c
+++ b/src/compiler/nir/nir_validate.c
@@ -852,7 +852,7 @@ postvalidate_reg_decl(nir_register *reg, validate_state *state)
reg_validate_state *reg_state = (reg_validate_state *) entry->data;
- nir_foreach_use(reg, src) {
+ nir_foreach_use(src, reg) {
struct set_entry *entry = _mesa_set_search(reg_state->uses, src);
assert(entry);
_mesa_set_remove(reg_state->uses, entry);
@@ -867,7 +867,7 @@ postvalidate_reg_decl(nir_register *reg, validate_state *state)
abort();
}
- nir_foreach_if_use(reg, src) {
+ nir_foreach_if_use(src, reg) {
struct set_entry *entry = _mesa_set_search(reg_state->if_uses, src);
assert(entry);
_mesa_set_remove(reg_state->if_uses, entry);
@@ -924,7 +924,7 @@ postvalidate_ssa_def(nir_ssa_def *def, void *void_state)
struct hash_entry *entry = _mesa_hash_table_search(state->ssa_defs, def);
ssa_def_validate_state *def_state = (ssa_def_validate_state *)entry->data;
- nir_foreach_use(def, src) {
+ nir_foreach_use(src, def) {
struct set_entry *entry = _mesa_set_search(def_state->uses, src);
assert(entry);
_mesa_set_remove(def_state->uses, entry);
@@ -939,7 +939,7 @@ postvalidate_ssa_def(nir_ssa_def *def, void *void_state)
abort();
}
- nir_foreach_if_use(def, src) {
+ nir_foreach_if_use(src, def) {
struct set_entry *entry = _mesa_set_search(def_state->if_uses, src);
assert(entry);
_mesa_set_remove(def_state->if_uses, entry);