Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/i386/src/locallibm.il
+++ new/usr/src/lib/libm/i386/src/locallibm.il
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, this CDDL HEADER in each
14 14 / file and 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 / Copyright 2011 Nexenta Systems, Inc. All rights reserved.
22 22 /
23 23 / Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 24 / Use is subject to license terms.
25 25 /
26 26
27 27 / Portions of this file are duplicated as GCC inline assembly in
28 28 / libm_inlines.h. Keep them in sync.
29 29
30 30 .inline __ieee754_sqrt,0
31 31 fldl (%esp)
32 32 fsqrt
33 33 .end
34 34
35 35 .inline __inline_rint,0
36 36 fldl (%esp)
37 37 movl 4(%esp),%eax
38 38 andl $0x7fffffff,%eax
39 39 cmpl $0x43300000,%eax
40 40 jae 1f
41 41 frndint
42 42 1:
43 43 fwait / in case we jumped around the frndint
44 44 .end
45 45
46 46 .inline __inline_sqrtf,0
47 47 flds (%esp)
48 48 fsqrt
49 49 .end
50 50
51 51 .inline __inline_sqrt,0
52 52 fldl (%esp)
53 53 fsqrt
54 54 .end
55 55
56 56 .inline __inline_fstsw,0
57 57 fstsw %ax
58 58 .end
59 59
60 60 /
61 61 / 00 - 24 bits
62 62 / 01 - reserved
63 63 / 10 - 53 bits
64 64 / 11 - 64 bits
65 65 /
66 66 .inline __swapRP,0
67 67 subl $4,%esp
68 68 fstcw (%esp)
69 69 movw (%esp),%ax
70 70 movw %ax,%cx
71 71 andw $0xfcff,%cx
72 72 movl 4(%esp),%edx ///
73 73 andl $0x3,%edx
74 74 shlw $8,%dx
75 75 orw %dx,%cx
76 76 movl %ecx,(%esp)
77 77 fldcw (%esp)
78 78 shrw $8,%ax
79 79 andl $0x3,%eax
80 80 addl $4,%esp
81 81 .end
82 82
83 83 /
84 84 / 00 - Round to nearest, with even preferred
85 85 / 01 - Round down
86 86 / 10 - Round up
87 87 / 11 - Chop
88 88 /
89 89 .inline __swap87RD,0
90 90 subl $4,%esp
91 91 fstcw (%esp)
92 92 movw (%esp),%ax
93 93 movw %ax,%cx
94 94 andw $0xf3ff,%cx
95 95 movl 4(%esp),%edx
96 96 andl $0x3,%edx
97 97 shlw $10,%dx
98 98 orw %dx,%cx
99 99 movl %ecx,(%esp)
100 100 fldcw (%esp)
101 101 shrw $10,%ax
102 102 andl $0x3,%eax
103 103 addl $4,%esp
104 104 .end
105 105
106 106 /
107 107 / Convert Top-of-Stack to long
108 108 /
109 109 .inline __xtol,0
110 110 subl $8,%esp / 8 bytes of stack space
111 111 fstcw 2(%esp) / byte[2:3] = old_cw
112 112 movw 2(%esp),%ax
113 113 andw $0xf3ff,%ax
114 114 orw $0x0c00,%ax / RD set to Chop
115 115 movw %ax,(%esp) / byte[0:1] = new_cw
116 116 fldcw (%esp) / set new_cw
117 117 fistpl 4(%esp) / byte[4:7] = converted long
118 118 fstcw (%esp) / restore old RD
119 119 movw (%esp),%ax
120 120 andw $0xf3ff,%ax
121 121 movw 2(%esp),%dx
122 122 andw $0x0c00,%dx
123 123 orw %ax,%dx
124 124 movw %dx,2(%esp)
125 125 fldcw 2(%esp)
126 126 movl 4(%esp),%eax
127 127 addl $8,%esp
128 128 .end
129 129
130 130 .inline __ceil,0
131 131 subl $8,%esp
132 132 fstcw (%esp)
133 133 fldl 8(%esp) ///
134 134 movw (%esp),%cx
135 135 orw $0x0c00,%cx
136 136 xorw $0x0400,%cx
137 137 movw %cx,4(%esp)
138 138 fldcw 4(%esp) / set RD = up
139 139 frndint
140 140 fstcw 4(%esp) / restore RD
141 141 movw 4(%esp),%dx
142 142 andw $0xf3ff,%dx
143 143 movw (%esp),%cx
144 144 andw $0x0c00,%cx
145 145 orw %dx,%cx
146 146 movw %cx,(%esp)
147 147 fldcw (%esp)
148 148 addl $8,%esp
149 149 .end
150 150
151 151 .inline __copysign,0
152 152 movl 4(%esp),%eax /// eax <-- hi_32(x)
153 153 movl 12(%esp),%ecx /// ecx <-- hi_32(y)
154 154 andl $0x7fffffff,%eax / eax <-- hi_32(abs(x))
155 155 andl $0x80000000,%ecx / ecx[31] <-- sign_bit(y)
156 156 orl %ecx,%eax / eax <-- hi_32(__copysign(x,y))
157 157 movl (%esp),%ecx /// ecx <-- lo_32(x)
158 158 / = lo_32(__copysign(x,y))
159 159 subl $8,%esp / set up loading dock for result
160 160 movl %ecx,(%esp) / copy lo_32(result) to loading dock
161 161 movl %eax,4(%esp) / copy hi_32(result) to loading dock
162 162 fldl (%esp) / load __copysign(x,y)
163 163 fwait / in case fldl causes exception
164 164 addl $8,%esp / restore stack-pointer
165 165 .end
166 166
167 167 .inline __d_sqrt_,0
168 168 movl (%esp),%eax
169 169 fldl (%eax)
170 170 fsqrt
171 171 .end
172 172
173 173 .inline __fabs,0
174 174 fldl (%esp) ///
175 175 fabs
176 176 .end
177 177
178 178 .inline __fabsf,0
179 179 flds (%esp)
180 180 fabs
181 181 .end
182 182
183 183 .inline __fabsl,0
184 184 fldt (%esp)
185 185 fabs
186 186 .end
187 187
188 188 /
189 189 / branchless _finite
190 190 /
191 191 .inline _finite,0
192 192 movl 4(%esp),%eax /// eax <-- hi_32(x)
193 193 notl %eax / not(bexp) = 0 iff bexp = all 1's
194 194 andl $0x7ff00000,%eax
195 195 negl %eax
196 196 shrl $31,%eax
197 197 .end
198 198
199 199 .inline __floor,0
200 200 subl $8,%esp
201 201 fstcw (%esp)
202 202 fldl 8(%esp) ///
203 203 movw (%esp),%cx
204 204 orw $0x0c00,%cx
205 205 xorw $0x0800,%cx
206 206 movw %cx,4(%esp)
207 207 fldcw 4(%esp) / set RD = down
208 208 frndint
209 209 fstcw 4(%esp) / restore RD
↓ open down ↓ |
209 lines elided |
↑ open up ↑ |
210 210 movw 4(%esp),%dx
211 211 andw $0xf3ff,%dx
212 212 movw (%esp),%cx
213 213 andw $0x0c00,%cx
214 214 orw %dx,%cx
215 215 movw %cx,(%esp)
216 216 fldcw (%esp) / restore RD
217 217 addl $8,%esp
218 218 .end
219 219
220 -/
221 -/ branchless __isnan
222 -/ ((0x7ff00000-[((lx|-lx)>>31)&1]|ahx)>>31)&1 = 1 iff x is NaN
223 -/
224 - .inline __isnan,0
225 - movl (%esp),%eax /// eax <-- lo_32(x)
226 - movl %eax,%ecx
227 - negl %ecx / ecx <-- -lo_32(x)
228 - orl %ecx,%eax
229 - shrl $31,%eax / 1 iff lx != 0
230 - movl 4(%esp),%ecx /// ecx <-- hi_32(x)
231 - andl $0x7fffffff,%ecx / ecx <-- hi_32(abs(x))
232 - orl %ecx,%eax
233 - subl $0x7ff00000,%eax
234 - negl %eax
235 - shrl $31,%eax
236 - .end
237 -
238 220 .inline __isnanf,0
239 221 movl (%esp),%eax
240 222 andl $0x7fffffff,%eax
241 223 negl %eax
242 224 addl $0x7f800000,%eax
243 225 shrl $31,%eax
244 226 .end
245 227
246 - .inline __isinf,0
247 - movl 4(%esp),%eax / eax <-- hi_32(x)
248 - andl $0x7fffffff,%eax / set first bit to 0
249 - cmpl $0x7ff00000,%eax
250 - pushfl
251 - popl %eax
252 - cmpl $0,(%esp) / is lo_32(x) = 0?
253 - pushfl
254 - popl %ecx / bit 6 of ecx <-- lo_32(x) == 0
255 - andl %ecx,%eax
256 - andl $0x40,%eax
257 - shrl $6,%eax
258 - .end
259 228
260 229 .inline __isnormal,0
261 230 / TRUE iff (x is _finite, but
262 231 / neither subnormal nor +/-0)
263 232 / iff (0 < bexp(x) < 0x7ff)
264 233 movl 4(%esp),%eax / eax <-- hi_32(x)
265 234 andl $0x7ff00000,%eax / eax[20..30] <-- bexp(x),
266 235 / rest_of(eax) <-- 0
267 236 pushfl
268 237 popl %ecx / bit 6 of ecx <-- not bexp(x)
269 238 subl $0x7ff00000,%eax
270 239 pushfl
271 240 popl %eax / bit 6 of eax <-- not bexp(x)
272 241 orl %ecx,%eax
273 242 andl $0x40,%eax
274 243 xorl $0x40,%eax
275 244 shrl $6,%eax
276 245 .end
277 246
278 247 .inline __issubnormal,0
279 248 / TRUE iff (bexp(x) = 0 and
280 249 / frac(x) /= 0)
281 250 movl $0,%eax
282 251 movl 4(%esp),%ecx / ecx <-- hi_32(x)
283 252 andl $0x7fffffff,%ecx / ecx <-- hi_32(abs(x))
284 253 cmpl $0x00100000,%ecx / is bexp(x) = 0?
285 254 adcl $0,%eax / jump if bexp(x) = 0
286 255 orl (%esp),%ecx / = 0 iff sgnfcnd(x) = 0
287 256 / iff x = +/- 0.0 here
288 257 pushfl
289 258 popl %ecx
290 259 andl $0x40,%ecx
291 260 xorl $0x40,%ecx
292 261 shrl $6,%ecx
293 262 andl %ecx,%eax
294 263 .end
295 264
296 265 .inline __iszero,0
297 266 movl 4(%esp),%eax / eax <-- hi_32(x)
298 267 andl $0x7fffffff,%eax / eax <-- hi_32(abs(x))
299 268 orl (%esp),%eax / = 0 iff x = +/- 0.0
300 269 pushfl
301 270 popl %eax
302 271 andl $0x40,%eax
303 272 shrl $6,%eax
304 273 .end
305 274
306 275 .inline __r_sqrt_,0
307 276 movl (%esp),%eax
308 277 flds (%eax)
309 278 fsqrt
310 279 .end
311 280
312 281 .inline __rint,0
313 282 fldl (%esp)
314 283 movl 4(%esp),%eax
315 284 andl $0x7fffffff,%eax
316 285 cmpl $0x43300000,%eax
317 286 jae 1f
318 287 frndint
319 288 1:
320 289 fwait / in case we jumped around frndint
321 290 .end
322 291
323 292 .inline __scalbn,0
324 293 fildl 8(%esp) /// convert N to extended
325 294 fldl (%esp) /// push x
326 295 fscale
327 296 fstp %st(1)
328 297 .end
329 298
330 299 .inline __signbit,0
331 300 movl 4(%esp),%eax /// high part of x
332 301 shrl $31,%eax
333 302 .end
334 303
335 304 .inline __signbitf,0
336 305 movl (%esp),%eax
337 306 shrl $31,%eax
338 307 .end
339 308
340 309 .inline __sqrt,0
341 310 fldl (%esp)
342 311 fsqrt
343 312 .end
344 313
345 314 .inline __sqrtf,0
346 315 flds (%esp)
347 316 fsqrt
348 317 .end
349 318
350 319 .inline __sqrtl,0
351 320 fldt (%esp)
352 321 fsqrt
353 322 .end
354 323
355 324 .inline __isnanl,0
356 325 movl 8(%esp),%eax / ax <-- sign bit and __exp
357 326 andl $0x00007fff,%eax
358 327 jz 1f / jump if __exp is all 0
359 328 xorl $0x00007fff,%eax
360 329 jz 2f / jump if __exp is all 1
361 330 testl $0x80000000,4(%esp)
362 331 jz 3f / jump if leading bit is 0
363 332 movl $0,%eax
364 333 jmp 1f
365 334 2: / note that %eax = 0 from before
366 335 cmpl $0x80000000,4(%esp) / what is first half of __significand?
367 336 jnz 3f / jump if not equal to 0x80000000
368 337 testl $0xffffffff,(%esp) / is second half of __significand 0?
369 338 jnz 3f / jump if not equal to 0
370 339 jmp 1f
371 340 3:
372 341 movl $1,%eax
373 342 1:
374 343 .end
375 344
376 345 .inline __f95_signf,0
377 346 sub $4,%esp
378 347 mov 4(%esp),%edx
379 348 mov (%edx),%eax
380 349 and $0x7fffffff,%eax
381 350 mov 8(%esp),%edx
382 351 mov (%edx),%ecx
383 352 and $0x80000000,%ecx
384 353 or %ecx,%eax
385 354 mov %eax,(%esp)
386 355 flds (%esp)
387 356 add $4,%esp
388 357 .end
389 358
390 359 .inline __f95_sign,0
391 360 mov (%esp),%edx
392 361 fldl (%edx)
393 362 fabs
394 363 mov 4(%esp),%edx
395 364 mov 4(%edx),%eax
396 365 test %eax,%eax
397 366 jns 1f
398 367 fchs
399 368 1:
400 369 .end
401 370
↓ open down ↓ |
133 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX