[Mesa-dev] [PATCH 6/8] nir: Trivial clean ups in the generated nir_constant_expressions.c

Ian Romanick idr at freedesktop.org
Mon Dec 14 15:34:30 PST 2015


From: Ian Romanick <ian.d.romanick at intel.com>

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/glsl/nir/nir_constant_expressions.py | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/glsl/nir/nir_constant_expressions.py b/src/glsl/nir/nir_constant_expressions.py
index a83c12e..d82b865 100644
--- a/src/glsl/nir/nir_constant_expressions.py
+++ b/src/glsl/nir/nir_constant_expressions.py
@@ -219,7 +219,6 @@ static nir_const_value
 evaluate_${name}(unsigned num_components, nir_const_value *_src)
 {
    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
-
    ## For each non-per-component input, create a variable srcN that
    ## contains x, y, z, and w elements which are filled in with the
    ## appropriately-typed values.
@@ -231,7 +230,7 @@ evaluate_${name}(unsigned num_components, nir_const_value *_src)
          <% continue %>
       %endif
 
-      struct ${op.input_types[j]}_vec src${j} = {
+      const struct ${op.input_types[j]}_vec src${j} = {
       % for k in range(op.input_sizes[j]):
          % if op.input_types[j] == "bool":
             _src[${j}].u[${k}] != 0,
@@ -273,17 +272,17 @@ evaluate_${name}(unsigned num_components, nir_const_value *_src)
                ## Avoid unused variable warnings
                <% continue %>
             % elif op.input_types[j] == "bool":
-               bool src${j} = _src[${j}].u[_i] != 0;
+               const bool src${j} = _src[${j}].u[_i] != 0;
             % else:
-               ${op.input_types[j]} src${j} = _src[${j}].${op.input_types[j][:1]}[_i];
+               const ${op.input_types[j]} src${j} = _src[${j}].${op.input_types[j][:1]}[_i];
             % endif
          % endfor
-
          ## Create an appropriately-typed variable dst and assign the
          ## result of the const_expr to it.  If const_expr already contains
          ## writes to dst, just include const_expr directly.
          % if "dst" in op.const_expr:
             ${op.output_type} dst;
+
             ${op.const_expr}
          % else:
             ${op.output_type} dst = ${op.const_expr};
@@ -337,10 +336,8 @@ nir_eval_const_opcode(nir_op op, unsigned num_components,
 {
    switch (op) {
 % for name in sorted(opcodes.iterkeys()):
-   case nir_op_${name}: {
+   case nir_op_${name}:
       return evaluate_${name}(num_components, src);
-      break;
-   }
 % endfor
    default:
       unreachable("shouldn't get here");
-- 
2.5.0



More information about the mesa-dev mailing list