nir/algebraic: #define around structure definitions
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 24 Mar 2015 00:22:44 +0000 (17:22 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 1 Apr 2015 19:51:03 +0000 (12:51 -0700)
Previously, we couldn't generate two algebraic passes in the same file
because of multiple structure definitions.  To solve this, we play the
age-old header file trick and just #define around it.

Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/nir/nir_algebraic.py

index afab1a0084f534c03eeb18c71e79a7a07aa594a8..bbf4f08ef92856531c343fa67a692c34a06cf2cb 100644 (file)
@@ -181,12 +181,23 @@ _algebraic_pass_template = mako.template.Template("""
 #include "nir.h"
 #include "nir_search.h"
 
+#ifndef NIR_OPT_ALGEBRAIC_STRUCT_DEFS
+#define NIR_OPT_ALGEBRAIC_STRUCT_DEFS
+
 struct transform {
    const nir_search_expression *search;
    const nir_search_value *replace;
    unsigned condition_offset;
 };
 
+struct opt_state {
+   void *mem_ctx;
+   bool progress;
+   const bool *condition_flags;
+};
+
+#endif
+
 % for (opcode, xform_list) in xform_dict.iteritems():
 % for xform in xform_list:
    ${xform.search.render()}
@@ -200,12 +211,6 @@ static const struct transform ${pass_name}_${opcode}_xforms[] = {
 };
 % endfor
 
-struct opt_state {
-   void *mem_ctx;
-   bool progress;
-   const bool *condition_flags;
-};
-
 static bool
 ${pass_name}_block(nir_block *block, void *void_state)
 {