mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
set eol-style native
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5307 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -1,35 +1,35 @@
|
|||||||
# -*- python -*-
|
# -*- python -*-
|
||||||
|
|
||||||
Import('env')
|
Import('env')
|
||||||
|
|
||||||
files = [
|
files = [
|
||||||
"assemble.cpp",
|
"assemble.cpp",
|
||||||
"disassemble.cpp",
|
"disassemble.cpp",
|
||||||
"DSPAccelerator.cpp",
|
"DSPAccelerator.cpp",
|
||||||
"DSPBreakpoints.cpp",
|
"DSPBreakpoints.cpp",
|
||||||
"DSPIntCCUtil.cpp",
|
"DSPIntCCUtil.cpp",
|
||||||
"DSPIntExtOps.cpp",
|
"DSPIntExtOps.cpp",
|
||||||
"DSPHWInterface.cpp",
|
"DSPHWInterface.cpp",
|
||||||
"DSPMemoryMap.cpp",
|
"DSPMemoryMap.cpp",
|
||||||
"DSPStacks.cpp",
|
"DSPStacks.cpp",
|
||||||
"DSPAnalyzer.cpp",
|
"DSPAnalyzer.cpp",
|
||||||
"DspIntArithmetic.cpp",
|
"DspIntArithmetic.cpp",
|
||||||
"DspIntBranch.cpp",
|
"DspIntBranch.cpp",
|
||||||
"DspIntLoadStore.cpp",
|
"DspIntLoadStore.cpp",
|
||||||
"DspIntMisc.cpp",
|
"DspIntMisc.cpp",
|
||||||
"DspIntMultiplier.cpp",
|
"DspIntMultiplier.cpp",
|
||||||
"DSPEmitter.cpp",
|
"DSPEmitter.cpp",
|
||||||
"DSPCodeUtil.cpp",
|
"DSPCodeUtil.cpp",
|
||||||
"LabelMap.cpp",
|
"LabelMap.cpp",
|
||||||
"DSPInterpreter.cpp",
|
"DSPInterpreter.cpp",
|
||||||
"DSPCore.cpp",
|
"DSPCore.cpp",
|
||||||
"DSPTables.cpp",
|
"DSPTables.cpp",
|
||||||
"Jit/DSPJitExtOps.cpp",
|
"Jit/DSPJitExtOps.cpp",
|
||||||
"Jit/DSPJitUtil.cpp",
|
"Jit/DSPJitUtil.cpp",
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
acenv = env.Clone()
|
acenv = env.Clone()
|
||||||
acenv.Append(CXXFLAGS = [ '-fPIC' ])
|
acenv.Append(CXXFLAGS = [ '-fPIC' ])
|
||||||
|
|
||||||
acenv.StaticLibrary(env['local_libs'] + 'dspcore', files, LIBS = [ 'common'] )
|
acenv.StaticLibrary(env['local_libs'] + 'dspcore', files, LIBS = [ 'common'] )
|
||||||
|
@ -1,84 +1,84 @@
|
|||||||
#include "DSPJitTester.h"
|
#include "DSPJitTester.h"
|
||||||
|
|
||||||
void nx_dr()
|
void nx_dr()
|
||||||
{
|
{
|
||||||
SDSP test_dsp;
|
SDSP test_dsp;
|
||||||
DSPJitTester tester(0x40, 0x04);
|
DSPJitTester tester(0x40, 0x04);
|
||||||
|
|
||||||
for (u16 input_reg = 0; input_reg < 50; input_reg++)
|
for (u16 input_reg = 0; input_reg < 50; input_reg++)
|
||||||
for (u16 input_wr0 = 0; input_wr0 < 10; input_wr0++)
|
for (u16 input_wr0 = 0; input_wr0 < 10; input_wr0++)
|
||||||
{
|
{
|
||||||
memset(&test_dsp, 0, sizeof(SDSP));
|
memset(&test_dsp, 0, sizeof(SDSP));
|
||||||
test_dsp.r[DSP_REG_WR0] = input_wr0;
|
test_dsp.r[DSP_REG_WR0] = input_wr0;
|
||||||
test_dsp.r[0] = input_reg;
|
test_dsp.r[0] = input_reg;
|
||||||
if (!tester.Test(test_dsp))
|
if (!tester.Test(test_dsp))
|
||||||
{
|
{
|
||||||
printf("%s Test failed: in = 0x%04x, wr0 = 0x%04x > int = 0x%04x, jit = 0x%04x\n",
|
printf("%s Test failed: in = 0x%04x, wr0 = 0x%04x > int = 0x%04x, jit = 0x%04x\n",
|
||||||
tester.GetInstructionName(),
|
tester.GetInstructionName(),
|
||||||
input_reg, input_wr0,
|
input_reg, input_wr0,
|
||||||
tester.GetLastInterpreterDSP().r[0], tester.GetLastJitDSP().r[0]);
|
tester.GetLastInterpreterDSP().r[0], tester.GetLastJitDSP().r[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tester.Report();
|
tester.Report();
|
||||||
}
|
}
|
||||||
|
|
||||||
void nx_ir()
|
void nx_ir()
|
||||||
{
|
{
|
||||||
SDSP test_dsp;
|
SDSP test_dsp;
|
||||||
DSPJitTester tester(0x40, 0x08);
|
DSPJitTester tester(0x40, 0x08);
|
||||||
|
|
||||||
for (u16 input_reg = 0; input_reg < 50; input_reg++)
|
for (u16 input_reg = 0; input_reg < 50; input_reg++)
|
||||||
for (u16 input_wr0 = 0; input_wr0 < 10; input_wr0++)
|
for (u16 input_wr0 = 0; input_wr0 < 10; input_wr0++)
|
||||||
{
|
{
|
||||||
memset(&test_dsp, 0, sizeof(SDSP));
|
memset(&test_dsp, 0, sizeof(SDSP));
|
||||||
test_dsp.r[DSP_REG_WR0] = input_wr0;
|
test_dsp.r[DSP_REG_WR0] = input_wr0;
|
||||||
test_dsp.r[0] = input_reg;
|
test_dsp.r[0] = input_reg;
|
||||||
if (!tester.Test(test_dsp))
|
if (!tester.Test(test_dsp))
|
||||||
{
|
{
|
||||||
printf("%s Test failed: in = 0x%04x, wr0 = 0x%04x > int = 0x%04x, jit = 0x%04x\n",
|
printf("%s Test failed: in = 0x%04x, wr0 = 0x%04x > int = 0x%04x, jit = 0x%04x\n",
|
||||||
tester.GetInstructionName(),
|
tester.GetInstructionName(),
|
||||||
input_reg, input_wr0,
|
input_reg, input_wr0,
|
||||||
tester.GetLastInterpreterDSP().r[0], tester.GetLastJitDSP().r[0]);
|
tester.GetLastInterpreterDSP().r[0], tester.GetLastJitDSP().r[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tester.Report();
|
tester.Report();
|
||||||
}
|
}
|
||||||
|
|
||||||
void nx_nr()
|
void nx_nr()
|
||||||
{
|
{
|
||||||
SDSP test_dsp;
|
SDSP test_dsp;
|
||||||
DSPJitTester tester(0x40, 0x0c);
|
DSPJitTester tester(0x40, 0x0c);
|
||||||
|
|
||||||
for (u16 input_reg = 0; input_reg < 50; input_reg++)
|
for (u16 input_reg = 0; input_reg < 50; input_reg++)
|
||||||
for (u16 input_wr0 = 0; input_wr0 < 10; input_wr0++)
|
for (u16 input_wr0 = 0; input_wr0 < 10; input_wr0++)
|
||||||
{
|
{
|
||||||
memset(&test_dsp, 0, sizeof(SDSP));
|
memset(&test_dsp, 0, sizeof(SDSP));
|
||||||
test_dsp.r[DSP_REG_WR0] = input_wr0;
|
test_dsp.r[DSP_REG_WR0] = input_wr0;
|
||||||
test_dsp.r[0] = input_reg;
|
test_dsp.r[0] = input_reg;
|
||||||
if (!tester.Test(test_dsp))
|
if (!tester.Test(test_dsp))
|
||||||
{
|
{
|
||||||
printf("%s Test failed: in = 0x%04x, wr0 = 0x%04x > int = 0x%04x, jit = 0x%04x\n",
|
printf("%s Test failed: in = 0x%04x, wr0 = 0x%04x > int = 0x%04x, jit = 0x%04x\n",
|
||||||
tester.GetInstructionName(),
|
tester.GetInstructionName(),
|
||||||
input_reg, input_wr0,
|
input_reg, input_wr0,
|
||||||
tester.GetLastInterpreterDSP().r[0], tester.GetLastJitDSP().r[0]);
|
tester.GetLastInterpreterDSP().r[0], tester.GetLastJitDSP().r[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tester.Report();
|
tester.Report();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioJitTests()
|
void AudioJitTests()
|
||||||
{
|
{
|
||||||
DSPJitTester::Initialize();
|
DSPJitTester::Initialize();
|
||||||
|
|
||||||
nx_ir();
|
nx_ir();
|
||||||
nx_dr();
|
nx_dr();
|
||||||
//nx_nr();
|
//nx_nr();
|
||||||
}
|
}
|
||||||
|
|
||||||
//required to be able to link against DSPCore
|
//required to be able to link against DSPCore
|
||||||
void DSPHost_UpdateDebugger() { }
|
void DSPHost_UpdateDebugger() { }
|
||||||
unsigned int DSPHost_CodeLoaded(unsigned const char*, int) { return 0; }
|
unsigned int DSPHost_CodeLoaded(unsigned const char*, int) { return 0; }
|
||||||
void DSPHost_InterruptRequest() { }
|
void DSPHost_InterruptRequest() { }
|
||||||
bool DSPHost_OnThread() { return false; }
|
bool DSPHost_OnThread() { return false; }
|
||||||
void DSPHost_WriteHostMemory(unsigned char, unsigned int) { }
|
void DSPHost_WriteHostMemory(unsigned char, unsigned int) { }
|
||||||
unsigned char DSPHost_ReadHostMemory(unsigned int) { return 0; }
|
unsigned char DSPHost_ReadHostMemory(unsigned int) { return 0; }
|
@ -1,71 +1,71 @@
|
|||||||
#include "DSPJitTester.h"
|
#include "DSPJitTester.h"
|
||||||
|
|
||||||
bool DSPJitTester::Test(SDSP dsp_settings)
|
bool DSPJitTester::Test(SDSP dsp_settings)
|
||||||
{
|
{
|
||||||
if (be_verbose)
|
if (be_verbose)
|
||||||
printf("Running %s: ", instruction_name);
|
printf("Running %s: ", instruction_name);
|
||||||
|
|
||||||
last_int_dsp = RunInterpreter(dsp_settings);
|
last_int_dsp = RunInterpreter(dsp_settings);
|
||||||
last_jit_dsp = RunJit(dsp_settings);
|
last_jit_dsp = RunJit(dsp_settings);
|
||||||
|
|
||||||
run_count++;
|
run_count++;
|
||||||
bool success = AreEqual(last_int_dsp, last_jit_dsp);
|
bool success = AreEqual(last_int_dsp, last_jit_dsp);
|
||||||
if (!success)
|
if (!success)
|
||||||
fail_count++;
|
fail_count++;
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
SDSP DSPJitTester::RunInterpreter(SDSP dsp_settings)
|
SDSP DSPJitTester::RunInterpreter(SDSP dsp_settings)
|
||||||
{
|
{
|
||||||
ResetInterpreter();
|
ResetInterpreter();
|
||||||
memcpy(&g_dsp, &dsp_settings, sizeof(SDSP));
|
memcpy(&g_dsp, &dsp_settings, sizeof(SDSP));
|
||||||
ExecuteInstruction(instruction);
|
ExecuteInstruction(instruction);
|
||||||
|
|
||||||
return g_dsp;
|
return g_dsp;
|
||||||
}
|
}
|
||||||
SDSP DSPJitTester::RunJit(SDSP dsp_settings)
|
SDSP DSPJitTester::RunJit(SDSP dsp_settings)
|
||||||
{
|
{
|
||||||
ResetJit();
|
ResetJit();
|
||||||
memcpy(&g_dsp, &dsp_settings, sizeof(SDSP));
|
memcpy(&g_dsp, &dsp_settings, sizeof(SDSP));
|
||||||
const u8* code = jit.GetCodePtr();
|
const u8* code = jit.GetCodePtr();
|
||||||
jit.WriteCallInterpreter(instruction);
|
jit.WriteCallInterpreter(instruction);
|
||||||
jit.RET();
|
jit.RET();
|
||||||
((void(*)())code)();
|
((void(*)())code)();
|
||||||
|
|
||||||
return g_dsp;
|
return g_dsp;
|
||||||
}
|
}
|
||||||
void DSPJitTester::ResetInterpreter()
|
void DSPJitTester::ResetInterpreter()
|
||||||
{
|
{
|
||||||
for (int i=0; i < WRITEBACKLOGSIZE; i++)
|
for (int i=0; i < WRITEBACKLOGSIZE; i++)
|
||||||
writeBackLogIdx[i] = -1;
|
writeBackLogIdx[i] = -1;
|
||||||
}
|
}
|
||||||
void DSPJitTester::ResetJit()
|
void DSPJitTester::ResetJit()
|
||||||
{
|
{
|
||||||
jit.ClearCodeSpace();
|
jit.ClearCodeSpace();
|
||||||
}
|
}
|
||||||
bool DSPJitTester::AreEqual(SDSP& int_dsp, SDSP& jit_dsp)
|
bool DSPJitTester::AreEqual(SDSP& int_dsp, SDSP& jit_dsp)
|
||||||
{
|
{
|
||||||
bool equal = true;
|
bool equal = true;
|
||||||
for (int i = 0; i < 32; i++)
|
for (int i = 0; i < 32; i++)
|
||||||
{
|
{
|
||||||
if (int_dsp.r[i] != jit_dsp.r[i])
|
if (int_dsp.r[i] != jit_dsp.r[i])
|
||||||
{
|
{
|
||||||
if (equal && be_verbose)
|
if (equal && be_verbose)
|
||||||
printf("failed\n");
|
printf("failed\n");
|
||||||
equal = false;
|
equal = false;
|
||||||
if (be_verbose)
|
if (be_verbose)
|
||||||
printf("\t%s: int = 0x%04x, jit = 0x%04x\n", regnames[i].name, int_dsp.r[i], jit_dsp.r[i]);
|
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)
|
if (equal && be_verbose)
|
||||||
printf("passed\n");
|
printf("passed\n");
|
||||||
return equal;
|
return equal;
|
||||||
}
|
}
|
||||||
void DSPJitTester::Report()
|
void DSPJitTester::Report()
|
||||||
{
|
{
|
||||||
printf("%s (0x%04x): Ran %d times, Failed %d times.\n", instruction_name, instruction, run_count, fail_count);
|
printf("%s (0x%04x): Ran %d times, Failed %d times.\n", instruction_name, instruction, run_count, fail_count);
|
||||||
}
|
}
|
||||||
void DSPJitTester::Initialize()
|
void DSPJitTester::Initialize()
|
||||||
{
|
{
|
||||||
//init int
|
//init int
|
||||||
InitInstructionTable();
|
InitInstructionTable();
|
||||||
}
|
}
|
@ -1,49 +1,49 @@
|
|||||||
#ifndef __DSP_JIT_TESTER_
|
#ifndef __DSP_JIT_TESTER_
|
||||||
#define __DSP_JIT_TESTER_
|
#define __DSP_JIT_TESTER_
|
||||||
|
|
||||||
#include "DSPCore.h"
|
#include "DSPCore.h"
|
||||||
#include "DSPInterpreter.h"
|
#include "DSPInterpreter.h"
|
||||||
//#include "DSPIntExtOps.h"
|
//#include "DSPIntExtOps.h"
|
||||||
//
|
//
|
||||||
//#include "x64Emitter.h"
|
//#include "x64Emitter.h"
|
||||||
|
|
||||||
class DSPJitTester
|
class DSPJitTester
|
||||||
{
|
{
|
||||||
UDSPInstruction instruction;
|
UDSPInstruction instruction;
|
||||||
const DSPOPCTemplate *opcode_template;
|
const DSPOPCTemplate *opcode_template;
|
||||||
DSPEmitter jit;
|
DSPEmitter jit;
|
||||||
SDSP last_int_dsp;
|
SDSP last_int_dsp;
|
||||||
SDSP last_jit_dsp;
|
SDSP last_jit_dsp;
|
||||||
bool be_verbose;
|
bool be_verbose;
|
||||||
int run_count;
|
int run_count;
|
||||||
int fail_count;
|
int fail_count;
|
||||||
char instruction_name[16];
|
char instruction_name[16];
|
||||||
|
|
||||||
bool AreEqual(SDSP&, SDSP&);
|
bool AreEqual(SDSP&, SDSP&);
|
||||||
public:
|
public:
|
||||||
DSPJitTester(u16 opcode, u16 opcode_ext, bool verbose = false)
|
DSPJitTester(u16 opcode, u16 opcode_ext, bool verbose = false)
|
||||||
: be_verbose(verbose), run_count(0), fail_count(0)
|
: be_verbose(verbose), run_count(0), fail_count(0)
|
||||||
{
|
{
|
||||||
instruction = opcode << 9 | opcode_ext;
|
instruction = opcode << 9 | opcode_ext;
|
||||||
opcode_template = GetOpTemplate(instruction);
|
opcode_template = GetOpTemplate(instruction);
|
||||||
sprintf(instruction_name, "%s", opcode_template->name);
|
sprintf(instruction_name, "%s", opcode_template->name);
|
||||||
if (opcode_template->extended)
|
if (opcode_template->extended)
|
||||||
sprintf(&instruction_name[strlen(instruction_name)], "'%s",
|
sprintf(&instruction_name[strlen(instruction_name)], "'%s",
|
||||||
extOpTable[instruction & (((instruction >> 12) == 0x3) ? 0x7F : 0xFF)]->name);
|
extOpTable[instruction & (((instruction >> 12) == 0x3) ? 0x7F : 0xFF)]->name);
|
||||||
}
|
}
|
||||||
bool Test(SDSP);
|
bool Test(SDSP);
|
||||||
SDSP RunInterpreter(SDSP);
|
SDSP RunInterpreter(SDSP);
|
||||||
SDSP RunJit(SDSP);
|
SDSP RunJit(SDSP);
|
||||||
void ResetInterpreter();
|
void ResetInterpreter();
|
||||||
void ResetJit();
|
void ResetJit();
|
||||||
inline SDSP GetLastInterpreterDSP() { return last_int_dsp; }
|
inline SDSP GetLastInterpreterDSP() { return last_int_dsp; }
|
||||||
inline SDSP GetLastJitDSP() { return last_jit_dsp; }
|
inline SDSP GetLastJitDSP() { return last_jit_dsp; }
|
||||||
inline int GetRunCount() { return run_count; }
|
inline int GetRunCount() { return run_count; }
|
||||||
inline int GetFailCount() { return fail_count; }
|
inline int GetFailCount() { return fail_count; }
|
||||||
inline const char* GetInstructionName() { return instruction_name; }
|
inline const char* GetInstructionName() { return instruction_name; }
|
||||||
void Report();
|
void Report();
|
||||||
|
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Reference in New Issue
Block a user