From: Julian Seward Date: Thu, 26 Aug 2004 01:25:07 +0000 (+0000) Subject: Add a bit of structure in x86guest_findhelper. X-Git-Tag: svn/VALGRIND_3_0_1^2~1120 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=38591bf0ce0dd48b546a410e953f804bc744d57d;p=thirdparty%2Fvalgrind.git Add a bit of structure in x86guest_findhelper. git-svn-id: svn://svn.valgrind.org/vex/trunk@214 --- diff --git a/VEX/priv/guest-x86/ghelpers.c b/VEX/priv/guest-x86/ghelpers.c index 1db7e98fb1..968867d2b7 100644 --- a/VEX/priv/guest-x86/ghelpers.c +++ b/VEX/priv/guest-x86/ghelpers.c @@ -506,7 +506,7 @@ static UInt calculate_eflags_c ( UInt cc_op, UInt cc_src, UInt cc_dst ) tab[cc_op][cond]++; n_calc_cond++; - if (0 == ((n_calc_all+n_calc_c) & 0x0FFF)) showCounts(); + if (0 == ((n_calc_all+n_calc_c) & 0x3FFF)) showCounts(); # endif switch (cond) { @@ -651,13 +651,44 @@ IRExpr* x86guest_spechelper ( Char* function_name, cc_src = args[2]; cc_dst = args[3]; - if (isU32(cc_op, CC_OP_LOGICB) && isU32(cond, CondZ)) { - /* byte and/or/xor, then Z --> test dst==0 */ + /*---------------- SUBL ----------------*/ + + if (isU32(cc_op, CC_OP_SUBL) && isU32(cond, CondZ)) { + /* long sub/cmp, then Z --> test dst==src */ return unop(Iop_1Uto32, - binop(Iop_CmpEQ32, binop(Iop_And32,cc_dst,mkU32(255)), - mkU32(0))); + binop(Iop_CmpEQ32, cc_dst, cc_src)); + } + + if (isU32(cc_op, CC_OP_SUBL) && isU32(cond, CondL)) { + /* long sub/cmp, then L (signed less than) + --> test dst test dst <=s src */ + return unop(Iop_1Uto32, + binop(Iop_CmpLE32S, cc_dst, cc_src)); + } + + if (isU32(cc_op, CC_OP_SUBL) && isU32(cond, CondBE)) { + /* long sub/cmp, then BE (unsigned less than or equal) + --> test dst <=u src */ + return unop(Iop_1Uto32, + binop(Iop_CmpLE32U, cc_dst, cc_src)); + } + + if (isU32(cc_op, CC_OP_SUBL) && isU32(cond, CondB)) { + /* long sub/cmp, then B (unsigned less than) + --> test dst test dst==src */ return unop(Iop_1Uto32, @@ -666,6 +697,8 @@ IRExpr* x86guest_spechelper ( Char* function_name, unop(Iop_32to16,cc_src))); } + /*---------------- SUBB ----------------*/ + if (isU32(cc_op, CC_OP_SUBB) && isU32(cond, CondZ)) { /* byte sub/cmp, then Z --> test dst==src */ return unop(Iop_1Uto32, @@ -691,6 +724,8 @@ IRExpr* x86guest_spechelper ( Char* function_name, binop(Iop_And32,cc_dst,mkU32(0xFFFF)))); } + /*---------------- LOGICL ----------------*/ + if (isU32(cc_op, CC_OP_LOGICL) && isU32(cond, CondZ)) { /* long and/or/xor, then Z --> test dst==0 */ return unop(Iop_1Uto32,binop(Iop_CmpEQ32, cc_dst, mkU32(0))); @@ -711,39 +746,16 @@ IRExpr* x86guest_spechelper ( Char* function_name, return unop(Iop_1Uto32,binop(Iop_CmpLE32S, cc_dst, mkU32(0))); } - if (isU32(cc_op, CC_OP_SUBL) && isU32(cond, CondZ)) { - /* long sub/cmp, then Z --> test dst==src */ - return unop(Iop_1Uto32, - binop(Iop_CmpEQ32, cc_dst, cc_src)); - } - - if (isU32(cc_op, CC_OP_SUBL) && isU32(cond, CondL)) { - /* long sub/cmp, then L (signed less than) - --> test dst test dst <=s src */ - return unop(Iop_1Uto32, - binop(Iop_CmpLE32S, cc_dst, cc_src)); - } + /*---------------- LOGICB ----------------*/ - if (isU32(cc_op, CC_OP_SUBL) && isU32(cond, CondBE)) { - /* long sub/cmp, then BE (unsigned less than or equal) - --> test dst <=u src */ + if (isU32(cc_op, CC_OP_LOGICB) && isU32(cond, CondZ)) { + /* byte and/or/xor, then Z --> test dst==0 */ return unop(Iop_1Uto32, - binop(Iop_CmpLE32U, cc_dst, cc_src)); + binop(Iop_CmpEQ32, binop(Iop_And32,cc_dst,mkU32(255)), + mkU32(0))); } - if (isU32(cc_op, CC_OP_SUBL) && isU32(cond, CondB)) { - /* long sub/cmp, then B (unsigned less than) - --> test dst test dst == 0 */