|
From: <sv...@va...> - 2005-08-23 15:41:18
|
Author: sewardj
Date: 2005-08-23 16:41:14 +0100 (Tue, 23 Aug 2005)
New Revision: 1341
Log:
Support x86 RCL instructions.
Modified:
trunk/priv/guest-x86/gdefs.h
trunk/priv/guest-x86/ghelpers.c
trunk/priv/guest-x86/toIR.c
Modified: trunk/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
--- trunk/priv/guest-x86/gdefs.h 2005-08-21 00:48:37 UTC (rev 1340)
+++ trunk/priv/guest-x86/gdefs.h 2005-08-23 15:41:14 UTC (rev 1341)
@@ -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: trunk/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
--- trunk/priv/guest-x86/ghelpers.c 2005-08-21 00:48:37 UTC (rev 1340)
+++ trunk/priv/guest-x86/ghelpers.c 2005-08-23 15:41:14 UTC (rev 1341)
@@ -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 (modifies guest state) */
/* Claim to be a P55C (Intel Pentium/MMX) */
Modified: trunk/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
--- trunk/priv/guest-x86/toIR.c 2005-08-21 00:48:37 UTC (rev 1340)
+++ trunk/priv/guest-x86/toIR.c 2005-08-23 15:41:14 UTC (rev 1341)
@@ -2146,7 +2146,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);
@@ -2170,16 +2170,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=
*/
@@ -2189,7 +2191,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
)
);
|