From 7f574eabbdc51f59fee1d7860d35a8abd39243ef Mon Sep 17 00:00:00 2001 From: lisyarus Date: Fri, 13 Mar 2026 11:05:20 +0300 Subject: [PATCH] Fix extending register after logical not in aarch64 compiler --- apps/interpreter/source/main.cpp | 4 ++-- examples/jit_test.psl | 3 +++ libs/jit/source/arch/aarch64/compiler.cpp | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/interpreter/source/main.cpp b/apps/interpreter/source/main.cpp index 1c847ee..2a6b68c 100644 --- a/apps/interpreter/source/main.cpp +++ b/apps/interpreter/source/main.cpp @@ -182,8 +182,8 @@ int main(int argc, char ** argv) { // TODO: remove, testing-only code; should execute entry point instead auto offset = pcontext.symbols.at("test"); - auto fptr = (double(*)(double))(executable.data.get() + offset); - auto x = fptr(3.14159265358979323846 / 6.0); + auto fptr = (std::uint32_t(*)(std::uint32_t))(executable.data.get() + offset); + auto x = fptr(0); std::cout << "Result: " << std::boolalpha << x << std::endl; } } diff --git a/examples/jit_test.psl b/examples/jit_test.psl index 4aa5c04..26ef3aa 100644 --- a/examples/jit_test.psl +++ b/examples/jit_test.psl @@ -9,3 +9,6 @@ func add_or_sub(add : bool) -> (u32 -> u32): return add1 else: return sub1 + +func test(x: u32) -> u32: + return (!0us) as u32 diff --git a/libs/jit/source/arch/aarch64/compiler.cpp b/libs/jit/source/arch/aarch64/compiler.cpp index 2361717..9ed3e9a 100644 --- a/libs/jit/source/arch/aarch64/compiler.cpp +++ b/libs/jit/source/arch/aarch64/compiler.cpp @@ -404,6 +404,8 @@ namespace pslang::jit::aarch64 case ast::unary_operation_type::logical_not: apply(*node.arg1); builder.or_not_reg(31, 0, 0); + if (types::is_integer_type(*node.inferred_type)) + extend(0, node.inferred_type); break; } }