nir: Slightly simplify algebraic code generation by reusing a struct.
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
This commit is contained in:
parent
9e35af08af
commit
6706537dd4
|
@ -179,10 +179,7 @@ struct transform {
|
||||||
${xform.replace.render()}
|
${xform.replace.render()}
|
||||||
% endfor
|
% endfor
|
||||||
|
|
||||||
static const struct {
|
static const struct transform ${pass_name}_${opcode}_xforms[] = {
|
||||||
const nir_search_expression *search;
|
|
||||||
const nir_search_value *replace;
|
|
||||||
} ${pass_name}_${opcode}_xforms[] = {
|
|
||||||
% for xform in xform_list:
|
% for xform in xform_list:
|
||||||
{ &${xform.search.name}, ${xform.replace.c_ptr} },
|
{ &${xform.search.name}, ${xform.replace.c_ptr} },
|
||||||
% endfor
|
% endfor
|
||||||
|
@ -211,8 +208,8 @@ ${pass_name}_block(nir_block *block, void *void_state)
|
||||||
% for opcode in xform_dict.keys():
|
% for opcode in xform_dict.keys():
|
||||||
case nir_op_${opcode}:
|
case nir_op_${opcode}:
|
||||||
for (unsigned i = 0; i < ARRAY_SIZE(${pass_name}_${opcode}_xforms); i++) {
|
for (unsigned i = 0; i < ARRAY_SIZE(${pass_name}_${opcode}_xforms); i++) {
|
||||||
if (nir_replace_instr(alu, ${pass_name}_${opcode}_xforms[i].search,
|
const struct transform *xform = &${pass_name}_${opcode}_xforms[i];
|
||||||
${pass_name}_${opcode}_xforms[i].replace,
|
if (nir_replace_instr(alu, xform->search, xform->replace,
|
||||||
state->mem_ctx)) {
|
state->mem_ctx)) {
|
||||||
state->progress = true;
|
state->progress = true;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue