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.
This commit is contained in:
Rich Felker
2016-01-20 01:09:57 +00:00
parent cb1875eb4f
commit e4355bd6be
16 changed files with 60 additions and 40 deletions
+15
View File
@@ -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
+15
View File
@@ -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
+15
View File
@@ -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
+15
View File
@@ -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
-1
View File
@@ -1 +0,0 @@
../armhf/fabs.s
-1
View File
@@ -1 +0,0 @@
../armhf/fabsf.s
-1
View File
@@ -1 +0,0 @@
../armhf/sqrt.s
-1
View File
@@ -1 +0,0 @@
../armhf/sqrtf.s
-8
View File
@@ -1,8 +0,0 @@
.syntax unified
.fpu vfp
.text
.global fabs
.type fabs,%function
fabs:
vabs.f64 d0, d0
bx lr
-1
View File
@@ -1 +0,0 @@
fabs.s
-8
View File
@@ -1,8 +0,0 @@
.syntax unified
.fpu vfp
.text
.global fabsf
.type fabsf,%function
fabsf:
vabs.f32 s0, s0
bx lr
-1
View File
@@ -1 +0,0 @@
fabsf.s
-8
View File
@@ -1,8 +0,0 @@
.syntax unified
.fpu vfp
.text
.global sqrt
.type sqrt,%function
sqrt:
vsqrt.f64 d0, d0
bx lr
-1
View File
@@ -1 +0,0 @@
sqrt.s
-8
View File
@@ -1,8 +0,0 @@
.syntax unified
.fpu vfp
.text
.global sqrtf
.type sqrtf,%function
sqrtf:
vsqrt.f32 s0, s0
bx lr
-1
View File
@@ -1 +0,0 @@
sqrtf.s