summaryrefslogtreecommitdiffstats
path: root/src/glsl/nir/nir.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-02-03 21:04:57 -0800
committerJason Ekstrand <[email protected]>2015-02-19 17:06:17 -0800
commite025943134ada9dad02926e8191dd1bd2e7fc95e (patch)
tree7bdc188c1b1a466b6d0eb0ff2bbc6846bb455d2e /src/glsl/nir/nir.c
parent0167c38cacc00eef77d7f83d3929cdbc99378d11 (diff)
nir: use nir_foreach_ssa_def for indexing ssa defs
This is both simpler and more correct. The old code didn't properly index load_const instructions. Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/glsl/nir/nir.c')
-rw-r--r--src/glsl/nir/nir.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
index 0d8c80ae55b..3b78766e6a2 100644
--- a/src/glsl/nir/nir.c
+++ b/src/glsl/nir/nir.c
@@ -2004,38 +2004,20 @@ nir_index_blocks(nir_function_impl *impl)
impl->num_blocks = index;
}
-static void
-index_ssa_def(nir_ssa_def *def, unsigned *index)
+static bool
+index_ssa_def_cb(nir_ssa_def *def, void *state)
{
+ unsigned *index = (unsigned *) state;
def->index = (*index)++;
-}
-static bool
-index_ssa_def_cb(nir_dest *dest, void *state)
-{
- unsigned *index = state;
- if (dest->is_ssa)
- index_ssa_def(&dest->ssa, index);
return true;
}
-static void
-index_ssa_undef(nir_ssa_undef_instr *instr, unsigned *index)
-{
- index_ssa_def(&instr->def, index);
-}
-
static bool
index_ssa_block(nir_block *block, void *state)
{
- unsigned *index = state;
-
- nir_foreach_instr(block, instr) {
- if (instr->type == nir_instr_type_ssa_undef)
- index_ssa_undef(nir_instr_as_ssa_undef(instr), index);
- else
- nir_foreach_dest(instr, index_ssa_def_cb, state);
- }
+ nir_foreach_instr(block, instr)
+ nir_foreach_ssa_def(instr, index_ssa_def_cb, state);
return true;
}