|
From: <sv...@va...> - 2005-06-23 08:44:56
|
Author: cerion
Date: 2005-06-23 09:44:52 +0100 (Thu, 23 Jun 2005)
New Revision: 1217
Log:
Fix ppc32 'Call' bug
- was (very) incorrectly jumping over the call on cond failure
Modified:
trunk/priv/host-ppc32/hdefs.c
Modified: trunk/priv/host-ppc32/hdefs.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/host-ppc32/hdefs.c 2005-06-21 13:51:18 UTC (rev 1216)
+++ trunk/priv/host-ppc32/hdefs.c 2005-06-23 08:44:52 UTC (rev 1217)
@@ -784,7 +784,7 @@
}
vex_printf("{ ");
ppLoadImm(hregPPC32_GPR12(), i->Pin.Call.target);
- vex_printf(" ; mtctr r12 ; bctrl[%d] }",i->Pin.Call.regparms);
+ vex_printf(" ; mtctr r12 ; bctrl [regparms=3D%d] }",i->Pin.Call.re=
gparms);
break;
case Pin_Goto:
vex_printf("goto: ");
@@ -1771,20 +1771,29 @@
=20
/* jump over the following insns if condition does not hold */
if (cond.test !=3D Pct_ALWAYS) {
- UInt delta =3D 4*4; /* jump 4 instrs */
-
- /* bca !ct,cf,dst */
- p =3D mkFormB(ptmp, invertCondTest(cond.test), cond.flag, (delt=
a>>2), 1, 0);
+ /* jmp fwds if !condition */
+ /* don't know how many bytes to jump over yet...
+ make space for a jump instruction and fill in later. */
+ ptmp =3D p; /* fill in this bit later */
+ p +=3D 4; // p +=3D=
4
}
=20
/* load target to r_dst */
- p =3D mkLoadImm(p, r_dst, i->Pin.Call.target);
+ p =3D mkLoadImm(p, r_dst, i->Pin.Call.target); // p +=3D=
4|8
=20
/* mtspr 9,r_dst =3D> move r_dst to count register */
- p =3D mkFormXFX(p, r_dst, 9, 467);
+ p =3D mkFormXFX(p, r_dst, 9, 467); // p +=3D=
4
=20
/* bctrl =3D> branch to count register (and save to lr) */
- p =3D mkFormXL(p, 19, Pct_ALWAYS, 0, 0, 528, 1);
+ p =3D mkFormXL(p, 19, Pct_ALWAYS, 0, 0, 528, 1); // p +=3D=
4
+
+ /* Fix up the conditional jump, if there was one. */
+ if (cond.test !=3D Pct_ALWAYS) {
+ Int delta =3D p - ptmp;
+ vassert(delta >=3D 16 && delta <=3D 20);
+ /* bc !ct,cf,delta */
+ mkFormB(ptmp, invertCondTest(cond.test), cond.flag, (delta>>2),=
0, 0);
+ }
goto done;
}
=20
|