소스 검색

math: move x86_64 (l)lrint(f) functions to C with inline asm

Alexander Monakov 5 년 전
부모
커밋
6bbdbfdcde
8개의 변경된 파일32개의 추가작업 그리고 20개의 파일을 삭제
  1. 8 0
      src/math/x86_64/llrint.c
  2. 0 5
      src/math/x86_64/llrint.s
  3. 8 0
      src/math/x86_64/llrintf.c
  4. 0 5
      src/math/x86_64/llrintf.s
  5. 8 0
      src/math/x86_64/lrint.c
  6. 0 5
      src/math/x86_64/lrint.s
  7. 8 0
      src/math/x86_64/lrintf.c
  8. 0 5
      src/math/x86_64/lrintf.s

+ 8 - 0
src/math/x86_64/llrint.c

@@ -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;
+}

+ 0 - 5
src/math/x86_64/llrint.s

@@ -1,5 +0,0 @@
-.global llrint
-.type llrint,@function
-llrint:
-	cvtsd2si %xmm0,%rax
-	ret

+ 8 - 0
src/math/x86_64/llrintf.c

@@ -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;
+}

+ 0 - 5
src/math/x86_64/llrintf.s

@@ -1,5 +0,0 @@
-.global llrintf
-.type llrintf,@function
-llrintf:
-	cvtss2si %xmm0,%rax
-	ret

+ 8 - 0
src/math/x86_64/lrint.c

@@ -0,0 +1,8 @@
+#include <math.h>
+
+long lrint(double x)
+{
+	long r;
+	__asm__ ("cvtsd2si %1, %0" : "=r"(r) : "x"(x));
+	return r;
+}

+ 0 - 5
src/math/x86_64/lrint.s

@@ -1,5 +0,0 @@
-.global lrint
-.type lrint,@function
-lrint:
-	cvtsd2si %xmm0,%rax
-	ret

+ 8 - 0
src/math/x86_64/lrintf.c

@@ -0,0 +1,8 @@
+#include <math.h>
+
+long lrintf(float x)
+{
+	long r;
+	__asm__ ("cvtss2si %1, %0" : "=r"(r) : "x"(x));
+	return r;
+}

+ 0 - 5
src/math/x86_64/lrintf.s

@@ -1,5 +0,0 @@
-.global lrintf
-.type lrintf,@function
-lrintf:
-	cvtss2si %xmm0,%rax
-	ret