提交 1c9d2cba 编写于 作者: I info@mobile-stream.com 提交者: Rich Felker

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.
上级 aa2d23e5
#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
#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
#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
#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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册