summaryrefslogtreecommitdiff
path: root/src/math
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2016-01-20 01:09:57 +0000
committerRich Felker <dalias@aerifal.cx>2016-01-20 01:09:57 +0000
commite4355bd6bec89688e8c739cd7b4c76e675643dca (patch)
tree53b4f0f0d7c5ba7e636edee2e0a977afacde931f /src/math
parentcb1875eb4ff755fe6c5d1909f64fc4be1ee396ab (diff)
downloadmusl-e4355bd6bec89688e8c739cd7b4c76e675643dca.tar.gz
musl-e4355bd6bec89688e8c739cd7b4c76e675643dca.tar.bz2
musl-e4355bd6bec89688e8c739cd7b4c76e675643dca.tar.xz
musl-e4355bd6bec89688e8c739cd7b4c76e675643dca.zip
replace armhf math asm source files with inline asm
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.
Diffstat (limited to 'src/math')
-rw-r--r--src/math/arm/fabs.c15
-rw-r--r--src/math/arm/fabsf.c15
-rw-r--r--src/math/arm/sqrt.c15
-rw-r--r--src/math/arm/sqrtf.c15
-rw-r--r--src/math/armebhf/fabs.sub1
-rw-r--r--src/math/armebhf/fabsf.sub1
-rw-r--r--src/math/armebhf/sqrt.sub1
-rw-r--r--src/math/armebhf/sqrtf.sub1
-rw-r--r--src/math/armhf/fabs.s8
-rw-r--r--src/math/armhf/fabs.sub1
-rw-r--r--src/math/armhf/fabsf.s8
-rw-r--r--src/math/armhf/fabsf.sub1
-rw-r--r--src/math/armhf/sqrt.s8
-rw-r--r--src/math/armhf/sqrt.sub1
-rw-r--r--src/math/armhf/sqrtf.s8
-rw-r--r--src/math/armhf/sqrtf.sub1
16 files changed, 60 insertions, 40 deletions
diff --git a/src/math/arm/fabs.c b/src/math/arm/fabs.c
new file mode 100644
index 00000000..f890520a
--- /dev/null
+++ b/src/math/arm/fabs.c
@@ -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
index 00000000..28153a61
--- /dev/null
+++ b/src/math/arm/fabsf.c
@@ -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
index 00000000..c9c00083
--- /dev/null
+++ b/src/math/arm/sqrt.c
@@ -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
index 00000000..e6576655
--- /dev/null
+++ b/src/math/arm/sqrtf.c
@@ -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
index 10d9fb7e..00000000
--- a/src/math/armebhf/fabs.sub
+++ /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
index 940b20bd..00000000
--- a/src/math/armebhf/fabsf.sub
+++ /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
index de2be116..00000000
--- a/src/math/armebhf/sqrt.sub
+++ /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
index 150ab9cc..00000000
--- a/src/math/armebhf/sqrtf.sub
+++ /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
index 0eb458d3..00000000
--- a/src/math/armhf/fabs.s
+++ /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
index 99e87406..00000000
--- a/src/math/armhf/fabs.sub
+++ /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
index da3809bb..00000000
--- a/src/math/armhf/fabsf.s
+++ /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
index c04638ae..00000000
--- a/src/math/armhf/fabsf.sub
+++ /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
index e38f060d..00000000
--- a/src/math/armhf/sqrt.s
+++ /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
index 25de7cfa..00000000
--- a/src/math/armhf/sqrt.sub
+++ /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
index 38c7ee89..00000000
--- a/src/math/armhf/sqrtf.s
+++ /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
index 3bcbac87..00000000
--- a/src/math/armhf/sqrtf.sub
+++ /dev/null
@@ -1 +0,0 @@
-sqrtf.s