|
From: <sv...@va...> - 2005-11-23 03:53:51
|
Author: sewardj
Date: 2005-11-23 03:53:45 +0000 (Wed, 23 Nov 2005)
New Revision: 1467
Log:
Do float-to-bit-image conversion in a way which does not break ANSI C
aliasing rules.
Modified:
trunk/priv/guest-ppc32/toIR.c
Modified: trunk/priv/guest-ppc32/toIR.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/priv/guest-ppc32/toIR.c 2005-11-18 22:18:23 UTC (rev 1466)
+++ trunk/priv/guest-ppc32/toIR.c 2005-11-23 03:53:45 UTC (rev 1467)
@@ -303,7 +303,19 @@
=20
static void put_emwarn ( IRExpr* e /* :: Ity_I32 */ );
=20
+/* Produce the 32-bit pattern corresponding to the supplied
+ float. */
+static UInt float_to_bits ( Float f )
+{
+ union { UInt i; Float f; } u;
+ vassert(4 =3D=3D sizeof(UInt));
+ vassert(4 =3D=3D sizeof(Float));
+ vassert(4 =3D=3D sizeof(u));
+ u.f =3D f;
+ return u.i;
+}
=20
+
/*------------------------------------------------------------*/
/*--- Misc Helpers ---*/
/*------------------------------------------------------------*/
@@ -6830,9 +6842,9 @@
=20
/* scale =3D 2^UIMM, cast to float, reinterpreted as uint */
scale =3D (float)( (unsigned int) 1<<UIMM_5 );
- assign( vScale, unop(Iop_Dup32x4, mkU32( *((unsigned int*)(&scale)) )=
) );
+ assign( vScale, unop(Iop_Dup32x4, mkU32( float_to_bits(scale) )) );
inv_scale =3D 1/scale;
- assign( vInvScale, unop(Iop_Dup32x4, mkU32( *((unsigned int*)(&inv_sc=
ale)) )) );
+ assign( vInvScale, unop(Iop_Dup32x4, mkU32( float_to_bits(inv_scale) =
)) );
=20
if (opc1 !=3D 0x4) {
vex_printf("dis_av_fp_convert(PPC32)(instr)\n");
|