Lots of FP hacking for little gain, super monkey ball is only slightly more sane (wow, it rhymed). Temporary no-speed-limit hack: Hold TAB.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@279 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2008-08-23 09:20:36 +00:00
parent 0becaa3223
commit f82bf2ae9a
25 changed files with 1107 additions and 861 deletions
+1 -1
View File
@@ -2075,7 +2075,7 @@ namespace PPCDisasm
break;
case 20:
fdabc(dp,in,"sqrte",2,0);
fdabc(dp,in,"rsqrte",2,0);
break;
case 24:
+1
View File
@@ -12,6 +12,7 @@
#ifndef _WX_LISTCTRL_H_
#define _WX_LISTCTRL_H_
#include "wx/dcbuffer.h"
#include "wx/textctrl.h"
class WXDLLIMPEXP_FWD_CORE wxImageList;
+66 -42
View File
@@ -50,6 +50,7 @@
BasicRuntimeChecks="3"
RuntimeLibrary="1"
BufferSecurityCheck="true"
FloatingPointModel="0"
UsePrecompiledHeader="2"
AssemblerListingLocation="$(IntDir)\"
WarningLevel="3"
@@ -118,6 +119,7 @@
BasicRuntimeChecks="3"
RuntimeLibrary="1"
BufferSecurityCheck="true"
FloatingPointModel="0"
UsePrecompiledHeader="2"
AssemblerListingLocation="$(IntDir)\"
WarningLevel="3"
@@ -190,7 +192,7 @@
RuntimeLibrary="0"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="2"
FloatingPointModel="2"
FloatingPointModel="0"
UsePrecompiledHeader="2"
AssemblerListingLocation="$(IntDir)\"
WarningLevel="3"
@@ -265,7 +267,7 @@
RuntimeLibrary="0"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="0"
FloatingPointModel="2"
FloatingPointModel="0"
UsePrecompiledHeader="2"
AssemblerListingLocation="$(IntDir)\"
WarningLevel="3"
@@ -336,6 +338,7 @@
PreprocessorDefinitions="NDEBUG;_LIB;LOGGING;DEBUGFAST;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0"
RuntimeLibrary="0"
BufferSecurityCheck="false"
FloatingPointModel="0"
UsePrecompiledHeader="2"
AssemblerListingLocation="$(IntDir)\"
WarningLevel="3"
@@ -407,6 +410,7 @@
PreprocessorDefinitions="NDEBUG;_LIB;LOGGING;DEBUGFAST;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0"
RuntimeLibrary="0"
BufferSecurityCheck="false"
FloatingPointModel="0"
UsePrecompiledHeader="2"
AssemblerListingLocation="$(IntDir)\"
WarningLevel="3"
@@ -835,6 +839,14 @@
<File
RelativePath=".\Src\PowerPC\Interpreter\Interpreter_FloatingPoint.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AssemblerOutput="4"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Src\PowerPC\Interpreter\Interpreter_Integer.cpp"
@@ -844,6 +856,10 @@
RelativePath=".\Src\PowerPC\Interpreter\Interpreter_LoadStore.cpp"
>
</File>
<File
RelativePath=".\Src\PowerPC\Interpreter\Interpreter_LoadStorePaired.cpp"
>
</File>
<File
RelativePath=".\Src\PowerPC\Interpreter\Interpreter_Paired.cpp"
>
@@ -851,6 +867,14 @@
<File
RelativePath=".\Src\PowerPC\Interpreter\Interpreter_SystemRegisters.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AssemblerOutput="4"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
@@ -946,46 +970,6 @@
</File>
</Filter>
</Filter>
<Filter
Name="Boot"
>
<File
RelativePath=".\Src\Boot\Boot.cpp"
>
</File>
<File
RelativePath=".\Src\Boot\Boot.h"
>
</File>
<File
RelativePath=".\Src\Boot\Boot_DOL.cpp"
>
</File>
<File
RelativePath=".\Src\Boot\Boot_DOL.h"
>
</File>
<File
RelativePath=".\Src\Boot\Boot_ELF.cpp"
>
</File>
<File
RelativePath=".\Src\Boot\Boot_ELF.h"
>
</File>
<File
RelativePath=".\Src\Boot\ElfReader.cpp"
>
</File>
<File
RelativePath=".\Src\Boot\ElfReader.h"
>
</File>
<File
RelativePath=".\Src\Boot\ElfTypes.h"
>
</File>
</Filter>
<Filter
Name="Debugger"
>
@@ -1025,6 +1009,46 @@
RelativePath=".\Src\Debugger\PPCDebugInterface.h"
>
</File>
<Filter
Name="Boot"
>
<File
RelativePath=".\Src\Boot\Boot.cpp"
>
</File>
<File
RelativePath=".\Src\Boot\Boot.h"
>
</File>
<File
RelativePath=".\Src\Boot\Boot_DOL.cpp"
>
</File>
<File
RelativePath=".\Src\Boot\Boot_DOL.h"
>
</File>
<File
RelativePath=".\Src\Boot\Boot_ELF.cpp"
>
</File>
<File
RelativePath=".\Src\Boot\Boot_ELF.h"
>
</File>
<File
RelativePath=".\Src\Boot\ElfReader.cpp"
>
</File>
<File
RelativePath=".\Src\Boot\ElfReader.h"
>
</File>
<File
RelativePath=".\Src\Boot\ElfTypes.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="IPC HLE"
File diff suppressed because it is too large Load Diff
@@ -72,13 +72,13 @@ void CInterpreter::lfdu(UGeckoInstruction _inst)
void CInterpreter::lfdux(UGeckoInstruction _inst)
{
u32 uAddress = Helper_Get_EA_UX(_inst);
riPS0(_inst.FS) = Memory::Read_U64(uAddress);
riPS0(_inst.FD) = Memory::Read_U64(uAddress);
m_GPR[_inst.RA] = uAddress;
}
void CInterpreter::lfdx(UGeckoInstruction _inst)
{
riPS0(_inst.FS) = Memory::Read_U64(Helper_Get_EA_X(_inst));
riPS0(_inst.FD) = Memory::Read_U64(Helper_Get_EA_X(_inst));
}
void CInterpreter::lfs(UGeckoInstruction _inst)
@@ -149,7 +149,7 @@ void CInterpreter::lmw(UGeckoInstruction _inst)
return;
}
m_GPR[iReg] = TempReg;
m_GPR[iReg] = TempReg;
}
}
@@ -0,0 +1,337 @@
// 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/
#include <math.h>
#include "Interpreter.h"
#include "../../HW/Memmap.h"
// dequantize table
const float m_dequantizeTable[] =
{
1.0 / (1 << 0), 1.0 / (1 << 1), 1.0 / (1 << 2), 1.0 / (1 << 3),
1.0 / (1 << 4), 1.0 / (1 << 5), 1.0 / (1 << 6), 1.0 / (1 << 7),
1.0 / (1 << 8), 1.0 / (1 << 9), 1.0 / (1 << 10), 1.0 / (1 << 11),
1.0 / (1 << 12), 1.0 / (1 << 13), 1.0 / (1 << 14), 1.0 / (1 << 15),
1.0 / (1 << 16), 1.0 / (1 << 17), 1.0 / (1 << 18), 1.0 / (1 << 19),
1.0 / (1 << 20), 1.0 / (1 << 21), 1.0 / (1 << 22), 1.0 / (1 << 23),
1.0 / (1 << 24), 1.0 / (1 << 25), 1.0 / (1 << 26), 1.0 / (1 << 27),
1.0 / (1 << 28), 1.0 / (1 << 29), 1.0 / (1 << 30), 1.0 / (1 << 31),
(1ULL << 32), (1 << 31), (1 << 30), (1 << 29),
(1 << 28), (1 << 27), (1 << 26), (1 << 25),
(1 << 24), (1 << 23), (1 << 22), (1 << 21),
(1 << 20), (1 << 19), (1 << 18), (1 << 17),
(1 << 16), (1 << 15), (1 << 14), (1 << 13),
(1 << 12), (1 << 11), (1 << 10), (1 << 9),
(1 << 8), (1 << 7), (1 << 6), (1 << 5),
(1 << 4), (1 << 3), (1 << 2), (1 << 1),
};
// quantize table
const float m_quantizeTable[] =
{
(1 << 0), (1 << 1), (1 << 2), (1 << 3),
(1 << 4), (1 << 5), (1 << 6), (1 << 7),
(1 << 8), (1 << 9), (1 << 10), (1 << 11),
(1 << 12), (1 << 13), (1 << 14), (1 << 15),
(1 << 16), (1 << 17), (1 << 18), (1 << 19),
(1 << 20), (1 << 21), (1 << 22), (1 << 23),
(1 << 24), (1 << 25), (1 << 26), (1 << 27),
(1 << 28), (1 << 29), (1 << 30), (1 << 31),
1.0 / (1ULL << 32), 1.0 / (1 << 31), 1.0 / (1 << 30), 1.0 / (1 << 29),
1.0 / (1 << 28), 1.0 / (1 << 27), 1.0 / (1 << 26), 1.0 / (1 << 25),
1.0 / (1 << 24), 1.0 / (1 << 23), 1.0 / (1 << 22), 1.0 / (1 << 21),
1.0 / (1 << 20), 1.0 / (1 << 19), 1.0 / (1 << 18), 1.0 / (1 << 17),
1.0 / (1 << 16), 1.0 / (1 << 15), 1.0 / (1 << 14), 1.0 / (1 << 13),
1.0 / (1 << 12), 1.0 / (1 << 11), 1.0 / (1 << 10), 1.0 / (1 << 9),
1.0 / (1 << 8), 1.0 / (1 << 7), 1.0 / (1 << 6), 1.0 / (1 << 5),
1.0 / (1 << 4), 1.0 / (1 << 3), 1.0 / (1 << 2), 1.0 / (1 << 1),
};
template <class T>
inline T CLAMP(T a, T bottom, T top) {
if (a > top) return top;
if (a < bottom) return bottom;
return a;
}
void CInterpreter::Helper_Quantize(const u32 _Addr, const float _fValue,
const EQuantizeType _quantizeType, const unsigned int _uScale)
{
switch(_quantizeType)
{
case QUANTIZE_FLOAT:
Memory::Write_U32(*(u32*)&_fValue,_Addr);
break;
// used for THP player
case QUANTIZE_U8:
{
float fResult = CLAMP(_fValue * m_quantizeTable[_uScale], 0.0f, 255.0f);
Memory::Write_U8((u8)fResult, _Addr);
}
break;
case QUANTIZE_U16:
{
float fResult = CLAMP(_fValue * m_quantizeTable[_uScale], 0.0f, 65535.0f);
Memory::Write_U16((u16)fResult, _Addr);
}
break;
case QUANTIZE_S8:
{
float fResult = CLAMP(_fValue * m_quantizeTable[_uScale], -128.0f, 127.0f);
Memory::Write_U8((u8)(s8)fResult, _Addr);
}
break;
case QUANTIZE_S16:
{
float fResult = CLAMP(_fValue * m_quantizeTable[_uScale], -32768.0f, 32767.0f);
Memory::Write_U16((u16)(s16)fResult, _Addr);
}
break;
default:
_dbg_assert_msg_(GEKKO,0,"PS dequantize","Unknown type to read");
break;
}
}
float CInterpreter::Helper_Dequantize(const u32 _Addr, const EQuantizeType _quantizeType,
const unsigned int _uScale)
{
// dequantize the value
float fResult;
switch(_quantizeType)
{
case QUANTIZE_FLOAT:
{
u32 dwValue = Memory::Read_U32(_Addr);
fResult = *(float*)&dwValue;
}
break;
case QUANTIZE_U8:
fResult = static_cast<float>(Memory::Read_U8(_Addr)) * m_dequantizeTable[_uScale];
break;
case QUANTIZE_U16:
fResult = static_cast<float>(Memory::Read_U16(_Addr)) * m_dequantizeTable[_uScale];
break;
case QUANTIZE_S8:
fResult = static_cast<float>((s8)Memory::Read_U8(_Addr)) * m_dequantizeTable[_uScale];
break;
// used for THP player
case QUANTIZE_S16:
fResult = static_cast<float>((s16)Memory::Read_U16(_Addr)) * m_dequantizeTable[_uScale];
break;
default:
_dbg_assert_msg_(GEKKO,0,"PS dequantize","Unknown type to read");
fResult = 0;
break;
}
return fResult;
}
void CInterpreter::psq_l(UGeckoInstruction _inst)
{
const UGQR gqr(rSPR(SPR_GQR0 + _inst.I));
const EQuantizeType ldType = static_cast<EQuantizeType>(gqr.LD_TYPE);
const unsigned int ldScale = gqr.LD_SCALE;
const u32 EA = _inst.RA ? (m_GPR[_inst.RA] + _inst.SIMM_12) : _inst.SIMM_12;
int c = 4;
if ((ldType == QUANTIZE_U8) || (ldType == QUANTIZE_S8)) c = 0x1;
if ((ldType == QUANTIZE_U16) || (ldType == QUANTIZE_S16)) c = 0x2;
if (_inst.W == 0)
{
rPS0(_inst.RS) = Helper_Dequantize(EA, ldType, ldScale);
rPS1(_inst.RS) = Helper_Dequantize(EA+c, ldType, ldScale);
}
else
{
rPS0(_inst.RS) = Helper_Dequantize(EA, ldType, ldScale);
rPS1(_inst.RS) = 1.0f;
}
}
void CInterpreter::psq_lu(UGeckoInstruction _inst)
{
const UGQR gqr(rSPR(SPR_GQR0 + _inst.I));
const EQuantizeType ldType = static_cast<EQuantizeType>(gqr.LD_TYPE);
const unsigned int ldScale = gqr.LD_SCALE;
const u32 EA = m_GPR[_inst.RA] + _inst.SIMM_12;
int c = 4;
if ((ldType == 4) || (ldType == 6)) c = 0x1;
if ((ldType == 5) || (ldType == 7)) c = 0x2;
if (_inst.W == 0)
{
rPS0(_inst.RS) = Helper_Dequantize( EA, ldType, ldScale );
rPS1(_inst.RS) = Helper_Dequantize( EA+c, ldType, ldScale );
}
else
{
rPS0(_inst.RS) = Helper_Dequantize( EA, ldType, ldScale );
rPS1(_inst.RS) = 1.0f;
}
m_GPR[_inst.RA] = EA;
}
void CInterpreter::psq_st(UGeckoInstruction _inst)
{
const UGQR gqr(rSPR(SPR_GQR0 + _inst.I));
const EQuantizeType stType = static_cast<EQuantizeType>(gqr.ST_TYPE);
const unsigned int stScale = gqr.ST_SCALE;
const u32 EA = _inst.RA ? (m_GPR[_inst.RA] + _inst.SIMM_12) : _inst.SIMM_12;
int c = 4;
if ((stType == 4) || (stType == 6)) c = 0x1;
if ((stType == 5) || (stType == 7)) c = 0x2;
if (_inst.W == 0)
{
Helper_Quantize( EA, (float)rPS0(_inst.RS), stType, stScale );
Helper_Quantize( EA+c, (float)rPS1(_inst.RS), stType, stScale );
}
else
{
Helper_Quantize( EA, (float)rPS0(_inst.RS), stType, stScale );
}
}
void CInterpreter::psq_stu(UGeckoInstruction _inst)
{
const UGQR gqr(rSPR(SPR_GQR0 + _inst.I));
const EQuantizeType stType = static_cast<EQuantizeType>(gqr.ST_TYPE);
const unsigned int stScale = gqr.ST_SCALE;
const u32 EA = m_GPR[_inst.RA] + _inst.SIMM_12;
int c = 4;
if ((stType == 4) || (stType == 6)) c = 0x1;
if ((stType == 5) || (stType == 7)) c = 0x2;
if (_inst.W == 0)
{
Helper_Quantize(EA, (float)rPS0(_inst.RS), stType, stScale);
Helper_Quantize(EA+c, (float)rPS1(_inst.RS), stType, stScale);
}
else
{
Helper_Quantize(EA, (float)rPS0(_inst.RS), stType, stScale);
}
m_GPR[_inst.RA] = EA;
}
void CInterpreter::psq_lx(UGeckoInstruction _inst)
{
const UGQR gqr(rSPR(SPR_GQR0 + _inst.Ix));
const EQuantizeType ldType = static_cast<EQuantizeType>(gqr.LD_TYPE);
const unsigned int ldScale = gqr.LD_SCALE;
const u32 EA = _inst.RA ? (m_GPR[_inst.RA] + m_GPR[_inst.RB]) : m_GPR[_inst.RB];
int c = 4;
if ((ldType == 4) || (ldType == 6)) c = 0x1;
if ((ldType == 5) || (ldType == 7)) c = 0x2;
if (_inst.Wx == 0)
{
rPS0(_inst.RS) = Helper_Dequantize( EA, ldType, ldScale );
rPS1(_inst.RS) = Helper_Dequantize( EA+c, ldType, ldScale );
}
else
{
rPS0(_inst.RS) = Helper_Dequantize( EA, ldType, ldScale );
rPS1(_inst.RS) = 1.0f;
}
}
void CInterpreter::psq_stx(UGeckoInstruction _inst)
{
const UGQR gqr(rSPR(SPR_GQR0 + _inst.Ix));
const EQuantizeType stType = static_cast<EQuantizeType>(gqr.ST_TYPE);
const unsigned int stScale = gqr.ST_SCALE;
const u32 EA = _inst.RA ? (m_GPR[_inst.RA] + m_GPR[_inst.RB]) : m_GPR[_inst.RB];
int c = 4;
if ((stType == 4) || (stType == 6)) c = 0x1;
if ((stType == 5) || (stType == 7)) c = 0x2;
if (_inst.Wx == 0)
{
Helper_Quantize(EA, (float)rPS0(_inst.RS), stType, stScale);
Helper_Quantize(EA+c, (float)rPS1(_inst.RS), stType, stScale);
}
else
{
Helper_Quantize(EA, (float)rPS0(_inst.RS), stType, stScale);
}
}
void CInterpreter::psq_lux(UGeckoInstruction _inst)
{
const UGQR gqr(rSPR(SPR_GQR0 + _inst.Ix));
const EQuantizeType ldType = static_cast<EQuantizeType>(gqr.LD_TYPE);
const unsigned int ldScale = gqr.LD_SCALE;
const u32 EA = m_GPR[_inst.RA] + m_GPR[_inst.RB];
int c = 4;
if ((ldType == 4) || (ldType == 6)) c = 0x1;
if ((ldType == 5) || (ldType == 7)) c = 0x2;
if (_inst.Wx == 0)
{
rPS0(_inst.RS) = Helper_Dequantize( EA, ldType, ldScale );
rPS1(_inst.RS) = Helper_Dequantize( EA+c, ldType, ldScale );
}
else
{
rPS0(_inst.RS) = Helper_Dequantize( EA, ldType, ldScale );
rPS1(_inst.RS) = 1.0f;
}
m_GPR[_inst.RA] = EA;
}
void CInterpreter::psq_stux(UGeckoInstruction _inst)
{
const UGQR gqr(rSPR(SPR_GQR0 + _inst.Ix));
const EQuantizeType stType = static_cast<EQuantizeType>(gqr.ST_TYPE);
const unsigned int stScale = gqr.ST_SCALE;
const u32 EA = m_GPR[_inst.RA] + m_GPR[_inst.RB];
int c = 4;
if ((stType == 4) || (stType == 6)) c = 0x1;
if ((stType == 5) || (stType == 7)) c = 0x2;
if (_inst.Wx == 0)
{
Helper_Quantize(EA, (float)rPS0(_inst.RS), stType, stScale);
Helper_Quantize(EA+c, (float)rPS1(_inst.RS), stType, stScale);
}
else
{
Helper_Quantize(EA, (float)rPS0(_inst.RS), stType, stScale);
}
m_GPR[_inst.RA] = EA;
}
File diff suppressed because it is too large Load Diff
@@ -34,12 +34,22 @@ static const unsigned short FPU_ROUND_MASK = 3 << 10;
#include "../../Core.h"
#include "Interpreter.h"
/*
Most of these are together with fctiwx
mffsx: 800c3624
mffsx: 80043c98
mffsx: 8003dd48
mffsx: 8003dd9c
mffsx: 80036608
mffsx: 80036650 (huh?)
*/
// TODO(ector): More proper handling of SSE state.
// That is, set rounding mode etc when entering jit code or the interpreter loop
// Restore rounding mode when calling anything external
void UpdateSSEState(int round, bool daz)
void UpdateSSEState()
{
u32 csr = _mm_getcsr();
@@ -51,14 +61,14 @@ void UpdateSSEState(int round, bool daz)
1,
};
csr = csr & 0x9FFF;
csr |= ssetable[round] << 13;
csr |= ssetable[FPSCR.RN] << 13;
// Also handle denormals as zero (FZ + DAZ)
csr &= ~0x8020;
// SETTING DAZ KILLS BEYOND GOOD AND EVIL
// if (daz)
// csr |= 0x8020;
// SETTING FTZ+DAZ KILLS BEYOND GOOD AND EVIL
//if (daz)
// csr |= 0x20; // Only set DAZ //0x8020;
_mm_setcsr(csr);
}
@@ -72,7 +82,6 @@ void RestoreSSEState()
void UpdateFPSCR(UReg_FPSCR fp)
{
// Set FPU rounding mode to mimic the PowerPC's
int round = fp.RN;
#ifdef _M_IX86
// This shouldn't really be needed anymore since we use SSE
#ifdef _WIN32
@@ -83,7 +92,7 @@ void UpdateFPSCR(UReg_FPSCR fp)
_RC_UP,
_RC_DOWN
};
_set_controlfp(_MCW_RC, table[round]);
_set_controlfp(_MCW_RC, table[fp.RN]);
#else
const unsigned short table[4] =
{
@@ -94,19 +103,48 @@ void UpdateFPSCR(UReg_FPSCR fp)
};
unsigned short mode;
asm ("fstcw %0" : : "m" (mode));
mode = (mode & ~FPU_ROUND_MASK) | table[round];
mode = (mode & ~FPU_ROUND_MASK) | table[fp.RN];
asm ("fldcw %0" : : "m" (mode));
#endif
#endif
if (fp.VE || fp.OE || fp.UE || fp.ZE || fp.XE)
{
PanicAlert("FPSCR - exceptions enabled. Please report.");
}
// Also corresponding SSE rounding mode setting
UpdateSSEState(round, fp.NI ? true : false);
UpdateSSEState();
}
void CInterpreter::mcrfs(UGeckoInstruction _inst)
{
// TODO(ector): check a ppc manual for this one
u32 fpflags = ((FPSCR.Hex >> (4*(_inst.CRFS))) & 0xF);
FPSCR.Hex &= ~(0xF0000000 >> (_inst.CRFS*4));
switch (_inst.CRFS) {
case 0:
FPSCR.FX = 0;
FPSCR.OX = 0;
break;
case 1:
FPSCR.UX = 0;
FPSCR.ZX = 0;
FPSCR.XX = 0;
FPSCR.VXSNAN = 0;
break;
case 2:
FPSCR.VXISI = 0;
FPSCR.VXIDI = 0;
FPSCR.VXZDZ = 0;
FPSCR.VXIMZ = 0;
break;
case 3:
FPSCR.VXVC = 0;
break;
case 5:
FPSCR.VXSOFT = 0;
FPSCR.VXSQRT = 0;
FPSCR.VXCVI = 0;
break;
}
SetCRField(_inst.CRFD, fpflags);
UpdateFPSCR(FPSCR);
}
@@ -127,8 +165,6 @@ void CInterpreter::mcrfs(UGeckoInstruction _inst)
#define MXCSR_ROUND (16384|8192)
#define MXCSR_FLUSH 32768
void CInterpreter::mffsx(UGeckoInstruction _inst)
{
// load from FPSCR
@@ -136,31 +172,35 @@ void CInterpreter::mffsx(UGeckoInstruction _inst)
// TODO(ector): grab all overflow flags etc and set them in FPSCR
riPS0(_inst.FD) = (u64)FPSCR.Hex;
if (_inst.Rc) PanicAlert("mffsx: inst_.Rc");
}
void CInterpreter::mtfsb0x(UGeckoInstruction _inst)
{
FPSCR.Hex &= (~(0x80000000 >> _inst.CRBD));
UpdateFPSCR(FPSCR);
if (_inst.Rc) PanicAlert("mtfsb0x: inst_.Rc");
}
void CInterpreter::mtfsb1x(UGeckoInstruction _inst)
{
FPSCR.Hex |= 0x80000000 >> _inst.CRBD;
UpdateFPSCR(FPSCR);
if (_inst.Rc) PanicAlert("mtfsb1x: inst_.Rc");
}
void CInterpreter::mtfsfix(UGeckoInstruction _inst)
{
u32 mask = (0xF0000000 >> (4*_inst.CRFD));
u32 mask = (0xF0000000 >> (4 * _inst.CRFD));
u32 imm = (_inst.hex << 16) & 0xF0000000;
FPSCR.Hex = (FPSCR.Hex & ~mask) | (imm >> (4*_inst.CRFD));
FPSCR.Hex = (FPSCR.Hex & ~mask) | (imm >> (4 * _inst.CRFD));
UpdateFPSCR(FPSCR);
if (_inst.Rc) PanicAlert("mtfsfix: inst_.Rc");
}
void CInterpreter::mtfsfx(UGeckoInstruction _inst)
{
u32 fm = _inst.FM;
u32 fm = _inst.FM;
u32 m = 0;
for (int i = 0; i < 8; i++) { //7?? todo check
if (fm & (1 << i))
@@ -169,6 +209,7 @@ void CInterpreter::mtfsfx(UGeckoInstruction _inst)
FPSCR.Hex = (FPSCR.Hex & ~m) | ((u32)(riPS0(_inst.FB)) & m);
UpdateFPSCR(FPSCR);
if (_inst.Rc) PanicAlert("mtfsfx: inst_.Rc");
}
void CInterpreter::mcrxr(UGeckoInstruction _inst)
@@ -240,7 +281,7 @@ void CInterpreter::mtsrin(UGeckoInstruction _inst)
void CInterpreter::mftb(UGeckoInstruction _inst)
{
int iIndex = (_inst.TBR >> 5) | ((_inst.TBR&0x1F) << 5);
int iIndex = (_inst.TBR >> 5) | ((_inst.TBR & 0x1F) << 5);
if (iIndex == 268) m_GPR[_inst.RD] = TL;
else if (iIndex == 269) m_GPR[_inst.RD] = TU;
else _dbg_assert_(GEKKO,0);
@@ -449,4 +490,3 @@ void CInterpreter::isync(UGeckoInstruction _inst)
{
//shouldnt do anything
}
+20 -6
View File
@@ -231,6 +231,21 @@ namespace Jit64
JitState js;
JitOptions jo;
void Init()
{
jo.optimizeStack = true;
jo.enableBlocklink = true; // Speed boost, but not 100% safe
#ifdef _M_X64
jo.enableFastMem = Core::GetStartupParameter().bUseFastMem;
#else
jo.enableFastMem = false;
#endif
jo.assumeFPLoadFromMem = true;
jo.fpAccurateFlags = true;
jo.optimizeGatherPipe = true;
jo.interpretFPU = false;
}
void WriteCallInterpreter(UGeckoInstruction _inst)
{
gpr.Flush(FLUSH_ALL);
@@ -263,12 +278,6 @@ namespace Jit64
// Yup, just don't do anything.
}
// RESULTS (running kururin with optimizations on)
// at block 13968 they diverge.
// linux goes to 8010fe54
// windoze goes to 8010feb0
// after they they are completely out of sync.
// branches from the cmp result of r0, which comes from an lbz (loaded from stack)
static const bool ImHereDebug = false;
static const bool ImHereLog = false;
static std::map<u32, int> been_here;
@@ -403,7 +412,12 @@ namespace Jit64
js.op = &ops[i];
js.instructionNumber = i;
if (i == (int)size - 1) js.isLastInstruction = true;
// const GekkoOpInfo *info = GetOpInfo();
// if (js.isLastInstruction)
if (jo.interpretFPU && PPCTables::UsesFPU(ops[i].inst))
Default(ops[i].inst);
else
PPCTables::CompileInstruction(ops[i].inst);
// else
// Default(ops[i].inst);
+3
View File
@@ -70,11 +70,14 @@ namespace Jit64
bool fpAccurateFlags;
bool enableFastMem;
bool optimizeGatherPipe;
bool interpretFPU;
};
extern JitState js;
extern JitOptions jo;
void Init();
void Default(UGeckoInstruction _inst);
void DoNothing(UGeckoInstruction _inst);
@@ -76,17 +76,6 @@ namespace Jit64
void InitCache()
{
jo.optimizeStack = true;
jo.enableBlocklink = true; // Speed boost, but not 100% safe
#ifdef _M_X64
jo.enableFastMem = Core::GetStartupParameter().bUseFastMem;
#else
jo.enableFastMem = false;
#endif
jo.assumeFPLoadFromMem = true;
jo.fpAccurateFlags = true;
jo.optimizeGatherPipe = true;
codeCache = (u8*)AllocateExecutableMemory(CODE_SIZE);
genFunctions = (u8*)AllocateExecutableMemory(GEN_SIZE);
trampolineCache = (u8*)AllocateExecutableMemory(TRAMPOLINE_SIZE);
@@ -17,6 +17,7 @@
#include "JitCore.h"
#include "JitCache.h"
#include "JitAsm.h"
#include "Jit.h"
#include "../../HW/Memmap.h"
#include "../../HW/CPU.h"
@@ -31,6 +32,7 @@ namespace Jit64
{
void Jit64Core::Init()
{
::Jit64::Init();
InitCache();
Asm::compareEnabled = Core::g_CoreStartupParameter.bRunCompareClient;
}
@@ -122,9 +122,9 @@ namespace Jit64
bool doFullTest = (inst.BO & 16) == 0 && (inst.BO & 4) == 0;
bool ctrDecremented = false;
if ((inst.BO & 16) == 0) // Test CR with a combination of bits
if ((inst.BO & 16) == 0) // Test a CR bit
{
TEST(32, M(&CR), Imm32(0x80000000>>inst.BI));
TEST(32, M(&CR), Imm32(0x80000000 >> inst.BI));
if (inst.BO & 8) // Conditional branch
branch = CC_NZ;
else
@@ -150,7 +150,6 @@ namespace Jit64
fpr.UnlockAll();
}
void fmrx(UGeckoInstruction inst)
{
INSTRUCTION_START;
@@ -25,6 +25,7 @@
#include "Jit.h"
#include "JitCache.h"
#include "JitRegCache.h"
#include "Jit_Util.h"
// TODO
// ps_madds0
@@ -198,7 +199,7 @@ namespace Jit64
op(XMM0, Gen::R(XMM1));
MOVAPD(fpr.RX(d), Gen::R(XMM0));
}
//fpr.SetDirty(fpr.RX(d));
ForceSinglePrecisionP(fpr.RX(d));
fpr.UnlockAll();
}
@@ -308,6 +309,7 @@ namespace Jit64
}
fpr.LoadToX64(d, false);
MOVAPD(fpr.RX(d), Gen::R(XMM0));
ForceSinglePrecisionP(fpr.RX(d));
fpr.UnlockAll();
}
+44 -1
View File
@@ -19,6 +19,7 @@
#include "Common.h"
#include "PPCTables.h"
#include "StringUtil.h"
#include "Interpreter/Interpreter.h"
#if defined(_M_IX86) || defined(_M_X64)
@@ -409,7 +410,7 @@ GekkoOPTemplate table59[] =
{18, CInterpreter::fdivsx, Jit64::fp_arith_s, {"fdivsx", OPTYPE_FPU, FL_RC_BIT_F, 16}},
{20, CInterpreter::fsubsx, Jit64::fp_arith_s, {"fsubsx", OPTYPE_FPU, FL_RC_BIT_F}},
{21, CInterpreter::faddsx, Jit64::fp_arith_s, {"faddsx", OPTYPE_FPU, FL_RC_BIT_F}},
{22, CInterpreter::fsqrtsx, Jit64::Default, {"frsqrtex", OPTYPE_FPU, FL_RC_BIT_F}},
// {22, CInterpreter::fsqrtsx, Jit64::Default, {"fsqrtsx", OPTYPE_FPU, FL_RC_BIT_F}}, // Not implemented on gekko
{24, CInterpreter::fresx, Jit64::Default, {"fresx", OPTYPE_FPU, FL_RC_BIT_F}},
{25, CInterpreter::fmulsx, Jit64::fp_arith_s, {"fmulsx", OPTYPE_FPU, FL_RC_BIT_F}},
{28, CInterpreter::fmsubsx, Jit64::fmaddXX, {"fmsubsx", OPTYPE_FPU, FL_RC_BIT_F}},
@@ -637,11 +638,26 @@ void PPCTables::InitTables()
m_allInstructions[m_numInstructions++] = &table63[i].opinfo;
for (int i = 0; i < (int)(sizeof(table63_2) / sizeof(GekkoOPTemplate)); i++)
m_allInstructions[m_numInstructions++] = &table63_2[i].opinfo;
if (m_numInstructions >= 2048) {
PanicAlert("m_allInstructions underdimensioned");
}
}
namespace {
std::vector<u32> rsplocations;
}
void PPCTables::CompileInstruction(UGeckoInstruction _inst)
{
dynaOpTable[_inst.OPCD](_inst);
GekkoOPInfo *info = GetOpInfo(_inst);
if (info) {
if (!strcmp(info->opname, "mffsx")) {
rsplocations.push_back(Jit64::js.compilerPC);
}
info->compileCount++;
info->lastUse = Jit64::js.compilerPC;
}
}
bool PPCTables::IsValidInstruction(UGeckoInstruction _instCode)
@@ -685,3 +701,30 @@ void PPCTables::PrintInstructionRunCounts()
LOG(GEKKO, "%s : %i", temp[i].name,temp[i].count);
}
}
void PPCTables::LogCompiledInstructions()
{
static int time = 0;
FILE *f = fopen(StringFromFormat("inst_log%i.txt", time).c_str(), "w");
for (int i = 0; i < m_numInstructions; i++)
{
if (m_allInstructions[i]->compileCount > 0) {
fprintf(f, "%s\t%i\t%i\t%08x\n", m_allInstructions[i]->opname, m_allInstructions[i]->compileCount, m_allInstructions[i]->runCount, m_allInstructions[i]->lastUse);
}
}
fclose(f);
f = fopen(StringFromFormat("inst_not%i.txt", time).c_str(), "w");
for (int i = 0; i < m_numInstructions; i++)
{
if (m_allInstructions[i]->compileCount == 0) {
fprintf(f, "%s\t%i\t%i\n", m_allInstructions[i]->opname, m_allInstructions[i]->compileCount, m_allInstructions[i]->runCount);
}
}
fclose(f);
f = fopen(StringFromFormat("rsp_at.txt", time).c_str(), "w");
for (int i = 0; i < rsplocations.size(); i++) {
fprintf(f, "mffsx: %08x\n", rsplocations[i]);
}
fclose(f);
time++;
}
+3
View File
@@ -73,6 +73,8 @@ struct GekkoOPInfo
int flags;
int numCyclesMinusOne;
int runCount;
int compileCount;
u32 lastUse;
};
@@ -92,6 +94,7 @@ public:
static void CountInstruction(UGeckoInstruction _inst);
static void PrintInstructionRunCounts();
static void LogCompiledInstructions();
static void CompileInstruction(UGeckoInstruction _inst);
};
+1
View File
@@ -63,6 +63,7 @@ files = ["Console.cpp",
"PowerPC/Interpreter/Interpreter_FloatingPoint.cpp",
"PowerPC/Interpreter/Interpreter_Paired.cpp",
"PowerPC/Interpreter/Interpreter_LoadStore.cpp",
"PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp",
"PowerPC/Interpreter/Interpreter_SystemRegisters.cpp",
"PowerPC/Jit64/Jit.cpp",
"PowerPC/Jit64/JitCore.cpp",
@@ -46,6 +46,7 @@
#include "Debugger/PPCDebugInterface.h"
#include "Debugger/Debugger_SymbolMap.h"
#include "PowerPC/PPCAnalyst.h"
#include "PowerPC/PPCTables.h"
#include "PowerPC/Jit64/Jit.h"
#include "PowerPC/Jit64/JitCache.h"
@@ -71,6 +72,9 @@ BEGIN_EVENT_TABLE(CCodeWindow, wxFrame)
EVT_MENU(IDM_SCANFUNCTIONS, CCodeWindow::OnSymbolsMenu)
EVT_MENU(IDM_LOADMAPFILE, CCodeWindow::OnSymbolsMenu)
EVT_MENU(IDM_SAVEMAPFILE, CCodeWindow::OnSymbolsMenu)
EVT_MENU(IDM_CLEARCODECACHE, CCodeWindow::OnJitMenu)
EVT_MENU(IDM_LOGINSTRUCTIONS, CCodeWindow::OnJitMenu)
// toolbar
EVT_MENU(IDM_DEBUG_GO, CCodeWindow::OnCodeStep)
EVT_MENU(IDM_STEP, CCodeWindow::OnCodeStep)
@@ -244,6 +248,7 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam
{
wxMenu *pJitMenu = new wxMenu;
pJitMenu->Append(IDM_CLEARCODECACHE, _T("&Clear code cache"));
pJitMenu->Append(IDM_LOGINSTRUCTIONS, _T("&Log JIT instruction coverage"));
pMenuBar->Append(pJitMenu, _T("&JIT"));
}
@@ -275,6 +280,9 @@ void CCodeWindow::OnJitMenu(wxCommandEvent& event)
case IDM_CLEARCODECACHE:
Jit64::ClearCache();
break;
case IDM_LOGINSTRUCTIONS:
PPCTables::LogCompiledInstructions();
break;
}
}
+1
View File
@@ -80,6 +80,7 @@ class CCodeWindow
IDM_BREAKPOINTWINDOW,
IDM_MEMORYWINDOW,
IDM_SCANFUNCTIONS,
IDM_LOGINSTRUCTIONS,
IDM_LOADMAPFILE,
IDM_SAVEMAPFILE,
IDM_CLEARCODECACHE,

Some files were not shown because too many files have changed in this diff Show More