mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
DSPJit: disabled NR again until we fix DSPEmitter::increase_addr_reg.
And to help test things like that: DSPJitTester (use with caution on x64, most likely fails there; r5250 might be why) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5306 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
84
Source/UnitTests/AudioJitTests.cpp
Normal file
84
Source/UnitTests/AudioJitTests.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
#include "DSPJitTester.h"
|
||||
|
||||
void nx_dr()
|
||||
{
|
||||
SDSP test_dsp;
|
||||
DSPJitTester tester(0x40, 0x04);
|
||||
|
||||
for (u16 input_reg = 0; input_reg < 50; input_reg++)
|
||||
for (u16 input_wr0 = 0; input_wr0 < 10; input_wr0++)
|
||||
{
|
||||
memset(&test_dsp, 0, sizeof(SDSP));
|
||||
test_dsp.r[DSP_REG_WR0] = input_wr0;
|
||||
test_dsp.r[0] = input_reg;
|
||||
if (!tester.Test(test_dsp))
|
||||
{
|
||||
printf("%s Test failed: in = 0x%04x, wr0 = 0x%04x > int = 0x%04x, jit = 0x%04x\n",
|
||||
tester.GetInstructionName(),
|
||||
input_reg, input_wr0,
|
||||
tester.GetLastInterpreterDSP().r[0], tester.GetLastJitDSP().r[0]);
|
||||
}
|
||||
}
|
||||
tester.Report();
|
||||
}
|
||||
|
||||
void nx_ir()
|
||||
{
|
||||
SDSP test_dsp;
|
||||
DSPJitTester tester(0x40, 0x08);
|
||||
|
||||
for (u16 input_reg = 0; input_reg < 50; input_reg++)
|
||||
for (u16 input_wr0 = 0; input_wr0 < 10; input_wr0++)
|
||||
{
|
||||
memset(&test_dsp, 0, sizeof(SDSP));
|
||||
test_dsp.r[DSP_REG_WR0] = input_wr0;
|
||||
test_dsp.r[0] = input_reg;
|
||||
if (!tester.Test(test_dsp))
|
||||
{
|
||||
printf("%s Test failed: in = 0x%04x, wr0 = 0x%04x > int = 0x%04x, jit = 0x%04x\n",
|
||||
tester.GetInstructionName(),
|
||||
input_reg, input_wr0,
|
||||
tester.GetLastInterpreterDSP().r[0], tester.GetLastJitDSP().r[0]);
|
||||
}
|
||||
}
|
||||
tester.Report();
|
||||
}
|
||||
|
||||
void nx_nr()
|
||||
{
|
||||
SDSP test_dsp;
|
||||
DSPJitTester tester(0x40, 0x0c);
|
||||
|
||||
for (u16 input_reg = 0; input_reg < 50; input_reg++)
|
||||
for (u16 input_wr0 = 0; input_wr0 < 10; input_wr0++)
|
||||
{
|
||||
memset(&test_dsp, 0, sizeof(SDSP));
|
||||
test_dsp.r[DSP_REG_WR0] = input_wr0;
|
||||
test_dsp.r[0] = input_reg;
|
||||
if (!tester.Test(test_dsp))
|
||||
{
|
||||
printf("%s Test failed: in = 0x%04x, wr0 = 0x%04x > int = 0x%04x, jit = 0x%04x\n",
|
||||
tester.GetInstructionName(),
|
||||
input_reg, input_wr0,
|
||||
tester.GetLastInterpreterDSP().r[0], tester.GetLastJitDSP().r[0]);
|
||||
}
|
||||
}
|
||||
tester.Report();
|
||||
}
|
||||
|
||||
void AudioJitTests()
|
||||
{
|
||||
DSPJitTester::Initialize();
|
||||
|
||||
nx_ir();
|
||||
nx_dr();
|
||||
//nx_nr();
|
||||
}
|
||||
|
||||
//required to be able to link against DSPCore
|
||||
void DSPHost_UpdateDebugger() { }
|
||||
unsigned int DSPHost_CodeLoaded(unsigned const char*, int) { return 0; }
|
||||
void DSPHost_InterruptRequest() { }
|
||||
bool DSPHost_OnThread() { return false; }
|
||||
void DSPHost_WriteHostMemory(unsigned char, unsigned int) { }
|
||||
unsigned char DSPHost_ReadHostMemory(unsigned int) { return 0; }
|
71
Source/UnitTests/DSPJitTester.cpp
Normal file
71
Source/UnitTests/DSPJitTester.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
#include "DSPJitTester.h"
|
||||
|
||||
bool DSPJitTester::Test(SDSP dsp_settings)
|
||||
{
|
||||
if (be_verbose)
|
||||
printf("Running %s: ", instruction_name);
|
||||
|
||||
last_int_dsp = RunInterpreter(dsp_settings);
|
||||
last_jit_dsp = RunJit(dsp_settings);
|
||||
|
||||
run_count++;
|
||||
bool success = AreEqual(last_int_dsp, last_jit_dsp);
|
||||
if (!success)
|
||||
fail_count++;
|
||||
return success;
|
||||
}
|
||||
SDSP DSPJitTester::RunInterpreter(SDSP dsp_settings)
|
||||
{
|
||||
ResetInterpreter();
|
||||
memcpy(&g_dsp, &dsp_settings, sizeof(SDSP));
|
||||
ExecuteInstruction(instruction);
|
||||
|
||||
return g_dsp;
|
||||
}
|
||||
SDSP DSPJitTester::RunJit(SDSP dsp_settings)
|
||||
{
|
||||
ResetJit();
|
||||
memcpy(&g_dsp, &dsp_settings, sizeof(SDSP));
|
||||
const u8* code = jit.GetCodePtr();
|
||||
jit.WriteCallInterpreter(instruction);
|
||||
jit.RET();
|
||||
((void(*)())code)();
|
||||
|
||||
return g_dsp;
|
||||
}
|
||||
void DSPJitTester::ResetInterpreter()
|
||||
{
|
||||
for (int i=0; i < WRITEBACKLOGSIZE; i++)
|
||||
writeBackLogIdx[i] = -1;
|
||||
}
|
||||
void DSPJitTester::ResetJit()
|
||||
{
|
||||
jit.ClearCodeSpace();
|
||||
}
|
||||
bool DSPJitTester::AreEqual(SDSP& int_dsp, SDSP& jit_dsp)
|
||||
{
|
||||
bool equal = true;
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
if (int_dsp.r[i] != jit_dsp.r[i])
|
||||
{
|
||||
if (equal && be_verbose)
|
||||
printf("failed\n");
|
||||
equal = false;
|
||||
if (be_verbose)
|
||||
printf("\t%s: int = 0x%04x, jit = 0x%04x\n", regnames[i].name, int_dsp.r[i], jit_dsp.r[i]);
|
||||
}
|
||||
}
|
||||
if (equal && be_verbose)
|
||||
printf("passed\n");
|
||||
return equal;
|
||||
}
|
||||
void DSPJitTester::Report()
|
||||
{
|
||||
printf("%s (0x%04x): Ran %d times, Failed %d times.\n", instruction_name, instruction, run_count, fail_count);
|
||||
}
|
||||
void DSPJitTester::Initialize()
|
||||
{
|
||||
//init int
|
||||
InitInstructionTable();
|
||||
}
|
49
Source/UnitTests/DSPJitTester.h
Normal file
49
Source/UnitTests/DSPJitTester.h
Normal file
@ -0,0 +1,49 @@
|
||||
#ifndef __DSP_JIT_TESTER_
|
||||
#define __DSP_JIT_TESTER_
|
||||
|
||||
#include "DSPCore.h"
|
||||
#include "DSPInterpreter.h"
|
||||
//#include "DSPIntExtOps.h"
|
||||
//
|
||||
//#include "x64Emitter.h"
|
||||
|
||||
class DSPJitTester
|
||||
{
|
||||
UDSPInstruction instruction;
|
||||
const DSPOPCTemplate *opcode_template;
|
||||
DSPEmitter jit;
|
||||
SDSP last_int_dsp;
|
||||
SDSP last_jit_dsp;
|
||||
bool be_verbose;
|
||||
int run_count;
|
||||
int fail_count;
|
||||
char instruction_name[16];
|
||||
|
||||
bool AreEqual(SDSP&, SDSP&);
|
||||
public:
|
||||
DSPJitTester(u16 opcode, u16 opcode_ext, bool verbose = false)
|
||||
: be_verbose(verbose), run_count(0), fail_count(0)
|
||||
{
|
||||
instruction = opcode << 9 | opcode_ext;
|
||||
opcode_template = GetOpTemplate(instruction);
|
||||
sprintf(instruction_name, "%s", opcode_template->name);
|
||||
if (opcode_template->extended)
|
||||
sprintf(&instruction_name[strlen(instruction_name)], "'%s",
|
||||
extOpTable[instruction & (((instruction >> 12) == 0x3) ? 0x7F : 0xFF)]->name);
|
||||
}
|
||||
bool Test(SDSP);
|
||||
SDSP RunInterpreter(SDSP);
|
||||
SDSP RunJit(SDSP);
|
||||
void ResetInterpreter();
|
||||
void ResetJit();
|
||||
inline SDSP GetLastInterpreterDSP() { return last_int_dsp; }
|
||||
inline SDSP GetLastJitDSP() { return last_jit_dsp; }
|
||||
inline int GetRunCount() { return run_count; }
|
||||
inline int GetFailCount() { return fail_count; }
|
||||
inline const char* GetInstructionName() { return instruction_name; }
|
||||
void Report();
|
||||
|
||||
static void Initialize();
|
||||
};
|
||||
|
||||
#endif
|
@ -23,6 +23,8 @@
|
||||
#include "PowerPC/PowerPC.h"
|
||||
#include "HW/SI_DeviceGCController.h"
|
||||
|
||||
void AudioJitTests();
|
||||
|
||||
using namespace std;
|
||||
|
||||
int fail_count = 0;
|
||||
@ -101,6 +103,8 @@ void StringTests()
|
||||
|
||||
int main(int argc, _TCHAR* argv[])
|
||||
{
|
||||
AudioJitTests();
|
||||
|
||||
CoreTests();
|
||||
MathTests();
|
||||
StringTests();
|
||||
@ -133,6 +137,7 @@ void Host_SetWiiMoteConnectionState(int _State){}
|
||||
void Host_UpdateLeds(int bits){}
|
||||
void Host_UpdateSpeakerStatus(int index, int bits){}
|
||||
void Host_UpdateStatus(){}
|
||||
void Host_Message(int){}
|
||||
|
||||
int CSIDevice_GCController::GetNetInput(u8 numPAD, SPADStatus PadStatus, u32 *PADStatus)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Version="9,00"
|
||||
Name="UnitTests"
|
||||
ProjectGUID="{40C636FA-B5BF-4D67-ABC8-376B524A7551}"
|
||||
RootNamespace="UnitTests"
|
||||
@ -44,7 +44,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../Core/Core/Src;../Core/Common/Src;../PluginSpecs;../Core/InputCommon/Src"
|
||||
AdditionalIncludeDirectories="../Core/Core/Src;../Core/Common/Src;../PluginSpecs;../Core/InputCommon/Src;../Core/DSPCore/Src"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
@ -64,6 +64,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Iphlpapi.lib winmm.lib"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
@ -119,7 +120,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../Core/Core/Src;../Core/Common/Src;../PluginSpecs;../Core/InputCommon/Src"
|
||||
AdditionalIncludeDirectories="../Core/Core/Src;../Core/Common/Src;../PluginSpecs;../Core/InputCommon/Src;../Core/DSPCore/Src"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
@ -139,6 +140,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Iphlpapi.lib winmm.lib"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
@ -195,7 +197,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories="../Core/Core/Src;../Core/Common/Src;../PluginSpecs;../Core/InputCommon/Src"
|
||||
AdditionalIncludeDirectories="../Core/Core/Src;../Core/Common/Src;../PluginSpecs;../Core/InputCommon/Src;../Core/DSPCore/Src"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
@ -214,6 +216,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Iphlpapi.lib winmm.lib"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
@ -273,7 +276,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories="../Core/Core/Src;../Core/Common/Src;../PluginSpecs;../Core/InputCommon/Src"
|
||||
AdditionalIncludeDirectories="../Core/Core/Src;../Core/Common/Src;../PluginSpecs;../Core/InputCommon/Src;../Core/DSPCore/Src"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
@ -292,6 +295,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Iphlpapi.lib winmm.lib"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
@ -327,6 +331,22 @@
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Audio"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\AudioJitTests.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DSPJitTester.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DSPJitTester.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\UnitTests.cpp"
|
||||
>
|
||||
|
Reference in New Issue
Block a user