Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Interpreter: Move common exception functions to ExceptionUtils.h
Keeps all of the interpreter-specific exception handling functions
together in a reusable way across translation units, similar to
FPUtils.h for reusable floating-point functions.
  • Loading branch information
lioncash committed May 20, 2018
1 parent 3d8e63f commit 3edf0f1
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 22 deletions.
1 change: 1 addition & 0 deletions Source/Core/Core/Core.vcxproj
Expand Up @@ -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" />
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/Core/Core.vcxproj.filters
Expand Up @@ -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>
Expand Down
26 changes: 26 additions & 0 deletions 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;
}
21 changes: 1 addition & 20 deletions Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp
Expand Up @@ -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"
Expand All @@ -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;
Expand Down
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 3edf0f1

Please sign in to comment.