summaryrefslogtreecommitdiffstats
path: root/src/glsl/ir_clone.cpp
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2012-03-20 15:56:37 -0700
committerKenneth Graunke <kenneth@whitecape.org>2012-04-02 14:15:41 -0700
commitd884f60861f270cdcf7d9d47765efcf1e1de30b6 (patch)
tree9041472738a13510a6cce1073cf64064eea294ec /src/glsl/ir_clone.cpp
parent622eed075092a0325e0927bf2f9ef29f20bbf416 (diff)
downloadexternal_mesa3d-d884f60861f270cdcf7d9d47765efcf1e1de30b6.zip
external_mesa3d-d884f60861f270cdcf7d9d47765efcf1e1de30b6.tar.gz
external_mesa3d-d884f60861f270cdcf7d9d47765efcf1e1de30b6.tar.bz2
glsl: Convert ir_call to be a statement rather than a value.
Aside from ir_call, our IR is cleanly split into two classes: - Statements (typeless; used for side effects, control flow) - Values (deeply nestable, pure, typed expression trees) Unfortunately, ir_call confused all this: - For void functions, we placed ir_call directly in the instruction stream, treating it as an untyped statement. Yet, it was a subclass of ir_rvalue, and no other ir_rvalue could be used in this way. - For functions with a return value, ir_call could be placed in arbitrary expression trees. While this fit naturally with the source language, it meant that expressions might not be pure, making it difficult to transform and optimize them. To combat this, we always emitted ir_call directly in the RHS of an ir_assignment, only using a temporary variable in expression trees. Many passes relied on this assumption; the acos and atan built-ins violated it. This patch makes ir_call a statement (ir_instruction) rather than a value (ir_rvalue). Non-void calls now take a ir_dereference of a variable, and store the return value there---effectively a call and assignment rolled into one. They cannot be embedded in expressions. All expression trees are now pure, without exception. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/glsl/ir_clone.cpp')
-rw-r--r--src/glsl/ir_clone.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp
index b6d0e8a..8a9701c 100644
--- a/src/glsl/ir_clone.cpp
+++ b/src/glsl/ir_clone.cpp
@@ -167,6 +167,10 @@ ir_loop::clone(void *mem_ctx, struct hash_table *ht) const
ir_call *
ir_call::clone(void *mem_ctx, struct hash_table *ht) const
{
+ ir_dereference_variable *new_return_ref = NULL;
+ if (this->return_deref != NULL)
+ new_return_ref = this->return_deref->clone(mem_ctx, ht);
+
exec_list new_parameters;
foreach_iter(exec_list_iterator, iter, this->actual_parameters) {
@@ -174,7 +178,7 @@ ir_call::clone(void *mem_ctx, struct hash_table *ht) const
new_parameters.push_tail(ir->clone(mem_ctx, ht));
}
- return new(mem_ctx) ir_call(this->callee, &new_parameters);
+ return new(mem_ctx) ir_call(this->callee, new_return_ref, &new_parameters);
}
ir_expression *