Skip to content

Commit

Permalink
Merge pull request #309 from magumagu/jit-unify-asm
Browse files Browse the repository at this point in the history
JIT: unify JitAsm for JIT64 and JIT64IL.
  • Loading branch information
shuffle2 committed May 22, 2014
2 parents c308657 + 727ef4a commit fc41a53
Show file tree
Hide file tree
Showing 18 changed files with 71 additions and 339 deletions.
1 change: 0 additions & 1 deletion Source/Core/Core/CMakeLists.txt
Expand Up @@ -180,7 +180,6 @@ if(_M_X86)
set(SRCS ${SRCS}
x64MemTools.cpp
PowerPC/Jit64IL/IR_X86.cpp
PowerPC/Jit64IL/JitILAsm.cpp
PowerPC/Jit64IL/JitIL.cpp
PowerPC/Jit64IL/JitIL_Tables.cpp
PowerPC/Jit64/Jit64_Tables.cpp
Expand Down
4 changes: 1 addition & 3 deletions Source/Core/Core/Core.vcxproj
Expand Up @@ -209,7 +209,6 @@
<ClCompile Include="PowerPC\JitILCommon\JitILBase_SystemRegisters.cpp" />
<ClCompile Include="PowerPC\Jit64IL\IR_X86.cpp" />
<ClCompile Include="PowerPC\Jit64IL\JitIL.cpp" />
<ClCompile Include="PowerPC\Jit64IL\JitILAsm.cpp" />
<ClCompile Include="PowerPC\Jit64IL\JitIL_Tables.cpp" />
<ClCompile Include="PowerPC\Jit64\Jit.cpp" />
<ClCompile Include="PowerPC\Jit64\Jit64_Tables.cpp" />
Expand Down Expand Up @@ -399,7 +398,6 @@
<ClInclude Include="PowerPC\Interpreter\Interpreter_FPUtils.h" />
<ClInclude Include="PowerPC\Interpreter\Interpreter_Tables.h" />
<ClInclude Include="PowerPC\Jit64IL\JitIL.h" />
<ClInclude Include="PowerPC\Jit64IL\JitILAsm.h" />
<ClInclude Include="PowerPC\Jit64IL\JitIL_Tables.h" />
<ClInclude Include="PowerPC\Jit64\Jit.h" />
<ClInclude Include="PowerPC\Jit64\Jit64_Tables.h" />
Expand Down Expand Up @@ -470,4 +468,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
8 changes: 1 addition & 7 deletions Source/Core/Core/Core.vcxproj.filters
Expand Up @@ -641,9 +641,6 @@
<ClCompile Include="PowerPC\Jit64IL\JitIL_Tables.cpp">
<Filter>PowerPC\JitIL</Filter>
</ClCompile>
<ClCompile Include="PowerPC\Jit64IL\JitILAsm.cpp">
<Filter>PowerPC\JitIL</Filter>
</ClCompile>
<ClCompile Include="PowerPC\Jit64\Jit_Branch.cpp">
<Filter>PowerPC\Jit64</Filter>
</ClCompile>
Expand Down Expand Up @@ -1191,9 +1188,6 @@
<ClInclude Include="PowerPC\Jit64IL\JitIL_Tables.h">
<Filter>PowerPC\JitIL</Filter>
</ClInclude>
<ClInclude Include="PowerPC\Jit64IL\JitILAsm.h">
<Filter>PowerPC\JitIL</Filter>
</ClInclude>
<ClInclude Include="PowerPC\Jit64\JitRegCache.h">
<Filter>PowerPC\Jit64</Filter>
</ClInclude>
Expand All @@ -1211,4 +1205,4 @@
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
</Project>
</Project>
2 changes: 0 additions & 2 deletions Source/Core/Core/PowerPC/Jit64/JitAsm.cpp
Expand Up @@ -28,8 +28,6 @@ static bool enableDebug = false;
//RBX - Base pointer of memory
//R15 - Pointer to array of block pointers

Jit64AsmRoutineManager asm_routines;

// PLAN: no more block numbers - crazy opcodes just contain offset within
// dynarec buffer
// At this offset - 4, there is an int specifying the block number.
Expand Down
2 changes: 0 additions & 2 deletions Source/Core/Core/PowerPC/Jit64/JitAsm.h
Expand Up @@ -37,5 +37,3 @@ class Jit64AsmRoutineManager : public CommonAsmRoutines
FreeCodeSpace();
}
};

extern Jit64AsmRoutineManager asm_routines;
7 changes: 4 additions & 3 deletions Source/Core/Core/PowerPC/Jit64IL/IR_X86.cpp
Expand Up @@ -1636,7 +1636,7 @@ static void DoWriteCode(IRBuilder* ibuild, JitIL* Jit, u32 exitAddress) {
Jit->ABI_CallFunction((void *)&PowerPC::OnIdleIL);

Jit->MOV(32, M(&PC), Imm32(ibuild->GetImmValue( getOp2(I) )));
Jit->JMP(((JitIL *)jit)->asm_routines.testExceptions, true);
Jit->WriteExceptionExit();

Jit->SetJumpTarget(cont);
if (RI.IInfo[I - RI.FirstI] & 4)
Expand Down Expand Up @@ -1691,7 +1691,7 @@ static void DoWriteCode(IRBuilder* ibuild, JitIL* Jit, u32 exitAddress) {
unsigned InstLoc = ibuild->GetImmValue(getOp1(I));
Jit->ABI_CallFunction((void *)&CoreTiming::Idle);
Jit->MOV(32, M(&PC), Imm32(InstLoc));
Jit->JMP(((JitIL *)jit)->asm_routines.testExceptions, true);
Jit->WriteExceptionExit();
break;
}
case SystemCall: {
Expand Down Expand Up @@ -1734,7 +1734,8 @@ static void DoWriteCode(IRBuilder* ibuild, JitIL* Jit, u32 exitAddress) {
// from PC. Update PC with the latest value in case that happens.
Jit->MOV(32, M(&PC), Imm32(InstLoc));
Jit->SUB(32, M(&CoreTiming::downcount), Jit->js.downcountAmount > 127 ? Imm32(Jit->js.downcountAmount) : Imm8(Jit->js.downcountAmount));
Jit->JMP(Jit->asm_routines.fpException, true);
Jit->OR(32, M((void *)&PowerPC::ppcState.Exceptions), Imm32(EXCEPTION_FPU_UNAVAILABLE));
Jit->WriteExceptionExit();
Jit->SetJumpTarget(b1);
break;
}
Expand Down
17 changes: 13 additions & 4 deletions Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp
Expand Up @@ -14,7 +14,6 @@
#include "Core/PowerPC/Profiler.h"
#include "Core/PowerPC/Jit64IL/JitIL.h"
#include "Core/PowerPC/Jit64IL/JitIL_Tables.h"
#include "Core/PowerPC/Jit64IL/JitILAsm.h"

using namespace Gen;
using namespace PowerPC;
Expand Down Expand Up @@ -427,12 +426,14 @@ void JitIL::WriteExitDestInOpArg(const Gen::OpArg& arg)
void JitIL::WriteRfiExitDestInOpArg(const Gen::OpArg& arg)
{
MOV(32, M(&PC), arg);
MOV(32, M(&NPC), arg);
Cleanup();
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITILTimeProfiling) {
ABI_CallFunction((void *)JitILProfiler::End);
}
ABI_CallFunction(reinterpret_cast<void *>(&PowerPC::CheckExceptions));
SUB(32, M(&CoreTiming::downcount), js.downcountAmount > 127 ? Imm32(js.downcountAmount) : Imm8(js.downcountAmount));
JMP(asm_routines.testExceptions, true);
JMP(asm_routines.dispatcher, true);
}

void JitIL::WriteExceptionExit()
Expand All @@ -441,8 +442,11 @@ void JitIL::WriteExceptionExit()
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITILTimeProfiling) {
ABI_CallFunction((void *)JitILProfiler::End);
}
MOV(32, R(EAX), M(&PC));
MOV(32, M(&NPC), R(EAX));
ABI_CallFunction(reinterpret_cast<void *>(&PowerPC::CheckExceptions));
SUB(32, M(&CoreTiming::downcount), js.downcountAmount > 127 ? Imm32(js.downcountAmount) : Imm8(js.downcountAmount));
JMP(asm_routines.testExceptions, true);
JMP(asm_routines.dispatcher, true);
}

void STACKALIGN JitIL::Run()
Expand Down Expand Up @@ -549,8 +553,13 @@ const u8* JitIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
// This block uses FPU - needs to add FP exception bailout
TEST(32, M(&PowerPC::ppcState.msr), Imm32(1 << 13)); //Test FP enabled bit
FixupBranch b1 = J_CC(CC_NZ);

// If a FPU exception occurs, the exception handler will read
// from PC. Update PC with the latest value in case that happens.
MOV(32, M(&PC), Imm32(js.blockStart));
JMP(asm_routines.fpException, true);
OR(32, M((void *)&PowerPC::ppcState.Exceptions), Imm32(EXCEPTION_FPU_UNAVAILABLE));
WriteExceptionExit();

SetJumpTarget(b1);
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/PowerPC/Jit64IL/JitIL.h
Expand Up @@ -28,7 +28,7 @@
#include "Core/PowerPC/PowerPC.h"
#include "Core/PowerPC/PPCAnalyst.h"
#include "Core/PowerPC/PPCTables.h"
#include "Core/PowerPC/Jit64IL/JitILAsm.h"
#include "Core/PowerPC/Jit64/JitAsm.h"
#include "Core/PowerPC/JitCommon/Jit_Util.h"
#include "Core/PowerPC/JitCommon/JitBackpatch.h"
#include "Core/PowerPC/JitCommon/JitBase.h"
Expand All @@ -50,7 +50,7 @@ class JitIL : public JitILBase, public EmuCodeBlock
TrampolineCache trampolines;

public:
JitILAsmRoutineManager asm_routines;
Jit64AsmRoutineManager asm_routines;

JitIL() {}
~JitIL() {}
Expand Down

0 comments on commit fc41a53

Please sign in to comment.