|
From: <sv...@va...> - 2005-08-24 17:45:36
|
Author: sewardj
Date: 2005-08-24 18:45:33 +0100 (Wed, 24 Aug 2005)
New Revision: 1359
Log:
Merge r1341 (x86 RCL implementation)
Modified:
branches/VEX_3_0_BRANCH/priv/guest-x86/gdefs.h
branches/VEX_3_0_BRANCH/priv/guest-x86/ghelpers.c
branches/VEX_3_0_BRANCH/priv/guest-x86/toIR.c
Modified: branches/VEX_3_0_BRANCH/priv/guest-x86/gdefs.h
=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/VEX_3_0_BRANCH/priv/guest-x86/gdefs.h 2005-08-24 17:39:26 UT=
C (rev 1358)
+++ branches/VEX_3_0_BRANCH/priv/guest-x86/gdefs.h 2005-08-24 17:45:33 UT=
C (rev 1359)
@@ -104,9 +104,12 @@
=20
extern UInt x86g_calculate_FXAM ( UInt tag, ULong dbl );
=20
-extern ULong x86g_calculate_RCR (=20
+extern ULong x86g_calculate_RCR (=20
UInt arg, UInt rot_amt, UInt eflags_in, UInt sz=20
);
+extern ULong x86g_calculate_RCL (=20
+ UInt arg, UInt rot_amt, UInt eflags_in, UInt sz=20
+ );
=20
extern ULong x86g_check_fldcw ( UInt fpucw );
=20
Modified: branches/VEX_3_0_BRANCH/priv/guest-x86/ghelpers.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/VEX_3_0_BRANCH/priv/guest-x86/ghelpers.c 2005-08-24 17:39:26=
UTC (rev 1358)
+++ branches/VEX_3_0_BRANCH/priv/guest-x86/ghelpers.c 2005-08-24 17:45:33=
UTC (rev 1359)
@@ -1638,6 +1638,61 @@
}
=20
=20
+/* CALLED FROM GENERATED CODE: CLEAN HELPER */
+/* Calculate both flags and value result for rotate left
+ through the carry bit. Result in low 32 bits,=20
+ new flags (OSZACP) in high 32 bits.
+*/
+ULong x86g_calculate_RCL ( UInt arg, UInt rot_amt, UInt eflags_in, UInt =
sz )
+{
+ UInt tempCOUNT =3D rot_amt & 0x1F, cf=3D0, of=3D0, tempcf;
+
+ switch (sz) {
+ case 4:
+ cf =3D (eflags_in >> X86G_CC_SHIFT_C) & 1;
+ while (tempCOUNT > 0) {
+ tempcf =3D (arg >> 31) & 1;
+ arg =3D (arg << 1) | (cf & 1);
+ cf =3D tempcf;
+ tempCOUNT--;
+ }
+ of =3D ((arg >> 31) ^ cf) & 1;
+ break;
+ case 2:
+ while (tempCOUNT >=3D 17) tempCOUNT -=3D 17;
+ cf =3D (eflags_in >> X86G_CC_SHIFT_C) & 1;
+ while (tempCOUNT > 0) {
+ tempcf =3D (arg >> 15) & 1;
+ arg =3D 0xFFFF & ((arg << 1) | (cf & 1));
+ cf =3D tempcf;
+ tempCOUNT--;
+ }
+ of =3D ((arg >> 15) ^ cf) & 1;
+ break;
+ case 1:
+ while (tempCOUNT >=3D 9) tempCOUNT -=3D 9;
+ cf =3D (eflags_in >> X86G_CC_SHIFT_C) & 1;
+ while (tempCOUNT > 0) {
+ tempcf =3D (arg >> 7) & 1;
+ arg =3D 0xFF & ((arg << 1) | (cf & 1));
+ cf =3D tempcf;
+ tempCOUNT--;
+ }
+ of =3D ((arg >> 7) ^ cf) & 1;
+ break;
+ default:=20
+ vpanic("calculate_RCL: invalid size");
+ }
+
+ cf &=3D 1;
+ of &=3D 1;
+ eflags_in &=3D ~(X86G_CC_MASK_C | X86G_CC_MASK_O);
+ eflags_in |=3D (cf << X86G_CC_SHIFT_C) | (of << X86G_CC_SHIFT_O);
+
+ return (((ULong)eflags_in) << 32) | ((ULong)arg);
+}
+
+
/* CALLED FROM GENERATED CODE */
/* DIRTY HELPER (non-referentially-transparent) */
/* Horrible hack. On non-x86 platforms, return 1. */
Modified: branches/VEX_3_0_BRANCH/priv/guest-x86/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
--- branches/VEX_3_0_BRANCH/priv/guest-x86/toIR.c 2005-08-24 17:39:26 UTC=
(rev 1358)
+++ branches/VEX_3_0_BRANCH/priv/guest-x86/toIR.c 2005-08-24 17:45:33 UTC=
(rev 1359)
@@ -2147,7 +2147,7 @@
/* delta on entry points at the modrm byte. */
HChar dis_buf[50];
Int len;
- Bool isShift, isRotate, isRotateRC;
+ Bool isShift, isRotate, isRotateC;
IRType ty =3D szToITy(sz);
IRTemp dst0 =3D newTemp(ty);
IRTemp dst1 =3D newTemp(ty);
@@ -2171,16 +2171,18 @@
isRotate =3D False;
switch (gregOfRM(modrm)) { case 0: case 1: isRotate =3D True; }
=20
- isRotateRC =3D toBool(gregOfRM(modrm) =3D=3D 3);
+ isRotateC =3D False;
+ switch (gregOfRM(modrm)) { case 2: case 3: isRotateC =3D True; }
=20
- if (!isShift && !isRotate && !isRotateRC) {
+ if (!isShift && !isRotate && !isRotateC) {
vex_printf("\ncase %d\n", gregOfRM(modrm));
vpanic("dis_Grp2(Reg): unhandled case(x86)");
}
=20
- if (isRotateRC) {
- /* call a helper; this insn is so ridiculous it does not deserve
- better */
+ if (isRotateC) {
+ /* call a helper; these insns are so ridiculous they do not
+ deserve better */
+ Bool left =3D toBool(gregOfRM(modrm) =3D=3D 2);
IRTemp r64 =3D newTemp(Ity_I64);
IRExpr** args=20
=3D mkIRExprVec_4( widenUto32(mkexpr(dst0)), /* thing to rotate=
*/
@@ -2190,7 +2192,8 @@
assign( r64, mkIRExprCCall(
Ity_I64,=20
0/*regparm*/,=20
- "x86g_calculate_RCR", &x86g_calculate_RCR,
+ left ? "x86g_calculate_RCL" : "x86g_calculate_RCR"=
,=20
+ left ? &x86g_calculate_RCL : &x86g_calculate_RCR,
args
)
);
|