diff options
author | Jason Ekstrand <[email protected]> | 2015-01-28 16:29:21 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-01-29 17:07:45 -0800 |
commit | 026b5cc79274af4a681d3ef41ccfd3b5fa5dc050 (patch) | |
tree | e1cd37daf11ba9959350897bfbb3286f130fdbec /src/glsl/nir/nir_search.c | |
parent | d8999bcdce6a3c8ab63f06c7028fd6e927bb9acb (diff) |
nir/search: Allow for matching variables based on types
This allows you to match on an unknown value but only if it is of a given
type. 90% of the uses of this are for matching only booleans, but adding
the generality of arbitrary types is no more complex.
nir_algebraic.py doesn't handle this yet but that's ok because the C
language will ensure that the default type on all variables is void.
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/glsl/nir/nir_search.c')
-rw-r--r-- | src/glsl/nir/nir_search.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/glsl/nir/nir_search.c b/src/glsl/nir/nir_search.c index ec898174364..467193112d2 100644 --- a/src/glsl/nir/nir_search.c +++ b/src/glsl/nir/nir_search.c @@ -82,6 +82,17 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src, instr->src[src].src.ssa->parent_instr->type != nir_instr_type_load_const) return false; + if (var->type != nir_type_invalid) { + if (instr->src[src].src.ssa->parent_instr->type != nir_instr_type_alu) + return false; + + nir_alu_instr *src_alu = + nir_instr_as_alu(instr->src[src].src.ssa->parent_instr); + + if (nir_op_infos[src_alu->op].output_type != var->type) + return false; + } + state->variables_seen |= (1 << var->variable); state->variables[var->variable].src = instr->src[src].src; state->variables[var->variable].abs = false; |