浏览代码

powerpc: add single instruction fabs, fabsf, fma, fmaf, sqrt, sqrtf

These are only available on hard float target and sqrt is not available
in the base ISA, so further check is used.
Szabolcs Nagy 6 年之前
父节点
当前提交
7c5f3bb955
共有 6 个文件被更改,包括 90 次插入0 次删除
  1. 15 0
      src/math/powerpc/fabs.c
  2. 15 0
      src/math/powerpc/fabsf.c
  3. 15 0
      src/math/powerpc/fma.c
  4. 15 0
      src/math/powerpc/fmaf.c
  5. 15 0
      src/math/powerpc/sqrt.c
  6. 15 0
      src/math/powerpc/sqrtf.c

+ 15 - 0
src/math/powerpc/fabs.c

@@ -0,0 +1,15 @@
+#include <math.h>
+
+#ifdef _SOFT_FLOAT
+
+#include "../fabs.c"
+
+#else
+
+double fabs(double x)
+{
+	__asm__ ("fabs %0, %1" : "=d"(x) : "d"(x));
+	return x;
+}
+
+#endif

+ 15 - 0
src/math/powerpc/fabsf.c

@@ -0,0 +1,15 @@
+#include <math.h>
+
+#ifdef _SOFT_FLOAT
+
+#include "../fabsf.c"
+
+#else
+
+float fabsf(float x)
+{
+	__asm__ ("fabs %0, %1" : "=f"(x) : "f"(x));
+	return x;
+}
+
+#endif

+ 15 - 0
src/math/powerpc/fma.c

@@ -0,0 +1,15 @@
+#include <math.h>
+
+#ifdef _SOFT_FLOAT
+
+#include "../fma.c"
+
+#else
+
+double fma(double x, double y, double z)
+{
+	__asm__("fmadd %0, %1, %2, %3" : "=d"(x) : "d"(x), "d"(y), "d"(z));
+	return x;
+}
+
+#endif

+ 15 - 0
src/math/powerpc/fmaf.c

@@ -0,0 +1,15 @@
+#include <math.h>
+
+#ifdef _SOFT_FLOAT
+
+#include "../fmaf.c"
+
+#else
+
+float fmaf(float x, float y, float z)
+{
+	__asm__("fmadds %0, %1, %2, %3" : "=f"(x) : "f"(x), "f"(y), "f"(z));
+	return x;
+}
+
+#endif

+ 15 - 0
src/math/powerpc/sqrt.c

@@ -0,0 +1,15 @@
+#include <math.h>
+
+#if !defined _SOFT_FLOAT && defined _ARCH_PPCSQ
+
+double sqrt(double x)
+{
+	__asm__ ("fsqrt %0, %1\n" : "=d" (x) : "d" (x));
+	return x;
+}
+
+#else
+
+#include "../sqrt.c"
+
+#endif

+ 15 - 0
src/math/powerpc/sqrtf.c

@@ -0,0 +1,15 @@
+#include <math.h>
+
+#if !defined _SOFT_FLOAT && defined _ARCH_PPCSQ
+
+float sqrtf(float x)
+{
+	__asm__ ("fsqrts %0, %1\n" : "=f" (x) : "f" (x));
+	return x;
+}
+
+#else
+
+#include "../sqrtf.c"
+
+#endif