From d1be767d24cb9f82b0c3f393d2f7cf98a1712264 Mon Sep 17 00:00:00 2001 From: zilmar Date: Wed, 20 Jul 2016 22:22:56 +1000 Subject: [PATCH] [Project64] Move fpu used in to Reg Base --- .../N64System/Recompiler/RegBase.cpp | 49 +++++++++++++++++-- .../N64System/Recompiler/RegBase.h | 9 ++++ .../Recompiler/x86/x86RecompilerOps.cpp | 8 +-- .../N64System/Recompiler/x86/x86RegInfo.cpp | 28 +++-------- .../N64System/Recompiler/x86/x86RegInfo.h | 2 - 5 files changed, 66 insertions(+), 30 deletions(-) diff --git a/Source/Project64-core/N64System/Recompiler/RegBase.cpp b/Source/Project64-core/N64System/Recompiler/RegBase.cpp index 3ca98b769..bd5abd872 100644 --- a/Source/Project64-core/N64System/Recompiler/RegBase.cpp +++ b/Source/Project64-core/N64System/Recompiler/RegBase.cpp @@ -12,12 +12,55 @@ #include CRegBase::CRegBase() : -m_CycleCount(0) +m_CycleCount(0), +m_Fpu_Used(false) { - m_MIPS_RegState[0] = STATE_CONST_32_SIGN; - for (int32_t i = 1; i < 32; i++) + for (int32_t i = 0; i < 32; i++) { m_MIPS_RegState[i] = STATE_UNKNOWN; m_MIPS_RegVal[i].DW = 0; } + m_MIPS_RegState[0] = STATE_CONST_32_SIGN; +} + +bool CRegBase::operator==(const CRegBase& right) const +{ + for (uint32_t count = 0; count < 32; count++) + { + if (m_MIPS_RegState[count] != right.m_MIPS_RegState[count]) + { + return false; + } + if (m_MIPS_RegState[count] == STATE_UNKNOWN) + { + continue; + } + if (m_MIPS_RegVal[count].DW != right.m_MIPS_RegVal[count].DW) + { + return false; + } + } + if (m_CycleCount != right.m_CycleCount) { return false; } + if (m_Fpu_Used != right.m_Fpu_Used) { return false; } + return true; +} + +bool CRegBase::operator!=(const CRegBase& right) const +{ + return !(right == *this); +} + +CRegBase& CRegBase::operator=(const CRegBase& right) +{ + memcpy(&m_MIPS_RegState, &right.m_MIPS_RegState, sizeof(m_MIPS_RegState)); + memcpy(&m_MIPS_RegVal, &right.m_MIPS_RegVal, sizeof(m_MIPS_RegVal)); + m_CycleCount = right.m_CycleCount; + m_Fpu_Used = right.m_Fpu_Used; +#ifdef _DEBUG + if (*this != right) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } +#endif + return *this; } \ No newline at end of file diff --git a/Source/Project64-core/N64System/Recompiler/RegBase.h b/Source/Project64-core/N64System/Recompiler/RegBase.h index e5b14209f..d34c558b9 100644 --- a/Source/Project64-core/N64System/Recompiler/RegBase.h +++ b/Source/Project64-core/N64System/Recompiler/RegBase.h @@ -69,8 +69,17 @@ public: void SetBlockCycleCount(uint32_t CyleCount) { m_CycleCount = CyleCount; } uint32_t GetBlockCycleCount() const { return m_CycleCount; } + void SetFpuBeenUsed(bool FpuUsed) { m_Fpu_Used = FpuUsed; } + bool GetFpuBeenUsed() const { return m_Fpu_Used; } + + CRegBase& operator=(const CRegBase&); + + bool operator==(const CRegBase& right) const; + bool operator!=(const CRegBase& right) const; + protected: REG_STATE m_MIPS_RegState[32]; MIPS_DWORD m_MIPS_RegVal[32]; uint32_t m_CycleCount; + bool m_Fpu_Used; }; diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp index 82156f56f..ed2ee8041 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp @@ -8851,12 +8851,14 @@ void CX86RecompilerOps::CompileExitCode() void CX86RecompilerOps::CompileCop1Test() { - if (m_RegWorkingSet.FpuBeenUsed()) + if (m_RegWorkingSet.GetFpuBeenUsed()) + { return; + } TestVariable(STATUS_CU1, &g_Reg->STATUS_REGISTER, "STATUS_REGISTER"); CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::COP1_Unuseable, false, JeLabel32); - m_RegWorkingSet.FpuBeenUsed() = true; + m_RegWorkingSet.SetFpuBeenUsed(true); } void CX86RecompilerOps::CompileInPermLoop(CRegInfo & RegSet, uint32_t ProgramCounter) @@ -11456,4 +11458,4 @@ void CX86RecompilerOps::ResetMemoryStack() MoveX86regToVariable(Reg, &(g_Recompiler->MemoryStackPos()), "MemoryStack"); } -#endif +#endif \ No newline at end of file diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.cpp index 8748c4a4f..6708ef044 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.cpp @@ -27,10 +27,8 @@ const char *Format_Name[] = { "Unknown", "dword", "qword", "float", "double" }; CX86RegInfo::CX86RegInfo() : m_Stack_TopPos(0), - m_Fpu_Used(false), m_RoundingModel(RoundUnknown) { - m_MIPS_RegVal[0].DW = 0; m_RegMapLo[0] = x86_Unknown; m_RegMapHi[0] = x86_Unknown; @@ -65,13 +63,10 @@ CX86RegInfo::~CX86RegInfo() CX86RegInfo& CX86RegInfo::operator=(const CX86RegInfo& right) { - m_CycleCount = right.m_CycleCount; + CRegBase::operator=(right); m_Stack_TopPos = right.m_Stack_TopPos; - m_Fpu_Used = right.m_Fpu_Used; m_RoundingModel = right.m_RoundingModel; - memcpy(&m_MIPS_RegState, &right.m_MIPS_RegState, sizeof(m_MIPS_RegState)); - memcpy(&m_MIPS_RegVal, &right.m_MIPS_RegVal, sizeof(m_MIPS_RegVal)); memcpy(&m_RegMapLo, &right.m_RegMapLo, sizeof(m_RegMapLo)); memcpy(&m_RegMapHi, &right.m_RegMapHi, sizeof(m_RegMapHi)); memcpy(&m_x86reg_MappedTo, &right.m_x86reg_MappedTo, sizeof(m_x86reg_MappedTo)); @@ -94,30 +89,19 @@ CX86RegInfo& CX86RegInfo::operator=(const CX86RegInfo& right) bool CX86RegInfo::operator==(const CX86RegInfo& right) const { + if (!CRegBase::operator==(right)) + { + return false; + } + int32_t count; - for (count = 0; count < 32; count++) - { - if (m_MIPS_RegState[count] != right.m_MIPS_RegState[count]) - { - return false; - } - if (m_MIPS_RegState[count] == STATE_UNKNOWN) - { - continue; - } - if (m_MIPS_RegVal[count].DW != right.m_MIPS_RegVal[count].DW) - { - return false; - } - } for (count = 0; count < 10; count++) { if (m_x86reg_MappedTo[count] != right.m_x86reg_MappedTo[count]) { return false; } if (m_x86reg_Protected[count] != right.m_x86reg_Protected[count]) { return false; } if (m_x86reg_MapOrder[count] != right.m_x86reg_MapOrder[count]) { return false; } } - if (m_CycleCount != right.m_CycleCount) { return false; } if (m_Stack_TopPos != right.m_Stack_TopPos) { return false; } for (count = 0; count < 8; count++) diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.h b/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.h index 13ccca05f..5688e7b04 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.h +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.h @@ -108,7 +108,6 @@ public: int32_t & FpuMappedTo(int32_t Reg) { return m_x86fpu_MappedTo[Reg]; } FPU_STATE & FpuState(int32_t Reg) { return m_x86fpu_State[Reg]; } FPU_ROUND & FpuRoundingModel(int32_t Reg) { return m_x86fpu_RoundingModel[Reg]; } - bool & FpuBeenUsed() { return m_Fpu_Used; } FPU_ROUND GetRoundingModel() const { return m_RoundingModel; } void SetRoundingModel(FPU_ROUND RoundingModel) { m_RoundingModel = RoundingModel; } @@ -132,7 +131,6 @@ private: bool m_x86fpu_StateChanged[8]; FPU_ROUND m_x86fpu_RoundingModel[8]; - bool m_Fpu_Used; FPU_ROUND m_RoundingModel; static uint32_t m_fpuControl;