From a143d666db14369f26da3d8590443083b382d8fe Mon Sep 17 00:00:00 2001 From: Hendiadyoin1 Date: Fri, 14 Oct 2022 01:45:28 +0200 Subject: [PATCH] AK: Fix aarch64 versions of math functions These were incorrectly assumed to compile, but did indeed still have a few issues. --- AK/Math.h | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/AK/Math.h b/AK/Math.h index 17184e52b0..5053b6079f 100644 --- a/AK/Math.h +++ b/AK/Math.h @@ -62,14 +62,14 @@ constexpr size_t product_odd() { return value * product_odd(); } double res; \ asm(#instruction " %d0, %d1" \ : "=w"(res) \ - : "w"(##arg)); \ + : "w"(arg)); \ return res; \ } \ if constexpr (IsSame) { \ float res; \ asm(#instruction " %s0, %s1" \ : "=w"(res) \ - : "w"(##arg)); \ + : "w"(arg)); \ return res; \ } @@ -238,7 +238,7 @@ constexpr T fabs(T x) : "+t"(x)); return x; #elif ARCH(AARCH64) - AARCH64_INSTRUCTION(abs, x); + AARCH64_INSTRUCTION(fabs, x); #else return __builtin_fabs(x); #endif @@ -612,23 +612,27 @@ ALWAYS_INLINE I round_to(P value) i32 res; if constexpr (IsSame) { asm("fcvtns %w0, %s1" - : "=r"(res), "w"(value)); + : "=r"(res) + : "w"(value)); } else if constexpr (IsSame) { asm("fcvtns %w0, %d1" - : "=r"(res), "w"(value)); + : "=r"(res) + : "w"(value)); } else if constexpr (IsSame) { TODO(); } return static_cast(res); } - static_cast; // either long or long long aka i64 + // either long or long long aka i64 i64 res; if constexpr (IsSame) { asm("fcvtns %0, %s1" - : "=r"(res), "w"(value)); + : "=r"(res) + : "w"(value)); } else if constexpr (IsSame) { asm("fcvtns %0, %d1" - : "=r"(res), "w"(value)); + : "=r"(res) + : "w"(value)); } else if constexpr (IsSame) { TODO(); } @@ -639,24 +643,28 @@ ALWAYS_INLINE I round_to(P value) u32 res; if constexpr (IsSame) { asm("fcvtnu %w0, %s1" - : "=r"(res), "w"(value)); + : "=r"(res) + : "w"(value)); } else if constexpr (IsSame) { asm("fcvtnu %w0, %d1" - : "=r"(res), "w"(value)); + : "=r"(res) + : "w"(value)); } else if constexpr (IsSame) { TODO(); } return static_cast(res); } - static_cast; // either unsigned long or unsigned long long aka u64 + // either unsigned long or unsigned long long aka u64 u64 res; if constexpr (IsSame) { asm("fcvtnu %0, %s1" - : "=r"(res), "w"(value)); + : "=r"(res) + : "w"(value)); } else if constexpr (IsSame) { asm("fcvtnu %0, %d1" - : "=r"(res), "w"(value)); + : "=r"(res) + : "w"(value)); } else if constexpr (IsSame) { TODO(); }