mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-24 23:11:14 +01:00
Cleanup, preparations for Linux/Mac JIT (not yet working)
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@114 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
60ac064e0c
commit
d8fa3113ea
@ -1,11 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
warnings = ' -Wall -Wwrite-strings -Wfloat-equal -Wshadow -Wpointer-arith -Wcast-qual -Wpacked'
|
ccflags = '-g -O3 -fno-strict-aliasing -fPIC -msse2 -Wall -DLOGGING -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE'
|
||||||
|
|
||||||
nonactive_warnings = '-Wunreachable-code'
|
|
||||||
|
|
||||||
ccflags = '-g -O3 -fno-strict-aliasing -fPIC -msse2 -DLOGGING -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE' + warnings
|
|
||||||
|
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
ccflags += ' -I/opt/local/include'
|
ccflags += ' -I/opt/local/include'
|
||||||
|
@ -447,6 +447,14 @@
|
|||||||
<References>
|
<References>
|
||||||
</References>
|
</References>
|
||||||
<Files>
|
<Files>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\ABI.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\ABI.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\Common.cpp"
|
RelativePath=".\Src\Common.cpp"
|
||||||
>
|
>
|
||||||
@ -559,6 +567,10 @@
|
|||||||
RelativePath=".\Src\PortableSockets.h"
|
RelativePath=".\Src\PortableSockets.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\SConscript"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\stdafx.cpp"
|
RelativePath=".\Src\stdafx.cpp"
|
||||||
>
|
>
|
||||||
|
111
Source/Core/Common/Src/ABI.cpp
Normal file
111
Source/Core/Common/Src/ABI.cpp
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
#include "Common.h"
|
||||||
|
#include "x64Emitter.h"
|
||||||
|
#include "ABI.h"
|
||||||
|
|
||||||
|
using namespace Gen;
|
||||||
|
|
||||||
|
#ifdef _M_IX86 // All32
|
||||||
|
|
||||||
|
// Shared code between Win32 and Unix32
|
||||||
|
// ====================================
|
||||||
|
|
||||||
|
void ABI_CallFunctionC(void *func, u32 param1) {
|
||||||
|
PUSH(32, Imm32(param1));
|
||||||
|
CALL(func);
|
||||||
|
ADD(32, R(ESP), Imm8(4));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ABI_CallFunctionCC(void *func, u32 param1, u32 param2) {
|
||||||
|
PUSH(32, Imm32(param2));
|
||||||
|
PUSH(32, Imm32(param1));
|
||||||
|
CALL(func);
|
||||||
|
ADD(32, R(ESP), Imm8(8));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pass a register as a paremeter.
|
||||||
|
void ABI_CallFunctionR(void *func, X64Reg reg1) {
|
||||||
|
PUSH(32, R(reg1));
|
||||||
|
CALL(func);
|
||||||
|
ADD(32, R(ESP), Imm8(4));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ABI_PushAllCalleeSavedRegsAndAdjustStack() {
|
||||||
|
PUSH(EBP);
|
||||||
|
PUSH(EBX);
|
||||||
|
PUSH(ESI);
|
||||||
|
PUSH(EDI);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ABI_PopAllCalleeSavedRegsAndAdjustStack() {
|
||||||
|
POP(EDI);
|
||||||
|
POP(ESI);
|
||||||
|
POP(EBX);
|
||||||
|
POP(EBP);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
// Shared code between Win64 and Unix64
|
||||||
|
// ====================================
|
||||||
|
|
||||||
|
void ABI_CallFunctionC(void *func, u32 param1) {
|
||||||
|
MOV(32, R(ABI_PARAM1), Imm32(param1));
|
||||||
|
CALL(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ABI_CallFunctionCC(void *func, u32 param1, u32 param2) {
|
||||||
|
MOV(32, R(ABI_PARAM1), Imm32(param1));
|
||||||
|
MOV(32, R(ABI_PARAM2), Imm32(param2));
|
||||||
|
CALL(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pass a register as a paremeter.
|
||||||
|
void ABI_CallFunctionR(void *func, X64Reg reg1) {
|
||||||
|
if (reg1 != ABI_PARAM1)
|
||||||
|
MOV(32, R(ABI_PARAM1), R(reg1));
|
||||||
|
CALL(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
// Win64 Specific Code
|
||||||
|
// ====================================
|
||||||
|
void ABI_PushAllCalleeSavedRegsAndAdjustStack() {
|
||||||
|
//we only want to do this once
|
||||||
|
PUSH(RBX);
|
||||||
|
PUSH(RSI);
|
||||||
|
PUSH(RDI);
|
||||||
|
PUSH(RBP);
|
||||||
|
PUSH(R12);
|
||||||
|
PUSH(R13);
|
||||||
|
PUSH(R14);
|
||||||
|
PUSH(R15);
|
||||||
|
//TODO: Also preserve XMM0-3?
|
||||||
|
SUB(64, R(RSP), Imm8(0x20));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ABI_PopAllCalleeSavedRegsAndAdjustStack() {
|
||||||
|
ADD(64, R(RSP), Imm8(0x20));
|
||||||
|
POP(R15);
|
||||||
|
POP(R14);
|
||||||
|
POP(R13);
|
||||||
|
POP(R12);
|
||||||
|
POP(RBP);
|
||||||
|
POP(RDI);
|
||||||
|
POP(RSI);
|
||||||
|
POP(RBX);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
// Unix64 Specific Code
|
||||||
|
// ====================================
|
||||||
|
void ABI_PushAllCalleeSavedRegsAndAdjustStack() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ABI_PopAllCalleeSavedRegsAndAdjustStack() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
93
Source/Core/Common/Src/ABI.h
Normal file
93
Source/Core/Common/Src/ABI.h
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
// Copyright (C) 2003-2008 Dolphin Project.
|
||||||
|
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, version 2.0.
|
||||||
|
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License 2.0 for more details.
|
||||||
|
|
||||||
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
|
// If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
|
// Official SVN repository and contact information can be found at
|
||||||
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
|
#ifndef _JIT_ABI_H
|
||||||
|
#define _JIT_ABI_H
|
||||||
|
|
||||||
|
#include "x64Emitter.h"
|
||||||
|
|
||||||
|
// x86/x64 ABI:s, and helpers to help follow them when JIT-ing code.
|
||||||
|
// All convensions return values in EAX (+ possibly EDX).
|
||||||
|
|
||||||
|
// Linux 32-bit, Windows 32-bit (cdecl, System V):
|
||||||
|
// * Caller pushes left to right
|
||||||
|
// * Caller fixes stack after call
|
||||||
|
// * function subtract from stack for local storage only.
|
||||||
|
// Scratch: EAX ECX EDX
|
||||||
|
// Callee-save: EBX ESI EDI EBP
|
||||||
|
// Parameters: -
|
||||||
|
|
||||||
|
// Windows 64-bit
|
||||||
|
// * 4-reg "fastcall" variant, very new-skool stack handling
|
||||||
|
// * Callee moves stack pointer, to make room for shadow regs for the biggest function _it itself calls_
|
||||||
|
// * Parameters passed in RCX, RDX, ... further parameters are MOVed into the allocated stack space.
|
||||||
|
// Scratch: RAX RCX RDX R8 R9 R10 R11
|
||||||
|
// Callee-save: RBX RSI RDI RBP R12 R13 R14 R15
|
||||||
|
// Parameters: RCX RDX R8 R9, further MOV-ed
|
||||||
|
|
||||||
|
// Linux 64-bit
|
||||||
|
// * 6-reg "fastcall" variant, old skool stack handling (parameters are pushed)
|
||||||
|
// Scratch: RAX RCX RDX RSI RDI R8 R9 R10 R11
|
||||||
|
// Callee-save: RBX RBP R12 R13 R14 R15
|
||||||
|
// Parameters: RDI RSI RDX RCX R8 R9
|
||||||
|
|
||||||
|
#ifdef _M_IX86
|
||||||
|
// 32 bit calling convention, shared by all
|
||||||
|
|
||||||
|
// There are no ABI_PARAM* here, since args are pushed.
|
||||||
|
|
||||||
|
// === 32-bit bog standard cdecl, shared between linux and windows ============================
|
||||||
|
// MacOSX 32-bit is same as System V with a few exceptions that we probably don't care much about.
|
||||||
|
|
||||||
|
#else
|
||||||
|
// 64 bit calling convention
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
// === 64-bit Windows - the really exotic calling convention ==================================
|
||||||
|
|
||||||
|
#define ABI_PARAM1 RCX
|
||||||
|
#define ABI_PARAM2 RDX
|
||||||
|
#define ABI_PARAM3 R8
|
||||||
|
#define ABI_PARAM4 R9
|
||||||
|
|
||||||
|
#else
|
||||||
|
// === 64-bit Unix (hopefully MacOSX too) =====================================================
|
||||||
|
|
||||||
|
#define ABI_PARAM1 RDI
|
||||||
|
#define ABI_PARAM2 RSI
|
||||||
|
#define ABI_PARAM3 RDX
|
||||||
|
#define ABI_PARAM4 RCX
|
||||||
|
#define ABI_PARAM5 R8
|
||||||
|
#define ABI_PARAM6 R9
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Utility functions
|
||||||
|
// These only support u32 parameters, but that's enough for a lot of uses.
|
||||||
|
// These will destroy the 1 or 2 first "parameter regs".
|
||||||
|
void ABI_CallFunctionC(void *func, u32 param1);
|
||||||
|
void ABI_CallFunctionCC(void *func, u32 param1, u32 param2);
|
||||||
|
|
||||||
|
// Pass a register as a paremeter.
|
||||||
|
void ABI_CallFunctionR(void *func, Gen::X64Reg reg1);
|
||||||
|
|
||||||
|
void ABI_PushAllCalleeSavedRegsAndAdjustStack();
|
||||||
|
void ABI_PopAllCalleeSavedRegsAndAdjustStack();
|
||||||
|
|
||||||
|
#endif // _JIT_ABI_H
|
@ -1,6 +1,7 @@
|
|||||||
Import('env')
|
Import('env')
|
||||||
|
|
||||||
files = ["Common.cpp",
|
files = ["ABI.cpp",
|
||||||
|
"Common.cpp",
|
||||||
"CPUDetect.cpp",
|
"CPUDetect.cpp",
|
||||||
"DynamicLibrary.cpp",
|
"DynamicLibrary.cpp",
|
||||||
"Hash.cpp",
|
"Hash.cpp",
|
||||||
|
@ -305,7 +305,7 @@ namespace Gen
|
|||||||
|
|
||||||
void XCHG_AHAL();
|
void XCHG_AHAL();
|
||||||
void BSWAP(int bits, X64Reg reg);
|
void BSWAP(int bits, X64Reg reg);
|
||||||
void MOVSX(int dbits, int sbits, X64Reg dest, OpArg src); //auto uses MOVSXD if necessary
|
void MOVSX(int dbits, int sbits, X64Reg dest, OpArg src); //automatically uses MOVSXD if necessary
|
||||||
void MOVZX(int dbits, int sbits, X64Reg dest, OpArg src);
|
void MOVZX(int dbits, int sbits, X64Reg dest, OpArg src);
|
||||||
|
|
||||||
enum SSECompare
|
enum SSECompare
|
||||||
@ -320,13 +320,11 @@ namespace Gen
|
|||||||
ORD,
|
ORD,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//SSE2
|
|
||||||
// WARNING - These two take 11-13 cycles and are VectorPath! (AMD64)
|
// WARNING - These two take 11-13 cycles and are VectorPath! (AMD64)
|
||||||
void STMXCSR(OpArg memloc);
|
void STMXCSR(OpArg memloc);
|
||||||
void LDMXCSR(OpArg memloc);
|
void LDMXCSR(OpArg memloc);
|
||||||
|
|
||||||
//Regular SSE instructions
|
// Regular SSE/SSE2 instructions
|
||||||
void ADDSS(X64Reg regOp, OpArg arg);
|
void ADDSS(X64Reg regOp, OpArg arg);
|
||||||
void ADDSD(X64Reg regOp, OpArg arg);
|
void ADDSD(X64Reg regOp, OpArg arg);
|
||||||
void SUBSS(X64Reg regOp, OpArg arg);
|
void SUBSS(X64Reg regOp, OpArg arg);
|
||||||
@ -492,7 +490,6 @@ namespace Gen
|
|||||||
|
|
||||||
void PMOVMSKB(X64Reg dest, OpArg arg);
|
void PMOVMSKB(X64Reg dest, OpArg arg);
|
||||||
|
|
||||||
|
|
||||||
namespace Util
|
namespace Util
|
||||||
{
|
{
|
||||||
// Sets up a __cdecl function.
|
// Sets up a __cdecl function.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="8,00"
|
Version="8.00"
|
||||||
Name="Core"
|
Name="Core"
|
||||||
ProjectGUID="{F0B874CB-4476-4199-9315-8343D05AE684}"
|
ProjectGUID="{F0B874CB-4476-4199-9315-8343D05AE684}"
|
||||||
RootNamespace="Core"
|
RootNamespace="Core"
|
||||||
@ -891,6 +891,14 @@
|
|||||||
RelativePath=".\Src\PowerPC\Jit64\Jit_SystemRegisters.cpp"
|
RelativePath=".\Src\PowerPC\Jit64\Jit_SystemRegisters.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\PowerPC\Jit64\JitABI.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\PowerPC\Jit64\JitABI.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\PowerPC\Jit64\JitAsm.cpp"
|
RelativePath=".\Src\PowerPC\Jit64\JitAsm.cpp"
|
||||||
>
|
>
|
||||||
|
@ -14,18 +14,18 @@
|
|||||||
|
|
||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
#include "Common.h"
|
||||||
|
#include "x64Emitter.h"
|
||||||
|
#include "ABI.h"
|
||||||
#include "../../HLE/HLE.h"
|
#include "../../HLE/HLE.h"
|
||||||
#include "../PowerPC.h"
|
|
||||||
#include "../../CoreTiming.h"
|
#include "../../CoreTiming.h"
|
||||||
|
#include "../PowerPC.h"
|
||||||
#include "../PPCTables.h"
|
#include "../PPCTables.h"
|
||||||
#include "../PPCAnalyst.h"
|
#include "../PPCAnalyst.h"
|
||||||
#include "x64Emitter.h"
|
|
||||||
#include "../../HW/Memmap.h"
|
#include "../../HW/Memmap.h"
|
||||||
#include "JitCache.h"
|
|
||||||
|
|
||||||
#include "JitAsm.h"
|
|
||||||
#include "Jit.h"
|
#include "Jit.h"
|
||||||
|
#include "JitAsm.h"
|
||||||
|
#include "JitCache.h"
|
||||||
#include "JitRegCache.h"
|
#include "JitRegCache.h"
|
||||||
|
|
||||||
using namespace Gen;
|
using namespace Gen;
|
||||||
@ -235,17 +235,8 @@ namespace Jit64
|
|||||||
MOV(32, M(&PC), Imm32(js.compilerPC));
|
MOV(32, M(&PC), Imm32(js.compilerPC));
|
||||||
MOV(32, M(&NPC), Imm32(js.compilerPC+4));
|
MOV(32, M(&NPC), Imm32(js.compilerPC+4));
|
||||||
}
|
}
|
||||||
#ifdef _M_X64
|
|
||||||
MOV(32,R(RCX), Imm32(_inst.hex));
|
|
||||||
CInterpreter::_interpreterInstruction instr = GetInterpreterOp(_inst);
|
CInterpreter::_interpreterInstruction instr = GetInterpreterOp(_inst);
|
||||||
CALL((void*)instr);
|
ABI_CallFunctionC((void*)instr, _inst.hex);
|
||||||
#elif _M_IX86
|
|
||||||
MOV(32,R(ECX), Imm32(_inst.hex));
|
|
||||||
PUSH(ECX);
|
|
||||||
CInterpreter::_interpreterInstruction instr = GetInterpreterOp(_inst);
|
|
||||||
CALL((void*)instr);
|
|
||||||
ADD(32,R(ESP), Imm8(4));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Default(UGeckoInstruction _inst)
|
void Default(UGeckoInstruction _inst)
|
||||||
@ -256,24 +247,14 @@ namespace Jit64
|
|||||||
void HLEFunction(UGeckoInstruction _inst)
|
void HLEFunction(UGeckoInstruction _inst)
|
||||||
{
|
{
|
||||||
FlushRegCaches();
|
FlushRegCaches();
|
||||||
#ifdef _M_X64
|
ABI_CallFunctionCC((void*)&HLE::Execute, js.compilerPC, _inst.hex);
|
||||||
MOV(32, R(ECX), Imm32(js.compilerPC));
|
|
||||||
MOV(32, R(EDX), Imm32(_inst.hex));
|
|
||||||
#elif _M_IX86
|
|
||||||
PUSH(32, Imm32(_inst.hex));
|
|
||||||
PUSH(32, Imm32(js.compilerPC));
|
|
||||||
#endif
|
|
||||||
CALL((void *)&HLE::Execute);
|
|
||||||
#ifdef _M_IX86
|
|
||||||
ADD(32, R(ESP), Imm8(8));
|
|
||||||
#endif
|
|
||||||
MOV(32, R(EAX), M(&NPC));
|
MOV(32, R(EAX), M(&NPC));
|
||||||
WriteExitDestInEAX(0);
|
WriteExitDestInEAX(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoNothing(UGeckoInstruction _inst)
|
void DoNothing(UGeckoInstruction _inst)
|
||||||
{
|
{
|
||||||
|
// Yup, just don't do anything.
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImHereDebug = false;
|
bool ImHereDebug = false;
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "../../CoreTiming.h"
|
#include "../../CoreTiming.h"
|
||||||
#include "MemoryUtil.h"
|
#include "MemoryUtil.h"
|
||||||
|
|
||||||
|
#include "ABI.h"
|
||||||
#include "Jit.h"
|
#include "Jit.h"
|
||||||
#include "JitCache.h"
|
#include "JitCache.h"
|
||||||
|
|
||||||
@ -187,16 +188,9 @@ void Generate()
|
|||||||
void Generate()
|
void Generate()
|
||||||
{
|
{
|
||||||
enterCode = AlignCode16();
|
enterCode = AlignCode16();
|
||||||
//we only want to do this once
|
|
||||||
PUSH(RBX);
|
ABI_PushAllCalleeSavedRegsAndAdjustStack();
|
||||||
PUSH(RSI);
|
|
||||||
PUSH(RDI);
|
|
||||||
PUSH(R12);
|
|
||||||
PUSH(R13);
|
|
||||||
PUSH(R14);
|
|
||||||
PUSH(R15);
|
|
||||||
//TODO: Also preserve XMM0-3?
|
|
||||||
SUB(64, R(RSP), Imm8(0x20));
|
|
||||||
//INT3();
|
//INT3();
|
||||||
|
|
||||||
MOV(64, R(RBX), Imm64((u64)Memory::base));
|
MOV(64, R(RBX), Imm64((u64)Memory::base));
|
||||||
@ -237,7 +231,7 @@ void Generate()
|
|||||||
SetJumpTarget(notfound);
|
SetJumpTarget(notfound);
|
||||||
|
|
||||||
//Ok, no block, let's jit
|
//Ok, no block, let's jit
|
||||||
MOV(32, R(ECX), M(&PowerPC::ppcState.pc));
|
MOV(32, R(ABI_PARAM1), M(&PowerPC::ppcState.pc));
|
||||||
CALL((void *)&Jit);
|
CALL((void *)&Jit);
|
||||||
JMP(dispatcherNoCheck); // no point in special casing this, not the "fast path"
|
JMP(dispatcherNoCheck); // no point in special casing this, not the "fast path"
|
||||||
|
|
||||||
@ -273,14 +267,7 @@ void Generate()
|
|||||||
J_CC(CC_Z, outerLoop, true);
|
J_CC(CC_Z, outerLoop, true);
|
||||||
|
|
||||||
//Landing pad for drec space
|
//Landing pad for drec space
|
||||||
ADD(64, R(RSP), Imm8(0x20));
|
ABI_PopAllCalleeSavedRegsAndAdjustStack();
|
||||||
POP(R15);
|
|
||||||
POP(R14);
|
|
||||||
POP(R13);
|
|
||||||
POP(R12);
|
|
||||||
POP(RDI);
|
|
||||||
POP(RSI);
|
|
||||||
POP(RBX);
|
|
||||||
RET();
|
RET();
|
||||||
|
|
||||||
computeRc = AlignCode16();
|
computeRc = AlignCode16();
|
||||||
|
@ -31,7 +31,6 @@ namespace Jit64
|
|||||||
GPRRegCache gpr;
|
GPRRegCache gpr;
|
||||||
FPURegCache fpr;
|
FPURegCache fpr;
|
||||||
|
|
||||||
|
|
||||||
void RegCache::Start(PPCAnalyst::BlockRegStats &stats)
|
void RegCache::Start(PPCAnalyst::BlockRegStats &stats)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < NUMXREGS; i++)
|
for (int i = 0; i < NUMXREGS; i++)
|
||||||
@ -245,13 +244,16 @@ namespace Jit64
|
|||||||
RegCache::Start(stats);
|
RegCache::Start(stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const int *GPRRegCache::GetAllocationOrder(int &count)
|
const int *GPRRegCache::GetAllocationOrder(int &count)
|
||||||
{
|
{
|
||||||
static const int allocationOrder[] =
|
static const int allocationOrder[] =
|
||||||
{
|
{
|
||||||
#ifdef _M_X64
|
#ifdef _M_X64
|
||||||
|
#ifdef _WIN32
|
||||||
RSI, RDI, R12, R13, R14, R8, R9, RDX, R10, R11 //, RCX
|
RSI, RDI, R12, R13, R14, R8, R9, RDX, R10, R11 //, RCX
|
||||||
|
#else
|
||||||
|
R12, R13, R14, R8, R9, RDX, R10, R11, RSI, RDI //, RCX
|
||||||
|
#endif
|
||||||
#elif _M_IX86
|
#elif _M_IX86
|
||||||
ESI, EDI, EBX, EBP, EDX //, RCX
|
ESI, EDI, EBX, EBP, EDX //, RCX
|
||||||
#endif
|
#endif
|
||||||
@ -260,8 +262,6 @@ namespace Jit64
|
|||||||
return allocationOrder;
|
return allocationOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const int *FPURegCache::GetAllocationOrder(int &count)
|
const int *FPURegCache::GetAllocationOrder(int &count)
|
||||||
{
|
{
|
||||||
static const int allocationOrder[] =
|
static const int allocationOrder[] =
|
||||||
|
@ -30,7 +30,7 @@ namespace Jit64
|
|||||||
{
|
{
|
||||||
typedef u32 (*Operation)(u32 a, u32 b);
|
typedef u32 (*Operation)(u32 a, u32 b);
|
||||||
u32 Add(u32 a, u32 b) {return a+b;}
|
u32 Add(u32 a, u32 b) {return a+b;}
|
||||||
u32 Or(u32 a, u32 b) {return a|b;}
|
u32 Or (u32 a, u32 b) {return a|b;}
|
||||||
u32 And(u32 a, u32 b) {return a&b;}
|
u32 And(u32 a, u32 b) {return a&b;}
|
||||||
u32 Xor(u32 a, u32 b) {return a^b;}
|
u32 Xor(u32 a, u32 b) {return a^b;}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "../../HW/Memmap.h"
|
#include "../../HW/Memmap.h"
|
||||||
#include "../PPCTables.h"
|
#include "../PPCTables.h"
|
||||||
#include "x64Emitter.h"
|
#include "x64Emitter.h"
|
||||||
|
#include "ABI.h"
|
||||||
|
|
||||||
#include "Jit.h"
|
#include "Jit.h"
|
||||||
#include "JitCache.h"
|
#include "JitCache.h"
|
||||||
@ -46,47 +47,22 @@ namespace Jit64
|
|||||||
static u64 GC_ALIGNED16(temp64);
|
static u64 GC_ALIGNED16(temp64);
|
||||||
static u32 GC_ALIGNED16(temp32);
|
static u32 GC_ALIGNED16(temp32);
|
||||||
|
|
||||||
#ifdef _M_X64
|
void SafeLoadRegToEAX(X64Reg reg, int accessSize, s32 offset)
|
||||||
void SafeLoadECXtoEAX(int accessSize, s32 offset)
|
|
||||||
{
|
{
|
||||||
if (offset)
|
if (offset)
|
||||||
ADD(32, R(ECX), Imm32((u32)offset));
|
ADD(32, R(reg), Imm32((u32)offset));
|
||||||
TEST(32, R(ECX), Imm32(0x0C000000));
|
TEST(32, R(reg), Imm32(0x0C000000));
|
||||||
FixupBranch argh = J_CC(CC_NZ);
|
|
||||||
if (accessSize != 32)
|
|
||||||
XOR(32, R(EAX), R(EAX));
|
|
||||||
MOV(accessSize, R(EAX), MComplex(RBX, ECX, SCALE_1, 0));
|
|
||||||
if (accessSize == 32)
|
|
||||||
BSWAP(32, EAX);
|
|
||||||
else if (accessSize == 16)
|
|
||||||
{
|
|
||||||
BSWAP(32, EAX);
|
|
||||||
SHR(32, R(EAX), Imm8(16));
|
|
||||||
}
|
|
||||||
FixupBranch arg2 = J();
|
|
||||||
SetJumpTarget(argh);
|
|
||||||
switch (accessSize)
|
|
||||||
{
|
|
||||||
case 32: CALL((void *)&Memory::Read_U32); break;
|
|
||||||
case 16: CALL((void *)&Memory::Read_U16);break;
|
|
||||||
case 8: CALL((void *)&Memory::Read_U8);break;
|
|
||||||
}
|
|
||||||
SetJumpTarget(arg2);
|
|
||||||
}
|
|
||||||
#elif _M_IX86
|
|
||||||
void SafeLoadECXtoEAX(int accessSize, s32 offset)
|
|
||||||
{
|
|
||||||
if (offset)
|
|
||||||
ADD(32, R(ECX), Imm32((u32)offset));
|
|
||||||
TEST(32, R(ECX), Imm32(0x0C000000));
|
|
||||||
FixupBranch argh = J_CC(CC_NZ);
|
FixupBranch argh = J_CC(CC_NZ);
|
||||||
if (accessSize != 32)
|
if (accessSize != 32)
|
||||||
XOR(32, R(EAX), R(EAX));
|
XOR(32, R(EAX), R(EAX));
|
||||||
|
#ifdef _M_IX86
|
||||||
AND(32, R(ECX), Imm32(Memory::MEMVIEW32_MASK));
|
AND(32, R(ECX), Imm32(Memory::MEMVIEW32_MASK));
|
||||||
|
|
||||||
MOV(accessSize, R(EAX), MDisp(ECX, (u32)Memory::base));
|
MOV(accessSize, R(EAX), MDisp(ECX, (u32)Memory::base));
|
||||||
|
#else
|
||||||
|
MOV(accessSize, R(EAX), MComplex(RBX, reg, SCALE_1, 0));
|
||||||
|
#endif
|
||||||
if (accessSize == 32)
|
if (accessSize == 32)
|
||||||
BSWAP(32,EAX);
|
BSWAP(32, EAX);
|
||||||
else if (accessSize == 16)
|
else if (accessSize == 16)
|
||||||
{
|
{
|
||||||
BSWAP(32, EAX);
|
BSWAP(32, EAX);
|
||||||
@ -94,17 +70,14 @@ namespace Jit64
|
|||||||
}
|
}
|
||||||
FixupBranch arg2 = J();
|
FixupBranch arg2 = J();
|
||||||
SetJumpTarget(argh);
|
SetJumpTarget(argh);
|
||||||
PUSH(ECX);
|
|
||||||
switch (accessSize)
|
switch (accessSize)
|
||||||
{
|
{
|
||||||
case 32: CALL(&Memory::Read_U32); break;
|
case 32: ABI_CallFunctionR((void *)&Memory::Read_U32, ECX); break;
|
||||||
case 16: CALL(&Memory::Read_U16); break;
|
case 16: ABI_CallFunctionR((void *)&Memory::Read_U16, ECX); break;
|
||||||
case 8: CALL(&Memory::Read_U8); break;
|
case 8: ABI_CallFunctionR((void *)&Memory::Read_U8, ECX); break;
|
||||||
}
|
}
|
||||||
ADD(32, R(ESP), Imm8(4));
|
|
||||||
SetJumpTarget(arg2);
|
SetJumpTarget(arg2);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void lbzx(UGeckoInstruction inst)
|
void lbzx(UGeckoInstruction inst)
|
||||||
{
|
{
|
||||||
@ -117,7 +90,7 @@ namespace Jit64
|
|||||||
MOV(32, R(ECX), gpr.R(b));
|
MOV(32, R(ECX), gpr.R(b));
|
||||||
if (a)
|
if (a)
|
||||||
ADD(32, R(ECX), gpr.R(a));
|
ADD(32, R(ECX), gpr.R(a));
|
||||||
SafeLoadECXtoEAX(8, 0);
|
SafeLoadRegToEAX(ECX, 8, 0);
|
||||||
MOV(32, gpr.R(d), R(EAX));
|
MOV(32, gpr.R(d), R(EAX));
|
||||||
gpr.UnlockAll();
|
gpr.UnlockAll();
|
||||||
}
|
}
|
||||||
@ -133,26 +106,15 @@ namespace Jit64
|
|||||||
|
|
||||||
if (!Core::GetStartupParameter().bUseDualCore &&
|
if (!Core::GetStartupParameter().bUseDualCore &&
|
||||||
inst.OPCD == 32 &&
|
inst.OPCD == 32 &&
|
||||||
(inst.hex & 0xFFFF0000)==0x800D0000 &&
|
(inst.hex & 0xFFFF0000) == 0x800D0000 &&
|
||||||
Memory::ReadUnchecked_U32(js.compilerPC+4)==0x28000000 &&
|
Memory::ReadUnchecked_U32(js.compilerPC+4) == 0x28000000 &&
|
||||||
Memory::ReadUnchecked_U32(js.compilerPC+8)==0x4182fff8)
|
Memory::ReadUnchecked_U32(js.compilerPC+8) == 0x4182fff8)
|
||||||
{
|
{
|
||||||
//PowerPC::downcount -= PowerPC::OnIdle(uAddress);
|
|
||||||
gpr.Flush(FLUSH_ALL);
|
gpr.Flush(FLUSH_ALL);
|
||||||
fpr.Flush(FLUSH_ALL);
|
fpr.Flush(FLUSH_ALL);
|
||||||
#ifdef _M_IX86
|
ABI_CallFunctionC((void *)&PowerPC::OnIdle, PowerPC::ppcState.gpr[a] + (s32)(s16)inst.SIMM_16);
|
||||||
MOV(32, R(ECX), Imm32(PowerPC::ppcState.gpr[a] + (s32)(s16)inst.SIMM_16));
|
MOV(32, M(&PowerPC::ppcState.pc), Imm32(js.compilerPC + 12));
|
||||||
PUSH(ECX);
|
|
||||||
CALL((void *)&PowerPC::OnIdle);
|
|
||||||
ADD(32, R(ESP), Imm32(4));
|
|
||||||
#elif defined(_M_X64)
|
|
||||||
//INT3();
|
|
||||||
MOV(32, R(ECX), Imm32(PowerPC::ppcState.gpr[a] + (s32)(s16)inst.SIMM_16));
|
|
||||||
CALL((void *)&PowerPC::OnIdle);
|
|
||||||
#endif
|
|
||||||
MOV(32,M(&PowerPC::ppcState.pc), Imm32(js.compilerPC+12));
|
|
||||||
JMP(Asm::testExceptions, true);
|
JMP(Asm::testExceptions, true);
|
||||||
|
|
||||||
js.compilerPC += 8;
|
js.compilerPC += 8;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -182,7 +144,7 @@ namespace Jit64
|
|||||||
gpr.Flush(FLUSH_VOLATILE);
|
gpr.Flush(FLUSH_VOLATILE);
|
||||||
gpr.Lock(d, a);
|
gpr.Lock(d, a);
|
||||||
MOV(32, R(ECX), gpr.R(a));
|
MOV(32, R(ECX), gpr.R(a));
|
||||||
SafeLoadECXtoEAX(accessSize, offset);
|
SafeLoadRegToEAX(ECX, accessSize, offset);
|
||||||
gpr.LoadToX64(d, false, true);
|
gpr.LoadToX64(d, false, true);
|
||||||
MOV(32, gpr.R(d), R(EAX));
|
MOV(32, gpr.R(d), R(EAX));
|
||||||
gpr.UnlockAll();
|
gpr.UnlockAll();
|
||||||
@ -235,7 +197,7 @@ namespace Jit64
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
SafeLoadECXtoEAX(32, offset);
|
SafeLoadRegToEAX(ECX, 32, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOV(32, M(&temp32), R(EAX));
|
MOV(32, M(&temp32), R(EAX));
|
||||||
|
@ -253,6 +253,4 @@ namespace Jit64
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user