Created the macro "memcpy_const" for memcpy's with constant sizes, and set pcsx2 to use it where applicable... currently just uses memcpy_amd internally...

Also some minor mVU compiler optimizations.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2515 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
cottonvibes 2010-01-24 22:04:49 +00:00
parent ddfb8de7f1
commit 2698b3da1b
9 changed files with 30 additions and 25 deletions

View File

@ -36,5 +36,7 @@
// Only used in the Windows version of memzero.h. But it's in Misc.cpp for some reason.
void _memset16_unaligned( void* dest, u16 data, size_t size );
#define memcpy_fast memcpy_amd_
#define memcpy_aligned memcpy_amd_
#define memcpy_fast memcpy_amd_ // Fast memcpy
#define memcpy_aligned memcpy_amd_ // Memcpy with 16-byte Aligned addresses
#define memcpy_const memcpy_amd_ // Memcpy with constant size
#define memcpy_constA memcpy_amd_ // Memcpy with constant size and 16-byte aligned

View File

@ -642,7 +642,7 @@ int cdvdReadSector() {
mdest[11] = 0;
// normal 2048 bytes of sector data
memcpy_fast( &mdest[12], cdr.Transfer, 2048);
memcpy_const(&mdest[12], cdr.Transfer, 2048);
// 4 bytes of edc (not calculated at present)
mdest[2060] = 0;

View File

@ -130,17 +130,17 @@ namespace VU1micro
XMMRegisters::Freeze();
runCount++;
memcpy_fast((u8*)backVUregs, (u8*)&VU1, sizeof(VURegs));
memcpy_fast((u8*)backVUmem, (u8*)VU1.Mem, 0x4000);
memcpy_const((u8*)backVUregs, (u8*)&VU1, sizeof(VURegs));
memcpy_const((u8*)backVUmem, (u8*)VU1.Mem, 0x4000);
do { // while loop needed since not always will return finished
SuperVUExecuteProgram(VU1.VI[ REG_TPC ].UL & 0x3fff, 1);
} while( VU0.VI[ REG_VPU_STAT ].UL&0x100 );
memcpy_fast((u8*)cmpVUregs, (u8*)&VU1, sizeof(VURegs));
memcpy_fast((u8*)cmpVUmem, (u8*)VU1.Mem, 0x4000);
memcpy_fast((u8*)&VU1, (u8*)backVUregs, sizeof(VURegs));
memcpy_fast((u8*)VU1.Mem, (u8*)backVUmem, 0x4000);
memcpy_const((u8*)cmpVUregs, (u8*)&VU1, sizeof(VURegs));
memcpy_const((u8*)cmpVUmem, (u8*)VU1.Mem, 0x4000);
memcpy_const((u8*)&VU1, (u8*)backVUregs, sizeof(VURegs));
memcpy_const((u8*)VU1.Mem, (u8*)backVUmem, 0x4000);
//Currently breaking mVU execution is disabled. Check mVUtestCycles<vuIndex>() in microVU_Compile.inl
runVUrec(VU1.VI[REG_TPC].UL, 300000 /*0x7fffffff*/, 1);
@ -231,8 +231,8 @@ namespace VU1micro
if (mVUdebugNow) {
resetVUrec(1);
memcpy_fast((u8*)&VU1, (u8*)backVUregs, sizeof(VURegs));
memcpy_fast((u8*)VU1.Mem, (u8*)backVUmem, 0x4000);
memcpy_const((u8*)&VU1, (u8*)backVUregs, sizeof(VURegs));
memcpy_const((u8*)VU1.Mem, (u8*)backVUmem, 0x4000);
runVUrec(VU1.VI[REG_TPC].UL, 300000 /*0x7fffffff*/, 1);

View File

@ -965,8 +965,8 @@ void SaveBranchState()
s_saveRegHasSignExt = g_cpuRegHasSignExt;
// save all mmx regs
memcpy_fast(s_saveMMXregs, mmxregs, sizeof(mmxregs));
memcpy_fast(s_saveXMMregs, xmmregs, sizeof(xmmregs));
memcpy_const(s_saveMMXregs, mmxregs, sizeof(mmxregs));
memcpy_const(s_saveXMMregs, xmmregs, sizeof(xmmregs));
}
void LoadBranchState()
@ -982,8 +982,8 @@ void LoadBranchState()
g_cpuRegHasSignExt = g_cpuPrevRegHasSignExt = s_saveRegHasSignExt;
// restore all mmx regs
memcpy_fast(mmxregs, s_saveMMXregs, sizeof(mmxregs));
memcpy_fast(xmmregs, s_saveXMMregs, sizeof(xmmregs));
memcpy_const(mmxregs, s_saveMMXregs, sizeof(mmxregs));
memcpy_const(xmmregs, s_saveXMMregs, sizeof(xmmregs));
}
void iFlushCall(int flushtype)

View File

@ -201,7 +201,8 @@ microVUf(void) mVUclearProg(int progIndex) {
// Caches Micro Program
microVUf(void) mVUcacheProg(int progIndex) {
microVU* mVU = mVUx;
memcpy_fast(mVU->prog.prog[progIndex].data, mVU->regs->Micro, mVU->microMemSize);
if (!vuIndex) memcpy_const(mVU->prog.prog[progIndex].data, mVU->regs->Micro, 0x1000);
else memcpy_const(mVU->prog.prog[progIndex].data, mVU->regs->Micro, 0x4000);
mVUdumpProg(progIndex);
}

View File

@ -62,7 +62,7 @@ public:
listI++;
blockEnd->block = (microBlock*)_aligned_malloc(sizeof(microBlock), 16);
blockEnd->next = new microBlockLink;
memcpy_fast(blockEnd->block, pBlock, sizeof(microBlock));
memcpy_const(blockEnd->block, pBlock, sizeof(microBlock));
thisBlock = blockEnd->block;
blockEnd = blockEnd->next;
}

View File

@ -98,7 +98,7 @@ void normBranchCompile(microVU* mVU, u32 branchPC) {
}
void normJumpCompile(mV, microFlagCycles& mFC, bool isEvilJump) {
memcpy_fast(&mVUpBlock->pStateEnd, &mVUregs, sizeof(microRegInfo));
memcpy_const(&mVUpBlock->pStateEnd, &mVUregs, sizeof(microRegInfo));
mVUsetupBranch(mVU, mFC);
mVUbackupRegs(mVU);
@ -155,7 +155,7 @@ void condBranch(mV, microFlagCycles& mFC, int JMPcc) {
s32* ajmp = xJcc32((JccComparisonType)JMPcc);
u32 bPC = iPC; // mVUcompile can modify iPC, mVUpBlock, and mVUregs so back them up
microBlock* pBlock = mVUpBlock;
memcpy_fast(&pBlock->pStateEnd, &mVUregs, sizeof(microRegInfo));
memcpy_const(&pBlock->pStateEnd, &mVUregs, sizeof(microRegInfo));
incPC2(1); // Get PC for branch not-taken
mVUcompile(mVU, xPC, (uptr)&mVUregs);

View File

@ -110,8 +110,8 @@ microVUt(void) startLoop(mV) {
if (curI & _Mbit_) { Console.WriteLn(Color_Green, "microVU%d: M-bit set!", getIndex); }
if (curI & _Dbit_) { DevCon.WriteLn (Color_Green, "microVU%d: D-bit set!", getIndex); }
if (curI & _Tbit_) { DevCon.WriteLn (Color_Green, "microVU%d: T-bit set!", getIndex); }
memset(&mVUinfo, 0, sizeof(mVUinfo));
memset(&mVUregsTemp, 0, sizeof(mVUregsTemp));
memzero(mVUinfo);
memzero(mVUregsTemp);
}
microVUt(void) doIbit(mV) {
@ -316,7 +316,9 @@ microVUt(void) mVUinitFirstPass(microVU* mVU, uptr pState, u8* thisPtr) {
mVUcycles = 0; // Skips "M" phase, and starts counting cycles at "T" stage
mVU->p = 0; // All blocks start at p index #0
mVU->q = 0; // All blocks start at q index #0
memcpy_fast(&mVUregs, (microRegInfo*)pState, sizeof(microRegInfo)); // Loads up Pipeline State Info
if ((uptr)&mVUregs != pState) { // Loads up Pipeline State Info
memcpy_const(&mVUregs, (microRegInfo*)pState, sizeof(microRegInfo));
}
mVUblock.x86ptrStart = thisPtr;
mVUpBlock = mVUblocks[mVUstartPC/2]->add(&mVUblock); // Add this block to block manager
mVUregs.blockType = 0;

View File

@ -87,7 +87,7 @@ public:
wxEmptyString
);
}
memcpy_fast(&bucket.Chain[bucket.Size++], &dataPtr, sizeof(T));
memcpy_const(&bucket.Chain[bucket.Size++], &dataPtr, sizeof(T));
}
void clear() {
for (int i = 0; i < hSize; i++) {