1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 3 /*============================================================================ 4 5 This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic 6 Package, Release 3a, by John R. Hauser. 7 8 Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. 9 All rights reserved. 10 11 Redistribution and use in source and binary forms, with or without 12 modification, are permitted provided that the following conditions are met: 13 14 1. Redistributions of source code must retain the above copyright notice, 15 this list of conditions, and the following disclaimer. 16 17 2. Redistributions in binary form must reproduce the above copyright notice, 18 this list of conditions, and the following disclaimer in the documentation 19 and/or other materials provided with the distribution. 20 21 3. Neither the name of the University nor the names of its contributors may 22 be used to endorse or promote products derived from this software without 23 specific prior written permission. 24 25 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY 26 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 27 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE 28 DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 29 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 30 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 32 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 36 =============================================================================*/ 37 38 #ifndef primitives_h 39 #define primitives_h 1 40 41 #include <stdbool.h> 42 #include <stdint.h> 43 #include "primitiveTypes.h" 44 45 #ifndef softfloat_shortShiftRightJam64 46 /*---------------------------------------------------------------------------- 47 | Shifts `a' right by the number of bits given in `count', which must be in 48 | the range 1 to 63. If any nonzero bits are shifted off, they are "jammed" 49 | into the least-significant bit of the shifted value by setting the least- 50 | significant bit to 1. This shifted-and-jammed value is returned. 51 *----------------------------------------------------------------------------*/ 52 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL) 53 INLINE 54 uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t count ) 55 { return a>>count | ((a & (((uint_fast64_t) 1<<count) - 1)) != 0); } 56 #else 57 uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t count ); 58 #endif 59 #endif 60 61 #ifndef softfloat_shiftRightJam32 62 /*---------------------------------------------------------------------------- 63 | Shifts `a' right by the number of bits given in `count', which must not 64 | be zero. If any nonzero bits are shifted off, they are "jammed" into the 65 | least-significant bit of the shifted value by setting the least-significant 66 | bit to 1. This shifted-and-jammed value is returned. 67 | The value of `count' can be arbitrarily large. In particular, if `count' 68 | is greater than 32, the result will be either 0 or 1, depending on whether 69 | `a' is zero or nonzero. 70 *----------------------------------------------------------------------------*/ 71 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL) 72 INLINE uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t count ) 73 { 74 return 75 (count < 31) ? a>>count | ((uint32_t) (a<<(-count & 31)) != 0) 76 : (a != 0); 77 } 78 #else 79 uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t count ); 80 #endif 81 #endif 82 83 #ifndef softfloat_shiftRightJam64 84 /*---------------------------------------------------------------------------- 85 | Shifts `a' right by the number of bits given in `count', which must not 86 | be zero. If any nonzero bits are shifted off, they are "jammed" into the 87 | least-significant bit of the shifted value by setting the least-significant 88 | bit to 1. This shifted-and-jammed value is returned. 89 | The value of `count' can be arbitrarily large. In particular, if `count' 90 | is greater than 64, the result will be either 0 or 1, depending on whether 91 | `a' is zero or nonzero. 92 *----------------------------------------------------------------------------*/ 93 #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL) 94 INLINE uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t count ) 95 { 96 return 97 (count < 63) ? a>>count | ((uint64_t) (a<<(-count & 63)) != 0) 98 : (a != 0); 99 } 100 #else 101 uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t count ); 102 #endif 103 #endif 104 105 /*---------------------------------------------------------------------------- 106 | A constant table that translates an 8-bit unsigned integer (the array index) 107 | into the number of leading 0 bits before the most-significant 1 of that 108 | integer. For integer zero (index 0), the corresponding table element is 8. 109 *----------------------------------------------------------------------------*/ 110 extern const uint_least8_t softfloat_countLeadingZeros8[256]; 111 112 #ifndef softfloat_countLeadingZeros32 113 /*---------------------------------------------------------------------------- 114 | Returns the number of leading 0 bits before the most-significant 1 bit of 115 | `a'. If `a' is zero, 32 is returned. 116 *----------------------------------------------------------------------------*/ 117 #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL) 118 INLINE uint_fast8_t softfloat_countLeadingZeros32( uint32_t a ) 119 { 120 uint_fast8_t count = 0; 121 if ( a < 0x10000 ) { 122 count = 16; 123 a <<= 16; 124 } 125 if ( a < 0x1000000 ) { 126 count += 8; 127 a <<= 8; 128 } 129 count += softfloat_countLeadingZeros8[a>>24]; 130 return count; 131 } 132 #else 133 uint_fast8_t softfloat_countLeadingZeros32( uint32_t a ); 134 #endif 135 #endif 136 137 #ifndef softfloat_countLeadingZeros64 138 /*---------------------------------------------------------------------------- 139 | Returns the number of leading 0 bits before the most-significant 1 bit of 140 | `a'. If `a' is zero, 64 is returned. 141 *----------------------------------------------------------------------------*/ 142 uint_fast8_t softfloat_countLeadingZeros64( uint64_t a ); 143 #endif 144 145 #ifndef softfloat_approxRecip32_1 146 /*---------------------------------------------------------------------------- 147 | Returns an approximation to the reciprocal of the number represented by `a', 148 | where `a' is interpreted as an unsigned fixed-point number with one integer 149 | bit and 31 fraction bits. The `a' input must be "normalized", meaning that 150 | its most-significant bit (bit 31) must be 1. Thus, if A is the value of 151 | the fixed-point interpretation of `a', then 1 <= A < 2. The returned value 152 | is interpreted as a pure unsigned fraction, having no integer bits and 32 153 | fraction bits. The approximation returned is never greater than the true 154 | reciprocal 1/A, and it differs from the true reciprocal by at most 2.006 ulp 155 | (units in the last place). 156 *----------------------------------------------------------------------------*/ 157 #ifdef SOFTFLOAT_FAST_DIV64TO32 158 #define softfloat_approxRecip32_1( a ) ((uint32_t) (UINT64_C( 0x7FFFFFFFFFFFFFFF ) / (uint32_t) (a))) 159 #else 160 uint32_t softfloat_approxRecip32_1( uint32_t a ); 161 #endif 162 #endif 163 164 #ifndef softfloat_approxRecipSqrt32_1 165 /*---------------------------------------------------------------------------- 166 | Returns an approximation to the reciprocal of the square root of the number 167 | represented by `a', where `a' is interpreted as an unsigned fixed-point 168 | number either with one integer bit and 31 fraction bits or with two integer 169 | bits and 30 fraction bits. The format of `a' is determined by `oddExpA', 170 | which must be either 0 or 1. If `oddExpA' is 1, `a' is interpreted as 171 | having one integer bit, and if `oddExpA' is 0, `a' is interpreted as having 172 | two integer bits. The `a' input must be "normalized", meaning that its 173 | most-significant bit (bit 31) must be 1. Thus, if A is the value of the 174 | fixed-point interpretation of `a', it follows that 1 <= A < 2 when `oddExpA' 175 | is 1, and 2 <= A < 4 when `oddExpA' is 0. 176 | The returned value is interpreted as a pure unsigned fraction, having 177 | no integer bits and 32 fraction bits. The approximation returned is never 178 | greater than the true reciprocal 1/sqrt(A), and it differs from the true 179 | reciprocal by at most 2.06 ulp (units in the last place). The approximation 180 | returned is also always within the range 0.5 to 1; thus, the most- 181 | significant bit of the result is always set. 182 *----------------------------------------------------------------------------*/ 183 uint32_t softfloat_approxRecipSqrt32_1( unsigned int oddExpA, uint32_t a ); 184 #endif 185 186 #ifdef SOFTFLOAT_FAST_INT64 187 188 /*---------------------------------------------------------------------------- 189 | The following functions are needed only when `SOFTFLOAT_FAST_INT64' is 190 | defined. 191 *----------------------------------------------------------------------------*/ 192 193 #ifndef softfloat_eq128 194 /*---------------------------------------------------------------------------- 195 | Returns true if the 128-bit unsigned integer formed by concatenating `a64' 196 | and `a0' is equal to the 128-bit unsigned integer formed by concatenating 197 | `b64' and `b0'. 198 *----------------------------------------------------------------------------*/ 199 #if defined INLINE_LEVEL && (1 <= INLINE_LEVEL) 200 INLINE 201 bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 ) 202 { return (a64 == b64) && (a0 == b0); } 203 #else 204 bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 ); 205 #endif 206 #endif 207 208 #ifndef softfloat_le128 209 /*---------------------------------------------------------------------------- 210 | Returns true if the 128-bit unsigned integer formed by concatenating `a64' 211 | and `a0' is less than or equal to the 128-bit unsigned integer formed by 212 | concatenating `b64' and `b0'. 213 *----------------------------------------------------------------------------*/ 214 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL) 215 INLINE 216 bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 ) 217 { return (a64 < b64) || ((a64 == b64) && (a0 <= b0)); } 218 #else 219 bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 ); 220 #endif 221 #endif 222 223 #ifndef softfloat_lt128 224 /*---------------------------------------------------------------------------- 225 | Returns true if the 128-bit unsigned integer formed by concatenating `a64' 226 | and `a0' is less than the 128-bit unsigned integer formed by concatenating 227 | `b64' and `b0'. 228 *----------------------------------------------------------------------------*/ 229 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL) 230 INLINE 231 bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 ) 232 { return (a64 < b64) || ((a64 == b64) && (a0 < b0)); } 233 #else 234 bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 ); 235 #endif 236 #endif 237 238 #ifndef softfloat_shortShiftLeft128 239 /*---------------------------------------------------------------------------- 240 | Shifts the 128 bits formed by concatenating `a64' and `a0' left by the 241 | number of bits given in `count', which must be in the range 1 to 63. 242 *----------------------------------------------------------------------------*/ 243 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL) 244 INLINE 245 struct uint128 246 softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t count ) 247 { 248 struct uint128 z; 249 z.v64 = a64<<count | a0>>(-count & 63); 250 z.v0 = a0<<count; 251 return z; 252 } 253 #else 254 struct uint128 255 softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t count ); 256 #endif 257 #endif 258 259 #ifndef softfloat_shortShiftRight128 260 /*---------------------------------------------------------------------------- 261 | Shifts the 128 bits formed by concatenating `a64' and `a0' right by the 262 | number of bits given in `count', which must be in the range 1 to 63. 263 *----------------------------------------------------------------------------*/ 264 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL) 265 INLINE 266 struct uint128 267 softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t count ) 268 { 269 struct uint128 z; 270 z.v64 = a64>>count; 271 z.v0 = a64<<(-count & 63) | a0>>count; 272 return z; 273 } 274 #else 275 struct uint128 276 softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t count ); 277 #endif 278 #endif 279 280 #ifndef softfloat_shortShiftRightJam64Extra 281 /*---------------------------------------------------------------------------- 282 | This function is the same as `softfloat_shiftRightJam64Extra' (below), 283 | except that `count' must be in the range 1 to 63. 284 *----------------------------------------------------------------------------*/ 285 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL) 286 INLINE 287 struct uint64_extra 288 softfloat_shortShiftRightJam64Extra( 289 uint64_t a, uint64_t extra, uint_fast8_t count ) 290 { 291 struct uint64_extra z; 292 z.v = a>>count; 293 z.extra = a<<(-count & 63) | (extra != 0); 294 return z; 295 } 296 #else 297 struct uint64_extra 298 softfloat_shortShiftRightJam64Extra( 299 uint64_t a, uint64_t extra, uint_fast8_t count ); 300 #endif 301 #endif 302 303 #ifndef softfloat_shortShiftRightJam128 304 /*---------------------------------------------------------------------------- 305 | Shifts the 128 bits formed by concatenating `a64' and `a0' right by the 306 | number of bits given in `count', which must be in the range 1 to 63. If any 307 | nonzero bits are shifted off, they are "jammed" into the least-significant 308 | bit of the shifted value by setting the least-significant bit to 1. This 309 | shifted-and-jammed value is returned. 310 *----------------------------------------------------------------------------*/ 311 #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL) 312 INLINE 313 struct uint128 314 softfloat_shortShiftRightJam128( 315 uint64_t a64, uint64_t a0, uint_fast8_t count ) 316 { 317 uint_fast8_t negCount = -count; 318 struct uint128 z; 319 z.v64 = a64>>count; 320 z.v0 = 321 a64<<(negCount & 63) | a0>>count 322 | ((uint64_t) (a0<<(negCount & 63)) != 0); 323 return z; 324 } 325 #else 326 struct uint128 327 softfloat_shortShiftRightJam128( 328 uint64_t a64, uint64_t a0, uint_fast8_t count ); 329 #endif 330 #endif 331 332 #ifndef softfloat_shortShiftRightJam128Extra 333 /*---------------------------------------------------------------------------- 334 | This function is the same as `softfloat_shiftRightJam128Extra' (below), 335 | except that `count' must be in the range 1 to 63. 336 *----------------------------------------------------------------------------*/ 337 #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL) 338 INLINE 339 struct uint128_extra 340 softfloat_shortShiftRightJam128Extra( 341 uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t count ) 342 { 343 uint_fast8_t negCount = -count; 344 struct uint128_extra z; 345 z.v.v64 = a64>>count; 346 z.v.v0 = a64<<(negCount & 63) | a0>>count; 347 z.extra = a0<<(negCount & 63) | (extra != 0); 348 return z; 349 } 350 #else 351 struct uint128_extra 352 softfloat_shortShiftRightJam128Extra( 353 uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t count ); 354 #endif 355 #endif 356 357 #ifndef softfloat_shiftRightJam64Extra 358 /*---------------------------------------------------------------------------- 359 | Shifts the 128 bits formed by concatenating `a' and `extra' right by 64 360 | _plus_ the number of bits given in `count', which must not be zero. This 361 | shifted value is at most 64 nonzero bits and is returned in the `v' field 362 | of the `struct uint64_extra' result. The 64-bit `extra' field of the result 363 | contains a value formed as follows from the bits that were shifted off: The 364 | _last_ bit shifted off is the most-significant bit of the `extra' field, and 365 | the other 63 bits of the `extra' field are all zero if and only if _all_but_ 366 | _the_last_ bits shifted off were all zero. 367 | (This function makes more sense if `a' and `extra' are considered to form 368 | an unsigned fixed-point number with binary point between `a' and `extra'. 369 | This fixed-point value is shifted right by the number of bits given in 370 | `count', and the integer part of this shifted value is returned in the `v' 371 | field of the result. The fractional part of the shifted value is modified 372 | as described above and returned in the `extra' field of the result.) 373 *----------------------------------------------------------------------------*/ 374 #if defined INLINE_LEVEL && (4 <= INLINE_LEVEL) 375 INLINE 376 struct uint64_extra 377 softfloat_shiftRightJam64Extra( 378 uint64_t a, uint64_t extra, uint_fast32_t count ) 379 { 380 struct uint64_extra z; 381 if ( count < 64 ) { 382 z.v = a>>count; 383 z.extra = a<<(-count & 63); 384 } else { 385 z.v = 0; 386 z.extra = (count == 64) ? a : (a != 0); 387 } 388 z.extra |= (extra != 0); 389 return z; 390 } 391 #else 392 struct uint64_extra 393 softfloat_shiftRightJam64Extra( 394 uint64_t a, uint64_t extra, uint_fast32_t count ); 395 #endif 396 #endif 397 398 #ifndef softfloat_shiftRightJam128 399 /*---------------------------------------------------------------------------- 400 | Shifts the 128 bits formed by concatenating `a64' and `a0' right by the 401 | number of bits given in `count', which must not be zero. If any nonzero 402 | bits are shifted off, they are "jammed" into the least-significant bit of 403 | the shifted value by setting the least-significant bit to 1. This shifted- 404 | and-jammed value is returned. 405 | The value of `count' can be arbitrarily large. In particular, if `count' 406 | is greater than 128, the result will be either 0 or 1, depending on whether 407 | the original 128 bits are all zeros. 408 *----------------------------------------------------------------------------*/ 409 struct uint128 410 softfloat_shiftRightJam128( uint64_t a64, uint64_t a0, uint_fast32_t count ); 411 #endif 412 413 #ifndef softfloat_shiftRightJam128Extra 414 /*---------------------------------------------------------------------------- 415 | Shifts the 192 bits formed by concatenating `a64', `a0', and `extra' right 416 | by 64 _plus_ the number of bits given in `count', which must not be zero. 417 | This shifted value is at most 128 nonzero bits and is returned in the `v' 418 | field of the `struct uint128_extra' result. The 64-bit `extra' field of the 419 | result contains a value formed as follows from the bits that were shifted 420 | off: The _last_ bit shifted off is the most-significant bit of the `extra' 421 | field, and the other 63 bits of the `extra' field are all zero if and only 422 | if _all_but_the_last_ bits shifted off were all zero. 423 | (This function makes more sense if `a64', `a0', and `extra' are considered 424 | to form an unsigned fixed-point number with binary point between `a0' and 425 | `extra'. This fixed-point value is shifted right by the number of bits 426 | given in `count', and the integer part of this shifted value is returned 427 | in the `v' field of the result. The fractional part of the shifted value 428 | is modified as described above and returned in the `extra' field of the 429 | result.) 430 *----------------------------------------------------------------------------*/ 431 struct uint128_extra 432 softfloat_shiftRightJam128Extra( 433 uint64_t a64, uint64_t a0, uint64_t extra, uint_fast32_t count ); 434 #endif 435 436 #ifndef softfloat_shiftRightJam256M 437 /*---------------------------------------------------------------------------- 438 | Shifts the 256-bit unsigned integer pointed to by `aPtr' right by the number 439 | of bits given in `count', which must not be zero. If any nonzero bits are 440 | shifted off, they are "jammed" into the least-significant bit of the shifted 441 | value by setting the least-significant bit to 1. This shifted-and-jammed 442 | value is stored at the location pointed to by `zPtr'. Each of `aPtr' and 443 | `zPtr' points to an array of four 64-bit elements that concatenate in the 444 | platform's normal endian order to form a 256-bit integer. 445 | The value of `count' can be arbitrarily large. In particular, if `count' 446 | is greater than 256, the stored result will be either 0 or 1, depending on 447 | whether the original 256 bits are all zeros. 448 *----------------------------------------------------------------------------*/ 449 void 450 softfloat_shiftRightJam256M( 451 const uint64_t *aPtr, uint_fast32_t count, uint64_t *zPtr ); 452 #endif 453 454 #ifndef softfloat_add128 455 /*---------------------------------------------------------------------------- 456 | Returns the sum of the 128-bit integer formed by concatenating `a64' and 457 | `a0' and the 128-bit integer formed by concatenating `b64' and `b0'. The 458 | addition is modulo 2^128, so any carry out is lost. 459 *----------------------------------------------------------------------------*/ 460 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL) 461 INLINE 462 struct uint128 463 softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 ) 464 { 465 struct uint128 z; 466 z.v0 = a0 + b0; 467 z.v64 = a64 + b64 + (z.v0 < a0); 468 return z; 469 } 470 #else 471 struct uint128 472 softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 ); 473 #endif 474 #endif 475 476 #ifndef softfloat_add256M 477 /*---------------------------------------------------------------------------- 478 | Adds the two 256-bit integers pointed to by `aPtr' and `bPtr'. The addition 479 | is modulo 2^256, so any carry out is lost. The sum is stored at the 480 | location pointed to by `zPtr'. Each of `aPtr', `bPtr', and `zPtr' points to 481 | an array of four 64-bit elements that concatenate in the platform's normal 482 | endian order to form a 256-bit integer. 483 *----------------------------------------------------------------------------*/ 484 void 485 softfloat_add256M( 486 const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr ); 487 #endif 488 489 #ifndef softfloat_sub128 490 /*---------------------------------------------------------------------------- 491 | Returns the difference of the 128-bit integer formed by concatenating `a64' 492 | and `a0' and the 128-bit integer formed by concatenating `b64' and `b0'. 493 | The subtraction is modulo 2^128, so any borrow out (carry out) is lost. 494 *----------------------------------------------------------------------------*/ 495 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL) 496 INLINE 497 struct uint128 498 softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 ) 499 { 500 struct uint128 z; 501 z.v0 = a0 - b0; 502 z.v64 = a64 - b64; 503 z.v64 -= (a0 < b0); 504 return z; 505 } 506 #else 507 struct uint128 508 softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 ); 509 #endif 510 #endif 511 512 #ifndef softfloat_sub256M 513 /*---------------------------------------------------------------------------- 514 | Subtracts the 256-bit integer pointed to by `bPtr' from the 256-bit integer 515 | pointed to by `aPtr'. The addition is modulo 2^256, so any borrow out 516 | (carry out) is lost. The difference is stored at the location pointed to 517 | by `zPtr'. Each of `aPtr', `bPtr', and `zPtr' points to an array of four 518 | 64-bit elements that concatenate in the platform's normal endian order to 519 | form a 256-bit integer. 520 *----------------------------------------------------------------------------*/ 521 void 522 softfloat_sub256M( 523 const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr ); 524 #endif 525 526 #ifndef softfloat_mul64ByShifted32To128 527 /*---------------------------------------------------------------------------- 528 | Returns the 128-bit product of `a', `b', and 2^32. 529 *----------------------------------------------------------------------------*/ 530 #if defined INLINE_LEVEL && (3 <= INLINE_LEVEL) 531 INLINE struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b ) 532 { 533 uint_fast64_t mid; 534 struct uint128 z; 535 mid = (uint_fast64_t) (uint32_t) a * b; 536 z.v0 = mid<<32; 537 z.v64 = (uint_fast64_t) (uint32_t) (a>>32) * b + (mid>>32); 538 return z; 539 } 540 #else 541 struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b ); 542 #endif 543 #endif 544 545 #ifndef softfloat_mul64To128 546 /*---------------------------------------------------------------------------- 547 | Returns the 128-bit product of `a' and `b'. 548 *----------------------------------------------------------------------------*/ 549 struct uint128 softfloat_mul64To128( uint64_t a, uint64_t b ); 550 #endif 551 552 #ifndef softfloat_mul128By32 553 /*---------------------------------------------------------------------------- 554 | Returns the product of the 128-bit integer formed by concatenating `a64' and 555 | `a0', multiplied by `b'. The multiplication is modulo 2^128; any overflow 556 | bits are discarded. 557 *----------------------------------------------------------------------------*/ 558 #if defined INLINE_LEVEL && (4 <= INLINE_LEVEL) 559 INLINE 560 struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b ) 561 { 562 struct uint128 z; 563 uint_fast64_t mid; 564 uint_fast32_t carry; 565 z.v0 = a0 * b; 566 mid = (uint_fast64_t) (uint32_t) (a0>>32) * b; 567 carry = (uint32_t) ((uint_fast32_t) (z.v0>>32) - (uint_fast32_t) mid); 568 z.v64 = a64 * b + (uint_fast32_t) ((mid + carry)>>32); 569 return z; 570 } 571 #else 572 struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b ); 573 #endif 574 #endif 575 576 #ifndef softfloat_mul128To256M 577 /*---------------------------------------------------------------------------- 578 | Multiplies the 128-bit unsigned integer formed by concatenating `a64' and 579 | `a0' by the 128-bit unsigned integer formed by concatenating `b64' and 580 | `b0'. The 256-bit product is stored at the location pointed to by `zPtr'. 581 | Argument `zPtr' points to an array of four 64-bit elements that concatenate 582 | in the platform's normal endian order to form a 256-bit integer. 583 *----------------------------------------------------------------------------*/ 584 void 585 softfloat_mul128To256M( 586 uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0, uint64_t *zPtr ); 587 #endif 588 589 #else 590 591 /*---------------------------------------------------------------------------- 592 | The following functions are needed only when `SOFTFLOAT_FAST_INT64' is not 593 | defined. 594 *----------------------------------------------------------------------------*/ 595 596 #ifndef softfloat_compare96M 597 /*---------------------------------------------------------------------------- 598 | Compares the two 96-bit unsigned integers pointed to by `aPtr' and `bPtr'. 599 | Returns -1 if the first integer (A) is less than the second (B); returns 0 600 | if the two integers are equal; and returns +1 if the first integer (A) 601 | is greater than the second (B). (The result is thus the signum of A - B.) 602 | Each of `aPtr' and `bPtr' points to an array of three 32-bit elements that 603 | concatenate in the platform's normal endian order to form a 96-bit integer. 604 *----------------------------------------------------------------------------*/ 605 int_fast8_t softfloat_compare96M( const uint32_t *aPtr, const uint32_t *bPtr ); 606 #endif 607 608 #ifndef softfloat_compare128M 609 /*---------------------------------------------------------------------------- 610 | Compares the two 128-bit unsigned integers pointed to by `aPtr' and `bPtr'. 611 | Returns -1 if the first integer (A) is less than the second (B); returns 0 612 | if the two integers are equal; and returns +1 if the first integer (A) 613 | is greater than the second (B). (The result is thus the signum of A - B.) 614 | Each of `aPtr' and `bPtr' points to an array of four 32-bit elements that 615 | concatenate in the platform's normal endian order to form a 128-bit integer. 616 *----------------------------------------------------------------------------*/ 617 int_fast8_t 618 softfloat_compare128M( const uint32_t *aPtr, const uint32_t *bPtr ); 619 #endif 620 621 #ifndef softfloat_shortShiftLeft64To96M 622 /*---------------------------------------------------------------------------- 623 | Extends `a' to 96 bits and shifts the value left by the number of bits given 624 | in `count', which must be in the range 1 to 31. The result is stored at the 625 | location pointed to by `zPtr'. Argument `zPtr' points to an array of three 626 | 32-bit elements that concatenate in the platform's normal endian order to 627 | form a 96-bit integer. 628 *----------------------------------------------------------------------------*/ 629 #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL) 630 INLINE 631 void 632 softfloat_shortShiftLeft64To96M( 633 uint64_t a, uint_fast8_t count, uint32_t *zPtr ) 634 { 635 zPtr[indexWord( 3, 0 )] = (uint32_t) a<<count; 636 a >>= 32 - count; 637 zPtr[indexWord( 3, 2 )] = a>>32; 638 zPtr[indexWord( 3, 1 )] = a; 639 } 640 #else 641 void 642 softfloat_shortShiftLeft64To96M( 643 uint64_t a, uint_fast8_t count, uint32_t *zPtr ); 644 #endif 645 #endif 646 647 #ifndef softfloat_shortShiftLeftM 648 /*---------------------------------------------------------------------------- 649 | Shifts the N-bit unsigned integer pointed to by `aPtr' left by the number 650 | of bits given in `count', where N = `size_words' * 32. The value of `count' 651 | must be in the range 1 to 31. Any nonzero bits shifted off are lost. The 652 | shifted N-bit result is stored at the location pointed to by `zPtr'. Each 653 | of `aPtr' and `zPtr' points to a `size_words'-long array of 32-bit elements 654 | that concatenate in the platform's normal endian order to form an N-bit 655 | integer. 656 *----------------------------------------------------------------------------*/ 657 void 658 softfloat_shortShiftLeftM( 659 uint_fast8_t size_words, 660 const uint32_t *aPtr, 661 uint_fast8_t count, 662 uint32_t *zPtr 663 ); 664 #endif 665 666 #ifndef softfloat_shortShiftLeft96M 667 /*---------------------------------------------------------------------------- 668 | This function or macro is the same as `softfloat_shortShiftLeftM' with 669 | `size_words' = 3 (N = 96). 670 *----------------------------------------------------------------------------*/ 671 #define softfloat_shortShiftLeft96M( aPtr, count, zPtr ) softfloat_shortShiftLeftM( 3, aPtr, count, zPtr ) 672 #endif 673 674 #ifndef softfloat_shortShiftLeft128M 675 /*---------------------------------------------------------------------------- 676 | This function or macro is the same as `softfloat_shortShiftLeftM' with 677 | `size_words' = 4 (N = 128). 678 *----------------------------------------------------------------------------*/ 679 #define softfloat_shortShiftLeft128M( aPtr, count, zPtr ) softfloat_shortShiftLeftM( 4, aPtr, count, zPtr ) 680 #endif 681 682 #ifndef softfloat_shortShiftLeft160M 683 /*---------------------------------------------------------------------------- 684 | This function or macro is the same as `softfloat_shortShiftLeftM' with 685 | `size_words' = 5 (N = 160). 686 *----------------------------------------------------------------------------*/ 687 #define softfloat_shortShiftLeft160M( aPtr, count, zPtr ) softfloat_shortShiftLeftM( 5, aPtr, count, zPtr ) 688 #endif 689 690 #ifndef softfloat_shiftLeftM 691 /*---------------------------------------------------------------------------- 692 | Shifts the N-bit unsigned integer pointed to by `aPtr' left by the number 693 | of bits given in `count', where N = `size_words' * 32. The value of `count' 694 | must not be zero. Any nonzero bits shifted off are lost. The shifted 695 | N-bit result is stored at the location pointed to by `zPtr'. Each of `aPtr' 696 | and `zPtr' points to a `size_words'-long array of 32-bit elements that 697 | concatenate in the platform's normal endian order to form an N-bit integer. 698 | The value of `count' can be arbitrarily large. In particular, if `count' 699 | is greater than N, the stored result will be 0. 700 *----------------------------------------------------------------------------*/ 701 void 702 softfloat_shiftLeftM( 703 uint_fast8_t size_words, 704 const uint32_t *aPtr, 705 uint32_t count, 706 uint32_t *zPtr 707 ); 708 #endif 709 710 #ifndef softfloat_shiftLeft96M 711 /*---------------------------------------------------------------------------- 712 | This function or macro is the same as `softfloat_shiftLeftM' with 713 | `size_words' = 3 (N = 96). 714 *----------------------------------------------------------------------------*/ 715 #define softfloat_shiftLeft96M( aPtr, count, zPtr ) softfloat_shiftLeftM( 3, aPtr, count, zPtr ) 716 #endif 717 718 #ifndef softfloat_shiftLeft128M 719 /*---------------------------------------------------------------------------- 720 | This function or macro is the same as `softfloat_shiftLeftM' with 721 | `size_words' = 4 (N = 128). 722 *----------------------------------------------------------------------------*/ 723 #define softfloat_shiftLeft128M( aPtr, count, zPtr ) softfloat_shiftLeftM( 4, aPtr, count, zPtr ) 724 #endif 725 726 #ifndef softfloat_shiftLeft160M 727 /*---------------------------------------------------------------------------- 728 | This function or macro is the same as `softfloat_shiftLeftM' with 729 | `size_words' = 5 (N = 160). 730 *----------------------------------------------------------------------------*/ 731 #define softfloat_shiftLeft160M( aPtr, count, zPtr ) softfloat_shiftLeftM( 5, aPtr, count, zPtr ) 732 #endif 733 734 #ifndef softfloat_shortShiftRightM 735 /*---------------------------------------------------------------------------- 736 | Shifts the N-bit unsigned integer pointed to by `aPtr' right by the number 737 | of bits given in `count', where N = `size_words' * 32. The value of `count' 738 | must be in the range 1 to 31. Any nonzero bits shifted off are lost. The 739 | shifted N-bit result is stored at the location pointed to by `zPtr'. Each 740 | of `aPtr' and `zPtr' points to a `size_words'-long array of 32-bit elements 741 | that concatenate in the platform's normal endian order to form an N-bit 742 | integer. 743 *----------------------------------------------------------------------------*/ 744 void 745 softfloat_shortShiftRightM( 746 uint_fast8_t size_words, 747 const uint32_t *aPtr, 748 uint_fast8_t count, 749 uint32_t *zPtr 750 ); 751 #endif 752 753 #ifndef softfloat_shortShiftRight128M 754 /*---------------------------------------------------------------------------- 755 | This function or macro is the same as `softfloat_shortShiftRightM' with 756 | `size_words' = 4 (N = 128). 757 *----------------------------------------------------------------------------*/ 758 #define softfloat_shortShiftRight128M( aPtr, count, zPtr ) softfloat_shortShiftRightM( 4, aPtr, count, zPtr ) 759 #endif 760 761 #ifndef softfloat_shortShiftRight160M 762 /*---------------------------------------------------------------------------- 763 | This function or macro is the same as `softfloat_shortShiftRightM' with 764 | `size_words' = 5 (N = 160). 765 *----------------------------------------------------------------------------*/ 766 #define softfloat_shortShiftRight160M( aPtr, count, zPtr ) softfloat_shortShiftRightM( 5, aPtr, count, zPtr ) 767 #endif 768 769 #ifndef softfloat_shortShiftRightJamM 770 /*---------------------------------------------------------------------------- 771 | Shifts the N-bit unsigned integer pointed to by `aPtr' right by the number 772 | of bits given in `count', where N = `size_words' * 32. The value of `count' 773 | must be in the range 1 to 31. If any nonzero bits are shifted off, they are 774 | "jammed" into the least-significant bit of the shifted value by setting the 775 | least-significant bit to 1. This shifted-and-jammed N-bit result is stored 776 | at the location pointed to by `zPtr'. Each of `aPtr' and `zPtr' points 777 | to a `size_words'-long array of 32-bit elements that concatenate in the 778 | platform's normal endian order to form an N-bit integer. 779 *----------------------------------------------------------------------------*/ 780 void 781 softfloat_shortShiftRightJamM( 782 uint_fast8_t, const uint32_t *, uint_fast8_t, uint32_t * ); 783 #endif 784 785 #ifndef softfloat_shortShiftRightJam160M 786 /*---------------------------------------------------------------------------- 787 | This function or macro is the same as `softfloat_shortShiftRightJamM' with 788 | `size_words' = 5 (N = 160). 789 *----------------------------------------------------------------------------*/ 790 #define softfloat_shortShiftRightJam160M( aPtr, count, zPtr ) softfloat_shortShiftRightJamM( 5, aPtr, count, zPtr ) 791 #endif 792 793 #ifndef softfloat_shiftRightM 794 /*---------------------------------------------------------------------------- 795 | Shifts the N-bit unsigned integer pointed to by `aPtr' right by the number 796 | of bits given in `count', where N = `size_words' * 32. The value of `count' 797 | must not be zero. Any nonzero bits shifted off are lost. The shifted 798 | N-bit result is stored at the location pointed to by `zPtr'. Each of `aPtr' 799 | and `zPtr' points to a `size_words'-long array of 32-bit elements that 800 | concatenate in the platform's normal endian order to form an N-bit integer. 801 | The value of `count' can be arbitrarily large. In particular, if `count' 802 | is greater than N, the stored result will be 0. 803 *----------------------------------------------------------------------------*/ 804 void 805 softfloat_shiftRightM( 806 uint_fast8_t size_words, 807 const uint32_t *aPtr, 808 uint32_t count, 809 uint32_t *zPtr 810 ); 811 #endif 812 813 #ifndef softfloat_shiftRight96M 814 /*---------------------------------------------------------------------------- 815 | This function or macro is the same as `softfloat_shiftRightM' with 816 | `size_words' = 3 (N = 96). 817 *----------------------------------------------------------------------------*/ 818 #define softfloat_shiftRight96M( aPtr, count, zPtr ) softfloat_shiftRightM( 3, aPtr, count, zPtr ) 819 #endif 820 821 #ifndef softfloat_shiftRightJamM 822 /*---------------------------------------------------------------------------- 823 | Shifts the N-bit unsigned integer pointed to by `aPtr' right by the number 824 | of bits given in `count', where N = `size_words' * 32. The value of `count' 825 | must not be zero. If any nonzero bits are shifted off, they are "jammed" 826 | into the least-significant bit of the shifted value by setting the least- 827 | significant bit to 1. This shifted-and-jammed N-bit result is stored 828 | at the location pointed to by `zPtr'. Each of `aPtr' and `zPtr' points 829 | to a `size_words'-long array of 32-bit elements that concatenate in the 830 | platform's normal endian order to form an N-bit integer. 831 | The value of `count' can be arbitrarily large. In particular, if `count' 832 | is greater than N, the stored result will be either 0 or 1, depending on 833 | whether the original N bits are all zeros. 834 *----------------------------------------------------------------------------*/ 835 void 836 softfloat_shiftRightJamM( 837 uint_fast8_t size_words, 838 const uint32_t *aPtr, 839 uint32_t count, 840 uint32_t *zPtr 841 ); 842 #endif 843 844 #ifndef softfloat_shiftRightJam96M 845 /*---------------------------------------------------------------------------- 846 | This function or macro is the same as `softfloat_shiftRightJamM' with 847 | `size_words' = 3 (N = 96). 848 *----------------------------------------------------------------------------*/ 849 #define softfloat_shiftRightJam96M( aPtr, count, zPtr ) softfloat_shiftRightJamM( 3, aPtr, count, zPtr ) 850 #endif 851 852 #ifndef softfloat_shiftRightJam128M 853 /*---------------------------------------------------------------------------- 854 | This function or macro is the same as `softfloat_shiftRightJamM' with 855 | `size_words' = 4 (N = 128). 856 *----------------------------------------------------------------------------*/ 857 #define softfloat_shiftRightJam128M( aPtr, count, zPtr ) softfloat_shiftRightJamM( 4, aPtr, count, zPtr ) 858 #endif 859 860 #ifndef softfloat_shiftRightJam160M 861 /*---------------------------------------------------------------------------- 862 | This function or macro is the same as `softfloat_shiftRightJamM' with 863 | `size_words' = 5 (N = 160). 864 *----------------------------------------------------------------------------*/ 865 #define softfloat_shiftRightJam160M( aPtr, count, zPtr ) softfloat_shiftRightJamM( 5, aPtr, count, zPtr ) 866 #endif 867 868 #ifndef softfloat_addM 869 /*---------------------------------------------------------------------------- 870 | Adds the two N-bit integers pointed to by `aPtr' and `bPtr', where N = 871 | `size_words' * 32. The addition is modulo 2^N, so any carry out is lost. 872 | The N-bit sum is stored at the location pointed to by `zPtr'. Each of 873 | `aPtr', `bPtr', and `zPtr' points to a `size_words'-long array of 32-bit 874 | elements that concatenate in the platform's normal endian order to form an 875 | N-bit integer. 876 *----------------------------------------------------------------------------*/ 877 void 878 softfloat_addM( 879 uint_fast8_t size_words, 880 const uint32_t *aPtr, 881 const uint32_t *bPtr, 882 uint32_t *zPtr 883 ); 884 #endif 885 886 #ifndef softfloat_add96M 887 /*---------------------------------------------------------------------------- 888 | This function or macro is the same as `softfloat_addM' with `size_words' 889 | = 3 (N = 96). 890 *----------------------------------------------------------------------------*/ 891 #define softfloat_add96M( aPtr, bPtr, zPtr ) softfloat_addM( 3, aPtr, bPtr, zPtr ) 892 #endif 893 894 #ifndef softfloat_add128M 895 /*---------------------------------------------------------------------------- 896 | This function or macro is the same as `softfloat_addM' with `size_words' 897 | = 4 (N = 128). 898 *----------------------------------------------------------------------------*/ 899 #define softfloat_add128M( aPtr, bPtr, zPtr ) softfloat_addM( 4, aPtr, bPtr, zPtr ) 900 #endif 901 902 #ifndef softfloat_add160M 903 /*---------------------------------------------------------------------------- 904 | This function or macro is the same as `softfloat_addM' with `size_words' 905 | = 5 (N = 160). 906 *----------------------------------------------------------------------------*/ 907 #define softfloat_add160M( aPtr, bPtr, zPtr ) softfloat_addM( 5, aPtr, bPtr, zPtr ) 908 #endif 909 910 #ifndef softfloat_addCarryM 911 /*---------------------------------------------------------------------------- 912 | Adds the two N-bit unsigned integers pointed to by `aPtr' and `bPtr', where 913 | N = `size_words' * 32, plus `carry', which must be either 0 or 1. The N-bit 914 | sum (modulo 2^N) is stored at the location pointed to by `zPtr', and any 915 | carry out is returned as the result. Each of `aPtr', `bPtr', and `zPtr' 916 | points to a `size_words'-long array of 32-bit elements that concatenate in 917 | the platform's normal endian order to form an N-bit integer. 918 *----------------------------------------------------------------------------*/ 919 uint_fast8_t 920 softfloat_addCarryM( 921 uint_fast8_t size_words, 922 const uint32_t *aPtr, 923 const uint32_t *bPtr, 924 uint_fast8_t carry, 925 uint32_t *zPtr 926 ); 927 #endif 928 929 #ifndef softfloat_addComplCarryM 930 /*---------------------------------------------------------------------------- 931 | This function or macro is the same as `softfloat_addCarryM', except that 932 | the value of the unsigned integer pointed to by `bPtr' is bit-wise completed 933 | before the addition. 934 *----------------------------------------------------------------------------*/ 935 uint_fast8_t 936 softfloat_addComplCarryM( 937 uint_fast8_t size_words, 938 const uint32_t *aPtr, 939 const uint32_t *bPtr, 940 uint_fast8_t carry, 941 uint32_t *zPtr 942 ); 943 #endif 944 945 #ifndef softfloat_addComplCarry96M 946 /*---------------------------------------------------------------------------- 947 | This function or macro is the same as `softfloat_addComplCarryM' with 948 | `size_words' = 3 (N = 96). 949 *----------------------------------------------------------------------------*/ 950 #define softfloat_addComplCarry96M( aPtr, bPtr, carry, zPtr ) softfloat_addComplCarryM( 3, aPtr, bPtr, carry, zPtr ) 951 #endif 952 953 #ifndef softfloat_negXM 954 /*---------------------------------------------------------------------------- 955 | Replaces the N-bit unsigned integer pointed to by `zPtr' by the 956 | 2s-complement of itself, where N = `size_words' * 32. Argument `zPtr' 957 | points to a `size_words'-long array of 32-bit elements that concatenate in 958 | the platform's normal endian order to form an N-bit integer. 959 *----------------------------------------------------------------------------*/ 960 void softfloat_negXM( uint_fast8_t size_words, uint32_t *zPtr ); 961 #endif 962 963 #ifndef softfloat_negX96M 964 /*---------------------------------------------------------------------------- 965 | This function or macro is the same as `softfloat_negXM' with `size_words' 966 | = 3 (N = 96). 967 *----------------------------------------------------------------------------*/ 968 #define softfloat_negX96M( zPtr ) softfloat_negXM( 3, zPtr ) 969 #endif 970 971 #ifndef softfloat_negX128M 972 /*---------------------------------------------------------------------------- 973 | This function or macro is the same as `softfloat_negXM' with `size_words' 974 | = 4 (N = 128). 975 *----------------------------------------------------------------------------*/ 976 #define softfloat_negX128M( zPtr ) softfloat_negXM( 4, zPtr ) 977 #endif 978 979 #ifndef softfloat_negX160M 980 /*---------------------------------------------------------------------------- 981 | This function or macro is the same as `softfloat_negXM' with `size_words' 982 | = 5 (N = 160). 983 *----------------------------------------------------------------------------*/ 984 #define softfloat_negX160M( zPtr ) softfloat_negXM( 5, zPtr ) 985 #endif 986 987 #ifndef softfloat_negX256M 988 /*---------------------------------------------------------------------------- 989 | This function or macro is the same as `softfloat_negXM' with `size_words' 990 | = 8 (N = 256). 991 *----------------------------------------------------------------------------*/ 992 #define softfloat_negX256M( zPtr ) softfloat_negXM( 8, zPtr ) 993 #endif 994 995 #ifndef softfloat_sub1XM 996 /*---------------------------------------------------------------------------- 997 | Subtracts 1 from the N-bit integer pointed to by `zPtr', where N = 998 | `size_words' * 32. The subtraction is modulo 2^N, so any borrow out (carry 999 | out) is lost. Argument `zPtr' points to a `size_words'-long array of 32-bit 1000 | elements that concatenate in the platform's normal endian order to form an 1001 | N-bit integer. 1002 *----------------------------------------------------------------------------*/ 1003 void softfloat_sub1XM( uint_fast8_t size_words, uint32_t *zPtr ); 1004 #endif 1005 1006 #ifndef softfloat_sub1X96M 1007 /*---------------------------------------------------------------------------- 1008 | This function or macro is the same as `softfloat_sub1XM' with `size_words' 1009 | = 3 (N = 96). 1010 *----------------------------------------------------------------------------*/ 1011 #define softfloat_sub1X96M( zPtr ) softfloat_sub1XM( 3, zPtr ) 1012 #endif 1013 1014 #ifndef softfloat_sub1X160M 1015 /*---------------------------------------------------------------------------- 1016 | This function or macro is the same as `softfloat_sub1XM' with `size_words' 1017 | = 5 (N = 160). 1018 *----------------------------------------------------------------------------*/ 1019 #define softfloat_sub1X160M( zPtr ) softfloat_sub1XM( 5, zPtr ) 1020 #endif 1021 1022 #ifndef softfloat_subM 1023 /*---------------------------------------------------------------------------- 1024 | Subtracts the two N-bit integers pointed to by `aPtr' and `bPtr', where N = 1025 | `size_words' * 32. The subtraction is modulo 2^N, so any borrow out (carry 1026 | out) is lost. The N-bit difference is stored at the location pointed to by 1027 | `zPtr'. Each of `aPtr', `bPtr', and `zPtr' points to a `size_words'-long 1028 | array of 32-bit elements that concatenate in the platform's normal endian 1029 | order to form an N-bit integer. 1030 *----------------------------------------------------------------------------*/ 1031 void 1032 softfloat_subM( 1033 uint_fast8_t size_words, 1034 const uint32_t *aPtr, 1035 const uint32_t *bPtr, 1036 uint32_t *zPtr 1037 ); 1038 #endif 1039 1040 #ifndef softfloat_sub96M 1041 /*---------------------------------------------------------------------------- 1042 | This function or macro is the same as `softfloat_subM' with `size_words' 1043 | = 3 (N = 96). 1044 *----------------------------------------------------------------------------*/ 1045 #define softfloat_sub96M( aPtr, bPtr, zPtr ) softfloat_subM( 3, aPtr, bPtr, zPtr ) 1046 #endif 1047 1048 #ifndef softfloat_sub128M 1049 /*---------------------------------------------------------------------------- 1050 | This function or macro is the same as `softfloat_subM' with `size_words' 1051 | = 4 (N = 128). 1052 *----------------------------------------------------------------------------*/ 1053 #define softfloat_sub128M( aPtr, bPtr, zPtr ) softfloat_subM( 4, aPtr, bPtr, zPtr ) 1054 #endif 1055 1056 #ifndef softfloat_sub160M 1057 /*---------------------------------------------------------------------------- 1058 | This function or macro is the same as `softfloat_subM' with `size_words' 1059 | = 5 (N = 160). 1060 *----------------------------------------------------------------------------*/ 1061 #define softfloat_sub160M( aPtr, bPtr, zPtr ) softfloat_subM( 5, aPtr, bPtr, zPtr ) 1062 #endif 1063 1064 #ifndef softfloat_mul64To128M 1065 /*---------------------------------------------------------------------------- 1066 | Multiplies `a' and `b' and stores the 128-bit product at the location 1067 | pointed to by `zPtr'. Argument `zPtr' points to an array of four 32-bit 1068 | elements that concatenate in the platform's normal endian order to form a 1069 | 128-bit integer. 1070 *----------------------------------------------------------------------------*/ 1071 void softfloat_mul64To128M( uint64_t a, uint64_t b, uint32_t *zPtr ); 1072 #endif 1073 1074 #ifndef softfloat_mul128MTo256M 1075 /*---------------------------------------------------------------------------- 1076 | Multiplies the two 128-bit unsigned integers pointed to by `aPtr' and 1077 | `bPtr', and stores the 256-bit product at the location pointed to by `zPtr'. 1078 | Each of `aPtr' and `bPtr' points to an array of four 32-bit elements that 1079 | concatenate in the platform's normal endian order to form a 128-bit integer. 1080 | Argument `zPtr' points to an array of eight 32-bit elements that concatenate 1081 | to form a 256-bit integer. 1082 *----------------------------------------------------------------------------*/ 1083 void 1084 softfloat_mul128MTo256M( 1085 const uint32_t *aPtr, const uint32_t *bPtr, uint32_t *zPtr ); 1086 #endif 1087 1088 #ifndef softfloat_remStepMBy32 1089 /*---------------------------------------------------------------------------- 1090 | Performs a "remainder reduction step" as follows: Arguments `remPtr' and 1091 | `bPtr' both point to N-bit unsigned integers, where N = `size_words' * 32. 1092 | Defining R and B as the values of those integers, the expression (R<<`count') 1093 | - B * q is computed modulo 2^N, and the N-bit result is stored at the 1094 | location pointed to by `zPtr'. Each of `remPtr', `bPtr', and `zPtr' points 1095 | to a `size_words'-long array of 32-bit elements that concatenate in the 1096 | platform's normal endian order to form an N-bit integer. 1097 *----------------------------------------------------------------------------*/ 1098 void 1099 softfloat_remStepMBy32( 1100 uint_fast8_t size_words, 1101 const uint32_t *remPtr, 1102 uint_fast8_t count, 1103 const uint32_t *bPtr, 1104 uint32_t q, 1105 uint32_t *zPtr 1106 ); 1107 #endif 1108 1109 #ifndef softfloat_remStep96MBy32 1110 /*---------------------------------------------------------------------------- 1111 | This function or macro is the same as `softfloat_remStepMBy32' with 1112 | `size_words' = 3 (N = 96). 1113 *----------------------------------------------------------------------------*/ 1114 #define softfloat_remStep96MBy32( remPtr, count, bPtr, q, zPtr ) softfloat_remStepMBy32( 3, remPtr, count, bPtr, q, zPtr ) 1115 #endif 1116 1117 #ifndef softfloat_remStep128MBy32 1118 /*---------------------------------------------------------------------------- 1119 | This function or macro is the same as `softfloat_remStepMBy32' with 1120 | `size_words' = 4 (N = 128). 1121 *----------------------------------------------------------------------------*/ 1122 #define softfloat_remStep128MBy32( remPtr, count, bPtr, q, zPtr ) softfloat_remStepMBy32( 4, remPtr, count, bPtr, q, zPtr ) 1123 #endif 1124 1125 #ifndef softfloat_remStep160MBy32 1126 /*---------------------------------------------------------------------------- 1127 | This function or macro is the same as `softfloat_remStepMBy32' with 1128 | `size_words' = 5 (N = 160). 1129 *----------------------------------------------------------------------------*/ 1130 #define softfloat_remStep160MBy32( remPtr, count, bPtr, q, zPtr ) softfloat_remStepMBy32( 5, remPtr, count, bPtr, q, zPtr ) 1131 #endif 1132 1133 #endif 1134 1135 #endif 1136 1137