|
From: <sv...@va...> - 2006-02-07 20:55:14
|
Author: sewardj
Date: 2006-02-07 20:55:08 +0000 (Tue, 07 Feb 2006)
New Revision: 1572
Log:
Word size fixes for twi/tdi (is trickier than it looks :-). Also add
missing DIP macros.
Modified:
trunk/priv/guest-ppc/toIR.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-02-07 16:42:39 UTC (rev 1571)
+++ trunk/priv/guest-ppc/toIR.c 2006-02-07 20:55:08 UTC (rev 1572)
@@ -4489,22 +4489,22 @@
=20
/* Do the code generation for a trap. Returned Bool is true iff
this is an unconditional trap. */
-static Bool do_trap ( IRType ty, UChar TO,=20
+static Bool do_trap ( Bool is_twi, UChar TO,=20
IRExpr* argL0, ULong argR0, Addr64 cia )
{
IRTemp argL, argR;
IRExpr *argLe, *argRe, *cond, *tmp;
=20
- IROp opAND =3D ty=3D=3DIty_I32 ? Iop_And32 : Iop_And64;
- IROp opOR =3D ty=3D=3DIty_I32 ? Iop_Or32 : Iop_Or64;
- IROp opCMPORDS =3D ty=3D=3DIty_I32 ? Iop_CmpORD32S : Iop_CmpORD64S=
;
- IROp opCMPORDU =3D ty=3D=3DIty_I32 ? Iop_CmpORD32U : Iop_CmpORD64U=
;
- IROp opCMPNE =3D ty=3D=3DIty_I32 ? Iop_CmpNE32 : Iop_CmpNE64;
- IROp opCMPEQ =3D ty=3D=3DIty_I32 ? Iop_CmpEQ32 : Iop_CmpEQ64;
- IRExpr* const0 =3D ty=3D=3DIty_I32 ? mkU32(0) : mkU64(0);
- IRExpr* const2 =3D ty=3D=3DIty_I32 ? mkU32(2) : mkU64(2);
- IRExpr* const4 =3D ty=3D=3DIty_I32 ? mkU32(4) : mkU64(4);
- IRExpr* const8 =3D ty=3D=3DIty_I32 ? mkU32(8) : mkU64(8);
+ IROp opAND =3D is_twi ? Iop_And32 : Iop_And64;
+ IROp opOR =3D is_twi ? Iop_Or32 : Iop_Or64;
+ IROp opCMPORDS =3D is_twi ? Iop_CmpORD32S : Iop_CmpORD64S;
+ IROp opCMPORDU =3D is_twi ? Iop_CmpORD32U : Iop_CmpORD64U;
+ IROp opCMPNE =3D is_twi ? Iop_CmpNE32 : Iop_CmpNE64;
+ IROp opCMPEQ =3D is_twi ? Iop_CmpEQ32 : Iop_CmpEQ64;
+ IRExpr* const0 =3D is_twi ? mkU32(0) : mkU64(0);
+ IRExpr* const2 =3D is_twi ? mkU32(2) : mkU64(2);
+ IRExpr* const4 =3D is_twi ? mkU32(4) : mkU64(4);
+ IRExpr* const8 =3D is_twi ? mkU32(8) : mkU64(8);
=20
const UChar b11100 =3D 0x1C;
const UChar b00111 =3D 0x07;
@@ -4520,16 +4520,16 @@
return True; /* unconditional trap */
}
=20
- /* ty is the type at which the comparisons are done. This is not
- the same as the 32/64-mode-ness. */
- vassert(ty =3D=3D Ity_I32 || ty =3D=3D Ity_I64);
- argL =3D newTemp(ty);
- argR =3D newTemp(ty);
- if (ty =3D=3D Ity_I32) {
- assign( argL, mkSzNarrow32(Ity_I32, argL0) );
+ if (is_twi) {
+ argL =3D newTemp(Ity_I32);
+ argR =3D newTemp(Ity_I32);
+ assign( argL, mode64 ? mkSzNarrow32(Ity_I64,argL0)
+ : argL0 );
assign( argR, mkU32( (UInt)argR0 ));
} else {
vassert(mode64);
+ argL =3D newTemp(Ity_I64);
+ argR =3D newTemp(Ity_I64);
assign( argL, argL0 );
assign( argR, mkU64( argR0 ));
}
@@ -4579,7 +4579,7 @@
=20
switch (opc1) {
case 0x03: // twi (Trap Word Immediate, PPC32 p548)
- uncond =3D do_trap( Ity_I32, TO, getIReg(rA_addr), simm16, cia );
+ uncond =3D do_trap( True/*is_twi*/, TO, getIReg(rA_addr), simm16, =
cia );
if (TO =3D=3D 4) {
DIP("tweqi r%u,%d\n", (UInt)rA_addr, (Int)simm16);
} else {
@@ -4589,7 +4589,12 @@
case 0x02: // tdi
if (!mode64)
return False;
- uncond =3D do_trap( Ity_I64, TO, getIReg(rA_addr), simm16, cia );
+ uncond =3D do_trap( False/*!is_twi*/, TO, getIReg(rA_addr), simm16=
, cia );
+ if (TO =3D=3D 4) {
+ DIP("tdeqi r%u,%d\n", (UInt)rA_addr, (Int)simm16);
+ } else {
+ DIP("td%di r%u,%d\n", (Int)TO, (UInt)rA_addr, (Int)simm16);
+ }
break;
default:
return False;
|