Remove sun musl fdlibm math library

The libm code from musl wasn't being used since most of these functions
are implemented using x87 which goes faster than a library intended for
risc machines.
This commit is contained in:
Justine Tunney 2021-01-31 18:25:16 -08:00
parent e6481efa80
commit fdc3fa9148
388 changed files with 304 additions and 19472 deletions

View file

@ -23,8 +23,6 @@
/
/ @param 𝑥 is double scalar in low half of %xmm0
/ @return double scalar in low half of %xmm0
tinymath_acos:
ezlea tinymath_acosl,ax
acos: ezlea acosl,ax
jmp _d2ld2
.endfn tinymath_acos,globl
.alias tinymath_acos,acos
.endfn acos,globl

View file

@ -23,8 +23,6 @@
/
/ @param 𝑥 is float scalar in low quarter of %xmm0
/ @return float scalar in low quarter of %xmm0
tinymath_acosf:
ezlea tinymath_acosl,ax
acosf: ezlea acosl,ax
jmp _f2ld2
.endfn tinymath_acosf,globl
.alias tinymath_acosf,acosf
.endfn acosf,globl

View file

@ -26,8 +26,7 @@
/ @define atan2(abs(sqrt((1-𝑥)*(1+𝑥))),𝑥)
/ @domain -1 ≤ 𝑥 ≤ 1
/ @mode long,legacy
tinymath_acosl:
push %rbp
acosl: push %rbp
mov %rsp,%rbp
.profilable
fldl 16(%rbp)
@ -49,8 +48,7 @@ tinymath_acosl:
fpatan
pop %rbp
ret
.endfn tinymath_acosl,globl
.alias tinymath_acosl,acosl
.endfn acosl,globl
.rodata.cst4
.Lone: .float 1.0

View file

@ -23,8 +23,6 @@
/
/ @param 𝑥 is double scalar in low half of %xmm0
/ @return double scalar in low half of %xmm0
tinymath_asin:
ezlea tinymath_asinl,ax
asin: ezlea asinl,ax
jmp _d2ld2
.endfn tinymath_asin,globl
.alias tinymath_asin,asin
.endfn asin,globl

View file

@ -23,8 +23,6 @@
/
/ @param 𝑥 is float scalar in low quarter of %xmm0
/ @return float scalar in low quarter of %xmm0
tinymath_asinf:
ezlea tinymath_asinl,ax
asinf: ezlea asinl,ax
jmp _f2ld2
.endfn tinymath_asinf,globl
.alias tinymath_asinf,asinf
.endfn asinf,globl

View file

@ -26,8 +26,7 @@
/ @define atan2(𝑥,sqrt((1-𝑥)*(1+𝑥)))
/ @domain -1 ≤ 𝑥 ≤ 1
/ @mode long,legacy
tinymath_asinl:
push %rbp
asinl: push %rbp
mov %rsp,%rbp
.profilable
fldl 16(%rbp)
@ -46,8 +45,7 @@ tinymath_asinl:
fpatan
pop %rbp
ret
.endfn tinymath_asinl,globl
.alias tinymath_asinl,asinl
.endfn asinl,globl
.rodata.cst4
.Lone: .float 1.0

View file

@ -23,8 +23,6 @@
/
/ @param 𝑥 is double scalar in low half of %xmm0
/ @return double scalar in low half of %xmm0
tinymath_atan:
ezlea tinymath_atanl,ax
atan: ezlea atanl,ax
jmp _d2ld2
.endfn tinymath_atan,globl
.alias tinymath_atan,atan
.endfn atan,globl

View file

@ -25,8 +25,6 @@
/ @param 𝑥 is double scalar in low half of %xmm1
/ @return double scalar in low half of %xmm0
/ @note the greatest of all libm functions
tinymath_atan2:
ezlea tinymath_atan2l,ax
atan2: ezlea atan2l,ax
jmp _d2ld2
.endfn tinymath_atan2,globl
.alias tinymath_atan2,atan2
.endfn atan2,globl

View file

@ -24,8 +24,6 @@
/ @param 𝑦 is float scalar in low quarter of %xmm0
/ @param 𝑥 is float scalar in low quarter of %xmm1
/ @return float scalar in low quarter of %xmm0
tinymath_atan2f:
ezlea tinymath_atan2l,ax
atan2f: ezlea atan2l,ax
jmp _f2ld2
.endfn tinymath_atan2f,globl
.alias tinymath_atan2f,atan2f
.endfn atan2f,globl

View file

@ -24,8 +24,7 @@
/ @param 𝑥 is an 80-bit long double passed on stack in 16-bytes
/ @param 𝑦 is an 80-bit long double passed on stack in 16-bytes
/ @return result of computation on FPU stack in %st
tinymath_atan2l:
push %rbp
atan2l: push %rbp
mov %rsp,%rbp
.profilable
fldt 16(%rbp)
@ -33,5 +32,4 @@ tinymath_atan2l:
fpatan
pop %rbp
ret
.endfn tinymath_atan2l,globl
.alias tinymath_atan2l,atan2l
.endfn atan2l,globl

View file

@ -23,8 +23,6 @@
/
/ @param 𝑥 is float scalar in low quarter of %xmm0
/ @return float scalar in low quarter of %xmm0
tinymath_atanf:
ezlea tinymath_atanl,ax
atanf: ezlea atanl,ax
jmp _f2ld2
.endfn tinymath_atanf,globl
.alias tinymath_atanf,atanf
.endfn atanf,globl

View file

@ -28,8 +28,7 @@
/ @param 𝑥 is an 80-bit long double passed on stack in 16-bytes
/ @return result of computation on FPU stack in %st
/ @define atan(𝑥) = Σₙ₌₀₋∞ 2²ⁿ(𝑛!)²/(𝟸𝑛+𝟷)!(𝑥²ⁿ⁺¹/(𝑥²+𝟷)ⁿ⁺¹)
tinymath_atanl:
push %rbp
atanl: push %rbp
mov %rsp,%rbp
.profilable
fldt 16(%rbp)
@ -37,5 +36,4 @@ tinymath_atanl:
fpatan
pop %rbp
ret
.endfn tinymath_atanl,globl
.alias tinymath_atanl,atanl
.endfn atanl,globl

View file

@ -20,7 +20,5 @@
.source __FILE__
/ Returns absolute value of complex number.
tinymath_cabs:
jmp tinymath_hypot
.endfn tinymath_cabs,globl
.alias tinymath_cabs,cabs
cabs: jmp hypot
.endfn cabs,globl

View file

@ -19,8 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_cabsf:
push %rbp
cabsf: push %rbp
mov %rsp,%rbp
.profilable
sub $16,%rsp
@ -35,5 +34,4 @@ tinymath_cabsf:
sqrtss %xmm0,%xmm0
leave
ret
.endfn tinymath_cabsf,globl
.alias tinymath_cabsf,cabsf
.endfn cabsf,globl

View file

@ -19,8 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_cabsl:
push %rbp
cabsl: push %rbp
mov %rsp,%rbp
.profilable
fldt 32(%rbp)
@ -32,5 +31,4 @@ tinymath_cabsl:
fsqrt
pop %rbp
ret
.endfn tinymath_cabsl,globl
.alias tinymath_cabsl,cabsl
.endfn cabsl,globl

View file

@ -19,8 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_carg:
push %rbp
carg: push %rbp
mov %rsp,%rbp
.profilable
sub $16,%rsp
@ -34,5 +33,4 @@ tinymath_carg:
movsd -16(%rbp),%xmm0
leave
ret
.endfn tinymath_carg,globl
.alias tinymath_carg,carg
.endfn carg,globl

View file

@ -19,8 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_cargf:
push %rbp
cargf: push %rbp
mov %rsp,%rbp
.profilable
sub $16,%rsp
@ -32,5 +31,4 @@ tinymath_cargf:
movss 4(%rsp),%xmm0
leave
ret
.endfn tinymath_cargf,globl
.alias tinymath_cargf,cargf
.endfn cargf,globl

View file

@ -19,8 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_cargl:
push %rbp
cargl: push %rbp
mov %rsp,%rbp
.profilable
fldt 32(%rbp)
@ -28,5 +27,4 @@ tinymath_cargl:
fpatan
pop %rbp
ret
.endfn tinymath_cargl,globl
.alias tinymath_cargl,cargl
.endfn cargl,globl

View file

@ -22,8 +22,6 @@
/
/ @param %xmm0 holds binary64 number
/ @return %xmm0 holds binary64 result
tinymath_cbrt:
jmp __cbrt
.endfn tinymath_cbrt,globl
.alias tinymath_cbrt,cbrt
cbrt: jmp __cbrt
.endfn cbrt,globl
.source __FILE__

View file

@ -22,14 +22,12 @@
/
/ @param %xmm0 holds binary32 number
/ @return %xmm0 holds binary32 result
tinymath_cbrtf:
pushq %rbp
cbrtf: pushq %rbp
mov %rsp,%rbp
cvtss2sd %xmm0,%xmm0
call __cbrt
cvtsd2ss %xmm0,%xmm0
popq %rbp
ret
.endfn tinymath_cbrtf,globl
.alias tinymath_cbrtf,cbrtf
.endfn cbrtf,globl
.source __FILE__

View file

@ -22,8 +22,7 @@
/
/ @param 𝑥 is an 80-bit long double passed on stack in 16-bytes
/ @return result of computation on FPU stack in %st
tinymath_cbrtl:
pushq %rbp
cbrtl: pushq %rbp
mov %rsp,%rbp
sub $16,%rsp
fldt 16(%rbp)
@ -34,6 +33,5 @@ tinymath_cbrtl:
fldl -8(%rbp)
leave
ret
.endfn tinymath_cbrtl,globl
.alias tinymath_cbrtl,cbrtl
.endfn cbrtl,globl
.source __FILE__

View file

@ -19,8 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_ceil:
.leafprologue
ceil: .leafprologue
.profilable
movsd nan(%rip),%xmm1
movsd sig(%rip),%xmm2
@ -35,8 +34,7 @@ tinymath_ceil:
andpd %xmm2,%xmm0
addsd %xmm1,%xmm0
1: .leafepilogue
.endfn tinymath_ceil,globl
.alias tinymath_ceil,ceil
.endfn ceil,globl
.rodata.cst8
nan: .double nan

View file

@ -19,8 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_ceilf:
.leafprologue
ceilf: .leafprologue
.profilable
movss .L3(%rip),%xmm1
andps %xmm0,%xmm1
@ -35,8 +34,7 @@ tinymath_ceilf:
andps %xmm2,%xmm0
addss %xmm1,%xmm0
1: .leafepilogue
.endfn tinymath_ceilf,globl
.alias tinymath_ceilf,ceilf
.endfn ceilf,globl
.rodata.cst4
.L1: .float 1.0

View file

@ -19,8 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_ceill:
.profilable
ceill: .profilable
sub $24,%rsp
fldt 32(%rsp)
fnstcw 14(%rsp)
@ -33,5 +32,4 @@ tinymath_ceill:
fldcw 14(%rsp)
add $24,%rsp
ret
.endfn tinymath_ceill,globl
.alias tinymath_ceill,ceill
.endfn ceill,globl

View file

@ -19,13 +19,11 @@
#include "libc/macros.h"
.source __FILE__
tinymath_conj:
.leafprologue
conj: .leafprologue
.profilable
xorpd .L1(%rip),%xmm1
.leafepilogue
.endfn tinymath_conj,globl
.alias tinymath_conj,conj
.endfn conj,globl
.rodata.cst16
.L1: .long 0

View file

@ -19,8 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_conjf:
.profilable
conjf: .profilable
sub $16,%rsp
movq %xmm0,8(%rsp)
movss 12(%rsp),%xmm0
@ -31,8 +30,7 @@ tinymath_conjf:
movq (%rsp),%xmm0
add $16,%rsp
ret
.endfn tinymath_conjf,globl
.alias tinymath_conjf,conjf
.endfn conjf,globl
.rodata.cst16
.L1: .long 2147483648

View file

@ -19,8 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_conjl:
.profilable
conjl: .profilable
sub $24,%rsp
fldt 32(%rsp)
fnstcw 14(%rsp)
@ -41,5 +40,4 @@ tinymath_conjl:
add $24,%rsp
mov %rcx,%rdx
ret
.endfn tinymath_conjl,globl
.alias tinymath_conjl,conjl
.endfn conjl,globl

View file

@ -19,7 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_copysign:
copysign:
.leafprologue
.profilable
movapd %xmm1,%xmm2
@ -27,8 +27,7 @@ tinymath_copysign:
andpd .Lneg0(%rip),%xmm2
orpd %xmm2,%xmm0
.leafepilogue
.endfn tinymath_copysign,globl
.alias tinymath_copysign,copysign
.endfn copysign,globl
.rodata.cst16
.Lnan: .long 0xffffffff

View file

@ -19,7 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_copysignf:
copysignf:
.leafprologue
.profilable
movaps %xmm1,%xmm2
@ -27,8 +27,7 @@ tinymath_copysignf:
andps .LC10(%rip),%xmm2
orps %xmm2,%xmm0
.leafepilogue
.endfn tinymath_copysignf,globl
.alias tinymath_copysignf,copysignf
.endfn copysignf,globl
.rodata.cst16
.LC8: .long 2147483647

View file

@ -20,7 +20,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_copysignl:
copysignl:
push %rbp
mov %rsp,%rbp
.profilable
@ -35,5 +35,4 @@ tinymath_copysignl:
fchs
1: pop %rbp
ret
.endfn tinymath_copysignl,globl
.alias tinymath_copysignl,copysignl
.endfn copysignl,globl

View file

@ -24,8 +24,6 @@
/ @param 𝑥 is double scalar in low half of %xmm0
/ @return double scalar in low half of %xmm0
/ @domain -(3π/8) < 𝑥 < 3π/8 for best accuracy
tinymath_cos:
ezlea tinymath_cosl,ax
cos: ezlea cosl,ax
jmp _d2ld2
.endfn tinymath_cos,globl
.alias tinymath_cos,cos
.endfn cos,globl

View file

@ -24,8 +24,6 @@
/ @param 𝑥 is float scalar in low quarter of %xmm0
/ @return float scalar in low quarter of %xmm0
/ @domain -(3π/8) < 𝑥 < 3π/8 for best accuracy
tinymath_cosf:
ezlea tinymath_cosl,ax
cosf: ezlea cosl,ax
jmp _f2ld2
.endfn tinymath_cosf,globl
.alias tinymath_cosf,cosf
.endfn cosf,globl

View file

@ -24,8 +24,7 @@
/ @param 𝑥 is an 80-bit long double passed on stack in 16-bytes
/ @domain -(3π/8) < 𝑥 < 3π/8 for best accuracy
/ @return %st stores result
tinymath_cosl:
push %rbp
cosl: push %rbp
mov %rsp,%rbp
.profilable
fldt 16(%rbp)
@ -33,8 +32,7 @@ tinymath_cosl:
call c2rangr
pop %rbp
ret
.endfn tinymath_cosl,globl
.alias tinymath_cosl,cosl
.endfn cosl,globl
_cos: .leafprologue
.profilable

View file

@ -19,8 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_cprojf:
push %rbp
cprojf: push %rbp
mov %rsp,%rbp
.profilable
sub $16,%rsp
@ -32,5 +31,4 @@ tinymath_cprojf:
movq (%rsp),%xmm0
leave
ret
.endfn tinymath_cprojf,globl
.alias tinymath_cprojf,cprojf
.endfn cprojf,globl

View file

@ -23,8 +23,7 @@
/
/ @param z is complex long double passed on stack
/ @note needs sse3
tinymath_cprojl:
.profilable
cprojl: .profilable
sub $24,%rsp
fldt 32(%rsp)
fisttpq 8(%rsp)
@ -36,5 +35,4 @@ tinymath_cprojl:
add $24,%rsp
mov %rcx,%rdx
ret
.endfn tinymath_cprojl,globl
.alias tinymath_cprojl,cprojl
.endfn cprojl,globl

View file

@ -23,8 +23,6 @@
/
/ @param 𝑥 is float scalar in low quarter of %xmm0
/ @return float scalar in low quarter of %xmm0
tinymath_exp:
ezlea tinymath_expl,ax
exp: ezlea expl,ax
jmp _d2ld2
.endfn tinymath_exp,globl
.alias tinymath_exp,exp
.endfn exp,globl

View file

@ -24,9 +24,8 @@
/ @param 𝑥 is double scalar in low half of %xmm0
/ @return double scalar in low half of %xmm0
/ @see pow(), exp()
tinymath_exp10:
ezlea tinymath_exp10l,ax
exp10:
ezlea exp10l,ax
jmp _d2ld2
.endfn tinymath_exp10,globl
.alias tinymath_exp10,exp10
.alias tinymath_exp10,pow10
.endfn exp10,globl
.alias exp10,pow10

View file

@ -23,9 +23,8 @@
/
/ @param 𝑥 is float scalar in low quarter of %xmm0
/ @return float scalar in low quarter of %xmm0
tinymath_exp10f:
ezlea tinymath_exp10l,ax
exp10f:
ezlea exp10l,ax
jmp _f2ld2
.endfn tinymath_exp10f,globl
.alias tinymath_exp10f,exp10f
.alias tinymath_exp10f,pow10f
.endfn exp10f,globl
.alias exp10f,pow10f

View file

@ -23,7 +23,7 @@
/
/ @param 𝑥 is an 80-bit long double passed on stack in 16-bytes
/ @return result of exponentiation on FPU stack in %st
tinymath_exp10l:
exp10l:
push %rbp
mov %rsp,%rbp
.profilable
@ -41,6 +41,5 @@ tinymath_exp10l:
fstp %st(1)
pop %rbp
ret
.endfn tinymath_exp10l,globl
.alias tinymath_exp10l,exp10l
.alias tinymath_exp10l,pow10l
.endfn exp10l,globl
.alias exp10l,pow10l

View file

@ -23,8 +23,7 @@
/
/ @param 𝑥 is a double passed in the lower quadword of %xmm0
/ @return result in lower quadword of %xmm0
tinymath_exp2:
ezlea tinymath_exp2l,ax
exp2:
ezlea exp2l,ax
jmp _d2ld2
.endfn tinymath_exp2,globl
.alias tinymath_exp2,exp2
.endfn exp2,globl

View file

@ -23,8 +23,7 @@
/
/ @param 𝑥 is a float passed in the lower quarter of %xmm0
/ @return result in lower quarter of %xmm0
tinymath_exp2f:
ezlea tinymath_exp2l,ax
exp2f:
ezlea exp2l,ax
jmp _f2ld2
.endfn tinymath_exp2f,globl
.alias tinymath_exp2f,exp2f
.endfn exp2f,globl

View file

@ -23,8 +23,7 @@
/
/ @param 𝑥 is an 80-bit long double passed on stack in 16-bytes
/ @return result of exponentiation on FPU stack in %st
tinymath_exp2l:
push %rbp
exp2l: push %rbp
mov %rsp,%rbp
.profilable
fldt 16(%rbp)
@ -38,8 +37,7 @@ tinymath_exp2l:
fstp %st(1)
pop %rbp
ret
.endfn tinymath_exp2l,globl
.alias tinymath_exp2l,exp2l
.endfn exp2l,globl
.rodata.cst4
.Lone: .float 1.0

View file

@ -23,8 +23,6 @@
/
/ @param 𝑥 is double scalar in low half of %xmm0
/ @return double scalar in low half of %xmm0
tinymath_expf:
ezlea tinymath_expl,ax
expf: ezlea expl,ax
jmp _f2ld2
.endfn tinymath_expf,globl
.alias tinymath_expf,expf
.endfn expf,globl

View file

@ -23,8 +23,7 @@
/
/ @param 𝑥 is an 80-bit long double passed on stack in 16-bytes
/ @return result of exponentiation on FPU stack in %st
tinymath_expl:
push %rbp
expl: push %rbp
mov %rsp,%rbp
.profilable
fldt 16(%rbp)
@ -41,5 +40,4 @@ tinymath_expl:
fstp %st(1)
pop %rbp
ret
.endfn tinymath_expl,globl
.alias tinymath_expl,expl
.endfn expl,globl

View file

@ -23,8 +23,7 @@
/
/ @param 𝑥 is double scalar in low half of %xmm0
/ @return double scalar in low half of %xmm0
tinymath_expm1:
ezlea tinymath_expm1l,ax
expm1:
ezlea expm1l,ax
jmp _d2ld2
.endfn tinymath_expm1,globl
.alias tinymath_expm1,expm1
.endfn expm1,globl

View file

@ -23,8 +23,6 @@
/
/ @param 𝑥 is float scalar in low quarter of %xmm0
/ @return float scalar in low quarter of %xmm0
tinymath_expm1f:
ezlea tinymath_expm1l,ax
expm1f: ezlea expm1l,ax
jmp _f2ld2
.endfn tinymath_expm1f,globl
.alias tinymath_expm1f,expm1f
.endfn expm1f,globl

View file

@ -23,7 +23,7 @@
/
/ @param 𝑥 is an 80-bit long double passed on stack in 16-bytes
/ @return result of exponentiation on FPU stack in %st
tinymath_expm1l:
expm1l:
push %rbp
mov %rsp,%rbp
.profilable
@ -44,8 +44,7 @@ tinymath_expm1l:
faddp %st,%st(1)
pop %rbp
ret
.endfn tinymath_expm1l,globl
.alias tinymath_expm1l,expm1l
.endfn expm1l,globl
.rodata.cst4
.Lone: .float 1.0

View file

@ -21,8 +21,7 @@
/ vroundsd $_MM_FROUND_TO_NEG_INF|_MM_FROUND_NO_EXC,%xmm0,%xmm0,%xmm0
tinymath_floor:
.leafprologue
floor: .leafprologue
.profilable
movsd 4f(%rip),%xmm1
movsd 3f(%rip),%xmm2
@ -40,8 +39,7 @@ tinymath_floor:
subsd %xmm0,%xmm1
movapd %xmm1,%xmm0
1: .leafepilogue
.endfn tinymath_floor,globl
.alias tinymath_floor,floor
.endfn floor,globl
.rodata.cst8
2: .double 1

View file

@ -19,8 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_floorf:
.leafprologue
floorf: .leafprologue
.profilable
movss .LC8(%rip),%xmm1
andps %xmm0,%xmm1
@ -38,8 +37,7 @@ tinymath_floorf:
subss %xmm0,%xmm1
movaps %xmm1,%xmm0
1: .leafepilogue
.endfn tinymath_floorf,globl
.alias tinymath_floorf,floorf
.endfn floorf,globl
.rodata.cst4
.LC3: .float 1.0

View file

@ -19,8 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_floorl:
.profilable
floorl: .profilable
fldt 8(%rsp)
mov $7,%al
fstcw 8(%rsp)
@ -31,5 +30,4 @@ tinymath_floorl:
mov %ah,9(%rsp)
fldcw 8(%rsp)
ret
.endfn tinymath_floorl,globl
.alias tinymath_floorl,floorl
.endfn floorl,globl

View file

@ -16,7 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/tinymath/tinymath.h"
#include "libc/math.h"
/**
* Returns maximum of two doubles.

View file

@ -16,7 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/tinymath/tinymath.h"
#include "libc/math.h"
/**
* Returns maximum of two floats.

View file

@ -16,7 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/tinymath/tinymath.h"
#include "libc/math.h"
/**
* Returns maximum of two long doubles.

View file

@ -16,7 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/tinymath/tinymath.h"
#include "libc/math.h"
/**
* Returns minimum of two doubles.

View file

@ -16,7 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/tinymath/tinymath.h"
#include "libc/math.h"
/**
* Returns minimum of two floats.
@ -25,7 +25,7 @@
* This function is designed to do the right thing with
* signed zeroes.
*/
float fmin(float x, float y) {
float fminf(float x, float y) {
if (__builtin_isnan(x)) return y;
if (__builtin_isnan(y)) return x;
if (__builtin_signbitf(x) != __builtin_signbitf(y)) {

View file

@ -16,7 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/tinymath/tinymath.h"
#include "libc/math.h"
/**
* Returns minimum of two long doubles.

View file

@ -26,8 +26,6 @@
/ @return remainder ∈ (-|𝑦|,|𝑦|) in %xmm0
/ @define 𝑥-trunc(𝑥/𝑦)*𝑦
/ @see emod()
tinymath_fmod:
ezlea tinymath_fmodl,ax
fmod: ezlea fmodl,ax
jmp _d2ld2
.endfn tinymath_fmod,globl
.alias tinymath_fmod,fmod
.endfn fmod,globl

View file

@ -19,8 +19,6 @@
#include "libc/macros.h"
.source __FILE__
tinymath_fmodf:
ezlea tinymath_fmodl,ax
fmodf: ezlea fmodl,ax
jmp _f2ld2
.endfn tinymath_fmodf,globl
.alias tinymath_fmodf,fmodf
.endfn fmodf,globl

View file

@ -20,8 +20,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_fmodl:
push %rbp
fmodl: push %rbp
mov %rsp,%rbp
.profilable
fldt 32(%rbp)
@ -33,5 +32,4 @@ tinymath_fmodl:
fstp %st(1)
pop %rbp
ret
.endfn tinymath_fmodl,globl
.alias tinymath_fmodl,fmodl
.endfn fmodl,globl

View file

@ -19,8 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_frexp:
.leafprologue
frexp: .leafprologue
push %rbx
push %rdx
mov %rdi,%rbx
@ -53,8 +52,7 @@ tinymath_frexp:
5: pop %rax
pop %rbx
.leafepilogue
.endfn tinymath_frexp,globl
.alias tinymath_frexp,frexp
.endfn frexp,globl
.rodata.cst8
6: .long 0,0x43f00000

View file

@ -20,13 +20,11 @@
.source __FILE__
/ Returns euclidean distance in 2d space.
tinymath_hypot:
.leafprologue
hypot: .leafprologue
.profilable
mulsd %xmm1,%xmm1
mulsd %xmm0,%xmm0
addsd %xmm1,%xmm0
sqrtsd %xmm0,%xmm0
.leafepilogue
.endfn tinymath_hypot,globl
.alias tinymath_hypot,hypot
.endfn hypot,globl

View file

@ -20,13 +20,11 @@
.source __FILE__
/ Returns euclidean distance in 2d space.
tinymath_hypotf:
.leafprologue
hypotf: .leafprologue
.profilable
mulss %xmm1,%xmm1
mulss %xmm0,%xmm0
addss %xmm1,%xmm0
sqrtss %xmm0,%xmm0
.leafepilogue
.endfn tinymath_hypotf,globl
.alias tinymath_hypotf,hypotf
.endfn hypotf,globl

View file

@ -20,8 +20,7 @@
.source __FILE__
/ Returns euclidean distance in 2d space.
tinymath_hypotl:
push %rbp
hypotl: push %rbp
mov %rsp,%rbp
.profilable
fldt 32(%rbp)
@ -32,5 +31,4 @@ tinymath_hypotl:
faddp
pop %rbp
ret
.endfn tinymath_hypotl,globl
.alias tinymath_hypotl,hypotl
.endfn hypotl,globl

View file

@ -23,8 +23,7 @@
/ @param 𝑥 is double passed in %xmm0
/ @return result in %eax
/ @note needs sse3
tinymath_ilogb:
push %rbp
ilogb: push %rbp
mov %rsp,%rbp
.profilable
push %rax
@ -36,6 +35,5 @@ tinymath_ilogb:
mov (%rsp),%eax
leave
ret
.endfn tinymath_ilogb,globl
.alias tinymath_ilogb,ilogb
.endfn ilogb,globl
.source __FILE__

View file

@ -23,8 +23,7 @@
/ @param 𝑥 is float passed in %xmm0
/ @return result in %eax
/ @note needs sse3
tinymath_ilogbf:
push %rbp
ilogbf: push %rbp
mov %rsp,%rbp
.profilable
push %rax
@ -36,6 +35,5 @@ tinymath_ilogbf:
mov (%rsp),%eax
leave
ret
.endfn tinymath_ilogbf,globl
.alias tinymath_ilogbf,ilogbf
.endfn ilogbf,globl
.source __FILE__

View file

@ -23,8 +23,7 @@
/ @param 𝑥 is long double passed on stack
/ @return result in %eax
/ @note needs sse3
tinymath_ilogbl:
push %rbp
ilogbl: push %rbp
mov %rsp,%rbp
.profilable
fldt 16(%rbp)
@ -35,6 +34,5 @@ tinymath_ilogbl:
mov (%rsp),%eax
leave
ret
.endfn tinymath_ilogbl,globl
.alias tinymath_ilogbl,ilogbl
.endfn ilogbl,globl
.source __FILE__

View file

@ -24,8 +24,7 @@
/ @param 𝑥 is double passed in %xmm0
/ @param 𝑦 is exponent via %edi
/ @return double in %xmm0
tinymath_ldexp:
push %rbp
ldexp: push %rbp
mov %rsp,%rbp
.profilable
push %rdi
@ -38,7 +37,6 @@ tinymath_ldexp:
movsd (%rsp),%xmm0
leave
ret
.endfn tinymath_ldexp,globl
.alias tinymath_ldexp,ldexp
.alias tinymath_ldexp,scalbn
.alias tinymath_ldexp,scalbln
.endfn ldexp,globl
.alias ldexp,scalbn
.alias ldexp,scalbln

View file

@ -24,8 +24,7 @@
/ @param 𝑥 is float passed in %xmm0
/ @param 𝑦 is exponent via %edi
/ @return float in %xmm0
tinymath_ldexpf:
push %rbp
ldexpf: push %rbp
mov %rsp,%rbp
.profilable
push %rdi
@ -38,7 +37,6 @@ tinymath_ldexpf:
movss (%rsp),%xmm0
leave
ret
.endfn tinymath_ldexpf,globl
.alias tinymath_ldexpf,ldexpf
.alias tinymath_ldexpf,scalbnf
.alias tinymath_ldexpf,scalblnf
.endfn ldexpf,globl
.alias ldexpf,scalbnf
.alias ldexpf,scalblnf

View file

@ -24,8 +24,7 @@
/ @param 𝑥 is long double passed on stack
/ @param 𝑦 is exponent via %edi
/ @return result in %st0
tinymath_ldexpl:
push %rbp
ldexpl: push %rbp
mov %rsp,%rbp
.profilable
push %rdi
@ -35,7 +34,6 @@ tinymath_ldexpl:
fstp %st(1)
leave
ret
.endfn tinymath_ldexpl,globl
.alias tinymath_ldexpl,ldexpl
.alias tinymath_ldexpl,scalbnl
.alias tinymath_ldexpl,scalblnl
.endfn ldexpl,globl
.alias ldexpl,scalbnl
.alias ldexpl,scalblnl

View file

@ -23,8 +23,6 @@
/
/ @param 𝑥 is double scalar in low half of %xmm0
/ @return double scalar in low half of %xmm0
tinymath_log:
ezlea tinymath_logl,ax
log: ezlea logl,ax
jmp _d2ld2
.endfn tinymath_log,globl
.alias tinymath_log,log
.endfn log,globl

View file

@ -23,8 +23,7 @@
/
/ @param 𝑥 is double scalar in low half of %xmm0
/ @return double scalar in low half of %xmm0
tinymath_log10:
ezlea tinymath_log10l,ax
log10:
ezlea log10l,ax
jmp _d2ld2
.endfn tinymath_log10,globl
.alias tinymath_log10,log10
.endfn log10,globl

View file

@ -23,8 +23,7 @@
/
/ @param 𝑥 is double scalar in low quarter of %xmm0
/ @return float scalar in low quarter of %xmm0
tinymath_log10f:
ezlea tinymath_log10l,ax
log10f:
ezlea log10l,ax
jmp _f2ld2
.endfn tinymath_log10f,globl
.alias tinymath_log10f,log10f
.endfn log10f,globl

View file

@ -23,8 +23,7 @@
/
/ @param 𝑥 is an 80-bit long double passed on stack in 16-bytes
/ @return result in %st
tinymath_log10l:
push %rbp
log10l: push %rbp
mov %rsp,%rbp
.profilable
fldlg2
@ -32,5 +31,4 @@ tinymath_log10l:
fyl2x
pop %rbp
ret
.endfn tinymath_log10l,globl
.alias tinymath_log10l,log10l
.endfn log10l,globl

View file

@ -23,7 +23,7 @@
/
/ @param 𝑥 is double scalar in low half of %xmm0
/ @return double scalar in low half of %xmm0
tinymath_log1p:
log1p:
push %rbp
mov %rsp,%rbp
.profilable
@ -52,8 +52,7 @@ tinymath_log1p:
fstpl (%rsp)
vmovsd (%rsp),%xmm0
jmp 0b
.endfn tinymath_log1p,globl
.alias tinymath_log1p,log1p
.endfn log1p,globl
.rodata.cst16
.LC16: .long 205731576

View file

@ -23,8 +23,7 @@
/
/ @param 𝑥 is float scalar in low quarter of %xmm0
/ @return float scalar in low quarter of %xmm0
tinymath_log1pf:
push %rbp
log1pf: push %rbp
mov %rsp,%rbp
.profilable
push %rax
@ -50,8 +49,7 @@ tinymath_log1pf:
fxch
fyl2x
jmp 1b
.endfn tinymath_log1pf,globl
.alias tinymath_log1pf,log1pf
.endfn log1pf,globl
.rodata.cst16
.LC16: .long 205731576

View file

@ -23,7 +23,7 @@
/
/ @param 𝑥 is an 80-bit long double passed on stack in 16-bytes
/ @return result of exponentiation on FPU stack in %st
tinymath_log1pl:
log1pl:
push %rbp
mov %rsp,%rbp
.profilable
@ -46,8 +46,7 @@ tinymath_log1pl:
fxch
fyl2x
jmp 0b
.endfn tinymath_log1pl,globl
.alias tinymath_log1pl,log1pl
.endfn log1pl,globl
.rodata.cst16
.LC16: .long 205731576

View file

@ -23,7 +23,7 @@
/
/ @param 𝑥 is a double passed in the lower quadword of %xmm0
/ @return result in lower quadword of %xmm0
tinymath_log2:
log2:
push %rbp
mov %rsp,%rbp
.profilable
@ -36,5 +36,4 @@ tinymath_log2:
movsd -8(%rbp),%xmm0
leave
ret
.endfn tinymath_log2,globl
.alias tinymath_log2,log2
.endfn log2,globl

View file

@ -23,7 +23,7 @@
/
/ @param 𝑥 is a float passed in the lower quarter of %xmm0
/ @return result in lower quarter of %xmm0
tinymath_log2f:
log2f:
push %rbp
mov %rsp,%rbp
.profilable
@ -36,5 +36,4 @@ tinymath_log2f:
movss 4(%rsp),%xmm0
leave
ret
.endfn tinymath_log2f,globl
.alias tinymath_log2f,log2f
.endfn log2f,globl

View file

@ -24,7 +24,7 @@
/ @param 𝑥 is an 80-bit long double passed on stack in 16-bytes
/ @return result in %st
/ @see ilogbl()
tinymath_log2l:
log2l:
push %rbp
mov %rsp,%rbp
.profilable
@ -33,5 +33,4 @@ tinymath_log2l:
fyl2x
pop %rbp
ret
.endfn tinymath_log2l,globl
.alias tinymath_log2l,log2l
.endfn log2l,globl

View file

@ -22,9 +22,7 @@
/
/ @param 𝑥 is double passed in %xmm0
/ @return result in %xmm0
tinymath_logb:
ezlea tinymath_logbl,ax
logb: ezlea logbl,ax
jmp _d2ld2
.endfn tinymath_logb,globl
.alias tinymath_logb,logb
.endfn logb,globl
.source __FILE__

View file

@ -22,9 +22,7 @@
/
/ @param 𝑥 is float passed in %xmm0
/ @return result in %xmm0
tinymath_logbf:
ezlea tinymath_logbl,ax
logbf: ezlea logbl,ax
jmp _f2ld2
.endfn tinymath_logbf,globl
.alias tinymath_logbf,logbf
.endfn logbf,globl
.source __FILE__

View file

@ -22,8 +22,7 @@
/
/ @param 𝑥 is long double passed on stack
/ @return result in %st0
tinymath_logbl:
push %rbp
logbl: push %rbp
mov %rsp,%rbp
.profilable
fldt 16(%rbp)
@ -31,6 +30,5 @@ tinymath_logbl:
fstp %st
pop %rbp
ret
.endfn tinymath_logbl,globl
.alias tinymath_logbl,logbl
.endfn logbl,globl
.source __FILE__

View file

@ -23,8 +23,6 @@
/
/ @param 𝑥 is double scalar in low quarter of %xmm0
/ @return float scalar in low quarter of %xmm0
tinymath_logf:
ezlea tinymath_logl,ax
logf: ezlea logl,ax
jmp _f2ld2
.endfn tinymath_logf,globl
.alias tinymath_logf,logf
.endfn logf,globl

View file

@ -23,8 +23,7 @@
/
/ @param 𝑥 is an 80-bit long double passed on stack in 16-bytes
/ @return result on FPU stack in %st
tinymath_logl:
push %rbp
logl: push %rbp
mov %rsp,%rbp
.profilable
fldln2
@ -32,5 +31,4 @@ tinymath_logl:
fyl2x
pop %rbp
ret
.endfn tinymath_logl,globl
.alias tinymath_logl,logl
.endfn logl,globl

View file

@ -19,9 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_lrint:
cvtsd2siq %xmm0,%rax
lrint: cvtsd2siq %xmm0,%rax
ret
.endfn tinymath_lrint,globl
.alias tinymath_lrint,lrint
.alias tinymath_lrint,llrint
.endfn lrint,globl
.alias lrint,llrint

View file

@ -19,9 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_lrintf:
cvtss2siq %xmm0,%rax
lrintf: cvtss2siq %xmm0,%rax
ret
.endfn tinymath_lrintf,globl
.alias tinymath_lrintf,lrintf
.alias tinymath_lrintf,llrintf
.endfn lrintf,globl
.alias lrintf,llrintf

View file

@ -19,8 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_lrintl:
push %rbp
lrintl: push %rbp
mov %rsp,%rbp
.profilable
fldt 16(%rbp)
@ -28,6 +27,5 @@ tinymath_lrintl:
mov 16(%rbp),%rax
pop %rbp
ret
.endfn tinymath_lrintl,globl
.alias tinymath_lrintl,lrintl
.alias tinymath_lrintl,llrintl
.endfn lrintl,globl
.alias lrintl,llrintl

View file

@ -24,8 +24,7 @@
/ @param 𝑥 is double scalar in low half of %xmm0
/ @return 64-bit signed integer in %rax
/ @see round(), lrint()
tinymath_lround:
.leafprologue
lround: .leafprologue
.profilable
movsd A(%rip),%xmm2
movsd B(%rip),%xmm1
@ -34,9 +33,8 @@ tinymath_lround:
addsd %xmm0,%xmm1
cvttsd2siq %xmm1,%rax
.leafepilogue
.endfn tinymath_lround,globl
.alias tinymath_lround,lround
.alias tinymath_lround,llround
.endfn lround,globl
.alias lround,llround
.rodata.cst16
A: .quad 0x8000000000000000,0

View file

@ -24,7 +24,7 @@
/ @param 𝑥 is float scalar in low quarter of %xmm0
/ @return 64-bit signed integer in %rax
/ @see round()
tinymath_lroundf:
lroundf:
.leafprologue
.profilable
movss A(%rip),%xmm1
@ -34,9 +34,8 @@ tinymath_lroundf:
addss %xmm0,%xmm1
cvttss2siq %xmm1,%rax
.leafepilogue
.endfn tinymath_lroundf,globl
.alias tinymath_lroundf,lroundf
.alias tinymath_lroundf,llroundf
.endfn lroundf,globl
.alias lroundf,llroundf
.rodata.cst4
A: .long 0x3effffff

View file

@ -20,7 +20,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_lroundl:
lroundl:
push %rbp
mov %rsp,%rbp
.profilable
@ -37,9 +37,8 @@ tinymath_lroundl:
neg %rax
1: leave
ret
.endfn tinymath_lroundl,globl
.alias tinymath_lroundl,lroundl
.alias tinymath_lroundl,llroundl
.endfn lroundl,globl
.alias lroundl,llroundl
.rodata.cst4
.Lhalf: .float .5

View file

@ -19,7 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_nearbyint:
nearbyint:
.profilable
sub $16,%rsp
movsd %xmm0,(%rsp)
@ -36,5 +36,4 @@ tinymath_nearbyint:
movsd (%rsp),%xmm0
add $16,%rsp
ret
.endfn tinymath_nearbyint,globl
.alias tinymath_nearbyint,nearbyint
.endfn nearbyint,globl

View file

@ -19,7 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_nearbyintf:
nearbyintf:
.profilable
sub $8,%rsp
movss %xmm0,(%rsp)
@ -36,5 +36,4 @@ tinymath_nearbyintf:
movss (%rsp),%xmm0
add $8,%rsp
ret
.endfn tinymath_nearbyintf,globl
.alias tinymath_nearbyintf,nearbyintf
.endfn nearbyintf,globl

View file

@ -19,7 +19,7 @@
#include "libc/macros.h"
.source __FILE__
tinymath_nearbyintl:
nearbyintl:
.profilable
sub $24,%rsp
fldt 32(%rsp)
@ -33,5 +33,4 @@ tinymath_nearbyintl:
fldcw 14(%rsp)
add $24,%rsp
ret
.endfn tinymath_nearbyintl,globl
.alias tinymath_nearbyintl,nearbyintl
.endfn nearbyintl,globl

View file

@ -24,9 +24,7 @@
/ @param 𝑥 is double scalar in low half of %xmm0
/ @param 𝑦 is double scalar in low half of %xmm1
/ @return double scalar in low half of %xmm0
tinymath_pow:
ezlea tinymath_powl,ax
pow: ezlea powl,ax
jmp _d2ld2
.endfn tinymath_pow,globl
.alias tinymath_pow,pow
.alias tinymath_pow,__pow_finite
.endfn pow,globl
.alias pow,__pow_finite

View file

@ -24,9 +24,7 @@
/ @param 𝑦 is float scalar in low quarter of %xmm0
/ @param 𝑥 is float scalar in low quarter of %xmm1
/ @return float scalar in low quarter of %xmm0
tinymath_powf:
ezlea tinymath_powl,ax
powf: ezlea powl,ax
jmp _f2ld2
.endfn tinymath_powf,globl
.alias tinymath_powf,powf
.alias tinymath_powf,__powf_finite
.endfn powf,globl
.alias powf,__powf_finite

View file

@ -23,8 +23,6 @@
/ @param 𝑥 is double scalar in low half of %xmm0
/ @param 𝑦 is int passed in %edi
/ @return double scalar in low half of %xmm0
tinymath_powi:
cvtsi2sd %edi,%xmm1
jmp tinymath_pow
.endfn tinymath_powi,globl
.alias tinymath_powi,powi
powi: cvtsi2sd %edi,%xmm1
jmp pow
.endfn powi,globl

View file

@ -23,8 +23,6 @@
/ @param 𝑥 is float scalar in low quarter of %xmm0
/ @param 𝑦 is int passed in %edi
/ @return double scalar in low half of %xmm0
tinymath_powif:
cvtsi2ss %edi,%xmm1
jmp tinymath_pow
.endfn tinymath_powif,globl
.alias tinymath_powif,powif
powif: cvtsi2ss %edi,%xmm1
jmp pow
.endfn powif,globl

View file

@ -23,8 +23,7 @@
/ @param 𝑥 is long double passed on stack
/ @param 𝑦 is int passed in %edi
/ @return %st
tinymath_powil:
push %rbp
powil: push %rbp
mov %rsp,%rbp
.profilable
sub $32,%rsp
@ -33,8 +32,7 @@ tinymath_powil:
fstpt (%rsp)
push 16+8(%rbp)
push 16+0(%rbp)
call tinymath_powl
call powl
leave
ret
.endfn tinymath_powil,globl
.alias tinymath_powil,powil
.endfn powil,globl

View file

@ -25,8 +25,7 @@
/ @param 𝑦 is the power, also pushed on stack, in reverse order
/ @return result of exponentiation on FPU stack in %st
/ @note Sun's fdlibm needs 2kLOC to do this for RISC lool
tinymath_powl:
push %rbp
powl: push %rbp
mov %rsp,%rbp
.profilable
fldt 32(%rbp)
@ -42,6 +41,5 @@ tinymath_powl:
fstp %st
pop %rbp
ret
.endfn tinymath_powl,globl
.alias tinymath_powl,powl
.alias tinymath_powl,__powl_finite
.endfn powl,globl
.alias powl,__powl_finite

View file

@ -26,9 +26,8 @@
/ @return remainder ∈ (-|𝑦|,|𝑦|) in %xmm0
/ @define 𝑥-rint(𝑥/𝑦)*𝑦
/ @see fmod(), emod(), operator%
tinymath_remainder:
ezlea tinymath_remainderl,ax
remainder:
ezlea remainderl,ax
jmp _d2ld2
.endfn tinymath_remainder,globl
.alias tinymath_remainder,remainder
.alias tinymath_remainder,drem
.endfn remainder,globl
.alias remainder,drem

Some files were not shown because too many files have changed in this diff Show more