]> gcc.gnu.org Git - gcc.git/blob - libgcc/soft-fp/quad.h
Use _Float128 and _Complex _Float128 for PowerPC libgcc IEEE 128-bit
[gcc.git] / libgcc / soft-fp / quad.h
1 /* Software floating-point emulation.
2 Definitions for IEEE Quad Precision.
3 Copyright (C) 1997-2022 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 In addition to the permissions in the GNU Lesser General Public
12 License, the Free Software Foundation gives you unlimited
13 permission to link the compiled version of this file into
14 combinations with other programs, and to distribute those
15 combinations without any restriction coming from the use of this
16 file. (The Lesser General Public License restrictions do apply in
17 other respects; for example, they cover modification of the file,
18 and distribution when not linked into a combine executable.)
19
20 The GNU C Library is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 Lesser General Public License for more details.
24
25 You should have received a copy of the GNU Lesser General Public
26 License along with the GNU C Library; if not, see
27 <https://www.gnu.org/licenses/>. */
28
29 #ifndef SOFT_FP_QUAD_H
30 #define SOFT_FP_QUAD_H 1
31
32 #if _FP_W_TYPE_SIZE < 32
33 # error "Here's a nickel, kid. Go buy yourself a real computer."
34 #endif
35
36 #if _FP_W_TYPE_SIZE < 64
37 # define _FP_FRACTBITS_Q (4*_FP_W_TYPE_SIZE)
38 # define _FP_FRACTBITS_DW_Q (8*_FP_W_TYPE_SIZE)
39 #else
40 # define _FP_FRACTBITS_Q (2*_FP_W_TYPE_SIZE)
41 # define _FP_FRACTBITS_DW_Q (4*_FP_W_TYPE_SIZE)
42 #endif
43
44 #define _FP_FRACBITS_Q 113
45 #define _FP_FRACXBITS_Q (_FP_FRACTBITS_Q - _FP_FRACBITS_Q)
46 #define _FP_WFRACBITS_Q (_FP_WORKBITS + _FP_FRACBITS_Q)
47 #define _FP_WFRACXBITS_Q (_FP_FRACTBITS_Q - _FP_WFRACBITS_Q)
48 #define _FP_EXPBITS_Q 15
49 #define _FP_EXPBIAS_Q 16383
50 #define _FP_EXPMAX_Q 32767
51
52 #define _FP_QNANBIT_Q \
53 ((_FP_W_TYPE) 1 << (_FP_FRACBITS_Q-2) % _FP_W_TYPE_SIZE)
54 #define _FP_QNANBIT_SH_Q \
55 ((_FP_W_TYPE) 1 << (_FP_FRACBITS_Q-2+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
56 #define _FP_IMPLBIT_Q \
57 ((_FP_W_TYPE) 1 << (_FP_FRACBITS_Q-1) % _FP_W_TYPE_SIZE)
58 #define _FP_IMPLBIT_SH_Q \
59 ((_FP_W_TYPE) 1 << (_FP_FRACBITS_Q-1+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
60 #define _FP_OVERFLOW_Q \
61 ((_FP_W_TYPE) 1 << (_FP_WFRACBITS_Q % _FP_W_TYPE_SIZE))
62
63 #define _FP_WFRACBITS_DW_Q (2 * _FP_WFRACBITS_Q)
64 #define _FP_WFRACXBITS_DW_Q (_FP_FRACTBITS_DW_Q - _FP_WFRACBITS_DW_Q)
65 #define _FP_HIGHBIT_DW_Q \
66 ((_FP_W_TYPE) 1 << (_FP_WFRACBITS_DW_Q - 1) % _FP_W_TYPE_SIZE)
67
68 #ifndef TFtype
69 typedef float TFtype __attribute__ ((mode (TF)));
70 #endif
71
72 #if _FP_W_TYPE_SIZE < 64
73
74 union _FP_UNION_Q
75 {
76 TFtype flt;
77 struct _FP_STRUCT_LAYOUT
78 {
79 # if __BYTE_ORDER == __BIG_ENDIAN
80 unsigned sign : 1;
81 unsigned exp : _FP_EXPBITS_Q;
82 unsigned long frac3 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0)-(_FP_W_TYPE_SIZE * 3);
83 unsigned long frac2 : _FP_W_TYPE_SIZE;
84 unsigned long frac1 : _FP_W_TYPE_SIZE;
85 unsigned long frac0 : _FP_W_TYPE_SIZE;
86 # else
87 unsigned long frac0 : _FP_W_TYPE_SIZE;
88 unsigned long frac1 : _FP_W_TYPE_SIZE;
89 unsigned long frac2 : _FP_W_TYPE_SIZE;
90 unsigned long frac3 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0)-(_FP_W_TYPE_SIZE * 3);
91 unsigned exp : _FP_EXPBITS_Q;
92 unsigned sign : 1;
93 # endif /* not bigendian */
94 } bits;
95 };
96
97
98 # define FP_DECL_Q(X) _FP_DECL (4, X)
99 # define FP_UNPACK_RAW_Q(X, val) _FP_UNPACK_RAW_4 (Q, X, (val))
100 # define FP_UNPACK_RAW_QP(X, val) _FP_UNPACK_RAW_4_P (Q, X, (val))
101 # define FP_PACK_RAW_Q(val, X) _FP_PACK_RAW_4 (Q, (val), X)
102 # define FP_PACK_RAW_QP(val, X) \
103 do \
104 { \
105 if (!FP_INHIBIT_RESULTS) \
106 _FP_PACK_RAW_4_P (Q, (val), X); \
107 } \
108 while (0)
109
110 # define FP_UNPACK_Q(X, val) \
111 do \
112 { \
113 _FP_UNPACK_RAW_4 (Q, X, (val)); \
114 _FP_UNPACK_CANONICAL (Q, 4, X); \
115 } \
116 while (0)
117
118 # define FP_UNPACK_QP(X, val) \
119 do \
120 { \
121 _FP_UNPACK_RAW_4_P (Q, X, (val)); \
122 _FP_UNPACK_CANONICAL (Q, 4, X); \
123 } \
124 while (0)
125
126 # define FP_UNPACK_SEMIRAW_Q(X, val) \
127 do \
128 { \
129 _FP_UNPACK_RAW_4 (Q, X, (val)); \
130 _FP_UNPACK_SEMIRAW (Q, 4, X); \
131 } \
132 while (0)
133
134 # define FP_UNPACK_SEMIRAW_QP(X, val) \
135 do \
136 { \
137 _FP_UNPACK_RAW_4_P (Q, X, (val)); \
138 _FP_UNPACK_SEMIRAW (Q, 4, X); \
139 } \
140 while (0)
141
142 # define FP_PACK_Q(val, X) \
143 do \
144 { \
145 _FP_PACK_CANONICAL (Q, 4, X); \
146 _FP_PACK_RAW_4 (Q, (val), X); \
147 } \
148 while (0)
149
150 # define FP_PACK_QP(val, X) \
151 do \
152 { \
153 _FP_PACK_CANONICAL (Q, 4, X); \
154 if (!FP_INHIBIT_RESULTS) \
155 _FP_PACK_RAW_4_P (Q, (val), X); \
156 } \
157 while (0)
158
159 # define FP_PACK_SEMIRAW_Q(val, X) \
160 do \
161 { \
162 _FP_PACK_SEMIRAW (Q, 4, X); \
163 _FP_PACK_RAW_4 (Q, (val), X); \
164 } \
165 while (0)
166
167 # define FP_PACK_SEMIRAW_QP(val, X) \
168 do \
169 { \
170 _FP_PACK_SEMIRAW (Q, 4, X); \
171 if (!FP_INHIBIT_RESULTS) \
172 _FP_PACK_RAW_4_P (Q, (val), X); \
173 } \
174 while (0)
175
176 # define FP_ISSIGNAN_Q(X) _FP_ISSIGNAN (Q, 4, X)
177 # define FP_NEG_Q(R, X) _FP_NEG (Q, 4, R, X)
178 # define FP_ADD_Q(R, X, Y) _FP_ADD (Q, 4, R, X, Y)
179 # define FP_SUB_Q(R, X, Y) _FP_SUB (Q, 4, R, X, Y)
180 # define FP_MUL_Q(R, X, Y) _FP_MUL (Q, 4, R, X, Y)
181 # define FP_DIV_Q(R, X, Y) _FP_DIV (Q, 4, R, X, Y)
182 # define FP_SQRT_Q(R, X) _FP_SQRT (Q, 4, R, X)
183 # define _FP_SQRT_MEAT_Q(R, S, T, X, Q) _FP_SQRT_MEAT_4 (R, S, T, X, (Q))
184 # define FP_FMA_Q(R, X, Y, Z) _FP_FMA (Q, 4, 8, R, X, Y, Z)
185
186 # define FP_CMP_Q(r, X, Y, un, ex) _FP_CMP (Q, 4, (r), X, Y, (un), (ex))
187 # define FP_CMP_EQ_Q(r, X, Y, ex) _FP_CMP_EQ (Q, 4, (r), X, Y, (ex))
188 # define FP_CMP_UNORD_Q(r, X, Y, ex) _FP_CMP_UNORD (Q, 4, (r), X, Y, (ex))
189
190 # define FP_TO_INT_Q(r, X, rsz, rsg) _FP_TO_INT (Q, 4, (r), X, (rsz), (rsg))
191 # define FP_TO_INT_ROUND_Q(r, X, rsz, rsg) \
192 _FP_TO_INT_ROUND (Q, 4, (r), X, (rsz), (rsg))
193 # define FP_FROM_INT_Q(X, r, rs, rt) _FP_FROM_INT (Q, 4, X, (r), (rs), rt)
194
195 # define _FP_FRAC_HIGH_Q(X) _FP_FRAC_HIGH_4 (X)
196 # define _FP_FRAC_HIGH_RAW_Q(X) _FP_FRAC_HIGH_4 (X)
197
198 # define _FP_FRAC_HIGH_DW_Q(X) _FP_FRAC_HIGH_8 (X)
199
200 #else /* not _FP_W_TYPE_SIZE < 64 */
201 union _FP_UNION_Q
202 {
203 TFtype flt /* __attribute__ ((mode (TF))) */ ;
204 struct _FP_STRUCT_LAYOUT
205 {
206 _FP_W_TYPE a, b;
207 } longs;
208 struct _FP_STRUCT_LAYOUT
209 {
210 # if __BYTE_ORDER == __BIG_ENDIAN
211 unsigned sign : 1;
212 unsigned exp : _FP_EXPBITS_Q;
213 _FP_W_TYPE frac1 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0) - _FP_W_TYPE_SIZE;
214 _FP_W_TYPE frac0 : _FP_W_TYPE_SIZE;
215 # else
216 _FP_W_TYPE frac0 : _FP_W_TYPE_SIZE;
217 _FP_W_TYPE frac1 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0) - _FP_W_TYPE_SIZE;
218 unsigned exp : _FP_EXPBITS_Q;
219 unsigned sign : 1;
220 # endif
221 } bits;
222 };
223
224 # define FP_DECL_Q(X) _FP_DECL (2, X)
225 # define FP_UNPACK_RAW_Q(X, val) _FP_UNPACK_RAW_2 (Q, X, (val))
226 # define FP_UNPACK_RAW_QP(X, val) _FP_UNPACK_RAW_2_P (Q, X, (val))
227 # define FP_PACK_RAW_Q(val, X) _FP_PACK_RAW_2 (Q, (val), X)
228 # define FP_PACK_RAW_QP(val, X) \
229 do \
230 { \
231 if (!FP_INHIBIT_RESULTS) \
232 _FP_PACK_RAW_2_P (Q, (val), X); \
233 } \
234 while (0)
235
236 # define FP_UNPACK_Q(X, val) \
237 do \
238 { \
239 _FP_UNPACK_RAW_2 (Q, X, (val)); \
240 _FP_UNPACK_CANONICAL (Q, 2, X); \
241 } \
242 while (0)
243
244 # define FP_UNPACK_QP(X, val) \
245 do \
246 { \
247 _FP_UNPACK_RAW_2_P (Q, X, (val)); \
248 _FP_UNPACK_CANONICAL (Q, 2, X); \
249 } \
250 while (0)
251
252 # define FP_UNPACK_SEMIRAW_Q(X, val) \
253 do \
254 { \
255 _FP_UNPACK_RAW_2 (Q, X, (val)); \
256 _FP_UNPACK_SEMIRAW (Q, 2, X); \
257 } \
258 while (0)
259
260 # define FP_UNPACK_SEMIRAW_QP(X, val) \
261 do \
262 { \
263 _FP_UNPACK_RAW_2_P (Q, X, (val)); \
264 _FP_UNPACK_SEMIRAW (Q, 2, X); \
265 } \
266 while (0)
267
268 # define FP_PACK_Q(val, X) \
269 do \
270 { \
271 _FP_PACK_CANONICAL (Q, 2, X); \
272 _FP_PACK_RAW_2 (Q, (val), X); \
273 } \
274 while (0)
275
276 # define FP_PACK_QP(val, X) \
277 do \
278 { \
279 _FP_PACK_CANONICAL (Q, 2, X); \
280 if (!FP_INHIBIT_RESULTS) \
281 _FP_PACK_RAW_2_P (Q, (val), X); \
282 } \
283 while (0)
284
285 # define FP_PACK_SEMIRAW_Q(val, X) \
286 do \
287 { \
288 _FP_PACK_SEMIRAW (Q, 2, X); \
289 _FP_PACK_RAW_2 (Q, (val), X); \
290 } \
291 while (0)
292
293 # define FP_PACK_SEMIRAW_QP(val, X) \
294 do \
295 { \
296 _FP_PACK_SEMIRAW (Q, 2, X); \
297 if (!FP_INHIBIT_RESULTS) \
298 _FP_PACK_RAW_2_P (Q, (val), X); \
299 } \
300 while (0)
301
302 # define FP_ISSIGNAN_Q(X) _FP_ISSIGNAN (Q, 2, X)
303 # define FP_NEG_Q(R, X) _FP_NEG (Q, 2, R, X)
304 # define FP_ADD_Q(R, X, Y) _FP_ADD (Q, 2, R, X, Y)
305 # define FP_SUB_Q(R, X, Y) _FP_SUB (Q, 2, R, X, Y)
306 # define FP_MUL_Q(R, X, Y) _FP_MUL (Q, 2, R, X, Y)
307 # define FP_DIV_Q(R, X, Y) _FP_DIV (Q, 2, R, X, Y)
308 # define FP_SQRT_Q(R, X) _FP_SQRT (Q, 2, R, X)
309 # define _FP_SQRT_MEAT_Q(R, S, T, X, Q) _FP_SQRT_MEAT_2 (R, S, T, X, (Q))
310 # define FP_FMA_Q(R, X, Y, Z) _FP_FMA (Q, 2, 4, R, X, Y, Z)
311
312 # define FP_CMP_Q(r, X, Y, un, ex) _FP_CMP (Q, 2, (r), X, Y, (un), (ex))
313 # define FP_CMP_EQ_Q(r, X, Y, ex) _FP_CMP_EQ (Q, 2, (r), X, Y, (ex))
314 # define FP_CMP_UNORD_Q(r, X, Y, ex) _FP_CMP_UNORD (Q, 2, (r), X, Y, (ex))
315
316 # define FP_TO_INT_Q(r, X, rsz, rsg) _FP_TO_INT (Q, 2, (r), X, (rsz), (rsg))
317 # define FP_TO_INT_ROUND_Q(r, X, rsz, rsg) \
318 _FP_TO_INT_ROUND (Q, 2, (r), X, (rsz), (rsg))
319 # define FP_FROM_INT_Q(X, r, rs, rt) _FP_FROM_INT (Q, 2, X, (r), (rs), rt)
320
321 # define _FP_FRAC_HIGH_Q(X) _FP_FRAC_HIGH_2 (X)
322 # define _FP_FRAC_HIGH_RAW_Q(X) _FP_FRAC_HIGH_2 (X)
323
324 # define _FP_FRAC_HIGH_DW_Q(X) _FP_FRAC_HIGH_4 (X)
325
326 #endif /* not _FP_W_TYPE_SIZE < 64 */
327
328 #endif /* !SOFT_FP_QUAD_H */
This page took 0.056697 seconds and 6 git commands to generate.