[Mesa-dev,v2,4/9] glsl: Generalize assignment and declaration IR sexp creation functions

Submitted by Iago Toral Quiroga on Oct. 1, 2014, 6:35 a.m.

Details

Message ID 1412145345-3974-5-git-send-email-itoral@igalia.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Iago Toral Quiroga Oct. 1, 2014, 6:35 a.m.
From: Petri Latvala <petri.latvala@intel.com>

Already-existing and used declare_temp() and assign_x() functions can
then be implemented in terms of the general functions.

Signed-off-by: Petri Latvala <petri.latvala@intel.com>
---
 src/glsl/tests/test_case_generator.py | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/glsl/tests/test_case_generator.py b/src/glsl/tests/test_case_generator.py
index d6754fc8..5df8420 100644
--- a/src/glsl/tests/test_case_generator.py
+++ b/src/glsl/tests/test_case_generator.py
@@ -127,19 +127,32 @@  def loop(statements):
     check_sexp(statements)
     return [['loop', statements]]
 
+def declare(var_type, var_name, decltype):
+    """Create a declaration of the form
+
+    (declare (<decltype>) <var_type> <var_name>)
+    """
+    return [['declare', [decltype], var_type, var_name]]
+
 def declare_temp(var_type, var_name):
     """Create a declaration of the form
 
     (declare (temporary) <var_type> <var_name)
     """
-    return [['declare', ['temporary'], var_type, var_name]]
+    return declare(var_type, var_name, 'temporary')
+
+def assign(var_name, mask, value):
+    """Create a statement that assigns <value> to the variable <var_name>. The
+    assignment uses <mask> (a string) as the write mask.
+    """
+    check_sexp(value)
+    return [['assign', [mask], ['var_ref', var_name], value]]
 
 def assign_x(var_name, value):
     """Create a statement that assigns <value> to the variable
     <var_name>.  The assignment uses the mask (x).
     """
-    check_sexp(value)
-    return [['assign', ['x'], ['var_ref', var_name], value]]
+    return assign(var_name, 'x', value)
 
 def complex_if(var_prefix, statements):
     """Create a statement of the form