|
From: <sv...@va...> - 2005-09-12 20:49:16
|
Author: cerion
Date: 2005-09-12 21:49:09 +0100 (Mon, 12 Sep 2005)
New Revision: 1386
Log:
front end:
- implemented insns: mfvscr, mtvscr, vand, vor, vxor
- fixed default vscr: enable non-java mode
back end:
- implemented enough to satisfy the front end: V128to32, 32UtoV128, not,=
and, or, xor
- fixed conversions to/from v128 to use quad-word-aligned stack addressi=
ng for their vector load/stores
Modified:
trunk/priv/guest-ppc32/gdefs.h
trunk/priv/guest-ppc32/ghelpers.c
trunk/priv/guest-ppc32/toIR.c
trunk/priv/host-ppc32/hdefs.c
trunk/priv/host-ppc32/hdefs.h
trunk/priv/host-ppc32/isel.c
trunk/pub/libvex_guest_ppc32.h
Modified: trunk/priv/guest-ppc32/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-ppc32/gdefs.h 2005-09-10 12:02:24 UTC (rev 1385)
+++ trunk/priv/guest-ppc32/gdefs.h 2005-09-12 20:49:09 UTC (rev 1386)
@@ -122,7 +122,7 @@
=20
=20
/*---------------------------------------------------------*/
-/*--- ppc32 guest helpers ---*/
+/*--- ppc32 guest helpers ---*/
/*---------------------------------------------------------*/
=20
/* --- CLEAN HELPERS --- */
Modified: trunk/priv/guest-ppc32/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-ppc32/ghelpers.c 2005-09-10 12:02:24 UTC (rev 1385)
+++ trunk/priv/guest-ppc32/ghelpers.c 2005-09-12 20:49:09 UTC (rev 1386)
@@ -318,7 +318,7 @@
=20
vex_state->guest_VRSAVE =3D 0;
=20
- vex_state->guest_VSCR =3D 0;
+ vex_state->guest_VSCR =3D 0x00010000; // Non-Java mode
=20
vex_state->guest_EMWARN =3D EmWarn_NONE;
=20
Modified: trunk/priv/guest-ppc32/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-ppc32/toIR.c 2005-09-10 12:02:24 UTC (rev 1385)
+++ trunk/priv/guest-ppc32/toIR.c 2005-09-12 20:49:09 UTC (rev 1386)
@@ -235,7 +235,7 @@
//zz PPC32_SPR_CR, // Condition Register
PPC32_SPR_FPSCR, // Floating Point Status/Control Register
PPC32_SPR_VRSAVE, // Vector Save/Restore Register
-//zz PPC32_SPR_VSCR, // Vector Status and Control Register
+ PPC32_SPR_VSCR, // Vector Status and Control Register
PPC32_SPR_MAX
} PPC32SPR;
=20
@@ -1188,13 +1188,13 @@
//zz case PPC32_SPR_VRSAVE:
//zz assign( val, IRExpr_Get(OFFB_VRSAVE, Ity_I32) );
//zz break;
-//zz=20
-//zz case PPC32_SPR_VSCR:
-//zz // All other bits are 'Reserved'. Returning zero for these bi=
ts.
-//zz mask =3D mask & 0x00010001;
-//zz assign( val, IRExpr_Get(OFFB_VSCR, Ity_I32) );
-//zz break;
=20
+ case PPC32_SPR_VSCR:
+ // All other bits are zero.
+ mask =3D mask & 0x00010001;
+ assign( val, IRExpr_Get(OFFB_VSCR, Ity_I32) );
+ break;
+
default:
vpanic("getReg(ppc32)");
}
@@ -1300,18 +1300,18 @@
//zz vassert(mask =3D=3D 0xFFFFFFFF); // Only ever need whole r=
eg
//zz stmt( IRStmt_Put( OFFB_VRSAVE, src ) );
//zz break;
-//zz=20
-//zz case PPC32_SPR_VSCR:
-//zz //CAB: There are only 2 valid bits in VSCR - maybe split into two v=
ars...
-//zz=20
-//zz // All other bits are 'Reserved'. Ignoring writes to these bi=
ts.
-//zz stmt( IRStmt_Put( OFFB_VSCR,
-//zz binop(Iop_Or32,
-//zz binop(Iop_And32, src, mkU32(mask & 0x00010001)=
),
-//zz getReg_masked( PPC32_SPR_VSCR, (~mask & 0x0001=
0001) ))));
-//zz break;
-//zz }
=20
+ case PPC32_SPR_VSCR:
+ // CAB: There are only 2 valid bits in VSCR - maybe split into two=
vars...
+ // ... or perhaps only 1 bit... is non-java mode bit ever set to z=
ero?
+
+ // All other bits are 'Reserved'. Ignoring writes to these bits.
+ stmt( IRStmt_Put( OFFB_VSCR,
+ binop(Iop_Or32,
+ binop(Iop_And32, src, mkU32(mask & 0x00010001)),
+ getReg_masked( PPC32_SPR_VSCR, (~mask & 0x00010001) ))));
+ break;
+
default:
vpanic("putReg(ppc32)");
}
@@ -1341,6 +1341,9 @@
case PPC32_SPR_VRSAVE:=20
stmt( IRStmt_Put( OFFB_VRSAVE, src ) );
break;
+ case PPC32_SPR_VSCR:
+ putReg_masked( reg, src, 0xFFFFFFFF );
+ break;
default:
vpanic("putSPR(ppc32)");
}
@@ -1355,6 +1358,8 @@
return IRExpr_Get( OFFB_CTR, Ity_I32 );
case PPC32_SPR_VRSAVE:=20
return IRExpr_Get( OFFB_VRSAVE, Ity_I32 );
+ case PPC32_SPR_VSCR:=20
+ return getReg_masked( reg, 0xFFFFFFFF );
default:
vpanic("getSPR(ppc32)");
}
@@ -2894,7 +2899,7 @@
case 0x010: // bclr (Branch Cond. to Link Register, PPC32 p365)=20
=20
if ((BO & 0x14 /* 1z1zz */) =3D=3D 0x14 && flag_LK =3D=3D 0) {
- DIP("blr");
+ DIP("blr\n");
} else {
DIP("bclr%s 0x%x, 0x%x\n", flag_LK ? "l" : "", BO, BI);
}
@@ -3427,7 +3432,7 @@
DIP("mcrxr crf%d\n", crfD);
=20
/* Compute XER[0-3] (the top 4 bits of XER) into the bottom
- 4 bits of xer_0to3. */
+ 4 bits of xer_0to3. */
assign(=20
xer_0to3,
unop(Iop_32to8,
@@ -4815,18 +4820,20 @@
return False;
}
DIP("mfvscr v%d\n", vD_addr);
- DIP(" =3D> not implemented\n");
- return False;
+ putVReg( vD_addr, unop(Iop_32UtoV128, getSPR( PPC32_SPR_VSCR )) );=
=20
+ break;
=20
- case 0x644: // mtvscr (Move to VSCR, AV p130)
+ case 0x644: { // mtvscr (Move to VSCR, AV p130)
if (vD_addr !=3D 0 || vA_addr !=3D 0) {
vex_printf("dis_av_procctl(PPC32)(opc2,dst)\n");
return False;
}
DIP("mtvscr v%d\n", vB_addr);
- DIP(" =3D> not implemented\n");
- return False;
-
+ IRTemp vB =3D newTemp(Ity_V128);
+ assign( vB, getVReg(vB_addr));
+ putSPR( PPC32_SPR_VSCR, unop(Iop_V128to32, mkexpr(vB)) );=20
+ break;
+ }
default:
vex_printf("dis_av_procctl(PPC32)(opc2)\n");
return False;
@@ -4914,14 +4921,14 @@
UInt opc2 =3D (theInstr >> 1) & 0x3FF; /* theInstr[1:10=
] */
UChar b0 =3D toUChar((theInstr >> 0) & 1); /* theInstr[0] =
*/
=20
- IRTemp rA =3D newTemp(Ity_I32);
- IRTemp rB =3D newTemp(Ity_I32);
+ // IRTemp rA =3D newTemp(Ity_I32);
+ // IRTemp rB =3D newTemp(Ity_I32);
IRTemp vS =3D newTemp(Ity_V128);
IRTemp EA =3D newTemp(Ity_I32);
IRTemp EA_aligned =3D newTemp(Ity_I32);
=20
- assign( rA, getIReg(rA_addr));
- assign( rB, getIReg(rB_addr));
+ // assign( rA, getIReg(rA_addr));
+ // assign( rB, getIReg(rB_addr));
assign( vS, getVReg(vS_addr));
=20
assign( EA, ea_standard(rA_addr, rB_addr) );
@@ -5283,6 +5290,11 @@
UChar vB_addr =3D toUChar((theInstr >> 11) & 0x1F); /* theInstr[11:1=
5] */
UInt opc2 =3D (theInstr >> 0) & 0x7FF; /* theInstr[0:10=
] */
=20
+ IRTemp vA =3D newTemp(Ity_V128);
+ IRTemp vB =3D newTemp(Ity_V128);
+ assign( vA, getVReg(vA_addr));
+ assign( vB, getVReg(vB_addr));
+
if (opc1 !=3D 0x4) {
vex_printf("dis_av_logic(PPC32)(opc1 !=3D 0x4)\n");
return False;
@@ -5291,8 +5303,8 @@
switch (opc2) {
case 0x404: // vand (And, AV p147)
DIP("vand v%d,v%d,v%d\n", vD_addr, vA_addr, vB_addr);
- DIP(" =3D> not implemented\n");
- return False;
+ putVReg( vD_addr, binop(Iop_AndV128, mkexpr(vA), mkexpr(vB)) );
+ break;
=20
case 0x444: // vandc (And, AV p148)
DIP("vandc v%d,v%d,v%d\n", vD_addr, vA_addr, vB_addr);
@@ -5301,13 +5313,13 @@
=20
case 0x484: // vor (Or, AV p217)
DIP("vor v%d,v%d,v%d\n", vD_addr, vA_addr, vB_addr);
- DIP(" =3D> not implemented\n");
- return False;
+ putVReg( vD_addr, binop(Iop_OrV128, mkexpr(vA), mkexpr(vB)) );
+ break;
=20
case 0x4C4: // vxor (Xor, AV p282)
DIP("vxor v%d,v%d,v%d\n", vD_addr, vA_addr, vB_addr);
- DIP(" =3D> not implemented\n");
- return False;
+ putVReg( vD_addr, binop(Iop_XorV128, mkexpr(vA), mkexpr(vB)) );
+ break;
=20
case 0x504: // vnor (Nor, AV p216)
DIP("vnor v%d,v%d,v%d\n", vD_addr, vA_addr, vB_addr);
@@ -6095,7 +6107,7 @@
opc1 =3D toUChar(ifieldOPC(theInstr));
opc2 =3D ifieldOPClo10(theInstr);
=20
-#if PPC32_TOIR_DEBUG
+#if 0 //PPC32_TOIR_DEBUG
vex_printf("\ndisInstr(ppc32): instr: 0x%x\n", theInstr);
vex_printf("disInstr(ppc32): instr: ");
vex_printf_binary( theInstr, 32, True );
@@ -6565,6 +6577,7 @@
default:
decode_failure:
/* All decode failures end up here. */
+ opc2 =3D (theInstr) & 0x7FF;
vex_printf("disInstr(ppc32): unhandled instruction: "
"0x%x\n", theInstr);
vex_printf(" primary %d(0x%x), secondary %u(0x%x)\n",=
=20
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-09-10 12:02:24 UTC (rev 1385)
+++ trunk/priv/host-ppc32/hdefs.c 2005-09-12 20:49:09 UTC (rev 1386)
@@ -1261,10 +1261,11 @@
ppLoadImm(hregPPC32_GPR30(), i->Pin.AvLdSt.addr->Pam.RR.index);
vex_printf(" ; ");
}
+ char* str_size =3D sz=3D=3D1 ? "eb" : sz=3D=3D2 ? "eh" : sz=3D=3D4=
? "ew" : "";
if (i->Pin.AvLdSt.isLoad)
- vex_printf("lv%sx ", sz=3D=3D8 ? "eb" : sz=3D=3D16 ? "eh" : sz=3D=
=3D32 ? "ew" : "");
+ vex_printf("lv%sx ", str_size);
else
- vex_printf("stv%sx ", sz=3D=3D8 ? "eb" : sz=3D=3D16 ? "eh" : sz=
=3D=3D32 ? "ew" : "");
+ vex_printf("stv%sx ", str_size);
ppHRegPPC32(i->Pin.AvLdSt.reg);
vex_printf(",");
if (i->Pin.AvLdSt.addr->tag =3D=3D Pam_IR)
@@ -2755,7 +2756,7 @@
UInt opc2, v_reg, r_idx, r_base;
UChar sz =3D i->Pin.AvLdSt.sz;
Bool idxd =3D toBool(i->Pin.AvLdSt.addr->tag =3D=3D Pam_RR);
- vassert(sz =3D=3D 8 || sz =3D=3D 16 || sz =3D=3D 32 || sz =3D=3D 1=
28);
+ vassert(sz =3D=3D 1 || sz =3D=3D 2 || sz =3D=3D 4 || sz =3D=3D 16)=
;
=20
v_reg =3D vregNo(i->Pin.AvLdSt.reg);
r_base =3D iregNo(i->Pin.AvLdSt.addr->Pam.RR.base);
@@ -2768,11 +2769,11 @@
r_idx =3D iregNo(i->Pin.AvLdSt.addr->Pam.RR.index);
}
=20
- if (i->Pin.FpLdSt.isLoad) { // Load from memory (8,16,32,128)
- opc2 =3D (sz =3D=3D 8) ? 7 : (sz =3D=3D 16) ? 39 : (sz =3D=3D 3=
2) ? 71 : 103;
+ if (i->Pin.FpLdSt.isLoad) { // Load from memory (1,2,4,16)
+ opc2 =3D (sz =3D=3D 1) ? 7 : (sz =3D=3D 2) ? 39 : (sz =3D=3D 4)=
? 71 : 103;
p =3D mkFormX(p, 31, v_reg, r_idx, r_base, opc2, 0);
- } else { // Store to memory (8,16,32,128)
- opc2 =3D (sz =3D=3D 8) ? 135 : (sz =3D=3D 16) ? 167 : (sz =3D=3D=
32) ? 199 : 231;
+ } else { // Store to memory (1,2,4,16)
+ opc2 =3D (sz =3D=3D 1) ? 135 : (sz =3D=3D 2) ? 167 : (sz =3D=3D=
4) ? 199 : 231;
p =3D mkFormX(p, 31, v_reg, r_idx, r_base, opc2, 0);
}
goto done;
@@ -2813,9 +2814,9 @@
UInt opc2;
switch (i->Pin.AvBinary.op) {
/* Bitwise */
- case Pav_AND: opc2 =3D 1026; break; // vand
+ case Pav_AND: opc2 =3D 1028; break; // vand
case Pav_OR: opc2 =3D 1156; break; // vor
- case Pav_XOR: opc2 =3D 1120; break; // vxor
+ case Pav_XOR: opc2 =3D 1220; break; // vxor
=20
/* Shift */
case Pav_SHL: opc2 =3D 452; break; // vsl
Modified: trunk/priv/host-ppc32/hdefs.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/host-ppc32/hdefs.h 2005-09-10 12:02:24 UTC (rev 1385)
+++ trunk/priv/host-ppc32/hdefs.h 2005-09-12 20:49:09 UTC (rev 1386)
@@ -54,7 +54,7 @@
/* --------- Registers. --------- */
=20
/* The usual HReg abstraction. There are 32 real int regs,
- 32 real float regs, and 0 real vector regs.=20
+ 32 real float regs, and 32 real vector regs.=20
*/
=20
extern void ppHRegPPC32 ( HReg );
Modified: trunk/priv/host-ppc32/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-ppc32/isel.c 2005-09-10 12:02:24 UTC (rev 1385)
+++ trunk/priv/host-ppc32/isel.c 2005-09-12 20:49:09 UTC (rev 1386)
@@ -344,7 +344,28 @@
Palu_SUB, sp, sp, PPC32RH_Imm(True,toUShort(n))));
}
=20
+/*
+ returns a quadword aligned address on the stack
+ - copies SP, adds 16bytes, aligns to quadword.
+ use sub_from_sp(32) before calling this,
+ as expects to have 32 bytes to play with.
+*/
+static HReg get_sp_aligned16 ( ISelEnv* env )
+{
+ HReg r =3D newVRegI(env);
+ HReg align16 =3D newVRegI(env);
+ addInstr(env, mk_iMOVds_RR(r, StackFramePtr));
+ // add 16
+ addInstr(env, PPC32Instr_Alu32(
+ Palu_ADD, r, r, PPC32RH_Imm(True,toUShort(16))));
+ // mask to quadword
+ addInstr(env, PPC32Instr_LI32(align16, (UInt)0xFFFFFFF0));
+ addInstr(env, PPC32Instr_Alu32(Palu_AND, r,r, PPC32RH_Reg(align16)));
+ return r;
+}
=20
+
+
/* Load 2*I32 regs to fp reg */
static HReg mk_LoadRRtoFPR ( ISelEnv* env, HReg r_srcHi, HReg r_srcLo )
{
@@ -1188,17 +1209,25 @@
return r_dst;
}
=20
-//.. case Iop_V128to32: {
-//.. HReg dst =3D newVRegI(env);
-//.. HReg vec =3D iselVecExpr(env, e->Iex.Unop.arg);
-//.. X86AMode* esp0 =3D X86AMode_IR(0, hregX86_ESP());
-//.. sub_from_esp(env, 16);
-//.. addInstr(env, X86Instr_SseLdSt(False/*store*/, vec, esp=
0));
-//.. addInstr(env, X86Instr_Alu32R( Xalu_MOV, X86RMI_Mem(esp=
0), dst ));
-//.. add_to_esp(env, 16);
-//.. return dst;
-//.. }
+ case Iop_V128to32: {
+ HReg dst =3D newVRegI(env);
+ HReg vec =3D iselVecExpr(env, e->Iex.Unop.arg);
+ PPC32AMode *am_off0, *am_off12;
+ sub_from_sp( env, 32 ); // Move SP down 32 bytes
=20
+ // get a quadword aligned address within our stack space
+ HReg r_aligned16 =3D get_sp_aligned16( env );
+ am_off0 =3D PPC32AMode_IR( 0, r_aligned16 );
+ am_off12 =3D PPC32AMode_IR( 12,r_aligned16 );
+
+ // store vec, load low word to dst
+ addInstr(env, PPC32Instr_AvLdSt( False/*store*/, 16, vec, am_of=
f0 ));
+ addInstr(env, PPC32Instr_Load( 4, False, dst, am_off12 ));
+
+ add_to_sp( env, 32 ); // Reset SP
+ return dst;
+ }
+
case Iop_16to8:
case Iop_32to8:
case Iop_32to16:
@@ -2316,19 +2345,21 @@
HReg tLo =3D newVRegI(env);
HReg tHi =3D newVRegI(env);
HReg vec =3D iselVecExpr(env, e->Iex.Unop.arg);
- PPC32AMode *sp0, *spLO, *spHI;
-
+ PPC32AMode *am_off0, *am_offLO, *am_offHI;
sub_from_sp( env, 32 ); // Move SP down 32 bytes
- sp0 =3D PPC32AMode_IR(0, StackFramePtr);
- spHI =3D PPC32AMode_IR(off, StackFramePtr);
- spLO =3D PPC32AMode_IR(off+4, StackFramePtr);
=20
+ // get a quadword aligned address within our stack space
+ HReg r_aligned16 =3D get_sp_aligned16( env );
+ am_off0 =3D PPC32AMode_IR( 0, r_aligned16 );
+ am_offHI =3D PPC32AMode_IR( off, r_aligned16 );
+ am_offLO =3D PPC32AMode_IR( off+4, r_aligned16 );
+
// store as Vec128
- addInstr(env, PPC32Instr_AvLdSt( False/*store*/, 16, vec, sp=
0 ));
+ addInstr(env, PPC32Instr_AvLdSt( False/*store*/, 16, vec, am=
_off0 ));
=20
// load hi,lo words (of hi/lo half of vec) as Ity_I32's
- addInstr(env, PPC32Instr_Load( 4, False, tHi, spHI ));
- addInstr(env, PPC32Instr_Load( 4, False, tLo, spLO ));
+ addInstr(env, PPC32Instr_Load( 4, False, tHi, am_offHI ));
+ addInstr(env, PPC32Instr_Load( 4, False, tLo, am_offLO ));
=20
add_to_sp( env, 32 ); // Reset SP
*rHi =3D tHi;
@@ -2781,7 +2812,7 @@
static HReg iselVecExpr_wrk ( ISelEnv* env, IRExpr* e )
{
//.. Bool arg1isEReg =3D False;
- // unused: PPC32AvOp op =3D Pav_INVALID;
+ PPC32AvOp op =3D Pav_INVALID;
IRType ty =3D typeOfIRExpr(env->type_env,e);
vassert(e);
vassert(ty =3D=3D Ity_V128);
@@ -2817,11 +2848,13 @@
if (e->tag =3D=3D Iex_Unop) {
switch (e->Iex.Unop.op) {
=20
-//.. case Iop_Not128: {
-//.. HReg arg =3D iselVecExpr(env, e->Iex.Unop.arg);
-//.. return do_sse_Not128(env, arg);
-//.. }
-//..=20
+ case Iop_NotV128: {
+ HReg arg =3D iselVecExpr(env, e->Iex.Unop.arg);
+ HReg dst =3D newVRegV(env);
+ addInstr(env, PPC32Instr_AvUnary(Pav_NOT, dst, arg));
+ return dst;
+ }
+
//.. case Iop_CmpNEZ64x2: {
//.. /* We can use SSE2 instructions for this. */
//.. /* Ideally, we want to do a 64Ix2 comparison against zero =
of
@@ -2963,17 +2996,37 @@
//.. addInstr(env, X86Instr_Sse64FLo(op, arg, dst));
//.. return dst;
//.. }
-//..=20
-//.. case Iop_32UtoV128: {
-//.. HReg dst =3D newVRegV(env);
-//.. X86AMode* esp0 =3D X86AMode_IR(0, hregX86_ESP());
-//.. X86RMI* rmi =3D iselIntExpr_RMI(env, e->Iex.Unop.arg);
-//.. addInstr(env, X86Instr_Push(rmi));
-//.. addInstr(env, X86Instr_SseLdzLO(4, dst, esp0));
-//.. add_to_esp(env, 4);
-//.. return dst;
-//.. }
-//..=20
+
+ case Iop_32UtoV128: {
+ HReg r_src =3D iselIntExpr_R(env, e->Iex.Unop.arg);
+ HReg dst =3D newVRegV(env);
+ PPC32AMode *am_off0, *am_off4, *am_off8, *am_off12;
+ sub_from_sp( env, 32 ); // Move SP down
+
+ /* Get a quadword aligned address within our stack space */
+ HReg r_aligned16 =3D get_sp_aligned16( env );
+ am_off0 =3D PPC32AMode_IR( 0, r_aligned16);
+ am_off4 =3D PPC32AMode_IR( 4, r_aligned16);
+ am_off8 =3D PPC32AMode_IR( 8, r_aligned16);
+ am_off12 =3D PPC32AMode_IR( 12, r_aligned16);
+
+ /* Store zero's */
+ HReg r_zeros =3D newVRegI(env);
+ addInstr(env, PPC32Instr_LI32(r_zeros, 0x0));
+ addInstr(env, PPC32Instr_Store( 4, am_off0, r_zeros ));
+ addInstr(env, PPC32Instr_Store( 4, am_off4, r_zeros ));
+ addInstr(env, PPC32Instr_Store( 4, am_off8, r_zeros ));
+
+ /* Store r_src in low word of quadword-aligned mem */
+ addInstr(env, PPC32Instr_Store( 4, am_off12, r_src ));
+
+ /* Load word into low word of quadword vector reg */
+ addInstr(env, PPC32Instr_AvLdSt( True/*load*/, 4, dst, am_off12=
));
+
+ add_to_sp( env, 32 ); // Reset SP
+ return dst;
+ }
+
//.. case Iop_64UtoV128: {
//.. HReg rHi, rLo;
//.. HReg dst =3D newVRegV(env);
@@ -3025,24 +3078,31 @@
//..=20
case Iop_64HLtoV128: {
HReg r3, r2, r1, r0;
- PPC32AMode *sp0 =3D PPC32AMode_IR(0, StackFramePtr);
- PPC32AMode *sp4 =3D PPC32AMode_IR(4, StackFramePtr);
- PPC32AMode *sp8 =3D PPC32AMode_IR(8, StackFramePtr);
- PPC32AMode *sp12 =3D PPC32AMode_IR(12, StackFramePtr);
+ PPC32AMode *am_off0, *am_off4, *am_off8, *am_off12;
HReg dst =3D newVRegV(env);
/* do this via the stack (easy, convenient, etc) */
- sub_from_sp( env, 16 ); // Move SP down 16 bytes
+ sub_from_sp( env, 32 ); // Move SP down
+
+ // get a quadword aligned address within our stack space
+ HReg r_aligned16 =3D get_sp_aligned16( env );
+ am_off0 =3D PPC32AMode_IR( 0, r_aligned16);
+ am_off4 =3D PPC32AMode_IR( 4, r_aligned16);
+ am_off8 =3D PPC32AMode_IR( 8, r_aligned16);
+ am_off12 =3D PPC32AMode_IR( 12, r_aligned16);
+
/* Do the less significant 64 bits */
iselInt64Expr(&r1, &r0, env, e->Iex.Binop.arg2);
- addInstr(env, PPC32Instr_Store( 4, sp12, r0 ));
- addInstr(env, PPC32Instr_Store( 4, sp8, r1 ));
+ addInstr(env, PPC32Instr_Store( 4, am_off12, r0 ));
+ addInstr(env, PPC32Instr_Store( 4, am_off8, r1 ));
/* Do the more significant 64 bits */
iselInt64Expr(&r3, &r2, env, e->Iex.Binop.arg1);
- addInstr(env, PPC32Instr_Store( 4, sp4, r2 ));
- addInstr(env, PPC32Instr_Store( 4, sp0, r3 ));
+ addInstr(env, PPC32Instr_Store( 4, am_off4, r2 ));
+ addInstr(env, PPC32Instr_Store( 4, am_off0, r3 ));
+
/* Fetch result back from stack. */
- addInstr(env, PPC32Instr_AvLdSt(True/*load*/, 16, dst, sp0));
- add_to_sp( env, 16 ); // Reset SP
+ addInstr(env, PPC32Instr_AvLdSt(True/*load*/, 16, dst, am_off0)=
);
+
+ add_to_sp( env, 32 ); // Reset SP
return dst;
}
=20
@@ -3146,10 +3206,10 @@
//.. op =3D Xsse_UNPCKLD; arg1isEReg =3D True; goto do_SseReRg;
//.. case Iop_InterleaveLO64x2:=20
//.. op =3D Xsse_UNPCKLQ; arg1isEReg =3D True; goto do_SseReRg;
-//..=20
-//.. case Iop_AndV128: op =3D Xsse_AND; goto do_SseReRg;
-//.. case Iop_OrV128: op =3D Xsse_OR; goto do_SseReRg;
-//.. case Iop_XorV128: op =3D Xsse_XOR; goto do_SseReRg;
+
+ case Iop_AndV128: op =3D Pav_AND; goto do_AvBin;
+ case Iop_OrV128: op =3D Pav_OR; goto do_AvBin;
+ case Iop_XorV128: op =3D Pav_XOR; goto do_AvBin;
//.. case Iop_Add8x16: op =3D Xsse_ADD8; goto do_SseReRg;
//.. case Iop_Add16x8: op =3D Xsse_ADD16; goto do_SseReRg;
//.. case Iop_Add32x4: op =3D Xsse_ADD32; goto do_SseReRg;
@@ -3181,6 +3241,13 @@
//.. case Iop_QSub16Sx8: op =3D Xsse_QSUB16S; goto do_SseReRg;
//.. case Iop_QSub8Ux16: op =3D Xsse_QSUB8U; goto do_SseReRg;
//.. case Iop_QSub16Ux8: op =3D Xsse_QSUB16U; goto do_SseReRg;
+ do_AvBin: {
+ HReg arg1 =3D iselVecExpr(env, e->Iex.Binop.arg1);
+ HReg arg2 =3D iselVecExpr(env, e->Iex.Binop.arg2);
+ HReg dst =3D newVRegV(env);
+ addInstr(env, PPC32Instr_AvBinary(op, dst, arg1, arg2));
+ return dst;
+ }
//.. do_SseReRg: {
//.. HReg arg1 =3D iselVecExpr(env, e->Iex.Binop.arg1);
//.. HReg arg2 =3D iselVecExpr(env, e->Iex.Binop.arg2);
Modified: trunk/pub/libvex_guest_ppc32.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/pub/libvex_guest_ppc32.h 2005-09-10 12:02:24 UTC (rev 1385)
+++ trunk/pub/libvex_guest_ppc32.h 2005-09-12 20:49:09 UTC (rev 1386)
@@ -208,7 +208,7 @@
/* 952 */ UInt guest_RESVN;
=20
/* Padding to make it have an 8-aligned size */
- /* UInt padding; */
+ UInt padding;
}
VexGuestPPC32State;
=20
|