Mesa (master): nir/algebraic: Move the template closer to the render function

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Apr 16 16:54:03 UTC 2019


Module: Mesa
Branch: master
Commit: 0c712fd4042c91f715260fe5923e798372f38e1e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0c712fd4042c91f715260fe5923e798372f38e1e

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Sat Apr 13 10:32:55 2019 -0500

nir/algebraic: Move the template closer to the render function

Reviewed-by: Connor Abbott <cwabbott0 at gmail.com>

---

 src/compiler/nir/nir_algebraic.py | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py
index 4772d4d123d..12d5da531d5 100644
--- a/src/compiler/nir/nir_algebraic.py
+++ b/src/compiler/nir/nir_algebraic.py
@@ -102,25 +102,6 @@ class Value(object):
       elif isinstance(val, (bool, float) + integer_types):
          return Constant(val, name_base)
 
-   __template = mako.template.Template("""
-static const ${val.c_type} ${val.name} = {
-   { ${val.type_enum}, ${val.c_bit_size} },
-% if isinstance(val, Constant):
-   ${val.type()}, { ${val.hex()} /* ${val.value} */ },
-% elif isinstance(val, Variable):
-   ${val.index}, /* ${val.var_name} */
-   ${'true' if val.is_constant else 'false'},
-   ${val.type() or 'nir_type_invalid' },
-   ${val.cond if val.cond else 'NULL'},
-% elif isinstance(val, Expression):
-   ${'true' if val.inexact else 'false'},
-   ${val.comm_expr_idx}, ${val.comm_exprs},
-   ${val.c_opcode()},
-   { ${', '.join(src.c_ptr for src in val.sources)} },
-   ${val.cond if val.cond else 'NULL'},
-% endif
-};""")
-
    def __init__(self, val, name, type_str):
       self.in_val = str(val)
       self.name = name
@@ -190,6 +171,25 @@ static const ${val.c_type} ${val.name} = {
          # We represent these cases with a 0 bit-size.
          return 0
 
+   __template = mako.template.Template("""
+static const ${val.c_type} ${val.name} = {
+   { ${val.type_enum}, ${val.c_bit_size} },
+% if isinstance(val, Constant):
+   ${val.type()}, { ${val.hex()} /* ${val.value} */ },
+% elif isinstance(val, Variable):
+   ${val.index}, /* ${val.var_name} */
+   ${'true' if val.is_constant else 'false'},
+   ${val.type() or 'nir_type_invalid' },
+   ${val.cond if val.cond else 'NULL'},
+% elif isinstance(val, Expression):
+   ${'true' if val.inexact else 'false'},
+   ${val.comm_expr_idx}, ${val.comm_exprs},
+   ${val.c_opcode()},
+   { ${', '.join(src.c_ptr for src in val.sources)} },
+   ${val.cond if val.cond else 'NULL'},
+% endif
+};""")
+
    def render(self):
       return self.__template.render(val=self,
                                     Constant=Constant,




More information about the mesa-commit mailing list