From: Julian Seward Date: Sun, 2 Aug 2009 14:35:45 +0000 (+0000) Subject: Implement mfpvr (mfspr 287) (bug #201585). X-Git-Tag: svn/VALGRIND_3_5_0^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=602bbd250b8f660b50e99bea2cb4d4c0a62a9bc0;p=thirdparty%2Fvalgrind.git Implement mfpvr (mfspr 287) (bug #201585). Also, fix a type mismatch in the generated IR for mfspr 268/269 which would have caused an IR checker assertion failure when handling those insns on ppc64. git-svn-id: svn://svn.valgrind.org/vex/trunk@1913 --- diff --git a/VEX/priv/guest_ppc_defs.h b/VEX/priv/guest_ppc_defs.h index 25fdaed41c..73b7f6acde 100644 --- a/VEX/priv/guest_ppc_defs.h +++ b/VEX/priv/guest_ppc_defs.h @@ -150,6 +150,8 @@ extern ULong ppcg_dirtyhelper_MFTB ( void ); extern UInt ppc32g_dirtyhelper_MFSPR_268_269 ( UInt ); +extern UInt ppc32g_dirtyhelper_MFSPR_287 ( void ); + extern void ppc32g_dirtyhelper_LVS ( VexGuestPPC32State* gst, UInt vD_idx, UInt sh, UInt shift_right ); diff --git a/VEX/priv/guest_ppc_helpers.c b/VEX/priv/guest_ppc_helpers.c index 8c3cc40068..b9d1052fc1 100644 --- a/VEX/priv/guest_ppc_helpers.c +++ b/VEX/priv/guest_ppc_helpers.c @@ -117,6 +117,20 @@ UInt ppc32g_dirtyhelper_MFSPR_268_269 ( UInt r269 ) } +/* CALLED FROM GENERATED CODE */ +/* DIRTY HELPER (I'm not really sure what the side effects are) */ +UInt ppc32g_dirtyhelper_MFSPR_287 ( void ) +{ +# if defined(__powerpc__) || defined(_AIX) + UInt spr; + __asm__ __volatile__("mfspr %0,287" : "=b"(spr)); + return spr; +# else + return 0; +# endif +} + + /* CALLED FROM GENERATED CODE */ /* DIRTY HELPER (reads guest state, writes guest mem) */ void ppc32g_dirtyhelper_LVS ( VexGuestPPC32State* gst, diff --git a/VEX/priv/guest_ppc_toIR.c b/VEX/priv/guest_ppc_toIR.c index 25e06bf476..92cc7d0dde 100644 --- a/VEX/priv/guest_ppc_toIR.c +++ b/VEX/priv/guest_ppc_toIR.c @@ -5471,7 +5471,29 @@ static Bool dis_proc_ctl ( VexAbiInfo* vbi, UInt theInstr ) ); /* execute the dirty call, dumping the result in val. */ stmt( IRStmt_Dirty(d) ); - putIReg( rD_addr, mkexpr(val) ); + putIReg( rD_addr, + mkWidenFrom32(ty, mkexpr(val), False/*unsigned*/) ); + DIP("mfspr r%u,%u", rD_addr, (UInt)SPR); + break; + } + + /* Again, runs natively on PPC7400 (7447, really). Not + bothering with a feature test. */ + case 287: /* 0x11F */ { + IRTemp val = newTemp(Ity_I32); + IRExpr** args = mkIRExprVec_0(); + IRDirty* d = unsafeIRDirty_1_N( + val, + 0/*regparms*/, + "ppc32g_dirtyhelper_MFSPR_287", + fnptr_to_fnentry + (vbi, &ppc32g_dirtyhelper_MFSPR_287), + args + ); + /* execute the dirty call, dumping the result in val. */ + stmt( IRStmt_Dirty(d) ); + putIReg( rD_addr, + mkWidenFrom32(ty, mkexpr(val), False/*unsigned*/) ); DIP("mfspr r%u,%u", rD_addr, (UInt)SPR); break; }