summaryrefslogtreecommitdiffstats
path: root/libc-top-half/musl/src/math/x32
diff options
context:
space:
mode:
Diffstat (limited to 'libc-top-half/musl/src/math/x32')
-rw-r--r--libc-top-half/musl/src/math/x32/__invtrigl.s0
-rw-r--r--libc-top-half/musl/src/math/x32/acosl.s16
-rw-r--r--libc-top-half/musl/src/math/x32/asinl.s12
-rw-r--r--libc-top-half/musl/src/math/x32/atan2l.s7
-rw-r--r--libc-top-half/musl/src/math/x32/atanl.s7
-rw-r--r--libc-top-half/musl/src/math/x32/ceill.s1
-rw-r--r--libc-top-half/musl/src/math/x32/exp2l.s83
-rw-r--r--libc-top-half/musl/src/math/x32/expl.s101
-rw-r--r--libc-top-half/musl/src/math/x32/expm1l.s1
-rw-r--r--libc-top-half/musl/src/math/x32/fabs.s9
-rw-r--r--libc-top-half/musl/src/math/x32/fabsf.s7
-rw-r--r--libc-top-half/musl/src/math/x32/fabsl.s6
-rw-r--r--libc-top-half/musl/src/math/x32/floorl.s27
-rw-r--r--libc-top-half/musl/src/math/x32/fma.c23
-rw-r--r--libc-top-half/musl/src/math/x32/fmaf.c23
-rw-r--r--libc-top-half/musl/src/math/x32/fmodl.s11
-rw-r--r--libc-top-half/musl/src/math/x32/llrint.s5
-rw-r--r--libc-top-half/musl/src/math/x32/llrintf.s5
-rw-r--r--libc-top-half/musl/src/math/x32/llrintl.s7
-rw-r--r--libc-top-half/musl/src/math/x32/log10l.s7
-rw-r--r--libc-top-half/musl/src/math/x32/log1pl.s15
-rw-r--r--libc-top-half/musl/src/math/x32/log2l.s7
-rw-r--r--libc-top-half/musl/src/math/x32/logl.s7
-rw-r--r--libc-top-half/musl/src/math/x32/lrint.s5
-rw-r--r--libc-top-half/musl/src/math/x32/lrintf.s5
-rw-r--r--libc-top-half/musl/src/math/x32/lrintl.s7
-rw-r--r--libc-top-half/musl/src/math/x32/remainderl.s11
-rw-r--r--libc-top-half/musl/src/math/x32/rintl.s6
-rw-r--r--libc-top-half/musl/src/math/x32/sqrt.s4
-rw-r--r--libc-top-half/musl/src/math/x32/sqrtf.s4
-rw-r--r--libc-top-half/musl/src/math/x32/sqrtl.s5
-rw-r--r--libc-top-half/musl/src/math/x32/truncl.s1
32 files changed, 435 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/math/x32/__invtrigl.s b/libc-top-half/musl/src/math/x32/__invtrigl.s
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/__invtrigl.s
diff --git a/libc-top-half/musl/src/math/x32/acosl.s b/libc-top-half/musl/src/math/x32/acosl.s
new file mode 100644
index 0000000..1abca12
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/acosl.s
@@ -0,0 +1,16 @@
+# see ../i386/acos.s
+
+.global acosl
+.type acosl,@function
+acosl:
+ fldt 8(%esp)
+1: fld %st(0)
+ fld1
+ fsub %st(0),%st(1)
+ fadd %st(2)
+ fmulp
+ fsqrt
+ fabs
+ fxch %st(1)
+ fpatan
+ ret
diff --git a/libc-top-half/musl/src/math/x32/asinl.s b/libc-top-half/musl/src/math/x32/asinl.s
new file mode 100644
index 0000000..7fe9f12
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/asinl.s
@@ -0,0 +1,12 @@
+.global asinl
+.type asinl,@function
+asinl:
+ fldt 8(%esp)
+1: fld %st(0)
+ fld1
+ fsub %st(0),%st(1)
+ fadd %st(2)
+ fmulp
+ fsqrt
+ fpatan
+ ret
diff --git a/libc-top-half/musl/src/math/x32/atan2l.s b/libc-top-half/musl/src/math/x32/atan2l.s
new file mode 100644
index 0000000..1ead078
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/atan2l.s
@@ -0,0 +1,7 @@
+.global atan2l
+.type atan2l,@function
+atan2l:
+ fldt 8(%esp)
+ fldt 24(%esp)
+ fpatan
+ ret
diff --git a/libc-top-half/musl/src/math/x32/atanl.s b/libc-top-half/musl/src/math/x32/atanl.s
new file mode 100644
index 0000000..f475fe0
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/atanl.s
@@ -0,0 +1,7 @@
+.global atanl
+.type atanl,@function
+atanl:
+ fldt 8(%esp)
+ fld1
+ fpatan
+ ret
diff --git a/libc-top-half/musl/src/math/x32/ceill.s b/libc-top-half/musl/src/math/x32/ceill.s
new file mode 100644
index 0000000..f5cfa3b
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/ceill.s
@@ -0,0 +1 @@
+# see floorl.s
diff --git a/libc-top-half/musl/src/math/x32/exp2l.s b/libc-top-half/musl/src/math/x32/exp2l.s
new file mode 100644
index 0000000..e9edb96
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/exp2l.s
@@ -0,0 +1,83 @@
+.global expm1l
+.type expm1l,@function
+expm1l:
+ fldt 8(%esp)
+ fldl2e
+ fmulp
+ movl $0xc2820000,-4(%esp)
+ flds -4(%esp)
+ fucomip %st(1),%st
+ fld1
+ jb 1f
+ # x*log2e <= -65, return -1 without underflow
+ fstp %st(1)
+ fchs
+ ret
+1: fld %st(1)
+ fabs
+ fucomip %st(1),%st
+ fstp %st(0)
+ ja 1f
+ f2xm1
+ ret
+1: push %rax
+ call 1f
+ pop %rax
+ fld1
+ fsubrp
+ ret
+
+.global exp2l
+.type exp2l,@function
+exp2l:
+ fldt 8(%esp)
+1: fld %st(0)
+ sub $16,%esp
+ fstpt (%esp)
+ mov 8(%esp),%ax
+ and $0x7fff,%ax
+ cmp $0x3fff+13,%ax
+ jb 4f # |x| < 8192
+ cmp $0x3fff+15,%ax
+ jae 3f # |x| >= 32768
+ fsts (%esp)
+ cmpl $0xc67ff800,(%esp)
+ jb 2f # x > -16382
+ movl $0x5f000000,(%esp)
+ flds (%esp) # 0x1p63
+ fld %st(1)
+ fsub %st(1)
+ faddp
+ fucomip %st(1),%st
+ je 2f # x - 0x1p63 + 0x1p63 == x
+ movl $1,(%esp)
+ flds (%esp) # 0x1p-149
+ fdiv %st(1)
+ fstps (%esp) # raise underflow
+2: fld1
+ fld %st(1)
+ frndint
+ fxch %st(2)
+ fsub %st(2) # st(0)=x-rint(x), st(1)=1, st(2)=rint(x)
+ f2xm1
+ faddp # 2^(x-rint(x))
+1: fscale
+ fstp %st(1)
+ add $16,%esp
+ ret
+3: xor %eax,%eax
+4: cmp $0x3fff-64,%ax
+ fld1
+ jb 1b # |x| < 0x1p-64
+ fstpt (%esp)
+ fistl 8(%esp)
+ fildl 8(%esp)
+ fsubrp %st(1)
+ addl $0x3fff,8(%esp)
+ f2xm1
+ fld1
+ faddp # 2^(x-rint(x))
+ fldt (%esp) # 2^rint(x)
+ fmulp
+ add $16,%esp
+ ret
diff --git a/libc-top-half/musl/src/math/x32/expl.s b/libc-top-half/musl/src/math/x32/expl.s
new file mode 100644
index 0000000..369f7bd
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/expl.s
@@ -0,0 +1,101 @@
+# exp(x) = 2^hi + 2^hi (2^lo - 1)
+# where hi+lo = log2e*x with 128bit precision
+# exact log2e*x calculation depends on nearest rounding mode
+# using the exact multiplication method of Dekker and Veltkamp
+
+.global expl
+.type expl,@function
+expl:
+ fldt 8(%esp)
+
+ # interesting case: 0x1p-32 <= |x| < 16384
+ # check if (exponent|0x8000) is in [0xbfff-32, 0xbfff+13]
+ mov 16(%esp), %ax
+ or $0x8000, %ax
+ sub $0xbfdf, %ax
+ cmp $45, %ax
+ jbe 2f
+ test %ax, %ax
+ fld1
+ js 1f
+ # if |x|>=0x1p14 or nan return 2^trunc(x)
+ fscale
+ fstp %st(1)
+ ret
+ # if |x|<0x1p-32 return 1+x
+1: faddp
+ ret
+
+ # should be 0x1.71547652b82fe178p0L == 0x3fff b8aa3b29 5c17f0bc
+ # it will be wrong on non-nearest rounding mode
+2: fldl2e
+ sub $48, %esp
+ # hi = log2e_hi*x
+ # 2^hi = exp2l(hi)
+ fmul %st(1),%st
+ fld %st(0)
+ fstpt (%esp)
+ fstpt 16(%esp)
+ fstpt 32(%esp)
+ call exp2l@PLT
+ # if 2^hi == inf return 2^hi
+ fld %st(0)
+ fstpt (%esp)
+ cmpw $0x7fff, 8(%esp)
+ je 1f
+ fldt 32(%esp)
+ fldt 16(%esp)
+ # fpu stack: 2^hi x hi
+ # exact mult: x*log2e
+ fld %st(1)
+ # c = 0x1p32+1
+ movq $0x41f0000000100000,%rax
+ pushq %rax
+ fldl (%esp)
+ # xh = x - c*x + c*x
+ # xl = x - xh
+ fmulp
+ fld %st(2)
+ fsub %st(1), %st
+ faddp
+ fld %st(2)
+ fsub %st(1), %st
+ # yh = log2e_hi - c*log2e_hi + c*log2e_hi
+ movq $0x3ff7154765200000,%rax
+ pushq %rax
+ fldl (%esp)
+ # fpu stack: 2^hi x hi xh xl yh
+ # lo = hi - xh*yh + xl*yh
+ fld %st(2)
+ fmul %st(1), %st
+ fsubp %st, %st(4)
+ fmul %st(1), %st
+ faddp %st, %st(3)
+ # yl = log2e_hi - yh
+ movq $0x3de705fc2f000000,%rax
+ pushq %rax
+ fldl (%esp)
+ # fpu stack: 2^hi x lo xh xl yl
+ # lo += xh*yl + xl*yl
+ fmul %st, %st(2)
+ fmulp %st, %st(1)
+ fxch %st(2)
+ faddp
+ faddp
+ # log2e_lo
+ movq $0xbfbe,%rax
+ pushq %rax
+ movq $0x82f0025f2dc582ee,%rax
+ pushq %rax
+ fldt (%esp)
+ add $40,%esp
+ # fpu stack: 2^hi x lo log2e_lo
+ # lo += log2e_lo*x
+ # return 2^hi + 2^hi (2^lo - 1)
+ fmulp %st, %st(2)
+ faddp
+ f2xm1
+ fmul %st(1), %st
+ faddp
+1: add $48, %esp
+ ret
diff --git a/libc-top-half/musl/src/math/x32/expm1l.s b/libc-top-half/musl/src/math/x32/expm1l.s
new file mode 100644
index 0000000..e773f08
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/expm1l.s
@@ -0,0 +1 @@
+# see exp2l.s
diff --git a/libc-top-half/musl/src/math/x32/fabs.s b/libc-top-half/musl/src/math/x32/fabs.s
new file mode 100644
index 0000000..5715005
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/fabs.s
@@ -0,0 +1,9 @@
+.global fabs
+.type fabs,@function
+fabs:
+ xor %eax,%eax
+ dec %rax
+ shr %rax
+ movq %rax,%xmm1
+ andpd %xmm1,%xmm0
+ ret
diff --git a/libc-top-half/musl/src/math/x32/fabsf.s b/libc-top-half/musl/src/math/x32/fabsf.s
new file mode 100644
index 0000000..501a1f1
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/fabsf.s
@@ -0,0 +1,7 @@
+.global fabsf
+.type fabsf,@function
+fabsf:
+ mov $0x7fffffff,%eax
+ movq %rax,%xmm1
+ andps %xmm1,%xmm0
+ ret
diff --git a/libc-top-half/musl/src/math/x32/fabsl.s b/libc-top-half/musl/src/math/x32/fabsl.s
new file mode 100644
index 0000000..4f215df
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/fabsl.s
@@ -0,0 +1,6 @@
+.global fabsl
+.type fabsl,@function
+fabsl:
+ fldt 8(%esp)
+ fabs
+ ret
diff --git a/libc-top-half/musl/src/math/x32/floorl.s b/libc-top-half/musl/src/math/x32/floorl.s
new file mode 100644
index 0000000..78dcb6d
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/floorl.s
@@ -0,0 +1,27 @@
+.global floorl
+.type floorl,@function
+floorl:
+ fldt 8(%esp)
+1: mov $0x7,%al
+1: fstcw 8(%esp)
+ mov 9(%esp),%ah
+ mov %al,9(%esp)
+ fldcw 8(%esp)
+ frndint
+ mov %ah,9(%esp)
+ fldcw 8(%esp)
+ ret
+
+.global ceill
+.type ceill,@function
+ceill:
+ fldt 8(%esp)
+ mov $0xb,%al
+ jmp 1b
+
+.global truncl
+.type truncl,@function
+truncl:
+ fldt 8(%esp)
+ mov $0xf,%al
+ jmp 1b
diff --git a/libc-top-half/musl/src/math/x32/fma.c b/libc-top-half/musl/src/math/x32/fma.c
new file mode 100644
index 0000000..4dd53f2
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/fma.c
@@ -0,0 +1,23 @@
+#include <math.h>
+
+#if __FMA__
+
+double fma(double x, double y, double z)
+{
+ __asm__ ("vfmadd132sd %1, %2, %0" : "+x" (x) : "x" (y), "x" (z));
+ return x;
+}
+
+#elif __FMA4__
+
+double fma(double x, double y, double z)
+{
+ __asm__ ("vfmaddsd %3, %2, %1, %0" : "=x" (x) : "x" (x), "x" (y), "x" (z));
+ return x;
+}
+
+#else
+
+#include "../fma.c"
+
+#endif
diff --git a/libc-top-half/musl/src/math/x32/fmaf.c b/libc-top-half/musl/src/math/x32/fmaf.c
new file mode 100644
index 0000000..30b971f
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/fmaf.c
@@ -0,0 +1,23 @@
+#include <math.h>
+
+#if __FMA__
+
+float fmaf(float x, float y, float z)
+{
+ __asm__ ("vfmadd132ss %1, %2, %0" : "+x" (x) : "x" (y), "x" (z));
+ return x;
+}
+
+#elif __FMA4__
+
+float fmaf(float x, float y, float z)
+{
+ __asm__ ("vfmaddss %3, %2, %1, %0" : "=x" (x) : "x" (x), "x" (y), "x" (z));
+ return x;
+}
+
+#else
+
+#include "../fmaf.c"
+
+#endif
diff --git a/libc-top-half/musl/src/math/x32/fmodl.s b/libc-top-half/musl/src/math/x32/fmodl.s
new file mode 100644
index 0000000..c3f790c
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/fmodl.s
@@ -0,0 +1,11 @@
+.global fmodl
+.type fmodl,@function
+fmodl:
+ fldt 24(%esp)
+ fldt 8(%esp)
+1: fprem
+ fnstsw %ax
+ testb $4,%ah
+ jnz 1b
+ fstp %st(1)
+ ret
diff --git a/libc-top-half/musl/src/math/x32/llrint.s b/libc-top-half/musl/src/math/x32/llrint.s
new file mode 100644
index 0000000..bf47649
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/llrint.s
@@ -0,0 +1,5 @@
+.global llrint
+.type llrint,@function
+llrint:
+ cvtsd2si %xmm0,%rax
+ ret
diff --git a/libc-top-half/musl/src/math/x32/llrintf.s b/libc-top-half/musl/src/math/x32/llrintf.s
new file mode 100644
index 0000000..d7204ac
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/llrintf.s
@@ -0,0 +1,5 @@
+.global llrintf
+.type llrintf,@function
+llrintf:
+ cvtss2si %xmm0,%rax
+ ret
diff --git a/libc-top-half/musl/src/math/x32/llrintl.s b/libc-top-half/musl/src/math/x32/llrintl.s
new file mode 100644
index 0000000..0938607
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/llrintl.s
@@ -0,0 +1,7 @@
+.global llrintl
+.type llrintl,@function
+llrintl:
+ fldt 8(%esp)
+ fistpll 8(%esp)
+ mov 8(%esp),%rax
+ ret
diff --git a/libc-top-half/musl/src/math/x32/log10l.s b/libc-top-half/musl/src/math/x32/log10l.s
new file mode 100644
index 0000000..ef5bea3
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/log10l.s
@@ -0,0 +1,7 @@
+.global log10l
+.type log10l,@function
+log10l:
+ fldlg2
+ fldt 8(%esp)
+ fyl2x
+ ret
diff --git a/libc-top-half/musl/src/math/x32/log1pl.s b/libc-top-half/musl/src/math/x32/log1pl.s
new file mode 100644
index 0000000..2e64fd4
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/log1pl.s
@@ -0,0 +1,15 @@
+.global log1pl
+.type log1pl,@function
+log1pl:
+ mov 14(%esp),%eax
+ fldln2
+ and $0x7fffffff,%eax
+ fldt 8(%esp)
+ cmp $0x3ffd9400,%eax
+ ja 1f
+ fyl2xp1
+ ret
+1: fld1
+ faddp
+ fyl2x
+ ret
diff --git a/libc-top-half/musl/src/math/x32/log2l.s b/libc-top-half/musl/src/math/x32/log2l.s
new file mode 100644
index 0000000..bf88e8e
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/log2l.s
@@ -0,0 +1,7 @@
+.global log2l
+.type log2l,@function
+log2l:
+ fld1
+ fldt 8(%esp)
+ fyl2x
+ ret
diff --git a/libc-top-half/musl/src/math/x32/logl.s b/libc-top-half/musl/src/math/x32/logl.s
new file mode 100644
index 0000000..eff6450
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/logl.s
@@ -0,0 +1,7 @@
+.global logl
+.type logl,@function
+logl:
+ fldln2
+ fldt 8(%esp)
+ fyl2x
+ ret
diff --git a/libc-top-half/musl/src/math/x32/lrint.s b/libc-top-half/musl/src/math/x32/lrint.s
new file mode 100644
index 0000000..15fc245
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/lrint.s
@@ -0,0 +1,5 @@
+.global lrint
+.type lrint,@function
+lrint:
+ cvtsd2si %xmm0,%rax
+ ret
diff --git a/libc-top-half/musl/src/math/x32/lrintf.s b/libc-top-half/musl/src/math/x32/lrintf.s
new file mode 100644
index 0000000..488423d
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/lrintf.s
@@ -0,0 +1,5 @@
+.global lrintf
+.type lrintf,@function
+lrintf:
+ cvtss2si %xmm0,%rax
+ ret
diff --git a/libc-top-half/musl/src/math/x32/lrintl.s b/libc-top-half/musl/src/math/x32/lrintl.s
new file mode 100644
index 0000000..d4355c3
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/lrintl.s
@@ -0,0 +1,7 @@
+.global lrintl
+.type lrintl,@function
+lrintl:
+ fldt 8(%esp)
+ fistpl 8(%esp)
+ movl 8(%esp),%eax
+ ret
diff --git a/libc-top-half/musl/src/math/x32/remainderl.s b/libc-top-half/musl/src/math/x32/remainderl.s
new file mode 100644
index 0000000..376ba0e
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/remainderl.s
@@ -0,0 +1,11 @@
+.global remainderl
+.type remainderl,@function
+remainderl:
+ fldt 24(%esp)
+ fldt 8(%esp)
+1: fprem1
+ fnstsw %ax
+ testb $4,%ah
+ jnz 1b
+ fstp %st(1)
+ ret
diff --git a/libc-top-half/musl/src/math/x32/rintl.s b/libc-top-half/musl/src/math/x32/rintl.s
new file mode 100644
index 0000000..be1d2fa
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/rintl.s
@@ -0,0 +1,6 @@
+.global rintl
+.type rintl,@function
+rintl:
+ fldt 8(%esp)
+ frndint
+ ret
diff --git a/libc-top-half/musl/src/math/x32/sqrt.s b/libc-top-half/musl/src/math/x32/sqrt.s
new file mode 100644
index 0000000..d3c609f
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/sqrt.s
@@ -0,0 +1,4 @@
+.global sqrt
+.type sqrt,@function
+sqrt: sqrtsd %xmm0, %xmm0
+ ret
diff --git a/libc-top-half/musl/src/math/x32/sqrtf.s b/libc-top-half/musl/src/math/x32/sqrtf.s
new file mode 100644
index 0000000..eec48c6
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/sqrtf.s
@@ -0,0 +1,4 @@
+.global sqrtf
+.type sqrtf,@function
+sqrtf: sqrtss %xmm0, %xmm0
+ ret
diff --git a/libc-top-half/musl/src/math/x32/sqrtl.s b/libc-top-half/musl/src/math/x32/sqrtl.s
new file mode 100644
index 0000000..8d70856
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/sqrtl.s
@@ -0,0 +1,5 @@
+.global sqrtl
+.type sqrtl,@function
+sqrtl: fldt 8(%esp)
+ fsqrt
+ ret
diff --git a/libc-top-half/musl/src/math/x32/truncl.s b/libc-top-half/musl/src/math/x32/truncl.s
new file mode 100644
index 0000000..f5cfa3b
--- /dev/null
+++ b/libc-top-half/musl/src/math/x32/truncl.s
@@ -0,0 +1 @@
+# see floorl.s