mirror of
git://git.musl-libc.org/musl
synced 2025-03-06 20:48:29 +01:00
math: move x87-family lrint functions to C with inline asm
This commit is contained in:
parent
6bbdbfdcde
commit
9443f1b5cf
16 changed files with 64 additions and 60 deletions
8
src/math/i386/llrint.c
Normal file
8
src/math/i386/llrint.c
Normal file
|
@ -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;
|
||||||
|
}
|
|
@ -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
|
|
8
src/math/i386/llrintf.c
Normal file
8
src/math/i386/llrintf.c
Normal file
|
@ -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;
|
||||||
|
}
|
|
@ -1,9 +0,0 @@
|
||||||
.global llrintf
|
|
||||||
.type llrintf,@function
|
|
||||||
llrintf:
|
|
||||||
sub $8,%esp
|
|
||||||
flds 12(%esp)
|
|
||||||
fistpll (%esp)
|
|
||||||
pop %eax
|
|
||||||
pop %edx
|
|
||||||
ret
|
|
8
src/math/i386/llrintl.c
Normal file
8
src/math/i386/llrintl.c
Normal file
|
@ -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;
|
||||||
|
}
|
|
@ -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
|
|
8
src/math/i386/lrint.c
Normal file
8
src/math/i386/lrint.c
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
long lrint(double x)
|
||||||
|
{
|
||||||
|
long r;
|
||||||
|
__asm__ ("fistpl %0" : "=m"(r) : "t"(x) : "st");
|
||||||
|
return r;
|
||||||
|
}
|
|
@ -1,7 +0,0 @@
|
||||||
.global lrint
|
|
||||||
.type lrint,@function
|
|
||||||
lrint:
|
|
||||||
fldl 4(%esp)
|
|
||||||
fistpl 4(%esp)
|
|
||||||
mov 4(%esp),%eax
|
|
||||||
ret
|
|
8
src/math/i386/lrintf.c
Normal file
8
src/math/i386/lrintf.c
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
long lrintf(float x)
|
||||||
|
{
|
||||||
|
long r;
|
||||||
|
__asm__ ("fistpl %0" : "=m"(r) : "t"(x) : "st");
|
||||||
|
return r;
|
||||||
|
}
|
|
@ -1,7 +0,0 @@
|
||||||
.global lrintf
|
|
||||||
.type lrintf,@function
|
|
||||||
lrintf:
|
|
||||||
flds 4(%esp)
|
|
||||||
fistpl 4(%esp)
|
|
||||||
mov 4(%esp),%eax
|
|
||||||
ret
|
|
8
src/math/i386/lrintl.c
Normal file
8
src/math/i386/lrintl.c
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
long lrintl(long double x)
|
||||||
|
{
|
||||||
|
long r;
|
||||||
|
__asm__ ("fistpl %0" : "=m"(r) : "t"(x) : "st");
|
||||||
|
return r;
|
||||||
|
}
|
|
@ -1,7 +0,0 @@
|
||||||
.global lrintl
|
|
||||||
.type lrintl,@function
|
|
||||||
lrintl:
|
|
||||||
fldt 4(%esp)
|
|
||||||
fistpl 4(%esp)
|
|
||||||
mov 4(%esp),%eax
|
|
||||||
ret
|
|
8
src/math/x86_64/llrintl.c
Normal file
8
src/math/x86_64/llrintl.c
Normal file
|
@ -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;
|
||||||
|
}
|
|
@ -1,7 +0,0 @@
|
||||||
.global llrintl
|
|
||||||
.type llrintl,@function
|
|
||||||
llrintl:
|
|
||||||
fldt 8(%rsp)
|
|
||||||
fistpll 8(%rsp)
|
|
||||||
mov 8(%rsp),%rax
|
|
||||||
ret
|
|
8
src/math/x86_64/lrintl.c
Normal file
8
src/math/x86_64/lrintl.c
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
long lrintl(long double x)
|
||||||
|
{
|
||||||
|
long r;
|
||||||
|
__asm__ ("fistpll %0" : "=m"(r) : "t"(x) : "st");
|
||||||
|
return r;
|
||||||
|
}
|
|
@ -1,7 +0,0 @@
|
||||||
.global lrintl
|
|
||||||
.type lrintl,@function
|
|
||||||
lrintl:
|
|
||||||
fldt 8(%rsp)
|
|
||||||
fistpll 8(%rsp)
|
|
||||||
mov 8(%rsp),%rax
|
|
||||||
ret
|
|
Loading…
Add table
Reference in a new issue