Преглед на файлове

math: move x87-family fabs functions to C with inline asm

Alexander Monakov преди 5 години
родител
ревизия
c24a992386
променени са 8 файла, в които са добавени 28 реда и са изтрити 24 реда
  1. 7 0
      src/math/i386/fabs.c
  2. 0 6
      src/math/i386/fabs.s
  3. 7 0
      src/math/i386/fabsf.c
  4. 0 6
      src/math/i386/fabsf.s
  5. 7 0
      src/math/i386/fabsl.c
  6. 0 6
      src/math/i386/fabsl.s
  7. 7 0
      src/math/x86_64/fabsl.c
  8. 0 6
      src/math/x86_64/fabsl.s

+ 7 - 0
src/math/i386/fabs.c

@@ -0,0 +1,7 @@
+#include <math.h>
+
+double fabs(double x)
+{
+	__asm__ ("fabs" : "+t"(x));
+	return x;
+}

+ 0 - 6
src/math/i386/fabs.s

@@ -1,6 +0,0 @@
-.global fabs
-.type fabs,@function
-fabs:
-	fldl 4(%esp)
-	fabs
-	ret

+ 7 - 0
src/math/i386/fabsf.c

@@ -0,0 +1,7 @@
+#include <math.h>
+
+float fabsf(float x)
+{
+	__asm__ ("fabs" : "+t"(x));
+	return x;
+}

+ 0 - 6
src/math/i386/fabsf.s

@@ -1,6 +0,0 @@
-.global fabsf
-.type fabsf,@function
-fabsf:
-	flds 4(%esp)
-	fabs
-	ret

+ 7 - 0
src/math/i386/fabsl.c

@@ -0,0 +1,7 @@
+#include <math.h>
+
+long double fabsl(long double x)
+{
+	__asm__ ("fabs" : "+t"(x));
+	return x;
+}

+ 0 - 6
src/math/i386/fabsl.s

@@ -1,6 +0,0 @@
-.global fabsl
-.type fabsl,@function
-fabsl:
-	fldt 4(%esp)
-	fabs
-	ret

+ 7 - 0
src/math/x86_64/fabsl.c

@@ -0,0 +1,7 @@
+#include <math.h>
+
+long double fabsl(long double x)
+{
+	__asm__ ("fabs" : "+t"(x));
+	return x;
+}

+ 0 - 6
src/math/x86_64/fabsl.s

@@ -1,6 +0,0 @@
-.global fabsl
-.type fabsl,@function
-fabsl:
-	fldt 8(%rsp)
-	fabs
-	ret