nir: Slightly simplify algebraic code generation by reusing a struct.
authorEric Anholt <eric@anholt.net>
Wed, 28 Jan 2015 00:42:38 +0000 (16:42 -0800)
committerEric Anholt <eric@anholt.net>
Fri, 6 Feb 2015 23:57:55 +0000 (15:57 -0800)
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
src/glsl/nir/nir_algebraic.py

index ea7f5fc65f91bfa9fd7148cac36c53a5b458c1f4..4929745dfa5c48079b42565f515e8b3c348a3911 100644 (file)
@@ -179,10 +179,7 @@ struct transform {
    ${xform.replace.render()}
 % endfor
 
-static const struct {
-   const nir_search_expression *search;
-   const nir_search_value *replace;
-} ${pass_name}_${opcode}_xforms[] = {
+static const struct transform ${pass_name}_${opcode}_xforms[] = {
 % for xform in xform_list:
    { &${xform.search.name}, ${xform.replace.c_ptr} },
 % endfor
@@ -211,8 +208,8 @@ ${pass_name}_block(nir_block *block, void *void_state)
       % for opcode in xform_dict.keys():
       case nir_op_${opcode}:
          for (unsigned i = 0; i < ARRAY_SIZE(${pass_name}_${opcode}_xforms); i++) {
-            if (nir_replace_instr(alu, ${pass_name}_${opcode}_xforms[i].search,
-                                  ${pass_name}_${opcode}_xforms[i].replace,
+            const struct transform *xform = &${pass_name}_${opcode}_xforms[i];
+            if (nir_replace_instr(alu, xform->search, xform->replace,
                                   state->mem_ctx)) {
                state->progress = true;
                break;