diff --git a/pcsx2/x86/iCore.cpp b/pcsx2/x86/iCore.cpp index 15a1ea158a..90fab0d675 100644 --- a/pcsx2/x86/iCore.cpp +++ b/pcsx2/x86/iCore.cpp @@ -108,17 +108,28 @@ void _initXMMregs() { __forceinline void* _XMMGetAddr(int type, int reg, VURegs *VU) { - if (type == XMMTYPE_VFREG ) return (void*)VU_VFx_ADDR(reg); - else if (type == XMMTYPE_ACC ) return (void*)VU_ACCx_ADDR; - else if (type == XMMTYPE_GPRREG) { - if( reg < 32 ) - assert( !(g_cpuHasConstReg & (1<= 0 ) { // requested specific reg, so return that instead if( i != xmmreg ) { @@ -231,12 +244,10 @@ int _allocVFtoXMMreg(VURegs *VU, int xmmreg, int vfreg, int mode) { return i; } - if (xmmreg == -1) { + if (xmmreg == -1) xmmreg = _getFreeXMMreg(); - } - else { + else _freeXMMreg(xmmreg); - } g_xmmtypes[xmmreg] = XMMT_FPS; xmmregs[xmmreg].inuse = 1; @@ -259,7 +270,7 @@ int _checkXMMreg(int type, int reg, int mode) int i; for (i=0; i= 0 ) SSE_MOVAPS_XMM_to_XMM(xmmreg, readfromreg); - else SSE_MOVAPS_M128_to_XMM(xmmreg, VU_ACCx_ADDR); + if (mode & MODE_READ) + { + if( readfromreg >= 0 ) + SSE_MOVAPS_XMM_to_XMM(xmmreg, readfromreg); + else + SSE_MOVAPS_M128_to_XMM(xmmreg, VU_ACCx_ADDR); } return xmmreg; @@ -359,9 +371,7 @@ int _allocFPtoXMMreg(int xmmreg, int fpreg, int mode) { return i; } - if (xmmreg == -1) { - xmmreg = _getFreeXMMreg(); - } + if (xmmreg == -1) xmmreg = _getFreeXMMreg(); g_xmmtypes[xmmreg] = XMMT_FPS; xmmregs[xmmreg].inuse = 1; @@ -371,9 +381,8 @@ int _allocFPtoXMMreg(int xmmreg, int fpreg, int mode) { xmmregs[xmmreg].needed = 1; xmmregs[xmmreg].counter = g_xmmAllocCounter++; - if (mode & MODE_READ) { + if (mode & MODE_READ) SSE_MOVSS_M32_to_XMM(xmmreg, (uptr)&fpuRegs.fpr[fpreg].f); - } return xmmreg; } @@ -382,7 +391,8 @@ int _allocGPRtoXMMreg(int xmmreg, int gprreg, int mode) { int i; - for (i=0; i= 0 ) { - // transfer - + mmxreg = _checkMMXreg(MMX_GPR+gprreg, 0); + + if (mmxreg >= 0 ) + { + // transfer SetMMXstate(); SSE2_MOVQ2DQ_MM_to_XMM(xmmreg, mmxreg); SSE2_PUNPCKLQDQ_XMM_to_XMM(xmmreg, xmmreg); SSE2_PUNPCKHQDQ_M128_to_XMM(xmmreg, (u32)&cpuRegs.GPR.r[gprreg].UL[0]); - if( mmxregs[mmxreg].mode & MODE_WRITE ) { - + if (mmxregs[mmxreg].mode & MODE_WRITE ) + { // instead of setting to write, just flush to mem - if( !(mode & MODE_WRITE) ) { + if (!(mode & MODE_WRITE)) + { SetMMXstate(); MOVQRtoM((u32)&cpuRegs.GPR.r[gprreg].UL[0], mmxreg); } @@ -465,27 +486,30 @@ int _allocGPRtoXMMreg(int xmmreg, int gprreg, int mode) mmxregs[mmxreg].inuse = 0; } #else - if( (mmxreg = _checkX86reg(X86TYPE_GPR, gprreg, 0)) >= 0 ) { - SSE2_MOVQ_R_to_XMM(xmmreg, mmxreg); - SSE_MOVHPS_M64_to_XMM(xmmreg, (uptr)&cpuRegs.GPR.r[gprreg].UL[0]); + mmxreg = _checkX86reg(X86TYPE_GPR, gprreg, 0); + + if (mmxreg >= 0 ) + { + SSE2_MOVQ_R_to_XMM(xmmreg, mmxreg); + SSE_MOVHPS_M64_to_XMM(xmmreg, (uptr)&cpuRegs.GPR.r[gprreg].UL[0]); - // read only, instead of setting to write, just flush to mem - if( !(mode&MODE_WRITE) && (x86regs[mmxreg].mode & MODE_WRITE) ) { - MOV64RtoM((uptr)&cpuRegs.GPR.r[gprreg].UL[0], mmxreg); - } + // read only, instead of setting to write, just flush to mem + if (!(mode & MODE_WRITE) && (x86regs[mmxreg].mode & MODE_WRITE) ) + MOV64RtoM((uptr)&cpuRegs.GPR.r[gprreg].UL[0], mmxreg); - x86regs[mmxreg].inuse = 0; - } + x86regs[mmxreg].inuse = 0; + } #endif else - { + { SSEX_MOVDQA_M128_to_XMM(xmmreg, (uptr)&cpuRegs.GPR.r[gprreg].UL[0]); } } } - else { + else + { #ifndef __x86_64__ - _deleteMMXreg(MMX_GPR+gprreg, 0); + _deleteMMXreg(MMX_GPR+gprreg, 0); #else _deleteX86reg(X86TYPE_GPR, gprreg, 0); #endif @@ -625,34 +649,42 @@ void _deleteVFtoXMMreg(int reg, int vu, int flush) int i; VURegs *VU = vu ? &VU1 : &VU0; - for (i=0; i 0) { for(i = 0; i < ARRAYSIZE(pinst->writeType); ++i) { - if( pinst->writeType[i] == xmmtype && pinst->writeReg[i] == reg ) + if ((pinst->writeType[i] == xmmtype) && (pinst->writeReg[i] == reg)) return inst; } ++inst; @@ -1199,9 +1257,9 @@ int _recIsRegWritten(EEINST* pinst, int size, u8 xmmtype, u8 reg) return 0; } -int _recIsRegUsed(EEINST* pinst, int size, u8 xmmtype, u8 reg) +u32 _recIsRegUsed(EEINST* pinst, int size, u8 xmmtype, u8 reg) { - int i, inst = 1; + u32 i, inst = 1; while(size-- > 0) { for(i = 0; i < ARRAYSIZE(pinst->writeType); ++i) { if( pinst->writeType[i] == xmmtype && pinst->writeReg[i] == reg ) @@ -1220,8 +1278,8 @@ int _recIsRegUsed(EEINST* pinst, int size, u8 xmmtype, u8 reg) void _recFillRegister(EEINST* pinst, int type, int reg, int write) { - int i = 0; - if( write ) { + u32 i = 0; + if (write ) { for(i = 0; i < ARRAYSIZE(pinst->writeType); ++i) { if( pinst->writeType[i] == XMMTYPE_TEMP ) { pinst->writeType[i] = type; diff --git a/pcsx2/x86/iCore.h b/pcsx2/x86/iCore.h index 15e272dfaf..aecaa7b20c 100644 --- a/pcsx2/x86/iCore.h +++ b/pcsx2/x86/iCore.h @@ -323,9 +323,9 @@ extern EEINST* g_pCurInstInfo; // info for the cur instruction void _recClearInst(EEINST* pinst); // returns the number of insts + 1 until written (0 if not written) -int _recIsRegWritten(EEINST* pinst, int size, u8 xmmtype, u8 reg); +u32 _recIsRegWritten(EEINST* pinst, int size, u8 xmmtype, u8 reg); // returns the number of insts + 1 until used (0 if not used) -int _recIsRegUsed(EEINST* pinst, int size, u8 xmmtype, u8 reg); +u32 _recIsRegUsed(EEINST* pinst, int size, u8 xmmtype, u8 reg); void _recFillRegister(EEINST* pinst, int type, int reg, int write); #define EEINST_ISLIVE64(reg) (g_pCurInstInfo->regs[reg] & (EEINST_LIVE0|EEINST_LIVE1))