提交 e4355bd6 编写于 作者: R Rich Felker

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.
上级 cb1875eb
#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
#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
#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
#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
.syntax unified
.fpu vfp
.text
.global fabs
.type fabs,%function
fabs:
vabs.f64 d0, d0
bx lr
.syntax unified
.fpu vfp
.text
.global fabsf
.type fabsf,%function
fabsf:
vabs.f32 s0, s0
bx lr
.syntax unified
.fpu vfp
.text
.global sqrt
.type sqrt,%function
sqrt:
vsqrt.f64 d0, d0
bx lr
.syntax unified
.fpu vfp
.text
.global sqrtf
.type sqrtf,%function
sqrtf:
vsqrt.f32 s0, s0
bx lr
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册