diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-01-29 03:45:15 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-29 03:45:15 -0500 |
| commit | 225910f9341fbc725ff5e0d2c653e29bc2f21cb8 (patch) | |
| tree | eac47d40ae555398c46e4ccdff9cace12eeabd3b /src/stage1/softfloat_ext.cpp | |
| parent | 63ee6e662582ee75ac804eb1a4dbdf4457b8f2d0 (diff) | |
| parent | a0a71709bc2104c708f045fbb42c6247aff136ac (diff) | |
| download | zig-225910f9341fbc725ff5e0d2c653e29bc2f21cb8.tar.gz zig-225910f9341fbc725ff5e0d2c653e29bc2f21cb8.zip | |
Merge pull request #10639 from Vexu/f80
Add f80
Diffstat (limited to 'src/stage1/softfloat_ext.cpp')
| -rw-r--r-- | src/stage1/softfloat_ext.cpp | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/src/stage1/softfloat_ext.cpp b/src/stage1/softfloat_ext.cpp index d0b8d1a5b3..bb4c134d9e 100644 --- a/src/stage1/softfloat_ext.cpp +++ b/src/stage1/softfloat_ext.cpp @@ -28,13 +28,6 @@ void f128M_trunc(const float128_t *aPtr, float128_t *zPtr) { } } -float16_t f16_neg(const float16_t a) { - union { uint16_t ui; float16_t f; } uA; - // Toggle the sign bit. - uA.ui = a.v ^ (UINT16_C(1) << 15); - return uA.f; -} - void f128M_neg(const float128_t *aPtr, float128_t *zPtr) { // Toggle the sign bit. #if ZIG_BYTE_ORDER == ZIG_LITTLE_ENDIAN @@ -46,4 +39,33 @@ void f128M_neg(const float128_t *aPtr, float128_t *zPtr) { #else #error Unsupported endian #endif -}
\ No newline at end of file +} + +void extF80M_abs(const extFloat80_t *aPtr, extFloat80_t *zPtr) { + // Clear the sign bit. + zPtr->signExp = aPtr->signExp & UINT16_C(0x7FFF); + zPtr->signif = aPtr->signif; +} + +void extF80M_trunc(const extFloat80_t *aPtr, extFloat80_t *zPtr) { + extFloat80_t zero_float; + ui32_to_extF80M(0, &zero_float); + if (extF80M_lt(aPtr, &zero_float)) { + extF80M_roundToInt(aPtr, softfloat_round_max, false, zPtr); + } else { + extF80M_roundToInt(aPtr, softfloat_round_min, false, zPtr); + } +} + +void extF80M_neg(const extFloat80_t *aPtr, extFloat80_t *zPtr) { + // Toggle the sign bit. + zPtr->signExp = aPtr->signExp ^ UINT16_C(0x8000); + zPtr->signif = aPtr->signif; +} + +float16_t f16_neg(const float16_t a) { + union { uint16_t ui; float16_t f; } uA; + // Toggle the sign bit. + uA.ui = a.v ^ (UINT16_C(1) << 15); + return uA.f; +} |
