diff options
| author | Tilka <tilkax@gmail.com> | 2018-05-21 08:46:43 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-21 08:46:43 +0100 |
| commit | 9806583b1e59fac760a5eaa505b6a030dae332a9 (patch) | |
| tree | 71b1458b84e26c8939d76c8b4a1dee2df965fd62 | |
| parent | 3d8e63fffd129ae2a40983d3ac82663698329e37 (diff) | |
| parent | 3edf0f1cf9fb17bf28ffe3b8cebe30b534f32504 (diff) | |
Merge pull request #6925 from lioncash/exception
Interpreter: Move common exception functions to ExceptionUtils.h
5 files changed, 34 insertions, 22 deletions
diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj index c7f1f31247..ae841ca4d1 100644 --- a/Source/Core/Core/Core.vcxproj +++ b/Source/Core/Core/Core.vcxproj @@ -500,6 +500,7 @@ <ClInclude Include="PowerPC\Gekko.h" /> <ClInclude Include="PowerPC\CachedInterpreter\CachedInterpreter.h" /> <ClInclude Include="PowerPC\CachedInterpreter\InterpreterBlockCache.h" /> + <ClInclude Include="PowerPC\Interpreter\ExceptionUtils.h" /> <ClInclude Include="PowerPC\Interpreter\Interpreter.h" /> <ClInclude Include="PowerPC\Interpreter\Interpreter_FPUtils.h" /> <ClInclude Include="PowerPC\Jit64Common\ConstantPool.h" /> diff --git a/Source/Core/Core/Core.vcxproj.filters b/Source/Core/Core/Core.vcxproj.filters index 6c20122943..944dfc1436 100644 --- a/Source/Core/Core/Core.vcxproj.filters +++ b/Source/Core/Core/Core.vcxproj.filters @@ -1011,6 +1011,9 @@ <ClInclude Include="PowerPC\CachedInterpreter\InterpreterBlockCache.h"> <Filter>PowerPC\Cached Interpreter</Filter> </ClInclude> + <ClInclude Include="PowerPC\Interpreter\ExceptionUtils.h"> + <Filter>PowerPC\Interpreter</Filter> + </ClInclude> <ClInclude Include="PowerPC\Interpreter\Interpreter.h"> <Filter>PowerPC\Interpreter</Filter> </ClInclude> diff --git a/Source/Core/Core/PowerPC/Interpreter/ExceptionUtils.h b/Source/Core/Core/PowerPC/Interpreter/ExceptionUtils.h new file mode 100644 index 0000000000..5b3af8a832 --- /dev/null +++ b/Source/Core/Core/PowerPC/Interpreter/ExceptionUtils.h @@ -0,0 +1,26 @@ +// Copyright 2018 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "Common/CommonTypes.h" +#include "Core/PowerPC/Gekko.h" +#include "Core/PowerPC/PowerPC.h" + +inline void GenerateAlignmentException(u32 address) +{ + PowerPC::ppcState.Exceptions |= EXCEPTION_ALIGNMENT; + PowerPC::ppcState.spr[SPR_DAR] = address; +} + +inline void GenerateDSIException(u32 address) +{ + PowerPC::ppcState.Exceptions |= EXCEPTION_DSI; + PowerPC::ppcState.spr[SPR_DAR] = address; +} + +inline void GenerateProgramException() +{ + PowerPC::ppcState.Exceptions |= EXCEPTION_PROGRAM; +} diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp index fd8233473a..679517b21a 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp @@ -9,6 +9,7 @@ #include "Common/Swap.h" #include "Core/ConfigManager.h" +#include "Core/PowerPC/Interpreter/ExceptionUtils.h" #include "Core/PowerPC/Interpreter/Interpreter.h" #include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h" #include "Core/PowerPC/JitInterface.h" @@ -18,26 +19,6 @@ bool Interpreter::m_reserve; u32 Interpreter::m_reserve_address; -namespace -{ -void GenerateAlignmentException(u32 address) -{ - PowerPC::ppcState.Exceptions |= EXCEPTION_ALIGNMENT; - PowerPC::ppcState.spr[SPR_DAR] = address; -} - -void GenerateDSIException(u32 address) -{ - PowerPC::ppcState.Exceptions |= EXCEPTION_DSI; - PowerPC::ppcState.spr[SPR_DAR] = address; -} - -void GenerateProgramException() -{ - PowerPC::ppcState.Exceptions |= EXCEPTION_PROGRAM; -} -} - u32 Interpreter::Helper_Get_EA(const UGeckoInstruction inst) { return inst.RA ? (rGPR[inst.RA] + inst.SIMM_16) : (u32)inst.SIMM_16; diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp index 1bdee2fbf7..20da986ead 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp @@ -12,6 +12,7 @@ #include "Common/Logging/Log.h" #include "Core/HW/GPFifo.h" #include "Core/HW/SystemTimers.h" +#include "Core/PowerPC/Interpreter/ExceptionUtils.h" #include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h" #include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" @@ -198,7 +199,7 @@ void Interpreter::mfspr(UGeckoInstruction inst) if (MSR.PR && index != SPR_XER && index != SPR_LR && index != SPR_CTR && index != SPR_TL && index != SPR_TU) { - PowerPC::ppcState.Exceptions |= EXCEPTION_PROGRAM; + GenerateProgramException(); return; } @@ -245,7 +246,7 @@ void Interpreter::mtspr(UGeckoInstruction inst) // XER, LR, and CTR are the only ones available to be written to in user mode if (MSR.PR && index != SPR_XER && index != SPR_LR && index != SPR_CTR) { - PowerPC::ppcState.Exceptions |= EXCEPTION_PROGRAM; + GenerateProgramException(); return; } |
