Add constructors for immediate hir constants.
authorEric Anholt <eric@anholt.net>
Fri, 26 Mar 2010 19:07:44 +0000 (12:07 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Sat, 27 Mar 2010 00:51:41 +0000 (17:51 -0700)
This will make ast_to_hir for inc/dec easier.

ir.cpp
ir.h

diff --git a/ir.cpp b/ir.cpp
index 06eb19691e7dd1e2a9db4a2233ea840fdd997968..4c1f307e8afc5908cc77d9b3b5c45e39742074b7 100644 (file)
--- a/ir.cpp
+++ b/ir.cpp
@@ -74,6 +74,34 @@ ir_constant::ir_constant(const struct glsl_type *type, const void *data)
    memcpy(& this->value, data, size * type->components());
 }
 
+ir_constant::ir_constant(float f)
+   : ir_rvalue()
+{
+   this->type = glsl_type::float_type;
+   this->value.f[0] = f;
+}
+
+ir_constant::ir_constant(unsigned int u)
+   : ir_rvalue()
+{
+   this->type = glsl_type::uint_type;
+   this->value.u[0] = u;
+}
+
+ir_constant::ir_constant(int i)
+   : ir_rvalue()
+{
+   this->type = glsl_type::int_type;
+   this->value.i[0] = i;
+}
+
+ir_constant::ir_constant(bool b)
+   : ir_rvalue()
+{
+   this->type = glsl_type::bool_type;
+   this->value.b[0] = b;
+}
+
 
 ir_dereference::ir_dereference(ir_instruction *var)
    : ir_rvalue()
diff --git a/ir.h b/ir.h
index c52efe61781d9583f963907a6cd5e517367d7b0c..a69f932c5a8de19ddf60feb0dbe0d3c521c09f85 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -481,6 +481,10 @@ public:
 class ir_constant : public ir_rvalue {
 public:
    ir_constant(const struct glsl_type *type, const void *data);
+   ir_constant(bool b);
+   ir_constant(unsigned int u);
+   ir_constant(int i);
+   ir_constant(float f);
 
    virtual void accept(ir_visitor *v)
    {