summaryrefslogtreecommitdiff
path: root/src/glsl/ir.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/glsl/ir.h')
-rw-r--r--src/glsl/ir.h91
1 files changed, 83 insertions, 8 deletions
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 06198e4f3f..850033b185 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -33,14 +33,11 @@ extern "C" {
#include <talloc.h>
}
+#include "glsl_types.h"
#include "list.h"
#include "ir_visitor.h"
#include "ir_hierarchical_visitor.h"
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
-#endif
-
/**
* \defgroup IR Intermediate representation nodes
*
@@ -147,6 +144,8 @@ public:
return this;
}
+ ir_rvalue *as_rvalue_to_saturate();
+
virtual bool is_lvalue()
{
return false;
@@ -175,6 +174,42 @@ public:
return NULL;
}
+ /**
+ * Determine if an r-value has the value zero
+ *
+ * The base implementation of this function always returns \c false. The
+ * \c ir_constant class over-rides this function to return \c true \b only
+ * for vector and scalar types that have all elements set to the value
+ * zero (or \c false for booleans).
+ *
+ * \sa ir_constant::has_value, ir_rvalue::is_one, ir_rvalue::is_negative_one
+ */
+ virtual bool is_zero() const;
+
+ /**
+ * Determine if an r-value has the value one
+ *
+ * The base implementation of this function always returns \c false. The
+ * \c ir_constant class over-rides this function to return \c true \b only
+ * for vector and scalar types that have all elements set to the value
+ * one (or \c true for booleans).
+ *
+ * \sa ir_constant::has_value, ir_rvalue::is_zero, ir_rvalue::is_negative_one
+ */
+ virtual bool is_one() const;
+
+ /**
+ * Determine if an r-value has the value negative one
+ *
+ * The base implementation of this function always returns \c false. The
+ * \c ir_constant class over-rides this function to return \c true \b only
+ * for vector and scalar types that have all elements set to the value
+ * negative one. For boolean times, the result is always \c false.
+ *
+ * \sa ir_constant::has_value, ir_rvalue::is_zero, ir_rvalue::is_one
+ */
+ virtual bool is_negative_one() const;
+
protected:
ir_rvalue();
};
@@ -709,6 +744,8 @@ enum ir_expression_operation {
/*@{*/
ir_unop_sin,
ir_unop_cos,
+ ir_unop_sin_reduced, /**< Reduced range sin. [-pi, pi] */
+ ir_unop_cos_reduced, /**< Reduced range cos. [-pi, pi] */
/*@}*/
/**
@@ -721,6 +758,11 @@ enum ir_expression_operation {
ir_unop_noise,
+ /**
+ * A sentinel marking the last of the unary operations.
+ */
+ ir_last_unop = ir_unop_noise,
+
ir_binop_add,
ir_binop_sub,
ir_binop_mul,
@@ -775,18 +817,43 @@ enum ir_expression_operation {
ir_binop_logic_or,
ir_binop_dot,
- ir_binop_cross,
ir_binop_min,
ir_binop_max,
- ir_binop_pow
+ ir_binop_pow,
+
+ /**
+ * A sentinel marking the last of the binary operations.
+ */
+ ir_last_binop = ir_binop_pow,
+
+ ir_quadop_vector,
+
+ /**
+ * A sentinel marking the last of all operations.
+ */
+ ir_last_opcode = ir_last_binop
};
class ir_expression : public ir_rvalue {
public:
+ /**
+ * Constructor for unary operation expressions
+ */
+ ir_expression(int op, const struct glsl_type *type, ir_rvalue *);
+
+ /**
+ * Constructor for binary operation expressions
+ */
ir_expression(int op, const struct glsl_type *type,
ir_rvalue *, ir_rvalue *);
+ /**
+ * Constructor for quad operator expressions
+ */
+ ir_expression(int op, const struct glsl_type *type,
+ ir_rvalue *, ir_rvalue *, ir_rvalue *, ir_rvalue *);
+
virtual ir_expression *as_expression()
{
return this;
@@ -812,7 +879,8 @@ public:
*/
unsigned int get_num_operands() const
{
- return get_num_operands(operation);
+ return (this->operation == ir_quadop_vector)
+ ? this->type->vector_elements : get_num_operands(operation);
}
/**
@@ -839,7 +907,7 @@ public:
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
ir_expression_operation operation;
- ir_rvalue *operands[2];
+ ir_rvalue *operands[4];
};
@@ -1445,9 +1513,16 @@ public:
/**
* Determine whether a constant has the same value as another constant
+ *
+ * \sa ir_constant::is_zero, ir_constant::is_one,
+ * ir_constant::is_negative_one
*/
bool has_value(const ir_constant *) const;
+ virtual bool is_zero() const;
+ virtual bool is_one() const;
+ virtual bool is_negative_one() const;
+
/**
* Value of the constant.
*