From: Julian Seward Date: Thu, 28 Dec 2006 04:40:12 +0000 (+0000) Subject: Tidy up and finalise x86/amd64 flag spec rules for 3.2.2. X-Git-Tag: svn/VALGRIND_3_3_1^2~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52e9af6a0feb81c1b0137ee9fe05d365ca838479;p=thirdparty%2Fvalgrind.git Tidy up and finalise x86/amd64 flag spec rules for 3.2.2. x86 COPY-CondP/NP needs re-verification. git-svn-id: svn://svn.valgrind.org/vex/trunk@1713 --- diff --git a/VEX/priv/guest-amd64/ghelpers.c b/VEX/priv/guest-amd64/ghelpers.c index 23952aba37..2c7b4b7153 100644 --- a/VEX/priv/guest-amd64/ghelpers.c +++ b/VEX/priv/guest-amd64/ghelpers.c @@ -904,7 +904,6 @@ IRExpr* guest_amd64_spechelper ( HChar* function_name, return unop(Iop_1Uto64, binop(Iop_CmpEQ64,cc_dep1,cc_dep2)); } - if (isU64(cc_op, AMD64G_CC_OP_SUBQ) && isU64(cond, AMD64CondNZ)) { /* long long sub/cmp, then NZ --> test dst!=src */ return unop(Iop_1Uto64, @@ -924,7 +923,6 @@ IRExpr* guest_amd64_spechelper ( HChar* function_name, return unop(Iop_1Uto64, binop(Iop_CmpLT64U, cc_dep1, cc_dep2)); } - if (isU64(cc_op, AMD64G_CC_OP_SUBQ) && isU64(cond, AMD64CondNB)) { /* long long sub/cmp, then NB (unsigned greater than or equal) --> test src <=u dst */ @@ -949,7 +947,6 @@ IRExpr* guest_amd64_spechelper ( HChar* function_name, binop(Iop_Shl64,cc_dep1,mkU8(32)), binop(Iop_Shl64,cc_dep2,mkU8(32)))); } - if (isU64(cc_op, AMD64G_CC_OP_SUBL) && isU64(cond, AMD64CondNZ)) { /* long sub/cmp, then NZ --> test dst!=src */ return unop(Iop_1Uto64, @@ -985,7 +982,6 @@ IRExpr* guest_amd64_spechelper ( HChar* function_name, binop(Iop_Shl64,cc_dep1,mkU8(32)), binop(Iop_Shl64,cc_dep2,mkU8(32)))); } - if (isU64(cc_op, AMD64G_CC_OP_SUBL) && isU64(cond, AMD64CondNBE)) { /* long sub/cmp, then NBE (unsigned greater than) --> test src test dst!=src */ return unop(Iop_1Uto64, diff --git a/VEX/priv/guest-x86/ghelpers.c b/VEX/priv/guest-x86/ghelpers.c index 3a490f2372..90f4126541 100644 --- a/VEX/priv/guest-x86/ghelpers.c +++ b/VEX/priv/guest-x86/ghelpers.c @@ -832,7 +832,6 @@ IRExpr* guest_x86_spechelper ( HChar* function_name, return unop(Iop_1Uto32, binop(Iop_CmpEQ32, cc_dep1, cc_dep2)); } - if (isU32(cc_op, X86G_CC_OP_SUBL) && isU32(cond, X86CondNZ)) { /* long sub/cmp, then NZ --> test dst!=src */ return unop(Iop_1Uto32, @@ -845,7 +844,6 @@ IRExpr* guest_x86_spechelper ( HChar* function_name, return unop(Iop_1Uto32, binop(Iop_CmpLT32S, cc_dep1, cc_dep2)); } - if (isU32(cc_op, X86G_CC_OP_SUBL) && isU32(cond, X86CondNL)) { /* long sub/cmp, then NL (signed greater than or equal) --> test !(dst test dst >s src --> test !(dst <=s src) */ return binop(Iop_Xor32, @@ -878,7 +875,6 @@ IRExpr* guest_x86_spechelper ( HChar* function_name, return unop(Iop_1Uto32, binop(Iop_CmpLE32U, cc_dep1, cc_dep2)); } - if (isU32(cc_op, X86G_CC_OP_SUBL) && isU32(cond, X86CondNBE)) { /* long sub/cmp, then BE (unsigned greater than) --> test !(dst <=u src) */ @@ -894,7 +890,6 @@ IRExpr* guest_x86_spechelper ( HChar* function_name, return unop(Iop_1Uto32, binop(Iop_CmpLT32U, cc_dep1, cc_dep2)); } - if (isU32(cc_op, X86G_CC_OP_SUBL) && isU32(cond, X86CondNB)) { /* long sub/cmp, then NB (unsigned greater than or equal) --> test !(dst test !(dst-src test dst!=src */ return unop(Iop_1Uto32, @@ -981,7 +974,6 @@ IRExpr* guest_x86_spechelper ( HChar* function_name, /* long and/or/xor, then Z --> test dst==0 */ return unop(Iop_1Uto32,binop(Iop_CmpEQ32, cc_dep1, mkU32(0))); } - if (isU32(cc_op, X86G_CC_OP_LOGICL) && isU32(cond, X86CondNZ)) { /* long and/or/xor, then NZ --> test dst!=0 */ return unop(Iop_1Uto32,binop(Iop_CmpNE32, cc_dep1, mkU32(0))); @@ -1039,17 +1031,6 @@ IRExpr* guest_x86_spechelper ( HChar* function_name, binop(Iop_Shr32,cc_dep1,mkU8(15)), mkU32(1)); } - //Probably correct, but no test case for it yet found - //if (isU32(cc_op, X86G_CC_OP_LOGICW) && isU32(cond, X86CondNS)) { - // /* see comment below for (LOGICB, CondNS) */ - // /* word and/or/xor, then S --> (UInt) ~ result[15] */ - // vassert(0+0); - // return binop(Iop_Xor32, - // binop(Iop_And32, - // binop(Iop_Shr32,cc_dep1,mkU8(15)), - // mkU32(1)), - // mkU32(1)); - //} /*---------------- LOGICB ----------------*/ @@ -1059,7 +1040,6 @@ IRExpr* guest_x86_spechelper ( HChar* function_name, binop(Iop_CmpEQ32, binop(Iop_And32,cc_dep1,mkU32(255)), mkU32(0))); } - if (isU32(cc_op, X86G_CC_OP_LOGICB) && isU32(cond, X86CondNZ)) { /* byte and/or/xor, then Z --> test dst!=0 */ /* b9ac9: 84 c0 test %al,%al @@ -1137,10 +1117,10 @@ IRExpr* guest_x86_spechelper ( HChar* function_name, if (isU32(cc_op, X86G_CC_OP_COPY) && (isU32(cond, X86CondBE) || isU32(cond, X86CondNBE))) { - /* COPY, then BE --> extract C and Z from dep1, and test (C - or Z == 1). */ - /* COPY, then NBE --> extract C and Z from dep1, and test (C - or Z == 0). */ + /* COPY, then BE --> extract C and Z from dep1, and test + (C or Z) == 1. */ + /* COPY, then NBE --> extract C and Z from dep1, and test + (C or Z) == 0. */ UInt nnn = isU32(cond, X86CondBE) ? 1 : 0; return unop( @@ -1201,19 +1181,22 @@ IRExpr* guest_x86_spechelper ( HChar* function_name, ); } - if (isU32(cc_op, X86G_CC_OP_COPY) && isU32(cond, X86CondP)) { + if (isU32(cc_op, X86G_CC_OP_COPY) + && (isU32(cond, X86CondP) || isU32(cond, X86CondNP))) { /* COPY, then P --> extract P from dep1, and test (P == 1). */ + /* COPY, then NP --> extract P from dep1, and test (P == 0). */ + UInt nnn = isU32(cond, X86CondP) ? 1 : 0; return unop( Iop_1Uto32, binop( - Iop_CmpNE32, + Iop_CmpEQ32, binop( Iop_And32, binop(Iop_Shr32, cc_dep1, mkU8(X86G_CC_SHIFT_P)), mkU32(1) ), - mkU32(0) + mkU32(nnn) ) ); }