From: Rich Felker Date: Wed, 20 Jan 2016 01:09:57 +0000 (+0000) Subject: replace armhf math asm source files with inline asm X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=e4355bd6bec89688e8c739cd7b4c76e675643dca;p=musl 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. --- 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 + +#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 + +#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 + +#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 + +#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