lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | /* Software floating-point emulation. |
| 2 | Definitions for IEEE Extended Precision. |
| 3 | Copyright (C) 1999-2015 Free Software Foundation, Inc. |
| 4 | This file is part of the GNU C Library. |
| 5 | Contributed by Jakub Jelinek (jj@ultra.linux.cz). |
| 6 | |
| 7 | The GNU C Library is free software; you can redistribute it and/or |
| 8 | modify it under the terms of the GNU Lesser General Public |
| 9 | License as published by the Free Software Foundation; either |
| 10 | version 2.1 of the License, or (at your option) any later version. |
| 11 | |
| 12 | In addition to the permissions in the GNU Lesser General Public |
| 13 | License, the Free Software Foundation gives you unlimited |
| 14 | permission to link the compiled version of this file into |
| 15 | combinations with other programs, and to distribute those |
| 16 | combinations without any restriction coming from the use of this |
| 17 | file. (The Lesser General Public License restrictions do apply in |
| 18 | other respects; for example, they cover modification of the file, |
| 19 | and distribution when not linked into a combine executable.) |
| 20 | |
| 21 | The GNU C Library is distributed in the hope that it will be useful, |
| 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 24 | Lesser General Public License for more details. |
| 25 | |
| 26 | You should have received a copy of the GNU Lesser General Public |
| 27 | License along with the GNU C Library; if not, see |
| 28 | <http://www.gnu.org/licenses/>. */ |
| 29 | |
| 30 | #ifndef SOFT_FP_EXTENDED_H |
| 31 | #define SOFT_FP_EXTENDED_H 1 |
| 32 | |
| 33 | #if _FP_W_TYPE_SIZE < 32 |
| 34 | # error "Here's a nickel, kid. Go buy yourself a real computer." |
| 35 | #endif |
| 36 | |
| 37 | #if _FP_W_TYPE_SIZE < 64 |
| 38 | # define _FP_FRACTBITS_E (4*_FP_W_TYPE_SIZE) |
| 39 | # define _FP_FRACTBITS_DW_E (8*_FP_W_TYPE_SIZE) |
| 40 | #else |
| 41 | # define _FP_FRACTBITS_E (2*_FP_W_TYPE_SIZE) |
| 42 | # define _FP_FRACTBITS_DW_E (4*_FP_W_TYPE_SIZE) |
| 43 | #endif |
| 44 | |
| 45 | #define _FP_FRACBITS_E 64 |
| 46 | #define _FP_FRACXBITS_E (_FP_FRACTBITS_E - _FP_FRACBITS_E) |
| 47 | #define _FP_WFRACBITS_E (_FP_WORKBITS + _FP_FRACBITS_E) |
| 48 | #define _FP_WFRACXBITS_E (_FP_FRACTBITS_E - _FP_WFRACBITS_E) |
| 49 | #define _FP_EXPBITS_E 15 |
| 50 | #define _FP_EXPBIAS_E 16383 |
| 51 | #define _FP_EXPMAX_E 32767 |
| 52 | |
| 53 | #define _FP_QNANBIT_E \ |
| 54 | ((_FP_W_TYPE) 1 << (_FP_FRACBITS_E-2) % _FP_W_TYPE_SIZE) |
| 55 | #define _FP_QNANBIT_SH_E \ |
| 56 | ((_FP_W_TYPE) 1 << (_FP_FRACBITS_E-2+_FP_WORKBITS) % _FP_W_TYPE_SIZE) |
| 57 | #define _FP_IMPLBIT_E \ |
| 58 | ((_FP_W_TYPE) 1 << (_FP_FRACBITS_E-1) % _FP_W_TYPE_SIZE) |
| 59 | #define _FP_IMPLBIT_SH_E \ |
| 60 | ((_FP_W_TYPE) 1 << (_FP_FRACBITS_E-1+_FP_WORKBITS) % _FP_W_TYPE_SIZE) |
| 61 | #define _FP_OVERFLOW_E \ |
| 62 | ((_FP_W_TYPE) 1 << (_FP_WFRACBITS_E % _FP_W_TYPE_SIZE)) |
| 63 | |
| 64 | #define _FP_WFRACBITS_DW_E (2 * _FP_WFRACBITS_E) |
| 65 | #define _FP_WFRACXBITS_DW_E (_FP_FRACTBITS_DW_E - _FP_WFRACBITS_DW_E) |
| 66 | #define _FP_HIGHBIT_DW_E \ |
| 67 | ((_FP_W_TYPE) 1 << (_FP_WFRACBITS_DW_E - 1) % _FP_W_TYPE_SIZE) |
| 68 | |
| 69 | typedef float XFtype __attribute__ ((mode (XF))); |
| 70 | |
| 71 | #if _FP_W_TYPE_SIZE < 64 |
| 72 | |
| 73 | union _FP_UNION_E |
| 74 | { |
| 75 | XFtype flt; |
| 76 | struct _FP_STRUCT_LAYOUT |
| 77 | { |
| 78 | # if __BYTE_ORDER == __BIG_ENDIAN |
| 79 | unsigned long pad1 : _FP_W_TYPE_SIZE; |
| 80 | unsigned long pad2 : (_FP_W_TYPE_SIZE - 1 - _FP_EXPBITS_E); |
| 81 | unsigned long sign : 1; |
| 82 | unsigned long exp : _FP_EXPBITS_E; |
| 83 | unsigned long frac1 : _FP_W_TYPE_SIZE; |
| 84 | unsigned long frac0 : _FP_W_TYPE_SIZE; |
| 85 | # else |
| 86 | unsigned long frac0 : _FP_W_TYPE_SIZE; |
| 87 | unsigned long frac1 : _FP_W_TYPE_SIZE; |
| 88 | unsigned exp : _FP_EXPBITS_E; |
| 89 | unsigned sign : 1; |
| 90 | # endif /* not bigendian */ |
| 91 | } bits __attribute__ ((packed)); |
| 92 | }; |
| 93 | |
| 94 | |
| 95 | # define FP_DECL_E(X) _FP_DECL (4, X) |
| 96 | |
| 97 | # define FP_UNPACK_RAW_E(X, val) \ |
| 98 | do \ |
| 99 | { \ |
| 100 | union _FP_UNION_E FP_UNPACK_RAW_E_flo; \ |
| 101 | FP_UNPACK_RAW_E_flo.flt = (val); \ |
| 102 | \ |
| 103 | X##_f[2] = 0; \ |
| 104 | X##_f[3] = 0; \ |
| 105 | X##_f[0] = FP_UNPACK_RAW_E_flo.bits.frac0; \ |
| 106 | X##_f[1] = FP_UNPACK_RAW_E_flo.bits.frac1; \ |
| 107 | X##_e = FP_UNPACK_RAW_E_flo.bits.exp; \ |
| 108 | X##_s = FP_UNPACK_RAW_E_flo.bits.sign; \ |
| 109 | } \ |
| 110 | while (0) |
| 111 | |
| 112 | # define FP_UNPACK_RAW_EP(X, val) \ |
| 113 | do \ |
| 114 | { \ |
| 115 | union _FP_UNION_E *FP_UNPACK_RAW_EP_flo \ |
| 116 | = (union _FP_UNION_E *) (val); \ |
| 117 | \ |
| 118 | X##_f[2] = 0; \ |
| 119 | X##_f[3] = 0; \ |
| 120 | X##_f[0] = FP_UNPACK_RAW_EP_flo->bits.frac0; \ |
| 121 | X##_f[1] = FP_UNPACK_RAW_EP_flo->bits.frac1; \ |
| 122 | X##_e = FP_UNPACK_RAW_EP_flo->bits.exp; \ |
| 123 | X##_s = FP_UNPACK_RAW_EP_flo->bits.sign; \ |
| 124 | } \ |
| 125 | while (0) |
| 126 | |
| 127 | # define FP_PACK_RAW_E(val, X) \ |
| 128 | do \ |
| 129 | { \ |
| 130 | union _FP_UNION_E FP_PACK_RAW_E_flo; \ |
| 131 | \ |
| 132 | if (X##_e) \ |
| 133 | X##_f[1] |= _FP_IMPLBIT_E; \ |
| 134 | else \ |
| 135 | X##_f[1] &= ~(_FP_IMPLBIT_E); \ |
| 136 | FP_PACK_RAW_E_flo.bits.frac0 = X##_f[0]; \ |
| 137 | FP_PACK_RAW_E_flo.bits.frac1 = X##_f[1]; \ |
| 138 | FP_PACK_RAW_E_flo.bits.exp = X##_e; \ |
| 139 | FP_PACK_RAW_E_flo.bits.sign = X##_s; \ |
| 140 | \ |
| 141 | (val) = FP_PACK_RAW_E_flo.flt; \ |
| 142 | } \ |
| 143 | while (0) |
| 144 | |
| 145 | # define FP_PACK_RAW_EP(val, X) \ |
| 146 | do \ |
| 147 | { \ |
| 148 | if (!FP_INHIBIT_RESULTS) \ |
| 149 | { \ |
| 150 | union _FP_UNION_E *FP_PACK_RAW_EP_flo \ |
| 151 | = (union _FP_UNION_E *) (val); \ |
| 152 | \ |
| 153 | if (X##_e) \ |
| 154 | X##_f[1] |= _FP_IMPLBIT_E; \ |
| 155 | else \ |
| 156 | X##_f[1] &= ~(_FP_IMPLBIT_E); \ |
| 157 | FP_PACK_RAW_EP_flo->bits.frac0 = X##_f[0]; \ |
| 158 | FP_PACK_RAW_EP_flo->bits.frac1 = X##_f[1]; \ |
| 159 | FP_PACK_RAW_EP_flo->bits.exp = X##_e; \ |
| 160 | FP_PACK_RAW_EP_flo->bits.sign = X##_s; \ |
| 161 | } \ |
| 162 | } \ |
| 163 | while (0) |
| 164 | |
| 165 | # define FP_UNPACK_E(X, val) \ |
| 166 | do \ |
| 167 | { \ |
| 168 | FP_UNPACK_RAW_E (X, (val)); \ |
| 169 | _FP_UNPACK_CANONICAL (E, 4, X); \ |
| 170 | } \ |
| 171 | while (0) |
| 172 | |
| 173 | # define FP_UNPACK_EP(X, val) \ |
| 174 | do \ |
| 175 | { \ |
| 176 | FP_UNPACK_RAW_EP (X, (val)); \ |
| 177 | _FP_UNPACK_CANONICAL (E, 4, X); \ |
| 178 | } \ |
| 179 | while (0) |
| 180 | |
| 181 | # define FP_UNPACK_SEMIRAW_E(X, val) \ |
| 182 | do \ |
| 183 | { \ |
| 184 | FP_UNPACK_RAW_E (X, (val)); \ |
| 185 | _FP_UNPACK_SEMIRAW (E, 4, X); \ |
| 186 | } \ |
| 187 | while (0) |
| 188 | |
| 189 | # define FP_UNPACK_SEMIRAW_EP(X, val) \ |
| 190 | do \ |
| 191 | { \ |
| 192 | FP_UNPACK_RAW_EP (X, (val)); \ |
| 193 | _FP_UNPACK_SEMIRAW (E, 4, X); \ |
| 194 | } \ |
| 195 | while (0) |
| 196 | |
| 197 | # define FP_PACK_E(val, X) \ |
| 198 | do \ |
| 199 | { \ |
| 200 | _FP_PACK_CANONICAL (E, 4, X); \ |
| 201 | FP_PACK_RAW_E ((val), X); \ |
| 202 | } \ |
| 203 | while (0) |
| 204 | |
| 205 | # define FP_PACK_EP(val, X) \ |
| 206 | do \ |
| 207 | { \ |
| 208 | _FP_PACK_CANONICAL (E, 4, X); \ |
| 209 | FP_PACK_RAW_EP ((val), X); \ |
| 210 | } \ |
| 211 | while (0) |
| 212 | |
| 213 | # define FP_PACK_SEMIRAW_E(val, X) \ |
| 214 | do \ |
| 215 | { \ |
| 216 | _FP_PACK_SEMIRAW (E, 4, X); \ |
| 217 | FP_PACK_RAW_E ((val), X); \ |
| 218 | } \ |
| 219 | while (0) |
| 220 | |
| 221 | # define FP_PACK_SEMIRAW_EP(val, X) \ |
| 222 | do \ |
| 223 | { \ |
| 224 | _FP_PACK_SEMIRAW (E, 4, X); \ |
| 225 | FP_PACK_RAW_EP ((val), X); \ |
| 226 | } \ |
| 227 | while (0) |
| 228 | |
| 229 | # define FP_ISSIGNAN_E(X) _FP_ISSIGNAN (E, 4, X) |
| 230 | # define FP_NEG_E(R, X) _FP_NEG (E, 4, R, X) |
| 231 | # define FP_ADD_E(R, X, Y) _FP_ADD (E, 4, R, X, Y) |
| 232 | # define FP_SUB_E(R, X, Y) _FP_SUB (E, 4, R, X, Y) |
| 233 | # define FP_MUL_E(R, X, Y) _FP_MUL (E, 4, R, X, Y) |
| 234 | # define FP_DIV_E(R, X, Y) _FP_DIV (E, 4, R, X, Y) |
| 235 | # define FP_SQRT_E(R, X) _FP_SQRT (E, 4, R, X) |
| 236 | # define FP_FMA_E(R, X, Y, Z) _FP_FMA (E, 4, 8, R, X, Y, Z) |
| 237 | |
| 238 | /* Square root algorithms: |
| 239 | We have just one right now, maybe Newton approximation |
| 240 | should be added for those machines where division is fast. |
| 241 | This has special _E version because standard _4 square |
| 242 | root would not work (it has to start normally with the |
| 243 | second word and not the first), but as we have to do it |
| 244 | anyway, we optimize it by doing most of the calculations |
| 245 | in two UWtype registers instead of four. */ |
| 246 | |
| 247 | # define _FP_SQRT_MEAT_E(R, S, T, X, q) \ |
| 248 | do \ |
| 249 | { \ |
| 250 | (q) = (_FP_W_TYPE) 1 << (_FP_W_TYPE_SIZE - 1); \ |
| 251 | _FP_FRAC_SRL_4 (X, (_FP_WORKBITS)); \ |
| 252 | while (q) \ |
| 253 | { \ |
| 254 | T##_f[1] = S##_f[1] + (q); \ |
| 255 | if (T##_f[1] <= X##_f[1]) \ |
| 256 | { \ |
| 257 | S##_f[1] = T##_f[1] + (q); \ |
| 258 | X##_f[1] -= T##_f[1]; \ |
| 259 | R##_f[1] += (q); \ |
| 260 | } \ |
| 261 | _FP_FRAC_SLL_2 (X, 1); \ |
| 262 | (q) >>= 1; \ |
| 263 | } \ |
| 264 | (q) = (_FP_W_TYPE) 1 << (_FP_W_TYPE_SIZE - 1); \ |
| 265 | while (q) \ |
| 266 | { \ |
| 267 | T##_f[0] = S##_f[0] + (q); \ |
| 268 | T##_f[1] = S##_f[1]; \ |
| 269 | if (T##_f[1] < X##_f[1] \ |
| 270 | || (T##_f[1] == X##_f[1] \ |
| 271 | && T##_f[0] <= X##_f[0])) \ |
| 272 | { \ |
| 273 | S##_f[0] = T##_f[0] + (q); \ |
| 274 | S##_f[1] += (T##_f[0] > S##_f[0]); \ |
| 275 | _FP_FRAC_DEC_2 (X, T); \ |
| 276 | R##_f[0] += (q); \ |
| 277 | } \ |
| 278 | _FP_FRAC_SLL_2 (X, 1); \ |
| 279 | (q) >>= 1; \ |
| 280 | } \ |
| 281 | _FP_FRAC_SLL_4 (R, (_FP_WORKBITS)); \ |
| 282 | if (X##_f[0] | X##_f[1]) \ |
| 283 | { \ |
| 284 | if (S##_f[1] < X##_f[1] \ |
| 285 | || (S##_f[1] == X##_f[1] \ |
| 286 | && S##_f[0] < X##_f[0])) \ |
| 287 | R##_f[0] |= _FP_WORK_ROUND; \ |
| 288 | R##_f[0] |= _FP_WORK_STICKY; \ |
| 289 | } \ |
| 290 | } \ |
| 291 | while (0) |
| 292 | |
| 293 | # define FP_CMP_E(r, X, Y, un, ex) _FP_CMP (E, 4, (r), X, Y, (un), (ex)) |
| 294 | # define FP_CMP_EQ_E(r, X, Y, ex) _FP_CMP_EQ (E, 4, (r), X, Y, (ex)) |
| 295 | # define FP_CMP_UNORD_E(r, X, Y, ex) _FP_CMP_UNORD (E, 4, (r), X, Y, (ex)) |
| 296 | |
| 297 | # define FP_TO_INT_E(r, X, rsz, rsg) _FP_TO_INT (E, 4, (r), X, (rsz), (rsg)) |
| 298 | # define FP_TO_INT_ROUND_E(r, X, rsz, rsg) \ |
| 299 | _FP_TO_INT_ROUND (E, 4, (r), X, (rsz), (rsg)) |
| 300 | # define FP_FROM_INT_E(X, r, rs, rt) _FP_FROM_INT (E, 4, X, (r), (rs), rt) |
| 301 | |
| 302 | # define _FP_FRAC_HIGH_E(X) (X##_f[2]) |
| 303 | # define _FP_FRAC_HIGH_RAW_E(X) (X##_f[1]) |
| 304 | |
| 305 | # define _FP_FRAC_HIGH_DW_E(X) (X##_f[4]) |
| 306 | |
| 307 | #else /* not _FP_W_TYPE_SIZE < 64 */ |
| 308 | union _FP_UNION_E |
| 309 | { |
| 310 | XFtype flt; |
| 311 | struct _FP_STRUCT_LAYOUT |
| 312 | { |
| 313 | # if __BYTE_ORDER == __BIG_ENDIAN |
| 314 | _FP_W_TYPE pad : (_FP_W_TYPE_SIZE - 1 - _FP_EXPBITS_E); |
| 315 | unsigned sign : 1; |
| 316 | unsigned exp : _FP_EXPBITS_E; |
| 317 | _FP_W_TYPE frac : _FP_W_TYPE_SIZE; |
| 318 | # else |
| 319 | _FP_W_TYPE frac : _FP_W_TYPE_SIZE; |
| 320 | unsigned exp : _FP_EXPBITS_E; |
| 321 | unsigned sign : 1; |
| 322 | # endif |
| 323 | } bits; |
| 324 | }; |
| 325 | |
| 326 | # define FP_DECL_E(X) _FP_DECL (2, X) |
| 327 | |
| 328 | # define FP_UNPACK_RAW_E(X, val) \ |
| 329 | do \ |
| 330 | { \ |
| 331 | union _FP_UNION_E FP_UNPACK_RAW_E_flo; \ |
| 332 | FP_UNPACK_RAW_E_flo.flt = (val); \ |
| 333 | \ |
| 334 | X##_f0 = FP_UNPACK_RAW_E_flo.bits.frac; \ |
| 335 | X##_f1 = 0; \ |
| 336 | X##_e = FP_UNPACK_RAW_E_flo.bits.exp; \ |
| 337 | X##_s = FP_UNPACK_RAW_E_flo.bits.sign; \ |
| 338 | } \ |
| 339 | while (0) |
| 340 | |
| 341 | # define FP_UNPACK_RAW_EP(X, val) \ |
| 342 | do \ |
| 343 | { \ |
| 344 | union _FP_UNION_E *FP_UNPACK_RAW_EP_flo \ |
| 345 | = (union _FP_UNION_E *) (val); \ |
| 346 | \ |
| 347 | X##_f0 = FP_UNPACK_RAW_EP_flo->bits.frac; \ |
| 348 | X##_f1 = 0; \ |
| 349 | X##_e = FP_UNPACK_RAW_EP_flo->bits.exp; \ |
| 350 | X##_s = FP_UNPACK_RAW_EP_flo->bits.sign; \ |
| 351 | } \ |
| 352 | while (0) |
| 353 | |
| 354 | # define FP_PACK_RAW_E(val, X) \ |
| 355 | do \ |
| 356 | { \ |
| 357 | union _FP_UNION_E FP_PACK_RAW_E_flo; \ |
| 358 | \ |
| 359 | if (X##_e) \ |
| 360 | X##_f0 |= _FP_IMPLBIT_E; \ |
| 361 | else \ |
| 362 | X##_f0 &= ~(_FP_IMPLBIT_E); \ |
| 363 | FP_PACK_RAW_E_flo.bits.frac = X##_f0; \ |
| 364 | FP_PACK_RAW_E_flo.bits.exp = X##_e; \ |
| 365 | FP_PACK_RAW_E_flo.bits.sign = X##_s; \ |
| 366 | \ |
| 367 | (val) = FP_PACK_RAW_E_flo.flt; \ |
| 368 | } \ |
| 369 | while (0) |
| 370 | |
| 371 | # define FP_PACK_RAW_EP(fs, val, X) \ |
| 372 | do \ |
| 373 | { \ |
| 374 | if (!FP_INHIBIT_RESULTS) \ |
| 375 | { \ |
| 376 | union _FP_UNION_E *FP_PACK_RAW_EP_flo \ |
| 377 | = (union _FP_UNION_E *) (val); \ |
| 378 | \ |
| 379 | if (X##_e) \ |
| 380 | X##_f0 |= _FP_IMPLBIT_E; \ |
| 381 | else \ |
| 382 | X##_f0 &= ~(_FP_IMPLBIT_E); \ |
| 383 | FP_PACK_RAW_EP_flo->bits.frac = X##_f0; \ |
| 384 | FP_PACK_RAW_EP_flo->bits.exp = X##_e; \ |
| 385 | FP_PACK_RAW_EP_flo->bits.sign = X##_s; \ |
| 386 | } \ |
| 387 | } \ |
| 388 | while (0) |
| 389 | |
| 390 | |
| 391 | # define FP_UNPACK_E(X, val) \ |
| 392 | do \ |
| 393 | { \ |
| 394 | FP_UNPACK_RAW_E (X, (val)); \ |
| 395 | _FP_UNPACK_CANONICAL (E, 2, X); \ |
| 396 | } \ |
| 397 | while (0) |
| 398 | |
| 399 | # define FP_UNPACK_EP(X, val) \ |
| 400 | do \ |
| 401 | { \ |
| 402 | FP_UNPACK_RAW_EP (X, (val)); \ |
| 403 | _FP_UNPACK_CANONICAL (E, 2, X); \ |
| 404 | } \ |
| 405 | while (0) |
| 406 | |
| 407 | # define FP_UNPACK_SEMIRAW_E(X, val) \ |
| 408 | do \ |
| 409 | { \ |
| 410 | FP_UNPACK_RAW_E (X, (val)); \ |
| 411 | _FP_UNPACK_SEMIRAW (E, 2, X); \ |
| 412 | } \ |
| 413 | while (0) |
| 414 | |
| 415 | # define FP_UNPACK_SEMIRAW_EP(X, val) \ |
| 416 | do \ |
| 417 | { \ |
| 418 | FP_UNPACK_RAW_EP (X, (val)); \ |
| 419 | _FP_UNPACK_SEMIRAW (E, 2, X); \ |
| 420 | } \ |
| 421 | while (0) |
| 422 | |
| 423 | # define FP_PACK_E(val, X) \ |
| 424 | do \ |
| 425 | { \ |
| 426 | _FP_PACK_CANONICAL (E, 2, X); \ |
| 427 | FP_PACK_RAW_E ((val), X); \ |
| 428 | } \ |
| 429 | while (0) |
| 430 | |
| 431 | # define FP_PACK_EP(val, X) \ |
| 432 | do \ |
| 433 | { \ |
| 434 | _FP_PACK_CANONICAL (E, 2, X); \ |
| 435 | FP_PACK_RAW_EP ((val), X); \ |
| 436 | } \ |
| 437 | while (0) |
| 438 | |
| 439 | # define FP_PACK_SEMIRAW_E(val, X) \ |
| 440 | do \ |
| 441 | { \ |
| 442 | _FP_PACK_SEMIRAW (E, 2, X); \ |
| 443 | FP_PACK_RAW_E ((val), X); \ |
| 444 | } \ |
| 445 | while (0) |
| 446 | |
| 447 | # define FP_PACK_SEMIRAW_EP(val, X) \ |
| 448 | do \ |
| 449 | { \ |
| 450 | _FP_PACK_SEMIRAW (E, 2, X); \ |
| 451 | FP_PACK_RAW_EP ((val), X); \ |
| 452 | } \ |
| 453 | while (0) |
| 454 | |
| 455 | # define FP_ISSIGNAN_E(X) _FP_ISSIGNAN (E, 2, X) |
| 456 | # define FP_NEG_E(R, X) _FP_NEG (E, 2, R, X) |
| 457 | # define FP_ADD_E(R, X, Y) _FP_ADD (E, 2, R, X, Y) |
| 458 | # define FP_SUB_E(R, X, Y) _FP_SUB (E, 2, R, X, Y) |
| 459 | # define FP_MUL_E(R, X, Y) _FP_MUL (E, 2, R, X, Y) |
| 460 | # define FP_DIV_E(R, X, Y) _FP_DIV (E, 2, R, X, Y) |
| 461 | # define FP_SQRT_E(R, X) _FP_SQRT (E, 2, R, X) |
| 462 | # define FP_FMA_E(R, X, Y, Z) _FP_FMA (E, 2, 4, R, X, Y, Z) |
| 463 | |
| 464 | /* Square root algorithms: |
| 465 | We have just one right now, maybe Newton approximation |
| 466 | should be added for those machines where division is fast. |
| 467 | We optimize it by doing most of the calculations |
| 468 | in one UWtype registers instead of two, although we don't |
| 469 | have to. */ |
| 470 | # define _FP_SQRT_MEAT_E(R, S, T, X, q) \ |
| 471 | do \ |
| 472 | { \ |
| 473 | (q) = (_FP_W_TYPE) 1 << (_FP_W_TYPE_SIZE - 1); \ |
| 474 | _FP_FRAC_SRL_2 (X, (_FP_WORKBITS)); \ |
| 475 | while (q) \ |
| 476 | { \ |
| 477 | T##_f0 = S##_f0 + (q); \ |
| 478 | if (T##_f0 <= X##_f0) \ |
| 479 | { \ |
| 480 | S##_f0 = T##_f0 + (q); \ |
| 481 | X##_f0 -= T##_f0; \ |
| 482 | R##_f0 += (q); \ |
| 483 | } \ |
| 484 | _FP_FRAC_SLL_1 (X, 1); \ |
| 485 | (q) >>= 1; \ |
| 486 | } \ |
| 487 | _FP_FRAC_SLL_2 (R, (_FP_WORKBITS)); \ |
| 488 | if (X##_f0) \ |
| 489 | { \ |
| 490 | if (S##_f0 < X##_f0) \ |
| 491 | R##_f0 |= _FP_WORK_ROUND; \ |
| 492 | R##_f0 |= _FP_WORK_STICKY; \ |
| 493 | } \ |
| 494 | } \ |
| 495 | while (0) |
| 496 | |
| 497 | # define FP_CMP_E(r, X, Y, un, ex) _FP_CMP (E, 2, (r), X, Y, (un), (ex)) |
| 498 | # define FP_CMP_EQ_E(r, X, Y, ex) _FP_CMP_EQ (E, 2, (r), X, Y, (ex)) |
| 499 | # define FP_CMP_UNORD_E(r, X, Y, ex) _FP_CMP_UNORD (E, 2, (r), X, Y, (ex)) |
| 500 | |
| 501 | # define FP_TO_INT_E(r, X, rsz, rsg) _FP_TO_INT (E, 2, (r), X, (rsz), (rsg)) |
| 502 | # define FP_TO_INT_ROUND_E(r, X, rsz, rsg) \ |
| 503 | _FP_TO_INT_ROUND (E, 2, (r), X, (rsz), (rsg)) |
| 504 | # define FP_FROM_INT_E(X, r, rs, rt) _FP_FROM_INT (E, 2, X, (r), (rs), rt) |
| 505 | |
| 506 | # define _FP_FRAC_HIGH_E(X) (X##_f1) |
| 507 | # define _FP_FRAC_HIGH_RAW_E(X) (X##_f0) |
| 508 | |
| 509 | # define _FP_FRAC_HIGH_DW_E(X) (X##_f[2]) |
| 510 | |
| 511 | #endif /* not _FP_W_TYPE_SIZE < 64 */ |
| 512 | |
| 513 | #endif /* !SOFT_FP_EXTENDED_H */ |