[Mesa-dev] [PATCH 5/6] Bitwise conversion operator support in ir_constant_expression.
Eric Anholt
eric at anholt.net
Mon Apr 30 11:26:55 PDT 2012
On Mon, 30 Apr 2012 13:19:05 +0200, Olivier Galibert <galibert at pobox.com> wrote:
> This patch expects to be applied after the "Constants through builtins
> evaluation rewrite" for two reasons:
> - a line of that patch appears in the context
> - the ir_function side changes that the old method would need are not
> present (and they would conflict)
>
> At that point a "test_out = floatBitsToUint(-1.0);" fired through the
> glsl compiler gives a correct "(assign (x) (var_ref test_out)
> (constant uint (3212836864)))"
>
> Signed-off-by: Olivier Galibert <galibert at pobox.com>
> ---
> src/glsl/ir_constant_expression.cpp | 47 +++++++++++++++++++++++++++++++++++
> 1 file changed, 47 insertions(+)
>
> diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
> index a7aafaa..5e6c164 100644
> --- a/src/glsl/ir_constant_expression.cpp
> +++ b/src/glsl/ir_constant_expression.cpp
> @@ -71,6 +71,29 @@ dot(ir_constant *op0, ir_constant *op1)
> return result;
> }
>
> +/* This method is the only one supported by gcc. Unions in particular
> + * are iffy, and read-through-converted-pointer is killed by strict
> + * aliasing. OTOH, the compiler sees through the memcpy, so the
> + * resulting asm is reasonable.
> + */
While the compiler guys may wish we didn't do the union trick, we (and
projects all over) rely on the union trick to keep working.
That said, I'm not opposed to doing it the memcmp way.
Other than the little nitpick on patch 1, patches 1-5 are:
Reviewed-by: Eric Anholt <eric at anholt.net>
-------------- 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/20120430/b39cf5ae/attachment.pgp>
More information about the mesa-dev
mailing list