From: Julian Seward Date: Sun, 25 Jul 2004 17:25:55 +0000 (+0000) Subject: Add a few more flag evaluation routines. X-Git-Tag: svn/VALGRIND_3_0_1^2~1213 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f74d15a103d1888f93b2bb5fbcddc7f76261770;p=thirdparty%2Fvalgrind.git Add a few more flag evaluation routines. git-svn-id: svn://svn.valgrind.org/vex/trunk@121 --- diff --git a/VEX/priv/guest-x86/x86guest_defs.h b/VEX/priv/guest-x86/x86guest_defs.h index d1ba7d6d59..7d8d76c2bb 100644 --- a/VEX/priv/guest-x86/x86guest_defs.h +++ b/VEX/priv/guest-x86/x86guest_defs.h @@ -62,11 +62,11 @@ enum { CC_OP_SBBB, /* modify all flags, CC_DST = res, CC_SRC = src1 */ CC_OP_SBBW, - CC_OP_SBBL, + CC_OP_SBBL, /* 12 */ CC_OP_LOGICB, /* modify all flags, CC_DST = res */ CC_OP_LOGICW, - CC_OP_LOGICL, + CC_OP_LOGICL, /* 15 */ CC_OP_INCB, /* modify all flags except, CC_DST = res, CC_SRC = C */ CC_OP_INCW, diff --git a/VEX/priv/guest-x86/x86helpers.c b/VEX/priv/guest-x86/x86helpers.c index e2e06dfa72..badce8f2fd 100644 --- a/VEX/priv/guest-x86/x86helpers.c +++ b/VEX/priv/guest-x86/x86helpers.c @@ -99,13 +99,29 @@ static inline int lshift(int x, int n) return cf | pf | af | zf | sf | of; \ } +#define ACTIONS_LOGIC(DATA_BITS,DATA_TYPE,DATA_STYPE) \ + { \ + PREAMBLE(DATA_BITS); \ + int cf, pf, af, zf, sf, of; \ + cf = 0; \ + pf = parity_table[(uint8_t)CC_DST]; \ + af = 0; \ + zf = ((DATA_TYPE)CC_DST == 0) << 6; \ + sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; \ + of = 0; \ + return cf | pf | af | zf | sf | of; \ + } + -/* RUNS AS PART OF GENERATED CODE */ +/* CALLED FROM GENERATED CODE */ /*static*/ UInt calculate_eflags_all ( UInt cc_op, UInt cc_src, UInt cc_dst ) { switch (cc_op) { - case CC_OP_SUBL: ACTIONS_SUB(32,UChar,Char); + case CC_OP_COPY: + return cc_src & (CC_MASK_O | CC_MASK_S | CC_MASK_Z | CC_MASK_A | CC_MASK_C | CC_MASK_O); + case CC_OP_SUBL: ACTIONS_SUB(32,UChar,Char); + case CC_OP_LOGICL: ACTIONS_LOGIC(32,UChar,Char); default: /* shouldn't really make these calls from generated code */ vex_printf("calculate_eflags_all( %d, 0x%x, 0x%x )\n", @@ -114,7 +130,7 @@ static inline int lshift(int x, int n) } } -/* RUNS AS PART OF GENERATED CODE */ +/* CALLED FROM GENERATED CODE */ static UInt calculate_eflags_c ( UInt cc_op, UInt cc_src, UInt cc_dst ) { return calculate_eflags_all(cc_op,cc_src,cc_dst) & CC_MASK_C;