aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/glsl')
-rw-r--r--mesalib/src/glsl/ast_function.cpp30
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp6
-rw-r--r--mesalib/src/glsl/ir.cpp107
-rw-r--r--mesalib/src/glsl/ir.h110
-rw-r--r--mesalib/src/glsl/ir_clone.cpp8
-rw-r--r--mesalib/src/glsl/ir_constant_expression.cpp673
6 files changed, 490 insertions, 444 deletions
diff --git a/mesalib/src/glsl/ast_function.cpp b/mesalib/src/glsl/ast_function.cpp
index 8bf0ba2a8..9e7c5995f 100644
--- a/mesalib/src/glsl/ast_function.cpp
+++ b/mesalib/src/glsl/ast_function.cpp
@@ -153,21 +153,21 @@ verify_parameter_modes(_mesa_glsl_parse_state *state,
}
ir_variable *var = actual->variable_referenced();
- if (var) {
- if (var->read_only) {
- _mesa_glsl_error(&loc, state,
- "function parameter '%s %s' references the "
- "read-only variable '%s'",
- mode, formal->name,
- actual->variable_referenced()->name);
- return false;
- } else if (!actual->is_lvalue()) {
- _mesa_glsl_error(&loc, state,
- "function parameter '%s %s' is not an lvalue",
- mode, formal->name);
- return false;
- }
+ if (var)
var->assigned = true;
+
+ if (var && var->read_only) {
+ _mesa_glsl_error(&loc, state,
+ "function parameter '%s %s' references the "
+ "read-only variable '%s'",
+ mode, formal->name,
+ actual->variable_referenced()->name);
+ return false;
+ } else if (!actual->is_lvalue()) {
+ _mesa_glsl_error(&loc, state,
+ "function parameter '%s %s' is not an lvalue",
+ mode, formal->name);
+ return false;
}
}
@@ -278,7 +278,7 @@ generate_call(exec_list *instructions, ir_function_signature *sig,
* Function calls were first allowed to be constant expressions in GLSL 1.20.
*/
if (state->language_version >= 120) {
- ir_constant *value = sig->constant_expression_value(actual_parameters);
+ ir_constant *value = sig->constant_expression_value(actual_parameters, NULL);
if (value != NULL) {
return value;
}
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index e24914b83..86bb8741b 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -4039,13 +4039,13 @@ detect_conflicting_assignments(struct _mesa_glsl_parse_state *state,
foreach_list(node, instructions) {
ir_variable *var = ((ir_instruction *)node)->as_variable();
- if (!var)
+ if (!var || !var->assigned)
continue;
if (strcmp(var->name, "gl_FragColor") == 0)
- gl_FragColor_assigned = var->assigned;
+ gl_FragColor_assigned = true;
else if (strcmp(var->name, "gl_FragData") == 0)
- gl_FragData_assigned = var->assigned;
+ gl_FragData_assigned = true;
else if (strncmp(var->name, "gl_", 3) != 0) {
if (state->target == fragment_shader &&
(var->mode == ir_var_out || var->mode == ir_var_inout)) {
diff --git a/mesalib/src/glsl/ir.cpp b/mesalib/src/glsl/ir.cpp
index 1ba87515e..970d8f3ba 100644
--- a/mesalib/src/glsl/ir.cpp
+++ b/mesalib/src/glsl/ir.cpp
@@ -716,12 +716,27 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
ir_constant *
ir_constant::zero(void *mem_ctx, const glsl_type *type)
{
- assert(type->is_numeric() || type->is_boolean());
+ assert(type->is_scalar() || type->is_vector() || type->is_matrix()
+ || type->is_record() || type->is_array());
ir_constant *c = new(mem_ctx) ir_constant;
c->type = type;
memset(&c->value, 0, sizeof(c->value));
+ if (type->is_array()) {
+ c->array_elements = ralloc_array(c, ir_constant *, type->length);
+
+ for (unsigned i = 0; i < type->length; i++)
+ c->array_elements[i] = ir_constant::zero(c, type->element_type());
+ }
+
+ if (type->is_record()) {
+ for (unsigned i = 0; i < type->length; i++) {
+ ir_constant *comp = ir_constant::zero(mem_ctx, type->fields.structure[i].type);
+ c->components.push_tail(comp);
+ }
+ }
+
return c;
}
@@ -841,6 +856,95 @@ ir_constant::get_record_field(const char *name)
return (ir_constant *) node;
}
+void
+ir_constant::copy_offset(ir_constant *src, int offset)
+{
+ switch (this->type->base_type) {
+ case GLSL_TYPE_UINT:
+ case GLSL_TYPE_INT:
+ case GLSL_TYPE_FLOAT:
+ case GLSL_TYPE_BOOL: {
+ unsigned int size = src->type->components();
+ assert (size <= this->type->components() - offset);
+ for (unsigned int i=0; i<size; i++) {
+ switch (this->type->base_type) {
+ case GLSL_TYPE_UINT:
+ value.u[i+offset] = src->get_uint_component(i);
+ break;
+ case GLSL_TYPE_INT:
+ value.i[i+offset] = src->get_int_component(i);
+ break;
+ case GLSL_TYPE_FLOAT:
+ value.f[i+offset] = src->get_float_component(i);
+ break;
+ case GLSL_TYPE_BOOL:
+ value.b[i+offset] = src->get_bool_component(i);
+ break;
+ default: // Shut up the compiler
+ break;
+ }
+ }
+ break;
+ }
+
+ case GLSL_TYPE_STRUCT: {
+ assert (src->type == this->type);
+ this->components.make_empty();
+ foreach_list(node, &src->components) {
+ ir_constant *const orig = (ir_constant *) node;
+
+ this->components.push_tail(orig->clone(this, NULL));
+ }
+ break;
+ }
+
+ case GLSL_TYPE_ARRAY: {
+ assert (src->type == this->type);
+ for (unsigned i = 0; i < this->type->length; i++) {
+ this->array_elements[i] = src->array_elements[i]->clone(this, NULL);
+ }
+ break;
+ }
+
+ default:
+ assert(!"Should not get here.");
+ break;
+ }
+}
+
+void
+ir_constant::copy_masked_offset(ir_constant *src, int offset, unsigned int mask)
+{
+ assert (!type->is_array() && !type->is_record());
+
+ if (!type->is_vector() && !type->is_matrix()) {
+ offset = 0;
+ mask = 1;
+ }
+
+ int id = 0;
+ for (int i=0; i<4; i++) {
+ if (mask & (1 << i)) {
+ switch (this->type->base_type) {
+ case GLSL_TYPE_UINT:
+ value.u[i+offset] = src->get_uint_component(id++);
+ break;
+ case GLSL_TYPE_INT:
+ value.i[i+offset] = src->get_int_component(id++);
+ break;
+ case GLSL_TYPE_FLOAT:
+ value.f[i+offset] = src->get_float_component(id++);
+ break;
+ case GLSL_TYPE_BOOL:
+ value.b[i+offset] = src->get_bool_component(id++);
+ break;
+ default:
+ assert(!"Should not get here.");
+ return;
+ }
+ }
+ }
+}
bool
ir_constant::has_value(const ir_constant *c) const
@@ -1377,6 +1481,7 @@ ir_function_signature::ir_function_signature(const glsl_type *return_type)
{
this->ir_type = ir_type_function_signature;
this->is_builtin = false;
+ this->origin = NULL;
}
diff --git a/mesalib/src/glsl/ir.h b/mesalib/src/glsl/ir.h
index ddfaf3614..9c7961ab9 100644
--- a/mesalib/src/glsl/ir.h
+++ b/mesalib/src/glsl/ir.h
@@ -146,7 +146,7 @@ public:
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
- virtual ir_constant *constant_expression_value();
+ virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
virtual ir_rvalue * as_rvalue()
{
@@ -502,10 +502,11 @@ public:
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
/**
- * Attempt to evaluate this function as a constant expression, given
- * a list of the actual parameters. Returns NULL for non-built-ins.
+ * Attempt to evaluate this function as a constant expression,
+ * given a list of the actual parameters and the variable context.
+ * Returns NULL for non-built-ins.
*/
- ir_constant *constant_expression_value(exec_list *actual_parameters);
+ ir_constant *constant_expression_value(exec_list *actual_parameters, struct hash_table *variable_context);
/**
* Get the name of the function for which this is a signature
@@ -571,7 +572,25 @@ private:
/** Function of which this signature is one overload. */
class ir_function *_function;
+ /** Function signature of which this one is a prototype clone */
+ const ir_function_signature *origin;
+
friend class ir_function;
+
+ /**
+ * Helper function to run a list of instructions for constant
+ * expression evaluation.
+ *
+ * The hash table represents the values of the visible variables.
+ * There are no scoping issues because the table is indexed on
+ * ir_variable pointers, not variable names.
+ *
+ * Returns false if the expression is not constant, true otherwise,
+ * and the value in *result if result is non-NULL.
+ */
+ bool constant_expression_evaluate_expression_list(const struct exec_list &body,
+ struct hash_table *variable_context,
+ ir_constant **result);
};
@@ -763,7 +782,7 @@ public:
virtual ir_assignment *clone(void *mem_ctx, struct hash_table *ht) const;
- virtual ir_constant *constant_expression_value();
+ virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
virtual void accept(ir_visitor *v)
{
@@ -999,10 +1018,14 @@ public:
/**
* Attempt to constant-fold the expression
*
+ * The "variable_context" hash table links ir_variable * to ir_constant *
+ * that represent the variables' values. \c NULL represents an empty
+ * context.
+ *
* If the expression cannot be constant folded, this method will return
* \c NULL.
*/
- virtual ir_constant *constant_expression_value();
+ virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
/**
* Determine the number of operands used by an expression
@@ -1065,7 +1088,7 @@ public:
virtual ir_call *clone(void *mem_ctx, struct hash_table *ht) const;
- virtual ir_constant *constant_expression_value();
+ virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
virtual ir_call *as_call()
{
@@ -1297,7 +1320,7 @@ public:
virtual ir_texture *clone(void *mem_ctx, struct hash_table *) const;
- virtual ir_constant *constant_expression_value();
+ virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
virtual void accept(ir_visitor *v)
{
@@ -1389,7 +1412,7 @@ public:
virtual ir_swizzle *clone(void *mem_ctx, struct hash_table *) const;
- virtual ir_constant *constant_expression_value();
+ virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
virtual ir_swizzle *as_swizzle()
{
@@ -1446,6 +1469,15 @@ public:
* Get the variable that is ultimately referenced by an r-value
*/
virtual ir_variable *variable_referenced() const = 0;
+
+ /**
+ * Get the constant that is ultimately referenced by an r-value,
+ * in a constant expression evaluation context.
+ *
+ * The offset is used when the reference is to a specific column of
+ * a matrix.
+ */
+ virtual void constant_referenced(struct hash_table *variable_context, ir_constant *&store, int &offset) const = 0;
};
@@ -1456,7 +1488,7 @@ public:
virtual ir_dereference_variable *clone(void *mem_ctx,
struct hash_table *) const;
- virtual ir_constant *constant_expression_value();
+ virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
virtual ir_dereference_variable *as_dereference_variable()
{
@@ -1471,6 +1503,15 @@ public:
return this->var;
}
+ /**
+ * Get the constant that is ultimately referenced by an r-value,
+ * in a constant expression evaluation context.
+ *
+ * The offset is used when the reference is to a specific column of
+ * a matrix.
+ */
+ virtual void constant_referenced(struct hash_table *variable_context, ir_constant *&store, int &offset) const;
+
virtual ir_variable *whole_variable_referenced()
{
/* ir_dereference_variable objects always dereference the entire
@@ -1505,7 +1546,7 @@ public:
virtual ir_dereference_array *clone(void *mem_ctx,
struct hash_table *) const;
- virtual ir_constant *constant_expression_value();
+ virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
virtual ir_dereference_array *as_dereference_array()
{
@@ -1520,6 +1561,15 @@ public:
return this->array->variable_referenced();
}
+ /**
+ * Get the constant that is ultimately referenced by an r-value,
+ * in a constant expression evaluation context.
+ *
+ * The offset is used when the reference is to a specific column of
+ * a matrix.
+ */
+ virtual void constant_referenced(struct hash_table *variable_context, ir_constant *&store, int &offset) const;
+
virtual void accept(ir_visitor *v)
{
v->visit(this);
@@ -1544,7 +1594,7 @@ public:
virtual ir_dereference_record *clone(void *mem_ctx,
struct hash_table *) const;
- virtual ir_constant *constant_expression_value();
+ virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
/**
* Get the variable that is ultimately referenced by an r-value
@@ -1554,6 +1604,15 @@ public:
return this->record->variable_referenced();
}
+ /**
+ * Get the constant that is ultimately referenced by an r-value,
+ * in a constant expression evaluation context.
+ *
+ * The offset is used when the reference is to a specific column of
+ * a matrix.
+ */
+ virtual void constant_referenced(struct hash_table *variable_context, ir_constant *&store, int &offset) const;
+
virtual void accept(ir_visitor *v)
{
v->visit(this);
@@ -1609,7 +1668,7 @@ public:
virtual ir_constant *clone(void *mem_ctx, struct hash_table *) const;
- virtual ir_constant *constant_expression_value();
+ virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
virtual ir_constant *as_constant()
{
@@ -1642,6 +1701,31 @@ public:
ir_constant *get_record_field(const char *name);
/**
+ * Copy the values on another constant at a given offset.
+ *
+ * The offset is ignored for array or struct copies, it's only for
+ * scalars or vectors into vectors or matrices.
+ *
+ * With identical types on both sides and zero offset it's clone()
+ * without creating a new object.
+ */
+
+ void copy_offset(ir_constant *src, int offset);
+
+ /**
+ * Copy the values on another constant at a given offset and
+ * following an assign-like mask.
+ *
+ * The mask is ignored for scalars.
+ *
+ * Note that this function only handles what assign can handle,
+ * i.e. at most a vector as source and a column of a matrix as
+ * destination.
+ */
+
+ void copy_masked_offset(ir_constant *src, int offset, unsigned int mask);
+
+ /**
* Determine whether a constant has the same value as another constant
*
* \sa ir_constant::is_zero, ir_constant::is_one,
diff --git a/mesalib/src/glsl/ir_clone.cpp b/mesalib/src/glsl/ir_clone.cpp
index 5a7a71cf6..591fe7b77 100644
--- a/mesalib/src/glsl/ir_clone.cpp
+++ b/mesalib/src/glsl/ir_clone.cpp
@@ -53,6 +53,7 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const
var->invariant = this->invariant;
var->interpolation = this->interpolation;
var->location = this->location;
+ var->index = this->index;
var->warn_extension = this->warn_extension;
var->origin_upper_left = this->origin_upper_left;
var->pixel_center_integer = this->pixel_center_integer;
@@ -72,12 +73,6 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const
sizeof(this->state_slots[0]) * var->num_state_slots);
}
- if (this->explicit_location)
- var->location = this->location;
-
- if (this->explicit_index)
- var->index = this->index;
-
if (this->constant_value)
var->constant_value = this->constant_value->clone(mem_ctx, ht);
@@ -329,6 +324,7 @@ ir_function_signature::clone_prototype(void *mem_ctx, struct hash_table *ht) con
copy->is_defined = false;
copy->is_builtin = this->is_builtin;
+ copy->origin = this;
/* Clone the parameter list, but NOT the body.
*/
diff --git a/mesalib/src/glsl/ir_constant_expression.cpp b/mesalib/src/glsl/ir_constant_expression.cpp
index 4e1714a84..08a33285b 100644
--- a/mesalib/src/glsl/ir_constant_expression.cpp
+++ b/mesalib/src/glsl/ir_constant_expression.cpp
@@ -38,6 +38,7 @@
#include "ir.h"
#include "ir_visitor.h"
#include "glsl_types.h"
+#include "program/hash_table.h"
/* Using C99 rounding functions for roundToEven() implementation is
* difficult, because round(), rint, and nearbyint() are affected by
@@ -71,14 +72,14 @@ dot(ir_constant *op0, ir_constant *op1)
}
ir_constant *
-ir_rvalue::constant_expression_value()
+ir_rvalue::constant_expression_value(struct hash_table *variable_context)
{
assert(this->type->is_error());
return NULL;
}
ir_constant *
-ir_expression::constant_expression_value()
+ir_expression::constant_expression_value(struct hash_table *variable_context)
{
if (this->type->is_error())
return NULL;
@@ -89,7 +90,7 @@ ir_expression::constant_expression_value()
memset(&data, 0, sizeof(data));
for (unsigned operand = 0; operand < this->get_num_operands(); operand++) {
- op[operand] = this->operands[operand]->constant_expression_value();
+ op[operand] = this->operands[operand]->constant_expression_value(variable_context);
if (!op[operand])
return NULL;
}
@@ -640,13 +641,13 @@ ir_expression::constant_expression_value()
for (unsigned c = 0; c < op[0]->type->components(); c++) {
switch (op[0]->type->base_type) {
case GLSL_TYPE_UINT:
- data.b[0] = op[0]->value.u[0] < op[1]->value.u[0];
+ data.b[c] = op[0]->value.u[c] < op[1]->value.u[c];
break;
case GLSL_TYPE_INT:
- data.b[0] = op[0]->value.i[0] < op[1]->value.i[0];
+ data.b[c] = op[0]->value.i[c] < op[1]->value.i[c];
break;
case GLSL_TYPE_FLOAT:
- data.b[0] = op[0]->value.f[0] < op[1]->value.f[0];
+ data.b[c] = op[0]->value.f[c] < op[1]->value.f[c];
break;
default:
assert(0);
@@ -676,13 +677,13 @@ ir_expression::constant_expression_value()
for (unsigned c = 0; c < op[0]->type->components(); c++) {
switch (op[0]->type->base_type) {
case GLSL_TYPE_UINT:
- data.b[0] = op[0]->value.u[0] <= op[1]->value.u[0];
+ data.b[c] = op[0]->value.u[c] <= op[1]->value.u[c];
break;
case GLSL_TYPE_INT:
- data.b[0] = op[0]->value.i[0] <= op[1]->value.i[0];
+ data.b[c] = op[0]->value.i[c] <= op[1]->value.i[c];
break;
case GLSL_TYPE_FLOAT:
- data.b[0] = op[0]->value.f[0] <= op[1]->value.f[0];
+ data.b[c] = op[0]->value.f[c] <= op[1]->value.f[c];
break;
default:
assert(0);
@@ -694,13 +695,13 @@ ir_expression::constant_expression_value()
for (unsigned c = 0; c < op[0]->type->components(); c++) {
switch (op[0]->type->base_type) {
case GLSL_TYPE_UINT:
- data.b[0] = op[0]->value.u[0] >= op[1]->value.u[0];
+ data.b[c] = op[0]->value.u[c] >= op[1]->value.u[c];
break;
case GLSL_TYPE_INT:
- data.b[0] = op[0]->value.i[0] >= op[1]->value.i[0];
+ data.b[c] = op[0]->value.i[c] >= op[1]->value.i[c];
break;
case GLSL_TYPE_FLOAT:
- data.b[0] = op[0]->value.f[0] >= op[1]->value.f[0];
+ data.b[c] = op[0]->value.f[c] >= op[1]->value.f[c];
break;
default:
assert(0);
@@ -886,7 +887,7 @@ ir_expression::constant_expression_value()
ir_constant *
-ir_texture::constant_expression_value()
+ir_texture::constant_expression_value(struct hash_table *variable_context)
{
/* texture lookups aren't constant expressions */
return NULL;
@@ -894,9 +895,9 @@ ir_texture::constant_expression_value()
ir_constant *
-ir_swizzle::constant_expression_value()
+ir_swizzle::constant_expression_value(struct hash_table *variable_context)
{
- ir_constant *v = this->val->constant_expression_value();
+ ir_constant *v = this->val->constant_expression_value(variable_context);
if (v != NULL) {
ir_constant_data data = { { 0 } };
@@ -922,13 +923,33 @@ ir_swizzle::constant_expression_value()
}
+void
+ir_dereference_variable::constant_referenced(struct hash_table *variable_context,
+ ir_constant *&store, int &offset) const
+{
+ if (variable_context) {
+ store = (ir_constant *)hash_table_find(variable_context, var);
+ offset = 0;
+ } else {
+ store = NULL;
+ offset = 0;
+ }
+}
+
ir_constant *
-ir_dereference_variable::constant_expression_value()
+ir_dereference_variable::constant_expression_value(struct hash_table *variable_context)
{
/* This may occur during compile and var->type is glsl_type::error_type */
if (!var)
return NULL;
+ /* Give priority to the context hashtable, if it exists */
+ if (variable_context) {
+ ir_constant *value = (ir_constant *)hash_table_find(variable_context, var);
+ if(value)
+ return value;
+ }
+
/* The constant_value of a uniform variable is its initializer,
* not the lifetime constant value of the uniform.
*/
@@ -942,11 +963,65 @@ ir_dereference_variable::constant_expression_value()
}
+void
+ir_dereference_array::constant_referenced(struct hash_table *variable_context,
+ ir_constant *&store, int &offset) const
+{
+ ir_constant *index_c = array_index->constant_expression_value(variable_context);
+
+ if (!index_c || !index_c->type->is_scalar() || !index_c->type->is_integer()) {
+ store = 0;
+ offset = 0;
+ return;
+ }
+
+ int index = index_c->type->base_type == GLSL_TYPE_INT ?
+ index_c->get_int_component(0) :
+ index_c->get_uint_component(0);
+
+ ir_constant *substore;
+ int suboffset;
+ const ir_dereference *deref = array->as_dereference();
+ if (!deref) {
+ store = 0;
+ offset = 0;
+ return;
+ }
+
+ deref->constant_referenced(variable_context, substore, suboffset);
+
+ if (!substore) {
+ store = 0;
+ offset = 0;
+ return;
+ }
+
+ const glsl_type *vt = substore->type;
+ if (vt->is_array()) {
+ store = substore->get_array_element(index);
+ offset = 0;
+ return;
+ }
+ if (vt->is_matrix()) {
+ store = substore;
+ offset = index * vt->vector_elements;
+ return;
+ }
+ if (vt->is_vector()) {
+ store = substore;
+ offset = suboffset + index;
+ return;
+ }
+
+ store = 0;
+ offset = 0;
+}
+
ir_constant *
-ir_dereference_array::constant_expression_value()
+ir_dereference_array::constant_expression_value(struct hash_table *variable_context)
{
- ir_constant *array = this->array->constant_expression_value();
- ir_constant *idx = this->array_index->constant_expression_value();
+ ir_constant *array = this->array->constant_expression_value(variable_context);
+ ir_constant *idx = this->array_index->constant_expression_value(variable_context);
if ((array != NULL) && (idx != NULL)) {
void *ctx = ralloc_parent(this);
@@ -997,8 +1072,33 @@ ir_dereference_array::constant_expression_value()
}
+void
+ir_dereference_record::constant_referenced(struct hash_table *variable_context,
+ ir_constant *&store, int &offset) const
+{
+ ir_constant *substore;
+ int suboffset;
+ const ir_dereference *deref = record->as_dereference();
+ if (!deref) {
+ store = 0;
+ offset = 0;
+ return;
+ }
+
+ deref->constant_referenced(variable_context, substore, suboffset);
+
+ if (!substore) {
+ store = 0;
+ offset = 0;
+ return;
+ }
+
+ store = substore->get_record_field(field);
+ offset = 0;
+}
+
ir_constant *
-ir_dereference_record::constant_expression_value()
+ir_dereference_record::constant_expression_value(struct hash_table *variable_context)
{
ir_constant *v = this->record->constant_expression_value();
@@ -1007,7 +1107,7 @@ ir_dereference_record::constant_expression_value()
ir_constant *
-ir_assignment::constant_expression_value()
+ir_assignment::constant_expression_value(struct hash_table *variable_context)
{
/* FINISHME: Handle CEs involving assignment (return RHS) */
return NULL;
@@ -1015,21 +1115,130 @@ ir_assignment::constant_expression_value()
ir_constant *
-ir_constant::constant_expression_value()
+ir_constant::constant_expression_value(struct hash_table *variable_context)
{
return this;
}
ir_constant *
-ir_call::constant_expression_value()
+ir_call::constant_expression_value(struct hash_table *variable_context)
{
- return this->callee->constant_expression_value(&this->actual_parameters);
+ return this->callee->constant_expression_value(&this->actual_parameters, variable_context);
}
+bool ir_function_signature::constant_expression_evaluate_expression_list(const struct exec_list &body,
+ struct hash_table *variable_context,
+ ir_constant **result)
+{
+ foreach_list(n, &body) {
+ ir_instruction *inst = (ir_instruction *)n;
+ switch(inst->ir_type) {
+
+ /* (declare () type symbol) */
+ case ir_type_variable: {
+ ir_variable *var = inst->as_variable();
+ hash_table_insert(variable_context, ir_constant::zero(this, var->type), var);
+ break;
+ }
+
+ /* (assign [condition] (write-mask) (ref) (value)) */
+ case ir_type_assignment: {
+ ir_assignment *asg = inst->as_assignment();
+ if (asg->condition) {
+ ir_constant *cond = asg->condition->constant_expression_value(variable_context);
+ if (!cond)
+ return false;
+ if (!cond->get_bool_component(0))
+ break;
+ }
+
+ ir_constant *store = NULL;
+ int offset = 0;
+ asg->lhs->constant_referenced(variable_context, store, offset);
+
+ if (!store)
+ return false;
+
+ ir_constant *value = asg->rhs->constant_expression_value(variable_context);
+
+ if (!value)
+ return false;
+
+ store->copy_masked_offset(value, offset, asg->write_mask);
+ break;
+ }
+
+ /* (return (expression)) */
+ case ir_type_return:
+ assert (result);
+ *result = inst->as_return()->value->constant_expression_value(variable_context);
+ return *result != NULL;
+
+ /* (call name (ref) (params))*/
+ case ir_type_call: {
+ ir_call *call = inst->as_call();
+
+ /* Just say no to void functions in constant expressions. We
+ * don't need them at that point.
+ */
+
+ if (!call->return_deref)
+ return false;
+
+ ir_constant *store = NULL;
+ int offset = 0;
+ call->return_deref->constant_referenced(variable_context, store, offset);
+
+ if (!store)
+ return false;
+
+ ir_constant *value = call->constant_expression_value(variable_context);
+
+ if(!value)
+ return false;
+
+ store->copy_offset(value, offset);
+ break;
+ }
+
+ /* (if condition (then-instructions) (else-instructions)) */
+ case ir_type_if: {
+ ir_if *iif = inst->as_if();
+
+ ir_constant *cond = iif->condition->constant_expression_value(variable_context);
+ if (!cond || !cond->type->is_boolean())
+ return false;
+
+ exec_list &branch = cond->get_bool_component(0) ? iif->then_instructions : iif->else_instructions;
+
+ *result = NULL;
+ if (!constant_expression_evaluate_expression_list(branch, variable_context, result))
+ return false;
+
+ /* If there was a return in the branch chosen, drop out now. */
+ if (*result)
+ return true;
+
+ break;
+ }
+
+ /* Every other expression type, we drop out. */
+ default:
+ return false;
+ }
+ }
+
+ /* Reaching the end of the block is not an error condition */
+ if (result)
+ *result = NULL;
+
+ return true;
+}
+
ir_constant *
-ir_function_signature::constant_expression_value(exec_list *actual_parameters)
+ir_function_signature::constant_expression_value(exec_list *actual_parameters, struct hash_table *variable_context)
{
const glsl_type *type = this->return_type;
if (type == glsl_type::void_type)
@@ -1042,396 +1251,48 @@ ir_function_signature::constant_expression_value(exec_list *actual_parameters)
if (!this->is_builtin)
return NULL;
- unsigned num_parameters = 0;
+ /*
+ * Of the builtin functions, only the texture lookups and the noise
+ * ones must not be used in constant expressions. They all include
+ * specific opcodes so they don't need to be special-cased at this
+ * point.
+ */
+
+ /* Initialize the table of dereferencable names with the function
+ * parameters. Verify their const-ness on the way.
+ *
+ * We expect the correctness of the number of parameters to have
+ * been checked earlier.
+ */
+ hash_table *deref_hash = hash_table_ctor(8, hash_table_pointer_hash,
+ hash_table_pointer_compare);
+
+ /* If "origin" is non-NULL, then the function body is there. So we
+ * have to use the variable objects from the object with the body,
+ * but the parameter instanciation on the current object.
+ */
+ const exec_node *parameter_info = origin ? origin->parameters.head : parameters.head;
- /* Check if all parameters are constant */
- ir_constant *op[3];
foreach_list(n, actual_parameters) {
- ir_constant *constant = ((ir_rvalue *) n)->constant_expression_value();
+ ir_constant *constant = ((ir_rvalue *) n)->constant_expression_value(variable_context);
if (constant == NULL)
return NULL;
- op[num_parameters] = constant;
+ ir_variable *var = (ir_variable *)parameter_info;
+ hash_table_insert(deref_hash, constant, var);
- assert(num_parameters < 3);
- num_parameters++;
+ parameter_info = parameter_info->next;
}
- /* Individual cases below can either:
- * - Assign "expr" a new ir_expression to evaluate (for basic opcodes)
- * - Fill "data" with appopriate constant data
- * - Return an ir_constant directly.
- */
- void *mem_ctx = ralloc_parent(this);
- ir_expression *expr = NULL;
-
- ir_constant_data data;
- memset(&data, 0, sizeof(data));
-
- const char *callee = this->function_name();
- if (strcmp(callee, "abs") == 0) {
- expr = new(mem_ctx) ir_expression(ir_unop_abs, type, op[0], NULL);
- } else if (strcmp(callee, "all") == 0) {
- assert(op[0]->type->is_boolean());
- for (unsigned c = 0; c < op[0]->type->components(); c++) {
- if (!op[0]->value.b[c])
- return new(mem_ctx) ir_constant(false);
- }
- return new(mem_ctx) ir_constant(true);
- } else if (strcmp(callee, "any") == 0) {
- assert(op[0]->type->is_boolean());
- for (unsigned c = 0; c < op[0]->type->components(); c++) {
- if (op[0]->value.b[c])
- return new(mem_ctx) ir_constant(true);
- }
- return new(mem_ctx) ir_constant(false);
- } else if (strcmp(callee, "acos") == 0) {
- assert(op[0]->type->is_float());
- for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.f[c] = acosf(op[0]->value.f[c]);
- } else if (strcmp(callee, "acosh") == 0) {
- assert(op[0]->type->is_float());
- for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.f[c] = acoshf(op[0]->value.f[c]);
- } else if (strcmp(callee, "asin") == 0) {
- assert(op[0]->type->is_float());
- for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.f[c] = asinf(op[0]->value.f[c]);
- } else if (strcmp(callee, "asinh") == 0) {
- assert(op[0]->type->is_float());
- for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.f[c] = asinhf(op[0]->value.f[c]);
- } else if (strcmp(callee, "atan") == 0) {
- assert(op[0]->type->is_float());
- if (num_parameters == 2) {
- assert(op[1]->type->is_float());
- for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.f[c] = atan2f(op[0]->value.f[c], op[1]->value.f[c]);
- } else {
- for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.f[c] = atanf(op[0]->value.f[c]);
- }
- } else if (strcmp(callee, "atanh") == 0) {
- assert(op[0]->type->is_float());
- for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.f[c] = atanhf(op[0]->value.f[c]);
- } else if (strcmp(callee, "dFdx") == 0 || strcmp(callee, "dFdy") == 0) {
- return ir_constant::zero(mem_ctx, type);
- } else if (strcmp(callee, "ceil") == 0) {
- expr = new(mem_ctx) ir_expression(ir_unop_ceil, type, op[0], NULL);
- } else if (strcmp(callee, "clamp") == 0) {
- assert(num_parameters == 3);
- unsigned c1_inc = op[1]->type->is_scalar() ? 0 : 1;
- unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1;
- for (unsigned c = 0, c1 = 0, c2 = 0;
- c < op[0]->type->components();
- c1 += c1_inc, c2 += c2_inc, c++) {
-
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- data.u[c] = CLAMP(op[0]->value.u[c], op[1]->value.u[c1],
- op[2]->value.u[c2]);
- break;
- case GLSL_TYPE_INT:
- data.i[c] = CLAMP(op[0]->value.i[c], op[1]->value.i[c1],
- op[2]->value.i[c2]);
- break;
- case GLSL_TYPE_FLOAT:
- data.f[c] = CLAMP(op[0]->value.f[c], op[1]->value.f[c1],
- op[2]->value.f[c2]);
- break;
- default:
- assert(!"Should not get here.");
- }
- }
- } else if (strcmp(callee, "cos") == 0) {
- expr = new(mem_ctx) ir_expression(ir_unop_cos, type, op[0], NULL);
- } else if (strcmp(callee, "cosh") == 0) {
- assert(op[0]->type->is_float());
- for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.f[c] = coshf(op[0]->value.f[c]);
- } else if (strcmp(callee, "cross") == 0) {
- assert(op[0]->type == glsl_type::vec3_type);
- assert(op[1]->type == glsl_type::vec3_type);
- data.f[0] = (op[0]->value.f[1] * op[1]->value.f[2] -
- op[1]->value.f[1] * op[0]->value.f[2]);
- data.f[1] = (op[0]->value.f[2] * op[1]->value.f[0] -
- op[1]->value.f[2] * op[0]->value.f[0]);
- data.f[2] = (op[0]->value.f[0] * op[1]->value.f[1] -
- op[1]->value.f[0] * op[0]->value.f[1]);
- } else if (strcmp(callee, "degrees") == 0) {
- assert(op[0]->type->is_float());
- for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.f[c] = 180.0F / M_PI * op[0]->value.f[c];
- } else if (strcmp(callee, "distance") == 0) {
- assert(op[0]->type->is_float() && op[1]->type->is_float());
- float length_squared = 0.0;
- for (unsigned c = 0; c < op[0]->type->components(); c++) {
- float t = op[0]->value.f[c] - op[1]->value.f[c];
- length_squared += t * t;
- }
- return new(mem_ctx) ir_constant(sqrtf(length_squared));
- } else if (strcmp(callee, "dot") == 0) {
- return new(mem_ctx) ir_constant(dot(op[0], op[1]));
- } else if (strcmp(callee, "equal") == 0) {
- assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
- for (unsigned c = 0; c < op[0]->type->components(); c++) {
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- data.b[c] = op[0]->value.u[c] == op[1]->value.u[c];
- break;
- case GLSL_TYPE_INT:
- data.b[c] = op[0]->value.i[c] == op[1]->value.i[c];
- break;
- case GLSL_TYPE_FLOAT:
- data.b[c] = op[0]->value.f[c] == op[1]->value.f[c];
- break;
- case GLSL_TYPE_BOOL:
- data.b[c] = op[0]->value.b[c] == op[1]->value.b[c];
- break;
- default:
- assert(!"Should not get here.");
- }
- }
- } else if (strcmp(callee, "exp") == 0) {
- expr = new(mem_ctx) ir_expression(ir_unop_exp, type, op[0], NULL);
- } else if (strcmp(callee, "exp2") == 0) {
- expr = new(mem_ctx) ir_expression(ir_unop_exp2, type, op[0], NULL);
- } else if (strcmp(callee, "faceforward") == 0) {
- if (dot(op[2], op[1]) < 0)
- return op[0];
- for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.f[c] = -op[0]->value.f[c];
- } else if (strcmp(callee, "floor") == 0) {
- expr = new(mem_ctx) ir_expression(ir_unop_floor, type, op[0], NULL);
- } else if (strcmp(callee, "fract") == 0) {
- expr = new(mem_ctx) ir_expression(ir_unop_fract, type, op[0], NULL);
- } else if (strcmp(callee, "fwidth") == 0) {
- return ir_constant::zero(mem_ctx, type);
- } else if (strcmp(callee, "greaterThan") == 0) {
- assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
- for (unsigned c = 0; c < op[0]->type->components(); c++) {
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- data.b[c] = op[0]->value.u[c] > op[1]->value.u[c];
- break;
- case GLSL_TYPE_INT:
- data.b[c] = op[0]->value.i[c] > op[1]->value.i[c];
- break;
- case GLSL_TYPE_FLOAT:
- data.b[c] = op[0]->value.f[c] > op[1]->value.f[c];
- break;
- default:
- assert(!"Should not get here.");
- }
- }
- } else if (strcmp(callee, "greaterThanEqual") == 0) {
- assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
- for (unsigned c = 0; c < op[0]->type->components(); c++) {
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- data.b[c] = op[0]->value.u[c] >= op[1]->value.u[c];
- break;
- case GLSL_TYPE_INT:
- data.b[c] = op[0]->value.i[c] >= op[1]->value.i[c];
- break;
- case GLSL_TYPE_FLOAT:
- data.b[c] = op[0]->value.f[c] >= op[1]->value.f[c];
- break;
- default:
- assert(!"Should not get here.");
- }
- }
- } else if (strcmp(callee, "inversesqrt") == 0) {
- expr = new(mem_ctx) ir_expression(ir_unop_rsq, type, op[0], NULL);
- } else if (strcmp(callee, "length") == 0) {
- return new(mem_ctx) ir_constant(sqrtf(dot(op[0], op[0])));
- } else if (strcmp(callee, "lessThan") == 0) {
- assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
- for (unsigned c = 0; c < op[0]->type->components(); c++) {
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- data.b[c] = op[0]->value.u[c] < op[1]->value.u[c];
- break;
- case GLSL_TYPE_INT:
- data.b[c] = op[0]->value.i[c] < op[1]->value.i[c];
- break;
- case GLSL_TYPE_FLOAT:
- data.b[c] = op[0]->value.f[c] < op[1]->value.f[c];
- break;
- default:
- assert(!"Should not get here.");
- }
- }
- } else if (strcmp(callee, "lessThanEqual") == 0) {
- assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
- for (unsigned c = 0; c < op[0]->type->components(); c++) {
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- data.b[c] = op[0]->value.u[c] <= op[1]->value.u[c];
- break;
- case GLSL_TYPE_INT:
- data.b[c] = op[0]->value.i[c] <= op[1]->value.i[c];
- break;
- case GLSL_TYPE_FLOAT:
- data.b[c] = op[0]->value.f[c] <= op[1]->value.f[c];
- break;
- default:
- assert(!"Should not get here.");
- }
- }
- } else if (strcmp(callee, "log") == 0) {
- expr = new(mem_ctx) ir_expression(ir_unop_log, type, op[0], NULL);
- } else if (strcmp(callee, "log2") == 0) {
- expr = new(mem_ctx) ir_expression(ir_unop_log2, type, op[0], NULL);
- } else if (strcmp(callee, "matrixCompMult") == 0) {
- assert(op[0]->type->is_float() && op[1]->type->is_float());
- for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.f[c] = op[0]->value.f[c] * op[1]->value.f[c];
- } else if (strcmp(callee, "max") == 0) {
- expr = new(mem_ctx) ir_expression(ir_binop_max, type, op[0], op[1]);
- } else if (strcmp(callee, "min") == 0) {
- expr = new(mem_ctx) ir_expression(ir_binop_min, type, op[0], op[1]);
- } else if (strcmp(callee, "mix") == 0) {
- assert(op[0]->type->is_float() && op[1]->type->is_float());
- if (op[2]->type->is_float()) {
- unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1;
- unsigned components = op[0]->type->components();
- for (unsigned c = 0, c2 = 0; c < components; c2 += c2_inc, c++) {
- data.f[c] = op[0]->value.f[c] * (1 - op[2]->value.f[c2]) +
- op[1]->value.f[c] * op[2]->value.f[c2];
- }
- } else {
- assert(op[2]->type->is_boolean());
- for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.f[c] = op[op[2]->value.b[c] ? 1 : 0]->value.f[c];
- }
- } else if (strcmp(callee, "mod") == 0) {
- expr = new(mem_ctx) ir_expression(ir_binop_mod, type, op[0], op[1]);
- } else if (strcmp(callee, "normalize") == 0) {
- assert(op[0]->type->is_float());
- float length = sqrtf(dot(op[0], op[0]));
-
- if (length == 0)
- return ir_constant::zero(mem_ctx, type);
+ ir_constant *result = NULL;
- for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.f[c] = op[0]->value.f[c] / length;
- } else if (strcmp(callee, "not") == 0) {
- expr = new(mem_ctx) ir_expression(ir_unop_logic_not, type, op[0], NULL);
- } else if (strcmp(callee, "notEqual") == 0) {
- assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
- for (unsigned c = 0; c < op[0]->type->components(); c++) {
- switch (op[0]->type->base_type) {
- case GLSL_TYPE_UINT:
- data.b[c] = op[0]->value.u[c] != op[1]->value.u[c];
- break;
- case GLSL_TYPE_INT:
- data.b[c] = op[0]->value.i[c] != op[1]->value.i[c];
- break;
- case GLSL_TYPE_FLOAT:
- data.b[c] = op[0]->value.f[c] != op[1]->value.f[c];
- break;
- case GLSL_TYPE_BOOL:
- data.b[c] = op[0]->value.b[c] != op[1]->value.b[c];
- break;
- default:
- assert(!"Should not get here.");
- }
- }
- } else if (strcmp(callee, "outerProduct") == 0) {
- assert(op[0]->type->is_vector() && op[1]->type->is_vector());
- const unsigned m = op[0]->type->vector_elements;
- const unsigned n = op[1]->type->vector_elements;
- for (unsigned j = 0; j < n; j++) {
- for (unsigned i = 0; i < m; i++) {
- data.f[i+m*j] = op[0]->value.f[i] * op[1]->value.f[j];
- }
- }
- } else if (strcmp(callee, "pow") == 0) {
- expr = new(mem_ctx) ir_expression(ir_binop_pow, type, op[0], op[1]);
- } else if (strcmp(callee, "radians") == 0) {
- assert(op[0]->type->is_float());
- for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.f[c] = M_PI / 180.0F * op[0]->value.f[c];
- } else if (strcmp(callee, "reflect") == 0) {
- assert(op[0]->type->is_float());
- float dot_NI = dot(op[1], op[0]);
- for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.f[c] = op[0]->value.f[c] - 2 * dot_NI * op[1]->value.f[c];
- } else if (strcmp(callee, "refract") == 0) {
- const float eta = op[2]->value.f[0];
- const float dot_NI = dot(op[1], op[0]);
- const float k = 1.0F - eta * eta * (1.0F - dot_NI * dot_NI);
- if (k < 0.0) {
- return ir_constant::zero(mem_ctx, type);
- } else {
- for (unsigned c = 0; c < type->components(); c++) {
- data.f[c] = eta * op[0]->value.f[c] - (eta * dot_NI + sqrtf(k))
- * op[1]->value.f[c];
- }
- }
- } else if (strcmp(callee, "round") == 0 ||
- strcmp(callee, "roundEven") == 0) {
- expr = new(mem_ctx) ir_expression(ir_unop_round_even, op[0]);
- } else if (strcmp(callee, "sign") == 0) {
- expr = new(mem_ctx) ir_expression(ir_unop_sign, type, op[0], NULL);
- } else if (strcmp(callee, "sin") == 0) {
- expr = new(mem_ctx) ir_expression(ir_unop_sin, type, op[0], NULL);
- } else if (strcmp(callee, "sinh") == 0) {
- assert(op[0]->type->is_float());
- for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.f[c] = sinhf(op[0]->value.f[c]);
- } else if (strcmp(callee, "smoothstep") == 0) {
- assert(num_parameters == 3);
- assert(op[1]->type == op[0]->type);
- unsigned edge_inc = op[0]->type->is_scalar() ? 0 : 1;
- for (unsigned c = 0, e = 0; c < type->components(); e += edge_inc, c++) {
- const float edge0 = op[0]->value.f[e];
- const float edge1 = op[1]->value.f[e];
- if (edge0 == edge1) {
- data.f[c] = 0.0; /* Avoid a crash - results are undefined anyway */
- } else {
- const float numerator = op[2]->value.f[c] - edge0;
- const float denominator = edge1 - edge0;
- const float t = CLAMP(numerator/denominator, 0, 1);
- data.f[c] = t * t * (3 - 2 * t);
- }
- }
- } else if (strcmp(callee, "sqrt") == 0) {
- expr = new(mem_ctx) ir_expression(ir_unop_sqrt, type, op[0], NULL);
- } else if (strcmp(callee, "step") == 0) {
- assert(op[0]->type->is_float() && op[1]->type->is_float());
- /* op[0] (edge) may be either a scalar or a vector */
- const unsigned c0_inc = op[0]->type->is_scalar() ? 0 : 1;
- for (unsigned c = 0, c0 = 0; c < type->components(); c0 += c0_inc, c++)
- data.f[c] = (op[1]->value.f[c] < op[0]->value.f[c0]) ? 0.0F : 1.0F;
- } else if (strcmp(callee, "tan") == 0) {
- assert(op[0]->type->is_float());
- for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.f[c] = tanf(op[0]->value.f[c]);
- } else if (strcmp(callee, "tanh") == 0) {
- assert(op[0]->type->is_float());
- for (unsigned c = 0; c < op[0]->type->components(); c++)
- data.f[c] = tanhf(op[0]->value.f[c]);
- } else if (strcmp(callee, "transpose") == 0) {
- assert(op[0]->type->is_matrix());
- const unsigned n = op[0]->type->vector_elements;
- const unsigned m = op[0]->type->matrix_columns;
- for (unsigned j = 0; j < m; j++) {
- for (unsigned i = 0; i < n; i++) {
- data.f[m*i+j] += op[0]->value.f[i+n*j];
- }
- }
- } else if (strcmp(callee, "trunc") == 0) {
- expr = new(mem_ctx) ir_expression(ir_unop_trunc, op[0]);
- } else {
- /* Unsupported builtin - some are not allowed in constant expressions. */
- return NULL;
- }
+ /* Now run the builtin function until something non-constant
+ * happens or we get the result.
+ */
+ if (constant_expression_evaluate_expression_list(origin ? origin->body : body, deref_hash, &result) && result)
+ result = result->clone(ralloc_parent(this), NULL);
- if (expr != NULL)
- return expr->constant_expression_value();
+ hash_table_dtor(deref_hash);
- return new(mem_ctx) ir_constant(type, &data);
+ return result;
}