mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Initial import
This commit is contained in:
commit
c91b3c5006
14915 changed files with 590219 additions and 0 deletions
16
libc/tinymath/README.txt
Normal file
16
libc/tinymath/README.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
|
||||
Cosmopolitan TinyMath
|
||||
|
||||
“Seymour Cray didn't care that 81.0/3.0 did not give exactly
|
||||
27.0 on the CDC 6000 class machines; and he was universally
|
||||
respected for making the fastest machines around.
|
||||
──Linus Torvalds
|
||||
|
||||
|
||||
Your Cosmopolitan TinyMath library provides hardware-accelerated scalar
|
||||
transcendental mathematical functions that are superior to the portable
|
||||
standards-compliant math library, in terms of both performance and code
|
||||
size, by trading away focus on temporal concerns, like IEEE conformance
|
||||
or rounding errors at the femto-scale, or reproducible results across a
|
||||
broad array of niche machine languages.
|
31
libc/tinymath/acos.S
Normal file
31
libc/tinymath/acos.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns arc cosine of 𝑥.
|
||||
/
|
||||
/ @param 𝑥 is double scalar in low half of %xmm0
|
||||
/ @return double scalar in low half of %xmm0
|
||||
tinymath_acos:
|
||||
ezlea tinymath_acosl,ax
|
||||
jmp _d2ld2
|
||||
.endfn tinymath_acos,globl
|
||||
.alias tinymath_acos,acos
|
31
libc/tinymath/acosf.S
Normal file
31
libc/tinymath/acosf.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns arc cosine of 𝑥.
|
||||
/
|
||||
/ @param 𝑥 is float scalar in low quarter of %xmm0
|
||||
/ @return float scalar in low quarter of %xmm0
|
||||
tinymath_acosf:
|
||||
ezlea tinymath_acosl,ax
|
||||
jmp _f2ld2
|
||||
.endfn tinymath_acosf,globl
|
||||
.alias tinymath_acosf,acosf
|
57
libc/tinymath/acosl.S
Normal file
57
libc/tinymath/acosl.S
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns arc cosine of 𝑥.
|
||||
/
|
||||
/ @param 𝑥 is an 80-bit long double passed on stack in 16-bytes
|
||||
/ @return result of computation on FPU stack in %st
|
||||
/ @define atan2(abs(sqrt((1-𝑥)*(1+𝑥))),𝑥)
|
||||
/ @domain -1 ≤ 𝑥 ≤ 1
|
||||
/ @mode long,legacy
|
||||
tinymath_acosl:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldl 16(%rbp)
|
||||
fld %st
|
||||
#ifdef __FAST_MATH__
|
||||
fmul %st(1),%st
|
||||
fsubrs .Lone(%rip)
|
||||
fsqrt
|
||||
#else
|
||||
fld1
|
||||
fsubp
|
||||
fld1
|
||||
fadd %st(2)
|
||||
fmulp
|
||||
fsqrt
|
||||
fabs # needed in downward rounding mode
|
||||
#endif
|
||||
fxch %st(1)
|
||||
fpatan
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_acosl,globl
|
||||
.alias tinymath_acosl,acosl
|
||||
|
||||
.rodata.cst4
|
||||
.Lone: .float 1.0
|
31
libc/tinymath/asin.S
Normal file
31
libc/tinymath/asin.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns arc sine of 𝑥.
|
||||
/
|
||||
/ @param 𝑥 is double scalar in low half of %xmm0
|
||||
/ @return double scalar in low half of %xmm0
|
||||
tinymath_asin:
|
||||
ezlea tinymath_asinl,ax
|
||||
jmp _d2ld2
|
||||
.endfn tinymath_asin,globl
|
||||
.alias tinymath_asin,asin
|
31
libc/tinymath/asinf.S
Normal file
31
libc/tinymath/asinf.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns arc sine of 𝑥.
|
||||
/
|
||||
/ @param 𝑥 is float scalar in low quarter of %xmm0
|
||||
/ @return float scalar in low quarter of %xmm0
|
||||
tinymath_asinf:
|
||||
ezlea tinymath_asinl,ax
|
||||
jmp _f2ld2
|
||||
.endfn tinymath_asinf,globl
|
||||
.alias tinymath_asinf,asinf
|
55
libc/tinymath/asinl.S
Normal file
55
libc/tinymath/asinl.S
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns arc sine of 𝑥.
|
||||
/
|
||||
/ @param 𝑥 is an 80-bit long double passed on stack in 16-bytes
|
||||
/ @return result of computation on FPU stack in %st
|
||||
/ @define atan2(𝑥,sqrt((1-𝑥)*(1+𝑥)))
|
||||
/ @domain -1 ≤ 𝑥 ≤ 1
|
||||
/ @mode long,legacy
|
||||
tinymath_asinl:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldl 16(%rbp)
|
||||
fld %st
|
||||
#ifdef __FAST_MATH__
|
||||
fmul %st(1),%st
|
||||
fsubrs .Lone(%rip)
|
||||
#else
|
||||
fld1
|
||||
fsubp
|
||||
fld1
|
||||
fadd %st(2)
|
||||
fmulp
|
||||
#endif
|
||||
fsqrt
|
||||
fpatan
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_asinl,globl
|
||||
.alias tinymath_asinl,asinl
|
||||
|
||||
.rodata.cst4
|
||||
.align 4
|
||||
.Lone: .float 1.0
|
31
libc/tinymath/atan.S
Normal file
31
libc/tinymath/atan.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns arc tangent of 𝑥.
|
||||
/
|
||||
/ @param 𝑥 is double scalar in low half of %xmm0
|
||||
/ @return double scalar in low half of %xmm0
|
||||
tinymath_atan:
|
||||
ezlea tinymath_atanl,ax
|
||||
jmp _d2ld2
|
||||
.endfn tinymath_atan,globl
|
||||
.alias tinymath_atan,atan
|
33
libc/tinymath/atan2.S
Normal file
33
libc/tinymath/atan2.S
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns arc tangent of 𝑦/𝑥.
|
||||
/
|
||||
/ @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
|
||||
/ @note the greatest of all libm functions
|
||||
tinymath_atan2:
|
||||
ezlea tinymath_atan2l,ax
|
||||
jmp _f2ld2
|
||||
.endfn tinymath_atan2,globl
|
||||
.alias tinymath_atan2,atan2
|
32
libc/tinymath/atan2f.S
Normal file
32
libc/tinymath/atan2f.S
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns arc tangent of 𝑦/𝑥.
|
||||
/
|
||||
/ @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
|
||||
jmp _f2ld2
|
||||
.endfn tinymath_atan2f,globl
|
||||
.alias tinymath_atan2f,atan2f
|
38
libc/tinymath/atan2l.S
Normal file
38
libc/tinymath/atan2l.S
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns arc tangent of 𝑦/𝑥.
|
||||
/
|
||||
/ @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
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 16(%rbp)
|
||||
fldt 32(%rbp)
|
||||
fpatan
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_atan2l,globl
|
||||
.alias tinymath_atan2l,atan2l
|
31
libc/tinymath/atanf.S
Normal file
31
libc/tinymath/atanf.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns arc tangent of 𝑥.
|
||||
/
|
||||
/ @param 𝑥 is float scalar in low quarter of %xmm0
|
||||
/ @return float scalar in low quarter of %xmm0
|
||||
tinymath_atanf:
|
||||
ezlea tinymath_atanl,ax
|
||||
jmp _f2ld2
|
||||
.endfn tinymath_atanf,globl
|
||||
.alias tinymath_atanf,atanf
|
41
libc/tinymath/atanl.S
Normal file
41
libc/tinymath/atanl.S
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns arc tangent of 𝑥.
|
||||
/
|
||||
/ @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²ⁿ(𝑛!)²/(𝟸𝑛+𝟷)!(𝑥²ⁿ⁺¹/(𝑥²+𝟷)ⁿ⁺¹)
|
||||
/ 1 3 1 5 1 7 1 9 1 11
|
||||
/ @define atan(𝑥) = 𝑥 - - 𝑥 + - 𝑥 - - 𝑥 + - 𝑥 - -- 𝑥 ...
|
||||
/ 3 5 7 9 11
|
||||
tinymath_atanl:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 16(%rbp)
|
||||
fld1
|
||||
fpatan
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_atanl,globl
|
||||
.alias tinymath_atanl,atanl
|
49
libc/tinymath/c2rangr.S
Normal file
49
libc/tinymath/c2rangr.S
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/lib/pc.h"
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Computes transcedental trigonometry op w/ reactive scaling.
|
||||
/
|
||||
/ @param %rdx points to op function
|
||||
/ @param everything else delegates
|
||||
/ @clob %ax
|
||||
/ @see sin,cos,tan
|
||||
c2rangr:push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
call *%rdx
|
||||
fstsw %ax
|
||||
test $FPU_C2>>8,%ah
|
||||
jnz 1f
|
||||
0: pop %rbp
|
||||
ret
|
||||
1: fldpi
|
||||
fadd %st
|
||||
fxch %st(1)
|
||||
2: fprem1
|
||||
fnstsw %ax
|
||||
test $FPU_C2>>8,%ah
|
||||
jnz 2b
|
||||
fstp %st(1)
|
||||
call *%rdx
|
||||
jmp 0b
|
||||
.endfn c2rangr,globl,hidden
|
27
libc/tinymath/cabs.S
Normal file
27
libc/tinymath/cabs.S
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns absolute value of complex number.
|
||||
tinymath_cabs:
|
||||
jmp tinymath_hypot
|
||||
.endfn tinymath_cabs,globl
|
||||
.alias tinymath_cabs,cabs
|
40
libc/tinymath/cabsf.S
Normal file
40
libc/tinymath/cabsf.S
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_cabsf:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
sub $16,%rsp
|
||||
movq %xmm0,(%rsp)
|
||||
movss (%rsp),%xmm0
|
||||
movss 4(%rsp),%xmm2
|
||||
movaps %xmm0,%xmm1
|
||||
mulss %xmm2,%xmm2
|
||||
mulss %xmm0,%xmm1
|
||||
movaps %xmm2,%xmm0
|
||||
addss %xmm1,%xmm0
|
||||
sqrtss %xmm0,%xmm0
|
||||
leave
|
||||
ret
|
||||
.endfn tinymath_cabsf,globl
|
||||
.alias tinymath_cabsf,cabsf
|
37
libc/tinymath/cabsl.S
Normal file
37
libc/tinymath/cabsl.S
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_cabsl:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 32(%rbp)
|
||||
fldt 16(%rbp)
|
||||
fmul %st,%st
|
||||
fxch %st(1)
|
||||
fmul %st,%st
|
||||
faddp %st,%st(1)
|
||||
fsqrt
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_cabsl,globl
|
||||
.alias tinymath_cabsl,cabsl
|
39
libc/tinymath/carg.S
Normal file
39
libc/tinymath/carg.S
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_carg:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
sub $16,%rsp
|
||||
movsd %xmm0,-16(%rbp)
|
||||
fldl -16(%rbp)
|
||||
movsd %xmm1,-16(%rbp)
|
||||
fldl -16(%rbp)
|
||||
fxch %st(1)
|
||||
fpatan
|
||||
fstpl -16(%rbp)
|
||||
movsd -16(%rbp),%xmm0
|
||||
leave
|
||||
ret
|
||||
.endfn tinymath_carg,globl
|
||||
.alias tinymath_carg,carg
|
37
libc/tinymath/cargf.S
Normal file
37
libc/tinymath/cargf.S
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_cargf:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
sub $16,%rsp
|
||||
movq %xmm0,8(%rsp)
|
||||
flds 12(%rsp)
|
||||
flds 8(%rsp)
|
||||
fpatan
|
||||
fstps 4(%rsp)
|
||||
movss 4(%rsp),%xmm0
|
||||
leave
|
||||
ret
|
||||
.endfn tinymath_cargf,globl
|
||||
.alias tinymath_cargf,cargf
|
33
libc/tinymath/cargl.S
Normal file
33
libc/tinymath/cargl.S
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_cargl:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 32(%rbp)
|
||||
fldt 16(%rbp)
|
||||
fpatan
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_cargl,globl
|
||||
.alias tinymath_cargl,cargl
|
106
libc/tinymath/cbrt.c
Normal file
106
libc/tinymath/cbrt.c
Normal file
|
@ -0,0 +1,106 @@
|
|||
/* origin: FreeBSD /usr/src/lib/msun/src/s_cbrt.c */
|
||||
/*
|
||||
* ====================================================
|
||||
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*
|
||||
* Optimized by Bruce D. Evans.
|
||||
*/
|
||||
/* cbrt(x)
|
||||
* Return cube root of x
|
||||
*/
|
||||
#include "libc/math.h"
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
fdlibm\\n\
|
||||
Copyright 1993 Sun Microsystems, Inc.\\n\
|
||||
Developed at SunPro, a Sun Microsystems, Inc. business.\"");
|
||||
|
||||
static const uint32_t
|
||||
B1 = 715094163, /* B1 = (1023-1023/3-0.03306235651)*2**20 */
|
||||
B2 = 696219795; /* B2 = (1023-1023/3-54/3-0.03306235651)*2**20 */
|
||||
|
||||
/* |1/cbrt(x) - p(x)| < 2**-23.5 (~[-7.93e-8, 7.929e-8]). */
|
||||
static const double P0 = 1.87595182427177009643, /* 0x3ffe03e6, 0x0f61e692 */
|
||||
P1 = -1.88497979543377169875, /* 0xbffe28e0, 0x92f02420 */
|
||||
P2 = 1.621429720105354466140, /* 0x3ff9f160, 0x4a49d6c2 */
|
||||
P3 = -0.758397934778766047437, /* 0xbfe844cb, 0xbee751d9 */
|
||||
P4 = 0.145996192886612446982; /* 0x3fc2b000, 0xd4e4edd7 */
|
||||
|
||||
double(cbrt)(double x) {
|
||||
union {
|
||||
double f;
|
||||
uint64_t i;
|
||||
} u = {x};
|
||||
double_t r, s, t, w;
|
||||
uint32_t hx = u.i >> 32 & 0x7fffffff;
|
||||
|
||||
if (hx >= 0x7ff00000) /* cbrt(NaN,INF) is itself */
|
||||
return x + x;
|
||||
|
||||
/*
|
||||
* Rough cbrt to 5 bits:
|
||||
* cbrt(2**e*(1+m) ~= 2**(e/3)*(1+(e%3+m)/3)
|
||||
* where e is integral and >= 0, m is real and in [0, 1), and "/" and
|
||||
* "%" are integer division and modulus with rounding towards minus
|
||||
* infinity. The RHS is always >= the LHS and has a maximum relative
|
||||
* error of about 1 in 16. Adding a bias of -0.03306235651 to the
|
||||
* (e%3+m)/3 term reduces the error to about 1 in 32. With the IEEE
|
||||
* floating point representation, for finite positive normal values,
|
||||
* ordinary integer divison of the value in bits magically gives
|
||||
* almost exactly the RHS of the above provided we first subtract the
|
||||
* exponent bias (1023 for doubles) and later add it back. We do the
|
||||
* subtraction virtually to keep e >= 0 so that ordinary integer
|
||||
* division rounds towards minus infinity; this is also efficient.
|
||||
*/
|
||||
if (hx < 0x00100000) { /* zero or subnormal? */
|
||||
u.f = x * 0x1p54;
|
||||
hx = u.i >> 32 & 0x7fffffff;
|
||||
if (hx == 0) return x; /* cbrt(0) is itself */
|
||||
hx = hx / 3 + B2;
|
||||
} else
|
||||
hx = hx / 3 + B1;
|
||||
u.i &= 1ULL << 63;
|
||||
u.i |= (uint64_t)hx << 32;
|
||||
t = u.f;
|
||||
|
||||
/*
|
||||
* New cbrt to 23 bits:
|
||||
* cbrt(x) = t*cbrt(x/t**3) ~= t*P(t**3/x)
|
||||
* where P(r) is a polynomial of degree 4 that approximates 1/cbrt(r)
|
||||
* to within 2**-23.5 when |r - 1| < 1/10. The rough approximation
|
||||
* has produced t such than |t/cbrt(x) - 1| ~< 1/32, and cubing this
|
||||
* gives us bounds for r = t**3/x.
|
||||
*
|
||||
* Try to optimize for parallel evaluation as in __tanf.c.
|
||||
*/
|
||||
r = (t * t) * (t / x);
|
||||
t = t * ((P0 + r * (P1 + r * P2)) + ((r * r) * r) * (P3 + r * P4));
|
||||
|
||||
/*
|
||||
* Round t away from zero to 23 bits (sloppily except for ensuring that
|
||||
* the result is larger in magnitude than cbrt(x) but not much more than
|
||||
* 2 23-bit ulps larger). With rounding towards zero, the error bound
|
||||
* would be ~5/6 instead of ~4/6. With a maximum error of 2 23-bit ulps
|
||||
* in the rounded t, the infinite-precision error in the Newton
|
||||
* approximation barely affects third digit in the final error
|
||||
* 0.667; the error in the rounded t can be up to about 3 23-bit ulps
|
||||
* before the final error is larger than 0.667 ulps.
|
||||
*/
|
||||
u.f = t;
|
||||
u.i = (u.i + 0x80000000) & 0xffffffffc0000000ULL;
|
||||
t = u.f;
|
||||
|
||||
/* one step Newton iteration to 53 bits with error < 0.667 ulps */
|
||||
s = t * t; /* t*t is exact */
|
||||
r = x / s; /* error <= 0.5 ulps; |r| < |t| */
|
||||
w = t + t; /* t+t is exact */
|
||||
r = (r - t) / (w + r); /* r-t is exact; w+r ~= 3*t */
|
||||
t = t + t * r; /* error <= 0.5 + 0.5/3 + epsilon */
|
||||
return t;
|
||||
}
|
54
libc/tinymath/ceil.S
Normal file
54
libc/tinymath/ceil.S
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_ceil:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movsd .Llol(%rip),%xmm1
|
||||
movsd .Lcat(%rip),%xmm2
|
||||
andpd %xmm0,%xmm1
|
||||
comisd %xmm1,%xmm2
|
||||
jbe 1f
|
||||
cvttsd2siq %xmm0,%rax
|
||||
pxor %xmm1,%xmm1
|
||||
movsd .Lmog(%rip),%xmm2
|
||||
cvtsi2sdq %rax,%xmm1
|
||||
cmpnlesd %xmm1,%xmm0
|
||||
andpd %xmm2,%xmm0
|
||||
addsd %xmm1,%xmm0
|
||||
1: .leafepilogue
|
||||
.endfn tinymath_ceil,globl
|
||||
.alias tinymath_ceil,ceil
|
||||
|
||||
.rodata.cst16
|
||||
.Llol: .long 4294967295
|
||||
.long 2147483647
|
||||
.long 0
|
||||
.long 0
|
||||
|
||||
.rodata.cst8
|
||||
.Lcat: .long 0
|
||||
.long 1127219200
|
||||
.Lmog: .long 0
|
||||
.long 1072693248
|
||||
|
||||
/ vroundsd $_MM_FROUND_TO_POS_INF|_MM_FROUND_NO_EXC,%xmm0,%xmm0,%xmm0
|
53
libc/tinymath/ceilf.S
Normal file
53
libc/tinymath/ceilf.S
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_ceilf:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movss .L3(%rip),%xmm1
|
||||
andps %xmm0,%xmm1
|
||||
movss .L2(%rip),%xmm2
|
||||
comiss %xmm1,%xmm2
|
||||
jbe 1f
|
||||
cvttss2si %xmm0,%eax
|
||||
pxor %xmm1,%xmm1
|
||||
movss .L1(%rip),%xmm2
|
||||
cvtsi2ss %eax,%xmm1
|
||||
cmpnless %xmm1,%xmm0
|
||||
andps %xmm2,%xmm0
|
||||
addss %xmm1,%xmm0
|
||||
1: .leafepilogue
|
||||
.endfn tinymath_ceilf,globl
|
||||
.alias tinymath_ceilf,ceilf
|
||||
|
||||
.rodata.cst4
|
||||
.L1: .float 1.0
|
||||
.L2: .long 1258291200
|
||||
|
||||
.rodata.cst16
|
||||
.L3: .long 2147483647
|
||||
.long 0
|
||||
.long 0
|
||||
.long 0
|
||||
|
||||
/ TODO(jart):
|
||||
/ vroundss $10,%xmm0,%xmm0,%xmm0
|
38
libc/tinymath/ceill.S
Normal file
38
libc/tinymath/ceill.S
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_ceill:
|
||||
.profilable
|
||||
sub $24,%rsp
|
||||
fldt 32(%rsp)
|
||||
fnstcw 14(%rsp)
|
||||
movzwl 14(%rsp),%eax
|
||||
andb $-13,%ah
|
||||
orb $8,%ah
|
||||
movw %ax,12(%rsp)
|
||||
fldcw 12(%rsp)
|
||||
frndint
|
||||
fldcw 14(%rsp)
|
||||
add $24,%rsp
|
||||
ret
|
||||
.endfn tinymath_ceill,globl
|
||||
.alias tinymath_ceill,ceill
|
27
libc/tinymath/cimag.S
Normal file
27
libc/tinymath/cimag.S
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
cimag: .leafprologue
|
||||
.profilable
|
||||
movapd %xmm1,%xmm0
|
||||
.leafepilogue
|
||||
.endfn cimag,globl
|
31
libc/tinymath/cimagf.S
Normal file
31
libc/tinymath/cimagf.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
cimagf: push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
sub $16,%rsp
|
||||
movq %xmm0,(%rsp)
|
||||
movss 4(%rsp),%xmm0
|
||||
leave
|
||||
ret
|
||||
.endfn cimagf,globl
|
29
libc/tinymath/cimagl.S
Normal file
29
libc/tinymath/cimagl.S
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
cimagl: push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 32(%rbp)
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn cimagl,globl
|
35
libc/tinymath/conj.S
Normal file
35
libc/tinymath/conj.S
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_conj:
|
||||
.leafprologue
|
||||
.profilable
|
||||
xorpd .L1(%rip),%xmm1
|
||||
.leafepilogue
|
||||
.endfn tinymath_conj,globl
|
||||
.alias tinymath_conj,conj
|
||||
|
||||
.rodata.cst16
|
||||
.L1: .long 0
|
||||
.long -2147483648
|
||||
.long 0
|
||||
.long 0
|
42
libc/tinymath/conjf.S
Normal file
42
libc/tinymath/conjf.S
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_conjf:
|
||||
.profilable
|
||||
sub $16,%rsp
|
||||
movq %xmm0,8(%rsp)
|
||||
movss 12(%rsp),%xmm0
|
||||
xorps .L1(%rip),%xmm0
|
||||
movss 8(%rsp),%xmm1
|
||||
movss %xmm1,(%rsp)
|
||||
movss %xmm0,4(%rsp)
|
||||
movq (%rsp),%xmm0
|
||||
add $16,%rsp
|
||||
ret
|
||||
.endfn tinymath_conjf,globl
|
||||
.alias tinymath_conjf,conjf
|
||||
|
||||
.rodata.cst16
|
||||
.L1: .long 2147483648
|
||||
.long 0
|
||||
.long 0
|
||||
.long 0
|
46
libc/tinymath/conjl.S
Normal file
46
libc/tinymath/conjl.S
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_conjl:
|
||||
.profilable
|
||||
sub $24,%rsp
|
||||
fldt 32(%rsp)
|
||||
fnstcw 14(%rsp)
|
||||
movzwl 14(%rsp),%eax
|
||||
orb $12,%ah
|
||||
movw %ax,12(%rsp)
|
||||
fldcw 12(%rsp)
|
||||
fistpq (%rsp)
|
||||
fldcw 14(%rsp)
|
||||
movq (%rsp),%rsi
|
||||
fldt 48(%rsp)
|
||||
mov %rsi,%rax
|
||||
fchs
|
||||
fldcw 12(%rsp)
|
||||
fistpq (%rsp)
|
||||
fldcw 14(%rsp)
|
||||
movq (%rsp),%rcx
|
||||
add $24,%rsp
|
||||
mov %rcx,%rdx
|
||||
ret
|
||||
.endfn tinymath_conjl,globl
|
||||
.alias tinymath_conjl,conjl
|
42
libc/tinymath/copysign.S
Normal file
42
libc/tinymath/copysign.S
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_copysign:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movapd %xmm1,%xmm2
|
||||
andpd .L1(%rip),%xmm0
|
||||
andpd .L2(%rip),%xmm2
|
||||
orpd %xmm2,%xmm0
|
||||
.leafepilogue
|
||||
.endfn tinymath_copysign,globl
|
||||
.alias tinymath_copysign,copysign
|
||||
|
||||
.rodata.cst16
|
||||
.L1: .long 4294967295
|
||||
.long 2147483647
|
||||
.long 0
|
||||
.long 0
|
||||
.L2: .long 0
|
||||
.long -2147483648
|
||||
.long 0
|
||||
.long 0
|
42
libc/tinymath/copysignf.S
Normal file
42
libc/tinymath/copysignf.S
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_copysignf:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movaps %xmm1,%xmm2
|
||||
andps .LC8(%rip),%xmm0
|
||||
andps .LC10(%rip),%xmm2
|
||||
orps %xmm2,%xmm0
|
||||
.leafepilogue
|
||||
.endfn tinymath_copysignf,globl
|
||||
.alias tinymath_copysignf,copysignf
|
||||
|
||||
.rodata.cst16
|
||||
.LC8: .long 2147483647
|
||||
.long 0
|
||||
.long 0
|
||||
.long 0
|
||||
.LC10: .long 2147483648
|
||||
.long 0
|
||||
.long 0
|
||||
.long 0
|
39
libc/tinymath/copysignl.S
Normal file
39
libc/tinymath/copysignl.S
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_copysignl:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 32(%rbp)
|
||||
fxam
|
||||
fnstsw %ax
|
||||
fstp %st
|
||||
fldt 16(%rbp)
|
||||
testb $2,%ah
|
||||
fabs
|
||||
je 1f
|
||||
fchs
|
||||
1: pop %rbp
|
||||
ret
|
||||
.endfn tinymath_copysignl,globl
|
||||
.alias tinymath_copysignl,copysignl
|
32
libc/tinymath/cos.S
Normal file
32
libc/tinymath/cos.S
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns cosine of 𝑥.
|
||||
/
|
||||
/ @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
|
||||
jmp _d2ld2
|
||||
.endfn tinymath_cos,globl
|
||||
.alias tinymath_cos,cos
|
32
libc/tinymath/cosf.S
Normal file
32
libc/tinymath/cosf.S
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns cosine of 𝑥.
|
||||
/
|
||||
/ @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
|
||||
jmp _f2ld2
|
||||
.endfn tinymath_cosf,globl
|
||||
.alias tinymath_cosf,cosf
|
44
libc/tinymath/cosl.S
Normal file
44
libc/tinymath/cosl.S
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns cosine of 𝑥.
|
||||
/
|
||||
/ @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
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 16(%rbp)
|
||||
ezlea _cos,dx
|
||||
call c2rangr
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_cosl,globl
|
||||
.alias tinymath_cosl,cosl
|
||||
|
||||
_cos: .leafprologue
|
||||
.profilable
|
||||
fcos
|
||||
.leafepilogue
|
||||
.endfn _cos
|
37
libc/tinymath/cprojf.S
Normal file
37
libc/tinymath/cprojf.S
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_cprojf:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
sub $16,%rsp
|
||||
movq %xmm0,8(%rsp)
|
||||
movss 8(%rsp),%xmm0
|
||||
movss %xmm0,(%rsp)
|
||||
movss 12(%rsp),%xmm0
|
||||
movss %xmm0,4(%rsp)
|
||||
movq (%rsp),%xmm0
|
||||
leave
|
||||
ret
|
||||
.endfn tinymath_cprojf,globl
|
||||
.alias tinymath_cprojf,cprojf
|
58
libc/tinymath/cprojl.S
Normal file
58
libc/tinymath/cprojl.S
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_cprojl:
|
||||
.profilable
|
||||
sub $24,%rsp
|
||||
fldt 32(%rsp)
|
||||
fnstcw 14(%rsp)
|
||||
movzwl 14(%rsp),%eax
|
||||
orb $12,%ah
|
||||
movw %ax,12(%rsp)
|
||||
fldcw 12(%rsp)
|
||||
fistpq (%rsp)
|
||||
fldcw 14(%rsp)
|
||||
movq (%rsp),%rsi
|
||||
fldt 48(%rsp)
|
||||
mov %rsi,%rax
|
||||
fldcw 12(%rsp)
|
||||
fistpq (%rsp)
|
||||
fldcw 14(%rsp)
|
||||
movq (%rsp),%rcx
|
||||
add $24,%rsp
|
||||
mov %rcx,%rdx
|
||||
ret
|
||||
.endfn tinymath_cprojl,globl
|
||||
.alias tinymath_cprojl,cprojl
|
||||
|
||||
/ TODO(jart):
|
||||
/ sub $24,%rsp
|
||||
/ fldt 32(%rsp)
|
||||
/ fisttpq 8(%rsp)
|
||||
/ fldt 48(%rsp)
|
||||
/ movq 8(%rsp),%rsi
|
||||
/ mov %rsi,%rax
|
||||
/ fisttpq 8(%rsp)
|
||||
/ movq 8(%rsp),%rcx
|
||||
/ add $24,%rsp
|
||||
/ mov %rcx,%rdx
|
||||
/ ret
|
24
libc/tinymath/creal.S
Normal file
24
libc/tinymath/creal.S
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.inc"
|
||||
.yoink __FILE__
|
||||
|
||||
creal: ret
|
||||
.endfn creal,globl
|
31
libc/tinymath/crealf.S
Normal file
31
libc/tinymath/crealf.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
crealf: push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
push %rax
|
||||
movq %xmm0,(%rsp)
|
||||
movss (%rsp),%xmm0
|
||||
leave
|
||||
ret
|
||||
.endfn crealf,globl
|
29
libc/tinymath/creall.S
Normal file
29
libc/tinymath/creall.S
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
creall: push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 16(%rbp)
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn creall,globl
|
43
libc/tinymath/d2ld2.S
Normal file
43
libc/tinymath/d2ld2.S
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Thunks double(*fn)(double,double) -> long double fn.
|
||||
/
|
||||
/ @param %xmm0[0] contains double param
|
||||
/ @return %xmm0[0] contains double result
|
||||
/ @note 100% negligible overhead
|
||||
_d2ld2: push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
sub $32,%rsp
|
||||
movsd %xmm0,-32(%rbp)
|
||||
fldl -32(%rbp)
|
||||
fstpt -32(%rbp)
|
||||
movsd %xmm1,-16(%rbp)
|
||||
fldl -16(%rbp)
|
||||
fstpt -16(%rbp)
|
||||
call *%rax
|
||||
fstpl -16(%rbp)
|
||||
movsd -16(%rbp),%xmm0
|
||||
leave
|
||||
ret
|
||||
.endfn _d2ld2,globl,hidden
|
24
libc/tinymath/delegates/powi.c
Normal file
24
libc/tinymath/delegates/powi.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/tinymath/tinymath.h"
|
||||
|
||||
double(powi)(double a, int b) {
|
||||
return tinymath_powl(a, b);
|
||||
}
|
24
libc/tinymath/delegates/powif.c
Normal file
24
libc/tinymath/delegates/powif.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/tinymath/tinymath.h"
|
||||
|
||||
float powif(float a, int b) {
|
||||
return tinymath_powl(a, b);
|
||||
}
|
24
libc/tinymath/delegates/powil.c
Normal file
24
libc/tinymath/delegates/powil.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/tinymath/tinymath.h"
|
||||
|
||||
long double powil(long double a, int b) {
|
||||
return tinymath_powl(a, b);
|
||||
}
|
17
libc/tinymath/emod.h
Normal file
17
libc/tinymath/emod.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_TINYMATH_EMOD_H_
|
||||
#define COSMOPOLITAN_LIBC_TINYMATH_EMOD_H_
|
||||
#include "libc/math.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
/**
|
||||
* Returns Euclidean floating-point division remainder.
|
||||
*
|
||||
* @return (𝑥 mod 𝑦) ∈ [0.,𝑦)
|
||||
* @see fmod()
|
||||
*/
|
||||
static double emod(double x, double y) {
|
||||
return x - fabs(y) * floor(x / fabs(y));
|
||||
}
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_TINYMATH_EMOD_H_ */
|
31
libc/tinymath/exp.S
Normal file
31
libc/tinymath/exp.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns 𝑒^x.
|
||||
/
|
||||
/ @param 𝑥 is float scalar in low quarter of %xmm0
|
||||
/ @return float scalar in low quarter of %xmm0
|
||||
tinymath_exp:
|
||||
ezlea tinymath_expl,ax
|
||||
jmp _d2ld2
|
||||
.endfn tinymath_exp,globl
|
||||
.alias tinymath_exp,exp
|
33
libc/tinymath/exp10.S
Normal file
33
libc/tinymath/exp10.S
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns 10^x.
|
||||
/
|
||||
/ @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
|
||||
jmp _d2ld2
|
||||
.endfn tinymath_exp10,globl
|
||||
.alias tinymath_exp10,exp10
|
||||
.alias tinymath_exp10,pow10
|
32
libc/tinymath/exp10f.S
Normal file
32
libc/tinymath/exp10f.S
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns 10^x.
|
||||
/
|
||||
/ @param 𝑥 is float scalar in low quarter of %xmm0
|
||||
/ @return float scalar in low quarter of %xmm0
|
||||
tinymath_exp10f:
|
||||
ezlea tinymath_exp10l,ax
|
||||
jmp _f2ld2
|
||||
.endfn tinymath_exp10f,globl
|
||||
.alias tinymath_exp10f,exp10f
|
||||
.alias tinymath_exp10f,pow10f
|
47
libc/tinymath/exp10l.S
Normal file
47
libc/tinymath/exp10l.S
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns 10^x.
|
||||
/
|
||||
/ @param 𝑥 is an 80-bit long double passed on stack in 16-bytes
|
||||
/ @return result of exponentiation on FPU stack in %st
|
||||
tinymath_exp10l:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 16(%rbp)
|
||||
fldl2t
|
||||
fmulp %st,%st(1)
|
||||
fld %st
|
||||
frndint
|
||||
fsubr %st,%st(1)
|
||||
fxch %st(1)
|
||||
f2xm1
|
||||
fld1
|
||||
faddp
|
||||
fscale
|
||||
fstp %st(1)
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_exp10l,globl
|
||||
.alias tinymath_exp10l,exp10l
|
||||
.alias tinymath_exp10l,pow10l
|
29
libc/tinymath/exp2.S
Normal file
29
libc/tinymath/exp2.S
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns 2^𝑥.
|
||||
/
|
||||
/ @param 𝑥 is a double passed in the lower quadword of %xmm0
|
||||
/ @return result in lower quadword of %xmm0
|
||||
exp2: ezlea exp2l,ax
|
||||
jmp _d2ld2
|
||||
.endfn exp2,globl
|
25
libc/tinymath/exp2f.S
Normal file
25
libc/tinymath/exp2f.S
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
exp2f: ezlea exp2f,ax
|
||||
jmp _f2ld2
|
||||
.endfn exp2f,globl
|
41
libc/tinymath/exp2l.S
Normal file
41
libc/tinymath/exp2l.S
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns 2^x.
|
||||
exp2l: push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 16(%rbp)
|
||||
fld %st
|
||||
frndint
|
||||
fsubr %st,%st(1)
|
||||
fxch %st(1)
|
||||
f2xm1
|
||||
fadds .Lone(%rip)
|
||||
fscale
|
||||
fstp %st(1)
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn exp2l,globl
|
||||
|
||||
.rodata.cst4
|
||||
.Lone: .float 1.0
|
31
libc/tinymath/expf.S
Normal file
31
libc/tinymath/expf.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns 𝑒^x.
|
||||
/
|
||||
/ @param 𝑥 is double scalar in low half of %xmm0
|
||||
/ @return double scalar in low half of %xmm0
|
||||
tinymath_expf:
|
||||
ezlea tinymath_expl,ax
|
||||
jmp _f2ld2
|
||||
.endfn tinymath_expf,globl
|
||||
.alias tinymath_expf,expf
|
46
libc/tinymath/expl.S
Normal file
46
libc/tinymath/expl.S
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns 𝑒^x.
|
||||
/
|
||||
/ @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
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 16(%rbp)
|
||||
fldl2e
|
||||
fmulp %st,%st(1)
|
||||
fld %st
|
||||
frndint
|
||||
fsubr %st,%st(1)
|
||||
fxch %st(1)
|
||||
f2xm1
|
||||
fld1
|
||||
faddp
|
||||
fscale
|
||||
fstp %st(1)
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_expl,globl
|
||||
.alias tinymath_expl,expl
|
25
libc/tinymath/expm1.S
Normal file
25
libc/tinymath/expm1.S
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
expm1: ezlea expm1l,ax
|
||||
jmp _d2ld2
|
||||
.endfn expm1,globl
|
25
libc/tinymath/expm1f.S
Normal file
25
libc/tinymath/expm1f.S
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
expm1f: ezlea expm1l,ax
|
||||
jmp _f2ld2
|
||||
.endfn expm1f,globl
|
47
libc/tinymath/expm1l.S
Normal file
47
libc/tinymath/expm1l.S
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns exp(𝑥) - 1.
|
||||
expm1l: push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 16(%rbp)
|
||||
fldl2e
|
||||
fmulp %st,%st(1)
|
||||
fld %st
|
||||
frndint
|
||||
fsubr %st,%st(1)
|
||||
fld1
|
||||
fxch %st(2)
|
||||
f2xm1
|
||||
fscale
|
||||
fxch %st(2)
|
||||
fscale
|
||||
fstp %st(1)
|
||||
fsubs .Lone(%rip)
|
||||
faddp %st,%st(1)
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn expm1l,globl
|
||||
|
||||
.rodata.cst4
|
||||
.Lone: .float 1.0
|
43
libc/tinymath/f2ld2.S
Normal file
43
libc/tinymath/f2ld2.S
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Thunks float(*fn)(float,float) -> long double fn.
|
||||
/
|
||||
/ @param %xmm0[0] contains float param
|
||||
/ @return %xmm0[0] contains float result
|
||||
/ @note 100% negligible overhead
|
||||
_f2ld2: push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
sub $32,%rsp
|
||||
movss %xmm0,-32(%rbp)
|
||||
flds -32(%rbp)
|
||||
fstpt -32(%rbp)
|
||||
movsd %xmm1,-16(%rbp)
|
||||
flds -16(%rbp)
|
||||
fstpt -16(%rbp)
|
||||
call *%rax
|
||||
fstps -16(%rbp)
|
||||
movss -16(%rbp),%xmm0
|
||||
leave
|
||||
ret
|
||||
.endfn _f2ld2,globl,hidden
|
30
libc/tinymath/fabs.S
Normal file
30
libc/tinymath/fabs.S
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
fabs: .leafprologue
|
||||
.profilable
|
||||
mov $0x7fffffffffffffff,%rax
|
||||
movq %xmm0,%rdx
|
||||
and %rax,%rdx
|
||||
movq %rdx,%xmm0
|
||||
.leafepilogue
|
||||
.endfn fabs,globl
|
29
libc/tinymath/fabsf.S
Normal file
29
libc/tinymath/fabsf.S
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
fabsf: .leafprologue
|
||||
.profilable
|
||||
movd %xmm0,%eax
|
||||
and $0x7fffffff,%eax
|
||||
movd %eax,%xmm0
|
||||
.leafepilogue
|
||||
.endfn fabsf,globl
|
30
libc/tinymath/fabsl.S
Normal file
30
libc/tinymath/fabsl.S
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
fabsl: push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 16(%rbp)
|
||||
fabs
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn fabsl,globl
|
45
libc/tinymath/fld.S
Normal file
45
libc/tinymath/fld.S
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.inc"
|
||||
.yoink __FILE__
|
||||
|
||||
fld1: fld1
|
||||
ret
|
||||
.endfn fld1,globl
|
||||
|
||||
fldl2t: fldl2t
|
||||
ret
|
||||
.endfn fldl2t,globl
|
||||
|
||||
fldlg2: fldlg2
|
||||
ret
|
||||
.endfn fldlg2,globl
|
||||
|
||||
fldl2e: fldl2e
|
||||
ret
|
||||
.endfn fldl2e,globl
|
||||
|
||||
fldln2: fldln2
|
||||
ret
|
||||
.endfn fldln2,globl
|
||||
|
||||
fldpi: fldpi
|
||||
ret
|
||||
.endfn fldpi,globl
|
57
libc/tinymath/floor.S
Normal file
57
libc/tinymath/floor.S
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ vroundsd $_MM_FROUND_TO_NEG_INF|_MM_FROUND_NO_EXC,%xmm0,%xmm0,%xmm0
|
||||
|
||||
tinymath_floor:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movsd .LC6(%rip),%xmm1
|
||||
movsd .LC5(%rip),%xmm2
|
||||
andpd %xmm0,%xmm1
|
||||
comisd %xmm1,%xmm2
|
||||
jbe 1f
|
||||
cvttsd2siq %xmm0,%rax
|
||||
pxor %xmm1,%xmm1
|
||||
movsd .LC4(%rip),%xmm2
|
||||
cvtsi2sdq %rax,%xmm1
|
||||
movapd %xmm1,%xmm3
|
||||
cmpnlesd %xmm0,%xmm3
|
||||
movapd %xmm3,%xmm0
|
||||
andpd %xmm2,%xmm0
|
||||
subsd %xmm0,%xmm1
|
||||
movapd %xmm1,%xmm0
|
||||
1: .leafepilogue
|
||||
.endfn tinymath_floor,globl
|
||||
.alias tinymath_floor,floor
|
||||
|
||||
.rodata.cst8
|
||||
.LC4: .long 0
|
||||
.long 1072693248
|
||||
.LC5: .long 0
|
||||
.long 1127219200
|
||||
|
||||
.rodata.cst16
|
||||
.LC6: .long 4294967295
|
||||
.long 2147483647
|
||||
.long 0
|
||||
.long 0
|
50
libc/tinymath/floorf.S
Normal file
50
libc/tinymath/floorf.S
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_floorf:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movss .LC8(%rip),%xmm1
|
||||
andps %xmm0,%xmm1
|
||||
movss .LC7(%rip),%xmm2
|
||||
comiss %xmm1,%xmm2
|
||||
jbe 1f
|
||||
cvttss2si %xmm0,%eax
|
||||
pxor %xmm1,%xmm1
|
||||
movss .LC3(%rip),%xmm2
|
||||
cvtsi2ss %eax,%xmm1
|
||||
movaps %xmm1,%xmm3
|
||||
cmpnless %xmm0,%xmm3
|
||||
movaps %xmm3,%xmm0
|
||||
andps %xmm2,%xmm0
|
||||
subss %xmm0,%xmm1
|
||||
movaps %xmm1,%xmm0
|
||||
1: .leafepilogue
|
||||
.endfn tinymath_floorf,globl
|
||||
.alias tinymath_floorf,floorf
|
||||
|
||||
.rodata.cst4
|
||||
.LC3: .float 1.0
|
||||
.LC7: .long 0x4b000000
|
||||
|
||||
.rodata.cst16
|
||||
.LC8: .long 2147483647,0,0,0
|
36
libc/tinymath/floorl.S
Normal file
36
libc/tinymath/floorl.S
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_floorl:
|
||||
.profilable
|
||||
fldt 8(%rsp)
|
||||
mov $7,%al
|
||||
fstcw 8(%rsp)
|
||||
mov 9(%rsp),%ah
|
||||
mov %al,9(%rsp)
|
||||
fldcw 8(%rsp)
|
||||
frndint
|
||||
mov %ah,9(%rsp)
|
||||
fldcw 8(%rsp)
|
||||
ret
|
||||
.endfn tinymath_floorl,globl
|
||||
.alias tinymath_floorl,floorl
|
29
libc/tinymath/fmax.S
Normal file
29
libc/tinymath/fmax.S
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_fmax:
|
||||
.leafprologue
|
||||
.profilable
|
||||
maxsd %xmm1,%xmm0
|
||||
.leafepilogue
|
||||
.endfn tinymath_fmax,globl
|
||||
.alias tinymath_fmax,fmax
|
29
libc/tinymath/fmaxf.S
Normal file
29
libc/tinymath/fmaxf.S
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_fmaxf:
|
||||
.leafprologue
|
||||
.profilable
|
||||
maxss %xmm1,%xmm0
|
||||
.leafepilogue
|
||||
.endfn tinymath_fmaxf,globl
|
||||
.alias tinymath_fmaxf,fmaxf
|
35
libc/tinymath/fmaxl.S
Normal file
35
libc/tinymath/fmaxl.S
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_fmaxl:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 32(%rbp)
|
||||
fldt 16(%rbp)
|
||||
fcomi %st(1),%st
|
||||
fcmovb %st(1),%st
|
||||
fstp %st(1)
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_fmaxl,globl
|
||||
.alias tinymath_fmaxl,fmaxl
|
29
libc/tinymath/fmin.S
Normal file
29
libc/tinymath/fmin.S
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_fmin:
|
||||
.leafprologue
|
||||
.profilable
|
||||
minsd %xmm1,%xmm0
|
||||
.leafepilogue
|
||||
.endfn tinymath_fmin,globl
|
||||
.alias tinymath_fmin,fmin
|
29
libc/tinymath/fminf.S
Normal file
29
libc/tinymath/fminf.S
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_fminf:
|
||||
.leafprologue
|
||||
.profilable
|
||||
minss %xmm1,%xmm0
|
||||
.leafepilogue
|
||||
.endfn tinymath_fminf,globl
|
||||
.alias tinymath_fminf,fminf
|
35
libc/tinymath/fminl.S
Normal file
35
libc/tinymath/fminl.S
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_fminl:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 32(%rbp)
|
||||
fldt 16(%rbp)
|
||||
fcomi %st(1),%st
|
||||
fcmovnbe %st(1),%st
|
||||
fstp %st(1)
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_fminl,globl
|
||||
.alias tinymath_fminl,fminl
|
34
libc/tinymath/fmod.S
Normal file
34
libc/tinymath/fmod.S
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ fmod [sic] does (𝑥 rem 𝑦) w/ round()-style rounding.
|
||||
/
|
||||
/ @param 𝑥 is double passed in lower half of %xmm0
|
||||
/ @param 𝑦 is double passed in lower half of %xmm1
|
||||
/ @return remainder ∈ (-|𝑦|,|𝑦|) in %xmm0
|
||||
/ @define 𝑥-trunc(𝑥/𝑦)*𝑦
|
||||
/ @see emod()
|
||||
tinymath_fmod:
|
||||
ezlea tinymath_fmodl,ax
|
||||
jmp _d2ld2
|
||||
.endfn tinymath_fmod,globl
|
||||
.alias tinymath_fmod,fmod
|
27
libc/tinymath/fmodf.S
Normal file
27
libc/tinymath/fmodf.S
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_fmodf:
|
||||
ezlea tinymath_fmodl,ax
|
||||
jmp _f2ld2
|
||||
.endfn tinymath_fmodf,globl
|
||||
.alias tinymath_fmodf,fmodf
|
37
libc/tinymath/fmodl.S
Normal file
37
libc/tinymath/fmodl.S
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_fmodl:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 32(%rbp)
|
||||
fldt 16(%rbp)
|
||||
1: fprem
|
||||
fnstsw %ax
|
||||
testb $4,%ah
|
||||
jnz 1b
|
||||
fstp %st(1)
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_fmodl,globl
|
||||
.alias tinymath_fmodl,fmodl
|
44
libc/tinymath/fpclassify.S
Normal file
44
libc/tinymath/fpclassify.S
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
__fpclassify:
|
||||
.leafprologue
|
||||
movd %xmm0,%rax
|
||||
movd %xmm0,%rdx
|
||||
shr $52,%rax
|
||||
mov %eax,%ecx
|
||||
and $0x7ff,%ecx
|
||||
jne 2f
|
||||
add %rdx,%rdx
|
||||
cmp $1,%rdx
|
||||
sbb %eax,%eax
|
||||
add $3,%eax
|
||||
jmp 1f
|
||||
2: mov $FP_NORMAL,%eax
|
||||
cmp $0x7ff,%ecx
|
||||
jne 1f
|
||||
xor %eax,%eax
|
||||
sal $12,%rdx
|
||||
sete %al
|
||||
1: .leafepilogue
|
||||
.endfn __fpclassify,globl
|
45
libc/tinymath/fpclassifyf.S
Normal file
45
libc/tinymath/fpclassifyf.S
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
__fpclassifyf:
|
||||
.leafprologue
|
||||
movd %xmm0,%edx
|
||||
movd %xmm0,%eax
|
||||
shr $23,%eax
|
||||
and $255,%eax
|
||||
je 7f
|
||||
cmp $255,%eax
|
||||
je 8f
|
||||
mov $FP_NORMAL,%eax
|
||||
jmp 1f
|
||||
7: add %edx,%edx
|
||||
je 5f
|
||||
mov $FP_SUBNORMAL,%eax
|
||||
jmp 1f
|
||||
5: mov $FP_ZERO,%eax
|
||||
jmp 1f
|
||||
8: sal $9,%edx
|
||||
sete %al
|
||||
movzbl %al,%eax
|
||||
1: .leafepilogue
|
||||
.endfn __fpclassifyf,globl
|
53
libc/tinymath/fpclassifyl.S
Normal file
53
libc/tinymath/fpclassifyl.S
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/math.h"
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
__fpclassifyl:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
mov 24(%rbp),%rax
|
||||
mov 16(%rbp),%rdx
|
||||
and $0x7fff,%ax
|
||||
mov %rdx,%rcx
|
||||
shr $63,%rcx
|
||||
movzwl %ax,%esi
|
||||
or %ecx,%esi
|
||||
jne 2f
|
||||
cmp $1,%rdx
|
||||
sbb %eax,%eax
|
||||
add $3,%eax
|
||||
jmp 1f
|
||||
2: cmp $0x7fff,%ax
|
||||
jne 4f
|
||||
xor %eax,%eax
|
||||
test %rcx,%rcx
|
||||
je 1f
|
||||
xor %eax,%eax
|
||||
add %rdx,%rdx
|
||||
sete %al
|
||||
jmp 1f
|
||||
4: mov %ecx,%eax
|
||||
neg %eax
|
||||
and $FP_NORMAL,%eax
|
||||
1: pop %rbp
|
||||
ret
|
||||
.endfn __fpclassifyl,globl
|
61
libc/tinymath/frexp.S
Normal file
61
libc/tinymath/frexp.S
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_frexp:
|
||||
.leafprologue
|
||||
push %rbx
|
||||
push %rdx
|
||||
mov %rdi,%rbx
|
||||
movq %xmm0,%rax
|
||||
shr $52,%rax
|
||||
and $0x7ff,%eax
|
||||
jne 3f
|
||||
xorps %xmm1,%xmm1
|
||||
ucomisd %xmm1,%xmm0
|
||||
jp 1f
|
||||
je 2f
|
||||
1: mulsd 6f(%rip),%xmm0
|
||||
mov %rbx,%rdi
|
||||
call frexp
|
||||
subl $64,(%rbx)
|
||||
jmp 5f
|
||||
2: movl $0,(%rdi)
|
||||
jmp 5f
|
||||
3: cmp $0x7ff,%eax
|
||||
je 5f
|
||||
movq %xmm0,%rdx
|
||||
sub $0x3fe,%eax
|
||||
mov %eax,(%rdi)
|
||||
movabs $-9218868437227405313,%rax
|
||||
and %rax,%rdx
|
||||
mov $511,%eax
|
||||
sal $53,%rax
|
||||
or %rax,%rdx
|
||||
movq %rdx,%xmm0
|
||||
5: pop %rax
|
||||
pop %rbx
|
||||
.leafepilogue
|
||||
.endfn tinymath_frexp,globl
|
||||
.alias tinymath_frexp,frexp
|
||||
|
||||
.rodata.cst8
|
||||
6: .long 0,0x43f00000
|
33
libc/tinymath/hypot.S
Normal file
33
libc/tinymath/hypot.S
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns euclidean distance in 2d space.
|
||||
tinymath_hypot:
|
||||
.leafprologue
|
||||
.profilable
|
||||
mulsd %xmm1,%xmm1
|
||||
mulsd %xmm0,%xmm0
|
||||
addsd %xmm1,%xmm0
|
||||
sqrtsd %xmm0,%xmm0
|
||||
.leafepilogue
|
||||
.endfn tinymath_hypot,globl
|
||||
.alias tinymath_hypot,hypot
|
33
libc/tinymath/hypotf.S
Normal file
33
libc/tinymath/hypotf.S
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns euclidean distance in 2d space.
|
||||
tinymath_hypotf:
|
||||
.leafprologue
|
||||
.profilable
|
||||
mulss %xmm1,%xmm1
|
||||
mulss %xmm0,%xmm0
|
||||
addss %xmm1,%xmm0
|
||||
sqrtss %xmm0,%xmm0
|
||||
.leafepilogue
|
||||
.endfn tinymath_hypotf,globl
|
||||
.alias tinymath_hypotf,hypotf
|
37
libc/tinymath/hypotl.S
Normal file
37
libc/tinymath/hypotl.S
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
/ Returns euclidean distance in 2d space.
|
||||
tinymath_hypotl:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 32(%rbp)
|
||||
fldt 16(%rbp)
|
||||
fmul %st,%st
|
||||
fxch %st(1)
|
||||
fmul %st,%st
|
||||
faddp
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_hypotl,globl
|
||||
.alias tinymath_hypotl,hypotl
|
27
libc/tinymath/ilogb.S
Normal file
27
libc/tinymath/ilogb.S
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_ilogb:
|
||||
ezlea tinymath_ilogbl,ax
|
||||
jmp _d2ld2
|
||||
.endfn tinymath_ilogb,globl
|
||||
.alias tinymath_ilogb,ilogb
|
27
libc/tinymath/ilogbf.S
Normal file
27
libc/tinymath/ilogbf.S
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_ilogbf:
|
||||
ezlea tinymath_ilogbl,ax
|
||||
jmp _f2ld2
|
||||
.endfn tinymath_ilogbf,globl
|
||||
.alias tinymath_ilogbf,ilogbf
|
55
libc/tinymath/ilogbl.S
Normal file
55
libc/tinymath/ilogbl.S
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_ilogbl:
|
||||
.profilable
|
||||
sub $24,%rsp
|
||||
fldt 32(%rsp)
|
||||
fnstcw 14(%rsp)
|
||||
movzwl 14(%rsp),%eax
|
||||
orb $12,%ah
|
||||
movw %ax,12(%rsp)
|
||||
fxtract
|
||||
fstp %st
|
||||
fldcw 12(%rsp)
|
||||
fistpl 8(%rsp)
|
||||
fldcw 14(%rsp)
|
||||
movl 8(%rsp),%eax
|
||||
add $24,%rsp
|
||||
ret
|
||||
.endfn tinymath_ilogbl,globl
|
||||
.alias tinymath_ilogbl,ilogbl
|
||||
|
||||
/*
|
||||
TODO(jart)
|
||||
.globl ilogbl
|
||||
.type ilogbl,@function
|
||||
ilogbl: sub $24,%rsp
|
||||
fldt 32(%rsp)
|
||||
fxtract
|
||||
fstp %st
|
||||
fisttpl 12(%rsp)
|
||||
movl 12(%rsp),%eax
|
||||
add $24,%rsp
|
||||
ret
|
||||
.size ilogbl,.-ilogbl
|
||||
*/
|
31
libc/tinymath/isgreater.S
Normal file
31
libc/tinymath/isgreater.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_isgreaterf:
|
||||
.leafprologue
|
||||
.profilable
|
||||
xor %eax,%eax
|
||||
comiss %xmm1,%xmm0
|
||||
seta %al
|
||||
.leafepilogue
|
||||
.endfn tinymath_isgreaterf,globl
|
||||
.alias tinymath_isgreaterf,isgreaterf
|
31
libc/tinymath/isgreaterequal.S
Normal file
31
libc/tinymath/isgreaterequal.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_isgreaterequal:
|
||||
.leafprologue
|
||||
.profilable
|
||||
xor %eax,%eax
|
||||
comisd %xmm1,%xmm0
|
||||
setnb %al
|
||||
.leafepilogue
|
||||
.endfn tinymath_isgreaterequal,globl
|
||||
.alias tinymath_isgreaterequal,isgreaterequal
|
31
libc/tinymath/isgreaterequalf.S
Normal file
31
libc/tinymath/isgreaterequalf.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_isgreaterequalf:
|
||||
.leafprologue
|
||||
.profilable
|
||||
xor %eax,%eax
|
||||
comiss %xmm1,%xmm0
|
||||
setnb %al
|
||||
.leafepilogue
|
||||
.endfn tinymath_isgreaterequalf,globl
|
||||
.alias tinymath_isgreaterequalf,isgreaterequalf
|
36
libc/tinymath/isgreaterequall.S
Normal file
36
libc/tinymath/isgreaterequall.S
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_isgreaterequall:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 32(%rbp)
|
||||
fldt 16(%rbp)
|
||||
xor %eax,%eax
|
||||
fcomip %st(1),%st
|
||||
fstp %st
|
||||
setnb %al
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_isgreaterequall,globl
|
||||
.alias tinymath_isgreaterequall,isgreaterequall
|
31
libc/tinymath/isgreaterf.S
Normal file
31
libc/tinymath/isgreaterf.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_isgreater:
|
||||
.leafprologue
|
||||
.profilable
|
||||
xor %eax,%eax
|
||||
comisd %xmm1,%xmm0
|
||||
seta %al
|
||||
.leafepilogue
|
||||
.endfn tinymath_isgreater,globl
|
||||
.alias tinymath_isgreater,isgreater
|
36
libc/tinymath/isgreaterl.S
Normal file
36
libc/tinymath/isgreaterl.S
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_isgreaterl:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 32(%rbp)
|
||||
fldt 16(%rbp)
|
||||
xor %eax,%eax
|
||||
fcomip %st(1),%st
|
||||
fstp %st
|
||||
seta %al
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_isgreaterl,globl
|
||||
.alias tinymath_isgreaterl,isgreaterl
|
31
libc/tinymath/isless.S
Normal file
31
libc/tinymath/isless.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_isless:
|
||||
.leafprologue
|
||||
.profilable
|
||||
xor %eax,%eax
|
||||
comisd %xmm0,%xmm1
|
||||
seta %al
|
||||
.leafepilogue
|
||||
.endfn tinymath_isless,globl
|
||||
.alias tinymath_isless,isless
|
31
libc/tinymath/islessequal.S
Normal file
31
libc/tinymath/islessequal.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_islessequal:
|
||||
.leafprologue
|
||||
.profilable
|
||||
xor %eax,%eax
|
||||
comisd %xmm0,%xmm1
|
||||
setnb %al
|
||||
.leafepilogue
|
||||
.endfn tinymath_islessequal,globl
|
||||
.alias tinymath_islessequal,islessequal
|
31
libc/tinymath/islessequalf.S
Normal file
31
libc/tinymath/islessequalf.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_islessequalf:
|
||||
.leafprologue
|
||||
.profilable
|
||||
xor %eax,%eax
|
||||
comiss %xmm0,%xmm1
|
||||
setnb %al
|
||||
.leafepilogue
|
||||
.endfn tinymath_islessequalf,globl
|
||||
.alias tinymath_islessequalf,islessequalf
|
36
libc/tinymath/islessequall.S
Normal file
36
libc/tinymath/islessequall.S
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_islessequall:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 16(%rbp)
|
||||
xor %eax,%eax
|
||||
fldt 32(%rbp)
|
||||
fcomip %st(1),%st
|
||||
fstp %st
|
||||
setnb %al
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_islessequall,globl
|
||||
.alias tinymath_islessequall,islessequall
|
31
libc/tinymath/islessf.S
Normal file
31
libc/tinymath/islessf.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_islessf:
|
||||
.leafprologue
|
||||
.profilable
|
||||
xor %eax,%eax
|
||||
comiss %xmm0,%xmm1
|
||||
seta %al
|
||||
.leafepilogue
|
||||
.endfn tinymath_islessf,globl
|
||||
.alias tinymath_islessf,islessf
|
31
libc/tinymath/islessgreater.S
Normal file
31
libc/tinymath/islessgreater.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_islessgreater:
|
||||
.leafprologue
|
||||
.profilable
|
||||
xor %eax,%eax
|
||||
comisd %xmm1,%xmm0
|
||||
setne %al
|
||||
.leafepilogue
|
||||
.endfn tinymath_islessgreater,globl
|
||||
.alias tinymath_islessgreater,islessgreater
|
31
libc/tinymath/islessgreaterf.S
Normal file
31
libc/tinymath/islessgreaterf.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_islessgreaterf:
|
||||
.leafprologue
|
||||
.profilable
|
||||
xor %eax,%eax
|
||||
comiss %xmm1,%xmm0
|
||||
setne %al
|
||||
.leafepilogue
|
||||
.endfn tinymath_islessgreaterf,globl
|
||||
.alias tinymath_islessgreaterf,islessgreaterf
|
36
libc/tinymath/islessgreaterl.S
Normal file
36
libc/tinymath/islessgreaterl.S
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_islessgreaterl:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 16(%rbp)
|
||||
xor %eax,%eax
|
||||
fldt 32(%rbp)
|
||||
fcomip %st(1),%st
|
||||
fstp %st
|
||||
setne %al
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_islessgreaterl,globl
|
||||
.alias tinymath_islessgreaterl,islessgreaterl
|
36
libc/tinymath/islessl.S
Normal file
36
libc/tinymath/islessl.S
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*-*- mode:asm; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.yoink __FILE__
|
||||
|
||||
tinymath_islessl:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
fldt 16(%rbp)
|
||||
xor %eax,%eax
|
||||
fldt 32(%rbp)
|
||||
fcomip %st(1),%st
|
||||
fstp %st
|
||||
seta %al
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn tinymath_islessl,globl
|
||||
.alias tinymath_islessl,islessl
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue