AK: Remove i686 support

This commit is contained in:
Liav A 2022-10-04 03:32:20 +03:00 committed by Andreas Kling
parent 91db482ad3
commit feeb25bcee
Notes: sideshowbarker 2024-07-17 02:31:00 +09:00
5 changed files with 26 additions and 38 deletions

View file

@ -79,7 +79,7 @@ constexpr T fmod(T x, T y)
{ {
CONSTEXPR_STATE(fmod, x, y); CONSTEXPR_STATE(fmod, x, y);
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
u16 fpu_status; u16 fpu_status;
do { do {
asm( asm(
@ -98,7 +98,7 @@ constexpr T remainder(T x, T y)
{ {
CONSTEXPR_STATE(remainder, x, y); CONSTEXPR_STATE(remainder, x, y);
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
u16 fpu_status; u16 fpu_status;
do { do {
asm( asm(
@ -122,7 +122,7 @@ constexpr T sqrt(T x)
{ {
CONSTEXPR_STATE(sqrt, x); CONSTEXPR_STATE(sqrt, x);
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
T res; T res;
asm("fsqrt" asm("fsqrt"
: "=t"(res) : "=t"(res)
@ -144,7 +144,7 @@ constexpr T rsqrt(T x)
return (T)1. / sqrt(x); return (T)1. / sqrt(x);
} }
#ifdef __SSE__ #if ARCH(x86_64)
template<> template<>
constexpr float sqrt(float x) constexpr float sqrt(float x)
{ {
@ -232,7 +232,7 @@ constexpr T fabs(T x)
{ {
if (is_constant_evaluated()) if (is_constant_evaluated())
return x < 0 ? -x : x; return x < 0 ? -x : x;
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
asm( asm(
"fabs" "fabs"
: "+t"(x)); : "+t"(x));
@ -257,7 +257,7 @@ constexpr T sin(T angle)
{ {
CONSTEXPR_STATE(sin, angle); CONSTEXPR_STATE(sin, angle);
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
T ret; T ret;
asm( asm(
"fsin" "fsin"
@ -274,7 +274,7 @@ constexpr T cos(T angle)
{ {
CONSTEXPR_STATE(cos, angle); CONSTEXPR_STATE(cos, angle);
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
T ret; T ret;
asm( asm(
"fcos" "fcos"
@ -294,7 +294,7 @@ constexpr void sincos(T angle, T& sin_val, T& cos_val)
cos_val = cos(angle); cos_val = cos(angle);
return; return;
} }
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
asm( asm(
"fsincos" "fsincos"
: "=t"(cos_val), "=u"(sin_val) : "=t"(cos_val), "=u"(sin_val)
@ -310,7 +310,7 @@ constexpr T tan(T angle)
{ {
CONSTEXPR_STATE(tan, angle); CONSTEXPR_STATE(tan, angle);
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
T ret, one; T ret, one;
asm( asm(
"fptan" "fptan"
@ -328,7 +328,7 @@ constexpr T atan(T value)
{ {
CONSTEXPR_STATE(atan, value); CONSTEXPR_STATE(atan, value);
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
T ret; T ret;
asm( asm(
"fld1\n" "fld1\n"
@ -384,7 +384,7 @@ constexpr T atan2(T y, T x)
{ {
CONSTEXPR_STATE(atan2, y, x); CONSTEXPR_STATE(atan2, y, x);
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
T ret; T ret;
asm("fpatan" asm("fpatan"
: "=t"(ret) : "=t"(ret)
@ -415,7 +415,7 @@ constexpr T log(T x)
{ {
CONSTEXPR_STATE(log, x); CONSTEXPR_STATE(log, x);
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
T ret; T ret;
asm( asm(
"fldln2\n" "fldln2\n"
@ -434,7 +434,7 @@ constexpr T log2(T x)
{ {
CONSTEXPR_STATE(log2, x); CONSTEXPR_STATE(log2, x);
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
T ret; T ret;
asm( asm(
"fld1\n" "fld1\n"
@ -453,7 +453,7 @@ constexpr T log10(T x)
{ {
CONSTEXPR_STATE(log10, x); CONSTEXPR_STATE(log10, x);
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
T ret; T ret;
asm( asm(
"fldlg2\n" "fldlg2\n"
@ -472,7 +472,7 @@ constexpr T exp(T exponent)
{ {
CONSTEXPR_STATE(exp, exponent); CONSTEXPR_STATE(exp, exponent);
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
T res; T res;
asm("fldl2e\n" asm("fldl2e\n"
"fmulp\n" "fmulp\n"
@ -496,7 +496,7 @@ constexpr T exp2(T exponent)
{ {
CONSTEXPR_STATE(exp2, exponent); CONSTEXPR_STATE(exp2, exponent);
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
T res; T res;
asm("fld1\n" asm("fld1\n"
"fld %%st(1)\n" "fld %%st(1)\n"
@ -585,7 +585,7 @@ using Hyperbolic::tanh;
template<Integral I, FloatingPoint P> template<Integral I, FloatingPoint P>
ALWAYS_INLINE I round_to(P value) ALWAYS_INLINE I round_to(P value)
{ {
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
// Note: fistps outputs into a signed integer location (i16, i32, i64), // Note: fistps outputs into a signed integer location (i16, i32, i64),
// so lets be nice and tell the compiler that. // so lets be nice and tell the compiler that.
Conditional<sizeof(I) >= sizeof(i16), MakeSigned<I>, i16> ret; Conditional<sizeof(I) >= sizeof(i16), MakeSigned<I>, i16> ret;
@ -679,22 +679,18 @@ ALWAYS_INLINE I round_to(P value)
#endif #endif
} }
#ifdef __SSE__ #if ARCH(x86_64)
template<Integral I> template<Integral I>
ALWAYS_INLINE I round_to(float value) ALWAYS_INLINE I round_to(float value)
{ {
if constexpr (sizeof(I) == sizeof(i64)) { if constexpr (sizeof(I) == sizeof(i64)) {
// Note: Outputting into 64-bit registers or memory locations requires the // Note: Outputting into 64-bit registers or memory locations requires the
// REX prefix, so we have to fall back to long doubles on i686 // REX prefix, so we have to fall back to long doubles on platforms
# if ARCH(X86_64)
i64 ret; i64 ret;
asm("cvtss2si %1, %0" asm("cvtss2si %1, %0"
: "=r"(ret) : "=r"(ret)
: "xm"(value)); : "xm"(value));
return static_cast<I>(ret); return static_cast<I>(ret);
# else
return round_to<I, long double>(value);
# endif
} }
i32 ret; i32 ret;
asm("cvtss2si %1, %0" asm("cvtss2si %1, %0"
@ -708,17 +704,11 @@ template<Integral I>
ALWAYS_INLINE I round_to(double value) ALWAYS_INLINE I round_to(double value)
{ {
if constexpr (sizeof(I) == sizeof(i64)) { if constexpr (sizeof(I) == sizeof(i64)) {
// Note: Outputting into 64-bit registers or memory locations requires the
// REX prefix, so we have to fall back to long doubles on i686
# if ARCH(X86_64)
i64 ret; i64 ret;
asm("cvtsd2si %1, %0" asm("cvtsd2si %1, %0"
: "=r"(ret) : "=r"(ret)
: "xm"(value)); : "xm"(value));
return static_cast<I>(ret); return static_cast<I>(ret);
# else
return round_to<I, long double>(value);
# endif
} }
i32 ret; i32 ret;
asm("cvtsd2si %1, %0" asm("cvtsd2si %1, %0"

View file

@ -18,7 +18,7 @@
ALWAYS_INLINE void fast_u32_copy(u32* dest, u32 const* src, size_t count) ALWAYS_INLINE void fast_u32_copy(u32* dest, u32 const* src, size_t count)
{ {
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
asm volatile( asm volatile(
"rep movsl\n" "rep movsl\n"
: "+S"(src), "+D"(dest), "+c"(count)::"memory"); : "+S"(src), "+D"(dest), "+c"(count)::"memory");
@ -29,7 +29,7 @@ ALWAYS_INLINE void fast_u32_copy(u32* dest, u32 const* src, size_t count)
ALWAYS_INLINE void fast_u32_fill(u32* dest, u32 value, size_t count) ALWAYS_INLINE void fast_u32_fill(u32* dest, u32 value, size_t count)
{ {
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
asm volatile( asm volatile(
"rep stosl\n" "rep stosl\n"
: "=D"(dest), "=c"(count) : "=D"(dest), "=c"(count)

View file

@ -94,7 +94,7 @@
#define ARCH(arch) (defined(AK_ARCH_##arch) && AK_ARCH_##arch) #define ARCH(arch) (defined(AK_ARCH_##arch) && AK_ARCH_##arch)
#if ARCH(I386) || ARCH(X86_64) #if ARCH(X86_64)
# define VALIDATE_IS_X86() # define VALIDATE_IS_X86()
#else #else
# define VALIDATE_IS_X86() static_assert(false, "Trying to include x86 only header on non x86 platform"); # define VALIDATE_IS_X86() static_assert(false, "Trying to include x86 only header on non x86 platform");

View file

@ -6,9 +6,7 @@
#pragma once #pragma once
#ifndef __SSE__
#include <AK/Math.h> #include <AK/Math.h>
#endif
#include <AK/SIMD.h> #include <AK/SIMD.h>
#include <AK/SIMDExtras.h> #include <AK/SIMDExtras.h>
#include <math.h> #include <math.h>
@ -70,7 +68,7 @@ ALWAYS_INLINE static f32x4 exp(f32x4 v)
ALWAYS_INLINE static f32x4 sqrt(f32x4 v) ALWAYS_INLINE static f32x4 sqrt(f32x4 v)
{ {
#ifdef __SSE__ #if ARCH(x86_64)
return __builtin_ia32_sqrtps(v); return __builtin_ia32_sqrtps(v);
#else #else
return f32x4 { return f32x4 {
@ -84,7 +82,7 @@ ALWAYS_INLINE static f32x4 sqrt(f32x4 v)
ALWAYS_INLINE static f32x4 rsqrt(f32x4 v) ALWAYS_INLINE static f32x4 rsqrt(f32x4 v)
{ {
#ifdef __SSE__ #if ARCH(x86_64)
return __builtin_ia32_rsqrtps(v); return __builtin_ia32_rsqrtps(v);
#else #else
return f32x4 { return f32x4 {

View file

@ -171,7 +171,7 @@ TEST_CASE(simple_cases)
// FIXME: These are different in 32 bit, since that will be removed some time (soon?) // FIXME: These are different in 32 bit, since that will be removed some time (soon?)
// we can remove this guard at that point. // we can remove this guard at that point.
#if not defined(__serenity__) || not ARCH(I386) #if not defined(__serenity__)
DOES_PARSE_FLOAT_AND_DOUBLE_LIKE_CPP(89255e-22); DOES_PARSE_FLOAT_AND_DOUBLE_LIKE_CPP(89255e-22);
DOES_PARSE_FLOAT_AND_DOUBLE_LIKE_CPP(8925.5e-21); DOES_PARSE_FLOAT_AND_DOUBLE_LIKE_CPP(8925.5e-21);
DOES_PARSE_FLOAT_AND_DOUBLE_LIKE_CPP(8.9255e-18); DOES_PARSE_FLOAT_AND_DOUBLE_LIKE_CPP(8.9255e-18);