diff --git a/pcsx2/Cache.c b/pcsx2/Cache.c index 47b201f431..ae7d5bab6c 100644 --- a/pcsx2/Cache.c +++ b/pcsx2/Cache.c @@ -53,7 +53,7 @@ int getFreeCache(u32 mem, int mode, int * way) { if(pCache[i].tag[number] & 0x60) // Valid Dirty { - t = (char *)(taddr[number]); // fixme - this should probably be cast to (u8*) + t = (u8*)(taddr[number]); out = (u8*)(t + (mem & 0xFC0)); ((u64*)out)[0] = ((u64*)pCache[i].data[number][0].b8._8)[0]; ((u64*)out)[1] = ((u64*)pCache[i].data[number][0].b8._8)[1]; diff --git a/pcsx2/Common.h b/pcsx2/Common.h index ef68004ee4..5928d6fde7 100644 --- a/pcsx2/Common.h +++ b/pcsx2/Common.h @@ -23,6 +23,10 @@ #define __LINUX__ #endif +#ifdef _WIN32 +#include +#endif + #include // fixme: is zlib.h stuff used by that many modules that it should be here in common? #include @@ -32,11 +36,7 @@ #define DONT_USE_GETTEXT #endif -#if defined(_WIN32) - -#include // fixme: windows.h should be included to windows gui modules only. - -#define pthread_mutex__unlock pthread_mutex_unlock +#if defined(_MSC_VER) #define strnicmp _strnicmp #define stricmp _stricmp diff --git a/pcsx2/DebugTools/Debug.h b/pcsx2/DebugTools/Debug.h index 473a34343f..f193c5852e 100644 --- a/pcsx2/DebugTools/Debug.h +++ b/pcsx2/DebugTools/Debug.h @@ -23,7 +23,6 @@ #include #include -#include "PS2Edefs.h" #include "Misc.h" extern FILE *emuLog; diff --git a/pcsx2/DebugTools/DisR5900asm.c b/pcsx2/DebugTools/DisR5900asm.c index e4528ead30..d6dd35d48e 100644 --- a/pcsx2/DebugTools/DisR5900asm.c +++ b/pcsx2/DebugTools/DisR5900asm.c @@ -19,7 +19,6 @@ #include #include -#include "PS2Etypes.h" #include "Debug.h" #include "R5900.h" #include "DisASM.h" diff --git a/pcsx2/Elfheader.c b/pcsx2/Elfheader.c index 50a0dc2065..b4b8ed8ce7 100644 --- a/pcsx2/Elfheader.c +++ b/pcsx2/Elfheader.c @@ -29,6 +29,7 @@ #endif #ifdef _WIN32 +#include AppData gApp; #endif diff --git a/pcsx2/GS.cpp b/pcsx2/GS.cpp index b5e9cce53e..6ad1cba698 100644 --- a/pcsx2/GS.cpp +++ b/pcsx2/GS.cpp @@ -18,18 +18,22 @@ // rewritten by zerofrog to add multithreading/gs caching to GS and VU1 -#include "PS2Etypes.h" - -#if defined(_WIN32) -#include -#endif - #include #include #include #include #include +#if defined(_WIN32) +#include +#endif + +#include "Common.h" +#include "zlib.h" +#include "VU.h" +#include "GS.h" +#include "iR5900.h" + using namespace std; #ifdef DEBUG @@ -201,16 +205,6 @@ static void mutex_unlock( mutex_t& mutex ) #endif - -#include "Common.h" -#include "zlib.h" -#include "VU.h" - -//#include "ix86/ix86.h" -#include "iR5900.h" - -#include "GS.h" - static wait_event_t g_hGsEvent; // set when path3 is ready to be processed static wait_event_t g_hGSDone; // used to regulate thread startup and gsInit static thread_t g_hVuGsThread; diff --git a/pcsx2/GS.h b/pcsx2/GS.h index 1b361721b3..964bbe95de 100644 --- a/pcsx2/GS.h +++ b/pcsx2/GS.h @@ -24,6 +24,8 @@ #include #include +#include "zlib.h" + struct GSRegSIGBLID { u32 SIGID; diff --git a/pcsx2/Hw.c b/pcsx2/Hw.c index 062d7992bd..ba05312e09 100644 --- a/pcsx2/Hw.c +++ b/pcsx2/Hw.c @@ -1216,13 +1216,13 @@ int hwMFIFOWrite(u32 addr, u8 *data, u32 size) { int s2 = size - s1; /* it does, so first copy 's1' bytes from 'data' to 'addr' */ - dst = PSM(addr); + dst = (u8*)PSM(addr); if (dst == NULL) return -1; Cpu->Clear(addr, s1/4); memcpy_fast(dst, data, s1); /* and second copy 's2' bytes from '&data[s1]' to 'maddr' */ - dst = PSM(psHu32(DMAC_RBOR)); + dst = (u8*)PSM(psHu32(DMAC_RBOR)); if (dst == NULL) return -1; Cpu->Clear(psHu32(DMAC_RBOR), s2/4); memcpy_fast(dst, &data[s1], s2); @@ -1230,7 +1230,7 @@ int hwMFIFOWrite(u32 addr, u8 *data, u32 size) { //u32 * tempptr, * tempptr2; /* it doesn't, so just copy 'size' bytes from 'data' to 'addr' */ - dst = PSM(addr); + dst = (u8*)PSM(addr); if (dst == NULL) return -1; Cpu->Clear(addr, size/4); memcpy_fast(dst, data, size); diff --git a/pcsx2/Misc.c b/pcsx2/Misc.c index 6656eaed08..94e0e132c2 100644 --- a/pcsx2/Misc.c +++ b/pcsx2/Misc.c @@ -23,12 +23,12 @@ #include #include -#include "Plugins.h" #include "Common.h" #include "PsxCommon.h" #include "CDVDisodrv.h" #include "VUmicro.h" #ifdef _WIN32 +#include #include "RDebug/deci2.h" #endif diff --git a/pcsx2/Misc.h b/pcsx2/Misc.h index 1047e8d106..11dffaafed 100644 --- a/pcsx2/Misc.h +++ b/pcsx2/Misc.h @@ -23,12 +23,14 @@ #include #include -#include "PS2Etypes.h" - #ifndef _WIN32 #include +#else +#include #endif +#include "PS2Etypes.h" + // compile-time assert #ifndef C_ASSERT #define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] diff --git a/pcsx2/PS2Edefs.h b/pcsx2/PS2Edefs.h index e675df00b8..61c0394928 100644 --- a/pcsx2/PS2Edefs.h +++ b/pcsx2/PS2Edefs.h @@ -53,7 +53,7 @@ #ifdef __LINUX__ #define CALLBACK #else -#include +#define CALLBACK __stdcall #endif @@ -197,7 +197,7 @@ typedef struct _GSdriverInfo { void *common; } GSdriverInfo; -#ifdef _WIN32 +#ifdef _WINDOWS_ typedef struct _winInfo { // unsupported values must be set to zero HWND hWnd; HMENU hMenu; @@ -538,7 +538,7 @@ typedef int (CALLBACK* _GSsetupRecording)(int, void*); typedef void (CALLBACK* _GSreset)(); typedef void (CALLBACK* _GSwriteCSR)(u32 value); typedef void (CALLBACK* _GSgetDriverInfo)(GSdriverInfo *info); -#ifdef _WIN32 +#ifdef _WINDOWS_ typedef s32 (CALLBACK* _GSsetWindowInfo)(winInfo *info); #endif typedef void (CALLBACK* _GSmakeSnapshot)(const char *path); @@ -724,7 +724,7 @@ extern _GSsetupRecording GSsetupRecording; extern _GSreset GSreset; extern _GSwriteCSR GSwriteCSR; extern _GSgetDriverInfo GSgetDriverInfo; -#ifdef _WIN32 +#ifdef _WINDOWS_ extern _GSsetWindowInfo GSsetWindowInfo; #endif extern _GSfreeze GSfreeze; diff --git a/pcsx2/PS2Etypes.h b/pcsx2/PS2Etypes.h index ecde55b784..40f0228db1 100644 --- a/pcsx2/PS2Etypes.h +++ b/pcsx2/PS2Etypes.h @@ -26,10 +26,6 @@ #define __LINUX__ #endif -#ifdef _WIN32 -#include -#endif - #ifndef ARRAYSIZE #define ARRAYSIZE(x) (sizeof(x)/sizeof((x)[0])) #endif diff --git a/pcsx2/Patch.h b/pcsx2/Patch.h index 705e8e221c..af018e03da 100644 --- a/pcsx2/Patch.h +++ b/pcsx2/Patch.h @@ -18,6 +18,12 @@ #ifndef __PATCH_H__ #define __PATCH_H__ +#ifdef _WIN32 +#include +#endif + +#include "PS2Etypes.h" + // // Defines // @@ -72,8 +78,7 @@ struct IniPatch u64 data; }; -#ifdef _WIN32 -#include +#ifdef _WINDOWS_ struct AppData { HWND hWnd; // Main window handle diff --git a/pcsx2/PsxCommon.h b/pcsx2/PsxCommon.h index ef345cf838..7e2fda788c 100644 --- a/pcsx2/PsxCommon.h +++ b/pcsx2/PsxCommon.h @@ -18,12 +18,12 @@ #ifndef __PSXCOMMON_H__ #define __PSXCOMMON_H__ -#include "PS2Etypes.h" - #ifdef _WIN32 #include #endif +#include "PS2Etypes.h" + #include #include "System.h" diff --git a/pcsx2/x86/fast_routines.cpp b/pcsx2/x86/fast_routines.cpp index 1947fa39ba..f0ba3efb7a 100644 --- a/pcsx2/x86/fast_routines.cpp +++ b/pcsx2/x86/fast_routines.cpp @@ -73,12 +73,6 @@ MEMCPY_AMD.CPP // Inline assembly syntax for use with Visual C++ -#include "PS2Etypes.h" - -#ifdef _WIN32 -#include -#endif - #include "Misc.h" #if defined(_MSC_VER) && !defined(__x86_64__) diff --git a/pcsx2/x86/iCore.cpp b/pcsx2/x86/iCore.cpp index 51be430f94..1ddac05fa7 100644 --- a/pcsx2/x86/iCore.cpp +++ b/pcsx2/x86/iCore.cpp @@ -23,12 +23,12 @@ #include #include -#include "PS2Etypes.h" - #if defined(_WIN32) #include #endif +#include "PS2Etypes.h" + #include "System.h" #include "R5900.h" #include "Vif.h" @@ -1278,24 +1278,24 @@ u32 _recIsRegUsed(EEINST* pinst, int size, u8 xmmtype, u8 reg) return 0; } -void _recFillRegister(EEINST* pinst, int type, int reg, int write) +void _recFillRegister(EEINST& pinst, int type, int reg, int write) { u32 i = 0; if (write ) { - for(i = 0; i < ARRAYSIZE(pinst->writeType); ++i) { - if( pinst->writeType[i] == XMMTYPE_TEMP ) { - pinst->writeType[i] = type; - pinst->writeReg[i] = reg; + for(i = 0; i < ARRAYSIZE(pinst.writeType); ++i) { + if( pinst.writeType[i] == XMMTYPE_TEMP ) { + pinst.writeType[i] = type; + pinst.writeReg[i] = reg; return; } } assert(0); } else { - for(i = 0; i < ARRAYSIZE(pinst->readType); ++i) { - if( pinst->readType[i] == XMMTYPE_TEMP ) { - pinst->readType[i] = type; - pinst->readReg[i] = reg; + for(i = 0; i < ARRAYSIZE(pinst.readType); ++i) { + if( pinst.readType[i] == XMMTYPE_TEMP ) { + pinst.readType[i] = type; + pinst.readReg[i] = reg; return; } } diff --git a/pcsx2/x86/iCore.h b/pcsx2/x86/iCore.h index 68cc196f6e..8afef31533 100644 --- a/pcsx2/x86/iCore.h +++ b/pcsx2/x86/iCore.h @@ -332,7 +332,7 @@ void _recClearInst(EEINST* pinst); u32 _recIsRegWritten(EEINST* pinst, int size, u8 xmmtype, u8 reg); // returns the number of insts + 1 until used (0 if not used) u32 _recIsRegUsed(EEINST* pinst, int size, u8 xmmtype, u8 reg); -void _recFillRegister(EEINST* pinst, int type, int reg, int write); +void _recFillRegister(EEINST& pinst, int type, int reg, int write); #define EEINST_ISLIVE64(reg) (g_pCurInstInfo->regs[reg] & (EEINST_LIVE0|EEINST_LIVE1)) #define EEINST_ISLIVEXMM(reg) (g_pCurInstInfo->regs[reg] & (EEINST_LIVE0|EEINST_LIVE1|EEINST_LIVE2)) diff --git a/pcsx2/x86/iGS.cpp b/pcsx2/x86/iGS.cpp index 8cd6e2bdfc..3b340e6504 100644 --- a/pcsx2/x86/iGS.cpp +++ b/pcsx2/x86/iGS.cpp @@ -19,34 +19,22 @@ // stop compiling if NORECBUILD build (only for Visual Studio) #if !(defined(_MSC_VER) && defined(PCSX2_NORECBUILD)) -#include "PS2Etypes.h" - #if defined(_WIN32) #include #endif #include - #include #include using namespace std; -#include "zlib.h" -#include "Elfheader.h" -#include "Misc.h" -#include "System.h" -#include "R5900.h" -#include "Vif.h" +#include "Common.h" #include "VU.h" -#include "VifDma.h" -#include "Memory.h" -#include "Hw.h" #include "ix86/ix86.h" #include "iR5900.h" -#include "Counters.h" #include "GS.h" #include "DebugTools/Debug.h" diff --git a/pcsx2/x86/iR3000A.cpp b/pcsx2/x86/iR3000A.cpp index 5e997bd466..d5a8e969cb 100644 --- a/pcsx2/x86/iR3000A.cpp +++ b/pcsx2/x86/iR3000A.cpp @@ -22,7 +22,7 @@ // stop compiling if NORECBUILD build (only for Visual Studio) #if !(defined(_MSC_VER) && defined(PCSX2_NORECBUILD)) -#ifdef _WIN32 +#ifdef _MSC_VER #pragma warning(disable:4244) #pragma warning(disable:4761) #endif @@ -33,8 +33,6 @@ #include #include -#include "PS2Etypes.h" - #if defined(_WIN32) #include #else @@ -42,21 +40,12 @@ #include #endif -#include "System.h" -#include "zlib.h" -#include "Memory.h" -#include "Misc.h" -#include "Vif.h" +#include "PsxCommon.h" #include "VU.h" -#include "R3000A.h" -#include "PsxMem.h" - #include "ix86/ix86.h" - #include "iCore.h" #include "iR3000A.h" -#include "PsxCounters.h" u32 g_psxMaxRecMem = 0; extern char *disRNameGPR[]; diff --git a/pcsx2/x86/iR3000Atables.cpp b/pcsx2/x86/iR3000Atables.cpp index 41e1c0fdfb..7578461cab 100644 --- a/pcsx2/x86/iR3000Atables.cpp +++ b/pcsx2/x86/iR3000Atables.cpp @@ -25,23 +25,10 @@ #include #include -#include "PS2Etypes.h" - -#if defined(_WIN32) -#include -#endif - -#include "System.h" -#include "Memory.h" -#include "Misc.h" -#include "Vif.h" +#include "PsxCommon.h" #include "VU.h" -#include "R3000A.h" -#include "PsxMem.h" - #include "ix86/ix86.h" - #include "iCore.h" #include "iR3000A.h" @@ -1855,7 +1842,7 @@ void (*rpsxBSC_co[64] )() = { pinst->regs[reg] |= EEINST_LASTUSE; \ prev->regs[reg] |= EEINST_LIVE0|EEINST_USED; \ pinst->regs[reg] |= EEINST_USED; \ - _recFillRegister(pinst, XMMTYPE_GPRREG, reg, 0); \ + _recFillRegister(*pinst, XMMTYPE_GPRREG, reg, 0); \ } \ #define rpsxpropSetWrite(reg) { \ @@ -1864,7 +1851,7 @@ void (*rpsxBSC_co[64] )() = { pinst->regs[reg] |= EEINST_LASTUSE; \ pinst->regs[reg] |= EEINST_USED; \ prev->regs[reg] |= EEINST_USED; \ - _recFillRegister(pinst, XMMTYPE_GPRREG, reg, 1); \ + _recFillRegister(*pinst, XMMTYPE_GPRREG, reg, 1); \ } void rpsxpropBSC(EEINST* prev, EEINST* pinst); diff --git a/pcsx2/x86/iR5900.h b/pcsx2/x86/iR5900.h index 218b7e67d2..fb9d2f0a82 100644 --- a/pcsx2/x86/iR5900.h +++ b/pcsx2/x86/iR5900.h @@ -249,4 +249,54 @@ void rec##fn(void) \ int eeRecompileCodeXMM(int xmminfo); void eeFPURecompileCode(R5900FNPTR_INFO xmmcode, R5900FNPTR fpucode, int xmminfo); + +// For propagation of BSC stuff. +// Code implementations in ir5900tables.c +class BSCPropagate +{ +protected: + EEINST& prev; + EEINST& pinst; + +public: + BSCPropagate( EEINST& previous, EEINST& pinstance ); + + void rprop(); + +protected: + void rpropSPECIAL(); + void rpropREGIMM(); + void rpropCP0(); + void rpropCP1(); + void rpropCP2(); + void rpropMMI(); + void rpropMMI0(); + void rpropMMI1(); + void rpropMMI2(); + void rpropMMI3(); + + void rpropSetRead( int reg, int mask ); + void rpropSetFPURead( int reg, int mask ); + void rpropSetWrite( int reg, int mask ); + void rpropSetFPUWrite( int reg, int mask ); + + template< int mask > + void rpropSetRead( int reg ); + + template< int live > + void rpropSetWrite0( int reg, int mask ); + + void rpropSetFast( int write1, int read1, int read2, int mask ); + + template< int low, int hi > + void rpropSetLOHI( int write1, int read1, int read2, int mask ); + + template< int mask > + void rpropSetFPURead( int reg ); + + template< int live > + void rpropSetFPUWrite0( int reg, int mask ); + +}; + #endif // __IR5900_H__ diff --git a/pcsx2/x86/ir5900tables.c b/pcsx2/x86/ir5900tables.c index 40c6fc34d7..e70a06a431 100644 --- a/pcsx2/x86/ir5900tables.c +++ b/pcsx2/x86/ir5900tables.c @@ -359,248 +359,253 @@ void (*recMMI3t[32] )() = { //////////////////////////////////////////////// // Back-Prob Function Tables - Gathering Info // //////////////////////////////////////////////// -#define rpropSetRead(reg, mask) { \ - if( !(pinst->regs[reg] & EEINST_USED) ) \ - pinst->regs[reg] |= EEINST_LASTUSE; \ - prev->regs[reg] |= EEINST_LIVE0|(mask)|EEINST_USED; \ - pinst->regs[reg] |= EEINST_USED; \ - if( reg ) pinst->info = ((mask)&(EEINST_MMX|EEINST_XMM)); \ - _recFillRegister(pinst, XMMTYPE_GPRREG, reg, 0); \ -} \ - -#define rpropSetWrite0(reg, mask, live) { \ - prev->regs[reg] &= ~((mask)|live|EEINST_XMM|EEINST_MMX); \ - if( !(pinst->regs[reg] & EEINST_USED) ) \ - pinst->regs[reg] |= EEINST_LASTUSE; \ - pinst->regs[reg] |= EEINST_USED; \ - prev->regs[reg] |= EEINST_USED; \ - _recFillRegister(pinst, XMMTYPE_GPRREG, reg, 1); \ +BSCPropagate::BSCPropagate( EEINST& previous, EEINST& pinstance ) : + prev( previous ) +, pinst( pinstance ) +{ } -#define rpropSetWrite(reg, mask) { \ - rpropSetWrite0(reg, mask, EEINST_LIVE0); \ -} \ +void BSCPropagate::rpropSetRead( int reg, int mask ) +{ + if( !(pinst.regs[reg] & EEINST_USED) ) + pinst.regs[reg] |= EEINST_LASTUSE; + prev.regs[reg] |= EEINST_LIVE0|(mask)|EEINST_USED; + pinst.regs[reg] |= EEINST_USED; + if( reg ) pinst.info = ((mask)&(EEINST_MMX|EEINST_XMM)); + _recFillRegister(pinst, XMMTYPE_GPRREG, reg, 0); +} -#define rpropSetFast(write1, read1, read2, mask) { \ - if( write1 ) { rpropSetWrite(write1, mask); } \ - if( read1 ) { rpropSetRead(read1, mask); } \ - if( read2 ) { rpropSetRead(read2, mask); } \ -} \ +template< int live > +void BSCPropagate::rpropSetWrite0( int reg, int mask ) +{ + prev.regs[reg] &= ~((mask)|live|EEINST_XMM|EEINST_MMX); + if( !(pinst.regs[reg] & EEINST_USED) ) + pinst.regs[reg] |= EEINST_LASTUSE; + pinst.regs[reg] |= EEINST_USED; + prev.regs[reg] |= EEINST_USED; + _recFillRegister(pinst, XMMTYPE_GPRREG, reg, 1); +} -#define rpropSetLOHI(write1, read1, read2, mask, lo, hi) { \ - if( write1 ) { rpropSetWrite(write1, mask); } \ - if( (lo) & MODE_WRITE ) { rpropSetWrite(XMMGPR_LO, mask); } \ - if( (hi) & MODE_WRITE ) { rpropSetWrite(XMMGPR_HI, mask); } \ - if( read1 ) { rpropSetRead(read1, mask); } \ - if( read2 ) { rpropSetRead(read2, mask); } \ - if( (lo) & MODE_READ ) { rpropSetRead(XMMGPR_LO, mask); } \ - if( (hi) & MODE_READ ) { rpropSetRead(XMMGPR_HI, mask); } \ -} \ +__forceinline void BSCPropagate::rpropSetWrite( int reg, int mask ) +{ + rpropSetWrite0( reg, mask ); +} + +__forceinline void BSCPropagate::rpropSetFast( int write1, int read1, int read2, int mask ) +{ + if( write1 ) { rpropSetWrite(write1,mask); } + if( read1 ) { rpropSetRead(read1,mask); } + if( read2 ) { rpropSetRead(read2,mask); } +} + +template< int lo, int hi > +void BSCPropagate::rpropSetLOHI( int write1, int read1, int read2, int mask ) +{ + if( write1 ) { rpropSetWrite(write1,mask); } + if( lo & MODE_WRITE ) { rpropSetWrite(XMMGPR_LO,mask); } + if( hi & MODE_WRITE ) { rpropSetWrite(XMMGPR_HI,mask); } + if( read1 ) { rpropSetRead(read1,mask); } + if( read2 ) { rpropSetRead(read2,mask); } + if( lo & MODE_READ ) { rpropSetRead(XMMGPR_LO,mask); } + if( hi & MODE_READ ) { rpropSetRead(XMMGPR_HI,mask); } +} // FPU regs -#define rpropSetFPURead(reg, mask) { \ - if( !(pinst->fpuregs[reg] & EEINST_USED) ) \ - pinst->fpuregs[reg] |= EEINST_LASTUSE; \ - prev->fpuregs[reg] |= EEINST_LIVE0|(mask)|EEINST_USED; \ - pinst->fpuregs[reg] |= EEINST_USED; \ - if( reg ) pinst->info = ((mask)&(EEINST_MMX|EEINST_XMM)); \ - if( reg == XMMFPU_ACC ) _recFillRegister(pinst, XMMTYPE_FPACC, 0, 0); \ - else _recFillRegister(pinst, XMMTYPE_FPREG, reg, 0); \ -} \ - -#define rpropSetFPUWrite0(reg, mask, live) { \ - prev->fpuregs[reg] &= ~((mask)|live|EEINST_XMM|EEINST_MMX); \ - if( !(pinst->fpuregs[reg] & EEINST_USED) ) \ - pinst->fpuregs[reg] |= EEINST_LASTUSE; \ - pinst->fpuregs[reg] |= EEINST_USED; \ - prev->fpuregs[reg] |= EEINST_USED; \ - if( reg == XMMFPU_ACC ) _recFillRegister(pinst, XMMTYPE_FPACC, 0, 1); \ - else _recFillRegister(pinst, XMMTYPE_FPREG, reg, 1); \ +void BSCPropagate::rpropSetFPURead( int reg, int mask ) +{ + if( !(pinst.fpuregs[reg] & EEINST_USED) ) + pinst.fpuregs[reg] |= EEINST_LASTUSE; + prev.fpuregs[reg] |= EEINST_LIVE0|(mask)|EEINST_USED; + pinst.fpuregs[reg] |= EEINST_USED; + if( reg ) pinst.info = ((mask)&(EEINST_MMX|EEINST_XMM)); + if( reg == XMMFPU_ACC ) _recFillRegister(pinst, XMMTYPE_FPACC, 0, 0); + else _recFillRegister(pinst, XMMTYPE_FPREG, reg, 0); } -#define rpropSetFPUWrite(reg, mask) { \ - rpropSetFPUWrite0(reg, mask, EEINST_LIVE0); \ -} \ +template< int live > +void BSCPropagate::rpropSetFPUWrite0( int reg, int mask ) +{ + prev.fpuregs[reg] &= ~((mask)|live|EEINST_XMM|EEINST_MMX); + if( !(pinst.fpuregs[reg] & EEINST_USED) ) + pinst.fpuregs[reg] |= EEINST_LASTUSE; + pinst.fpuregs[reg] |= EEINST_USED; + prev.fpuregs[reg] |= EEINST_USED; + if( reg == XMMFPU_ACC ) _recFillRegister(pinst, XMMTYPE_FPACC, 0, 1); + else _recFillRegister(pinst, XMMTYPE_FPREG, reg, 1); +} +__forceinline void BSCPropagate::rpropSetFPUWrite( int reg, int mask ) +{ + rpropSetFPUWrite0( reg, mask ); +} -void rpropBSC(EEINST* prev, EEINST* pinst); -void rpropSPECIAL(EEINST* prev, EEINST* pinst); -void rpropREGIMM(EEINST* prev, EEINST* pinst); -void rpropCP0(EEINST* prev, EEINST* pinst); -void rpropCP1(EEINST* prev, EEINST* pinst); -void rpropCP2(EEINST* prev, EEINST* pinst); -void rpropMMI(EEINST* prev, EEINST* pinst); -void rpropMMI0(EEINST* prev, EEINST* pinst); -void rpropMMI1(EEINST* prev, EEINST* pinst); -void rpropMMI2(EEINST* prev, EEINST* pinst); -void rpropMMI3(EEINST* prev, EEINST* pinst); #define EEINST_REALXMM EEINST_XMM -//SPECIAL, REGIMM, J, JAL, BEQ, BNE, BLEZ, BGTZ, -//ADDI, ADDIU, SLTI, SLTIU, ANDI, ORI, XORI, LUI, -//COP0, COP1, COP2, NULL, BEQL, BNEL, BLEZL, BGTZL, -//DADDI, DADDIU, LDL, LDR, MMI, NULL, LQ, SQ, -//LB, LH, LWL, LW, LBU, LHU, LWR, LWU, -//SB, SH, SWL, SW, SDL, SDR, SWR, CACHE, -//NULL, LWC1, NULL, PREF, NULL, NULL, LQC2, LD, -//NULL, SWC1, NULL, NULL, NULL, NULL, SQC2, SD -void rpropBSC(EEINST* prev, EEINST* pinst) -{ - switch(cpuRegs.code >> 26) { - case 0: rpropSPECIAL(prev, pinst); break; - case 1: rpropREGIMM(prev, pinst); break; - case 2: // j - break; - case 3: // jal - rpropSetWrite(31, EEINST_LIVE1); - break; - case 4: // beq - case 5: // bne - rpropSetRead(_Rs_, EEINST_LIVE1); - rpropSetRead(_Rt_, EEINST_LIVE1); - pinst->info |= EEINST_REALXMM|EEINST_MMX; - break; - case 20: // beql - case 21: // bnel - // reset since don't know which path to go - _recClearInst(prev); - prev->info = 0; - rpropSetRead(_Rs_, EEINST_LIVE1); - rpropSetRead(_Rt_, EEINST_LIVE1); - pinst->info |= EEINST_REALXMM|EEINST_MMX; - break; - case 6: // blez - case 7: // bgtz - rpropSetRead(_Rs_, EEINST_LIVE1); - break; - case 22: // blezl - case 23: // bgtzl - // reset since don't know which path to go - _recClearInst(prev); - prev->info = 0; - rpropSetRead(_Rs_, EEINST_LIVE1); - break; - case 24: // daddi - case 25: // daddiu - rpropSetWrite(_Rt_, EEINST_LIVE1); - rpropSetRead(_Rs_, EEINST_LIVE1 | (_Rs_!=0?EEINST_MMX:0)); // This looks like what ZeroFrog wanted; ToDo: Needs checking! (cottonvibes) - break; - case 8: // addi - case 9: // addiu - rpropSetWrite(_Rt_, EEINST_LIVE1); - rpropSetRead(_Rs_, 0); - pinst->info |= EEINST_MMX; - break; - case 10: // slti - rpropSetWrite(_Rt_, EEINST_LIVE1); - rpropSetRead(_Rs_, EEINST_LIVE1); - pinst->info |= EEINST_MMX; - break; - case 11: // sltiu - rpropSetWrite(_Rt_, EEINST_LIVE1); - rpropSetRead(_Rs_, EEINST_LIVE1); - pinst->info |= EEINST_MMX; - break; - case 12: // andi - rpropSetWrite(_Rt_, EEINST_LIVE1); - rpropSetRead(_Rs_, (_Rs_!=_Rt_?EEINST_MMX:0)); - pinst->info |= EEINST_MMX; - break; - case 13: // ori - rpropSetWrite(_Rt_, EEINST_LIVE1); - rpropSetRead(_Rs_, EEINST_LIVE1|(_Rs_!=_Rt_?EEINST_MMX:0)); - pinst->info |= EEINST_MMX; - break; - case 14: // xori - rpropSetWrite(_Rt_, EEINST_LIVE1); - rpropSetRead(_Rs_, EEINST_LIVE1|(_Rs_!=_Rt_?EEINST_MMX:0)); - pinst->info |= EEINST_MMX; - break; - case 15: // lui - rpropSetWrite(_Rt_, EEINST_LIVE1); - break; - case 16: rpropCP0(prev, pinst); break; - case 17: rpropCP1(prev, pinst); break; - case 18: rpropCP2(prev, pinst); break; - // loads - case 34: // lwl - case 38: // lwr - case 26: // ldl - case 27: // ldr - rpropSetWrite(_Rt_, EEINST_LIVE1); - rpropSetRead(_Rt_, EEINST_LIVE1); - rpropSetRead(_Rs_, 0); - break; - case 32: case 33: case 35: case 36: case 37: case 39: - case 55: // LD - rpropSetWrite(_Rt_, EEINST_LIVE1); - rpropSetRead(_Rs_, 0); - break; - case 28: rpropMMI(prev, pinst); break; - case 30: // lq - rpropSetWrite(_Rt_, EEINST_LIVE1|EEINST_LIVE2); - rpropSetRead(_Rs_, 0); - pinst->info |= EEINST_MMX; - pinst->info |= EEINST_REALXMM; - break; - case 31: // sq - rpropSetRead(_Rt_, EEINST_LIVE1|EEINST_LIVE2|EEINST_REALXMM); - rpropSetRead(_Rs_, 0); - pinst->info |= EEINST_MMX; - pinst->info |= EEINST_REALXMM; - break; - // 4 byte stores - case 40: case 41: case 42: case 43: case 46: - rpropSetRead(_Rt_, 0); - rpropSetRead(_Rs_, 0); - pinst->info |= EEINST_MMX; - pinst->info |= EEINST_REALXMM; - break; - case 44: // sdl - case 45: // sdr - case 63: // sd - rpropSetRead(_Rt_, EEINST_LIVE1|EEINST_MMX|EEINST_REALXMM); - rpropSetRead(_Rs_, 0); - break; - case 49: // lwc1 - rpropSetFPUWrite(_Rt_, EEINST_REALXMM); - rpropSetRead(_Rs_, 0); - break; - case 57: // swc1 - rpropSetFPURead(_Rt_, EEINST_REALXMM); - rpropSetRead(_Rs_, 0); - break; - case 54: // lqc2 - case 62: // sqc2 - rpropSetRead(_Rs_, 0); - break; - default: - rpropSetWrite(_Rt_, EEINST_LIVE1); - rpropSetRead(_Rs_, EEINST_LIVE1|(_Rs_!=0?EEINST_MMX:0)); - break; - } -} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + //SLL, NULL, SRL, SRA, SLLV, NULL, SRLV, SRAV, //JR, JALR, MOVZ, MOVN, SYSCALL, BREAK, NULL, SYNC, @@ -610,9 +615,9 @@ void rpropBSC(EEINST* prev, EEINST* pinst) //MFSA, MTSA, SLT, SLTU, DADD, DADDU, DSUB, DSUBU, //TGE, TGEU, TLT, TLTU, TEQ, NULL, TNE, NULL, //DSLL, NULL, DSRL, DSRA, DSLL32, NULL, DSRL32, DSRA32 -void rpropSPECIAL(EEINST* prev, EEINST* pinst) + +__forceinline void BSCPropagate::rpropSPECIAL() { - //int temp; switch(_Funct_) { case 0: // SLL case 2: // SRL @@ -643,21 +648,21 @@ void rpropSPECIAL(EEINST* prev, EEINST* pinst) rpropSetRead(_Rs_, EEINST_LIVE1); rpropSetRead(_Rt_, EEINST_LIVE1); rpropSetRead(_Rd_, EEINST_LIVE1); - pinst->info |= EEINST_MMX; + pinst.info |= EEINST_MMX; _recFillRegister(pinst, XMMTYPE_GPRREG, _Rd_, 1); break; case 12: // syscall case 13: // break - _recClearInst(prev); - prev->info = 0; + _recClearInst(&prev); + prev.info = 0; break; case 15: // sync break; case 16: // mfhi rpropSetWrite(_Rd_, EEINST_LIVE1); - rpropSetRead(XMMGPR_HI, (pinst->regs[_Rd_]&(EEINST_MMX|EEINST_REALXMM))|EEINST_LIVE1); + rpropSetRead(XMMGPR_HI, (pinst.regs[_Rd_]&(EEINST_MMX|EEINST_REALXMM))|EEINST_LIVE1); break; case 17: // mthi rpropSetWrite(XMMGPR_HI, EEINST_LIVE1); @@ -665,7 +670,7 @@ void rpropSPECIAL(EEINST* prev, EEINST* pinst) break; case 18: // mflo rpropSetWrite(_Rd_, EEINST_LIVE1); - rpropSetRead(XMMGPR_LO, (pinst->regs[_Rd_]&(EEINST_MMX|EEINST_REALXMM))|EEINST_LIVE1); + rpropSetRead(XMMGPR_LO, (pinst.regs[_Rd_]&(EEINST_MMX|EEINST_REALXMM))|EEINST_LIVE1); break; case 19: // mtlo rpropSetWrite(XMMGPR_LO, EEINST_LIVE1); @@ -684,7 +689,7 @@ void rpropSPECIAL(EEINST* prev, EEINST* pinst) // // can do unsigned mult only if HI isn't used // //using this allocation for temp causes the emu to crash - // //temp = (pinst->regs[XMMGPR_HI]&(EEINST_LIVE0|EEINST_LIVE1))?0:EEINST_MMX; + // //temp = (pinst.regs[XMMGPR_HI]&(EEINST_LIVE0|EEINST_LIVE1))?0:EEINST_MMX; // temp = 0; // rpropSetWrite(XMMGPR_LO, EEINST_LIVE1); // rpropSetWrite(XMMGPR_HI, EEINST_LIVE1); @@ -695,7 +700,7 @@ void rpropSPECIAL(EEINST* prev, EEINST* pinst) // // Yep, its wrong. Using always 0 causes the wrong damage calculations in Soul Nomad. // rpropSetRead(_Rs_, temp); // rpropSetRead(_Rt_, temp); - // pinst->info |= temp; + // pinst.info |= temp; // break; //case 25: // multu @@ -704,7 +709,7 @@ void rpropSPECIAL(EEINST* prev, EEINST* pinst) // rpropSetWrite(_Rd_, EEINST_LIVE1); // rpropSetRead(_Rs_, EEINST_MMX); // rpropSetRead(_Rt_, EEINST_MMX); - // pinst->info |= EEINST_MMX; + // pinst.info |= EEINST_MMX; // break; @@ -715,7 +720,9 @@ void rpropSPECIAL(EEINST* prev, EEINST* pinst) rpropSetWrite(_Rd_, EEINST_LIVE1); rpropSetRead(_Rs_, EEINST_USED); //EEINST_MMX crashes on init, EEINST_XMM fails on Tales of Abyss, so EEINST_USED (rama) rpropSetRead(_Rt_, EEINST_USED); - pinst->info |= EEINST_USED; + // did we ever try EEINST_LIVE1 or 0 in the place of EEINST_USED? I think of those might be more correct here (Air) + + pinst.info |= EEINST_USED; break; case 26: // div @@ -724,7 +731,7 @@ void rpropSPECIAL(EEINST* prev, EEINST* pinst) rpropSetWrite(XMMGPR_HI, EEINST_LIVE1); rpropSetRead(_Rs_, 0); rpropSetRead(_Rt_, 0); - //pinst->info |= EEINST_REALXMM|EEINST_MMX; + //pinst.info |= EEINST_REALXMM|EEINST_MMX; break; case 32: // add @@ -734,7 +741,7 @@ void rpropSPECIAL(EEINST* prev, EEINST* pinst) rpropSetWrite(_Rd_, EEINST_LIVE1); if( _Rs_ ) rpropSetRead(_Rs_, 0); if( _Rt_ ) rpropSetRead(_Rt_, 0); - pinst->info |= EEINST_MMX; + pinst.info |= EEINST_MMX; break; case 36: // and @@ -743,8 +750,8 @@ void rpropSPECIAL(EEINST* prev, EEINST* pinst) case 39: // nor // if rd == rs or rt, keep live1 rpropSetWrite(_Rd_, EEINST_LIVE1); - rpropSetRead(_Rs_, (pinst->regs[_Rd_]&EEINST_LIVE1)|EEINST_MMX); - rpropSetRead(_Rt_, (pinst->regs[_Rd_]&EEINST_LIVE1)|EEINST_MMX); + rpropSetRead(_Rs_, (pinst.regs[_Rd_]&EEINST_LIVE1)|EEINST_MMX); + rpropSetRead(_Rt_, (pinst.regs[_Rd_]&EEINST_LIVE1)|EEINST_MMX); break; case 40: // mfsa @@ -758,14 +765,14 @@ void rpropSPECIAL(EEINST* prev, EEINST* pinst) rpropSetWrite(_Rd_, EEINST_LIVE1); rpropSetRead(_Rs_, EEINST_LIVE1); rpropSetRead(_Rt_, EEINST_LIVE1); - pinst->info |= EEINST_MMX; + pinst.info |= EEINST_MMX; break; case 43: // sltu rpropSetWrite(_Rd_, EEINST_LIVE1); rpropSetRead(_Rs_, EEINST_LIVE1); rpropSetRead(_Rt_, EEINST_LIVE1); - pinst->info |= EEINST_MMX; + pinst.info |= EEINST_MMX; break; case 44: // dadd @@ -775,14 +782,14 @@ void rpropSPECIAL(EEINST* prev, EEINST* pinst) rpropSetWrite(_Rd_, EEINST_LIVE1); if( _Rs_ == 0 || _Rt_ == 0 ) { // just a copy, so don't force mmx - rpropSetRead(_Rs_, (pinst->regs[_Rd_]&EEINST_LIVE1)); - rpropSetRead(_Rt_, (pinst->regs[_Rd_]&EEINST_LIVE1)); + rpropSetRead(_Rs_, (pinst.regs[_Rd_]&EEINST_LIVE1)); + rpropSetRead(_Rt_, (pinst.regs[_Rd_]&EEINST_LIVE1)); } else { - rpropSetRead(_Rs_, (pinst->regs[_Rd_]&EEINST_LIVE1)|EEINST_MMX); - rpropSetRead(_Rt_, (pinst->regs[_Rd_]&EEINST_LIVE1)|EEINST_MMX); + rpropSetRead(_Rs_, (pinst.regs[_Rd_]&EEINST_LIVE1)|EEINST_MMX); + rpropSetRead(_Rt_, (pinst.regs[_Rd_]&EEINST_LIVE1)|EEINST_MMX); } - pinst->info |= EEINST_MMX; + pinst.info |= EEINST_MMX; break; // traps @@ -798,13 +805,13 @@ void rpropSPECIAL(EEINST* prev, EEINST* pinst) case 63: // dsra32 rpropSetWrite(_Rd_, EEINST_LIVE1); rpropSetRead(_Rt_, EEINST_LIVE1|EEINST_MMX); - pinst->info |= EEINST_MMX; + pinst.info |= EEINST_MMX; break; case 60: // dsll32 rpropSetWrite(_Rd_, EEINST_LIVE1); rpropSetRead(_Rt_, EEINST_MMX); - pinst->info |= EEINST_MMX; + pinst.info |= EEINST_MMX; break; default: @@ -819,24 +826,24 @@ void rpropSPECIAL(EEINST* prev, EEINST* pinst) //TGEI, TGEIU, TLTI, TLTIU, TEQI, NULL, TNEI, NULL, //BLTZAL, BGEZAL, BLTZALL, BGEZALL, NULL, NULL, NULL, NULL, //MTSAB, MTSAH, NULL, NULL, NULL, NULL, NULL, NULL, -void rpropREGIMM(EEINST* prev, EEINST* pinst) +__forceinline void BSCPropagate::rpropREGIMM() { switch(_Rt_) { case 0: // bltz case 1: // bgez rpropSetRead(_Rs_, EEINST_LIVE1); - pinst->info |= EEINST_MMX; - pinst->info |= EEINST_REALXMM; + pinst.info |= EEINST_MMX; + pinst.info |= EEINST_REALXMM; break; case 2: // bltzl case 3: // bgezl // reset since don't know which path to go - _recClearInst(prev); - prev->info = 0; + _recClearInst(&prev); + prev.info = 0; rpropSetRead(_Rs_, EEINST_LIVE1); - pinst->info |= EEINST_MMX; - pinst->info |= EEINST_REALXMM; + pinst.info |= EEINST_MMX; + pinst.info |= EEINST_REALXMM; break; // traps @@ -858,8 +865,8 @@ void rpropREGIMM(EEINST* prev, EEINST* pinst) case 18: // bltzall case 19: // bgezall // reset since don't know which path to go - _recClearInst(prev); - prev->info = 0; + _recClearInst(&prev); + prev.info = 0; // do not write 31 rpropSetRead(_Rs_, EEINST_LIVE1); break; @@ -878,7 +885,7 @@ void rpropREGIMM(EEINST* prev, EEINST* pinst) //COP0BC0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, //COP0C0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, //NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -void rpropCP0(EEINST* prev, EEINST* pinst) +__forceinline void BSCPropagate::rpropCP0() { switch(_Rs_) { case 0: // mfc0 @@ -888,12 +895,12 @@ void rpropCP0(EEINST* prev, EEINST* pinst) rpropSetRead(_Rt_, EEINST_LIVE1|EEINST_REALXMM); break; case 8: // cop0bc0 - _recClearInst(prev); - prev->info = 0; + _recClearInst(&prev); + prev.info = 0; break; case 16: // cop0c0 - _recClearInst(prev); - prev->info = 0; + _recClearInst(&prev); + prev.info = 0; break; } } @@ -910,7 +917,7 @@ void rpropCP0(EEINST* prev, EEINST* pinst) //MAX_S, MIN_S, NULL, NULL, NULL, NULL, NULL, NULL, //C_F, NULL, C_EQ, NULL, C_LT, NULL, C_LE, NULL, //NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -void rpropCP1(EEINST* prev, EEINST* pinst) +__forceinline void BSCPropagate::rpropCP1() { switch(_Rs_) { case 0: // mfc1 @@ -929,12 +936,12 @@ void rpropCP1(EEINST* prev, EEINST* pinst) break; case 8: // bc1 // reset since don't know which path to go - _recClearInst(prev); - prev->info = 0; + _recClearInst(&prev); + prev.info = 0; break; case 16: // floating point ops - pinst->info |= EEINST_REALXMM; + pinst.info |= EEINST_REALXMM; switch( _Funct_ ) { case 0: // add.s case 1: // sub.s @@ -1005,7 +1012,7 @@ void rpropCP1(EEINST* prev, EEINST* pinst) #undef _Fs_ #undef _Fd_ -void rpropCP2(EEINST* prev, EEINST* pinst) +__forceinline void BSCPropagate::rpropCP2() { switch(_Rs_) { case 1: // qmfc2 @@ -1029,7 +1036,7 @@ void rpropCP2(EEINST* prev, EEINST* pinst) default: // vu macro mode insts - pinst->info |= 2; + pinst.info |= 2; break; } } @@ -1042,77 +1049,82 @@ void rpropCP2(EEINST* prev, EEINST* pinst) //MMI1 , MMI3, NULL, NULL, NULL, NULL, NULL, NULL, //PMFHL, PMTHL, NULL, NULL, PSLLH, NULL, PSRLH, PSRAH, //NULL, NULL, NULL, NULL, PSLLW, NULL, PSRLW, PSRAW, -void rpropMMI(EEINST* prev, EEINST* pinst) +__forceinline void BSCPropagate::rpropMMI() { - int temp; switch(cpuRegs.code&0x3f) { case 0: // madd case 1: // maddu - rpropSetLOHI(_Rd_, _Rs_, _Rt_, EEINST_LIVE1, MODE_READ|MODE_WRITE, MODE_READ|MODE_WRITE); + rpropSetLOHI(_Rd_, _Rs_, _Rt_, EEINST_LIVE1); break; case 4: // plzcw rpropSetFast(_Rd_, _Rs_, 0, EEINST_LIVE1); break; - case 8: rpropMMI0(prev, pinst); break; - case 9: rpropMMI2(prev, pinst); break; + case 8: rpropMMI0(); break; + case 9: rpropMMI2(); break; case 16: // mfhi1 + { rpropSetWrite(_Rd_, EEINST_LIVE1); - temp = ((pinst->regs[_Rd_]&(EEINST_MMX|EEINST_REALXMM))?EEINST_MMX:EEINST_REALXMM); + int temp = ((pinst.regs[_Rd_]&(EEINST_MMX|EEINST_REALXMM))?EEINST_MMX:EEINST_REALXMM); rpropSetRead(XMMGPR_HI, temp|EEINST_LIVE2); break; + } case 17: // mthi1 - rpropSetWrite0(XMMGPR_HI, EEINST_LIVE2, 0); + rpropSetWrite0<0>(XMMGPR_HI, EEINST_LIVE2); rpropSetRead(_Rs_, EEINST_LIVE1); break; case 18: // mflo1 + { rpropSetWrite(_Rd_, EEINST_LIVE1); - temp = ((pinst->regs[_Rd_]&(EEINST_MMX|EEINST_REALXMM))?EEINST_MMX:EEINST_REALXMM); + int temp = ((pinst.regs[_Rd_]&(EEINST_MMX|EEINST_REALXMM))?EEINST_MMX:EEINST_REALXMM); rpropSetRead(XMMGPR_LO, temp|EEINST_LIVE2); break; + } case 19: // mtlo1 - rpropSetWrite0(XMMGPR_LO, EEINST_LIVE2, 0); + rpropSetWrite0<0>(XMMGPR_LO, EEINST_LIVE2); rpropSetRead(_Rs_, EEINST_LIVE1); break; case 24: // mult1 - temp = (pinst->regs[XMMGPR_HI]&(EEINST_LIVE2))?0:EEINST_MMX; - rpropSetWrite0(XMMGPR_LO, EEINST_LIVE2, 0); - rpropSetWrite0(XMMGPR_HI, EEINST_LIVE2, 0); + { + int temp = (pinst.regs[XMMGPR_HI]&(EEINST_LIVE2))?0:EEINST_MMX; + rpropSetWrite0<0>(XMMGPR_LO, EEINST_LIVE2); + rpropSetWrite0<0>(XMMGPR_HI, EEINST_LIVE2); rpropSetWrite(_Rd_, EEINST_LIVE1); rpropSetRead(_Rs_, temp); rpropSetRead(_Rt_, temp); - pinst->info |= temp; + pinst.info |= temp; break; + } case 25: // multu1 - rpropSetWrite0(XMMGPR_LO, EEINST_LIVE2, 0); - rpropSetWrite0(XMMGPR_HI, EEINST_LIVE2, 0); + rpropSetWrite0<0>(XMMGPR_LO, EEINST_LIVE2); + rpropSetWrite0<0>(XMMGPR_HI, EEINST_LIVE2); rpropSetWrite(_Rd_, EEINST_LIVE1); rpropSetRead(_Rs_, EEINST_MMX); rpropSetRead(_Rt_, EEINST_MMX); - pinst->info |= EEINST_MMX; + pinst.info |= EEINST_MMX; break; case 26: // div1 case 27: // divu1 - rpropSetWrite0(XMMGPR_LO, EEINST_LIVE2, 0); - rpropSetWrite0(XMMGPR_HI, EEINST_LIVE2, 0); + rpropSetWrite0<0>(XMMGPR_LO, EEINST_LIVE2); + rpropSetWrite0<0>(XMMGPR_HI, EEINST_LIVE2); rpropSetRead(_Rs_, 0); rpropSetRead(_Rt_, 0); - //pinst->info |= EEINST_REALXMM|EEINST_MMX; + //pinst.info |= EEINST_REALXMM|EEINST_MMX; break; case 32: // madd1 case 33: // maddu1 - rpropSetWrite0(XMMGPR_LO, EEINST_LIVE2, 0); - rpropSetWrite0(XMMGPR_HI, EEINST_LIVE2, 0); + rpropSetWrite0<0>(XMMGPR_LO, EEINST_LIVE2); + rpropSetWrite0<0>(XMMGPR_HI, EEINST_LIVE2); rpropSetFast(_Rd_, _Rs_, _Rt_, EEINST_LIVE1); rpropSetRead(XMMGPR_LO, EEINST_LIVE2); rpropSetRead(XMMGPR_HI, EEINST_LIVE2); break; - case 40: rpropMMI1(prev, pinst); break; - case 41: rpropMMI3(prev, pinst); break; + case 40: rpropMMI1(); break; + case 41: rpropMMI3(); break; case 48: // pmfhl rpropSetWrite(_Rd_, EEINST_LIVE2|EEINST_LIVE1); @@ -1140,7 +1152,7 @@ void rpropMMI(EEINST* prev, EEINST* pinst) //PADDSH, PSUBSH, PEXTLH, PPACH, //PADDSB, PSUBSB, PEXTLB, PPACB, //NULL, NULL, PEXT5, PPAC5, -void rpropMMI0(EEINST* prev, EEINST* pinst) +__forceinline void BSCPropagate::rpropMMI0() { switch((cpuRegs.code>>6)&0x1f) { case 16: // paddsw @@ -1167,7 +1179,7 @@ void rpropMMI0(EEINST* prev, EEINST* pinst) } } -void rpropMMI1(EEINST* prev, EEINST* pinst) +__forceinline void BSCPropagate::rpropMMI1() { switch((cpuRegs.code>>6)&0x1f) { case 1: // pabsw @@ -1194,12 +1206,13 @@ void rpropMMI1(EEINST* prev, EEINST* pinst) } } -void rpropMMI2(EEINST* prev, EEINST* pinst) +__forceinline void BSCPropagate::rpropMMI2() { switch((cpuRegs.code>>6)&0x1f) { case 0: // pmaddw case 4: // pmsubw - rpropSetLOHI(_Rd_, _Rs_, _Rt_, EEINST_LIVE2|EEINST_LIVE1, MODE_READ|MODE_WRITE, MODE_READ|MODE_WRITE); + rpropSetLOHI + (_Rd_, _Rs_, _Rt_, EEINST_LIVE2|EEINST_LIVE1); break; case 2: // psllvw case 3: // psllvw @@ -1219,10 +1232,12 @@ void rpropMMI2(EEINST* prev, EEINST* pinst) rpropSetRead(_Rt_, EEINST_LIVE1|EEINST_REALXMM); break; case 12: // pmultw, - rpropSetLOHI(_Rd_, _Rs_, _Rt_, EEINST_LIVE2|EEINST_LIVE1, MODE_WRITE, MODE_WRITE); + rpropSetLOHI + (_Rd_, _Rs_, _Rt_, EEINST_LIVE2|EEINST_LIVE1); break; case 13: // pdivw - rpropSetLOHI(0, _Rs_, _Rt_, EEINST_LIVE2|EEINST_LIVE1, MODE_WRITE, MODE_WRITE); + rpropSetLOHI + (0, _Rs_, _Rt_, EEINST_LIVE2|EEINST_LIVE1); break; case 14: // pcpyld rpropSetWrite(_Rd_, EEINST_LIVE2|EEINST_LIVE1); @@ -1233,7 +1248,8 @@ void rpropMMI2(EEINST* prev, EEINST* pinst) case 17: // phmadh case 20: // pmsubh case 21: // phmsbh - rpropSetLOHI(_Rd_, _Rs_, _Rt_, EEINST_LIVE2|EEINST_LIVE1|EEINST_REALXMM, MODE_READ|MODE_WRITE, MODE_READ|MODE_WRITE); + rpropSetLOHI + (_Rd_, _Rs_, _Rt_, EEINST_LIVE2|EEINST_LIVE1|EEINST_REALXMM); break; case 26: // pexeh @@ -1245,10 +1261,12 @@ void rpropMMI2(EEINST* prev, EEINST* pinst) break; case 28: // pmulth - rpropSetLOHI(_Rd_, _Rs_, _Rt_, EEINST_LIVE2|EEINST_LIVE1|EEINST_REALXMM, MODE_WRITE, MODE_WRITE); + rpropSetLOHI + (_Rd_, _Rs_, _Rt_, EEINST_LIVE2|EEINST_LIVE1|EEINST_REALXMM); break; case 29: // pdivbw - rpropSetLOHI(_Rd_, _Rs_, _Rt_, EEINST_LIVE2|EEINST_LIVE1, MODE_WRITE, MODE_WRITE); + rpropSetLOHI + (_Rd_, _Rs_, _Rt_, EEINST_LIVE2|EEINST_LIVE1|EEINST_REALXMM); break; default: @@ -1257,11 +1275,12 @@ void rpropMMI2(EEINST* prev, EEINST* pinst) } } -void rpropMMI3(EEINST* prev, EEINST* pinst) +__forceinline void BSCPropagate::rpropMMI3() { switch((cpuRegs.code>>6)&0x1f) { case 0: // pmadduw - rpropSetLOHI(_Rd_, _Rs_, _Rt_, EEINST_LIVE2|EEINST_LIVE1|EEINST_REALXMM, MODE_READ|MODE_WRITE, MODE_READ|MODE_WRITE); + rpropSetLOHI + (_Rd_, _Rs_, _Rt_, EEINST_LIVE2|EEINST_LIVE1|EEINST_REALXMM ); break; case 3: // psravw rpropSetFast(_Rd_, _Rs_, _Rt_, EEINST_LIVE2); @@ -1276,10 +1295,12 @@ void rpropMMI3(EEINST* prev, EEINST* pinst) rpropSetRead(_Rs_, EEINST_LIVE2|EEINST_LIVE1|EEINST_REALXMM); break; case 12: // pmultuw, - rpropSetLOHI(_Rd_, _Rs_, _Rt_, EEINST_LIVE2|EEINST_LIVE1|EEINST_REALXMM, MODE_WRITE, MODE_WRITE); + rpropSetLOHI + (_Rd_, _Rs_, _Rt_, EEINST_LIVE2|EEINST_LIVE1|EEINST_REALXMM); break; case 13: // pdivuw - rpropSetLOHI(0, _Rs_, _Rt_, EEINST_LIVE2|EEINST_LIVE1, MODE_WRITE, MODE_WRITE); + rpropSetLOHI + (0, _Rs_, _Rt_, EEINST_LIVE2|EEINST_LIVE1); break; case 14: // pcpyud rpropSetWrite(_Rd_, EEINST_LIVE2|EEINST_LIVE1); @@ -1300,4 +1321,169 @@ void rpropMMI3(EEINST* prev, EEINST* pinst) } } +//SPECIAL, REGIMM, J, JAL, BEQ, BNE, BLEZ, BGTZ, +//ADDI, ADDIU, SLTI, SLTIU, ANDI, ORI, XORI, LUI, +//COP0, COP1, COP2, NULL, BEQL, BNEL, BLEZL, BGTZL, +//DADDI, DADDIU, LDL, LDR, MMI, NULL, LQ, SQ, +//LB, LH, LWL, LW, LBU, LHU, LWR, LWU, +//SB, SH, SWL, SW, SDL, SDR, SWR, CACHE, +//NULL, LWC1, NULL, PREF, NULL, NULL, LQC2, LD, +//NULL, SWC1, NULL, NULL, NULL, NULL, SQC2, SD +void BSCPropagate::rprop() +{ + switch(cpuRegs.code >> 26) { + case 0: rpropSPECIAL(); break; + case 1: rpropREGIMM(); break; + case 2: // j + break; + case 3: // jal + rpropSetWrite(31, EEINST_LIVE1); + break; + case 4: // beq + case 5: // bne + rpropSetRead(_Rs_, EEINST_LIVE1); + rpropSetRead(_Rt_, EEINST_LIVE1); + pinst.info |= EEINST_REALXMM|EEINST_MMX; + break; + + case 20: // beql + case 21: // bnel + // reset since don't know which path to go + _recClearInst(&prev); + prev.info = 0; + rpropSetRead(_Rs_, EEINST_LIVE1); + rpropSetRead(_Rt_, EEINST_LIVE1); + pinst.info |= EEINST_REALXMM|EEINST_MMX; + break; + + case 6: // blez + case 7: // bgtz + rpropSetRead(_Rs_, EEINST_LIVE1); + break; + + case 22: // blezl + case 23: // bgtzl + // reset since don't know which path to go + _recClearInst(&prev); + prev.info = 0; + rpropSetRead(_Rs_, EEINST_LIVE1); + break; + + case 24: // daddi + case 25: // daddiu + rpropSetWrite(_Rt_, EEINST_LIVE1); + rpropSetRead(_Rs_, EEINST_LIVE1 | (_Rs_!=0?EEINST_MMX:0)); // This looks like what ZeroFrog wanted; ToDo: Needs checking! (cottonvibes) + break; + + case 8: // addi + case 9: // addiu + rpropSetWrite(_Rt_, EEINST_LIVE1); + rpropSetRead(_Rs_, 0); + pinst.info |= EEINST_MMX; + break; + + case 10: // slti + rpropSetWrite(_Rt_, EEINST_LIVE1); + rpropSetRead(_Rs_, EEINST_LIVE1); + pinst.info |= EEINST_MMX; + break; + case 11: // sltiu + rpropSetWrite(_Rt_, EEINST_LIVE1); + rpropSetRead(_Rs_, EEINST_LIVE1); + pinst.info |= EEINST_MMX; + break; + + case 12: // andi + rpropSetWrite(_Rt_, EEINST_LIVE1); + rpropSetRead(_Rs_, (_Rs_!=_Rt_?EEINST_MMX:0)); + pinst.info |= EEINST_MMX; + break; + case 13: // ori + rpropSetWrite(_Rt_, EEINST_LIVE1); + rpropSetRead(_Rs_, EEINST_LIVE1|(_Rs_!=_Rt_?EEINST_MMX:0)); + pinst.info |= EEINST_MMX; + break; + case 14: // xori + rpropSetWrite(_Rt_, EEINST_LIVE1); + rpropSetRead(_Rs_, EEINST_LIVE1|(_Rs_!=_Rt_?EEINST_MMX:0)); + pinst.info |= EEINST_MMX; + break; + + case 15: // lui + rpropSetWrite(_Rt_, EEINST_LIVE1); + break; + + case 16: rpropCP0(); break; + case 17: rpropCP1(); break; + case 18: rpropCP2(); break; + + // loads + case 34: // lwl + case 38: // lwr + case 26: // ldl + case 27: // ldr + rpropSetWrite(_Rt_, EEINST_LIVE1); + rpropSetRead(_Rt_, EEINST_LIVE1); + rpropSetRead(_Rs_, 0); + break; + + case 32: case 33: case 35: case 36: case 37: case 39: + case 55: // LD + rpropSetWrite(_Rt_, EEINST_LIVE1); + rpropSetRead(_Rs_, 0); + break; + + case 28: rpropMMI(); break; + + case 30: // lq + rpropSetWrite(_Rt_, EEINST_LIVE1|EEINST_LIVE2); + rpropSetRead(_Rs_, 0); + pinst.info |= EEINST_MMX; + pinst.info |= EEINST_REALXMM; + break; + + case 31: // sq + rpropSetRead(_Rt_, EEINST_LIVE1|EEINST_LIVE2|EEINST_REALXMM); + rpropSetRead(_Rs_, 0); + pinst.info |= EEINST_MMX; + pinst.info |= EEINST_REALXMM; + break; + + // 4 byte stores + case 40: case 41: case 42: case 43: case 46: + rpropSetRead(_Rt_, 0); + rpropSetRead(_Rs_, 0); + pinst.info |= EEINST_MMX; + pinst.info |= EEINST_REALXMM; + break; + + case 44: // sdl + case 45: // sdr + case 63: // sd + rpropSetRead(_Rt_, EEINST_LIVE1|EEINST_MMX|EEINST_REALXMM); + rpropSetRead(_Rs_, 0); + break; + + case 49: // lwc1 + rpropSetFPUWrite(_Rt_, EEINST_REALXMM); + rpropSetRead(_Rs_, 0); + break; + + case 57: // swc1 + rpropSetFPURead(_Rt_, EEINST_REALXMM); + rpropSetRead(_Rs_, 0); + break; + + case 54: // lqc2 + case 62: // sqc2 + rpropSetRead(_Rs_, 0); + break; + + default: + rpropSetWrite(_Rt_, EEINST_LIVE1); + rpropSetRead(_Rs_, EEINST_LIVE1|(_Rs_!=0?EEINST_MMX:0)); + break; + } +} + #endif // PCSX2_NORECBUILD diff --git a/pcsx2/x86/ix86-32/iCore-32.cpp b/pcsx2/x86/ix86-32/iCore-32.cpp index fae42b6bd0..76f54fffd6 100644 --- a/pcsx2/x86/ix86-32/iCore-32.cpp +++ b/pcsx2/x86/ix86-32/iCore-32.cpp @@ -20,12 +20,11 @@ #include #include -#include "PS2Etypes.h" - #if defined(_WIN32) #include #endif +#include "PS2Etypes.h" #include "System.h" #include "R5900.h" #include "Vif.h" diff --git a/pcsx2/x86/ix86-32/iR5900-32.c b/pcsx2/x86/ix86-32/iR5900-32.c index bebafa1ae6..6b5b0f0995 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.c +++ b/pcsx2/x86/ix86-32/iR5900-32.c @@ -87,7 +87,6 @@ static u32 s_nNextBlock = 0; // next free block in recBlocks extern void (*recBSC[64])(); extern void (*recBSC_co[64])(); -void rpropBSC(EEINST* prev, EEINST* pinst); // save states for branches static u16 s_savex86FpuState, s_saveiCWstate; @@ -3013,7 +3012,9 @@ StartRecomp: for(i = s_nEndBlock; i > startpc; i -= 4 ) { cpuRegs.code = *(int *)PSM(i-4); pcur[-1] = pcur[0]; - rpropBSC(pcur-1, pcur); + + BSCPropagate bsc( pcur[-1], pcur[0] ); + bsc.rprop(); pcur--; } } diff --git a/pcsx2/xmlpatchloader.cpp b/pcsx2/xmlpatchloader.cpp index cf78450006..45274ab152 100644 --- a/pcsx2/xmlpatchloader.cpp +++ b/pcsx2/xmlpatchloader.cpp @@ -24,13 +24,16 @@ using namespace std; #include "tinyxml/tinyxml.h" -#include "PS2Etypes.h" #include "Patch.h" #ifdef _MSC_VER #pragma warning(disable:4996) //ignore the stricmp deprecated warning #endif +#ifdef _WIN32 +#include +#endif + extern void SysPrintf(const char *fmt, ...); #if !defined(_WIN32) && !defined(__MINGW32__)