From a7aa8f44cefb6def93ffd1a80a8b3abb764c20c1 Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Wed, 27 Dec 2006 18:39:46 +0000 Subject: [PATCH] Implement mfspr 268 and 269. Fixes #139050. git-svn-id: svn://svn.valgrind.org/vex/trunk@1705 --- VEX/priv/guest-ppc/gdefs.h | 2 ++ VEX/priv/guest-ppc/ghelpers.c | 18 ++++++++++++++++++ VEX/priv/guest-ppc/toIR.c | 22 ++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/VEX/priv/guest-ppc/gdefs.h b/VEX/priv/guest-ppc/gdefs.h index 1fc1681a25..68b478d273 100644 --- a/VEX/priv/guest-ppc/gdefs.h +++ b/VEX/priv/guest-ppc/gdefs.h @@ -148,6 +148,8 @@ enum { extern ULong ppcg_dirtyhelper_MFTB ( void ); +extern UInt ppc32g_dirtyhelper_MFSPR_268_269 ( UInt ); + extern void ppc32g_dirtyhelper_LVS ( VexGuestPPC32State* gst, UInt vD_idx, UInt sh, UInt shift_right ); diff --git a/VEX/priv/guest-ppc/ghelpers.c b/VEX/priv/guest-ppc/ghelpers.c index 8eb35b244b..ff1a5994a4 100644 --- a/VEX/priv/guest-ppc/ghelpers.c +++ b/VEX/priv/guest-ppc/ghelpers.c @@ -99,6 +99,24 @@ ULong ppcg_dirtyhelper_MFTB ( void ) } +/* CALLED FROM GENERATED CODE */ +/* DIRTY HELPER (non-referentially transparent) */ +UInt ppc32g_dirtyhelper_MFSPR_268_269 ( UInt r269 ) +{ +# if defined(__powerpc__) || defined(_AIX) + UInt spr; + if (r269) { + __asm__ __volatile__("mfspr %0,269" : "=b"(spr)); + } else { + __asm__ __volatile__("mfspr %0,268" : "=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 eb1eba5de1..f014264618 100644 --- a/VEX/priv/guest-ppc/toIR.c +++ b/VEX/priv/guest-ppc/toIR.c @@ -5347,6 +5347,28 @@ static Bool dis_proc_ctl ( VexAbiInfo* vbi, UInt theInstr ) putIReg( rD_addr, getGST( PPC_GST_SPRG3_RO ) ); break; + /* Even a lowly PPC7400 can run the associated helper, so no + obvious need for feature testing at this point. */ + case 268 /* 0x10C */: + case 269 /* 0x10D */: { + UInt arg = SPR==268 ? 0 : 1; + IRTemp val = newTemp(Ity_I32); + IRExpr** args = mkIRExprVec_1( mkU32(arg) ); + IRDirty* d = unsafeIRDirty_1_N( + val, + 0/*regparms*/, + "ppc32g_dirtyhelper_MFSPR_268_269", + fnptr_to_fnentry + (vbi, &ppc32g_dirtyhelper_MFSPR_268_269), + args + ); + /* execute the dirty call, dumping the result in val. */ + stmt( IRStmt_Dirty(d) ); + putIReg( rD_addr, mkexpr(val) ); + DIP("mfspr r%u,%u", rD_addr, (UInt)SPR); + break; + } + default: vex_printf("dis_proc_ctl(ppc)(mfspr,SPR)(0x%x)\n", SPR); return False; -- 2.47.2