1 /* Helper macros for x86_64 libm functions.
2    Copyright (C) 2015-2022 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4 
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.
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
13    Lesser General Public License for more details.
14 
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    <https://www.gnu.org/licenses/>.  */
18 
19 #ifndef _X86_64_MATH_ASM_H
20 #define _X86_64_MATH_ASM_H 1
21 
22 /* Define constants for the minimum value of a floating-point
23    type.  */
24 #define DEFINE_LDBL_MIN					\
25 	.section .rodata.cst16,"aM",@progbits,16;	\
26 	.p2align 4;					\
27 	.type ldbl_min,@object;				\
28 ldbl_min:						\
29 	.byte 0, 0, 0, 0, 0, 0, 0, 0x80, 0x1, 0;	\
30 	.byte 0, 0, 0, 0, 0, 0;				\
31 	.size ldbl_min, .-ldbl_min;
32 
33 /* Force an underflow exception if the given value (nonnegative or
34    NaN) is subnormal.  The relevant constant for the minimum of the
35    type must have been defined, the MO macro must have been defined
36    for access to memory operands, and, if PIC, the PIC register must
37    have been loaded.  */
38 #define LDBL_CHECK_FORCE_UFLOW_NONNEG_NAN	\
39 	fldt	MO(ldbl_min);			\
40 	fld	%st(1);				\
41 	fucomip	%st(1), %st(0);			\
42 	fstp	%st(0);				\
43 	jnc 6464f;				\
44 	fld	%st(0);				\
45 	fmul	%st(0);				\
46 	fstp	%st(0);				\
47 6464:
48 
49 /* Likewise, but the argument is not a NaN.  */
50 #define LDBL_CHECK_FORCE_UFLOW_NONNAN		\
51 	fldt	MO(ldbl_min);			\
52 	fld	%st(1);				\
53 	fabs;					\
54 	fcomip	%st(1), %st(0);			\
55 	fstp	%st(0);				\
56 	jnc 6464f;				\
57 	fld	%st(0);				\
58 	fmul	%st(0);				\
59 	fstp	%st(0);				\
60 6464:
61 
62 /* Likewise, but the argument is nonnegative and not a NaN.  */
63 #define LDBL_CHECK_FORCE_UFLOW_NONNEG		\
64 	fldt	MO(ldbl_min);			\
65 	fld	%st(1);				\
66 	fcomip	%st(1), %st(0);			\
67 	fstp	%st(0);				\
68 	jnc 6464f;				\
69 	fld	%st(0);				\
70 	fmul	%st(0);				\
71 	fstp	%st(0);				\
72 6464:
73 
74 #endif /* x86_64-math-asm.h.  */
75