mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-24 16:40:21 +00:00
AK: Fix aarch64 versions of math functions
These were incorrectly assumed to compile, but did indeed still have a few issues.
This commit is contained in:
parent
eb5651870e
commit
a143d666db
Notes:
sideshowbarker
2024-07-18 03:23:00 +09:00
Author: https://github.com/Hendiadyoin1 Commit: https://github.com/SerenityOS/serenity/commit/a143d666db Pull-request: https://github.com/SerenityOS/serenity/pull/15578
1 changed files with 21 additions and 13 deletions
34
AK/Math.h
34
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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue