|
From: <sv...@va...> - 2005-08-18 17:55:37
|
Author: sewardj
Date: 2005-08-18 12:50:43 +0100 (Thu, 18 Aug 2005)
New Revision: 1339
Log:
Add tested but unused code just in case it is useful at some point in
the future: a potentially more memcheck-friendly implementation of
count-leading-zeroes.
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-08-14 00:50:40 UTC (rev 1338)
+++ trunk/priv/guest-ppc32/toIR.c 2005-08-18 11:50:43 UTC (rev 1339)
@@ -2028,6 +2028,7 @@
assign(Ra, IRExpr_Mux0X( unop(Iop_1Uto8, irx),
mkU32(32),
unop(Iop_Clz32, mkexpr(Rs)) ));
+ // alternatively: assign(Ra, verbose_Clz32(Rs));
break;
=20
case 0x11C: // eqv (Equivalent, PPC32 p396)
@@ -6711,6 +6712,93 @@
}
=20
=20
+/*------------------------------------------------------------*/
+/*--- Unused stuff ---*/
+/*------------------------------------------------------------*/
+
+///* A potentially more memcheck-friendly implementation of Clz32, with
+// the boundary case Clz32(0) =3D 32, which is what ppc requires. */
+//
+//static IRExpr* /* :: Ity_I32 */ verbose_Clz32 ( IRTemp arg )
+//{
+// /* Welcome ... to SSA R Us. */
+// IRTemp n1 =3D newTemp(Ity_I32);
+// IRTemp n2 =3D newTemp(Ity_I32);
+// IRTemp n3 =3D newTemp(Ity_I32);
+// IRTemp n4 =3D newTemp(Ity_I32);
+// IRTemp n5 =3D newTemp(Ity_I32);
+// IRTemp n6 =3D newTemp(Ity_I32);
+// IRTemp n7 =3D newTemp(Ity_I32);
+// IRTemp n8 =3D newTemp(Ity_I32);
+// IRTemp n9 =3D newTemp(Ity_I32);
+// IRTemp n10 =3D newTemp(Ity_I32);
+// IRTemp n11 =3D newTemp(Ity_I32);
+// IRTemp n12 =3D newTemp(Ity_I32);
+//
+// /* First, propagate the most significant 1-bit into all lower
+// positions in the word. */
+// /* unsigned int clz ( unsigned int n )
+// {
+// n |=3D (n >> 1);
+// n |=3D (n >> 2);
+// n |=3D (n >> 4);
+// n |=3D (n >> 8);
+// n |=3D (n >> 16);
+// return bitcount(~n);
+// }
+// */
+// assign(n1, mkexpr(arg));
+// assign(n2, binop(Iop_Or32, mkexpr(n1), binop(Iop_Shr32, mkexpr(n1),=
mkU8(1))));
+// assign(n3, binop(Iop_Or32, mkexpr(n2), binop(Iop_Shr32, mkexpr(n2),=
mkU8(2))));
+// assign(n4, binop(Iop_Or32, mkexpr(n3), binop(Iop_Shr32, mkexpr(n3),=
mkU8(4))));
+// assign(n5, binop(Iop_Or32, mkexpr(n4), binop(Iop_Shr32, mkexpr(n4),=
mkU8(8))));
+// assign(n6, binop(Iop_Or32, mkexpr(n5), binop(Iop_Shr32, mkexpr(n5),=
mkU8(16))));
+// /* This gives a word of the form 0---01---1. Now invert it, giving
+// a word of the form 1---10---0, then do a population-count idiom
+// (to count the 1s, which is the number of leading zeroes, or 32
+// if the original word was 0. */
+// assign(n7, unop(Iop_Not32, mkexpr(n6)));
+//
+// /* unsigned int bitcount ( unsigned int n )
+// {
+// n =3D n - ((n >> 1) & 0x55555555);
+// n =3D (n & 0x33333333) + ((n >> 2) & 0x33333333);
+// n =3D (n + (n >> 4)) & 0x0F0F0F0F;
+// n =3D n + (n >> 8);
+// n =3D (n + (n >> 16)) & 0x3F;
+// return n;
+// }
+// */
+// assign(n8,=20
+// binop(Iop_Sub32,=20
+// mkexpr(n7), =20
+// binop(Iop_And32,=20
+// binop(Iop_Shr32, mkexpr(n7), mkU8(1)),
+// mkU32(0x55555555))));
+// assign(n9,
+// binop(Iop_Add32,
+// binop(Iop_And32, mkexpr(n8), mkU32(0x33333333)),
+// binop(Iop_And32,
+// binop(Iop_Shr32, mkexpr(n8), mkU8(2)),
+// mkU32(0x33333333))));
+// assign(n10,
+// binop(Iop_And32,
+// binop(Iop_Add32,=20
+// mkexpr(n9),=20
+// binop(Iop_Shr32, mkexpr(n9), mkU8(4))),
+// mkU32(0x0F0F0F0F)));
+// assign(n11,
+// binop(Iop_Add32,
+// mkexpr(n10),
+// binop(Iop_Shr32, mkexpr(n10), mkU8(8))));
+// assign(n12,
+// binop(Iop_Add32,
+// mkexpr(n11),
+// binop(Iop_Shr32, mkexpr(n11), mkU8(16))));
+// return
+// binop(Iop_And32, mkexpr(n12), mkU32(0x3F));
+//}
+
/*--------------------------------------------------------------------*/
/*--- end guest-ppc32/toIR.c ---*/
/*--------------------------------------------------------------------*/
|