Let clang generate most of our assembler for x86/x86-64 too.
It looks like the only functions current clang can't do are the lrint
family. Everything else looks good, and the fact that clang has builtins
means we shouldn't normally see calls to any of these functions anyway.
Test: llvm-objdump
Change-Id: I65b4da96b6c9b10f01cb54a7ebd1de5934ba4488
diff --git a/libm/builtins.cpp b/libm/builtins.cpp
index 99758ff..e66c3e7 100644
--- a/libm/builtins.cpp
+++ b/libm/builtins.cpp
@@ -22,9 +22,12 @@
float fabsf(float x) { return __builtin_fabsf(x); }
long double fabsl(long double x) { return __builtin_fabsl(x); }
-#if defined(__aarch64__)
+#if defined(__aarch64__) || defined(__i386__) || defined(__x86_64__)
float ceilf(float x) { return __builtin_ceilf(x); }
double ceil(double x) { return __builtin_ceil(x); }
+#if defined(__ILP32__)
+__weak_reference(ceil, ceill);
+#endif
#endif
#if defined(__aarch64__) || defined(__riscv)
@@ -32,7 +35,7 @@
float copysignf(float x, float y) { return __builtin_copysignf(x, y); }
#endif
-#if defined(__arm__) || defined(__aarch64__)
+#if defined(__arm__) || defined(__aarch64__) || defined(__i386__) || defined(__x86_64__)
float floorf(float x) { return __builtin_floorf(x); }
double floor(double x) { return __builtin_floor(x); }
#if defined(__ILP32__)
@@ -49,35 +52,45 @@
float fminf(float x, float y) { return __builtin_fminf(x, y); }
double fmin(double x, double y) { return __builtin_fmin(x, y); }
+#endif
+#if defined(__aarch64__) || defined(__riscv)
long lrint(double x) { return __builtin_lrint(x); }
long lrintf(float x) { return __builtin_lrintf(x); }
long long llrint(double x) { return __builtin_llrint(x); }
long long llrintf(float x) { return __builtin_llrintf(x); }
+#endif
+#if defined(__aarch64__) || defined(__riscv)
long lround(double x) { return __builtin_lround(x); }
long lroundf(float x) { return __builtin_lroundf(x); }
long long llround(double x) { return __builtin_llround(x); }
long long llroundf(float x) { return __builtin_llroundf(x); }
#endif
-#if defined(__aarch64__)
+#if defined(__aarch64__) || defined(__i386__) || defined(__x86_64__)
float rintf(float x) { return __builtin_rintf(x); }
double rint(double x) { return __builtin_rint(x); }
+#if defined(__ILP32__)
+__weak_reference(rint, rintl);
+#endif
+#endif
+#if defined(__aarch64__)
float roundf(float x) { return __builtin_roundf(x); }
double round(double x) { return __builtin_round(x); }
#endif
-#if defined(__arm__) || defined(__aarch64__) || defined(__riscv)
float sqrtf(float x) { return __builtin_sqrtf(x); }
double sqrt(double x) { return __builtin_sqrt(x); }
#if defined(__ILP32__)
__weak_reference(sqrt, sqrtl);
#endif
-#endif
-#if defined(__aarch64__)
+#if defined(__aarch64__) || defined(__i386__) || defined(__x86_64__)
float truncf(float x) { return __builtin_truncf(x); }
double trunc(double x) { return __builtin_trunc(x); }
+#if defined(__ILP32__)
+__weak_reference(trunc, truncl);
+#endif
#endif