diff options
| author | j4ck.fr0st <j4ck.fr0st@gmail.com> | 2010-04-09 19:28:18 +0000 |
|---|---|---|
| committer | j4ck.fr0st <j4ck.fr0st@gmail.com> | 2010-04-09 19:28:18 +0000 |
| commit | ab76cbf2fcf31b059edf10c220800150313ddf18 (patch) | |
| tree | 272a82d9382989b1b35067b2517c4a9ed4ae80ca /Source/UnitTests | |
| parent | 57a3c878158d56565e42164a2c23e01d07050dd3 (diff) | |
set eol-style native
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5307 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/UnitTests')
| -rw-r--r-- | Source/UnitTests/AudioJitTests.cpp | 166 | ||||
| -rw-r--r-- | Source/UnitTests/DSPJitTester.cpp | 140 | ||||
| -rw-r--r-- | Source/UnitTests/DSPJitTester.h | 96 |
3 files changed, 201 insertions, 201 deletions
diff --git a/Source/UnitTests/AudioJitTests.cpp b/Source/UnitTests/AudioJitTests.cpp index 2247f529b5..db17e24926 100644 --- a/Source/UnitTests/AudioJitTests.cpp +++ b/Source/UnitTests/AudioJitTests.cpp @@ -1,84 +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) { }
+#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; }
\ No newline at end of file diff --git a/Source/UnitTests/DSPJitTester.cpp b/Source/UnitTests/DSPJitTester.cpp index aa13aa6d6d..4be7ccf50b 100644 --- a/Source/UnitTests/DSPJitTester.cpp +++ b/Source/UnitTests/DSPJitTester.cpp @@ -1,71 +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();
+#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(); }
\ No newline at end of file diff --git a/Source/UnitTests/DSPJitTester.h b/Source/UnitTests/DSPJitTester.h index 98de3a7868..cd9dd5c217 100644 --- a/Source/UnitTests/DSPJitTester.h +++ b/Source/UnitTests/DSPJitTester.h @@ -1,49 +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();
-};
-
+#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
\ No newline at end of file |
