microVU: Use 16 xmm's in x64

This commit is contained in:
refractionpcsx2 2021-09-17 14:36:59 +01:00
parent 9c24e48e68
commit a546cb8f7f
4 changed files with 22 additions and 5 deletions

View File

@ -209,7 +209,11 @@ struct microVU
__aligned16 u32 macFlag [4]; // 4 instances of mac flag (used in execution)
__aligned16 u32 clipFlag[4]; // 4 instances of clip flag (used in execution)
__aligned16 u32 xmmCTemp[4]; // Backup used in mVUclamp2()
#ifdef __M_X86_64
__aligned16 u32 xmmBackup[16][4]; // Backup for xmm0~xmm15
#else
__aligned16 u32 xmmBackup[8][4]; // Backup for xmm0~xmm7
#endif
u32 index; // VU Index (VU0 or VU1)
u32 cop2; // VU is in COP2 mode? (No/Yes)

View File

@ -224,7 +224,11 @@ struct microMapXMM
class microRegAlloc
{
protected:
static const int xmmTotal = 7; // Don't allocate PQ?
#ifdef __M_X86_64
static const int xmmTotal = 15; // PQ register is reserved
#else
static const int xmmTotal = 7; // PQ register is reserved
#endif
microMapXMM xmmMap[xmmTotal];
int counter; // Current allocation count
int index; // VU0 or VU1
@ -287,6 +291,10 @@ public:
counter = 0;
}
int getXmmCount()
{
return xmmTotal + 1;
}
// Flushes all allocated registers (i.e. writes-back to memory all modified registers).
// If clearState is 0, then it keeps cached reg data valid
// If clearState is 1, then it invalidates all cached reg data after write-back

View File

@ -141,7 +141,12 @@ static const char branchSTR[16][8] = {
#define xmmT5 xmm4 // Used for regAlloc
#define xmmT6 xmm5 // Used for regAlloc
#define xmmT7 xmm6 // Used for regAlloc
#ifdef __M_X86_64
#define xmmPQ xmm15 // Holds the Value and Backup Values of P and Q regs
#else
#define xmmPQ xmm7 // Holds the Value and Backup Values of P and Q regs
#endif
#define gprT1 eax // eax - Temp Reg
#define gprT2 ecx // ecx - Temp Reg

View File

@ -149,7 +149,7 @@ __fi void mVUbackupRegs(microVU& mVU, bool toMemory = false, bool onlyNeeded = f
{
if (toMemory)
{
for (int i = 0; i < 8; i++)
for (int i = 0; i < mVU.regAlloc->getXmmCount(); i++)
{
if (!onlyNeeded || mVU.regAlloc->checkCachedReg(i) || xmmPQ.Id == i)
xMOVAPS(ptr128[&mVU.xmmBackup[i][0]], xmm(i));
@ -167,7 +167,7 @@ __fi void mVUrestoreRegs(microVU& mVU, bool fromMemory = false, bool onlyNeeded
{
if (fromMemory)
{
for (int i = 0; i < 8; i++)
for (int i = 0; i < mVU.regAlloc->getXmmCount(); i++)
{
if (!onlyNeeded || mVU.regAlloc->checkCachedReg(i) || xmmPQ.Id == i)
xMOVAPS(xmm(i), ptr128[&mVU.xmmBackup[i][0]]);
@ -197,13 +197,13 @@ public:
_mVUt void __fc mVUprintRegs()
{
microVU& mVU = mVUx;
for (int i = 0; i < 8; i++)
for (int i = 0; i < mVU.regAlloc->getXmmCount(); i++)
{
Console.WriteLn("xmm%d = [0x%08x,0x%08x,0x%08x,0x%08x]", i,
mVU.xmmBackup[i][0], mVU.xmmBackup[i][1],
mVU.xmmBackup[i][2], mVU.xmmBackup[i][3]);
}
for (int i = 0; i < 8; i++)
for (int i = 0; i < mVU.regAlloc->getXmmCount(); i++)
{
Console.WriteLn("xmm%d = [%f,%f,%f,%f]", i,
(float&)mVU.xmmBackup[i][0], (float&)mVU.xmmBackup[i][1],