[Mesa-dev] [PATCH 3/7] nir/search: Make nir_replace_instr take a value for the search expression
Jason Ekstrand
jason at jlekstrand.net
Fri May 27 01:30:33 UTC 2016
---
src/compiler/nir/nir_algebraic.py | 4 ++--
src/compiler/nir/nir_search.c | 12 ++++++++----
src/compiler/nir/nir_search.h | 2 +-
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py
index 285f853..b4df8c8 100644
--- a/src/compiler/nir/nir_algebraic.py
+++ b/src/compiler/nir/nir_algebraic.py
@@ -498,7 +498,7 @@ _algebraic_pass_template = mako.template.Template("""
#define NIR_OPT_ALGEBRAIC_STRUCT_DEFS
struct transform {
- const nir_search_expression *search;
+ const nir_search_value *search;
const nir_search_value *replace;
unsigned condition_offset;
};
@@ -513,7 +513,7 @@ struct transform {
static const struct transform ${pass_name}_${opcode}_xforms[] = {
% for xform in xform_list:
- { &${xform.search.name}, ${xform.replace.c_ptr}, ${xform.condition_index} },
+ { ${xform.search.c_ptr}, ${xform.replace.c_ptr}, ${xform.condition_index} },
% endfor
};
% endfor
diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c
index 2c2fd92..6e8c829d 100644
--- a/src/compiler/nir/nir_search.c
+++ b/src/compiler/nir/nir_search.c
@@ -36,7 +36,7 @@ struct match_state {
};
static bool
-match_expression(const nir_search_expression *expr, nir_alu_instr *instr,
+match_expression(const nir_search_value *expr, nir_alu_instr *instr,
unsigned num_components, const uint8_t *swizzle,
struct match_state *state);
@@ -101,7 +101,7 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,
if (instr->src[src].src.ssa->parent_instr->type != nir_instr_type_alu)
return false;
- return match_expression(nir_search_value_as_expression(value),
+ return match_expression(value,
nir_instr_as_alu(instr->src[src].src.ssa->parent_instr),
num_components, new_swizzle, state);
@@ -239,10 +239,12 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,
}
static bool
-match_expression(const nir_search_expression *expr, nir_alu_instr *instr,
+match_expression(const nir_search_value *expr_val, nir_alu_instr *instr,
unsigned num_components, const uint8_t *swizzle,
struct match_state *state)
{
+ nir_search_expression *expr = nir_search_value_as_expression(expr_val);
+
if (instr->op != expr->opcode)
return false;
@@ -561,9 +563,11 @@ construct_value(const nir_search_value *value,
}
nir_alu_instr *
-nir_replace_instr(nir_alu_instr *instr, const nir_search_expression *search,
+nir_replace_instr(nir_alu_instr *instr, const nir_search_value *search,
const nir_search_value *replace, void *mem_ctx)
{
+ assert(search->type == nir_search_value_expression);
+
uint8_t swizzle[4] = { 0, 0, 0, 0 };
for (unsigned i = 0; i < instr->dest.dest.ssa.num_components; ++i)
diff --git a/src/compiler/nir/nir_search.h b/src/compiler/nir/nir_search.h
index a500feb..888a2a3 100644
--- a/src/compiler/nir/nir_search.h
+++ b/src/compiler/nir/nir_search.h
@@ -103,7 +103,7 @@ NIR_DEFINE_CAST(nir_search_value_as_expression, nir_search_value,
nir_search_expression, value)
nir_alu_instr *
-nir_replace_instr(nir_alu_instr *instr, const nir_search_expression *search,
+nir_replace_instr(nir_alu_instr *instr, const nir_search_value *search,
const nir_search_value *replace, void *mem_ctx);
#endif /* _NIR_SEARCH_ */
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list