about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorinfo@mobile-stream.com <info@mobile-stream.com>2019-09-11 13:05:04 +0300
committerRich Felker <dalias@aerifal.cx>2019-10-14 10:04:47 -0400
commit1c9d2cba11ef2c9de31a6edb48eb20777be4a4f8 (patch)
tree8d269e5fc6e757ea291f0c2a6512ca8be493a66d /src
parentaa2d23e57c9c95f0ffeb80cb035e5a5be52d8ef0 (diff)
downloadmusl-1c9d2cba11ef2c9de31a6edb48eb20777be4a4f8.tar.gz
musl-1c9d2cba11ef2c9de31a6edb48eb20777be4a4f8.tar.xz
musl-1c9d2cba11ef2c9de31a6edb48eb20777be4a4f8.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/math/mips/fabs.c16
-rw-r--r--src/math/mips/fabsf.c16
-rw-r--r--src/math/mips/sqrt.c16
-rw-r--r--src/math/mips/sqrtf.c16
4 files changed, 64 insertions, 0 deletions
diff --git a/src/math/mips/fabs.c b/src/math/mips/fabs.c
new file mode 100644
index 00000000..0a5aa3b1
--- /dev/null
+++ b/src/math/mips/fabs.c
@@ -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
diff --git a/src/math/mips/fabsf.c b/src/math/mips/fabsf.c
new file mode 100644
index 00000000..35307be6
--- /dev/null
+++ b/src/math/mips/fabsf.c
@@ -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
diff --git a/src/math/mips/sqrt.c b/src/math/mips/sqrt.c
new file mode 100644
index 00000000..595c9dbc
--- /dev/null
+++ b/src/math/mips/sqrt.c
@@ -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
diff --git a/src/math/mips/sqrtf.c b/src/math/mips/sqrtf.c
new file mode 100644
index 00000000..84090d2d
--- /dev/null
+++ b/src/math/mips/sqrtf.c
@@ -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