1 /* Automatic switching between software and hardware IEEE 128-bit
2 floating-point emulation for PowerPC.
4 Copyright (C) 2016-2024 Free Software Foundation, Inc.
5 This file is part of the GNU C Library.
6 Contributed by Michael Meissner (meissner@linux.vnet.ibm.com)
7 Code is based on the main soft-fp library written by:
8 Richard Henderson (rth@cygnus.com) and
9 Jakub Jelinek (jj@ultra.linux.cz).
11 The GNU C Library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Lesser General Public
13 License as published by the Free Software Foundation; either
14 version 2.1 of the License, or (at your option) any later version.
16 In addition to the permissions in the GNU Lesser General Public
17 License, the Free Software Foundation gives you unlimited
18 permission to link the compiled version of this file into
19 combinations with other programs, and to distribute those
20 combinations without any restriction coming from the use of this
21 file. (The Lesser General Public License restrictions do apply in
22 other respects; for example, they cover modification of the file,
23 and distribution when not linked into a combine executable.)
25 The GNU C Library is distributed in the hope that it will be useful,
26 but WITHOUT ANY WARRANTY; without even the implied warranty of
27 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 Lesser General Public License for more details.
30 You should have received a copy of the GNU Lesser General Public
31 License along with the GNU C Library; if not, see
32 <http://www.gnu.org/licenses/>. */
35 #include <quad-float128.h>
37 #ifndef __FLOAT128_HARDWARE__
38 #error "This module must be compiled with IEEE 128-bit hardware support"
42 __addkf3_hw (TFtype a
, TFtype b
)
48 __subkf3_hw (TFtype a
, TFtype b
)
54 __mulkf3_hw (TFtype a
, TFtype b
)
60 __divkf3_hw (TFtype a
, TFtype b
)
66 __negkf2_hw (TFtype a
)
72 __floatsikf_hw (SItype_ppc a
)
78 __floatunsikf_hw (USItype_ppc a
)
84 __floatdikf_hw (DItype_ppc a
)
90 __floatundikf_hw (UDItype_ppc a
)
96 __fixkfsi_hw (TFtype a
)
98 return (SItype_ppc
) a
;
102 __fixunskfsi_hw (TFtype a
)
104 return (USItype_ppc
) a
;
108 __fixkfdi_hw (TFtype a
)
110 return (DItype_ppc
) a
;
114 __fixunskfdi_hw (TFtype a
)
116 return (UDItype_ppc
) a
;
120 __extendsfkf2_hw (float a
)
126 __extenddfkf2_hw (double a
)
132 __trunckfsf2_hw (TFtype a
)
138 __trunckfdf2_hw (TFtype a
)
143 /* __eqkf2 returns 0 if equal, or 1 if not equal or NaN. */
145 __eqkf2_hw (TFtype a
, TFtype b
)
150 /* __gekf2 returns -1 if a < b, 0 if a == b, +1 if a > b, or -2 if NaN. */
152 __gekf2_hw (TFtype a
, TFtype b
)
157 else if (__builtin_isunordered (a
, b
))
166 /* __lekf2 returns -1 if a < b, 0 if a == b, +1 if a > b, or +2 if NaN. */
168 __lekf2_hw (TFtype a
, TFtype b
)
173 else if (__builtin_isunordered (a
, b
))
182 /* __unordkf2 returns 1 if NaN or 0 otherwise. */
184 __unordkf2_hw (TFtype a
, TFtype b
)
186 return (__builtin_isunordered (a
, b
)) ? 1 : 0;
189 /* Convert __float128 to __ibm128. */
191 __extendkftf2_hw (TFtype value
)
195 CVT_FLOAT128_TO_IBM128 (ret
, value
);
199 /* Convert __ibm128 to __float128. */
201 __trunctfkf2_hw (IBM128_TYPE value
)
205 CVT_IBM128_TO_FLOAT128 (ret
, value
);