[Mesa-dev] [PATCH 3/5] glsl: Convert ir_call to be a statement rather than an rvalue.

Eric Anholt eric at anholt.net
Wed Sep 21 10:36:39 PDT 2011

On Tue, 20 Sep 2011 18:28:17 -0700, Kenneth Graunke <kenneth at whitecape.org> wrote:
> This begins the process of cleaning up and un-muddling our IR.
> 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 at whitecape.org>

I spent most of my review time on this looking at the optimization pass
changes, so I haven't done as much coverage of the ast-level changes.

Reviewed-by: Eric Anholt <eric at anholt.net>

> diff --git a/src/glsl/ir_expression_flattening.cpp b/src/glsl/ir_expression_flattening.cpp
> index 0b7c537..3922da8 100644
> --- a/src/glsl/ir_expression_flattening.cpp
> +++ b/src/glsl/ir_expression_flattening.cpp
> @@ -27,10 +27,8 @@
>   * Takes the leaves of expression trees and makes them dereferences of
>   * assignments of the leaves to temporaries, according to a predicate.
>   *
> - * This is used for automatic function inlining, where we want to take
> - * an expression containing a call and move the call out to its own
> - * assignment so that we can inline it at the appropriate place in the
> - * instruction stream.
> + * This is used for breaking down matrix operations, where it's easier to
> + * create a temporary and work on each of its vectory components individually.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110921/c6d58ce2/attachment-0001.pgp>

More information about the mesa-dev mailing list