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