summaryrefslogtreecommitdiffstats
path: root/src/glsl/nir/nir.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-04-24 10:34:30 -0700
committerJason Ekstrand <[email protected]>2015-05-08 17:16:13 -0700
commitf72a8d1cf06da55c215a61c085e1f29a5102182b (patch)
treed8278287ddef5c488e042c59eb70eefdd2140f3a /src/glsl/nir/nir.c
parent300d72943675a49091ecb49597b56f7bdfefd22d (diff)
nir: Add a function for rewriting the condition of an if statement
Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/glsl/nir/nir.c')
-rw-r--r--src/glsl/nir/nir.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
index 4cc074b808f..b8f5dd491a4 100644
--- a/src/glsl/nir/nir.c
+++ b/src/glsl/nir/nir.c
@@ -1895,6 +1895,28 @@ nir_instr_rewrite_src(nir_instr *instr, nir_src *src, nir_src new_src)
}
void
+nir_if_rewrite_condition(nir_if *if_stmt, nir_src new_src)
+{
+ for (nir_src *src = &if_stmt->condition; src;
+ src = src->is_ssa ? NULL : src->reg.indirect) {
+ struct set *uses = src->is_ssa ? src->ssa->if_uses
+ : src->reg.reg->if_uses;
+ struct set_entry *entry = _mesa_set_search(uses, if_stmt);
+ assert(entry);
+ _mesa_set_remove(uses, entry);
+ }
+
+ if_stmt->condition = new_src;
+
+ for (nir_src *src = &if_stmt->condition; src;
+ src = src->is_ssa ? NULL : src->reg.indirect) {
+ struct set *uses = src->is_ssa ? src->ssa->if_uses
+ : src->reg.reg->if_uses;
+ _mesa_set_add(uses, if_stmt);
+ }
+}
+
+void
nir_ssa_def_init(nir_instr *instr, nir_ssa_def *def,
unsigned num_components, const char *name)
{