math: move x86_64 (l)lrint(f) functions to C with inline asm
authorAlexander Monakov <amonakov@ispras.ru>
Fri, 10 Jan 2020 20:06:36 +0000 (23:06 +0300)
committerRich Felker <dalias@aerifal.cx>
Tue, 24 Mar 2020 20:31:36 +0000 (16:31 -0400)
src/math/x86_64/llrint.c [new file with mode: 0644]
src/math/x86_64/llrint.s [deleted file]
src/math/x86_64/llrintf.c [new file with mode: 0644]
src/math/x86_64/llrintf.s [deleted file]
src/math/x86_64/lrint.c [new file with mode: 0644]
src/math/x86_64/lrint.s [deleted file]
src/math/x86_64/lrintf.c [new file with mode: 0644]
src/math/x86_64/lrintf.s [deleted file]

diff --git a/src/math/x86_64/llrint.c b/src/math/x86_64/llrint.c
new file mode 100644 (file)
index 0000000..dd38a72
--- /dev/null
@@ -0,0 +1,8 @@
+#include <math.h>
+
+long long llrint(double x)
+{
+       long long r;
+       __asm__ ("cvtsd2si %1, %0" : "=r"(r) : "x"(x));
+       return r;
+}
diff --git a/src/math/x86_64/llrint.s b/src/math/x86_64/llrint.s
deleted file mode 100644 (file)
index bf47649..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-.global llrint
-.type llrint,@function
-llrint:
-       cvtsd2si %xmm0,%rax
-       ret
diff --git a/src/math/x86_64/llrintf.c b/src/math/x86_64/llrintf.c
new file mode 100644 (file)
index 0000000..fc8625e
--- /dev/null
@@ -0,0 +1,8 @@
+#include <math.h>
+
+long long llrintf(float x)
+{
+       long long r;
+       __asm__ ("cvtss2si %1, %0" : "=r"(r) : "x"(x));
+       return r;
+}
diff --git a/src/math/x86_64/llrintf.s b/src/math/x86_64/llrintf.s
deleted file mode 100644 (file)
index d7204ac..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-.global llrintf
-.type llrintf,@function
-llrintf:
-       cvtss2si %xmm0,%rax
-       ret
diff --git a/src/math/x86_64/lrint.c b/src/math/x86_64/lrint.c
new file mode 100644 (file)
index 0000000..a742fec
--- /dev/null
@@ -0,0 +1,8 @@
+#include <math.h>
+
+long lrint(double x)
+{
+       long r;
+       __asm__ ("cvtsd2si %1, %0" : "=r"(r) : "x"(x));
+       return r;
+}
diff --git a/src/math/x86_64/lrint.s b/src/math/x86_64/lrint.s
deleted file mode 100644 (file)
index 15fc245..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-.global lrint
-.type lrint,@function
-lrint:
-       cvtsd2si %xmm0,%rax
-       ret
diff --git a/src/math/x86_64/lrintf.c b/src/math/x86_64/lrintf.c
new file mode 100644 (file)
index 0000000..2ba5639
--- /dev/null
@@ -0,0 +1,8 @@
+#include <math.h>
+
+long lrintf(float x)
+{
+       long r;
+       __asm__ ("cvtss2si %1, %0" : "=r"(r) : "x"(x));
+       return r;
+}
diff --git a/src/math/x86_64/lrintf.s b/src/math/x86_64/lrintf.s
deleted file mode 100644 (file)
index 488423d..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-.global lrintf
-.type lrintf,@function
-lrintf:
-       cvtss2si %xmm0,%rax
-       ret