diff options
author | das <das@FreeBSD.org> | 2005-04-16 21:12:55 +0000 |
---|---|---|
committer | das <das@FreeBSD.org> | 2005-04-16 21:12:55 +0000 |
commit | 9c49c2a65a7716bcd9c75a74df1af7695cfad48f (patch) | |
tree | 7d175e24cc4583e1a5a8407639639582a10bced5 /lib/msun/i387 | |
parent | a9fd105354f92d739364a8db4c72a9ebc48e2db7 (diff) | |
download | FreeBSD-src-9c49c2a65a7716bcd9c75a74df1af7695cfad48f.zip FreeBSD-src-9c49c2a65a7716bcd9c75a74df1af7695cfad48f.tar.gz |
More optimized math functions.
Diffstat (limited to 'lib/msun/i387')
-rw-r--r-- | lib/msun/i387/Makefile.inc | 10 | ||||
-rw-r--r-- | lib/msun/i387/s_ceill.S | 27 | ||||
-rw-r--r-- | lib/msun/i387/s_copysignl.S | 17 | ||||
-rw-r--r-- | lib/msun/i387/s_floorl.S | 27 | ||||
-rw-r--r-- | lib/msun/i387/s_llrintf.S | 36 | ||||
-rw-r--r-- | lib/msun/i387/s_lrintf.S | 35 | ||||
-rw-r--r-- | lib/msun/i387/s_trunc.S | 26 | ||||
-rw-r--r-- | lib/msun/i387/s_truncf.S | 26 | ||||
-rw-r--r-- | lib/msun/i387/s_truncl.S | 26 |
9 files changed, 226 insertions, 4 deletions
diff --git a/lib/msun/i387/Makefile.inc b/lib/msun/i387/Makefile.inc index 38cb0fc..bae4c62 100644 --- a/lib/msun/i387/Makefile.inc +++ b/lib/msun/i387/Makefile.inc @@ -3,14 +3,16 @@ ARCH_SRCS = e_exp.S e_fmod.S e_log.S e_log10.S \ e_remainder.S e_scalb.S e_sqrt.S s_ceil.S s_copysign.S \ s_cos.S s_finite.S s_floor.S s_llrint.S s_logb.S s_lrint.S \ - s_remquo.S s_rint.S s_scalbn.S s_significand.S s_sin.S s_tan.S + s_remquo.S s_rint.S s_scalbn.S s_significand.S s_sin.S s_tan.S \ + s_trunc.S # float counterparts ARCH_SRCS+= e_log10f.S e_logf.S e_remainderf.S e_scalbf.S \ - e_sqrtf.S s_ceilf.S s_copysignf.S s_floorf.S s_logbf.S \ - s_remquof.S s_rintf.S s_scalbnf.S s_significandf.S + e_sqrtf.S s_ceilf.S s_copysignf.S s_floorf.S \ + s_llrintf.S s_logbf.S s_lrintf.S \ + s_remquof.S s_rintf.S s_scalbnf.S s_significandf.S s_truncf.S # long double counterparts -ARCH_SRCS+= s_scalbnl.S +ARCH_SRCS+= s_ceill.S s_copysignl.S s_floorl.S s_scalbnl.S s_truncl.S LDBL_PREC = 64 # XXX 64-bit format, but truncated to 53 bits diff --git a/lib/msun/i387/s_ceill.S b/lib/msun/i387/s_ceill.S new file mode 100644 index 0000000..ae64abf --- /dev/null +++ b/lib/msun/i387/s_ceill.S @@ -0,0 +1,27 @@ +/* + * Based on code written by J.T. Conklin <jtc@NetBSD.org>. + * Public domain. + */ + +#include <machine/asm.h> +__FBSDID("$FreeBSD$") + +ENTRY(ceill) + pushl %ebp + movl %esp,%ebp + subl $8,%esp + + fstcw -4(%ebp) /* store fpu control word */ + movw -4(%ebp),%dx + orw $0x0800,%dx /* round towards +oo */ + andw $0xfbff,%dx + movw %dx,-8(%ebp) + fldcw -8(%ebp) /* load modfied control word */ + + fldt 8(%ebp) /* round */ + frndint + + fldcw -4(%ebp) /* restore original control word */ + + leave + ret diff --git a/lib/msun/i387/s_copysignl.S b/lib/msun/i387/s_copysignl.S new file mode 100644 index 0000000..7878591 --- /dev/null +++ b/lib/msun/i387/s_copysignl.S @@ -0,0 +1,17 @@ +/* + * Based on code written by J.T. Conklin <jtc@NetBSD.org>. + * Public domain. + */ + +#include <machine/asm.h> +__FBSDID("$FreeBSD$") + +ENTRY(copysignl) + movl 24(%esp),%edx + andl $0x8000,%edx + movl 12(%esp),%eax + andl $0x7fff,%eax + orl %edx,%eax + movl %eax,12(%esp) + fldt 4(%esp) + ret diff --git a/lib/msun/i387/s_floorl.S b/lib/msun/i387/s_floorl.S new file mode 100644 index 0000000..a0bb048 --- /dev/null +++ b/lib/msun/i387/s_floorl.S @@ -0,0 +1,27 @@ +/* + * Based on code written by J.T. Conklin <jtc@NetBSD.org>. + * Public domain. + */ + +#include <machine/asm.h> +__FBSDID("$FreeBSD$") + +ENTRY(floorl) + pushl %ebp + movl %esp,%ebp + subl $8,%esp + + fstcw -4(%ebp) /* store fpu control word */ + movw -4(%ebp),%dx + orw $0x0400,%dx /* round towards -oo */ + andw $0xf7ff,%dx + movw %dx,-8(%ebp) + fldcw -8(%ebp) /* load modfied control word */ + + fldt 8(%ebp) /* round */ + frndint + + fldcw -4(%ebp) /* restore original control word */ + + leave + ret diff --git a/lib/msun/i387/s_llrintf.S b/lib/msun/i387/s_llrintf.S new file mode 100644 index 0000000..4f398b6 --- /dev/null +++ b/lib/msun/i387/s_llrintf.S @@ -0,0 +1,36 @@ +/*- + * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <machine/asm.h> +__FBSDID("$FreeBSD$") + +ENTRY(llrintf) + flds 4(%esp) + subl $8,%esp + fistpll (%esp) + popl %eax + popl %edx + ret diff --git a/lib/msun/i387/s_lrintf.S b/lib/msun/i387/s_lrintf.S new file mode 100644 index 0000000..b9915fa --- /dev/null +++ b/lib/msun/i387/s_lrintf.S @@ -0,0 +1,35 @@ +/*- + * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <machine/asm.h> +__FBSDID("$FreeBSD$") + +ENTRY(lrintf) + flds 4(%esp) + subl $4,%esp + fistpl (%esp) + popl %eax + ret diff --git a/lib/msun/i387/s_trunc.S b/lib/msun/i387/s_trunc.S new file mode 100644 index 0000000..91926d7 --- /dev/null +++ b/lib/msun/i387/s_trunc.S @@ -0,0 +1,26 @@ +/* + * Based on code written by J.T. Conklin <jtc@NetBSD.org>. + * Public domain. + */ + +#include <machine/asm.h> +__FBSDID("$FreeBSD$") + +ENTRY(trunc) + pushl %ebp + movl %esp,%ebp + subl $8,%esp + + fstcw -4(%ebp) /* store fpu control word */ + movw -4(%ebp),%dx + orw $0x0c00,%dx /* round towards -oo */ + movw %dx,-8(%ebp) + fldcw -8(%ebp) /* load modfied control word */ + + fldl 8(%ebp) /* round */ + frndint + + fldcw -4(%ebp) /* restore original control word */ + + leave + ret diff --git a/lib/msun/i387/s_truncf.S b/lib/msun/i387/s_truncf.S new file mode 100644 index 0000000..b732908 --- /dev/null +++ b/lib/msun/i387/s_truncf.S @@ -0,0 +1,26 @@ +/* + * Based on code written by J.T. Conklin <jtc@NetBSD.org>. + * Public domain. + */ + +#include <machine/asm.h> +__FBSDID("$FreeBSD$") + +ENTRY(truncf) + pushl %ebp + movl %esp,%ebp + subl $8,%esp + + fstcw -12(%ebp) /* store fpu control word */ + movw -12(%ebp),%dx + orw $0x0c00,%dx /* round towards -oo */ + movw %dx,-16(%ebp) + fldcw -16(%ebp) /* load modfied control word */ + + flds 8(%ebp) /* round */ + frndint + + fldcw -12(%ebp) /* restore original control word */ + + leave + ret diff --git a/lib/msun/i387/s_truncl.S b/lib/msun/i387/s_truncl.S new file mode 100644 index 0000000..b20b06e --- /dev/null +++ b/lib/msun/i387/s_truncl.S @@ -0,0 +1,26 @@ +/* + * Based on code written by J.T. Conklin <jtc@NetBSD.org>. + * Public domain. + */ + +#include <machine/asm.h> +__FBSDID("$FreeBSD$") + +ENTRY(truncl) + pushl %ebp + movl %esp,%ebp + subl $8,%esp + + fstcw -4(%ebp) /* store fpu control word */ + movw -4(%ebp),%dx + orw $0x0c00,%dx /* round towards -oo */ + movw %dx,-8(%ebp) + fldcw -8(%ebp) /* load modfied control word */ + + fldt 8(%ebp) /* round */ + frndint + + fldcw -4(%ebp) /* restore original control word */ + + leave + ret |