diff --git a/Core/MIPS/x86/RegCacheFPU.cpp b/Core/MIPS/x86/RegCacheFPU.cpp index b8767479d7..35f0d8d6f5 100644 --- a/Core/MIPS/x86/RegCacheFPU.cpp +++ b/Core/MIPS/x86/RegCacheFPU.cpp @@ -23,7 +23,7 @@ u32 FPURegCache::tempValues[NUM_TEMPS]; -FPURegCache::FPURegCache() : mips(0), emit(0) { +FPURegCache::FPURegCache() : mips(0), initialReady(false), emit(0) { memset(regs, 0, sizeof(regs)); memset(xregs, 0, sizeof(xregs)); vregs = regs + 32; @@ -31,21 +31,31 @@ FPURegCache::FPURegCache() : mips(0), emit(0) { void FPURegCache::Start(MIPSState *mips, MIPSAnalyst::AnalysisResults &stats) { this->mips = mips; + + if (!initialReady) + SetupInitialRegs(); + + memcpy(xregs, xregsInitial, sizeof(xregs)); + memcpy(regs, regsInitial, sizeof(regs)); +} + +void FPURegCache::SetupInitialRegs() { for (int i = 0; i < NUM_X_FPREGS; i++) { - xregs[i].mipsReg = -1; - xregs[i].dirty = false; + xregsInitial[i].mipsReg = -1; + xregsInitial[i].dirty = false; } - memset(regs, 0, sizeof(regs)); + memset(regsInitial, 0, sizeof(regsInitial)); OpArg base = GetDefaultLocation(0); for (int i = 0; i < 32; i++) { - regs[i].location = base; + regsInitial[i].location = base; base.IncreaseOffset(sizeof(float)); } base = GetDefaultLocation(32); for (int i = 32; i < NUM_MIPS_FPRS; i++) { - regs[i].location = base; + regsInitial[i].location = base; base.IncreaseOffset(sizeof(float)); } + initialReady = true; } void FPURegCache::SpillLock(int p1, int p2, int p3, int p4) { diff --git a/Core/MIPS/x86/RegCacheFPU.h b/Core/MIPS/x86/RegCacheFPU.h index 5f7340f25d..90ebdaa0d9 100644 --- a/Core/MIPS/x86/RegCacheFPU.h +++ b/Core/MIPS/x86/RegCacheFPU.h @@ -155,11 +155,16 @@ public: X64Reg GetFreeXReg(); private: const int *GetAllocationOrder(int &count); + void SetupInitialRegs(); MIPSCachedFPReg regs[NUM_MIPS_FPRS]; X64CachedFPReg xregs[NUM_X_FPREGS]; MIPSCachedFPReg *vregs; + bool initialReady; + MIPSCachedFPReg regsInitial[NUM_MIPS_FPRS]; + X64CachedFPReg xregsInitial[NUM_X_FPREGS]; + // TEMP0, etc. are swapped in here if necessary (e.g. on x86.) static u32 tempValues[NUM_TEMPS];