aboutsummaryrefslogtreecommitdiff
path: root/src/dynarmic/tests/decoder_tests.cpp
diff options
context:
space:
mode:
authorcrueter <crueter@eden-emu.dev>2025-08-04 04:50:14 +0200
committercrueter <crueter@eden-emu.dev>2025-08-04 04:50:14 +0200
commit51b170b470ed587f99a7c2a773e4464687f0d07a (patch)
tree4c03c510cfb17a5f5d6233df490d78f06dcfa7f7 /src/dynarmic/tests/decoder_tests.cpp
parent04e5e6453875ffa5c79cdb421a29bc19985b1049 (diff)
[cmake] refactor: Use CPM over submodules (#143)
Transfers the majority of submodules and large externals to CPM, using source archives rather than full Git clones. Not only does this save massive amounts of clone and configure time, but dependencies are grabbed on-demand rather than being required by default. Additionally, CPM will (generally) automatically search for system dependencies, though certain dependencies have options to control this. Testing shows gains ranging from 5x to 10x in terms of overall clone/configure time. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/143 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Diffstat (limited to 'src/dynarmic/tests/decoder_tests.cpp')
-rw-r--r--src/dynarmic/tests/decoder_tests.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/dynarmic/tests/decoder_tests.cpp b/src/dynarmic/tests/decoder_tests.cpp
new file mode 100644
index 0000000000..e545309960
--- /dev/null
+++ b/src/dynarmic/tests/decoder_tests.cpp
@@ -0,0 +1,78 @@
+// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+/* This file is part of the dynarmic project.
+ * Copyright (c) 2020 MerryMage
+ * SPDX-License-Identifier: 0BSD
+ */
+
+#include <cstring>
+#include <iomanip>
+#include <iostream>
+
+#include <catch2/catch_test_macros.hpp>
+#include "dynarmic/common/assert.h"
+
+#include "dynarmic/frontend/A32/decoder/asimd.h"
+#include "dynarmic/frontend/A32/translate/impl/a32_translate_impl.h"
+#include "dynarmic/interface/A32/config.h"
+#include "dynarmic/ir/opcodes.h"
+
+using namespace Dynarmic;
+
+TEST_CASE("ASIMD Decoder: Ensure table order correctness", "[decode][a32][.]") {
+ const auto table = A32::GetASIMDDecodeTable<A32::TranslatorVisitor>();
+
+ const auto get_ir = [](const A32::ASIMDMatcher<A32::TranslatorVisitor>& matcher, u32 instruction) {
+ ASSERT(matcher.Matches(instruction));
+
+ const A32::LocationDescriptor location{0, {}, {}};
+ IR::Block block{location};
+ A32::TranslatorVisitor visitor{block, location, {}};
+ matcher.call(visitor, instruction);
+
+ return block;
+ };
+
+ const auto is_decode_error = [&get_ir](const A32::ASIMDMatcher<A32::TranslatorVisitor>& matcher, u32 instruction) {
+ const auto block = get_ir(matcher, instruction);
+
+ for (const auto& ir_inst : block) {
+ if (ir_inst.GetOpcode() == IR::Opcode::A32ExceptionRaised) {
+ if (static_cast<A32::Exception>(ir_inst.GetArg(1).GetU64()) == A32::Exception::DecodeError) {
+ return true;
+ }
+ }
+ }
+ return false;
+ };
+
+ for (auto iter = table.cbegin(); iter != table.cend(); ++iter) {
+ if (std::strncmp(iter->GetName(), "UNALLOCATED", 11) == 0) {
+ continue;
+ }
+
+ const u32 expect = iter->GetExpected();
+ const u32 mask = iter->GetMask();
+ u32 x = 0;
+ do {
+ const u32 instruction = expect | x;
+
+ const bool iserr = is_decode_error(*iter, instruction);
+ const auto alternative = std::find_if(table.cbegin(), iter, [instruction](const auto& m) { return m.Matches(instruction); });
+ const bool altiserr = is_decode_error(*alternative, instruction);
+
+ INFO("Instruction: " << std::hex << std::setfill('0') << std::setw(8) << instruction);
+ INFO("Expect: " << std::hex << std::setfill('0') << std::setw(8) << expect);
+ INFO("Fill: " << std::hex << std::setfill('0') << std::setw(8) << x);
+ INFO("Name: " << iter->GetName());
+ INFO("iserr: " << iserr);
+ INFO("alternative: " << alternative->GetName());
+ INFO("altiserr: " << altiserr);
+
+ REQUIRE(((!iserr && alternative == iter) || (iserr && alternative != iter && !altiserr)));
+
+ x = ((x | mask) + 1) & ~mask;
+ } while (x != 0);
+ }
+}