]>
Commit | Line | Data |
---|---|---|
26dee9c4 | 1 | /* ix87 specific frexp implementation for long double. |
dff8da6b | 2 | Copyright (C) 1997-2024 Free Software Foundation, Inc. |
26dee9c4 | 3 | This file is part of the GNU C Library. |
26dee9c4 UD |
4 | |
5 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
26dee9c4 UD |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
26dee9c4 | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 16 | License along with the GNU C Library; if not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
26dee9c4 | 18 | |
2ce30701 | 19 | #include <libm-alias-ldouble.h> |
26dee9c4 UD |
20 | #include <machine/asm.h> |
21 | ||
26dee9c4 | 22 | .section .rodata |
26dee9c4 UD |
23 | |
24 | .align ALIGNARG(4) | |
b67e9372 | 25 | .type two64,@object |
26dee9c4 UD |
26 | two64: .byte 0, 0, 0, 0, 0, 0, 0xf0, 0x43 |
27 | ASM_SIZE_DIRECTIVE(two64) | |
28 | ||
29 | #ifdef PIC | |
30 | #define MO(op) op##@GOTOFF(%edx) | |
31 | #else | |
32 | #define MO(op) op | |
33 | #endif | |
34 | ||
2366713d | 35 | #define PARMS 4 /* no space for saved regs */ |
9e25f6e2 GM |
36 | #define VAL0 PARMS |
37 | #define VAL1 VAL0+4 | |
38 | #define VAL2 VAL1+4 | |
39 | #define EXPP VAL2+4 | |
40 | ||
26dee9c4 | 41 | .text |
2366713d | 42 | ENTRY (__frexpl) |
9e25f6e2 GM |
43 | |
44 | movl VAL0(%esp), %ecx | |
45 | movl VAL2(%esp), %eax | |
46 | orl VAL1(%esp), %ecx | |
26dee9c4 UD |
47 | movl %eax, %edx |
48 | andl $0x7fff, %eax | |
49 | orl %eax, %ecx | |
50 | jz 1f | |
51 | xorl %ecx, %ecx | |
52 | cmpl $0x7fff, %eax | |
88283451 | 53 | je 3f |
26dee9c4 UD |
54 | |
55 | cmpl $0, %eax | |
601d2942 | 56 | jne 2f |
79569444 | 57 | |
9e25f6e2 | 58 | fldt VAL0(%esp) |
26dee9c4 | 59 | #ifdef PIC |
fee732e5 | 60 | LOAD_PIC_REG (dx) |
26dee9c4 | 61 | #endif |
79569444 | 62 | |
26dee9c4 UD |
63 | fmull MO(two64) /* It's not necessary to use a 80bit factor */ |
64 | movl $-64, %ecx | |
9e25f6e2 | 65 | fstpt VAL0(%esp) |
00f5fcbb | 66 | fwait |
9e25f6e2 | 67 | movl VAL2(%esp), %eax |
26dee9c4 UD |
68 | movl %eax, %edx |
69 | andl $0x7fff, %eax | |
70 | ||
71 | 2: andl $0x8000, %edx | |
72 | subl $16382, %eax | |
73 | orl $0x3ffe, %edx | |
74 | addl %eax, %ecx | |
9e25f6e2 | 75 | movl %edx, VAL2(%esp) |
26dee9c4 UD |
76 | |
77 | /* Store %ecx in the variable pointed to by the second argument, | |
78 | get the factor from the stack and return. */ | |
9e25f6e2 | 79 | 1: movl EXPP(%esp), %eax |
9e25f6e2 | 80 | fldt VAL0(%esp) |
26dee9c4 | 81 | movl %ecx, (%eax) |
9e25f6e2 | 82 | |
26dee9c4 | 83 | ret |
88283451 JM |
84 | |
85 | /* Infinity or NaN; ensure signaling NaNs are quieted. */ | |
86 | 3: movl EXPP(%esp), %eax | |
87 | fldt VAL0(%esp) | |
88 | fadd %st | |
89 | movl %ecx, (%eax) | |
90 | ret | |
2366713d | 91 | END (__frexpl) |
2ce30701 | 92 | libm_alias_ldouble (__frexp, frexp) |