1N/A/*
1N/A * CDDL HEADER START
1N/A *
1N/A * The contents of this file are subject to the terms of the
1N/A * Common Development and Distribution License (the "License").
1N/A * You may not use this file except in compliance with the License.
1N/A *
1N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1N/A * or http://www.opensolaris.org/os/licensing.
1N/A * See the License for the specific language governing permissions
1N/A * and limitations under the License.
1N/A *
1N/A * When distributing Covered Code, include this CDDL HEADER in each
1N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1N/A * If applicable, add the following below this CDDL HEADER, with the
1N/A * fields enclosed by brackets "[]" replaced with your own identifying
1N/A * information: Portions Copyright [yyyy] [name of copyright owner]
1N/A *
1N/A * CDDL HEADER END
1N/A */
1N/A/*
1N/A * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
1N/A */
1N/A/*
1N/A * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
1N/A * Use is subject to license terms.
1N/A */
1N/A
1N/A .file "expm1l.s"
1N/A
1N/A#include "libm.h"
1N/ALIBM_ANSI_PRAGMA_WEAK(expm1l,function)
1N/A
1N/A .data
1N/A .align 16
1N/Aln2_hi: .4byte 0xd1d00000, 0xb17217f7, 0x3ffe, 0x0
1N/Aln2_lo: .4byte 0x4c67fc0d, 0x8654361c, 0xbfce, 0x0
1N/A
1N/A ENTRY(expm1l)
1N/A movl 16(%rsp),%ecx / cx <--sign&bexp(x)
1N/A movl %ecx,%eax / ax <--sign&bexp(x)
1N/A andl $0x7fff,%ecx / ecx <-- zero_xtnd(bexp(x))
1N/A cmpl $0x3ffe,%ecx / Is |x| < ln(2)?
1N/A jb .shortcut / If so, take a shortcut.
1N/A je .check_tail / |x| may be only slightly < ln(2)
1N/A.general_case: / Here, |x| > ln(2) or x is NaN
1N/A cmpl $0x7fff,%ecx / bexp(|x|) = bexp(INF)?
1N/A je .not_finite / if so, x is not finite
1N/A andl $0xffff,%eax / eax <-- sign&bexp(x)
1N/A cmpl $0xc006,%eax / x <= -128?
1N/A jae 1f / if so, simply return -1
1N/A cmpl $0x400d,%ecx / |x| < 16384 = 2^14?
1N/A jb .finite_non_special / if so, proceed with argument reduction
1N/A fldt 8(%rsp) / x >= 16384; x
1N/A fld1 / 1, x
1N/A fscale / +Inf, x
1N/A fstp %st(1) / +Inf
1N/A ret
1N/A
1N/A.finite_non_special: / -128 < x < -ln(2) || ln(2) < x < 2^14
1N/A fldt 8(%rsp) / x
1N/A fld %st(0) / x, x
1N/A fldl2e / log2(e), x, x
1N/A fmulp / z := x*log2(e), x
1N/A frndint / [z], x
1N/A fst %st(2) / [z], x, [z]
1N/A PIC_SETUP(1)
1N/A fldt PIC_L(ln2_hi) / ln2_hi, [z], x, [z]
1N/A fmulp / [z]*ln2_hi, x, [z]
1N/A fsubrp %st,%st(1) / x-[z]*ln2_hi, [z]
1N/A fldt PIC_L(ln2_lo) / ln2_lo, x-[z]*ln2_hi, [z]
1N/A PIC_WRAPUP
1N/A fmul %st(2),%st / [z]*ln2_lo, x-[z]*ln2_hi, [z]
1N/A fsubrp %st,%st(1) / r := x-[z]*ln(2), [z]
1N/A fldl2e / log2(e), r, [z]
1N/A fmulp / f := r*log2(e), [z]
1N/A f2xm1 / 2^f-1,[z]
1N/A fld1 / 1, 2^f-1, [z]
1N/A faddp %st,%st(1) / 2^f, [z]
1N/A fscale / e^x, [z]
1N/A fstp %st(1) / e^x
1N/A fld1 / 1, e^x
1N/A fsubrp %st,%st(1) / e^x-1
1N/A ret
1N/A
1N/A.check_tail:
1N/A movl 12(%rsp),%ecx / ecx <-- hi_32(sgnfcnd(x))
1N/A cmpl $0xb17217f7,%ecx / Is |x| < ln(2)?
1N/A ja .finite_non_special
1N/A jb .shortcut
1N/A movl 8(%rsp),%edx / edx <-- lo_32(x)
1N/A cmpl $0xd1cf79ab,%edx / Is |x| slightly < ln(2)?
1N/A ja .finite_non_special / branch if |x| slightly > ln(2)
1N/A.shortcut:
1N/A / Here, |x| < ln(2), so |z| = |x/ln(2)| < 1,
1N/A / whence z is in f2xm1's domain.
1N/A fldt 8(%rsp) / x
1N/A fldl2e / log2(e), x
1N/A fmulp / z := x*log2(e)
1N/A f2xm1 / 2^(x*log2(e))-1 = e^x-1
1N/A ret
1N/A
1N/A.not_finite:
1N/A movl 12(%rsp),%ecx / ecx <-- hi_32(sgnfcnd(x))
1N/A cmpl $0x80000000,%ecx / hi_32(|x|) = hi_32(INF)?
1N/A jne .NaN_or_pinf / if not, x is NaN
1N/A movl 8(%rsp),%edx / edx <-- lo_32(x)
1N/A cmpl $0,%edx / lo_32(x) = 0?
1N/A jne .NaN_or_pinf / if not, x is NaN
1N/A movl 16(%rsp),%eax / ax <-- sign&bexp((x))
1N/A andl $0x8000,%eax / here, x is infinite, but +/-?
1N/A jz .NaN_or_pinf / branch if x = +INF
1N/A1:
1N/A fld1 / Here, x = -inf, so return -1
1N/A fchs
1N/A ret
1N/A
1N/A.NaN_or_pinf:
1N/A / Here, x = NaN or +inf, so load x and return immediately.
1N/A fldt 8(%rsp)
1N/A ret
1N/A .align 16
1N/A SET_SIZE(expm1l)
1N/A