From ab76cbf2fcf31b059edf10c220800150313ddf18 Mon Sep 17 00:00:00 2001 From: "j4ck.fr0st" Date: Fri, 9 Apr 2010 19:28:18 +0000 Subject: [PATCH] set eol-style native git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5307 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DSPCore/Src/SConscript | 70 ++++++------ Source/UnitTests/AudioJitTests.cpp | 166 ++++++++++++++--------------- Source/UnitTests/DSPJitTester.cpp | 140 ++++++++++++------------ Source/UnitTests/DSPJitTester.h | 96 ++++++++--------- 4 files changed, 236 insertions(+), 236 deletions(-) diff --git a/Source/Core/DSPCore/Src/SConscript b/Source/Core/DSPCore/Src/SConscript index 13d20f1863..8433d084a1 100644 --- a/Source/Core/DSPCore/Src/SConscript +++ b/Source/Core/DSPCore/Src/SConscript @@ -1,35 +1,35 @@ -# -*- python -*- - -Import('env') - -files = [ - "assemble.cpp", - "disassemble.cpp", - "DSPAccelerator.cpp", - "DSPBreakpoints.cpp", - "DSPIntCCUtil.cpp", - "DSPIntExtOps.cpp", - "DSPHWInterface.cpp", - "DSPMemoryMap.cpp", - "DSPStacks.cpp", - "DSPAnalyzer.cpp", - "DspIntArithmetic.cpp", - "DspIntBranch.cpp", - "DspIntLoadStore.cpp", - "DspIntMisc.cpp", - "DspIntMultiplier.cpp", - "DSPEmitter.cpp", - "DSPCodeUtil.cpp", - "LabelMap.cpp", - "DSPInterpreter.cpp", - "DSPCore.cpp", - "DSPTables.cpp", - "Jit/DSPJitExtOps.cpp", - "Jit/DSPJitUtil.cpp", - - ] - -acenv = env.Clone() -acenv.Append(CXXFLAGS = [ '-fPIC' ]) - -acenv.StaticLibrary(env['local_libs'] + 'dspcore', files, LIBS = [ 'common'] ) +# -*- python -*- + +Import('env') + +files = [ + "assemble.cpp", + "disassemble.cpp", + "DSPAccelerator.cpp", + "DSPBreakpoints.cpp", + "DSPIntCCUtil.cpp", + "DSPIntExtOps.cpp", + "DSPHWInterface.cpp", + "DSPMemoryMap.cpp", + "DSPStacks.cpp", + "DSPAnalyzer.cpp", + "DspIntArithmetic.cpp", + "DspIntBranch.cpp", + "DspIntLoadStore.cpp", + "DspIntMisc.cpp", + "DspIntMultiplier.cpp", + "DSPEmitter.cpp", + "DSPCodeUtil.cpp", + "LabelMap.cpp", + "DSPInterpreter.cpp", + "DSPCore.cpp", + "DSPTables.cpp", + "Jit/DSPJitExtOps.cpp", + "Jit/DSPJitUtil.cpp", + + ] + +acenv = env.Clone() +acenv.Append(CXXFLAGS = [ '-fPIC' ]) + +acenv.StaticLibrary(env['local_libs'] + 'dspcore', files, LIBS = [ 'common'] ) 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