|
From: <sv...@va...> - 2005-12-07 22:19:40
|
Author: sewardj
Date: 2005-12-07 22:19:36 +0000 (Wed, 07 Dec 2005)
New Revision: 1486
Log:
Function wrapping: add tri-state hack to deal with libpthread better.
Modified:
branches/FNWRAP/priv/guest-generic/bb_to_IR.c
Modified: branches/FNWRAP/priv/guest-generic/bb_to_IR.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
--- branches/FNWRAP/priv/guest-generic/bb_to_IR.c 2005-12-07 17:31:42 UTC=
(rev 1485)
+++ branches/FNWRAP/priv/guest-generic/bb_to_IR.c 2005-12-07 22:19:36 UTC=
(rev 1486)
@@ -76,7 +76,22 @@
IRExpr_Unop(Iop_1Uto64,y)));
}
=20
+static IRExpr* mkOr1 ( IRType ty, IRExpr* x, IRExpr* y )
+{
+ vassert(ty =3D=3D Ity_I32 || ty =3D=3D Ity_I64);
+ return=20
+ ty =3D=3D Ity_I32
+ ? IRExpr_Unop(Iop_32to1,
+ IRExpr_Binop(Iop_Or32,
+ IRExpr_Unop(Iop_1Uto32,x),
+ IRExpr_Unop(Iop_1Uto32,y)))
+ : IRExpr_Unop(Iop_64to1,
+ IRExpr_Binop(Iop_Or64,
+ IRExpr_Unop(Iop_1Uto64,x),
+ IRExpr_Unop(Iop_1Uto64,y)));
+}
=20
+
/* Disassemble a complete basic block, starting at guest_IP_start,=20
returning a new IRBB. The disassembler may chase across basic
block boundaries if it wishes and if chase_into_ok allows it.
@@ -179,35 +194,43 @@
if (do_noredir_check) {
/* Create this:
tmp =3D _NRFLAG;
- _NRFLAG =3D 0;
- if (tmp !=3D 0 && _NRADDR =3D=3D guest_IP_bbstart_noredir)
+ _NRFLAG =3D tmp-1;
+ if ( (tmp =3D=3D 1 && _NRADDR =3D=3D guest_IP_bbstart_noredir=
)
+ || tmp =3D=3D 2)
exit, request noredir xfer to guest_IP_bbstart_noredir
_NRFLAG =3D tmp -- restores _NRFLAG to whatever it was
*/
IRTemp tmp =3D newIRTemp(irbb->tyenv, guest_word_type);
- IRExpr* zero =3D guest_word_type=3D=3DIty_I32=20
- ? IRExpr_Const(IRConst_U32(0))=20
- : IRExpr_Const(IRConst_U64(0));
+ IRExpr* one =3D guest_word_type=3D=3DIty_I32=20
+ ? IRExpr_Const(IRConst_U32(1))=20
+ : IRExpr_Const(IRConst_U64(1));
+ IRExpr* two =3D guest_word_type=3D=3DIty_I32=20
+ ? IRExpr_Const(IRConst_U32(2))=20
+ : IRExpr_Const(IRConst_U64(2));
IROp cmpEQ =3D guest_word_type=3D=3DIty_I32 ? Iop_CmpEQ32 : Iop_Cm=
pEQ64;
- IROp cmpNE =3D guest_word_type=3D=3DIty_I32 ? Iop_CmpNE32 : Iop_Cm=
pNE64;
+ IROp opSUB =3D guest_word_type=3D=3DIty_I32 ? Iop_Sub32 : Iop_Sub6=
4;
=20
/* fetch old flag */
addStmtToIRBB( irbb,=20
IRStmt_Tmp( tmp,=20
IRExpr_Get(offB_NRFLAG, guest_word_type)));
- /* zero flag */
+ /* flag-- */
addStmtToIRBB( irbb,
- IRStmt_Put( offB_NRFLAG, zero ));
+ IRStmt_Put( offB_NRFLAG, IRExpr_Binop(opSUB, IRExpr_Tmp(tmp), o=
ne) ));
/* exit, maybe */
addStmtToIRBB( irbb,
- IRStmt_Exit(=20
- mkAnd1( guest_word_type,
- IRExpr_Binop( cmpNE, IRExpr_Tmp(tmp), zero ),
- IRExpr_Binop(=20
- cmpEQ,=20
- IRExpr_Get(offB_NRADDR, guest_word_type),
- IRExpr_Const(guest_IP_bbstart_noredir_IRConst)
- )
+ IRStmt_Exit(
+ mkOr1(
+ guest_word_type,
+ mkAnd1( guest_word_type,
+ IRExpr_Binop( cmpEQ, IRExpr_Tmp(tmp), one ),
+ IRExpr_Binop(=20
+ cmpEQ,=20
+ IRExpr_Get(offB_NRADDR, guest_word_type),
+ IRExpr_Const(guest_IP_bbstart_noredir_IRConst)
+ )
+ ),
+ IRExpr_Binop( cmpEQ, IRExpr_Tmp(tmp), two )
),
Ijk_NoRedir,
guest_IP_bbstart_noredir_IRConst=20
@@ -215,6 +238,7 @@
/* if we didn't exit, now need to restore the flag */
addStmtToIRBB( irbb,
IRStmt_Put( offB_NRFLAG, IRExpr_Tmp(tmp) ));
+
}
=20
/* If asked to make a self-checking translation, leave 5 spaces
|