externals: Update oaknut to 1.1.4

Merge commit 'b65b07d566d032339e85d67ecf094a489b05604d' into HEAD
This commit is contained in:
Merry
2022-11-26 15:17:46 +00:00
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));
}
}