summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorHendiadyoin1 <leon.a@serenityos.org>2022-10-14 01:45:28 +0200
committerLinus Groh <mail@linusgroh.de>2022-10-14 11:06:28 +0200
commita143d666db14369f26da3d8590443083b382d8fe (patch)
tree175a2b5ef8e81b9e837665075608a444b74e3ed8 /AK
parenteb5651870e41f08e35e9c7bd02d9e50b3be27a46 (diff)
downloadserenity-a143d666db14369f26da3d8590443083b382d8fe.zip
AK: Fix aarch64 versions of math functions
These were incorrectly assumed to compile, but did indeed still have a few issues.
Diffstat (limited to 'AK')
-rw-r--r--AK/Math.h34
1 files 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<value - 2>(); }
double res; \
asm(#instruction " %d0, %d1" \
: "=w"(res) \
- : "w"(##arg)); \
+ : "w"(arg)); \
return res; \
} \
if constexpr (IsSame<T, float>) { \
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<P, float>) {
asm("fcvtns %w0, %s1"
- : "=r"(res), "w"(value));
+ : "=r"(res)
+ : "w"(value));
} else if constexpr (IsSame<P, double>) {
asm("fcvtns %w0, %d1"
- : "=r"(res), "w"(value));
+ : "=r"(res)
+ : "w"(value));
} else if constexpr (IsSame<P, long double>) {
TODO();
}
return static_cast<I>(res);
}
- static_cast<sizeof(I) == 8>; // either long or long long aka i64
+ // either long or long long aka i64
i64 res;
if constexpr (IsSame<P, float>) {
asm("fcvtns %0, %s1"
- : "=r"(res), "w"(value));
+ : "=r"(res)
+ : "w"(value));
} else if constexpr (IsSame<P, double>) {
asm("fcvtns %0, %d1"
- : "=r"(res), "w"(value));
+ : "=r"(res)
+ : "w"(value));
} else if constexpr (IsSame<P, long double>) {
TODO();
}
@@ -639,24 +643,28 @@ ALWAYS_INLINE I round_to(P value)
u32 res;
if constexpr (IsSame<P, float>) {
asm("fcvtnu %w0, %s1"
- : "=r"(res), "w"(value));
+ : "=r"(res)
+ : "w"(value));
} else if constexpr (IsSame<P, double>) {
asm("fcvtnu %w0, %d1"
- : "=r"(res), "w"(value));
+ : "=r"(res)
+ : "w"(value));
} else if constexpr (IsSame<P, long double>) {
TODO();
}
return static_cast<I>(res);
}
- static_cast<sizeof(I) == 8>; // either unsigned long or unsigned long long aka u64
+ // either unsigned long or unsigned long long aka u64
u64 res;
if constexpr (IsSame<P, float>) {
asm("fcvtnu %0, %s1"
- : "=r"(res), "w"(value));
+ : "=r"(res)
+ : "w"(value));
} else if constexpr (IsSame<P, double>) {
asm("fcvtnu %0, %d1"
- : "=r"(res), "w"(value));
+ : "=r"(res)
+ : "w"(value));
} else if constexpr (IsSame<P, long double>) {
TODO();
}