Print this page
5261 libm should stop using synonyms.h
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/i386/src/expl.s
+++ new/usr/src/lib/libm/i386/src/expl.s
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
23 23 */
24 24 /*
25 25 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
26 26 * Use is subject to license terms.
27 27 */
28 28
29 29 .file "expl.s"
30 30
31 31 #include "libm.h"
32 32 LIBM_ANSI_PRAGMA_WEAK(expl,function)
33 -#include "libm_synonyms.h"
34 33
35 34 .data
36 35 .align 4
37 36 ln2_hi: .long 0xd1d00000, 0xb17217f7, 0x00003ffe
38 37 ln2_lo: .long 0x4c67fc0d, 0x8654361c, 0x0000bfce
39 38
40 39 ENTRY(expl)
41 40 movl 12(%esp),%ecx / cx <--sign&bexp(x)
42 41 andl $0x7fff,%ecx / ecx <-- zero_xtnd(bexp(x))
43 42 cmpl $0x3ffe,%ecx / Is |x| < 0.5?
44 43 jb 2f / If so, see which shortcut to take
45 44 je .check_tail / More checking if 0.5 <= |x| < 1
46 45 cmpl $0x00007fff,%ecx / bexp(|x|) = bexp(INF)?
47 46 je .not_finite / if so, x is not finite
48 47 cmpl $0x0000400e,%ecx / |x| < 32768 = 2^15?
49 48 jb .finite_non_special / if so, proceed with argument reduction
50 49 fldt 4(%esp) / x
51 50 fld1 / 1, x
52 51 jmp 1f
53 52 .finite_non_special: / Here, ln(2) < |x| < 2^15
54 53 fldt 4(%esp) / x
55 54 fld %st(0) / x, x
56 55 fldl2e / log2(e), x, x
57 56 fmulp / z := x*log2(e), x
58 57 frndint / [z], x
59 58 fst %st(2) / [z], x, [z]
60 59 PIC_SETUP(1)
61 60 fldt PIC_L(ln2_hi) / ln2_hi, [z], x, [z]
62 61 fmulp / [z]*ln2_hi, x, [z]
63 62 fsubrp %st,%st(1) / x-[z]*ln2_hi, [z]
64 63 fldt PIC_L(ln2_lo) / ln2_lo, x-[z]*ln2_hi, [z]
65 64 PIC_WRAPUP
66 65 fmul %st(2),%st / [z]*ln2_lo, x-[z]*ln2_hi, [z]
67 66 fsubrp %st,%st(1) / r := x-[z]*ln(2), [z]
68 67 fldl2e / log2(e), r, [z]
69 68 fmulp / f := r*log2(e), [z]
70 69 f2xm1 / 2^f-1,[z]
71 70 fld1 / 1, 2^f-1, [z]
72 71 faddp %st,%st(1) / 2^f, [z]
73 72 1:
74 73 fscale / e^x, [z]
75 74 fstp %st(1)
76 75 ret
77 76
78 77 2: / Here, |x| < 0.5
79 78 cmpl $0x3fbe,%ecx / Is |x| >= 2^-65?
80 79 jae .shortcut / If so, take a shortcut
81 80 fldt 4(%esp) / x
82 81 fld1 / 1, x
83 82 faddp %st,%st(1) / 1+x (for inexact & directed rounding)
84 83 ret
85 84
86 85 .check_tail:
87 86 movl 8(%esp),%ecx / ecx <-- hi_32(sgnfcnd(x))
88 87 cmpl $0xb17217f7,%ecx / Is |x| < ln(2)?
89 88 ja .finite_non_special
90 89 jb .shortcut
91 90 movl 4(%esp),%edx / edx <-- lo_32(x)
92 91 cmpl $0xd1cf79ab,%edx / Is |x| slightly < ln(2)?
93 92 ja .finite_non_special / branch if |x| slightly > ln(2)
94 93 .shortcut:
95 94 / Here, |x| < ln(2), so |z| = |x/ln(2)| < 1,
96 95 / whence z is in f2xm1's domain.
97 96 fldt 4(%esp) / x
98 97 fldl2e / log2(e), x
99 98 fmulp / x*log2(e)
100 99 f2xm1 / 2^(x*log2(e))-1 = e^x-1
101 100 fld1 / 1, e^x-1
102 101 faddp %st,%st(1) / e^x
103 102 ret
104 103
105 104 .not_finite:
106 105 movl 8(%esp),%ecx / ecx <-- hi_32(sgnfcnd(x))
107 106 cmpl $0x80000000,%ecx / hi_32(|x|) = hi_32(INF)?
108 107 jne .NaN_or_pinf / if not, x is NaN
109 108 movl 4(%esp),%edx / edx <-- lo_32(x)
110 109 cmpl $0,%edx / lo_32(x) = 0?
111 110 jne .NaN_or_pinf / if not, x is NaN
112 111 movl 12(%esp),%eax / ax <-- sign&bexp((x))
113 112 andl $0x00008000,%eax / here, x is infinite, but +/-?
114 113 jz .NaN_or_pinf / branch if x = +INF
115 114 fldz / Here, x = -inf, so return 0
116 115 ret
117 116
118 117 .NaN_or_pinf:
119 118 / Here, x = NaN or +inf, so load x and return immediately.
120 119 fldt 4(%esp)
121 120 fadd %st(0),%st / quiet SNaN
122 121 ret
123 122 .align 4
124 123 SET_SIZE(expl)
↓ open down ↓ |
81 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX