mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:07:45 +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
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; \
|
double res; \
|
||||||
asm(#instruction " %d0, %d1" \
|
asm(#instruction " %d0, %d1" \
|
||||||
: "=w"(res) \
|
: "=w"(res) \
|
||||||
: "w"(##arg)); \
|
: "w"(arg)); \
|
||||||
return res; \
|
return res; \
|
||||||
} \
|
} \
|
||||||
if constexpr (IsSame<T, float>) { \
|
if constexpr (IsSame<T, float>) { \
|
||||||
float res; \
|
float res; \
|
||||||
asm(#instruction " %s0, %s1" \
|
asm(#instruction " %s0, %s1" \
|
||||||
: "=w"(res) \
|
: "=w"(res) \
|
||||||
: "w"(##arg)); \
|
: "w"(arg)); \
|
||||||
return res; \
|
return res; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ constexpr T fabs(T x)
|
||||||
: "+t"(x));
|
: "+t"(x));
|
||||||
return x;
|
return x;
|
||||||
#elif ARCH(AARCH64)
|
#elif ARCH(AARCH64)
|
||||||
AARCH64_INSTRUCTION(abs, x);
|
AARCH64_INSTRUCTION(fabs, x);
|
||||||
#else
|
#else
|
||||||
return __builtin_fabs(x);
|
return __builtin_fabs(x);
|
||||||
#endif
|
#endif
|
||||||
|
@ -612,23 +612,27 @@ ALWAYS_INLINE I round_to(P value)
|
||||||
i32 res;
|
i32 res;
|
||||||
if constexpr (IsSame<P, float>) {
|
if constexpr (IsSame<P, float>) {
|
||||||
asm("fcvtns %w0, %s1"
|
asm("fcvtns %w0, %s1"
|
||||||
: "=r"(res), "w"(value));
|
: "=r"(res)
|
||||||
|
: "w"(value));
|
||||||
} else if constexpr (IsSame<P, double>) {
|
} else if constexpr (IsSame<P, double>) {
|
||||||
asm("fcvtns %w0, %d1"
|
asm("fcvtns %w0, %d1"
|
||||||
: "=r"(res), "w"(value));
|
: "=r"(res)
|
||||||
|
: "w"(value));
|
||||||
} else if constexpr (IsSame<P, long double>) {
|
} else if constexpr (IsSame<P, long double>) {
|
||||||
TODO();
|
TODO();
|
||||||
}
|
}
|
||||||
return static_cast<I>(res);
|
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;
|
i64 res;
|
||||||
if constexpr (IsSame<P, float>) {
|
if constexpr (IsSame<P, float>) {
|
||||||
asm("fcvtns %0, %s1"
|
asm("fcvtns %0, %s1"
|
||||||
: "=r"(res), "w"(value));
|
: "=r"(res)
|
||||||
|
: "w"(value));
|
||||||
} else if constexpr (IsSame<P, double>) {
|
} else if constexpr (IsSame<P, double>) {
|
||||||
asm("fcvtns %0, %d1"
|
asm("fcvtns %0, %d1"
|
||||||
: "=r"(res), "w"(value));
|
: "=r"(res)
|
||||||
|
: "w"(value));
|
||||||
} else if constexpr (IsSame<P, long double>) {
|
} else if constexpr (IsSame<P, long double>) {
|
||||||
TODO();
|
TODO();
|
||||||
}
|
}
|
||||||
|
@ -639,24 +643,28 @@ ALWAYS_INLINE I round_to(P value)
|
||||||
u32 res;
|
u32 res;
|
||||||
if constexpr (IsSame<P, float>) {
|
if constexpr (IsSame<P, float>) {
|
||||||
asm("fcvtnu %w0, %s1"
|
asm("fcvtnu %w0, %s1"
|
||||||
: "=r"(res), "w"(value));
|
: "=r"(res)
|
||||||
|
: "w"(value));
|
||||||
} else if constexpr (IsSame<P, double>) {
|
} else if constexpr (IsSame<P, double>) {
|
||||||
asm("fcvtnu %w0, %d1"
|
asm("fcvtnu %w0, %d1"
|
||||||
: "=r"(res), "w"(value));
|
: "=r"(res)
|
||||||
|
: "w"(value));
|
||||||
} else if constexpr (IsSame<P, long double>) {
|
} else if constexpr (IsSame<P, long double>) {
|
||||||
TODO();
|
TODO();
|
||||||
}
|
}
|
||||||
return static_cast<I>(res);
|
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;
|
u64 res;
|
||||||
if constexpr (IsSame<P, float>) {
|
if constexpr (IsSame<P, float>) {
|
||||||
asm("fcvtnu %0, %s1"
|
asm("fcvtnu %0, %s1"
|
||||||
: "=r"(res), "w"(value));
|
: "=r"(res)
|
||||||
|
: "w"(value));
|
||||||
} else if constexpr (IsSame<P, double>) {
|
} else if constexpr (IsSame<P, double>) {
|
||||||
asm("fcvtnu %0, %d1"
|
asm("fcvtnu %0, %d1"
|
||||||
: "=r"(res), "w"(value));
|
: "=r"(res)
|
||||||
|
: "w"(value));
|
||||||
} else if constexpr (IsSame<P, long double>) {
|
} else if constexpr (IsSame<P, long double>) {
|
||||||
TODO();
|
TODO();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue