gimplify: Handle void expression as asm input [PR100501, PR100792]
[gcc.git] / libgcc / config / rs6000 / float128-hw.c
blobe4042c8b2ddb47389268923daf30b9c019e7d9a0
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/>. */
34 #include <soft-fp.h>
35 #include <quad-float128.h>
37 #ifndef __FLOAT128_HARDWARE__
38 #error "This module must be compiled with IEEE 128-bit hardware support"
39 #endif
41 TFtype
42 __addkf3_hw (TFtype a, TFtype b)
44 return a + b;
47 TFtype
48 __subkf3_hw (TFtype a, TFtype b)
50 return a - b;
53 TFtype
54 __mulkf3_hw (TFtype a, TFtype b)
56 return a * b;
59 TFtype
60 __divkf3_hw (TFtype a, TFtype b)
62 return a / b;
65 TFtype
66 __negkf2_hw (TFtype a)
68 return -a;
71 TFtype
72 __floatsikf_hw (SItype_ppc a)
74 return (TFtype) a;
77 TFtype
78 __floatunsikf_hw (USItype_ppc a)
80 return (TFtype) a;
83 TFtype
84 __floatdikf_hw (DItype_ppc a)
86 return (TFtype) a;
89 TFtype
90 __floatundikf_hw (UDItype_ppc a)
92 return (TFtype) a;
95 SItype_ppc
96 __fixkfsi_hw (TFtype a)
98 return (SItype_ppc) a;
101 USItype_ppc
102 __fixunskfsi_hw (TFtype a)
104 return (USItype_ppc) a;
107 DItype_ppc
108 __fixkfdi_hw (TFtype a)
110 return (DItype_ppc) a;
113 UDItype_ppc
114 __fixunskfdi_hw (TFtype a)
116 return (UDItype_ppc) a;
119 TFtype
120 __extendsfkf2_hw (float a)
122 return (TFtype) a;
125 TFtype
126 __extenddfkf2_hw (double a)
128 return (TFtype) a;
131 float
132 __trunckfsf2_hw (TFtype a)
134 return (float) a;
137 double
138 __trunckfdf2_hw (TFtype a)
140 return (double) a;
143 /* __eqkf2 returns 0 if equal, or 1 if not equal or NaN. */
144 CMPtype
145 __eqkf2_hw (TFtype a, TFtype b)
147 return (a != b);
150 /* __gekf2 returns -1 if a < b, 0 if a == b, +1 if a > b, or -2 if NaN. */
151 CMPtype
152 __gekf2_hw (TFtype a, TFtype b)
154 if (a < b)
155 return -1;
157 else if (__builtin_isunordered (a, b))
158 return -2;
160 else if (a == b)
161 return 0;
163 return 1;
166 /* __lekf2 returns -1 if a < b, 0 if a == b, +1 if a > b, or +2 if NaN. */
167 CMPtype
168 __lekf2_hw (TFtype a, TFtype b)
170 if (a < b)
171 return -1;
173 else if (__builtin_isunordered (a, b))
174 return 2;
176 else if (a == b)
177 return 0;
179 return 1;
182 /* __unordkf2 returns 1 if NaN or 0 otherwise. */
183 CMPtype
184 __unordkf2_hw (TFtype a, TFtype b)
186 return (__builtin_isunordered (a, b)) ? 1 : 0;
189 /* Convert __float128 to __ibm128. */
190 IBM128_TYPE
191 __extendkftf2_hw (TFtype value)
193 IBM128_TYPE ret;
195 CVT_FLOAT128_TO_IBM128 (ret, value);
196 return ret;
199 /* Convert __ibm128 to __float128. */
200 TFtype
201 __trunctfkf2_hw (IBM128_TYPE value)
203 TFtype ret;
205 CVT_IBM128_TO_FLOAT128 (ret, value);
206 return ret;