mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
AK: Make math work on arm hosts again
957f89ce4a
added some tweaks for serenity-on-aarch64.
It broke anythingelse-on-aarch64 hosts though, so only do these tweaks
when targeting serenity.
(I wonder if AK/Math.h should fall back to the system math routines
when not targeting serenity in general. Would probably help ladybird
performance. On the other hand, the serenity routines would see less
use and hence exposure and love.)
This commit is contained in:
parent
bf5a18babb
commit
fc15fc36ce
Notes:
sideshowbarker
2024-07-17 20:22:04 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/fc15fc36ce Pull-request: https://github.com/SerenityOS/serenity/pull/18368 Reviewed-by: https://github.com/caoimhebyrne ✅
1 changed files with 30 additions and 0 deletions
30
AK/Math.h
30
AK/Math.h
|
@ -90,8 +90,10 @@ constexpr T fmod(T x, T y)
|
||||||
} while (fpu_status & 0x400);
|
} while (fpu_status & 0x400);
|
||||||
return x;
|
return x;
|
||||||
#else
|
#else
|
||||||
|
# if defined(AK_OS_SERENITY)
|
||||||
// TODO: Add implementation for this function.
|
// TODO: Add implementation for this function.
|
||||||
TODO();
|
TODO();
|
||||||
|
# endif
|
||||||
return __builtin_fmod(x, y);
|
return __builtin_fmod(x, y);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -111,8 +113,10 @@ constexpr T remainder(T x, T y)
|
||||||
} while (fpu_status & 0x400);
|
} while (fpu_status & 0x400);
|
||||||
return x;
|
return x;
|
||||||
#else
|
#else
|
||||||
|
# if defined(AK_OS_SERENITY)
|
||||||
// TODO: Add implementation for this function.
|
// TODO: Add implementation for this function.
|
||||||
TODO();
|
TODO();
|
||||||
|
# endif
|
||||||
return __builtin_fmod(x, y);
|
return __builtin_fmod(x, y);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -248,9 +252,13 @@ constexpr T sin(T angle)
|
||||||
: "0"(angle));
|
: "0"(angle));
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
|
# if defined(AK_OS_SERENITY)
|
||||||
// FIXME: This is a very naive implementation, and is only valid for small x.
|
// FIXME: This is a very naive implementation, and is only valid for small x.
|
||||||
// Probably a good idea to use a better algorithm in the future, such as a taylor approximation.
|
// Probably a good idea to use a better algorithm in the future, such as a taylor approximation.
|
||||||
return angle;
|
return angle;
|
||||||
|
# else
|
||||||
|
return __builtin_sin(angle);
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,9 +275,13 @@ constexpr T cos(T angle)
|
||||||
: "0"(angle));
|
: "0"(angle));
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
|
# if defined(AK_OS_SERENITY)
|
||||||
// FIXME: This is a very naive implementation, and is only valid for small x.
|
// FIXME: This is a very naive implementation, and is only valid for small x.
|
||||||
// Probably a good idea to use a better algorithm in the future, such as a taylor approximation.
|
// Probably a good idea to use a better algorithm in the future, such as a taylor approximation.
|
||||||
return 1 - ((angle * angle) / 2);
|
return 1 - ((angle * angle) / 2);
|
||||||
|
# else
|
||||||
|
return __builtin_cos(angle);
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,9 +318,13 @@ constexpr T tan(T angle)
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
|
# if defined(AK_OS_SERENITY)
|
||||||
// FIXME: This is a very naive implementation, and is only valid for small x.
|
// FIXME: This is a very naive implementation, and is only valid for small x.
|
||||||
// Probably a good idea to use a better algorithm in the future, such as a taylor approximation.
|
// Probably a good idea to use a better algorithm in the future, such as a taylor approximation.
|
||||||
return angle;
|
return angle;
|
||||||
|
# else
|
||||||
|
return __builtin_tan(angle);
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,8 +342,10 @@ constexpr T atan(T value)
|
||||||
: "0"(value));
|
: "0"(value));
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
|
# if defined(AK_OS_SERENITY)
|
||||||
// TODO: Add implementation for this function.
|
// TODO: Add implementation for this function.
|
||||||
TODO();
|
TODO();
|
||||||
|
# endif
|
||||||
return __builtin_atan(value);
|
return __builtin_atan(value);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -383,8 +401,10 @@ constexpr T atan2(T y, T x)
|
||||||
: "st(1)");
|
: "st(1)");
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
|
# if defined(AK_OS_SERENITY)
|
||||||
// TODO: Add implementation for this function.
|
// TODO: Add implementation for this function.
|
||||||
TODO();
|
TODO();
|
||||||
|
# endif
|
||||||
return __builtin_atan2(y, x);
|
return __builtin_atan2(y, x);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -418,8 +438,10 @@ constexpr T log(T x)
|
||||||
: "0"(x));
|
: "0"(x));
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
|
# if defined(AK_OS_SERENITY)
|
||||||
// TODO: Add implementation for this function.
|
// TODO: Add implementation for this function.
|
||||||
TODO();
|
TODO();
|
||||||
|
# endif
|
||||||
return __builtin_log(x);
|
return __builtin_log(x);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -439,8 +461,10 @@ constexpr T log2(T x)
|
||||||
: "0"(x));
|
: "0"(x));
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
|
# if defined(AK_OS_SERENITY)
|
||||||
// TODO: Add implementation for this function.
|
// TODO: Add implementation for this function.
|
||||||
TODO();
|
TODO();
|
||||||
|
# endif
|
||||||
return __builtin_log2(x);
|
return __builtin_log2(x);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -460,8 +484,10 @@ constexpr T log10(T x)
|
||||||
: "0"(x));
|
: "0"(x));
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
|
# if defined(AK_OS_SERENITY)
|
||||||
// TODO: Add implementation for this function.
|
// TODO: Add implementation for this function.
|
||||||
TODO();
|
TODO();
|
||||||
|
# endif
|
||||||
return __builtin_log10(x);
|
return __builtin_log10(x);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -486,8 +512,10 @@ constexpr T exp(T exponent)
|
||||||
: "0"(exponent));
|
: "0"(exponent));
|
||||||
return res;
|
return res;
|
||||||
#else
|
#else
|
||||||
|
# if defined(AK_OS_SERENITY)
|
||||||
// TODO: Add implementation for this function.
|
// TODO: Add implementation for this function.
|
||||||
TODO();
|
TODO();
|
||||||
|
# endif
|
||||||
return __builtin_exp(exponent);
|
return __builtin_exp(exponent);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -510,8 +538,10 @@ constexpr T exp2(T exponent)
|
||||||
: "0"(exponent));
|
: "0"(exponent));
|
||||||
return res;
|
return res;
|
||||||
#else
|
#else
|
||||||
|
# if defined(AK_OS_SERENITY)
|
||||||
// TODO: Add implementation for this function.
|
// TODO: Add implementation for this function.
|
||||||
TODO();
|
TODO();
|
||||||
|
# endif
|
||||||
return __builtin_exp2(exponent);
|
return __builtin_exp2(exponent);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue