replace armhf math asm source files with inline asm
authorRich Felker <dalias@aerifal.cx>
Wed, 20 Jan 2016 01:09:57 +0000 (01:09 +0000)
committerRich Felker <dalias@aerifal.cx>
Wed, 20 Jan 2016 01:09:57 +0000 (01:09 +0000)
this makes it possible to inline them with LTO, and is the simplest
approach to eliminating the use of .sub files.

this also makes VFP sqrt available for use with the standard EABI
(plain arm rather than armhf subarch) when libc is built with
-mfloat-abi=softfp. the same could have been done for fabs, but when
the argument and return value are in integer registers, moving to VFP
registers and back is almost certainly more costly than a simple
integer operation.

16 files changed:
src/math/arm/fabs.c [new file with mode: 0644]
src/math/arm/fabsf.c [new file with mode: 0644]
src/math/arm/sqrt.c [new file with mode: 0644]
src/math/arm/sqrtf.c [new file with mode: 0644]
src/math/armebhf/fabs.sub [deleted file]
src/math/armebhf/fabsf.sub [deleted file]
src/math/armebhf/sqrt.sub [deleted file]
src/math/armebhf/sqrtf.sub [deleted file]
src/math/armhf/fabs.s [deleted file]
src/math/armhf/fabs.sub [deleted file]
src/math/armhf/fabsf.s [deleted file]
src/math/armhf/fabsf.sub [deleted file]
src/math/armhf/sqrt.s [deleted file]
src/math/armhf/sqrt.sub [deleted file]
src/math/armhf/sqrtf.s [deleted file]
src/math/armhf/sqrtf.sub [deleted file]

diff --git a/src/math/arm/fabs.c b/src/math/arm/fabs.c
new file mode 100644 (file)
index 0000000..f890520
--- /dev/null
@@ -0,0 +1,15 @@
+#include <math.h>
+
+#if __ARM_PCS_VFP
+
+double fabs(double x)
+{
+       __asm__ ("vabs.f64 %P0, %P1" : "=w"(x) : "w"(x));
+       return x;
+}
+
+#else
+
+#include "../fabs.c"
+
+#endif
diff --git a/src/math/arm/fabsf.c b/src/math/arm/fabsf.c
new file mode 100644 (file)
index 0000000..28153a6
--- /dev/null
@@ -0,0 +1,15 @@
+#include <math.h>
+
+#if __ARM_PCS_VFP
+
+float fabsf(float x)
+{
+       __asm__ ("vabs.f32 %0, %1" : "=t"(x) : "t"(x));
+       return x;
+}
+
+#else
+
+#include "../fabsf.c"
+
+#endif
diff --git a/src/math/arm/sqrt.c b/src/math/arm/sqrt.c
new file mode 100644 (file)
index 0000000..c9c0008
--- /dev/null
@@ -0,0 +1,15 @@
+#include <math.h>
+
+#if __VFP_FP__ && !__SOFTFP__
+
+double sqrt(double x)
+{
+       __asm__ ("vsqrt.f64 %P0, %P1" : "=w"(x) : "w"(x));
+       return x;
+}
+
+#else
+
+#include "../sqrt.c"
+
+#endif
diff --git a/src/math/arm/sqrtf.c b/src/math/arm/sqrtf.c
new file mode 100644 (file)
index 0000000..e657665
--- /dev/null
@@ -0,0 +1,15 @@
+#include <math.h>
+
+#if __VFP_FP__ && !__SOFTFP__
+
+float sqrtf(float x)
+{
+       __asm__ ("vsqrt.f32 %0, %1" : "=t"(x) : "t"(x));
+       return x;
+}
+
+#else
+
+#include "../sqrtf.c"
+
+#endif
diff --git a/src/math/armebhf/fabs.sub b/src/math/armebhf/fabs.sub
deleted file mode 100644 (file)
index 10d9fb7..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../armhf/fabs.s
diff --git a/src/math/armebhf/fabsf.sub b/src/math/armebhf/fabsf.sub
deleted file mode 100644 (file)
index 940b20b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../armhf/fabsf.s
diff --git a/src/math/armebhf/sqrt.sub b/src/math/armebhf/sqrt.sub
deleted file mode 100644 (file)
index de2be11..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../armhf/sqrt.s
diff --git a/src/math/armebhf/sqrtf.sub b/src/math/armebhf/sqrtf.sub
deleted file mode 100644 (file)
index 150ab9c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../armhf/sqrtf.s
diff --git a/src/math/armhf/fabs.s b/src/math/armhf/fabs.s
deleted file mode 100644 (file)
index 0eb458d..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-.syntax unified
-.fpu vfp
-.text
-.global fabs
-.type   fabs,%function
-fabs:
-       vabs.f64 d0, d0
-       bx lr
diff --git a/src/math/armhf/fabs.sub b/src/math/armhf/fabs.sub
deleted file mode 100644 (file)
index 99e8740..0000000
+++ /dev/null
@@ -1 +0,0 @@
-fabs.s
diff --git a/src/math/armhf/fabsf.s b/src/math/armhf/fabsf.s
deleted file mode 100644 (file)
index da3809b..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-.syntax unified
-.fpu vfp
-.text
-.global fabsf
-.type   fabsf,%function
-fabsf:
-       vabs.f32 s0, s0
-       bx lr
diff --git a/src/math/armhf/fabsf.sub b/src/math/armhf/fabsf.sub
deleted file mode 100644 (file)
index c04638a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-fabsf.s
diff --git a/src/math/armhf/sqrt.s b/src/math/armhf/sqrt.s
deleted file mode 100644 (file)
index e38f060..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-.syntax unified
-.fpu vfp
-.text
-.global sqrt
-.type   sqrt,%function
-sqrt:
-       vsqrt.f64 d0, d0
-       bx lr
diff --git a/src/math/armhf/sqrt.sub b/src/math/armhf/sqrt.sub
deleted file mode 100644 (file)
index 25de7cf..0000000
+++ /dev/null
@@ -1 +0,0 @@
-sqrt.s
diff --git a/src/math/armhf/sqrtf.s b/src/math/armhf/sqrtf.s
deleted file mode 100644 (file)
index 38c7ee8..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-.syntax unified
-.fpu vfp
-.text
-.global sqrtf
-.type   sqrtf,%function
-sqrtf:
-       vsqrt.f32 s0, s0
-       bx lr
diff --git a/src/math/armhf/sqrtf.sub b/src/math/armhf/sqrtf.sub
deleted file mode 100644 (file)
index 3bcbac8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-sqrtf.s