math: move x87-family lrint functions to C with inline asm
authorAlexander Monakov <amonakov@ispras.ru>
Sat, 11 Jan 2020 15:14:24 +0000 (18:14 +0300)
committerRich Felker <dalias@aerifal.cx>
Tue, 24 Mar 2020 20:31:36 +0000 (16:31 -0400)
16 files changed:
src/math/i386/llrint.c [new file with mode: 0644]
src/math/i386/llrint.s [deleted file]
src/math/i386/llrintf.c [new file with mode: 0644]
src/math/i386/llrintf.s [deleted file]
src/math/i386/llrintl.c [new file with mode: 0644]
src/math/i386/llrintl.s [deleted file]
src/math/i386/lrint.c [new file with mode: 0644]
src/math/i386/lrint.s [deleted file]
src/math/i386/lrintf.c [new file with mode: 0644]
src/math/i386/lrintf.s [deleted file]
src/math/i386/lrintl.c [new file with mode: 0644]
src/math/i386/lrintl.s [deleted file]
src/math/x86_64/llrintl.c [new file with mode: 0644]
src/math/x86_64/llrintl.s [deleted file]
src/math/x86_64/lrintl.c [new file with mode: 0644]
src/math/x86_64/lrintl.s [deleted file]

diff --git a/src/math/i386/llrint.c b/src/math/i386/llrint.c
new file mode 100644 (file)
index 0000000..aa40081
--- /dev/null
@@ -0,0 +1,8 @@
+#include <math.h>
+
+long long llrint(double x)
+{
+       long long r;
+       __asm__ ("fistpll %0" : "=m"(r) : "t"(x) : "st");
+       return r;
+}
diff --git a/src/math/i386/llrint.s b/src/math/i386/llrint.s
deleted file mode 100644 (file)
index 8e89cd9..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-.global llrint
-.type llrint,@function
-llrint:
-       fldl 4(%esp)
-       fistpll 4(%esp)
-       mov 4(%esp),%eax
-       mov 8(%esp),%edx
-       ret
diff --git a/src/math/i386/llrintf.c b/src/math/i386/llrintf.c
new file mode 100644 (file)
index 0000000..c41a317
--- /dev/null
@@ -0,0 +1,8 @@
+#include <math.h>
+
+long long llrintf(float x)
+{
+       long long r;
+       __asm__ ("fistpll %0" : "=m"(r) : "t"(x) : "st");
+       return r;
+}
diff --git a/src/math/i386/llrintf.s b/src/math/i386/llrintf.s
deleted file mode 100644 (file)
index aa850c6..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-.global llrintf
-.type llrintf,@function
-llrintf:
-       sub $8,%esp
-       flds 12(%esp)
-       fistpll (%esp)
-       pop %eax
-       pop %edx
-       ret
diff --git a/src/math/i386/llrintl.c b/src/math/i386/llrintl.c
new file mode 100644 (file)
index 0000000..c439ef2
--- /dev/null
@@ -0,0 +1,8 @@
+#include <math.h>
+
+long long llrintl(long double x)
+{
+       long long r;
+       __asm__ ("fistpll %0" : "=m"(r) : "t"(x) : "st");
+       return r;
+}
diff --git a/src/math/i386/llrintl.s b/src/math/i386/llrintl.s
deleted file mode 100644 (file)
index 1cfb56f..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-.global llrintl
-.type llrintl,@function
-llrintl:
-       fldt 4(%esp)
-       fistpll 4(%esp)
-       mov 4(%esp),%eax
-       mov 8(%esp),%edx
-       ret
diff --git a/src/math/i386/lrint.c b/src/math/i386/lrint.c
new file mode 100644 (file)
index 0000000..89563ab
--- /dev/null
@@ -0,0 +1,8 @@
+#include <math.h>
+
+long lrint(double x)
+{
+       long r;
+       __asm__ ("fistpl %0" : "=m"(r) : "t"(x) : "st");
+       return r;
+}
diff --git a/src/math/i386/lrint.s b/src/math/i386/lrint.s
deleted file mode 100644 (file)
index 02b83d9..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-.global lrint
-.type lrint,@function
-lrint:
-       fldl 4(%esp)
-       fistpl 4(%esp)
-       mov 4(%esp),%eax
-       ret
diff --git a/src/math/i386/lrintf.c b/src/math/i386/lrintf.c
new file mode 100644 (file)
index 0000000..0bbf29d
--- /dev/null
@@ -0,0 +1,8 @@
+#include <math.h>
+
+long lrintf(float x)
+{
+       long r;
+       __asm__ ("fistpl %0" : "=m"(r) : "t"(x) : "st");
+       return r;
+}
diff --git a/src/math/i386/lrintf.s b/src/math/i386/lrintf.s
deleted file mode 100644 (file)
index 907aac2..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-.global lrintf
-.type lrintf,@function
-lrintf:
-       flds 4(%esp)
-       fistpl 4(%esp)
-       mov 4(%esp),%eax
-       ret
diff --git a/src/math/i386/lrintl.c b/src/math/i386/lrintl.c
new file mode 100644 (file)
index 0000000..eb8c090
--- /dev/null
@@ -0,0 +1,8 @@
+#include <math.h>
+
+long lrintl(long double x)
+{
+       long r;
+       __asm__ ("fistpl %0" : "=m"(r) : "t"(x) : "st");
+       return r;
+}
diff --git a/src/math/i386/lrintl.s b/src/math/i386/lrintl.s
deleted file mode 100644 (file)
index 3ae05aa..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-.global lrintl
-.type lrintl,@function
-lrintl:
-       fldt 4(%esp)
-       fistpl 4(%esp)
-       mov 4(%esp),%eax
-       ret
diff --git a/src/math/x86_64/llrintl.c b/src/math/x86_64/llrintl.c
new file mode 100644 (file)
index 0000000..c439ef2
--- /dev/null
@@ -0,0 +1,8 @@
+#include <math.h>
+
+long long llrintl(long double x)
+{
+       long long r;
+       __asm__ ("fistpll %0" : "=m"(r) : "t"(x) : "st");
+       return r;
+}
diff --git a/src/math/x86_64/llrintl.s b/src/math/x86_64/llrintl.s
deleted file mode 100644 (file)
index 1ec0817..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-.global llrintl
-.type llrintl,@function
-llrintl:
-       fldt 8(%rsp)
-       fistpll 8(%rsp)
-       mov 8(%rsp),%rax
-       ret
diff --git a/src/math/x86_64/lrintl.c b/src/math/x86_64/lrintl.c
new file mode 100644 (file)
index 0000000..068e2e4
--- /dev/null
@@ -0,0 +1,8 @@
+#include <math.h>
+
+long lrintl(long double x)
+{
+       long r;
+       __asm__ ("fistpll %0" : "=m"(r) : "t"(x) : "st");
+       return r;
+}
diff --git a/src/math/x86_64/lrintl.s b/src/math/x86_64/lrintl.s
deleted file mode 100644 (file)
index d587b12..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-.global lrintl
-.type lrintl,@function
-lrintl:
-       fldt 8(%rsp)
-       fistpll 8(%rsp)
-       mov 8(%rsp),%rax
-       ret