[Mesa-dev] [PATCH RFC 08/11] glsl: add ssa_assign() to ir_builder

Connor Abbott cwabbott0 at gmail.com
Wed Jan 22 09:16:55 PST 2014


ssa_assign() creates an SSA variable and assignment at the same
time. With this, simple sequences of SSA statements can be easily
created.
---
 src/glsl/ir_builder.cpp | 14 ++++++++++++++
 src/glsl/ir_builder.h   |  1 +
 2 files changed, 15 insertions(+)

diff --git a/src/glsl/ir_builder.cpp b/src/glsl/ir_builder.cpp
index 2229cd2..03cb38f 100644
--- a/src/glsl/ir_builder.cpp
+++ b/src/glsl/ir_builder.cpp
@@ -76,6 +76,20 @@ assign(deref lhs, operand rhs, operand condition)
    return assign(lhs, rhs, condition, (1 << lhs.val->type->vector_elements) - 1);
 }
 
+ir_assignment *
+ssa_assign(const char *name, operand rhs)
+{
+   void *mem_ctx = ralloc_parent(rhs.val);
+
+   ir_variable *var = new(mem_ctx) ir_variable(rhs.val->type, name,
+					       ir_var_temporary_ssa);
+
+   ir_assignment *ret = assign(var, rhs);
+   var->ssa_assignment = ret;
+   return ret;
+}
+
+
 ir_return *
 ret(operand retval)
 {
diff --git a/src/glsl/ir_builder.h b/src/glsl/ir_builder.h
index ae10995..415112b 100644
--- a/src/glsl/ir_builder.h
+++ b/src/glsl/ir_builder.h
@@ -124,6 +124,7 @@ ir_assignment *assign(deref lhs, operand rhs);
 ir_assignment *assign(deref lhs, operand rhs, int writemask);
 ir_assignment *assign(deref lhs, operand rhs, operand condition);
 ir_assignment *assign(deref lhs, operand rhs, operand condition, int writemask);
+ir_assignment *ssa_assign(const char *name, operand rhs);
 
 ir_return *ret(operand retval);
 
-- 
1.8.3.1



More information about the mesa-dev mailing list