]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/i386/fpu/i386-math-asm.h
1 /* Helper macros for x86 libm functions.
2 Copyright (C) 2015-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
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.
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
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef _I386_MATH_ASM_H
20 #define _I386_MATH_ASM_H 1
22 /* Remove excess range and precision by storing a value on the stack
23 and loading it back. */
24 #define FLT_NARROW_EVAL \
26 cfi_adjust_cfa_offset (4); \
30 cfi_adjust_cfa_offset (-4);
31 #define DBL_NARROW_EVAL \
33 cfi_adjust_cfa_offset (8); \
37 cfi_adjust_cfa_offset (-8);
39 /* Define constants for the minimum value of a floating-point
41 #define DEFINE_FLT_MIN \
42 .section .rodata.cst4,"aM",@progbits,4; \
44 .type flt_min,@object; \
46 .byte 0, 0, 0x80, 0; \
47 .size flt_min, .-flt_min;
48 #define DEFINE_DBL_MIN \
49 .section .rodata.cst8,"aM",@progbits,8; \
51 .type dbl_min,@object; \
53 .byte 0, 0, 0, 0, 0, 0, 0x10, 0; \
54 .size dbl_min, .-dbl_min;
55 #define DEFINE_LDBL_MIN \
56 .section .rodata.cst16,"aM",@progbits,16; \
58 .type ldbl_min,@object; \
60 .byte 0, 0, 0, 0, 0, 0, 0, 0x80, 0x1, 0; \
61 .byte 0, 0, 0, 0, 0, 0; \
62 .size ldbl_min, .-ldbl_min;
64 /* Remove excess range and precision by storing a value on the stack
65 and loading it back. The value is given to be nonnegative or NaN;
66 if it is subnormal, also force an underflow exception. The
67 relevant constant for the minimum of the type must have been
68 defined, the MO macro must have been defined for access to memory
69 operands, and, if PIC, the PIC register must have been loaded. */
70 #define FLT_NARROW_EVAL_UFLOW_NONNEG_NAN \
72 cfi_adjust_cfa_offset (4); \
85 cfi_adjust_cfa_offset (-4);
86 #define DBL_NARROW_EVAL_UFLOW_NONNEG_NAN \
88 cfi_adjust_cfa_offset (8); \
101 cfi_adjust_cfa_offset (-8);
103 /* Likewise, but the argument is not a NaN (so fcom instructions,
104 which support memory operands, can be used). */
105 #define FLT_NARROW_EVAL_UFLOW_NONNEG \
107 cfi_adjust_cfa_offset (4); \
115 6424: fstps (%esp); \
118 cfi_adjust_cfa_offset (-4);
119 #define DBL_NARROW_EVAL_UFLOW_NONNEG \
121 cfi_adjust_cfa_offset (8); \
129 6453: fstpl (%esp); \
132 cfi_adjust_cfa_offset (-8);
134 /* Likewise, but the non-NaN argument may be negative. */
135 #define FLT_NARROW_EVAL_UFLOW_NONNAN \
137 cfi_adjust_cfa_offset (4); \
140 fcomps MO(flt_min); \
147 6424: fstps (%esp); \
150 cfi_adjust_cfa_offset (-4);
151 #define DBL_NARROW_EVAL_UFLOW_NONNAN \
153 cfi_adjust_cfa_offset (8); \
156 fcompl MO(dbl_min); \
163 6453: fstpl (%esp); \
166 cfi_adjust_cfa_offset (-8);
168 /* Force an underflow exception if the given value is subnormal. The
169 relevant constant for the minimum of the type must have been
170 defined, the MO macro must have been defined for access to memory
171 operands, and, if PIC, the PIC register must have been loaded. */
172 #define FLT_CHECK_FORCE_UFLOW \
181 cfi_adjust_cfa_offset (4); \
186 cfi_adjust_cfa_offset (-4); \
188 #define DBL_CHECK_FORCE_UFLOW \
197 cfi_adjust_cfa_offset (8); \
202 cfi_adjust_cfa_offset (-8); \
205 /* Likewise, but also remove excess range and precision if the value
207 #define FLT_CHECK_FORCE_UFLOW_NARROW \
216 cfi_adjust_cfa_offset (4); \
223 cfi_adjust_cfa_offset (-4); \
225 #define DBL_CHECK_FORCE_UFLOW_NARROW \
234 cfi_adjust_cfa_offset (8); \
241 cfi_adjust_cfa_offset (-8); \
244 /* Likewise, but the argument is nonnegative or NaN. */
245 #define LDBL_CHECK_FORCE_UFLOW_NONNEG_NAN \
257 /* Likewise, but the argument is not a NaN. */
258 #define FLT_CHECK_FORCE_UFLOW_NONNAN \
261 fcomps MO(flt_min); \
266 cfi_adjust_cfa_offset (4); \
271 cfi_adjust_cfa_offset (-4); \
273 #define DBL_CHECK_FORCE_UFLOW_NONNAN \
276 fcompl MO(dbl_min); \
281 cfi_adjust_cfa_offset (8); \
286 cfi_adjust_cfa_offset (-8); \
288 #define LDBL_CHECK_FORCE_UFLOW_NONNAN \
301 /* Likewise, but the argument is nonnegative and not a NaN. */
302 #define FLT_CHECK_FORCE_UFLOW_NONNEG \
308 cfi_adjust_cfa_offset (4); \
313 cfi_adjust_cfa_offset (-4); \
315 #define DBL_CHECK_FORCE_UFLOW_NONNEG \
321 cfi_adjust_cfa_offset (8); \
326 cfi_adjust_cfa_offset (-8); \
328 #define LDBL_CHECK_FORCE_UFLOW_NONNEG \
340 #endif /* i386-math-asm.h. */