|
|
|
@ -15,11 +15,11 @@ |
|
|
|
#include <mcl/scope_exit.hpp>
|
|
|
|
#include "dynarmic/common/common_types.h"
|
|
|
|
|
|
|
|
#include "../fuzz_util.h"
|
|
|
|
#include "../rand_int.h"
|
|
|
|
#include "../unicorn_emu/a64_unicorn.h"
|
|
|
|
#include "./testenv.h"
|
|
|
|
#include "../native/testenv.h"
|
|
|
|
#include "dynarmic/tests/fuzz_util.h"
|
|
|
|
#include "dynarmic/tests/rand_int.h"
|
|
|
|
#include "dynarmic/tests/unicorn_emu/a64_unicorn.h"
|
|
|
|
#include "dynarmic/tests/A64/testenv.h"
|
|
|
|
#include "dynarmic/tests/native/testenv.h"
|
|
|
|
#include "dynarmic/common/fp/fpcr.h"
|
|
|
|
#include "dynarmic/common/fp/fpsr.h"
|
|
|
|
#include "dynarmic/common/llvm_disassemble.h"
|
|
|
|
@ -168,7 +168,7 @@ static Dynarmic::A64::UserConfig GetUserConfig(A64TestEnv& jit_env) { |
|
|
|
return jit_user_config; |
|
|
|
} |
|
|
|
|
|
|
|
static void RunTestInstance(Dynarmic::A64::Jit& jit, A64Unicorn& uni, A64TestEnv& jit_env, A64TestEnv& uni_env, const A64Unicorn::RegisterArray& regs, const A64Unicorn::VectorArray& vecs, const size_t instructions_start, const std::vector<u32>& instructions, const u32 pstate, const u32 fpcr) { |
|
|
|
static void RunTestInstance(Dynarmic::A64::Jit& jit, A64Unicorn& uni, A64TestEnv& jit_env, A64TestEnv& uni_env, Dynarmic::A64::UserConfig& conf, const A64Unicorn::RegisterArray& regs, const A64Unicorn::VectorArray& vecs, const size_t instructions_start, const std::vector<u32>& instructions, const u32 pstate, const u32 fpcr) { |
|
|
|
jit_env.code_mem = instructions; |
|
|
|
uni_env.code_mem = instructions; |
|
|
|
jit_env.code_mem.emplace_back(0x14000000); // B .
|
|
|
|
@ -269,16 +269,13 @@ static void RunTestInstance(Dynarmic::A64::Jit& jit, A64Unicorn& uni, A64TestEnv |
|
|
|
fmt::print("\n"); |
|
|
|
|
|
|
|
const auto get_code = [&jit_env](u64 vaddr) { return jit_env.MemoryReadCode(vaddr); }; |
|
|
|
IR::Block ir_block = A64::Translate({instructions_start, FP::FPCR{fpcr}}, get_code, {}); |
|
|
|
fmt::print("IR:\n"); |
|
|
|
fmt::print("{}\n", IR::DumpBlock(ir_block)); |
|
|
|
const A64::LocationDescriptor location{instructions_start, FP::FPCR{fpcr}}; |
|
|
|
IR::Block ir_block{location}; |
|
|
|
A64::Translate(ir_block, location, get_code, {}); |
|
|
|
fmt::print("IR:\n{}\n", IR::DumpBlock(ir_block)); |
|
|
|
Optimization::Optimize(ir_block, conf, {}); |
|
|
|
fmt::print("Optimized IR:\n"); |
|
|
|
fmt::print("{}\n", IR::DumpBlock(ir_block)); |
|
|
|
|
|
|
|
fmt::print("x86_64:\n"); |
|
|
|
fmt::print("{}", jit.Disassemble()); |
|
|
|
|
|
|
|
fmt::print("Optimized IR:\n{}\n", IR::DumpBlock(ir_block)); |
|
|
|
fmt::print("x86_64:\n{}", jit.Disassemble()); |
|
|
|
fmt::print("Interrupts:\n"); |
|
|
|
for (auto& i : uni_env.interrupts) { |
|
|
|
puts(i.c_str()); |
|
|
|
@ -304,7 +301,8 @@ TEST_CASE("A64: Single random instruction", "[a64][unicorn]") { |
|
|
|
A64TestEnv jit_env{}; |
|
|
|
A64TestEnv uni_env{}; |
|
|
|
|
|
|
|
Dynarmic::A64::Jit jit{GetUserConfig(jit_env)}; |
|
|
|
Dynarmic::A64::UserConfig conf{GetUserConfig(jit_env)}; |
|
|
|
Dynarmic::A64::Jit jit{conf}; |
|
|
|
A64Unicorn uni{uni_env}; |
|
|
|
|
|
|
|
A64Unicorn::RegisterArray regs; |
|
|
|
@ -323,7 +321,7 @@ TEST_CASE("A64: Single random instruction", "[a64][unicorn]") { |
|
|
|
|
|
|
|
INFO("Instruction: 0x" << std::hex << instructions[0]); |
|
|
|
|
|
|
|
RunTestInstance(jit, uni, jit_env, uni_env, regs, vecs, start_address, instructions, pstate, fpcr); |
|
|
|
RunTestInstance(jit, uni, jit_env, uni_env, conf, regs, vecs, start_address, instructions, pstate, fpcr); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -331,7 +329,8 @@ TEST_CASE("A64: Floating point instructions", "[a64][unicorn]") { |
|
|
|
A64TestEnv jit_env{}; |
|
|
|
A64TestEnv uni_env{}; |
|
|
|
|
|
|
|
Dynarmic::A64::Jit jit{GetUserConfig(jit_env)}; |
|
|
|
Dynarmic::A64::UserConfig conf{GetUserConfig(jit_env)}; |
|
|
|
Dynarmic::A64::Jit jit{conf}; |
|
|
|
A64Unicorn uni{uni_env}; |
|
|
|
|
|
|
|
static constexpr std::array<u64, 80> float_numbers{ |
|
|
|
@ -448,7 +447,7 @@ TEST_CASE("A64: Floating point instructions", "[a64][unicorn]") { |
|
|
|
|
|
|
|
INFO("Instruction: 0x" << std::hex << instructions[0]); |
|
|
|
|
|
|
|
RunTestInstance(jit, uni, jit_env, uni_env, regs, vecs, start_address, instructions, pstate, fpcr); |
|
|
|
RunTestInstance(jit, uni, jit_env, uni_env, conf, regs, vecs, start_address, instructions, pstate, fpcr); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -456,7 +455,8 @@ TEST_CASE("A64: Small random block", "[a64][unicorn]") { |
|
|
|
A64TestEnv jit_env{}; |
|
|
|
A64TestEnv uni_env{}; |
|
|
|
|
|
|
|
Dynarmic::A64::Jit jit{GetUserConfig(jit_env)}; |
|
|
|
Dynarmic::A64::UserConfig conf{GetUserConfig(jit_env)}; |
|
|
|
Dynarmic::A64::Jit jit{conf}; |
|
|
|
A64Unicorn uni{uni_env}; |
|
|
|
|
|
|
|
A64Unicorn::RegisterArray regs; |
|
|
|
@ -483,7 +483,7 @@ TEST_CASE("A64: Small random block", "[a64][unicorn]") { |
|
|
|
INFO("Instruction 4: 0x" << std::hex << instructions[3]); |
|
|
|
INFO("Instruction 5: 0x" << std::hex << instructions[4]); |
|
|
|
|
|
|
|
RunTestInstance(jit, uni, jit_env, uni_env, regs, vecs, start_address, instructions, pstate, fpcr); |
|
|
|
RunTestInstance(jit, uni, jit_env, uni_env, conf, regs, vecs, start_address, instructions, pstate, fpcr); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -491,7 +491,8 @@ TEST_CASE("A64: Large random block", "[a64][unicorn]") { |
|
|
|
A64TestEnv jit_env{}; |
|
|
|
A64TestEnv uni_env{}; |
|
|
|
|
|
|
|
Dynarmic::A64::Jit jit{GetUserConfig(jit_env)}; |
|
|
|
Dynarmic::A64::UserConfig conf{GetUserConfig(jit_env)}; |
|
|
|
Dynarmic::A64::Jit jit{conf}; |
|
|
|
A64Unicorn uni{uni_env}; |
|
|
|
|
|
|
|
A64Unicorn::RegisterArray regs; |
|
|
|
@ -512,6 +513,6 @@ TEST_CASE("A64: Large random block", "[a64][unicorn]") { |
|
|
|
const u32 pstate = RandInt<u32>(0, 0xF) << 28; |
|
|
|
const u32 fpcr = RandomFpcr(); |
|
|
|
|
|
|
|
RunTestInstance(jit, uni, jit_env, uni_env, regs, vecs, start_address, instructions, pstate, fpcr); |
|
|
|
RunTestInstance(jit, uni, jit_env, uni_env, conf, regs, vecs, start_address, instructions, pstate, fpcr); |
|
|
|
} |
|
|
|
} |