Same as convertToSignExtendedInteger, except we provide deterministic values in case of an invalid operation exception, namely zero for NaNs and the minimal or maximal value respectively for underflow or overflow. The *isExact output tells whether the result is exact, in the sense that converting it back to the original floating point type produces the original value. This is al
| 2371 | except for negative zeroes. |
| 2372 | */ |
| 2373 | IEEEFloat::opStatus |
| 2374 | IEEEFloat::convertToInteger(MutableArrayRef<integerPart> parts, |
| 2375 | unsigned int width, bool isSigned, |
| 2376 | roundingMode rounding_mode, bool *isExact) const { |
| 2377 | opStatus fs; |
| 2378 | |
| 2379 | fs = convertToSignExtendedInteger(parts, width, isSigned, rounding_mode, |
| 2380 | isExact); |
| 2381 | |
| 2382 | if (fs == opInvalidOp) { |
| 2383 | unsigned int bits, dstPartsCount; |
| 2384 | |
| 2385 | dstPartsCount = partCountForBits(width); |
| 2386 | assert(dstPartsCount <= parts.size() && "Integer too big"); |
| 2387 | |
| 2388 | if (category == fcNaN) |
| 2389 | bits = 0; |
| 2390 | else if (sign) |
| 2391 | bits = isSigned; |
| 2392 | else |
| 2393 | bits = width - isSigned; |
| 2394 | |
| 2395 | APInt::tcSetLeastSignificantBits(parts.data(), dstPartsCount, bits); |
| 2396 | if (sign && isSigned) |
| 2397 | APInt::tcShiftLeft(parts.data(), dstPartsCount, width - 1); |
| 2398 | } |
| 2399 | |
| 2400 | return fs; |
| 2401 | } |
| 2402 | |
| 2403 | /* Convert an unsigned integer SRC to a floating point number, |
| 2404 | rounding according to ROUNDING_MODE. The sign of the floating |