Squashed 'externals/oaknut/' changes from 72f7ccd94..816481f10

816481f10 oaknut: 1.1.4
a75c1144e cmake: add export rules
ff4d78861 oaknut: CI: Add msvc-arm64 build
d0c317831 oaknut: CI: Pin catch2 version to v3.2.0
caf9cbbdc oaknut: Implement ADRL and MOVP2R pseudo instructions (#2)

git-subtree-dir: externals/oaknut
git-subtree-split: 816481f1036fb4177455ffa0c7b71e6ac9193d6c
This commit is contained in:
Merry
2022-11-26 15:17:46 +00:00
parent cb8abc3ae5
commit b65b07d566
5 changed files with 113 additions and 5 deletions

View File

@@ -3,6 +3,7 @@
#include <cstdint>
#include <cstdio>
#include <limits>
#include <catch2/catch_test_macros.hpp>
@@ -159,3 +160,48 @@ TEST_CASE("ADRP")
REQUIRE(f() == expect);
}
}
TEST_CASE("ADRL")
{
CodeBlock mem{4096};
for (int i = 0; i < 0x200000; i++) {
const std::int64_t diff = RandInt<std::int64_t>(-4294967296, 4294967295);
const std::intptr_t value = reinterpret_cast<std::intptr_t>(mem.ptr()) + diff;
CodeGenerator code{mem.ptr()};
auto f = code.ptr<std::uint64_t (*)()>();
mem.unprotect();
code.ADRL(X0, reinterpret_cast<void*>(value));
code.RET();
mem.protect();
mem.invalidate_all();
INFO(i);
REQUIRE(f() == static_cast<std::uint64_t>(value));
}
}
TEST_CASE("MOVP2R")
{
CodeBlock mem{4096};
for (int i = 0; i < 0x200'0000; i++)
{
const std::int64_t diff = RandInt<std::int64_t>(std::numeric_limits<std::int64_t>::min(),
std::numeric_limits<std::int64_t>::max());
const std::intptr_t value = reinterpret_cast<std::intptr_t>(mem.ptr()) + diff;
CodeGenerator code{mem.ptr()};
auto f = code.ptr<std::uint64_t (*)()>();
mem.unprotect();
code.MOVP2R(X0, reinterpret_cast<void*>(value));
code.RET();
mem.protect();
mem.invalidate_all();
REQUIRE(f() == static_cast<std::uint64_t>(value));
}
}