microVU rec stuff

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@637 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
cottonvibes 2009-03-01 03:36:52 +00:00
parent da25976c6b
commit e87d55f153
11 changed files with 349 additions and 26 deletions

View File

@ -16,9 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __VU_H__
#define __VU_H__
#pragma once
#include "Vif.h"
#define REG_STATUS_FLAG 16
@ -205,5 +203,3 @@ static __forceinline u32* GET_VU_MEM(VURegs* VU, u32 addr)
#define VUFIX_EXTRAFLAGS 2
#define VUFIX_XGKICKDELAY2 4
extern int g_VUGameFixes;
#endif /* __VU_H__ */

View File

@ -2421,10 +2421,30 @@
RelativePath="..\..\x86\microVU.h"
>
</File>
<File
RelativePath="..\..\x86\microVU_Alloc.cpp"
>
</File>
<File
RelativePath="..\..\x86\microVU_Alloc.h"
>
</File>
<File
RelativePath="..\..\x86\microVU_Compile.cpp"
>
</File>
<File
RelativePath="..\..\x86\microVU_Lower.cpp"
>
</File>
<File
RelativePath="..\..\x86\microVU_Misc.cpp"
>
</File>
<File
RelativePath="..\..\x86\microVU_Misc.h"
>
</File>
<File
RelativePath="..\..\x86\microVU_Tables.cpp"
>

View File

@ -65,7 +65,7 @@ microVUt(void) mVUreset() {
if ( mVU->cache == NULL ) throw Exception::OutOfMemory(fmt_string( "microVU Error: failed to allocate recompiler memory! (addr: 0x%x)", params (u32)mVU->cache));
// Other Variables
ZeroMemory(&mVU->prog, sizeof(mVU->prog));
memset(&mVU->prog, 0, sizeof(mVU->prog));
mVU->prog.finished = 1;
mVU->prog.cleared = 1;
mVU->prog.cur = -1;
@ -221,7 +221,7 @@ __declspec(naked) void __fastcall startVU0(u32 startPC, u32 cycles) {
push edi;
ldmxcsr g_sseVUMXCSR
/* Should set xmmZ? */
jmp eax
}
}

View File

@ -19,6 +19,8 @@
#pragma once
#include "Common.h"
#include "VU.h"
#include "microVU_Misc.h"
#include "microVU_Alloc.h"
#include "microVU_Tables.h"
//#include <vector>
@ -82,8 +84,8 @@ template<u32 progSize>
struct microProgram {
u8 data[progSize];
u32 used; // Number of times its been used
//int cached; // Has been Cached? (can be omitted because every new program will be cached?)
microBlockManager* block[progSize];
microAllocInfo<progSize> allocInfo;
};
#define mMaxProg 16 // The amount of Micro Programs Recs will 'remember' (For n = 1, 2, 4, 8, 16, etc...)
@ -121,22 +123,10 @@ struct microVU {
microProgManager<0x800> prog; // Micro Program Data
};
// Template Stuff
#define mVUx (vuIndex ? &microVU1 : &microVU0)
#define microVUt(aType) template<int vuIndex> __forceinline aType
// Opcode Tables
extern void (*mVU_UPPER_OPCODE[64])( VURegs* VU, s32 info );
extern void (*mVU_LOWER_OPCODE[128])( VURegs* VU, s32 info );
//void invalidateBlocks(u32 addr, u32 size); // Invalidates Blocks in the range [addr, addr+size)
//__forceinline void mVUinit(microVU* mVU, VURegs* vuRegsPtr, const int vuIndex);
//__forceinline void mVUreset(microVU* mVU);
//__forceinline void mVUclose(microVU* mVU);
//__forceinline void mVUclear(microVU* mVU, u32 addr, u32 size); // Clears part of a Micro Program (must use before modifying micro program!)
//void* mVUexecute(microVU* mVU, u32 startPC, u32 cycles); // Recompiles/Executes code for the number of cycles indicated (will always run for >= 'cycles' amount unless 'finished')
//void* mVUexecuteF(microVU* mVU, u32 startPC); // Recompiles/Executes code till finished
__forceinline void mVUclearProg(microVU* mVU, int progIndex);
__forceinline int mVUfindLeastUsedProg(microVU* mVU);
__forceinline int mVUsearchProg(microVU* mVU);

View File

@ -0,0 +1,61 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2009 Pcsx2-Playground Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "PrecompiledHeader.h"
#include "microVU.h"
#ifdef PCSX2_MICROVU
extern PCSX2_ALIGNED16(microVU microVU0);
extern PCSX2_ALIGNED16(microVU microVU1);
//------------------------------------------------------------------
// Micro VU - recPass 0 Functions
//------------------------------------------------------------------
//------------------------------------------------------------------
// Micro VU - recPass 1 Functions
//------------------------------------------------------------------
/*
#define setFd (mVU->prog.prog[mVU->prog.cur].allocInfo.info[pc] & (1<<7))
#define getFd (mVU->prog.prog[mVU->prog.cur].allocInfo.info[pc] & (1<<1))
#define getFs (mVU->prog.prog[mVU->prog.cur].allocInfo.info[pc] & (1<<2))
#define getFt (mVU->prog.prog[mVU->prog.cur].allocInfo.info[pc] & (1<<3))
*/
#define makeFdFd (makeFd == 0)
#define makeFdFs (makeFd == 1)
#define makeFdFt (makeFd == 2)
microVUt(void) mVUallocFMAC1a(u32 code, int& Fd, int& Fs, int& Ft, const int makeFd) {
microVU* mVU = mVUx;
if (_Fs_ == 0) { Fs = xmmZ; } else { Fs = xmmFs; }
if (_Ft_ == 0) { Ft = xmmZ; } else { Ft = xmmFt; }
if (makeFdFd) {Fd = xmmFd}
else if (makeFdFs) {Fd = Fs}
else if (makeFdFt) {Fd = Ft}
if (_Fs_) SSE_MOVAPS_M128_to_XMM(Fs, (uptr)&mVU->regs->VF[_Fs_].UL[0]);
if (_Ft_ == _Ft_) SSE_MOVAPS_M128_to_XMM(Ft, (uptr)&mVU->regs->VF[_Ft_].UL[0]);
}
microVUt(void) mVUallocFMAC1b(u32 code, u32 pc, int& Fd) {
microVU* mVU = mVUx;
if (_Fd_ == 0) return;
else mVUsaveReg<vuIndex>(code, Fd, (uptr)&mVU->regs->VF[_Fd_].UL[0]);
}
#endif //PCSX2_MICROVU

49
pcsx2/x86/microVU_Alloc.h Normal file
View File

@ -0,0 +1,49 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2009 Pcsx2-Playground Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#pragma once
union regInfo {
u32 reg;
struct {
u8 x;
u8 y;
u8 z;
u8 w;
};
};
template<u32 pSize>
struct microAllocInfo {
regInfo VF[32];
regInfo Acc;
u8 VI[32];
u8 i;
u8 q;
u8 p;
u8 r;
u16 info[pSize];// bit 0 = NOP?
// bit 1 = Read Fd from backup memory?
// bit 2 = Read Fs from backup memory?
// bit 3 = Read Ft from backup memory?
// bit 4 = ACC1 or ACC2?
// bit 5 = Read Q1/P1 or backup?
// bit 6 = Write to Q2/P2?
// bit 7 = Write Fd/Acc to backup memory?
u32 curPC;
};

View File

@ -0,0 +1,26 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2009 Pcsx2-Playground Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "PrecompiledHeader.h"
#include "microVU.h"
#ifdef PCSX2_MICROVU
extern PCSX2_ALIGNED16(microVU microVU0);
extern PCSX2_ALIGNED16(microVU microVU1);
#endif //PCSX2_MICROVU

105
pcsx2/x86/microVU_Misc.cpp Normal file
View File

@ -0,0 +1,105 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2009 Pcsx2-Playground Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "PrecompiledHeader.h"
#include "microVU.h"
#ifdef PCSX2_MICROVU
extern PCSX2_ALIGNED16(microVU microVU0);
extern PCSX2_ALIGNED16(microVU microVU1);
//------------------------------------------------------------------
// Micro VU - Misc Functions
//------------------------------------------------------------------
microVUx(void) mVUsaveReg(u32 code, int reg, u32 offset) {
switch ( _X_Y_Z_W ) {
case 1: // W
//SSE2_PSHUFD_XMM_to_XMM(xmmT1, reg, 0x27);
//SSE_MOVSS_XMM_to_M32(offset+12, xmmT1);
SSE_MOVSS_XMM_to_M32(offset+12, reg);
break;
case 2: // Z
//SSE_MOVHLPS_XMM_to_XMM(xmmT1, reg);
//SSE_MOVSS_XMM_to_M32(offset+8, xmmT1);
SSE_MOVSS_XMM_to_M32(offset+8, reg);
break;
case 3: // ZW
SSE_MOVHPS_XMM_to_M64(offset+8, reg);
break;
case 4: // Y
//SSE2_PSHUFLW_XMM_to_XMM(xmmT1, reg, 0x4e);
//SSE_MOVSS_XMM_to_M32(offset+4, xmmT1);
SSE_MOVSS_XMM_to_M32(offset+4, reg);
break;
case 5: // YW
SSE_SHUFPS_XMM_to_XMM(reg, reg, 0xB1);
SSE_MOVHLPS_XMM_to_XMM(xmmT1, reg);
SSE_MOVSS_XMM_to_M32(offset+4, reg);
SSE_MOVSS_XMM_to_M32(offset+12, xmmT1);
SSE_SHUFPS_XMM_to_XMM(reg, reg, 0xB1);
break;
case 6: // YZ
SSE2_PSHUFD_XMM_to_XMM(xmmT1, reg, 0xc9);
SSE_MOVLPS_XMM_to_M64(offset+4, xmmT1);
break;
case 7: // YZW
SSE2_PSHUFD_XMM_to_XMM(xmmT1, reg, 0x93); //ZYXW
SSE_MOVHPS_XMM_to_M64(offset+4, xmmT1);
SSE_MOVSS_XMM_to_M32(offset+12, xmmT1);
break;
case 8: // X
SSE_MOVSS_XMM_to_M32(offset, reg);
break;
case 9: // XW
SSE_MOVHLPS_XMM_to_XMM(xmmT1, reg);
SSE_MOVSS_XMM_to_M32(offset, reg);
if ( cpucaps.hasStreamingSIMD3Extensions ) SSE3_MOVSLDUP_XMM_to_XMM(xmmT1, xmmT1);
else SSE_SHUFPS_XMM_to_XMM(xmmT1, xmmT1, 0x55);
SSE_MOVSS_XMM_to_M32(offset+12, xmmT1);
break;
case 10: //XZ
SSE_MOVHLPS_XMM_to_XMM(xmmT1, reg);
SSE_MOVSS_XMM_to_M32(offset, reg);
SSE_MOVSS_XMM_to_M32(offset+8, xmmT1);
break;
case 11: //XZW
SSE_MOVSS_XMM_to_M32(offset, reg);
SSE_MOVHPS_XMM_to_M64(offset+8, reg);
break;
case 12: // XY
SSE_MOVLPS_XMM_to_M64(offset, reg);
break;
case 13: // XYW
SSE2_PSHUFD_XMM_to_XMM(xmmT1, reg, 0x4b); //YXZW
SSE_MOVHPS_XMM_to_M64(offset, xmmT1);
SSE_MOVSS_XMM_to_M32(offset+12, xmmT1);
break;
case 14: // XYZ
SSE_MOVHLPS_XMM_to_XMM(xmmT1, reg);
SSE_MOVLPS_XMM_to_M64(offset, reg);
SSE_MOVSS_XMM_to_M32(offset+8, xmmT1);
break;
case 15: // XYZW
if( offset & 15 ) SSE_MOVUPS_XMM_to_M128(offset, reg);
else SSE_MOVAPS_XMM_to_M128(offset, reg);
break;
}
}
#endif //PCSX2_MICROVU

75
pcsx2/x86/microVU_Misc.h Normal file
View File

@ -0,0 +1,75 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2009 Pcsx2-Playground Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#pragma once
//------------------------------------------------------------------
// Helper Macros
//------------------------------------------------------------------
#define _Ft_ ((code >> 16) & 0x1F) // The rt part of the instruction register
#define _Fs_ ((code >> 11) & 0x1F) // The rd part of the instruction register
#define _Fd_ ((code >> 6) & 0x1F) // The sa part of the instruction register
#define _X ((code>>24) & 0x1)
#define _Y ((code>>23) & 0x1)
#define _Z ((code>>22) & 0x1)
#define _W ((code>>21) & 0x1)
#define _XYZW_SS (_X+_Y+_Z+_W==1)
#define _X_Y_Z_W (((code >> 21 ) & 0xF ) )
#define _Fsf_ ((code >> 21) & 0x03)
#define _Ftf_ ((code >> 23) & 0x03)
#define _Imm11_ (s32)(code & 0x400 ? 0xfffffc00 | (code & 0x3ff) : code & 0x3ff)
#define _UImm11_ (s32)(code & 0x7ff)
/*
#define VU_VFx_ADDR(x) (uptr)&VU->VF[x].UL[0]
#define VU_VFy_ADDR(x) (uptr)&VU->VF[x].UL[1]
#define VU_VFz_ADDR(x) (uptr)&VU->VF[x].UL[2]
#define VU_VFw_ADDR(x) (uptr)&VU->VF[x].UL[3]
#define VU_REGR_ADDR (uptr)&VU->VI[REG_R]
#define VU_REGQ_ADDR (uptr)&VU->VI[REG_Q]
#define VU_REGMAC_ADDR (uptr)&VU->VI[REG_MAC_FLAG]
#define VU_VI_ADDR(x, read) GetVIAddr(VU, x, read, info)
#define VU_ACCx_ADDR (uptr)&VU->ACC.UL[0]
#define VU_ACCy_ADDR (uptr)&VU->ACC.UL[1]
#define VU_ACCz_ADDR (uptr)&VU->ACC.UL[2]
#define VU_ACCw_ADDR (uptr)&VU->ACC.UL[3]
*/
#define xmmT1 0 // XMM0
#define xmmFd 1 // XMM1
#define xmmFs 2 // XMM2
#define xmmFt 3 // XMM3
#define xmmACC1 4 // XMM4
#define xmmACC2 5 // XMM5
#define xmmPQ 6 // XMM6
#define xmmZ 7 // XMM7
// Template Stuff
#define mVUx (vuIndex ? &microVU1 : &microVU0)
#define microVUt(aType) template<int vuIndex> __forceinline aType
#define microVUx(aType) template<int vuIndex> aType
#define microVUf(aType) template<int vuIndex, int recPass> aType
microVUx(void) mVUsaveReg(u32 code, int reg, u32 offset);

View File

@ -18,8 +18,6 @@
#pragma once
#define microVUf(aType) template<int vuIndex, int recPass> aType
//------------------------------------------------------------------
// Micro VU Micromode Upper instructions
//------------------------------------------------------------------

View File

@ -40,9 +40,9 @@ xmmT1 = xmm0
xmmFd = xmm1
xmmFs = xmm2
xmmFt = xmm3
xmmAcc = xmm4
xmmT2 = xmm5
xmmT3 = xmm6
xmmACC1 = xmm4
xmmACC2 = xmm5
xmmPQ = xmm6
xmmZ = xmm7
Most of the time the above mapping will be true, unless I find a reason not to do it this way :)
@ -77,7 +77,10 @@ have an idea of how things work. Right now its all theoretical and I'll change t
//------------------------------------------------------------------
microVUf(void) mVU_ABS(){}
microVUf(void) mVU_ADD(){}
microVUf(void) mVU_ADD(){
if (recPass == 0) {}
else {}
}
microVUf(void) mVU_ADDi(){}
microVUf(void) mVU_ADDq(){}
microVUf(void) mVU_ADDx(){}