|
From: <sv...@va...> - 2006-01-18 04:14:58
|
Author: sewardj
Date: 2006-01-18 04:14:52 +0000 (Wed, 18 Jan 2006)
New Revision: 1541
Log:
For ppc64, emit AbiHints from the front end so as to tell tools when
the 288-byte stack should be regarded as having become undefined as
per the ppc64 ELF ABI.
Modified:
trunk/priv/guest-ppc/toIR.c
trunk/priv/host-ppc/isel.c
Modified: trunk/priv/guest-ppc/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-ppc/toIR.c 2006-01-17 01:48:46 UTC (rev 1540)
+++ trunk/priv/guest-ppc/toIR.c 2006-01-18 04:14:52 UTC (rev 1541)
@@ -46,8 +46,8 @@
=20
/* TODO 18/Nov/05:
=20
- Spot rlwimi cases which are simply left/right shifts and
- emit Shl32/Shr32 accordingly.
+ Spot rld... cases which are simply left/right shifts and emit
+ Shl64/Shr64 accordingly.
=20
Altivec
- datastream insns
@@ -81,6 +81,11 @@
to zero, whereas we keep maximum accuracy. However, using
Non-Java mode would give us more inaccuracy, as our intermediate
results would then be zeroed, too.
+
+ - 64-bit mode: AbiHints for the stack red zone are only emitted for
+ unconditional calls and returns (bl, blr). They should also be
+ emitted for conditional calls and returns, but we don't have a=20
+ way to express that right now. Ah well.
*/
=20
/* "Special" instructions.
@@ -1193,6 +1198,22 @@
}
=20
=20
+/* Generate AbiHints which mark points at which the ELF ppc64 ABI says
+ that the stack red zone (viz, -288(r1) .. -1(r1)) becomes
+ undefined. That is at function calls and returns. Only in 64-bit
+ mode - ELF ppc32 doesn't have this "feature".
+*/
+static void make_redzone_AbiHint ( HChar* who )
+{
+ if (0) vex_printf("AbiHint: %s\n", who);
+ vassert(mode64);
+ stmt( IRStmt_AbiHint(=20
+ binop(Iop_Sub64, getIReg(1), mkU64(288)),=20
+ 288=20
+ ));
+}
+
+
/*------------------------------------------------------------*/
/*--- Helpers for condition codes. ---*/
/*------------------------------------------------------------*/
@@ -4193,8 +4214,11 @@
flag_LK ? "l" : "", flag_AA ? "a" : "", (Addr32)tgt);
}
=20
- if (flag_LK)
+ if (flag_LK) {
putGST( PPC_GST_LR, e_nia );
+ if (mode64)
+ make_redzone_AbiHint( "branch-and-link (unconditional call)"=
);
+ }
=20
if (resteerOkFn( callback_opaque, tgt )) {
dres->whatNext =3D Dis_Resteer;
@@ -4273,10 +4297,11 @@
irbb->next =3D mkexpr(lr_old);
break;
=20
- case 0x010: // bclr (Branch Cond. to Link Register, PPC32 p365)=20
-
+ case 0x010: { // bclr (Branch Cond. to Link Register, PPC32 p365)=20
+ Bool vanilla_return =3D False;
if ((BO & 0x14 /* 1z1zz */) =3D=3D 0x14 && flag_LK =3D=3D 0) {
DIP("blr\n");
+ vanilla_return =3D True;
} else {
DIP("bclr%s 0x%x, 0x%x\n", flag_LK ? "l" : "", BO, BI);
}
@@ -4303,13 +4328,16 @@
Ijk_Boring,
c_nia ));
=20
+ if (vanilla_return && mode64)
+ make_redzone_AbiHint( "branch-to-lr (unconditional return)" =
);
+
/* blrl is pretty strange; it's like a return that sets the
return address of its caller to the insn following this
one. Mark it as a return. */
irbb->jumpkind =3D Ijk_Ret; /* was flag_LK ? Ijk_Call : Ijk_Re=
t; */
irbb->next =3D mkexpr(lr_old);
break;
- =20
+ }
default:
vex_printf("dis_int_branch(ppc)(opc2)\n");
return False;
Modified: trunk/priv/host-ppc/isel.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-ppc/isel.c 2006-01-17 01:48:46 UTC (rev 1540)
+++ trunk/priv/host-ppc/isel.c 2006-01-18 04:14:52 UTC (rev 1541)
@@ -4455,6 +4455,12 @@
case Ist_IMark:
return;
=20
+ /* --------- ABI HINT --------- */
+ /* These have no meaning (denotation in the IR) and so we ignore
+ them ... if any actually made it this far. */
+ case Ist_AbiHint:
+ return;
+
/* --------- NO-OP --------- */
/* Fairly self-explanatory, wouldn't you say? */
case Ist_NoOp:
|