From 64d4e40081b38295d2c8e1f3ac9c0150e4833aee Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 13 Jul 2018 14:19:22 -0400 Subject: [PATCH] tests/A32/testenv: Add type aliases for register arrays Allows avoiding duplicating std::array instance sizes and types. --- tests/A32/fuzz_arm.cpp | 7 ++++--- tests/A32/fuzz_thumb.cpp | 7 ++++--- tests/A32/testenv.h | 3 +++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/A32/fuzz_arm.cpp b/tests/A32/fuzz_arm.cpp index d36a2fd7..4aa2532b 100644 --- a/tests/A32/fuzz_arm.cpp +++ b/tests/A32/fuzz_arm.cpp @@ -126,12 +126,13 @@ void FuzzJitArm(const size_t instruction_count, const size_t instructions_to_exe u32 initial_cpsr = 0x000001D0; - std::array initial_regs; + ArmTestEnv::RegisterArray initial_regs; std::generate_n(initial_regs.begin(), 15, []{ return RandInt(0, 0xFFFFFFFF); }); initial_regs[15] = 0; - std::array initial_extregs; - std::generate_n(initial_extregs.begin(), 64, []{ return RandInt(0, 0xFFFFFFFF); }); + ArmTestEnv::ExtRegsArray initial_extregs; + std::generate(initial_extregs.begin(), initial_extregs.end(), + []{ return RandInt(0, 0xFFFFFFFF); }); u32 initial_fpscr = 0x01000000 | (RandInt(0, 3) << 22); diff --git a/tests/A32/fuzz_thumb.cpp b/tests/A32/fuzz_thumb.cpp index 5bac231a..95e54b7e 100644 --- a/tests/A32/fuzz_thumb.cpp +++ b/tests/A32/fuzz_thumb.cpp @@ -86,7 +86,8 @@ static bool DoesBehaviorMatch(const ARMul_State& interp, const Dynarmic::A32::Ji && interp_write_records == jit_write_records; } -static void RunInstance(size_t run_number, ThumbTestEnv& test_env, ARMul_State& interp, Dynarmic::A32::Jit& jit, const std::array& initial_regs, size_t instruction_count, size_t instructions_to_execute_count) { +static void RunInstance(size_t run_number, ThumbTestEnv& test_env, ARMul_State& interp, Dynarmic::A32::Jit& jit, const ThumbTestEnv::RegisterArray& initial_regs, + size_t instruction_count, size_t instructions_to_execute_count) { interp.instruction_cache.clear(); InterpreterClearCache(); jit.ClearCache(); @@ -182,7 +183,7 @@ void FuzzJitThumb(const size_t instruction_count, const size_t instructions_to_e Dynarmic::A32::Jit jit{GetUserConfig(&test_env)}; for (size_t run_number = 0; run_number < run_count; run_number++) { - std::array initial_regs; + ThumbTestEnv::RegisterArray initial_regs; std::generate_n(initial_regs.begin(), 15, []{ return RandInt(0, 0xFFFFFFFF); }); initial_regs[15] = 0; @@ -284,7 +285,7 @@ TEST_CASE("Verify fix for off by one error in MemoryRead32 worked", "[Thumb]") { interp.user_callbacks = &test_env; Dynarmic::A32::Jit jit{GetUserConfig(&test_env)}; - std::array initial_regs { + constexpr ThumbTestEnv::RegisterArray initial_regs { 0xe90ecd70, 0x3e3b73c3, 0x571616f9, diff --git a/tests/A32/testenv.h b/tests/A32/testenv.h index 780c23ff..5a42bb14 100644 --- a/tests/A32/testenv.h +++ b/tests/A32/testenv.h @@ -18,6 +18,9 @@ template class A32TestEnv final : public Dynarmic::A32::UserCallbacks { public: + using RegisterArray = std::array; + using ExtRegsArray = std::array; + u64 ticks_left = 0; bool code_mem_modified_by_guest = false; std::array code_mem{};