mirror of
git://git.musl-libc.org/musl
synced 2025-02-20 21:06:49 +00:00
mips: add single-instruction math functions
SQRT.fmt exists on MIPS II+ (float), MIPS III+ (double). ABS.fmt exists on MIPS I+ but only cores with ABS2008 flag in FCSR implement the required behaviour.
This commit is contained in:
parent
aa2d23e57c
commit
1c9d2cba11
16
src/math/mips/fabs.c
Normal file
16
src/math/mips/fabs.c
Normal file
@ -0,0 +1,16 @@
|
||||
#if !defined(__mips_soft_float) && defined(__mips_abs2008)
|
||||
|
||||
#include <math.h>
|
||||
|
||||
double fabs(double x)
|
||||
{
|
||||
double r;
|
||||
__asm__("abs.d %0,%1" : "=f"(r) : "f"(x));
|
||||
return r;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "../fabs.c"
|
||||
|
||||
#endif
|
16
src/math/mips/fabsf.c
Normal file
16
src/math/mips/fabsf.c
Normal file
@ -0,0 +1,16 @@
|
||||
#if !defined(__mips_soft_float) && defined(__mips_abs2008)
|
||||
|
||||
#include <math.h>
|
||||
|
||||
float fabsf(float x)
|
||||
{
|
||||
float r;
|
||||
__asm__("abs.s %0,%1" : "=f"(r) : "f"(x));
|
||||
return r;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "../fabsf.c"
|
||||
|
||||
#endif
|
16
src/math/mips/sqrt.c
Normal file
16
src/math/mips/sqrt.c
Normal file
@ -0,0 +1,16 @@
|
||||
#if !defined(__mips_soft_float) && __mips >= 3
|
||||
|
||||
#include <math.h>
|
||||
|
||||
double sqrt(double x)
|
||||
{
|
||||
double r;
|
||||
__asm__("sqrt.d %0,%1" : "=f"(r) : "f"(x));
|
||||
return r;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "../sqrt.c"
|
||||
|
||||
#endif
|
16
src/math/mips/sqrtf.c
Normal file
16
src/math/mips/sqrtf.c
Normal file
@ -0,0 +1,16 @@
|
||||
#if !defined(__mips_soft_float) && __mips >= 2
|
||||
|
||||
#include <math.h>
|
||||
|
||||
float sqrtf(float x)
|
||||
{
|
||||
float r;
|
||||
__asm__("sqrt.s %0,%1" : "=f"(r) : "f"(x));
|
||||
return r;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "../sqrtf.c"
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user