ext: Update softfloat to 3d full version
* Add all softfloat source files without any change.
* Remove useless file softfloat.mk.in, since gem5 use Scons.
* Add `use_fast_int64` in SConscript to distinguish src of two strategies for data
larger than 64 bits.
* The SoftFloat library uses two strategies to handle data larger than 64bit. One is
spliting data into `fast_int64`, and the other is using pointer. Two strategies
are distinguished by macro `SOFTFLOAT_FAST_INT64`. But not all "*.c" files are
guarded by this macro, which leads to including useless files in compiling progress
and compiling error. `use_fast_int64` used in SConscript can exclude unnecessary
files.
Change-Id: I7cec10412c00a35c247299cd92d83cdee9066410
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/66552
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
This commit is contained in:
@@ -33,18 +33,27 @@ import os
|
||||
|
||||
Import('env')
|
||||
|
||||
# You can change it to undefine SOFTFLOAT_FAST_INT64
|
||||
use_fast_int64 = True
|
||||
|
||||
sf_env = env.Clone()
|
||||
if sf_env['GCC']:
|
||||
sf_env.Append(CCFLAGS=['-Wno-unused-variable',
|
||||
'-Wno-unused-label',
|
||||
'-Wno-implicit-fallthrough',
|
||||
'-Wno-implicit-function-declaration',
|
||||
'-g'])
|
||||
|
||||
elif sf_env['CLANG']:
|
||||
sf_env.Append(CCFLAGS=['-Wno-unused-variable',
|
||||
'-Wno-unused-label',
|
||||
'-Wno-implicit-function-declaration',
|
||||
'-g'])
|
||||
|
||||
if use_fast_int64:
|
||||
sf_env.Prepend(CXXFLAGS=['-DSOFTFLOAT_FAST_INT64'])
|
||||
sf_env.Prepend(CFLAGS=['-DSOFTFLOAT_FAST_INT64'])
|
||||
|
||||
# Add the appropriate files for the library
|
||||
softfloat_files = []
|
||||
|
||||
@@ -52,33 +61,6 @@ softfloat_files = []
|
||||
def SoftfloatFile(filename):
|
||||
softfloat_files.append(File('./' + filename))
|
||||
|
||||
SoftfloatFile('f128_add.c')
|
||||
SoftfloatFile('f128_classify.c')
|
||||
SoftfloatFile('f128_div.c')
|
||||
SoftfloatFile('f128_eq.c')
|
||||
SoftfloatFile('f128_eq_signaling.c')
|
||||
SoftfloatFile('f128_isSignalingNaN.c')
|
||||
SoftfloatFile('f128_le.c')
|
||||
SoftfloatFile('f128_le_quiet.c')
|
||||
SoftfloatFile('f128_lt.c')
|
||||
SoftfloatFile('f128_lt_quiet.c')
|
||||
SoftfloatFile('f128_mulAdd.c')
|
||||
SoftfloatFile('f128_mul.c')
|
||||
SoftfloatFile('f128_rem.c')
|
||||
SoftfloatFile('f128_roundToInt.c')
|
||||
SoftfloatFile('f128_sqrt.c')
|
||||
SoftfloatFile('f128_sub.c')
|
||||
SoftfloatFile('f128_to_f16.c')
|
||||
SoftfloatFile('f128_to_f32.c')
|
||||
SoftfloatFile('f128_to_f64.c')
|
||||
SoftfloatFile('f128_to_i32.c')
|
||||
SoftfloatFile('f128_to_i32_r_minMag.c')
|
||||
SoftfloatFile('f128_to_i64.c')
|
||||
SoftfloatFile('f128_to_i64_r_minMag.c')
|
||||
SoftfloatFile('f128_to_ui32.c')
|
||||
SoftfloatFile('f128_to_ui32_r_minMag.c')
|
||||
SoftfloatFile('f128_to_ui64.c')
|
||||
SoftfloatFile('f128_to_ui64_r_minMag.c')
|
||||
SoftfloatFile('f16_add.c')
|
||||
SoftfloatFile('f16_classify.c')
|
||||
SoftfloatFile('f16_div.c')
|
||||
@@ -95,17 +77,20 @@ SoftfloatFile('f16_rem.c')
|
||||
SoftfloatFile('f16_roundToInt.c')
|
||||
SoftfloatFile('f16_sqrt.c')
|
||||
SoftfloatFile('f16_sub.c')
|
||||
SoftfloatFile('f16_to_f128.c')
|
||||
SoftfloatFile('f16_to_f32.c')
|
||||
SoftfloatFile('f16_to_f64.c')
|
||||
SoftfloatFile('f16_to_i16.c')
|
||||
SoftfloatFile('f16_to_i32.c')
|
||||
SoftfloatFile('f16_to_i32_r_minMag.c')
|
||||
SoftfloatFile('f16_to_i64.c')
|
||||
SoftfloatFile('f16_to_i64_r_minMag.c')
|
||||
SoftfloatFile('f16_to_i8.c')
|
||||
SoftfloatFile('f16_to_ui16.c')
|
||||
SoftfloatFile('f16_to_ui32.c')
|
||||
SoftfloatFile('f16_to_ui32_r_minMag.c')
|
||||
SoftfloatFile('f16_to_ui64.c')
|
||||
SoftfloatFile('f16_to_ui64_r_minMag.c')
|
||||
SoftfloatFile('f16_to_ui8.c')
|
||||
SoftfloatFile('f32_add.c')
|
||||
SoftfloatFile('f32_classify.c')
|
||||
SoftfloatFile('f32_div.c')
|
||||
@@ -122,17 +107,22 @@ SoftfloatFile('f32_rem.c')
|
||||
SoftfloatFile('f32_roundToInt.c')
|
||||
SoftfloatFile('f32_sqrt.c')
|
||||
SoftfloatFile('f32_sub.c')
|
||||
SoftfloatFile('f32_to_f128.c')
|
||||
SoftfloatFile('f32_to_f16.c')
|
||||
SoftfloatFile('f32_to_f64.c')
|
||||
SoftfloatFile('f32_to_i16.c')
|
||||
SoftfloatFile('f32_to_i32.c')
|
||||
SoftfloatFile('f32_to_i32_r_minMag.c')
|
||||
SoftfloatFile('f32_to_i64.c')
|
||||
SoftfloatFile('f32_to_i64_r_minMag.c')
|
||||
SoftfloatFile('f32_to_ui16.c')
|
||||
SoftfloatFile('f32_to_ui32.c')
|
||||
SoftfloatFile('f32_to_ui32_r_minMag.c')
|
||||
SoftfloatFile('f32_to_ui64.c')
|
||||
SoftfloatFile('f32_to_ui64_r_minMag.c')
|
||||
SoftfloatFile('f16_to_extF80M.c')
|
||||
SoftfloatFile('f16_to_f128M.c')
|
||||
SoftfloatFile('f32_to_extF80M.c')
|
||||
SoftfloatFile('f32_to_f128M.c')
|
||||
SoftfloatFile('f64_add.c')
|
||||
SoftfloatFile('f64_classify.c')
|
||||
SoftfloatFile('f64_div.c')
|
||||
@@ -149,7 +139,8 @@ SoftfloatFile('f64_rem.c')
|
||||
SoftfloatFile('f64_roundToInt.c')
|
||||
SoftfloatFile('f64_sqrt.c')
|
||||
SoftfloatFile('f64_sub.c')
|
||||
SoftfloatFile('f64_to_f128.c')
|
||||
SoftfloatFile('f64_to_extF80M.c')
|
||||
SoftfloatFile('f64_to_f128M.c')
|
||||
SoftfloatFile('f64_to_f16.c')
|
||||
SoftfloatFile('f64_to_f32.c')
|
||||
SoftfloatFile('f64_to_i32.c')
|
||||
@@ -160,75 +151,48 @@ SoftfloatFile('f64_to_ui32.c')
|
||||
SoftfloatFile('f64_to_ui32_r_minMag.c')
|
||||
SoftfloatFile('f64_to_ui64.c')
|
||||
SoftfloatFile('f64_to_ui64_r_minMag.c')
|
||||
SoftfloatFile('i32_to_f128.c')
|
||||
SoftfloatFile('fall_maxmin.c')
|
||||
SoftfloatFile('fall_reciprocal.c')
|
||||
SoftfloatFile('i32_to_extF80M.c')
|
||||
SoftfloatFile('i32_to_f128M.c')
|
||||
SoftfloatFile('i32_to_f16.c')
|
||||
SoftfloatFile('i32_to_f32.c')
|
||||
SoftfloatFile('i32_to_f64.c')
|
||||
SoftfloatFile('i64_to_f128.c')
|
||||
SoftfloatFile('i64_to_extF80M.c')
|
||||
SoftfloatFile('i64_to_f128M.c')
|
||||
SoftfloatFile('i64_to_f16.c')
|
||||
SoftfloatFile('i64_to_f32.c')
|
||||
SoftfloatFile('i64_to_f64.c')
|
||||
SoftfloatFile('s_add128.c')
|
||||
SoftfloatFile('s_add256M.c')
|
||||
SoftfloatFile('s_addCarryM.c')
|
||||
SoftfloatFile('s_addComplCarryM.c')
|
||||
SoftfloatFile('s_addMagsF128.c')
|
||||
SoftfloatFile('s_addMagsF16.c')
|
||||
SoftfloatFile('s_addMagsF32.c')
|
||||
SoftfloatFile('s_addMagsF64.c')
|
||||
SoftfloatFile('s_addM.c')
|
||||
SoftfloatFile('s_approxRecip_1Ks.c')
|
||||
SoftfloatFile('s_approxRecip32_1.c')
|
||||
SoftfloatFile('s_approxRecipSqrt_1Ks.c')
|
||||
SoftfloatFile('s_approxRecipSqrt32_1.c')
|
||||
SoftfloatFile('s_commonNaNToF128UI.c')
|
||||
SoftfloatFile('s_commonNaNToF16UI.c')
|
||||
SoftfloatFile('s_commonNaNToF32UI.c')
|
||||
SoftfloatFile('s_commonNaNToF64UI.c')
|
||||
SoftfloatFile('s_compare128M.c')
|
||||
SoftfloatFile('s_compare96M.c')
|
||||
SoftfloatFile('s_countLeadingZeros16.c')
|
||||
SoftfloatFile('s_countLeadingZeros32.c')
|
||||
SoftfloatFile('s_countLeadingZeros64.c')
|
||||
SoftfloatFile('s_countLeadingZeros8.c')
|
||||
SoftfloatFile('s_eq128.c')
|
||||
SoftfloatFile('s_f128UIToCommonNaN.c')
|
||||
SoftfloatFile('s_f16UIToCommonNaN.c')
|
||||
SoftfloatFile('s_f32UIToCommonNaN.c')
|
||||
SoftfloatFile('s_f64UIToCommonNaN.c')
|
||||
SoftfloatFile('s_le128.c')
|
||||
SoftfloatFile('s_lt128.c')
|
||||
SoftfloatFile('s_mul128By32.c')
|
||||
SoftfloatFile('s_mul128MTo256M.c')
|
||||
SoftfloatFile('s_mul128To256M.c')
|
||||
SoftfloatFile('s_mul64ByShifted32To128.c')
|
||||
SoftfloatFile('s_mul64To128.c')
|
||||
SoftfloatFile('s_mul64To128M.c')
|
||||
SoftfloatFile('s_mulAddF128.c')
|
||||
SoftfloatFile('s_mulAddF16.c')
|
||||
SoftfloatFile('s_mulAddF32.c')
|
||||
SoftfloatFile('s_mulAddF64.c')
|
||||
SoftfloatFile('s_negXM.c')
|
||||
SoftfloatFile('s_normRoundPackToF128.c')
|
||||
SoftfloatFile('s_normRoundPackToF16.c')
|
||||
SoftfloatFile('s_normRoundPackToF32.c')
|
||||
SoftfloatFile('s_normRoundPackToF64.c')
|
||||
SoftfloatFile('s_normSubnormalF128Sig.c')
|
||||
SoftfloatFile('s_normSubnormalF16Sig.c')
|
||||
SoftfloatFile('s_normSubnormalF32Sig.c')
|
||||
SoftfloatFile('s_normSubnormalF64Sig.c')
|
||||
SoftfloatFile('softfloat_raiseFlags.c')
|
||||
SoftfloatFile('softfloat_state.c')
|
||||
SoftfloatFile('s_propagateNaNF128UI.c')
|
||||
SoftfloatFile('s_propagateNaNF16UI.c')
|
||||
SoftfloatFile('s_propagateNaNF32UI.c')
|
||||
SoftfloatFile('s_propagateNaNF64UI.c')
|
||||
SoftfloatFile('s_remStepMBy32.c')
|
||||
SoftfloatFile('s_roundMToI64.c')
|
||||
SoftfloatFile('s_roundMToUI64.c')
|
||||
SoftfloatFile('s_roundPackMToI64.c')
|
||||
SoftfloatFile('s_roundPackMToUI64.c')
|
||||
SoftfloatFile('s_roundPackToF128.c')
|
||||
SoftfloatFile('s_roundPackToF16.c')
|
||||
SoftfloatFile('s_roundPackToF32.c')
|
||||
SoftfloatFile('s_roundPackToF64.c')
|
||||
@@ -239,39 +203,221 @@ SoftfloatFile('s_roundPackToUI64.c')
|
||||
SoftfloatFile('s_roundToI32.c')
|
||||
SoftfloatFile('s_roundToI64.c')
|
||||
SoftfloatFile('s_roundToUI32.c')
|
||||
SoftfloatFile('s_roundToUI64.c')
|
||||
SoftfloatFile('s_shiftRightJam128.c')
|
||||
SoftfloatFile('s_shiftRightJam128Extra.c')
|
||||
SoftfloatFile('s_shiftRightJam256M.c')
|
||||
SoftfloatFile('s_shiftRightJam32.c')
|
||||
SoftfloatFile('s_shiftRightJam64.c')
|
||||
SoftfloatFile('s_shiftRightJam64Extra.c')
|
||||
SoftfloatFile('s_shortShiftLeft128.c')
|
||||
SoftfloatFile('s_shortShiftLeft64To96M.c')
|
||||
SoftfloatFile('s_shortShiftRight128.c')
|
||||
SoftfloatFile('s_shortShiftRightExtendM.c')
|
||||
SoftfloatFile('s_shortShiftRightJam128.c')
|
||||
SoftfloatFile('s_shortShiftRightJam128Extra.c')
|
||||
SoftfloatFile('s_shortShiftRightJam64.c')
|
||||
SoftfloatFile('s_shortShiftRightJam64Extra.c')
|
||||
SoftfloatFile('s_shortShiftRightM.c')
|
||||
SoftfloatFile('s_sub128.c')
|
||||
SoftfloatFile('s_sub1XM.c')
|
||||
SoftfloatFile('s_sub256M.c')
|
||||
SoftfloatFile('s_subMagsF128.c')
|
||||
SoftfloatFile('s_subMagsF16.c')
|
||||
SoftfloatFile('s_subMagsF32.c')
|
||||
SoftfloatFile('s_subMagsF64.c')
|
||||
SoftfloatFile('s_subM.c')
|
||||
SoftfloatFile('ui32_to_f128.c')
|
||||
SoftfloatFile('softfloat_raiseFlags.c')
|
||||
SoftfloatFile('softfloat_state.c')
|
||||
SoftfloatFile('ui32_to_f16.c')
|
||||
SoftfloatFile('ui32_to_f32.c')
|
||||
SoftfloatFile('ui32_to_f64.c')
|
||||
SoftfloatFile('ui64_to_f128.c')
|
||||
SoftfloatFile('ui64_to_f16.c')
|
||||
SoftfloatFile('ui64_to_f32.c')
|
||||
SoftfloatFile('ui64_to_f64.c')
|
||||
|
||||
if use_fast_int64:
|
||||
SoftfloatFile('extF80_add.c')
|
||||
SoftfloatFile('extF80_div.c')
|
||||
SoftfloatFile('extF80_eq.c')
|
||||
SoftfloatFile('extF80_eq_signaling.c')
|
||||
SoftfloatFile('extF80_isSignalingNaN.c')
|
||||
SoftfloatFile('extF80_le.c')
|
||||
SoftfloatFile('extF80_le_quiet.c')
|
||||
SoftfloatFile('extF80_lt.c')
|
||||
SoftfloatFile('extF80_lt_quiet.c')
|
||||
SoftfloatFile('extF80_mul.c')
|
||||
SoftfloatFile('extF80_rem.c')
|
||||
SoftfloatFile('extF80_roundToInt.c')
|
||||
SoftfloatFile('extF80_sqrt.c')
|
||||
SoftfloatFile('extF80_sub.c')
|
||||
SoftfloatFile('extF80_to_f128.c')
|
||||
SoftfloatFile('extF80_to_f16.c')
|
||||
SoftfloatFile('extF80_to_f32.c')
|
||||
SoftfloatFile('extF80_to_f64.c')
|
||||
SoftfloatFile('extF80_to_i32.c')
|
||||
SoftfloatFile('extF80_to_i32_r_minMag.c')
|
||||
SoftfloatFile('extF80_to_i64.c')
|
||||
SoftfloatFile('extF80_to_i64_r_minMag.c')
|
||||
SoftfloatFile('extF80_to_ui32.c')
|
||||
SoftfloatFile('extF80_to_ui32_r_minMag.c')
|
||||
SoftfloatFile('extF80_to_ui64.c')
|
||||
SoftfloatFile('extF80_to_ui64_r_minMag.c')
|
||||
SoftfloatFile('f128_add.c')
|
||||
SoftfloatFile('f128_classify.c')
|
||||
SoftfloatFile('f128_div.c')
|
||||
SoftfloatFile('f128_eq.c')
|
||||
SoftfloatFile('f128_eq_signaling.c')
|
||||
SoftfloatFile('f128_isSignalingNaN.c')
|
||||
SoftfloatFile('f128_le.c')
|
||||
SoftfloatFile('f128_le_quiet.c')
|
||||
SoftfloatFile('f128_lt.c')
|
||||
SoftfloatFile('f128_lt_quiet.c')
|
||||
SoftfloatFile('f128_mulAdd.c')
|
||||
SoftfloatFile('f128_mul.c')
|
||||
SoftfloatFile('f128_rem.c')
|
||||
SoftfloatFile('f128_roundToInt.c')
|
||||
SoftfloatFile('f128_sqrt.c')
|
||||
SoftfloatFile('f128_sub.c')
|
||||
SoftfloatFile('f128_to_extF80.c')
|
||||
SoftfloatFile('f128_to_f16.c')
|
||||
SoftfloatFile('f128_to_f32.c')
|
||||
SoftfloatFile('f128_to_f64.c')
|
||||
SoftfloatFile('f128_to_i32.c')
|
||||
SoftfloatFile('f128_to_i32_r_minMag.c')
|
||||
SoftfloatFile('f128_to_i64.c')
|
||||
SoftfloatFile('f128_to_i64_r_minMag.c')
|
||||
SoftfloatFile('f128_to_ui32.c')
|
||||
SoftfloatFile('f128_to_ui32_r_minMag.c')
|
||||
SoftfloatFile('f128_to_ui64.c')
|
||||
SoftfloatFile('f128_to_ui64_r_minMag.c')
|
||||
SoftfloatFile('f16_to_extF80.c')
|
||||
SoftfloatFile('f16_to_f128.c')
|
||||
SoftfloatFile('f32_to_extF80.c')
|
||||
SoftfloatFile('f32_to_f128.c')
|
||||
SoftfloatFile('f64_to_extF80.c')
|
||||
SoftfloatFile('f64_to_f128.c')
|
||||
SoftfloatFile('i32_to_extF80.c')
|
||||
SoftfloatFile('i32_to_f128.c')
|
||||
SoftfloatFile('i64_to_extF80.c')
|
||||
SoftfloatFile('i64_to_f128.c')
|
||||
SoftfloatFile('s_addMagsExtF80.c')
|
||||
SoftfloatFile('s_addMagsF128.c')
|
||||
SoftfloatFile('s_add128.c')
|
||||
SoftfloatFile('s_add256M.c')
|
||||
SoftfloatFile('s_commonNaNToF128UI.c')
|
||||
SoftfloatFile('s_eq128.c')
|
||||
SoftfloatFile('s_le128.c')
|
||||
SoftfloatFile('s_lt128.c')
|
||||
SoftfloatFile('s_mulAddF128.c')
|
||||
SoftfloatFile('s_mul64ByShifted32To128.c')
|
||||
SoftfloatFile('s_mul64To128.c')
|
||||
SoftfloatFile('s_mul128By32.c')
|
||||
SoftfloatFile('s_mul128To256M.c')
|
||||
SoftfloatFile('s_normRoundPackToExtF80.c')
|
||||
SoftfloatFile('s_normRoundPackToF128.c')
|
||||
SoftfloatFile('s_normSubnormalExtF80Sig.c')
|
||||
SoftfloatFile('s_normSubnormalF128Sig.c')
|
||||
SoftfloatFile('s_propagateNaNF128UI.c')
|
||||
SoftfloatFile('s_roundPackToExtF80.c')
|
||||
SoftfloatFile('s_roundPackToF128.c')
|
||||
SoftfloatFile('s_roundToUI64.c')
|
||||
SoftfloatFile('s_shiftRightJam128.c')
|
||||
SoftfloatFile('s_shiftRightJam128Extra.c')
|
||||
SoftfloatFile('s_shiftRightJam256M.c')
|
||||
SoftfloatFile('s_shiftRightJam64Extra.c')
|
||||
SoftfloatFile('s_shortShiftLeft128.c')
|
||||
SoftfloatFile('s_shortShiftRight128.c')
|
||||
SoftfloatFile('s_shortShiftRightJam64Extra.c')
|
||||
SoftfloatFile('s_shortShiftRightJam128.c')
|
||||
SoftfloatFile('s_shortShiftRightJam128Extra.c')
|
||||
SoftfloatFile('s_subMagsExtF80.c')
|
||||
SoftfloatFile('s_subMagsF128.c')
|
||||
SoftfloatFile('s_sub128.c')
|
||||
SoftfloatFile('s_sub256M.c')
|
||||
SoftfloatFile('ui32_to_extF80.c')
|
||||
SoftfloatFile('ui32_to_f128.c')
|
||||
SoftfloatFile('ui64_to_extF80.c')
|
||||
SoftfloatFile('ui64_to_f128.c')
|
||||
|
||||
else:
|
||||
SoftfloatFile('extF80M_add.c')
|
||||
SoftfloatFile('extF80M_div.c')
|
||||
SoftfloatFile('extF80M_eq.c')
|
||||
SoftfloatFile('extF80M_eq_signaling.c')
|
||||
SoftfloatFile('extF80M_le.c')
|
||||
SoftfloatFile('extF80M_le_quiet.c')
|
||||
SoftfloatFile('extF80M_lt.c')
|
||||
SoftfloatFile('extF80M_lt_quiet.c')
|
||||
SoftfloatFile('extF80M_mul.c')
|
||||
SoftfloatFile('extF80M_rem.c')
|
||||
SoftfloatFile('extF80M_roundToInt.c')
|
||||
SoftfloatFile('extF80M_sqrt.c')
|
||||
SoftfloatFile('extF80M_sub.c')
|
||||
SoftfloatFile('extF80M_to_f128M.c')
|
||||
SoftfloatFile('extF80M_to_f16.c')
|
||||
SoftfloatFile('extF80M_to_f32.c')
|
||||
SoftfloatFile('extF80M_to_f64.c')
|
||||
SoftfloatFile('extF80M_to_i32.c')
|
||||
SoftfloatFile('extF80M_to_i32_r_minMag.c')
|
||||
SoftfloatFile('extF80M_to_i64.c')
|
||||
SoftfloatFile('extF80M_to_i64_r_minMag.c')
|
||||
SoftfloatFile('extF80M_to_ui32.c')
|
||||
SoftfloatFile('extF80M_to_ui32_r_minMag.c')
|
||||
SoftfloatFile('extF80M_to_ui64.c')
|
||||
SoftfloatFile('extF80M_to_ui64_r_minMag.c')
|
||||
SoftfloatFile('f128M_add.c')
|
||||
SoftfloatFile('f128M_div.c')
|
||||
SoftfloatFile('f128M_eq.c')
|
||||
SoftfloatFile('f128M_eq_signaling.c')
|
||||
SoftfloatFile('f128M_le.c')
|
||||
SoftfloatFile('f128M_le_quiet.c')
|
||||
SoftfloatFile('f128M_lt.c')
|
||||
SoftfloatFile('f128M_lt_quiet.c')
|
||||
SoftfloatFile('f128M_mulAdd.c')
|
||||
SoftfloatFile('f128M_mul.c')
|
||||
SoftfloatFile('f128M_rem.c')
|
||||
SoftfloatFile('f128M_roundToInt.c')
|
||||
SoftfloatFile('f128M_sqrt.c')
|
||||
SoftfloatFile('f128M_sub.c')
|
||||
SoftfloatFile('f128M_to_extF80M.c')
|
||||
SoftfloatFile('f128M_to_f16.c')
|
||||
SoftfloatFile('f128M_to_f32.c')
|
||||
SoftfloatFile('f128M_to_f64.c')
|
||||
SoftfloatFile('f128M_to_i32.c')
|
||||
SoftfloatFile('f128M_to_i32_r_minMag.c')
|
||||
SoftfloatFile('f128M_to_i64.c')
|
||||
SoftfloatFile('f128M_to_i64_r_minMag.c')
|
||||
SoftfloatFile('f128M_to_ui32.c')
|
||||
SoftfloatFile('f128M_to_ui32_r_minMag.c')
|
||||
SoftfloatFile('f128M_to_ui64.c')
|
||||
SoftfloatFile('f128M_to_ui64_r_minMag.c')
|
||||
SoftfloatFile('s_addM.c')
|
||||
SoftfloatFile('s_addCarryM.c')
|
||||
SoftfloatFile('s_addComplCarryM.c')
|
||||
SoftfloatFile('s_addExtF80M.c')
|
||||
SoftfloatFile('s_addF128M.c')
|
||||
SoftfloatFile('s_compareNonnormExtF80M.c')
|
||||
SoftfloatFile('s_compare128M.c')
|
||||
SoftfloatFile('s_compare96M.c')
|
||||
SoftfloatFile('s_invalidExtF80M.c')
|
||||
SoftfloatFile('s_invalidF128M.c')
|
||||
SoftfloatFile('s_isNaNF128M.c')
|
||||
SoftfloatFile('s_mulAddF128M.c')
|
||||
SoftfloatFile('s_mul128MTo256M.c')
|
||||
SoftfloatFile('s_mul64To128M.c')
|
||||
SoftfloatFile('s_negXM.c')
|
||||
SoftfloatFile('s_normExtF80SigM.c')
|
||||
SoftfloatFile('s_normRoundPackMToExtF80M.c')
|
||||
SoftfloatFile('s_normRoundPackMToF128M.c')
|
||||
SoftfloatFile('s_normSubnormalF128SigM.c')
|
||||
SoftfloatFile('s_remStepMBy32.c')
|
||||
SoftfloatFile('s_roundMToI64.c')
|
||||
SoftfloatFile('s_roundMToUI64.c')
|
||||
SoftfloatFile('s_roundPackMToExtF80M.c')
|
||||
SoftfloatFile('s_roundPackMToF128M.c')
|
||||
SoftfloatFile('s_roundPackMToI64.c')
|
||||
SoftfloatFile('s_roundPackMToUI64.c')
|
||||
SoftfloatFile('s_shiftLeftM.c')
|
||||
SoftfloatFile('s_shiftNormSigF128M.c')
|
||||
SoftfloatFile('s_shiftRightJamM.c')
|
||||
SoftfloatFile('s_shiftRightM.c')
|
||||
SoftfloatFile('s_shortShiftLeftM.c')
|
||||
SoftfloatFile('s_shortShiftLeft64To96M.c')
|
||||
SoftfloatFile('s_shortShiftRightJamM.c')
|
||||
SoftfloatFile('s_shortShiftRightM.c')
|
||||
SoftfloatFile('s_subM.c')
|
||||
SoftfloatFile('s_sub1XM.c')
|
||||
SoftfloatFile('s_tryPropagateNaNExtF80M.c')
|
||||
SoftfloatFile('s_tryPropagateNaNF128M.c')
|
||||
SoftfloatFile('ui32_to_extF80M.c')
|
||||
SoftfloatFile('ui32_to_f128M.c')
|
||||
SoftfloatFile('ui64_to_extF80M.c')
|
||||
SoftfloatFile('ui64_to_f128M.c')
|
||||
|
||||
sf_env.Library('softfloat', [sf_env.SharedObject(f) for f in softfloat_files])
|
||||
|
||||
env.Prepend(CPPPATH=Dir('./'))
|
||||
|
||||
100
ext/softfloat/extF80M_add.c
Normal file
100
ext/softfloat/extF80M_add.c
Normal file
@@ -0,0 +1,100 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
extF80M_add(
|
||||
const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool signA;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signB;
|
||||
#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
|
||||
extFloat80_t
|
||||
(*magsFuncPtr)(
|
||||
uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
|
||||
#endif
|
||||
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
uiA0 = aSPtr->signif;
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
uiB64 = bSPtr->signExp;
|
||||
uiB0 = bSPtr->signif;
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
||||
if ( signA == signB ) {
|
||||
*zPtr = softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
} else {
|
||||
*zPtr = softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
}
|
||||
#else
|
||||
magsFuncPtr =
|
||||
(signA == signB) ? softfloat_addMagsExtF80 : softfloat_subMagsExtF80;
|
||||
*zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
extF80M_add(
|
||||
const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
|
||||
{
|
||||
|
||||
softfloat_addExtF80M(
|
||||
(const struct extFloat80M *) aPtr,
|
||||
(const struct extFloat80M *) bPtr,
|
||||
(struct extFloat80M *) zPtr,
|
||||
false
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
194
ext/softfloat/extF80M_div.c
Normal file
194
ext/softfloat/extF80M_div.c
Normal file
@@ -0,0 +1,194 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
extF80M_div(
|
||||
const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = extF80_div( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
extF80M_div(
|
||||
const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
struct extFloat80M *zSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
int32_t expA;
|
||||
uint_fast16_t uiB64;
|
||||
int32_t expB;
|
||||
bool signZ;
|
||||
uint64_t sigA, x64;
|
||||
int32_t expZ;
|
||||
int shiftDist;
|
||||
uint32_t y[3], recip32, sigB[3];
|
||||
int ix;
|
||||
uint32_t q, qs[2];
|
||||
uint_fast16_t uiZ64;
|
||||
uint64_t uiZ0;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
zSPtr = (struct extFloat80M *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
expA = expExtF80UI64( uiA64 );
|
||||
uiB64 = bSPtr->signExp;
|
||||
expB = expExtF80UI64( uiB64 );
|
||||
signZ = signExtF80UI64( uiA64 ) ^ signExtF80UI64( uiB64 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
|
||||
if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
|
||||
if ( expA == 0x7FFF ) {
|
||||
if ( expB == 0x7FFF ) goto invalid;
|
||||
goto infinity;
|
||||
}
|
||||
goto zero;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sigA = aSPtr->signif;
|
||||
x64 = bSPtr->signif;
|
||||
if ( ! expB ) expB = 1;
|
||||
if ( ! (x64 & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! x64 ) {
|
||||
if ( ! sigA ) goto invalid;
|
||||
softfloat_raiseFlags( softfloat_flag_infinite );
|
||||
goto infinity;
|
||||
}
|
||||
expB += softfloat_normExtF80SigM( &x64 );
|
||||
}
|
||||
if ( ! expA ) expA = 1;
|
||||
if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigA ) goto zero;
|
||||
expA += softfloat_normExtF80SigM( &sigA );
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = expA - expB + 0x3FFF;
|
||||
shiftDist = 29;
|
||||
if ( sigA < x64 ) {
|
||||
--expZ;
|
||||
shiftDist = 30;
|
||||
}
|
||||
softfloat_shortShiftLeft64To96M( sigA, shiftDist, y );
|
||||
recip32 = softfloat_approxRecip32_1( x64>>32 );
|
||||
sigB[indexWord( 3, 0 )] = (uint32_t) x64<<30;
|
||||
x64 >>= 2;
|
||||
sigB[indexWord( 3, 2 )] = x64>>32;
|
||||
sigB[indexWord( 3, 1 )] = x64;
|
||||
ix = 2;
|
||||
for (;;) {
|
||||
x64 = (uint64_t) y[indexWordHi( 3 )] * recip32;
|
||||
q = (x64 + 0x80000000)>>32;
|
||||
--ix;
|
||||
if ( ix < 0 ) break;
|
||||
softfloat_remStep96MBy32( y, 29, sigB, q, y );
|
||||
if ( y[indexWordHi( 3 )] & 0x80000000 ) {
|
||||
--q;
|
||||
softfloat_add96M( y, sigB, y );
|
||||
}
|
||||
qs[ix] = q;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ((q + 1) & 0x3FFFFF) < 2 ) {
|
||||
softfloat_remStep96MBy32( y, 29, sigB, q, y );
|
||||
if ( y[indexWordHi( 3 )] & 0x80000000 ) {
|
||||
--q;
|
||||
softfloat_add96M( y, sigB, y );
|
||||
} else if ( softfloat_compare96M( sigB, y ) <= 0 ) {
|
||||
++q;
|
||||
softfloat_sub96M( y, sigB, y );
|
||||
}
|
||||
if (
|
||||
y[indexWordLo( 3 )] || y[indexWord( 3, 1 )] || y[indexWord( 3, 2 )]
|
||||
) {
|
||||
q |= 1;
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
x64 = (uint64_t) q<<9;
|
||||
y[indexWord( 3, 0 )] = x64;
|
||||
x64 = ((uint64_t) qs[0]<<6) + (x64>>32);
|
||||
y[indexWord( 3, 1 )] = x64;
|
||||
y[indexWord( 3, 2 )] = (qs[1]<<3) + (x64>>32);
|
||||
softfloat_roundPackMToExtF80M(
|
||||
signZ, expZ, y, extF80_roundingPrecision, zSPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_invalidExtF80M( zSPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
infinity:
|
||||
uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
|
||||
uiZ0 = UINT64_C( 0x8000000000000000 );
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
zero:
|
||||
uiZ64 = packToExtF80UI64( signZ, 0 );
|
||||
uiZ0 = 0;
|
||||
uiZ:
|
||||
zSPtr->signExp = uiZ64;
|
||||
zSPtr->signif = uiZ0;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
98
ext/softfloat/extF80M_eq.c
Normal file
98
ext/softfloat/extF80M_eq.c
Normal file
@@ -0,0 +1,98 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool extF80M_eq( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
|
||||
{
|
||||
|
||||
return extF80_eq( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool extF80M_eq( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
uint64_t uiA0;
|
||||
uint_fast16_t uiB64;
|
||||
uint64_t uiB0;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
uiA0 = aSPtr->signif;
|
||||
uiB64 = bSPtr->signExp;
|
||||
uiB0 = bSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
if (
|
||||
softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
|
||||
|| softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
|
||||
) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( uiA0 == uiB0 ) {
|
||||
return (uiA64 == uiB64) || ! uiA0;
|
||||
} else {
|
||||
if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
|
||||
return ! softfloat_compareNonnormExtF80M( aSPtr, bSPtr );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
92
ext/softfloat/extF80M_eq_signaling.c
Normal file
92
ext/softfloat/extF80M_eq_signaling.c
Normal file
@@ -0,0 +1,92 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool extF80M_eq_signaling( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
|
||||
{
|
||||
|
||||
return extF80_eq_signaling( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool extF80M_eq_signaling( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
uint64_t uiA0;
|
||||
uint_fast16_t uiB64;
|
||||
uint64_t uiB0;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
uiA0 = aSPtr->signif;
|
||||
uiB64 = bSPtr->signExp;
|
||||
uiB0 = bSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( uiA0 == uiB0 ) {
|
||||
return (uiA64 == uiB64) || ! uiA0;
|
||||
} else {
|
||||
if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
|
||||
return ! softfloat_compareNonnormExtF80M( aSPtr, bSPtr );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
106
ext/softfloat/extF80M_le.c
Normal file
106
ext/softfloat/extF80M_le.c
Normal file
@@ -0,0 +1,106 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool extF80M_le( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
|
||||
{
|
||||
|
||||
return extF80_le( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool extF80M_le( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
uint64_t uiA0;
|
||||
uint_fast16_t uiB64;
|
||||
uint64_t uiB0;
|
||||
bool signA, ltMags;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
uiA0 = aSPtr->signif;
|
||||
uiB64 = bSPtr->signExp;
|
||||
uiB0 = bSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
if ( (uiA64 ^ uiB64) & 0x8000 ) {
|
||||
/*--------------------------------------------------------------------
|
||||
| Signs are different.
|
||||
*--------------------------------------------------------------------*/
|
||||
return signA || ! (uiA0 | uiB0);
|
||||
} else {
|
||||
/*--------------------------------------------------------------------
|
||||
| Signs are the same.
|
||||
*--------------------------------------------------------------------*/
|
||||
if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
|
||||
return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) <= 0);
|
||||
}
|
||||
if ( uiA64 == uiB64 ) {
|
||||
if ( uiA0 == uiB0 ) return true;
|
||||
ltMags = (uiA0 < uiB0);
|
||||
} else {
|
||||
ltMags = (uiA64 < uiB64);
|
||||
}
|
||||
return signA ^ ltMags;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
112
ext/softfloat/extF80M_le_quiet.c
Normal file
112
ext/softfloat/extF80M_le_quiet.c
Normal file
@@ -0,0 +1,112 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool extF80M_le_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
|
||||
{
|
||||
|
||||
return extF80_le_quiet( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool extF80M_le_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
uint64_t uiA0;
|
||||
uint_fast16_t uiB64;
|
||||
uint64_t uiB0;
|
||||
bool signA, ltMags;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
uiA0 = aSPtr->signif;
|
||||
uiB64 = bSPtr->signExp;
|
||||
uiB0 = bSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
if (
|
||||
softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
|
||||
|| softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
|
||||
) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
if ( (uiA64 ^ uiB64) & 0x8000 ) {
|
||||
/*--------------------------------------------------------------------
|
||||
| Signs are different.
|
||||
*--------------------------------------------------------------------*/
|
||||
return signA || ! (uiA0 | uiB0);
|
||||
} else {
|
||||
/*--------------------------------------------------------------------
|
||||
| Signs are the same.
|
||||
*--------------------------------------------------------------------*/
|
||||
if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
|
||||
return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) <= 0);
|
||||
}
|
||||
if ( uiA64 == uiB64 ) {
|
||||
if ( uiA0 == uiB0 ) return true;
|
||||
ltMags = (uiA0 < uiB0);
|
||||
} else {
|
||||
ltMags = (uiA64 < uiB64);
|
||||
}
|
||||
return signA ^ ltMags;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
106
ext/softfloat/extF80M_lt.c
Normal file
106
ext/softfloat/extF80M_lt.c
Normal file
@@ -0,0 +1,106 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool extF80M_lt( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
|
||||
{
|
||||
|
||||
return extF80_lt( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool extF80M_lt( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
uint64_t uiA0;
|
||||
uint_fast16_t uiB64;
|
||||
uint64_t uiB0;
|
||||
bool signA, ltMags;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
uiA0 = aSPtr->signif;
|
||||
uiB64 = bSPtr->signExp;
|
||||
uiB0 = bSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
if ( (uiA64 ^ uiB64) & 0x8000 ) {
|
||||
/*--------------------------------------------------------------------
|
||||
| Signs are different.
|
||||
*--------------------------------------------------------------------*/
|
||||
return signA && ((uiA0 | uiB0) != 0);
|
||||
} else {
|
||||
/*--------------------------------------------------------------------
|
||||
| Signs are the same.
|
||||
*--------------------------------------------------------------------*/
|
||||
if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
|
||||
return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) < 0);
|
||||
}
|
||||
if ( uiA64 == uiB64 ) {
|
||||
if ( uiA0 == uiB0 ) return false;
|
||||
ltMags = (uiA0 < uiB0);
|
||||
} else {
|
||||
ltMags = (uiA64 < uiB64);
|
||||
}
|
||||
return signA ^ ltMags;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
112
ext/softfloat/extF80M_lt_quiet.c
Normal file
112
ext/softfloat/extF80M_lt_quiet.c
Normal file
@@ -0,0 +1,112 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool extF80M_lt_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
|
||||
{
|
||||
|
||||
return extF80_lt_quiet( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool extF80M_lt_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
uint64_t uiA0;
|
||||
uint_fast16_t uiB64;
|
||||
uint64_t uiB0;
|
||||
bool signA, ltMags;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
uiA0 = aSPtr->signif;
|
||||
uiB64 = bSPtr->signExp;
|
||||
uiB0 = bSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
if (
|
||||
softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
|
||||
|| softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
|
||||
) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
if ( (uiA64 ^ uiB64) & 0x8000 ) {
|
||||
/*--------------------------------------------------------------------
|
||||
| Signs are different.
|
||||
*--------------------------------------------------------------------*/
|
||||
return signA && ((uiA0 | uiB0) != 0);
|
||||
} else {
|
||||
/*--------------------------------------------------------------------
|
||||
| Signs are the same.
|
||||
*--------------------------------------------------------------------*/
|
||||
if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
|
||||
return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) < 0);
|
||||
}
|
||||
if ( uiA64 == uiB64 ) {
|
||||
if ( uiA0 == uiB0 ) return false;
|
||||
ltMags = (uiA0 < uiB0);
|
||||
} else {
|
||||
ltMags = (uiA64 < uiB64);
|
||||
}
|
||||
return signA ^ ltMags;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
139
ext/softfloat/extF80M_mul.c
Normal file
139
ext/softfloat/extF80M_mul.c
Normal file
@@ -0,0 +1,139 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
extF80M_mul(
|
||||
const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = extF80_mul( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
extF80M_mul(
|
||||
const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
struct extFloat80M *zSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
int32_t expA;
|
||||
uint_fast16_t uiB64;
|
||||
int32_t expB;
|
||||
bool signZ;
|
||||
uint_fast16_t exp, uiZ64;
|
||||
uint64_t uiZ0, sigA, sigB;
|
||||
int32_t expZ;
|
||||
uint32_t sigProd[4], *extSigZPtr;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
zSPtr = (struct extFloat80M *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
expA = expExtF80UI64( uiA64 );
|
||||
uiB64 = bSPtr->signExp;
|
||||
expB = expExtF80UI64( uiB64 );
|
||||
signZ = signExtF80UI64( uiA64 ) ^ signExtF80UI64( uiB64 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
|
||||
if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
|
||||
if (
|
||||
(! aSPtr->signif && (expA != 0x7FFF))
|
||||
|| (! bSPtr->signif && (expB != 0x7FFF))
|
||||
) {
|
||||
softfloat_invalidExtF80M( zSPtr );
|
||||
return;
|
||||
}
|
||||
uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
|
||||
uiZ0 = UINT64_C( 0x8000000000000000 );
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! expA ) expA = 1;
|
||||
sigA = aSPtr->signif;
|
||||
if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigA ) goto zero;
|
||||
expA += softfloat_normExtF80SigM( &sigA );
|
||||
}
|
||||
if ( ! expB ) expB = 1;
|
||||
sigB = bSPtr->signif;
|
||||
if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigB ) goto zero;
|
||||
expB += softfloat_normExtF80SigM( &sigB );
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = expA + expB - 0x3FFE;
|
||||
softfloat_mul64To128M( sigA, sigB, sigProd );
|
||||
if ( sigProd[indexWordLo( 4 )] ) sigProd[indexWord( 4, 1 )] |= 1;
|
||||
extSigZPtr = &sigProd[indexMultiwordHi( 4, 3 )];
|
||||
if ( sigProd[indexWordHi( 4 )] < 0x80000000 ) {
|
||||
--expZ;
|
||||
softfloat_add96M( extSigZPtr, extSigZPtr, extSigZPtr );
|
||||
}
|
||||
softfloat_roundPackMToExtF80M(
|
||||
signZ, expZ, extSigZPtr, extF80_roundingPrecision, zSPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
zero:
|
||||
uiZ64 = packToExtF80UI64( signZ, 0 );
|
||||
uiZ0 = 0;
|
||||
uiZ:
|
||||
zSPtr->signExp = uiZ64;
|
||||
zSPtr->signif = uiZ0;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
204
ext/softfloat/extF80M_rem.c
Normal file
204
ext/softfloat/extF80M_rem.c
Normal file
@@ -0,0 +1,204 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
extF80M_rem(
|
||||
const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = extF80_rem( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
extF80M_rem(
|
||||
const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
struct extFloat80M *zSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
int32_t expA, expB;
|
||||
uint64_t x64;
|
||||
bool signRem;
|
||||
uint64_t sigA;
|
||||
int32_t expDiff;
|
||||
uint32_t rem[3], x[3], sig32B, q, recip32, rem2[3], *remPtr, *altRemPtr;
|
||||
uint32_t *newRemPtr, wordMeanRem;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
zSPtr = (struct extFloat80M *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
expA = expExtF80UI64( uiA64 );
|
||||
expB = expExtF80UI64( bSPtr->signExp );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
|
||||
if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
|
||||
if ( expA == 0x7FFF ) goto invalid;
|
||||
/*--------------------------------------------------------------------
|
||||
| If we get here, then argument b is an infinity and `expB' is 0x7FFF;
|
||||
| Doubling `expB' is an easy way to ensure that `expDiff' later is
|
||||
| less than -1, which will result in returning a canonicalized version
|
||||
| of argument a.
|
||||
*--------------------------------------------------------------------*/
|
||||
expB += expB;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! expB ) expB = 1;
|
||||
x64 = bSPtr->signif;
|
||||
if ( ! (x64 & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! x64 ) goto invalid;
|
||||
expB += softfloat_normExtF80SigM( &x64 );
|
||||
}
|
||||
signRem = signExtF80UI64( uiA64 );
|
||||
if ( ! expA ) expA = 1;
|
||||
sigA = aSPtr->signif;
|
||||
if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigA ) {
|
||||
expA = 0;
|
||||
goto copyA;
|
||||
}
|
||||
expA += softfloat_normExtF80SigM( &sigA );
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expDiff = expA - expB;
|
||||
if ( expDiff < -1 ) goto copyA;
|
||||
rem[indexWord( 3, 2 )] = sigA>>34;
|
||||
rem[indexWord( 3, 1 )] = sigA>>2;
|
||||
rem[indexWord( 3, 0 )] = (uint32_t) sigA<<30;
|
||||
x[indexWord( 3, 0 )] = (uint32_t) x64<<30;
|
||||
sig32B = x64>>32;
|
||||
x64 >>= 2;
|
||||
x[indexWord( 3, 2 )] = x64>>32;
|
||||
x[indexWord( 3, 1 )] = x64;
|
||||
if ( expDiff < 1 ) {
|
||||
if ( expDiff ) {
|
||||
--expB;
|
||||
softfloat_add96M( x, x, x );
|
||||
q = 0;
|
||||
} else {
|
||||
q = (softfloat_compare96M( x, rem ) <= 0);
|
||||
if ( q ) softfloat_sub96M( rem, x, rem );
|
||||
}
|
||||
} else {
|
||||
recip32 = softfloat_approxRecip32_1( sig32B );
|
||||
expDiff -= 30;
|
||||
for (;;) {
|
||||
x64 = (uint64_t) rem[indexWordHi( 3 )] * recip32;
|
||||
if ( expDiff < 0 ) break;
|
||||
q = (x64 + 0x80000000)>>32;
|
||||
softfloat_remStep96MBy32( rem, 29, x, q, rem );
|
||||
if ( rem[indexWordHi( 3 )] & 0x80000000 ) {
|
||||
softfloat_add96M( rem, x, rem );
|
||||
}
|
||||
expDiff -= 29;
|
||||
}
|
||||
/*--------------------------------------------------------------------
|
||||
| (`expDiff' cannot be less than -29 here.)
|
||||
*--------------------------------------------------------------------*/
|
||||
q = (uint32_t) (x64>>32)>>(~expDiff & 31);
|
||||
softfloat_remStep96MBy32( rem, expDiff + 30, x, q, rem );
|
||||
if ( rem[indexWordHi( 3 )] & 0x80000000 ) {
|
||||
remPtr = rem;
|
||||
altRemPtr = rem2;
|
||||
softfloat_add96M( remPtr, x, altRemPtr );
|
||||
goto selectRem;
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
remPtr = rem;
|
||||
altRemPtr = rem2;
|
||||
do {
|
||||
++q;
|
||||
newRemPtr = altRemPtr;
|
||||
softfloat_sub96M( remPtr, x, newRemPtr );
|
||||
altRemPtr = remPtr;
|
||||
remPtr = newRemPtr;
|
||||
} while ( ! (remPtr[indexWordHi( 3 )] & 0x80000000) );
|
||||
selectRem:
|
||||
softfloat_add96M( remPtr, altRemPtr, x );
|
||||
wordMeanRem = x[indexWordHi( 3 )];
|
||||
if (
|
||||
(wordMeanRem & 0x80000000)
|
||||
|| (! wordMeanRem && (q & 1) && ! x[indexWord( 3, 0 )]
|
||||
&& ! x[indexWord( 3, 1 )])
|
||||
) {
|
||||
remPtr = altRemPtr;
|
||||
}
|
||||
if ( remPtr[indexWordHi( 3 )] & 0x80000000 ) {
|
||||
signRem = ! signRem;
|
||||
softfloat_negX96M( remPtr );
|
||||
}
|
||||
softfloat_normRoundPackMToExtF80M( signRem, expB + 2, remPtr, 80, zSPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_invalidExtF80M( zSPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
copyA:
|
||||
if ( expA < 1 ) {
|
||||
sigA >>= 1 - expA;
|
||||
expA = 0;
|
||||
}
|
||||
zSPtr->signExp = packToExtF80UI64( signRem, expA );
|
||||
zSPtr->signif = sigA;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
169
ext/softfloat/extF80M_roundToInt.c
Normal file
169
ext/softfloat/extF80M_roundToInt.c
Normal file
@@ -0,0 +1,169 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
extF80M_roundToInt(
|
||||
const extFloat80_t *aPtr,
|
||||
uint_fast8_t roundingMode,
|
||||
bool exact,
|
||||
extFloat80_t *zPtr
|
||||
)
|
||||
{
|
||||
|
||||
*zPtr = extF80_roundToInt( *aPtr, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
extF80M_roundToInt(
|
||||
const extFloat80_t *aPtr,
|
||||
uint_fast8_t roundingMode,
|
||||
bool exact,
|
||||
extFloat80_t *zPtr
|
||||
)
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
struct extFloat80M *zSPtr;
|
||||
uint_fast16_t uiA64, signUI64;
|
||||
int32_t exp;
|
||||
uint64_t sigA;
|
||||
uint_fast16_t uiZ64;
|
||||
uint64_t sigZ, lastBitMask, roundBitsMask;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
zSPtr = (struct extFloat80M *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
signUI64 = uiA64 & packToExtF80UI64( 1, 0 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sigA = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! (sigA & UINT64_C( 0x8000000000000000 )) && (exp != 0x7FFF) ) {
|
||||
if ( ! sigA ) {
|
||||
uiZ64 = signUI64;
|
||||
sigZ = 0;
|
||||
goto uiZ;
|
||||
}
|
||||
exp += softfloat_normExtF80SigM( &sigA );
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp <= 0x3FFE ) {
|
||||
if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
switch ( roundingMode ) {
|
||||
case softfloat_round_near_even:
|
||||
if ( ! (sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) break;
|
||||
case softfloat_round_near_maxMag:
|
||||
if ( exp == 0x3FFE ) goto mag1;
|
||||
break;
|
||||
case softfloat_round_min:
|
||||
if ( signUI64 ) goto mag1;
|
||||
break;
|
||||
case softfloat_round_max:
|
||||
if ( ! signUI64 ) goto mag1;
|
||||
break;
|
||||
}
|
||||
uiZ64 = signUI64;
|
||||
sigZ = 0;
|
||||
goto uiZ;
|
||||
mag1:
|
||||
uiZ64 = signUI64 | 0x3FFF;
|
||||
sigZ = UINT64_C( 0x8000000000000000 );
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( 0x403E <= exp ) {
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
softfloat_propagateNaNExtF80M( aSPtr, 0, zSPtr );
|
||||
return;
|
||||
}
|
||||
sigZ = UINT64_C( 0x8000000000000000 );
|
||||
} else {
|
||||
sigZ = sigA;
|
||||
}
|
||||
uiZ64 = signUI64 | exp;
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ64 = signUI64 | exp;
|
||||
lastBitMask = (uint64_t) 1<<(0x403E - exp);
|
||||
roundBitsMask = lastBitMask - 1;
|
||||
sigZ = sigA;
|
||||
if ( roundingMode == softfloat_round_near_maxMag ) {
|
||||
sigZ += lastBitMask>>1;
|
||||
} else if ( roundingMode == softfloat_round_near_even ) {
|
||||
sigZ += lastBitMask>>1;
|
||||
if ( ! (sigZ & roundBitsMask) ) sigZ &= ~lastBitMask;
|
||||
} else if (
|
||||
roundingMode == (signUI64 ? softfloat_round_min : softfloat_round_max)
|
||||
) {
|
||||
sigZ += roundBitsMask;
|
||||
}
|
||||
sigZ &= ~roundBitsMask;
|
||||
if ( ! sigZ ) {
|
||||
++uiZ64;
|
||||
sigZ = UINT64_C( 0x8000000000000000 );
|
||||
}
|
||||
if ( exact && (sigZ != sigA) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
uiZ:
|
||||
zSPtr->signExp = uiZ64;
|
||||
zSPtr->signif = sigZ;
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
180
ext/softfloat/extF80M_sqrt.c
Normal file
180
ext/softfloat/extF80M_sqrt.c
Normal file
@@ -0,0 +1,180 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void extF80M_sqrt( const extFloat80_t *aPtr, extFloat80_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = extF80_sqrt( *aPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void extF80M_sqrt( const extFloat80_t *aPtr, extFloat80_t *zPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
struct extFloat80M *zSPtr;
|
||||
uint_fast16_t uiA64, signUI64;
|
||||
int32_t expA;
|
||||
uint64_t rem64;
|
||||
int32_t expZ;
|
||||
uint32_t rem96[3], sig32A, recipSqrt32, sig32Z, q;
|
||||
uint64_t sig64Z, x64;
|
||||
uint32_t rem32, term[4], rem[4], extSigZ[3];
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
zSPtr = (struct extFloat80M *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
signUI64 = uiA64 & packToExtF80UI64( 1, 0 );
|
||||
expA = expExtF80UI64( uiA64 );
|
||||
rem64 = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( expA == 0x7FFF ) {
|
||||
if ( rem64 & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
softfloat_propagateNaNExtF80M( aSPtr, 0, zSPtr );
|
||||
return;
|
||||
}
|
||||
if ( signUI64 ) goto invalid;
|
||||
rem64 = UINT64_C( 0x8000000000000000 );
|
||||
goto copyA;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! expA ) expA = 1;
|
||||
if ( ! (rem64 & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! rem64 ) {
|
||||
uiA64 = signUI64;
|
||||
goto copyA;
|
||||
}
|
||||
expA += softfloat_normExtF80SigM( &rem64 );
|
||||
}
|
||||
if ( signUI64 ) goto invalid;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = ((expA - 0x3FFF)>>1) + 0x3FFF;
|
||||
expA &= 1;
|
||||
softfloat_shortShiftLeft64To96M( rem64, 30 - expA, rem96 );
|
||||
sig32A = rem64>>32;
|
||||
recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
|
||||
sig32Z = ((uint64_t) sig32A * recipSqrt32)>>32;
|
||||
if ( expA ) sig32Z >>= 1;
|
||||
rem64 =
|
||||
((uint64_t) rem96[indexWord( 3, 2 )]<<32 | rem96[indexWord( 3, 1 )])
|
||||
- (uint64_t) sig32Z * sig32Z;
|
||||
rem96[indexWord( 3, 2 )] = rem64>>32;
|
||||
rem96[indexWord( 3, 1 )] = rem64;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
q = ((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32;
|
||||
sig64Z = ((uint64_t) sig32Z<<32) + ((uint64_t) q<<3);
|
||||
term[indexWord( 3, 2 )] = 0;
|
||||
/*------------------------------------------------------------------------
|
||||
| (Repeating this loop is a rare occurrence.)
|
||||
*------------------------------------------------------------------------*/
|
||||
for (;;) {
|
||||
x64 = ((uint64_t) sig32Z<<32) + sig64Z;
|
||||
term[indexWord( 3, 1 )] = x64>>32;
|
||||
term[indexWord( 3, 0 )] = x64;
|
||||
softfloat_remStep96MBy32(
|
||||
rem96, 29, term, q, &rem[indexMultiwordHi( 4, 3 )] );
|
||||
rem32 = rem[indexWord( 4, 3 )];
|
||||
if ( ! (rem32 & 0x80000000) ) break;
|
||||
--q;
|
||||
sig64Z -= 1<<3;
|
||||
}
|
||||
rem64 = (uint64_t) rem32<<32 | rem[indexWord( 4, 2 )];
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
q = (((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32) + 2;
|
||||
if ( rem64>>34 ) q += recipSqrt32;
|
||||
x64 = (uint64_t) q<<7;
|
||||
extSigZ[indexWord( 3, 0 )] = x64;
|
||||
x64 = (sig64Z<<1) + (x64>>32);
|
||||
extSigZ[indexWord( 3, 2 )] = x64>>32;
|
||||
extSigZ[indexWord( 3, 1 )] = x64;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (q & 0xFFFFFF) <= 2 ) {
|
||||
q &= ~(uint32_t) 0xFFFF;
|
||||
extSigZ[indexWordLo( 3 )] = q<<7;
|
||||
x64 = sig64Z + (q>>27);
|
||||
term[indexWord( 4, 3 )] = 0;
|
||||
term[indexWord( 4, 2 )] = x64>>32;
|
||||
term[indexWord( 4, 1 )] = x64;
|
||||
term[indexWord( 4, 0 )] = q<<5;
|
||||
rem[indexWord( 4, 0 )] = 0;
|
||||
softfloat_remStep128MBy32( rem, 28, term, q, rem );
|
||||
q = rem[indexWordHi( 4 )];
|
||||
if ( q & 0x80000000 ) {
|
||||
softfloat_sub1X96M( extSigZ );
|
||||
} else {
|
||||
if ( q || rem[indexWord( 4, 1 )] || rem[indexWord( 4, 2 )] ) {
|
||||
extSigZ[indexWordLo( 3 )] |= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
softfloat_roundPackMToExtF80M(
|
||||
0, expZ, extSigZ, extF80_roundingPrecision, zSPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_invalidExtF80M( zSPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
copyA:
|
||||
zSPtr->signExp = uiA64;
|
||||
zSPtr->signif = rem64;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
100
ext/softfloat/extF80M_sub.c
Normal file
100
ext/softfloat/extF80M_sub.c
Normal file
@@ -0,0 +1,100 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
extF80M_sub(
|
||||
const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool signA;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signB;
|
||||
#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
|
||||
extFloat80_t
|
||||
(*magsFuncPtr)(
|
||||
uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
|
||||
#endif
|
||||
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
uiA0 = aSPtr->signif;
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
uiB64 = bSPtr->signExp;
|
||||
uiB0 = bSPtr->signif;
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
||||
if ( signA == signB ) {
|
||||
*zPtr = softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
} else {
|
||||
*zPtr = softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
}
|
||||
#else
|
||||
magsFuncPtr =
|
||||
(signA == signB) ? softfloat_subMagsExtF80 : softfloat_addMagsExtF80;
|
||||
*zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
extF80M_sub(
|
||||
const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
|
||||
{
|
||||
|
||||
softfloat_addExtF80M(
|
||||
(const struct extFloat80M *) aPtr,
|
||||
(const struct extFloat80M *) bPtr,
|
||||
(struct extFloat80M *) zPtr,
|
||||
true
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
125
ext/softfloat/extF80M_to_f128M.c
Normal file
125
ext/softfloat/extF80M_to_f128M.c
Normal file
@@ -0,0 +1,125 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void extF80M_to_f128M( const extFloat80_t *aPtr, float128_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = extF80_to_f128( *aPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void extF80M_to_f128M( const extFloat80_t *aPtr, float128_t *zPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint32_t *zWPtr;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
struct commonNaN commonNaN;
|
||||
uint32_t uiZ96;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
zWPtr = (uint32_t *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
zWPtr[indexWord( 4, 0 )] = 0;
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
|
||||
softfloat_commonNaNToF128M( &commonNaN, zWPtr );
|
||||
return;
|
||||
}
|
||||
uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp ) --exp;
|
||||
if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sig ) {
|
||||
uiZ96 = packToF128UI96( sign, 0, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
exp += softfloat_normExtF80SigM( &sig );
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
zWPtr[indexWord( 4, 1 )] = (uint32_t) sig<<17;
|
||||
sig >>= 15;
|
||||
zWPtr[indexWord( 4, 2 )] = sig;
|
||||
if ( exp < 0 ) {
|
||||
zWPtr[indexWordHi( 4 )] = sig>>32;
|
||||
softfloat_shiftRight96M(
|
||||
&zWPtr[indexMultiwordHi( 4, 3 )],
|
||||
-exp,
|
||||
&zWPtr[indexMultiwordHi( 4, 3 )]
|
||||
);
|
||||
exp = 0;
|
||||
sig = (uint64_t) zWPtr[indexWordHi( 4 )]<<32;
|
||||
}
|
||||
zWPtr[indexWordHi( 4 )] = packToF128UI96( sign, exp, sig>>32 );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ:
|
||||
zWPtr[indexWord( 4, 3 )] = uiZ96;
|
||||
zWPtr[indexWord( 4, 2 )] = 0;
|
||||
zWPtr[indexWord( 4, 1 )] = 0;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
112
ext/softfloat/extF80M_to_f16.c
Normal file
112
ext/softfloat/extF80M_to_f16.c
Normal file
@@ -0,0 +1,112 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
float16_t extF80M_to_f16( const extFloat80_t *aPtr )
|
||||
{
|
||||
|
||||
return extF80_to_f16( *aPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
float16_t extF80M_to_f16( const extFloat80_t *aPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
struct commonNaN commonNaN;
|
||||
uint16_t uiZ, sig16;
|
||||
union ui16_f16 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
|
||||
uiZ = softfloat_commonNaNToF16UI( &commonNaN );
|
||||
} else {
|
||||
uiZ = packToF16UI( sign, 0x1F, 0 );
|
||||
}
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sig ) {
|
||||
uiZ = packToF16UI( sign, 0, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
exp += softfloat_normExtF80SigM( &sig );
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sig16 = softfloat_shortShiftRightJam64( sig, 49 );
|
||||
exp -= 0x3FF1;
|
||||
if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
|
||||
if ( exp < -0x40 ) exp = -0x40;
|
||||
}
|
||||
return softfloat_roundPackToF16( sign, exp, sig16 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
112
ext/softfloat/extF80M_to_f32.c
Normal file
112
ext/softfloat/extF80M_to_f32.c
Normal file
@@ -0,0 +1,112 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
float32_t extF80M_to_f32( const extFloat80_t *aPtr )
|
||||
{
|
||||
|
||||
return extF80_to_f32( *aPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
float32_t extF80M_to_f32( const extFloat80_t *aPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
struct commonNaN commonNaN;
|
||||
uint32_t uiZ, sig32;
|
||||
union ui32_f32 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
|
||||
uiZ = softfloat_commonNaNToF32UI( &commonNaN );
|
||||
} else {
|
||||
uiZ = packToF32UI( sign, 0xFF, 0 );
|
||||
}
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sig ) {
|
||||
uiZ = packToF32UI( sign, 0, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
exp += softfloat_normExtF80SigM( &sig );
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sig32 = softfloat_shortShiftRightJam64( sig, 33 );
|
||||
exp -= 0x3F81;
|
||||
if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
|
||||
if ( exp < -0x1000 ) exp = -0x1000;
|
||||
}
|
||||
return softfloat_roundPackToF32( sign, exp, sig32 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
112
ext/softfloat/extF80M_to_f64.c
Normal file
112
ext/softfloat/extF80M_to_f64.c
Normal file
@@ -0,0 +1,112 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
float64_t extF80M_to_f64( const extFloat80_t *aPtr )
|
||||
{
|
||||
|
||||
return extF80_to_f64( *aPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
float64_t extF80M_to_f64( const extFloat80_t *aPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
struct commonNaN commonNaN;
|
||||
uint64_t uiZ;
|
||||
union ui64_f64 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
|
||||
uiZ = softfloat_commonNaNToF64UI( &commonNaN );
|
||||
} else {
|
||||
uiZ = packToF64UI( sign, 0x7FF, 0 );
|
||||
}
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sig ) {
|
||||
uiZ = packToF64UI( sign, 0, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
exp += softfloat_normExtF80SigM( &sig );
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sig = softfloat_shortShiftRightJam64( sig, 1 );
|
||||
exp -= 0x3C01;
|
||||
if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
|
||||
if ( exp < -0x1000 ) exp = -0x1000;
|
||||
}
|
||||
return softfloat_roundPackToF64( sign, exp, sig );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
100
ext/softfloat/extF80M_to_i32.c
Normal file
100
ext/softfloat/extF80M_to_i32.c
Normal file
@@ -0,0 +1,100 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
int_fast32_t
|
||||
extF80M_to_i32(
|
||||
const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
|
||||
return extF80_to_i32( *aPtr, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int_fast32_t
|
||||
extF80M_to_i32(
|
||||
const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
int32_t shiftDist;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x4032 - exp;
|
||||
if ( shiftDist <= 0 ) {
|
||||
if ( sig>>32 ) goto invalid;
|
||||
if ( -32 < shiftDist ) {
|
||||
sig <<= -shiftDist;
|
||||
} else {
|
||||
if ( (uint32_t) sig ) goto invalid;
|
||||
}
|
||||
} else {
|
||||
sig = softfloat_shiftRightJam64( sig, shiftDist );
|
||||
}
|
||||
return softfloat_roundToI32( sign, sig, roundingMode, exact );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ? i32_fromNaN
|
||||
: sign ? i32_fromNegOverflow : i32_fromPosOverflow;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
120
ext/softfloat/extF80M_to_i32_r_minMag.c
Normal file
120
ext/softfloat/extF80M_to_i32_r_minMag.c
Normal file
@@ -0,0 +1,120 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
int_fast32_t extF80M_to_i32_r_minMag( const extFloat80_t *aPtr, bool exact )
|
||||
{
|
||||
|
||||
return extF80_to_i32_r_minMag( *aPtr, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int_fast32_t extF80M_to_i32_r_minMag( const extFloat80_t *aPtr, bool exact )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
int32_t shiftDist;
|
||||
bool sign, raiseInexact;
|
||||
int32_t z;
|
||||
uint64_t shiftedSig;
|
||||
uint32_t absZ;
|
||||
union { uint32_t ui; int32_t i; } u;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! sig && (exp != 0x7FFF) ) return 0;
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( 64 <= shiftDist ) {
|
||||
raiseInexact = exact;
|
||||
z = 0;
|
||||
} else {
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
raiseInexact = false;
|
||||
if ( shiftDist < 0 ) {
|
||||
if ( sig>>32 || (shiftDist <= -31) ) goto invalid;
|
||||
shiftedSig = (uint64_t) (uint32_t) sig<<-shiftDist;
|
||||
if ( shiftedSig>>32 ) goto invalid;
|
||||
absZ = shiftedSig;
|
||||
} else {
|
||||
shiftedSig = sig;
|
||||
if ( shiftDist ) shiftedSig >>= shiftDist;
|
||||
if ( shiftedSig>>32 ) goto invalid;
|
||||
absZ = shiftedSig;
|
||||
if ( exact && shiftDist ) {
|
||||
raiseInexact = ((uint64_t) absZ<<shiftDist != sig);
|
||||
}
|
||||
}
|
||||
if ( sign ) {
|
||||
if ( 0x80000000 < absZ ) goto invalid;
|
||||
u.ui = -absZ;
|
||||
z = u.i;
|
||||
} else {
|
||||
if ( 0x80000000 <= absZ ) goto invalid;
|
||||
z = absZ;
|
||||
}
|
||||
}
|
||||
if ( raiseInexact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
return z;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ? i32_fromNaN
|
||||
: sign ? i32_fromNegOverflow : i32_fromPosOverflow;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
97
ext/softfloat/extF80M_to_i64.c
Normal file
97
ext/softfloat/extF80M_to_i64.c
Normal file
@@ -0,0 +1,97 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
int_fast64_t
|
||||
extF80M_to_i64(
|
||||
const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
|
||||
return extF80_to_i64( *aPtr, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int_fast64_t
|
||||
extF80M_to_i64(
|
||||
const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
int32_t shiftDist;
|
||||
uint32_t extSig[3];
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( shiftDist < 0 ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? i64_fromNaN
|
||||
: sign ? i64_fromNegOverflow : i64_fromPosOverflow;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
extSig[indexWord( 3, 2 )] = sig>>32;
|
||||
extSig[indexWord( 3, 1 )] = sig;
|
||||
extSig[indexWord( 3, 0 )] = 0;
|
||||
if ( shiftDist ) softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
|
||||
return softfloat_roundMToI64( sign, extSig, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
115
ext/softfloat/extF80M_to_i64_r_minMag.c
Normal file
115
ext/softfloat/extF80M_to_i64_r_minMag.c
Normal file
@@ -0,0 +1,115 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
int_fast64_t extF80M_to_i64_r_minMag( const extFloat80_t *aPtr, bool exact )
|
||||
{
|
||||
|
||||
return extF80_to_i64_r_minMag( *aPtr, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int_fast64_t extF80M_to_i64_r_minMag( const extFloat80_t *aPtr, bool exact )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
int32_t shiftDist;
|
||||
bool sign, raiseInexact;
|
||||
int64_t z;
|
||||
uint64_t absZ;
|
||||
union { uint64_t ui; int64_t i; } u;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! sig && (exp != 0x7FFF) ) return 0;
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( 64 <= shiftDist ) {
|
||||
raiseInexact = exact;
|
||||
z = 0;
|
||||
} else {
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
raiseInexact = false;
|
||||
if ( shiftDist < 0 ) {
|
||||
if ( shiftDist <= -63 ) goto invalid;
|
||||
shiftDist = -shiftDist;
|
||||
absZ = sig<<shiftDist;
|
||||
if ( absZ>>shiftDist != sig ) goto invalid;
|
||||
} else {
|
||||
absZ = sig;
|
||||
if ( shiftDist ) absZ >>= shiftDist;
|
||||
if ( exact && shiftDist ) raiseInexact = (absZ<<shiftDist != sig);
|
||||
}
|
||||
if ( sign ) {
|
||||
if ( UINT64_C( 0x8000000000000000 ) < absZ ) goto invalid;
|
||||
u.ui = -absZ;
|
||||
z = u.i;
|
||||
} else {
|
||||
if ( UINT64_C( 0x8000000000000000 ) <= absZ ) goto invalid;
|
||||
z = absZ;
|
||||
}
|
||||
}
|
||||
if ( raiseInexact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
return z;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ? i64_fromNaN
|
||||
: sign ? i64_fromNegOverflow : i64_fromPosOverflow;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
101
ext/softfloat/extF80M_to_ui32.c
Normal file
101
ext/softfloat/extF80M_to_ui32.c
Normal file
@@ -0,0 +1,101 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
uint_fast32_t
|
||||
extF80M_to_ui32(
|
||||
const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
|
||||
return extF80_to_ui32( *aPtr, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
uint_fast32_t
|
||||
extF80M_to_ui32(
|
||||
const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
int32_t shiftDist;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x4032 - exp;
|
||||
if ( shiftDist <= 0 ) {
|
||||
if ( sig>>32 ) goto invalid;
|
||||
if ( -32 < shiftDist ) {
|
||||
sig <<= -shiftDist;
|
||||
} else {
|
||||
if ( (uint32_t) sig ) goto invalid;
|
||||
}
|
||||
} else {
|
||||
sig = softfloat_shiftRightJam64( sig, shiftDist );
|
||||
}
|
||||
return softfloat_roundToUI32( sign, sig, roundingMode, exact );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? ui32_fromNaN
|
||||
: sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
111
ext/softfloat/extF80M_to_ui32_r_minMag.c
Normal file
111
ext/softfloat/extF80M_to_ui32_r_minMag.c
Normal file
@@ -0,0 +1,111 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
uint_fast32_t extF80M_to_ui32_r_minMag( const extFloat80_t *aPtr, bool exact )
|
||||
{
|
||||
|
||||
return extF80_to_ui32_r_minMag( *aPtr, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
uint_fast32_t extF80M_to_ui32_r_minMag( const extFloat80_t *aPtr, bool exact )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
int32_t shiftDist;
|
||||
bool sign;
|
||||
uint64_t shiftedSig;
|
||||
uint32_t z;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! sig && (exp != 0x7FFF) ) return 0;
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( 64 <= shiftDist ) {
|
||||
if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
if ( shiftDist < 0 ) {
|
||||
if ( sign || sig>>32 || (shiftDist <= -31) ) goto invalid;
|
||||
shiftedSig = (uint64_t) (uint32_t) sig<<-shiftDist;
|
||||
if ( shiftedSig>>32 ) goto invalid;
|
||||
z = shiftedSig;
|
||||
} else {
|
||||
shiftedSig = sig;
|
||||
if ( shiftDist ) shiftedSig >>= shiftDist;
|
||||
if ( shiftedSig>>32 ) goto invalid;
|
||||
z = shiftedSig;
|
||||
if ( sign && z ) goto invalid;
|
||||
if ( exact && shiftDist && ((uint64_t) z<<shiftDist != sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
}
|
||||
return z;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? ui32_fromNaN
|
||||
: sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
97
ext/softfloat/extF80M_to_ui64.c
Normal file
97
ext/softfloat/extF80M_to_ui64.c
Normal file
@@ -0,0 +1,97 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
uint_fast64_t
|
||||
extF80M_to_ui64(
|
||||
const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
|
||||
return extF80_to_ui64( *aPtr, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
uint_fast64_t
|
||||
extF80M_to_ui64(
|
||||
const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
int32_t shiftDist;
|
||||
uint32_t extSig[3];
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( shiftDist < 0 ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? ui64_fromNaN
|
||||
: sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
extSig[indexWord( 3, 2 )] = sig>>32;
|
||||
extSig[indexWord( 3, 1 )] = sig;
|
||||
extSig[indexWord( 3, 0 )] = 0;
|
||||
if ( shiftDist ) softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
|
||||
return softfloat_roundMToUI64( sign, extSig, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
108
ext/softfloat/extF80M_to_ui64_r_minMag.c
Normal file
108
ext/softfloat/extF80M_to_ui64_r_minMag.c
Normal file
@@ -0,0 +1,108 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
uint_fast64_t extF80M_to_ui64_r_minMag( const extFloat80_t *aPtr, bool exact )
|
||||
{
|
||||
|
||||
return extF80_to_ui64_r_minMag( *aPtr, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
uint_fast64_t extF80M_to_ui64_r_minMag( const extFloat80_t *aPtr, bool exact )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
int32_t shiftDist;
|
||||
bool sign;
|
||||
uint64_t z;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! sig && (exp != 0x7FFF) ) return 0;
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( 64 <= shiftDist ) {
|
||||
if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
if ( shiftDist < 0 ) {
|
||||
if ( sign || (shiftDist <= -63) ) goto invalid;
|
||||
shiftDist = -shiftDist;
|
||||
z = sig<<shiftDist;
|
||||
if ( z>>shiftDist != sig ) goto invalid;
|
||||
} else {
|
||||
z = sig;
|
||||
if ( shiftDist ) z >>= shiftDist;
|
||||
if ( sign && z ) goto invalid;
|
||||
if ( exact && shiftDist && (z<<shiftDist != sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
}
|
||||
return z;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? ui64_fromNaN
|
||||
: sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
80
ext/softfloat/extF80_add.c
Normal file
80
ext/softfloat/extF80_add.c
Normal file
@@ -0,0 +1,80 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
extFloat80_t extF80_add( extFloat80_t a, extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool signA;
|
||||
union { struct extFloat80M s; extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signB;
|
||||
#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
|
||||
extFloat80_t
|
||||
(*magsFuncPtr)(
|
||||
uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
|
||||
#endif
|
||||
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
||||
if ( signA == signB ) {
|
||||
return softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
} else {
|
||||
return softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
}
|
||||
#else
|
||||
magsFuncPtr =
|
||||
(signA == signB) ? softfloat_addMagsExtF80 : softfloat_subMagsExtF80;
|
||||
return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
203
ext/softfloat/extF80_div.c
Normal file
203
ext/softfloat/extF80_div.c
Normal file
@@ -0,0 +1,203 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
extFloat80_t extF80_div( extFloat80_t a, extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool signA;
|
||||
int_fast32_t expA;
|
||||
uint_fast64_t sigA;
|
||||
union { struct extFloat80M s; extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signB;
|
||||
int_fast32_t expB;
|
||||
uint_fast64_t sigB;
|
||||
bool signZ;
|
||||
struct exp32_sig64 normExpSig;
|
||||
int_fast32_t expZ;
|
||||
struct uint128 rem;
|
||||
uint_fast32_t recip32;
|
||||
uint_fast64_t sigZ;
|
||||
int ix;
|
||||
uint_fast64_t q64;
|
||||
uint_fast32_t q;
|
||||
struct uint128 term;
|
||||
uint_fast64_t sigZExtra;
|
||||
struct uint128 uiZ;
|
||||
uint_fast16_t uiZ64;
|
||||
uint_fast64_t uiZ0;
|
||||
union { struct extFloat80M s; extFloat80_t f; } uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
expA = expExtF80UI64( uiA64 );
|
||||
sigA = uiA0;
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
expB = expExtF80UI64( uiB64 );
|
||||
sigB = uiB0;
|
||||
signZ = signA ^ signB;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( expA == 0x7FFF ) {
|
||||
if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
|
||||
if ( expB == 0x7FFF ) {
|
||||
if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
|
||||
goto invalid;
|
||||
}
|
||||
goto infinity;
|
||||
}
|
||||
if ( expB == 0x7FFF ) {
|
||||
if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
|
||||
goto zero;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! expB ) expB = 1;
|
||||
if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigB ) {
|
||||
if ( ! sigA ) goto invalid;
|
||||
softfloat_raiseFlags( softfloat_flag_infinite );
|
||||
goto infinity;
|
||||
}
|
||||
normExpSig = softfloat_normSubnormalExtF80Sig( sigB );
|
||||
expB += normExpSig.exp;
|
||||
sigB = normExpSig.sig;
|
||||
}
|
||||
if ( ! expA ) expA = 1;
|
||||
if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigA ) goto zero;
|
||||
normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
|
||||
expA += normExpSig.exp;
|
||||
sigA = normExpSig.sig;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = expA - expB + 0x3FFF;
|
||||
if ( sigA < sigB ) {
|
||||
--expZ;
|
||||
rem = softfloat_shortShiftLeft128( 0, sigA, 32 );
|
||||
} else {
|
||||
rem = softfloat_shortShiftLeft128( 0, sigA, 31 );
|
||||
}
|
||||
recip32 = softfloat_approxRecip32_1( sigB>>32 );
|
||||
sigZ = 0;
|
||||
ix = 2;
|
||||
for (;;) {
|
||||
q64 = (uint_fast64_t) (uint32_t) (rem.v64>>2) * recip32;
|
||||
q = (q64 + 0x80000000)>>32;
|
||||
--ix;
|
||||
if ( ix < 0 ) break;
|
||||
rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
|
||||
term = softfloat_mul64ByShifted32To128( sigB, q );
|
||||
rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
|
||||
if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
|
||||
--q;
|
||||
rem = softfloat_add128( rem.v64, rem.v0, sigB>>32, sigB<<32 );
|
||||
}
|
||||
sigZ = (sigZ<<29) + q;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ((q + 1) & 0x3FFFFF) < 2 ) {
|
||||
rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
|
||||
term = softfloat_mul64ByShifted32To128( sigB, q );
|
||||
rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
|
||||
term = softfloat_shortShiftLeft128( 0, sigB, 32 );
|
||||
if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
|
||||
--q;
|
||||
rem = softfloat_add128( rem.v64, rem.v0, term.v64, term.v0 );
|
||||
} else if ( softfloat_le128( term.v64, term.v0, rem.v64, rem.v0 ) ) {
|
||||
++q;
|
||||
rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
|
||||
}
|
||||
if ( rem.v64 | rem.v0 ) q |= 1;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sigZ = (sigZ<<6) + (q>>23);
|
||||
sigZExtra = (uint64_t) ((uint_fast64_t) q<<41);
|
||||
return
|
||||
softfloat_roundPackToExtF80(
|
||||
signZ, expZ, sigZ, sigZExtra, extF80_roundingPrecision );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
propagateNaN:
|
||||
uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
|
||||
uiZ64 = uiZ.v64;
|
||||
uiZ0 = uiZ.v0;
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
uiZ64 = defaultNaNExtF80UI64;
|
||||
uiZ0 = defaultNaNExtF80UI0;
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
infinity:
|
||||
uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
|
||||
uiZ0 = UINT64_C( 0x8000000000000000 );
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
zero:
|
||||
uiZ64 = packToExtF80UI64( signZ, 0 );
|
||||
uiZ0 = 0;
|
||||
uiZ:
|
||||
uZ.s.signExp = uiZ64;
|
||||
uZ.s.signif = uiZ0;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
73
ext/softfloat/extF80_eq.c
Normal file
73
ext/softfloat/extF80_eq.c
Normal file
@@ -0,0 +1,73 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool extF80_eq( extFloat80_t a, extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
union { struct extFloat80M s; extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
if (
|
||||
softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
|
||||
|| softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
|
||||
) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return
|
||||
(uiA0 == uiB0)
|
||||
&& ((uiA64 == uiB64) || (! uiA0 && ! ((uiA64 | uiB64) & 0x7FFF)));
|
||||
|
||||
}
|
||||
|
||||
67
ext/softfloat/extF80_eq_signaling.c
Normal file
67
ext/softfloat/extF80_eq_signaling.c
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool extF80_eq_signaling( extFloat80_t a, extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
union { struct extFloat80M s; extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
return
|
||||
(uiA0 == uiB0)
|
||||
&& ((uiA64 == uiB64) || (! uiA0 && ! ((uiA64 | uiB64) & 0x7FFF)));
|
||||
|
||||
}
|
||||
|
||||
51
ext/softfloat/extF80_isSignalingNaN.c
Normal file
51
ext/softfloat/extF80_isSignalingNaN.c
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool extF80_isSignalingNaN( extFloat80_t a )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
|
||||
uA.f = a;
|
||||
return softfloat_isSigNaNExtF80UI( uA.s.signExp, uA.s.signif );
|
||||
|
||||
}
|
||||
|
||||
73
ext/softfloat/extF80_le.c
Normal file
73
ext/softfloat/extF80_le.c
Normal file
@@ -0,0 +1,73 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool extF80_le( extFloat80_t a, extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
union { struct extFloat80M s; extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signA, signB;
|
||||
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
return
|
||||
(signA != signB)
|
||||
? signA || ! (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
|
||||
: ((uiA64 == uiB64) && (uiA0 == uiB0))
|
||||
|| (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
|
||||
|
||||
}
|
||||
|
||||
78
ext/softfloat/extF80_le_quiet.c
Normal file
78
ext/softfloat/extF80_le_quiet.c
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool extF80_le_quiet( extFloat80_t a, extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
union { struct extFloat80M s; extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signA, signB;
|
||||
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
if (
|
||||
softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
|
||||
|| softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
|
||||
) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
return
|
||||
(signA != signB)
|
||||
? signA || ! (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
|
||||
: ((uiA64 == uiB64) && (uiA0 == uiB0))
|
||||
|| (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
|
||||
|
||||
}
|
||||
|
||||
73
ext/softfloat/extF80_lt.c
Normal file
73
ext/softfloat/extF80_lt.c
Normal file
@@ -0,0 +1,73 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool extF80_lt( extFloat80_t a, extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
union { struct extFloat80M s; extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signA, signB;
|
||||
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
return
|
||||
(signA != signB)
|
||||
? signA && (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
|
||||
: ((uiA64 != uiB64) || (uiA0 != uiB0))
|
||||
&& (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
|
||||
|
||||
}
|
||||
|
||||
78
ext/softfloat/extF80_lt_quiet.c
Normal file
78
ext/softfloat/extF80_lt_quiet.c
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool extF80_lt_quiet( extFloat80_t a, extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
union { struct extFloat80M s; extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signA, signB;
|
||||
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
if (
|
||||
softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
|
||||
|| softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
|
||||
) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
return
|
||||
(signA != signB)
|
||||
? signA && (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
|
||||
: ((uiA64 != uiB64) || (uiA0 != uiB0))
|
||||
&& (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
|
||||
|
||||
}
|
||||
|
||||
158
ext/softfloat/extF80_mul.c
Normal file
158
ext/softfloat/extF80_mul.c
Normal file
@@ -0,0 +1,158 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
extFloat80_t extF80_mul( extFloat80_t a, extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool signA;
|
||||
int_fast32_t expA;
|
||||
uint_fast64_t sigA;
|
||||
union { struct extFloat80M s; extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signB;
|
||||
int_fast32_t expB;
|
||||
uint_fast64_t sigB;
|
||||
bool signZ;
|
||||
uint_fast64_t magBits;
|
||||
struct exp32_sig64 normExpSig;
|
||||
int_fast32_t expZ;
|
||||
struct uint128 sig128Z, uiZ;
|
||||
uint_fast16_t uiZ64;
|
||||
uint_fast64_t uiZ0;
|
||||
union { struct extFloat80M s; extFloat80_t f; } uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
expA = expExtF80UI64( uiA64 );
|
||||
sigA = uiA0;
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
expB = expExtF80UI64( uiB64 );
|
||||
sigB = uiB0;
|
||||
signZ = signA ^ signB;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( expA == 0x7FFF ) {
|
||||
if (
|
||||
(sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
|| ((expB == 0x7FFF) && (sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
|
||||
) {
|
||||
goto propagateNaN;
|
||||
}
|
||||
magBits = expB | sigB;
|
||||
goto infArg;
|
||||
}
|
||||
if ( expB == 0x7FFF ) {
|
||||
if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
|
||||
magBits = expA | sigA;
|
||||
goto infArg;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! expA ) expA = 1;
|
||||
if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigA ) goto zero;
|
||||
normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
|
||||
expA += normExpSig.exp;
|
||||
sigA = normExpSig.sig;
|
||||
}
|
||||
if ( ! expB ) expB = 1;
|
||||
if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigB ) goto zero;
|
||||
normExpSig = softfloat_normSubnormalExtF80Sig( sigB );
|
||||
expB += normExpSig.exp;
|
||||
sigB = normExpSig.sig;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = expA + expB - 0x3FFE;
|
||||
sig128Z = softfloat_mul64To128( sigA, sigB );
|
||||
if ( sig128Z.v64 < UINT64_C( 0x8000000000000000 ) ) {
|
||||
--expZ;
|
||||
sig128Z =
|
||||
softfloat_add128(
|
||||
sig128Z.v64, sig128Z.v0, sig128Z.v64, sig128Z.v0 );
|
||||
}
|
||||
return
|
||||
softfloat_roundPackToExtF80(
|
||||
signZ, expZ, sig128Z.v64, sig128Z.v0, extF80_roundingPrecision );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
propagateNaN:
|
||||
uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
|
||||
uiZ64 = uiZ.v64;
|
||||
uiZ0 = uiZ.v0;
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
infArg:
|
||||
if ( ! magBits ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
uiZ64 = defaultNaNExtF80UI64;
|
||||
uiZ0 = defaultNaNExtF80UI0;
|
||||
} else {
|
||||
uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
|
||||
uiZ0 = UINT64_C( 0x8000000000000000 );
|
||||
}
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
zero:
|
||||
uiZ64 = packToExtF80UI64( signZ, 0 );
|
||||
uiZ0 = 0;
|
||||
uiZ:
|
||||
uZ.s.signExp = uiZ64;
|
||||
uZ.s.signif = uiZ0;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
225
ext/softfloat/extF80_rem.c
Normal file
225
ext/softfloat/extF80_rem.c
Normal file
@@ -0,0 +1,225 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
extFloat80_t extF80_rem( extFloat80_t a, extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool signA;
|
||||
int_fast32_t expA;
|
||||
uint_fast64_t sigA;
|
||||
union { struct extFloat80M s; extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
int_fast32_t expB;
|
||||
uint_fast64_t sigB;
|
||||
struct exp32_sig64 normExpSig;
|
||||
int_fast32_t expDiff;
|
||||
struct uint128 rem, shiftedSigB;
|
||||
uint_fast32_t q, recip32;
|
||||
uint_fast64_t q64;
|
||||
struct uint128 term, altRem, meanRem;
|
||||
bool signRem;
|
||||
struct uint128 uiZ;
|
||||
uint_fast16_t uiZ64;
|
||||
uint_fast64_t uiZ0;
|
||||
union { struct extFloat80M s; extFloat80_t f; } uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
expA = expExtF80UI64( uiA64 );
|
||||
sigA = uiA0;
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
expB = expExtF80UI64( uiB64 );
|
||||
sigB = uiB0;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( expA == 0x7FFF ) {
|
||||
if (
|
||||
(sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
|| ((expB == 0x7FFF) && (sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
|
||||
) {
|
||||
goto propagateNaN;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if ( expB == 0x7FFF ) {
|
||||
if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
|
||||
/*--------------------------------------------------------------------
|
||||
| Argument b is an infinity. Doubling `expB' is an easy way to ensure
|
||||
| that `expDiff' later is less than -1, which will result in returning
|
||||
| a canonicalized version of argument a.
|
||||
*--------------------------------------------------------------------*/
|
||||
expB += expB;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! expB ) expB = 1;
|
||||
if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigB ) goto invalid;
|
||||
normExpSig = softfloat_normSubnormalExtF80Sig( sigB );
|
||||
expB += normExpSig.exp;
|
||||
sigB = normExpSig.sig;
|
||||
}
|
||||
if ( ! expA ) expA = 1;
|
||||
if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigA ) {
|
||||
expA = 0;
|
||||
goto copyA;
|
||||
}
|
||||
normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
|
||||
expA += normExpSig.exp;
|
||||
sigA = normExpSig.sig;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expDiff = expA - expB;
|
||||
if ( expDiff < -1 ) goto copyA;
|
||||
rem = softfloat_shortShiftLeft128( 0, sigA, 32 );
|
||||
shiftedSigB = softfloat_shortShiftLeft128( 0, sigB, 32 );
|
||||
if ( expDiff < 1 ) {
|
||||
if ( expDiff ) {
|
||||
--expB;
|
||||
shiftedSigB = softfloat_shortShiftLeft128( 0, sigB, 33 );
|
||||
q = 0;
|
||||
} else {
|
||||
q = (sigB <= sigA);
|
||||
if ( q ) {
|
||||
rem =
|
||||
softfloat_sub128(
|
||||
rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
recip32 = softfloat_approxRecip32_1( sigB>>32 );
|
||||
expDiff -= 30;
|
||||
for (;;) {
|
||||
q64 = (uint_fast64_t) (uint32_t) (rem.v64>>2) * recip32;
|
||||
if ( expDiff < 0 ) break;
|
||||
q = (q64 + 0x80000000)>>32;
|
||||
rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
|
||||
term = softfloat_mul64ByShifted32To128( sigB, q );
|
||||
rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
|
||||
if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
|
||||
rem =
|
||||
softfloat_add128(
|
||||
rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
|
||||
}
|
||||
expDiff -= 29;
|
||||
}
|
||||
/*--------------------------------------------------------------------
|
||||
| (`expDiff' cannot be less than -29 here.)
|
||||
*--------------------------------------------------------------------*/
|
||||
q = (uint32_t) (q64>>32)>>(~expDiff & 31);
|
||||
rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, expDiff + 30 );
|
||||
term = softfloat_mul64ByShifted32To128( sigB, q );
|
||||
rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
|
||||
if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
|
||||
altRem =
|
||||
softfloat_add128(
|
||||
rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
|
||||
goto selectRem;
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
do {
|
||||
altRem = rem;
|
||||
++q;
|
||||
rem =
|
||||
softfloat_sub128(
|
||||
rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
|
||||
} while ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) );
|
||||
selectRem:
|
||||
meanRem = softfloat_add128( rem.v64, rem.v0, altRem.v64, altRem.v0 );
|
||||
if (
|
||||
(meanRem.v64 & UINT64_C( 0x8000000000000000 ))
|
||||
|| (! (meanRem.v64 | meanRem.v0) && (q & 1))
|
||||
) {
|
||||
rem = altRem;
|
||||
}
|
||||
signRem = signA;
|
||||
if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
|
||||
signRem = ! signRem;
|
||||
rem = softfloat_sub128( 0, 0, rem.v64, rem.v0 );
|
||||
}
|
||||
return
|
||||
softfloat_normRoundPackToExtF80(
|
||||
signRem, rem.v64 | rem.v0 ? expB + 32 : 0, rem.v64, rem.v0, 80 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
propagateNaN:
|
||||
uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
|
||||
uiZ64 = uiZ.v64;
|
||||
uiZ0 = uiZ.v0;
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
uiZ64 = defaultNaNExtF80UI64;
|
||||
uiZ0 = defaultNaNExtF80UI0;
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
copyA:
|
||||
if ( expA < 1 ) {
|
||||
sigA >>= 1 - expA;
|
||||
expA = 0;
|
||||
}
|
||||
uiZ64 = packToExtF80UI64( signA, expA );
|
||||
uiZ0 = sigA;
|
||||
uiZ:
|
||||
uZ.s.signExp = uiZ64;
|
||||
uZ.s.signif = uiZ0;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
147
ext/softfloat/extF80_roundToInt.c
Normal file
147
ext/softfloat/extF80_roundToInt.c
Normal file
@@ -0,0 +1,147 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
extFloat80_t
|
||||
extF80_roundToInt( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64, signUI64;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sigA;
|
||||
uint_fast16_t uiZ64;
|
||||
uint_fast64_t sigZ;
|
||||
struct exp32_sig64 normExpSig;
|
||||
struct uint128 uiZ;
|
||||
uint_fast64_t lastBitMask, roundBitsMask;
|
||||
union { struct extFloat80M s; extFloat80_t f; } uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
signUI64 = uiA64 & packToExtF80UI64( 1, 0 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sigA = uA.s.signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! (sigA & UINT64_C( 0x8000000000000000 )) && (exp != 0x7FFF) ) {
|
||||
if ( ! sigA ) {
|
||||
uiZ64 = signUI64;
|
||||
sigZ = 0;
|
||||
goto uiZ;
|
||||
}
|
||||
normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
|
||||
exp += normExpSig.exp;
|
||||
sigA = normExpSig.sig;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( 0x403E <= exp ) {
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
uiZ = softfloat_propagateNaNExtF80UI( uiA64, sigA, 0, 0 );
|
||||
uiZ64 = uiZ.v64;
|
||||
sigZ = uiZ.v0;
|
||||
goto uiZ;
|
||||
}
|
||||
sigZ = UINT64_C( 0x8000000000000000 );
|
||||
} else {
|
||||
sigZ = sigA;
|
||||
}
|
||||
uiZ64 = signUI64 | exp;
|
||||
goto uiZ;
|
||||
}
|
||||
if ( exp <= 0x3FFE ) {
|
||||
if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
switch ( roundingMode ) {
|
||||
case softfloat_round_near_even:
|
||||
if ( ! (sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) break;
|
||||
case softfloat_round_near_maxMag:
|
||||
if ( exp == 0x3FFE ) goto mag1;
|
||||
break;
|
||||
case softfloat_round_min:
|
||||
if ( signUI64 ) goto mag1;
|
||||
break;
|
||||
case softfloat_round_max:
|
||||
if ( ! signUI64 ) goto mag1;
|
||||
break;
|
||||
}
|
||||
uiZ64 = signUI64;
|
||||
sigZ = 0;
|
||||
goto uiZ;
|
||||
mag1:
|
||||
uiZ64 = signUI64 | 0x3FFF;
|
||||
sigZ = UINT64_C( 0x8000000000000000 );
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ64 = signUI64 | exp;
|
||||
lastBitMask = (uint_fast64_t) 1<<(0x403E - exp);
|
||||
roundBitsMask = lastBitMask - 1;
|
||||
sigZ = sigA;
|
||||
if ( roundingMode == softfloat_round_near_maxMag ) {
|
||||
sigZ += lastBitMask>>1;
|
||||
} else if ( roundingMode == softfloat_round_near_even ) {
|
||||
sigZ += lastBitMask>>1;
|
||||
if ( ! (sigZ & roundBitsMask) ) sigZ &= ~lastBitMask;
|
||||
} else if (
|
||||
roundingMode == (signUI64 ? softfloat_round_min : softfloat_round_max)
|
||||
) {
|
||||
sigZ += roundBitsMask;
|
||||
}
|
||||
sigZ &= ~roundBitsMask;
|
||||
if ( ! sigZ ) {
|
||||
++uiZ64;
|
||||
sigZ = UINT64_C( 0x8000000000000000 );
|
||||
}
|
||||
if ( exact && (sigZ != sigA) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
uiZ:
|
||||
uZ.s.signExp = uiZ64;
|
||||
uZ.s.signif = sigZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
176
ext/softfloat/extF80_sqrt.c
Normal file
176
ext/softfloat/extF80_sqrt.c
Normal file
@@ -0,0 +1,176 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
extFloat80_t extF80_sqrt( extFloat80_t a )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool signA;
|
||||
int_fast32_t expA;
|
||||
uint_fast64_t sigA;
|
||||
struct uint128 uiZ;
|
||||
uint_fast16_t uiZ64;
|
||||
uint_fast64_t uiZ0;
|
||||
struct exp32_sig64 normExpSig;
|
||||
int_fast32_t expZ;
|
||||
uint_fast32_t sig32A, recipSqrt32, sig32Z;
|
||||
struct uint128 rem;
|
||||
uint_fast64_t q, x64, sigZ;
|
||||
struct uint128 y, term;
|
||||
uint_fast64_t sigZExtra;
|
||||
union { struct extFloat80M s; extFloat80_t f; } uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
expA = expExtF80UI64( uiA64 );
|
||||
sigA = uiA0;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( expA == 0x7FFF ) {
|
||||
if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, 0, 0 );
|
||||
uiZ64 = uiZ.v64;
|
||||
uiZ0 = uiZ.v0;
|
||||
goto uiZ;
|
||||
}
|
||||
if ( ! signA ) return a;
|
||||
goto invalid;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( signA ) {
|
||||
if ( ! sigA ) goto zero;
|
||||
goto invalid;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! expA ) expA = 1;
|
||||
if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigA ) goto zero;
|
||||
normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
|
||||
expA += normExpSig.exp;
|
||||
sigA = normExpSig.sig;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
| (`sig32Z' is guaranteed to be a lower bound on the square root of
|
||||
| `sig32A', which makes `sig32Z' also a lower bound on the square root of
|
||||
| `sigA'.)
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = ((expA - 0x3FFF)>>1) + 0x3FFF;
|
||||
expA &= 1;
|
||||
sig32A = sigA>>32;
|
||||
recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
|
||||
sig32Z = ((uint_fast64_t) sig32A * recipSqrt32)>>32;
|
||||
if ( expA ) {
|
||||
sig32Z >>= 1;
|
||||
rem = softfloat_shortShiftLeft128( 0, sigA, 61 );
|
||||
} else {
|
||||
rem = softfloat_shortShiftLeft128( 0, sigA, 62 );
|
||||
}
|
||||
rem.v64 -= (uint_fast64_t) sig32Z * sig32Z;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
q = ((uint32_t) (rem.v64>>2) * (uint_fast64_t) recipSqrt32)>>32;
|
||||
x64 = (uint_fast64_t) sig32Z<<32;
|
||||
sigZ = x64 + (q<<3);
|
||||
y = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
|
||||
/*------------------------------------------------------------------------
|
||||
| (Repeating this loop is a rare occurrence.)
|
||||
*------------------------------------------------------------------------*/
|
||||
for (;;) {
|
||||
term = softfloat_mul64ByShifted32To128( x64 + sigZ, q );
|
||||
rem = softfloat_sub128( y.v64, y.v0, term.v64, term.v0 );
|
||||
if ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) ) break;
|
||||
--q;
|
||||
sigZ -= 1<<3;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
q = (((rem.v64>>2) * recipSqrt32)>>32) + 2;
|
||||
x64 = sigZ;
|
||||
sigZ = (sigZ<<1) + (q>>25);
|
||||
sigZExtra = (uint64_t) (q<<39);
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (q & 0xFFFFFF) <= 2 ) {
|
||||
q &= ~(uint_fast64_t) 0xFFFF;
|
||||
sigZExtra = (uint64_t) (q<<39);
|
||||
term = softfloat_mul64ByShifted32To128( x64 + (q>>27), q );
|
||||
x64 = (uint32_t) (q<<5) * (uint_fast64_t) (uint32_t) q;
|
||||
term = softfloat_add128( term.v64, term.v0, 0, x64 );
|
||||
rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 28 );
|
||||
rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
|
||||
if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
|
||||
if ( ! sigZExtra ) --sigZ;
|
||||
--sigZExtra;
|
||||
} else {
|
||||
if ( rem.v64 | rem.v0 ) sigZExtra |= 1;
|
||||
}
|
||||
}
|
||||
return
|
||||
softfloat_roundPackToExtF80(
|
||||
0, expZ, sigZ, sigZExtra, extF80_roundingPrecision );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
uiZ64 = defaultNaNExtF80UI64;
|
||||
uiZ0 = defaultNaNExtF80UI0;
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
zero:
|
||||
uiZ64 = packToExtF80UI64( signA, 0 );
|
||||
uiZ0 = 0;
|
||||
uiZ:
|
||||
uZ.s.signExp = uiZ64;
|
||||
uZ.s.signif = uiZ0;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
80
ext/softfloat/extF80_sub.c
Normal file
80
ext/softfloat/extF80_sub.c
Normal file
@@ -0,0 +1,80 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
extFloat80_t extF80_sub( extFloat80_t a, extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool signA;
|
||||
union { struct extFloat80M s; extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signB;
|
||||
#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
|
||||
extFloat80_t
|
||||
(*magsFuncPtr)(
|
||||
uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
|
||||
#endif
|
||||
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
||||
if ( signA == signB ) {
|
||||
return softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
} else {
|
||||
return softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
}
|
||||
#else
|
||||
magsFuncPtr =
|
||||
(signA == signB) ? softfloat_subMagsExtF80 : softfloat_addMagsExtF80;
|
||||
return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
75
ext/softfloat/extF80_to_f128.c
Normal file
75
ext/softfloat/extF80_to_f128.c
Normal file
@@ -0,0 +1,75 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float128_t extF80_to_f128( extFloat80_t a )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
uint_fast16_t exp;
|
||||
uint_fast64_t frac;
|
||||
struct commonNaN commonNaN;
|
||||
struct uint128 uiZ;
|
||||
bool sign;
|
||||
struct uint128 frac128;
|
||||
union ui128_f128 uZ;
|
||||
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
frac = uiA0 & UINT64_C( 0x7FFFFFFFFFFFFFFF );
|
||||
if ( (exp == 0x7FFF) && frac ) {
|
||||
softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
|
||||
uiZ = softfloat_commonNaNToF128UI( &commonNaN );
|
||||
} else {
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
frac128 = softfloat_shortShiftLeft128( 0, frac, 49 );
|
||||
uiZ.v64 = packToF128UI64( sign, exp, frac128.v64 );
|
||||
uiZ.v0 = frac128.v0;
|
||||
}
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
96
ext/softfloat/extF80_to_f16.c
Normal file
96
ext/softfloat/extF80_to_f16.c
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float16_t extF80_to_f16( extFloat80_t a )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool sign;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
struct commonNaN commonNaN;
|
||||
uint_fast16_t uiZ, sig16;
|
||||
union ui16_f16 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uiA0;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
|
||||
uiZ = softfloat_commonNaNToF16UI( &commonNaN );
|
||||
} else {
|
||||
uiZ = packToF16UI( sign, 0x1F, 0 );
|
||||
}
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sig16 = softfloat_shortShiftRightJam64( sig, 49 );
|
||||
if ( ! (exp | sig16) ) {
|
||||
uiZ = packToF16UI( sign, 0, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
exp -= 0x3FF1;
|
||||
if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
|
||||
if ( exp < -0x40 ) exp = -0x40;
|
||||
}
|
||||
return softfloat_roundPackToF16( sign, exp, sig16 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
96
ext/softfloat/extF80_to_f32.c
Normal file
96
ext/softfloat/extF80_to_f32.c
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float32_t extF80_to_f32( extFloat80_t a )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool sign;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
struct commonNaN commonNaN;
|
||||
uint_fast32_t uiZ, sig32;
|
||||
union ui32_f32 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uiA0;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
|
||||
uiZ = softfloat_commonNaNToF32UI( &commonNaN );
|
||||
} else {
|
||||
uiZ = packToF32UI( sign, 0xFF, 0 );
|
||||
}
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sig32 = softfloat_shortShiftRightJam64( sig, 33 );
|
||||
if ( ! (exp | sig32) ) {
|
||||
uiZ = packToF32UI( sign, 0, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
exp -= 0x3F81;
|
||||
if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
|
||||
if ( exp < -0x1000 ) exp = -0x1000;
|
||||
}
|
||||
return softfloat_roundPackToF32( sign, exp, sig32 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
96
ext/softfloat/extF80_to_f64.c
Normal file
96
ext/softfloat/extF80_to_f64.c
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float64_t extF80_to_f64( extFloat80_t a )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool sign;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
struct commonNaN commonNaN;
|
||||
uint_fast64_t uiZ;
|
||||
union ui64_f64 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uiA0;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! (exp | sig) ) {
|
||||
uiZ = packToF64UI( sign, 0, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
|
||||
uiZ = softfloat_commonNaNToF64UI( &commonNaN );
|
||||
} else {
|
||||
uiZ = packToF64UI( sign, 0x7FF, 0 );
|
||||
}
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sig = softfloat_shortShiftRightJam64( sig, 1 );
|
||||
exp -= 0x3C01;
|
||||
if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
|
||||
if ( exp < -0x1000 ) exp = -0x1000;
|
||||
}
|
||||
return softfloat_roundPackToF64( sign, exp, sig );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
83
ext/softfloat/extF80_to_i32.c
Normal file
83
ext/softfloat/extF80_to_i32.c
Normal file
@@ -0,0 +1,83 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
int_fast32_t
|
||||
extF80_to_i32( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
int_fast32_t shiftDist;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uA.s.signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
|
||||
if ( (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) {
|
||||
#if (i32_fromNaN == i32_fromPosOverflow)
|
||||
sign = 0;
|
||||
#elif (i32_fromNaN == i32_fromNegOverflow)
|
||||
sign = 1;
|
||||
#else
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return i32_fromNaN;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x4032 - exp;
|
||||
if ( shiftDist <= 0 ) shiftDist = 1;
|
||||
sig = softfloat_shiftRightJam64( sig, shiftDist );
|
||||
return softfloat_roundToI32( sign, sig, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
97
ext/softfloat/extF80_to_i32_r_minMag.c
Normal file
97
ext/softfloat/extF80_to_i32_r_minMag.c
Normal file
@@ -0,0 +1,97 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
int_fast32_t extF80_to_i32_r_minMag( extFloat80_t a, bool exact )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
int_fast32_t shiftDist;
|
||||
bool sign;
|
||||
int_fast32_t absZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uA.s.signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( 64 <= shiftDist ) {
|
||||
if ( exact && (exp | sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
if ( shiftDist < 33 ) {
|
||||
if (
|
||||
(uiA64 == packToExtF80UI64( 1, 0x401E ))
|
||||
&& (sig < UINT64_C( 0x8000000100000000 ))
|
||||
) {
|
||||
if ( exact && (sig & UINT64_C( 0x00000000FFFFFFFF )) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return -0x7FFFFFFF - 1;
|
||||
}
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? i32_fromNaN
|
||||
: sign ? i32_fromNegOverflow : i32_fromPosOverflow;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
absZ = sig>>shiftDist;
|
||||
if ( exact && ((uint_fast64_t) (uint_fast32_t) absZ<<shiftDist != sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return sign ? -absZ : absZ;
|
||||
|
||||
}
|
||||
|
||||
89
ext/softfloat/extF80_to_i64.c
Normal file
89
ext/softfloat/extF80_to_i64.c
Normal file
@@ -0,0 +1,89 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
int_fast64_t
|
||||
extF80_to_i64( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
int_fast32_t shiftDist;
|
||||
uint_fast64_t sigExtra;
|
||||
struct uint64_extra sig64Extra;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uA.s.signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( shiftDist <= 0 ) {
|
||||
/*--------------------------------------------------------------------
|
||||
*--------------------------------------------------------------------*/
|
||||
if ( shiftDist ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? i64_fromNaN
|
||||
: sign ? i64_fromNegOverflow : i64_fromPosOverflow;
|
||||
}
|
||||
/*--------------------------------------------------------------------
|
||||
*--------------------------------------------------------------------*/
|
||||
sigExtra = 0;
|
||||
} else {
|
||||
/*--------------------------------------------------------------------
|
||||
*--------------------------------------------------------------------*/
|
||||
sig64Extra = softfloat_shiftRightJam64Extra( sig, 0, shiftDist );
|
||||
sig = sig64Extra.v;
|
||||
sigExtra = sig64Extra.extra;
|
||||
}
|
||||
return softfloat_roundToI64( sign, sig, sigExtra, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
94
ext/softfloat/extF80_to_i64_r_minMag.c
Normal file
94
ext/softfloat/extF80_to_i64_r_minMag.c
Normal file
@@ -0,0 +1,94 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
int_fast64_t extF80_to_i64_r_minMag( extFloat80_t a, bool exact )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
int_fast32_t shiftDist;
|
||||
bool sign;
|
||||
int_fast64_t absZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uA.s.signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( 64 <= shiftDist ) {
|
||||
if ( exact && (exp | sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
if ( shiftDist <= 0 ) {
|
||||
if (
|
||||
(uiA64 == packToExtF80UI64( 1, 0x403E ))
|
||||
&& (sig == UINT64_C( 0x8000000000000000 ))
|
||||
) {
|
||||
return -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
|
||||
}
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? i64_fromNaN
|
||||
: sign ? i64_fromNegOverflow : i64_fromPosOverflow;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
absZ = sig>>shiftDist;
|
||||
if ( exact && (uint64_t) (sig<<(-shiftDist & 63)) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return sign ? -absZ : absZ;
|
||||
|
||||
}
|
||||
|
||||
83
ext/softfloat/extF80_to_ui32.c
Normal file
83
ext/softfloat/extF80_to_ui32.c
Normal file
@@ -0,0 +1,83 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
uint_fast32_t
|
||||
extF80_to_ui32( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
int_fast32_t shiftDist;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uA.s.signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
#if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
|
||||
if ( (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) {
|
||||
#if (ui32_fromNaN == ui32_fromPosOverflow)
|
||||
sign = 0;
|
||||
#elif (ui32_fromNaN == ui32_fromNegOverflow)
|
||||
sign = 1;
|
||||
#else
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return ui32_fromNaN;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x4032 - exp;
|
||||
if ( shiftDist <= 0 ) shiftDist = 1;
|
||||
sig = softfloat_shiftRightJam64( sig, shiftDist );
|
||||
return softfloat_roundToUI32( sign, sig, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
88
ext/softfloat/extF80_to_ui32_r_minMag.c
Normal file
88
ext/softfloat/extF80_to_ui32_r_minMag.c
Normal file
@@ -0,0 +1,88 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
uint_fast32_t extF80_to_ui32_r_minMag( extFloat80_t a, bool exact )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
int_fast32_t shiftDist;
|
||||
bool sign;
|
||||
uint_fast32_t z;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uA.s.signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( 64 <= shiftDist ) {
|
||||
if ( exact && (exp | sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
if ( sign || (shiftDist < 32) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? ui32_fromNaN
|
||||
: sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
z = sig>>shiftDist;
|
||||
if ( exact && ((uint_fast64_t) z<<shiftDist != sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return z;
|
||||
|
||||
}
|
||||
|
||||
84
ext/softfloat/extF80_to_ui64.c
Normal file
84
ext/softfloat/extF80_to_ui64.c
Normal file
@@ -0,0 +1,84 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
uint_fast64_t
|
||||
extF80_to_ui64( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
int_fast32_t shiftDist;
|
||||
uint_fast64_t sigExtra;
|
||||
struct uint64_extra sig64Extra;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uA.s.signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( shiftDist < 0 ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? ui64_fromNaN
|
||||
: sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sigExtra = 0;
|
||||
if ( shiftDist ) {
|
||||
sig64Extra = softfloat_shiftRightJam64Extra( sig, 0, shiftDist );
|
||||
sig = sig64Extra.v;
|
||||
sigExtra = sig64Extra.extra;
|
||||
}
|
||||
return softfloat_roundToUI64( sign, sig, sigExtra, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
88
ext/softfloat/extF80_to_ui64_r_minMag.c
Normal file
88
ext/softfloat/extF80_to_ui64_r_minMag.c
Normal file
@@ -0,0 +1,88 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
uint_fast64_t extF80_to_ui64_r_minMag( extFloat80_t a, bool exact )
|
||||
{
|
||||
union { struct extFloat80M s; extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
int_fast32_t shiftDist;
|
||||
bool sign;
|
||||
uint_fast64_t z;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uA.s.signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( 64 <= shiftDist ) {
|
||||
if ( exact && (exp | sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
if ( sign || (shiftDist < 0) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? ui64_fromNaN
|
||||
: sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
z = sig>>shiftDist;
|
||||
if ( exact && (z<<shiftDist != sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return z;
|
||||
|
||||
}
|
||||
|
||||
97
ext/softfloat/f128M_add.c
Normal file
97
ext/softfloat/f128M_add.c
Normal file
@@ -0,0 +1,97 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
f128M_add( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
|
||||
{
|
||||
const uint64_t *aWPtr, *bWPtr;
|
||||
uint_fast64_t uiA64, uiA0;
|
||||
bool signA;
|
||||
uint_fast64_t uiB64, uiB0;
|
||||
bool signB;
|
||||
#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
|
||||
float128_t
|
||||
(*magsFuncPtr)(
|
||||
uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
|
||||
#endif
|
||||
|
||||
aWPtr = (const uint64_t *) aPtr;
|
||||
bWPtr = (const uint64_t *) bPtr;
|
||||
uiA64 = aWPtr[indexWord( 2, 1 )];
|
||||
uiA0 = aWPtr[indexWord( 2, 0 )];
|
||||
signA = signF128UI64( uiA64 );
|
||||
uiB64 = bWPtr[indexWord( 2, 1 )];
|
||||
uiB0 = bWPtr[indexWord( 2, 0 )];
|
||||
signB = signF128UI64( uiB64 );
|
||||
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
||||
if ( signA == signB ) {
|
||||
*zPtr = softfloat_addMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
} else {
|
||||
*zPtr = softfloat_subMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
}
|
||||
#else
|
||||
magsFuncPtr =
|
||||
(signA == signB) ? softfloat_addMagsF128 : softfloat_subMagsF128;
|
||||
*zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
f128M_add( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
|
||||
{
|
||||
|
||||
softfloat_addF128M(
|
||||
(const uint32_t *) aPtr,
|
||||
(const uint32_t *) bPtr,
|
||||
(uint32_t *) zPtr,
|
||||
false
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
187
ext/softfloat/f128M_div.c
Normal file
187
ext/softfloat/f128M_div.c
Normal file
@@ -0,0 +1,187 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
f128M_div( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = f128_div( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
f128M_div( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
|
||||
{
|
||||
const uint32_t *aWPtr, *bWPtr;
|
||||
uint32_t *zWPtr, uiA96;
|
||||
bool signA;
|
||||
int32_t expA;
|
||||
uint32_t uiB96;
|
||||
bool signB;
|
||||
int32_t expB;
|
||||
bool signZ;
|
||||
uint32_t y[5], sigB[4];
|
||||
int32_t expZ;
|
||||
uint32_t recip32;
|
||||
int ix;
|
||||
uint64_t q64;
|
||||
uint32_t q, qs[3], uiZ96;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
bWPtr = (const uint32_t *) bPtr;
|
||||
zWPtr = (uint32_t *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
signA = signF128UI96( uiA96 );
|
||||
expA = expF128UI96( uiA96 );
|
||||
uiB96 = bWPtr[indexWordHi( 4 )];
|
||||
signB = signF128UI96( uiB96 );
|
||||
expB = expF128UI96( uiB96 );
|
||||
signZ = signA ^ signB;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
|
||||
if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
|
||||
if ( expA == 0x7FFF ) {
|
||||
if ( expB == 0x7FFF ) goto invalid;
|
||||
goto infinity;
|
||||
}
|
||||
goto zero;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expA = softfloat_shiftNormSigF128M( aWPtr, 13, y );
|
||||
expB = softfloat_shiftNormSigF128M( bWPtr, 13, sigB );
|
||||
if ( expA == -128 ) {
|
||||
if ( expB == -128 ) goto invalid;
|
||||
goto zero;
|
||||
}
|
||||
if ( expB == -128 ) {
|
||||
softfloat_raiseFlags( softfloat_flag_infinite );
|
||||
goto infinity;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = expA - expB + 0x3FFE;
|
||||
if ( softfloat_compare128M( y, sigB ) < 0 ) {
|
||||
--expZ;
|
||||
softfloat_add128M( y, y, y );
|
||||
}
|
||||
recip32 =
|
||||
softfloat_approxRecip32_1(
|
||||
((uint64_t) sigB[indexWord( 4, 3 )]<<32 | sigB[indexWord( 4, 2 )])
|
||||
>>30
|
||||
);
|
||||
ix = 3;
|
||||
for (;;) {
|
||||
q64 = (uint64_t) y[indexWordHi( 4 )] * recip32;
|
||||
q = (q64 + 0x80000000)>>32;
|
||||
--ix;
|
||||
if ( ix < 0 ) break;
|
||||
softfloat_remStep128MBy32( y, 29, sigB, q, y );
|
||||
if ( y[indexWordHi( 4 )] & 0x80000000 ) {
|
||||
--q;
|
||||
softfloat_add128M( y, sigB, y );
|
||||
}
|
||||
qs[ix] = q;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ((q + 1) & 7) < 2 ) {
|
||||
softfloat_remStep128MBy32( y, 29, sigB, q, y );
|
||||
if ( y[indexWordHi( 4 )] & 0x80000000 ) {
|
||||
--q;
|
||||
softfloat_add128M( y, sigB, y );
|
||||
} else if ( softfloat_compare128M( sigB, y ) <= 0 ) {
|
||||
++q;
|
||||
softfloat_sub128M( y, sigB, y );
|
||||
}
|
||||
if (
|
||||
y[indexWordLo( 4 )] || y[indexWord( 4, 1 )]
|
||||
|| (y[indexWord( 4, 2 )] | y[indexWord( 4, 3 )])
|
||||
) {
|
||||
q |= 1;
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
q64 = (uint64_t) q<<28;
|
||||
y[indexWord( 5, 0 )] = q64;
|
||||
q64 = ((uint64_t) qs[0]<<25) + (q64>>32);
|
||||
y[indexWord( 5, 1 )] = q64;
|
||||
q64 = ((uint64_t) qs[1]<<22) + (q64>>32);
|
||||
y[indexWord( 5, 2 )] = q64;
|
||||
q64 = ((uint64_t) qs[2]<<19) + (q64>>32);
|
||||
y[indexWord( 5, 3 )] = q64;
|
||||
y[indexWord( 5, 4 )] = q64>>32;
|
||||
softfloat_roundPackMToF128M( signZ, expZ, y, zWPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_invalidF128M( zWPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
infinity:
|
||||
uiZ96 = packToF128UI96( signZ, 0x7FFF, 0 );
|
||||
goto uiZ96;
|
||||
zero:
|
||||
uiZ96 = packToF128UI96( signZ, 0, 0 );
|
||||
uiZ96:
|
||||
zWPtr[indexWordHi( 4 )] = uiZ96;
|
||||
zWPtr[indexWord( 4, 2 )] = 0;
|
||||
zWPtr[indexWord( 4, 1 )] = 0;
|
||||
zWPtr[indexWord( 4, 0 )] = 0;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
100
ext/softfloat/f128M_eq.c
Normal file
100
ext/softfloat/f128M_eq.c
Normal file
@@ -0,0 +1,100 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool f128M_eq( const float128_t *aPtr, const float128_t *bPtr )
|
||||
{
|
||||
|
||||
return f128_eq( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool f128M_eq( const float128_t *aPtr, const float128_t *bPtr )
|
||||
{
|
||||
const uint32_t *aWPtr, *bWPtr;
|
||||
uint32_t wordA, wordB, uiA96, uiB96;
|
||||
bool possibleOppositeZeros;
|
||||
uint32_t mashWord;
|
||||
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
bWPtr = (const uint32_t *) bPtr;
|
||||
wordA = aWPtr[indexWord( 4, 2 )];
|
||||
wordB = bWPtr[indexWord( 4, 2 )];
|
||||
if ( wordA != wordB ) goto false_checkSigNaNs;
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
uiB96 = bWPtr[indexWordHi( 4 )];
|
||||
possibleOppositeZeros = false;
|
||||
if ( uiA96 != uiB96 ) {
|
||||
possibleOppositeZeros = (((uiA96 | uiB96) & 0x7FFFFFFF) == 0);
|
||||
if ( ! possibleOppositeZeros ) goto false_checkSigNaNs;
|
||||
}
|
||||
mashWord = wordA | wordB;
|
||||
wordA = aWPtr[indexWord( 4, 1 )];
|
||||
wordB = bWPtr[indexWord( 4, 1 )];
|
||||
if ( wordA != wordB ) goto false_checkSigNaNs;
|
||||
mashWord |= wordA | wordB;
|
||||
wordA = aWPtr[indexWord( 4, 0 )];
|
||||
wordB = bWPtr[indexWord( 4, 0 )];
|
||||
if ( wordA != wordB ) goto false_checkSigNaNs;
|
||||
if ( possibleOppositeZeros && ((mashWord | wordA | wordB) != 0) ) {
|
||||
goto false_checkSigNaNs;
|
||||
}
|
||||
if ( ! softfloat_isNaNF128M( aWPtr ) && ! softfloat_isNaNF128M( bWPtr ) ) {
|
||||
return true;
|
||||
}
|
||||
false_checkSigNaNs:
|
||||
if (
|
||||
f128M_isSignalingNaN( (const float128_t *) aWPtr )
|
||||
|| f128M_isSignalingNaN( (const float128_t *) bWPtr )
|
||||
) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
92
ext/softfloat/f128M_eq_signaling.c
Normal file
92
ext/softfloat/f128M_eq_signaling.c
Normal file
@@ -0,0 +1,92 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool f128M_eq_signaling( const float128_t *aPtr, const float128_t *bPtr )
|
||||
{
|
||||
|
||||
return f128_eq_signaling( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool f128M_eq_signaling( const float128_t *aPtr, const float128_t *bPtr )
|
||||
{
|
||||
const uint32_t *aWPtr, *bWPtr;
|
||||
uint32_t wordA, wordB, uiA96, uiB96;
|
||||
bool possibleOppositeZeros;
|
||||
uint32_t mashWord;
|
||||
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
bWPtr = (const uint32_t *) bPtr;
|
||||
if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
wordA = aWPtr[indexWord( 4, 2 )];
|
||||
wordB = bWPtr[indexWord( 4, 2 )];
|
||||
if ( wordA != wordB ) return false;
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
uiB96 = bWPtr[indexWordHi( 4 )];
|
||||
possibleOppositeZeros = false;
|
||||
if ( uiA96 != uiB96 ) {
|
||||
possibleOppositeZeros = (((uiA96 | uiB96) & 0x7FFFFFFF) == 0);
|
||||
if ( ! possibleOppositeZeros ) return false;
|
||||
}
|
||||
mashWord = wordA | wordB;
|
||||
wordA = aWPtr[indexWord( 4, 1 )];
|
||||
wordB = bWPtr[indexWord( 4, 1 )];
|
||||
if ( wordA != wordB ) return false;
|
||||
mashWord |= wordA | wordB;
|
||||
wordA = aWPtr[indexWord( 4, 0 )];
|
||||
wordB = bWPtr[indexWord( 4, 0 )];
|
||||
return
|
||||
(wordA == wordB)
|
||||
&& (! possibleOppositeZeros || ((mashWord | wordA | wordB) == 0));
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
93
ext/softfloat/f128M_le.c
Normal file
93
ext/softfloat/f128M_le.c
Normal file
@@ -0,0 +1,93 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool f128M_le( const float128_t *aPtr, const float128_t *bPtr )
|
||||
{
|
||||
|
||||
return f128_le( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool f128M_le( const float128_t *aPtr, const float128_t *bPtr )
|
||||
{
|
||||
const uint32_t *aWPtr, *bWPtr;
|
||||
uint32_t uiA96, uiB96;
|
||||
bool signA, signB;
|
||||
uint32_t wordA, wordB;
|
||||
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
bWPtr = (const uint32_t *) bPtr;
|
||||
if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
uiB96 = bWPtr[indexWordHi( 4 )];
|
||||
signA = signF128UI96( uiA96 );
|
||||
signB = signF128UI96( uiB96 );
|
||||
if ( signA != signB ) {
|
||||
if ( signA ) return true;
|
||||
if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return false;
|
||||
wordA = aWPtr[indexWord( 4, 2 )];
|
||||
wordB = bWPtr[indexWord( 4, 2 )];
|
||||
if ( wordA | wordB ) return false;
|
||||
wordA = aWPtr[indexWord( 4, 1 )];
|
||||
wordB = bWPtr[indexWord( 4, 1 )];
|
||||
if ( wordA | wordB ) return false;
|
||||
wordA = aWPtr[indexWord( 4, 0 )];
|
||||
wordB = bWPtr[indexWord( 4, 0 )];
|
||||
return ((wordA | wordB) == 0);
|
||||
}
|
||||
if ( signA ) {
|
||||
aWPtr = (const uint32_t *) bPtr;
|
||||
bWPtr = (const uint32_t *) aPtr;
|
||||
}
|
||||
return (softfloat_compare128M( aWPtr, bWPtr ) <= 0);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
96
ext/softfloat/f128M_le_quiet.c
Normal file
96
ext/softfloat/f128M_le_quiet.c
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool f128M_le_quiet( const float128_t *aPtr, const float128_t *bPtr )
|
||||
{
|
||||
|
||||
return f128_le_quiet( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool f128M_le_quiet( const float128_t *aPtr, const float128_t *bPtr )
|
||||
{
|
||||
const uint32_t *aWPtr, *bWPtr;
|
||||
uint32_t uiA96, uiB96;
|
||||
bool signA, signB;
|
||||
uint32_t wordA, wordB;
|
||||
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
bWPtr = (const uint32_t *) bPtr;
|
||||
if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
|
||||
if ( f128M_isSignalingNaN( aPtr ) || f128M_isSignalingNaN( bPtr ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
uiB96 = bWPtr[indexWordHi( 4 )];
|
||||
signA = signF128UI96( uiA96 );
|
||||
signB = signF128UI96( uiB96 );
|
||||
if ( signA != signB ) {
|
||||
if ( signA ) return true;
|
||||
if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return false;
|
||||
wordA = aWPtr[indexWord( 4, 2 )];
|
||||
wordB = bWPtr[indexWord( 4, 2 )];
|
||||
if ( wordA | wordB ) return false;
|
||||
wordA = aWPtr[indexWord( 4, 1 )];
|
||||
wordB = bWPtr[indexWord( 4, 1 )];
|
||||
if ( wordA | wordB ) return false;
|
||||
wordA = aWPtr[indexWord( 4, 0 )];
|
||||
wordB = bWPtr[indexWord( 4, 0 )];
|
||||
return ((wordA | wordB) == 0);
|
||||
}
|
||||
if ( signA ) {
|
||||
aWPtr = (const uint32_t *) bPtr;
|
||||
bWPtr = (const uint32_t *) aPtr;
|
||||
}
|
||||
return (softfloat_compare128M( aWPtr, bWPtr ) <= 0);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
93
ext/softfloat/f128M_lt.c
Normal file
93
ext/softfloat/f128M_lt.c
Normal file
@@ -0,0 +1,93 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool f128M_lt( const float128_t *aPtr, const float128_t *bPtr )
|
||||
{
|
||||
|
||||
return f128_lt( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool f128M_lt( const float128_t *aPtr, const float128_t *bPtr )
|
||||
{
|
||||
const uint32_t *aWPtr, *bWPtr;
|
||||
uint32_t uiA96, uiB96;
|
||||
bool signA, signB;
|
||||
uint32_t wordA, wordB;
|
||||
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
bWPtr = (const uint32_t *) bPtr;
|
||||
if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
uiB96 = bWPtr[indexWordHi( 4 )];
|
||||
signA = signF128UI96( uiA96 );
|
||||
signB = signF128UI96( uiB96 );
|
||||
if ( signA != signB ) {
|
||||
if ( signB ) return false;
|
||||
if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return true;
|
||||
wordA = aWPtr[indexWord( 4, 2 )];
|
||||
wordB = bWPtr[indexWord( 4, 2 )];
|
||||
if ( wordA | wordB ) return true;
|
||||
wordA = aWPtr[indexWord( 4, 1 )];
|
||||
wordB = bWPtr[indexWord( 4, 1 )];
|
||||
if ( wordA | wordB ) return true;
|
||||
wordA = aWPtr[indexWord( 4, 0 )];
|
||||
wordB = bWPtr[indexWord( 4, 0 )];
|
||||
return ((wordA | wordB) != 0);
|
||||
}
|
||||
if ( signA ) {
|
||||
aWPtr = (const uint32_t *) bPtr;
|
||||
bWPtr = (const uint32_t *) aPtr;
|
||||
}
|
||||
return (softfloat_compare128M( aWPtr, bWPtr ) < 0);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
96
ext/softfloat/f128M_lt_quiet.c
Normal file
96
ext/softfloat/f128M_lt_quiet.c
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool f128M_lt_quiet( const float128_t *aPtr, const float128_t *bPtr )
|
||||
{
|
||||
|
||||
return f128_lt_quiet( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool f128M_lt_quiet( const float128_t *aPtr, const float128_t *bPtr )
|
||||
{
|
||||
const uint32_t *aWPtr, *bWPtr;
|
||||
uint32_t uiA96, uiB96;
|
||||
bool signA, signB;
|
||||
uint32_t wordA, wordB;
|
||||
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
bWPtr = (const uint32_t *) bPtr;
|
||||
if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
|
||||
if ( f128M_isSignalingNaN( aPtr ) || f128M_isSignalingNaN( bPtr ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
uiB96 = bWPtr[indexWordHi( 4 )];
|
||||
signA = signF128UI96( uiA96 );
|
||||
signB = signF128UI96( uiB96 );
|
||||
if ( signA != signB ) {
|
||||
if ( signB ) return false;
|
||||
if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return true;
|
||||
wordA = aWPtr[indexWord( 4, 2 )];
|
||||
wordB = bWPtr[indexWord( 4, 2 )];
|
||||
if ( wordA | wordB ) return true;
|
||||
wordA = aWPtr[indexWord( 4, 1 )];
|
||||
wordB = bWPtr[indexWord( 4, 1 )];
|
||||
if ( wordA | wordB ) return true;
|
||||
wordA = aWPtr[indexWord( 4, 0 )];
|
||||
wordB = bWPtr[indexWord( 4, 0 )];
|
||||
return ((wordA | wordB) != 0);
|
||||
}
|
||||
if ( signA ) {
|
||||
aWPtr = (const uint32_t *) bPtr;
|
||||
bWPtr = (const uint32_t *) aPtr;
|
||||
}
|
||||
return (softfloat_compare128M( aWPtr, bWPtr ) < 0);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
158
ext/softfloat/f128M_mul.c
Normal file
158
ext/softfloat/f128M_mul.c
Normal file
@@ -0,0 +1,158 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
f128M_mul( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = f128_mul( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
f128M_mul( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
|
||||
{
|
||||
const uint32_t *aWPtr, *bWPtr;
|
||||
uint32_t *zWPtr;
|
||||
uint32_t uiA96;
|
||||
int32_t expA;
|
||||
uint32_t uiB96;
|
||||
int32_t expB;
|
||||
bool signZ;
|
||||
const uint32_t *ptr;
|
||||
uint32_t uiZ96, sigA[4];
|
||||
uint_fast8_t shiftDist;
|
||||
uint32_t sigB[4];
|
||||
int32_t expZ;
|
||||
uint32_t sigProd[8], *extSigZPtr;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
bWPtr = (const uint32_t *) bPtr;
|
||||
zWPtr = (uint32_t *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
expA = expF128UI96( uiA96 );
|
||||
uiB96 = bWPtr[indexWordHi( 4 )];
|
||||
expB = expF128UI96( uiB96 );
|
||||
signZ = signF128UI96( uiA96 ) ^ signF128UI96( uiB96 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
|
||||
if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
|
||||
ptr = aWPtr;
|
||||
if ( ! expA ) goto possiblyInvalid;
|
||||
if ( ! expB ) {
|
||||
ptr = bWPtr;
|
||||
possiblyInvalid:
|
||||
if (
|
||||
! fracF128UI96( ptr[indexWordHi( 4 )] )
|
||||
&& ! (ptr[indexWord( 4, 2 )] | ptr[indexWord( 4, 1 )]
|
||||
| ptr[indexWord( 4, 0 )])
|
||||
) {
|
||||
softfloat_invalidF128M( zWPtr );
|
||||
return;
|
||||
}
|
||||
}
|
||||
uiZ96 = packToF128UI96( signZ, 0x7FFF, 0 );
|
||||
goto uiZ96;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( expA ) {
|
||||
sigA[indexWordHi( 4 )] = fracF128UI96( uiA96 ) | 0x00010000;
|
||||
sigA[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
|
||||
sigA[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
|
||||
sigA[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
|
||||
} else {
|
||||
expA = softfloat_shiftNormSigF128M( aWPtr, 0, sigA );
|
||||
if ( expA == -128 ) goto zero;
|
||||
}
|
||||
if ( expB ) {
|
||||
sigB[indexWordHi( 4 )] = fracF128UI96( uiB96 ) | 0x00010000;
|
||||
sigB[indexWord( 4, 2 )] = bWPtr[indexWord( 4, 2 )];
|
||||
sigB[indexWord( 4, 1 )] = bWPtr[indexWord( 4, 1 )];
|
||||
sigB[indexWord( 4, 0 )] = bWPtr[indexWord( 4, 0 )];
|
||||
} else {
|
||||
expB = softfloat_shiftNormSigF128M( bWPtr, 0, sigB );
|
||||
if ( expB == -128 ) goto zero;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = expA + expB - 0x4000;
|
||||
softfloat_mul128MTo256M( sigA, sigB, sigProd );
|
||||
if (
|
||||
sigProd[indexWord( 8, 2 )]
|
||||
|| (sigProd[indexWord( 8, 1 )] | sigProd[indexWord( 8, 0 )])
|
||||
) {
|
||||
sigProd[indexWord( 8, 3 )] |= 1;
|
||||
}
|
||||
extSigZPtr = &sigProd[indexMultiwordHi( 8, 5 )];
|
||||
shiftDist = 16;
|
||||
if ( extSigZPtr[indexWordHi( 5 )] & 2 ) {
|
||||
++expZ;
|
||||
shiftDist = 15;
|
||||
}
|
||||
softfloat_shortShiftLeft160M( extSigZPtr, shiftDist, extSigZPtr );
|
||||
softfloat_roundPackMToF128M( signZ, expZ, extSigZPtr, zWPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
zero:
|
||||
uiZ96 = packToF128UI96( signZ, 0, 0 );
|
||||
uiZ96:
|
||||
zWPtr[indexWordHi( 4 )] = uiZ96;
|
||||
zWPtr[indexWord( 4, 2 )] = 0;
|
||||
zWPtr[indexWord( 4, 1 )] = 0;
|
||||
zWPtr[indexWord( 4, 0 )] = 0;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
92
ext/softfloat/f128M_mulAdd.c
Normal file
92
ext/softfloat/f128M_mulAdd.c
Normal file
@@ -0,0 +1,92 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
f128M_mulAdd(
|
||||
const float128_t *aPtr,
|
||||
const float128_t *bPtr,
|
||||
const float128_t *cPtr,
|
||||
float128_t *zPtr
|
||||
)
|
||||
{
|
||||
const uint64_t *aWPtr, *bWPtr, *cWPtr;
|
||||
uint_fast64_t uiA64, uiA0;
|
||||
uint_fast64_t uiB64, uiB0;
|
||||
uint_fast64_t uiC64, uiC0;
|
||||
|
||||
aWPtr = (const uint64_t *) aPtr;
|
||||
bWPtr = (const uint64_t *) bPtr;
|
||||
cWPtr = (const uint64_t *) cPtr;
|
||||
uiA64 = aWPtr[indexWord( 2, 1 )];
|
||||
uiA0 = aWPtr[indexWord( 2, 0 )];
|
||||
uiB64 = bWPtr[indexWord( 2, 1 )];
|
||||
uiB0 = bWPtr[indexWord( 2, 0 )];
|
||||
uiC64 = cWPtr[indexWord( 2, 1 )];
|
||||
uiC0 = cWPtr[indexWord( 2, 0 )];
|
||||
*zPtr = softfloat_mulAddF128( uiA64, uiA0, uiB64, uiB0, uiC64, uiC0, 0 );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
f128M_mulAdd(
|
||||
const float128_t *aPtr,
|
||||
const float128_t *bPtr,
|
||||
const float128_t *cPtr,
|
||||
float128_t *zPtr
|
||||
)
|
||||
{
|
||||
|
||||
softfloat_mulAddF128M(
|
||||
(const uint32_t *) aPtr,
|
||||
(const uint32_t *) bPtr,
|
||||
(const uint32_t *) cPtr,
|
||||
(uint32_t *) zPtr,
|
||||
0
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
182
ext/softfloat/f128M_rem.c
Normal file
182
ext/softfloat/f128M_rem.c
Normal file
@@ -0,0 +1,182 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
f128M_rem( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = f128_rem( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
f128M_rem( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
|
||||
{
|
||||
const uint32_t *aWPtr, *bWPtr;
|
||||
uint32_t *zWPtr, uiA96;
|
||||
int32_t expA, expB;
|
||||
uint32_t x[4], rem1[5], *remPtr;
|
||||
bool signRem;
|
||||
int32_t expDiff;
|
||||
uint32_t q, recip32;
|
||||
uint64_t q64;
|
||||
uint32_t rem2[5], *altRemPtr, *newRemPtr, wordMeanRem;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
bWPtr = (const uint32_t *) bPtr;
|
||||
zWPtr = (uint32_t *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
expA = expF128UI96( uiA96 );
|
||||
expB = expF128UI96( bWPtr[indexWordHi( 4 )] );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
|
||||
if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
|
||||
if ( expA == 0x7FFF ) goto invalid;
|
||||
goto copyA;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( expA < expB - 1 ) goto copyA;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expB = softfloat_shiftNormSigF128M( bWPtr, 13, x );
|
||||
if ( expB == -128 ) goto invalid;
|
||||
remPtr = &rem1[indexMultiwordLo( 5, 4 )];
|
||||
expA = softfloat_shiftNormSigF128M( aWPtr, 13, remPtr );
|
||||
if ( expA == -128 ) goto copyA;
|
||||
signRem = signF128UI96( uiA96 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expDiff = expA - expB;
|
||||
if ( expDiff < 1 ) {
|
||||
if ( expDiff < -1 ) goto copyA;
|
||||
if ( expDiff ) {
|
||||
--expB;
|
||||
softfloat_add128M( x, x, x );
|
||||
q = 0;
|
||||
} else {
|
||||
q = (softfloat_compare128M( x, remPtr ) <= 0);
|
||||
if ( q ) softfloat_sub128M( remPtr, x, remPtr );
|
||||
}
|
||||
} else {
|
||||
recip32 =
|
||||
softfloat_approxRecip32_1(
|
||||
((uint64_t) x[indexWord( 4, 3 )]<<32 | x[indexWord( 4, 2 )])
|
||||
>>30
|
||||
);
|
||||
expDiff -= 30;
|
||||
for (;;) {
|
||||
q64 = (uint64_t) remPtr[indexWordHi( 4 )] * recip32;
|
||||
if ( expDiff < 0 ) break;
|
||||
q = (q64 + 0x80000000)>>32;
|
||||
softfloat_remStep128MBy32( remPtr, 29, x, q, remPtr );
|
||||
if ( remPtr[indexWordHi( 4 )] & 0x80000000 ) {
|
||||
softfloat_add128M( remPtr, x, remPtr );
|
||||
}
|
||||
expDiff -= 29;
|
||||
}
|
||||
/*--------------------------------------------------------------------
|
||||
| (`expDiff' cannot be less than -29 here.)
|
||||
*--------------------------------------------------------------------*/
|
||||
q = (uint32_t) (q64>>32)>>(~expDiff & 31);
|
||||
softfloat_remStep128MBy32( remPtr, expDiff + 30, x, q, remPtr );
|
||||
if ( remPtr[indexWordHi( 4 )] & 0x80000000 ) {
|
||||
altRemPtr = &rem2[indexMultiwordLo( 5, 4 )];
|
||||
softfloat_add128M( remPtr, x, altRemPtr );
|
||||
goto selectRem;
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
altRemPtr = &rem2[indexMultiwordLo( 5, 4 )];
|
||||
do {
|
||||
++q;
|
||||
newRemPtr = altRemPtr;
|
||||
softfloat_sub128M( remPtr, x, newRemPtr );
|
||||
altRemPtr = remPtr;
|
||||
remPtr = newRemPtr;
|
||||
} while ( ! (remPtr[indexWordHi( 4 )] & 0x80000000) );
|
||||
selectRem:
|
||||
softfloat_add128M( remPtr, altRemPtr, x );
|
||||
wordMeanRem = x[indexWordHi( 4 )];
|
||||
if (
|
||||
(wordMeanRem & 0x80000000)
|
||||
|| (! wordMeanRem && (q & 1) && ! x[indexWord( 4, 0 )]
|
||||
&& ! (x[indexWord( 4, 2 )] | x[indexWord( 4, 1 )]))
|
||||
) {
|
||||
remPtr = altRemPtr;
|
||||
}
|
||||
if ( remPtr[indexWordHi( 4 )] & 0x80000000 ) {
|
||||
signRem = ! signRem;
|
||||
softfloat_negX128M( remPtr );
|
||||
}
|
||||
remPtr -= indexMultiwordLo( 5, 4 );
|
||||
remPtr[indexWordHi( 5 )] = 0;
|
||||
softfloat_normRoundPackMToF128M( signRem, expB + 18, remPtr, zWPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_invalidF128M( zWPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
copyA:
|
||||
zWPtr[indexWordHi( 4 )] = uiA96;
|
||||
zWPtr[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
|
||||
zWPtr[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
|
||||
zWPtr[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
216
ext/softfloat/f128M_roundToInt.c
Normal file
216
ext/softfloat/f128M_roundToInt.c
Normal file
@@ -0,0 +1,216 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
f128M_roundToInt(
|
||||
const float128_t *aPtr,
|
||||
uint_fast8_t roundingMode,
|
||||
bool exact,
|
||||
float128_t *zPtr
|
||||
)
|
||||
{
|
||||
|
||||
*zPtr = f128_roundToInt( *aPtr, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
f128M_roundToInt(
|
||||
const float128_t *aPtr,
|
||||
uint_fast8_t roundingMode,
|
||||
bool exact,
|
||||
float128_t *zPtr
|
||||
)
|
||||
{
|
||||
const uint32_t *aWPtr;
|
||||
uint32_t *zWPtr;
|
||||
uint32_t ui96;
|
||||
int32_t exp;
|
||||
uint32_t sigExtra;
|
||||
bool sign;
|
||||
uint_fast8_t bitPos;
|
||||
bool roundNear;
|
||||
unsigned int index, lastIndex;
|
||||
bool extra;
|
||||
uint32_t wordA, bit, wordZ;
|
||||
uint_fast8_t carry;
|
||||
uint32_t extrasMask;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
zWPtr = (uint32_t *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
ui96 = aWPtr[indexWordHi( 4 )];
|
||||
exp = expF128UI96( ui96 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp < 0x3FFF ) {
|
||||
zWPtr[indexWord( 4, 2 )] = 0;
|
||||
zWPtr[indexWord( 4, 1 )] = 0;
|
||||
zWPtr[indexWord( 4, 0 )] = 0;
|
||||
sigExtra = aWPtr[indexWord( 4, 2 )];
|
||||
if ( ! sigExtra ) {
|
||||
sigExtra = aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )];
|
||||
}
|
||||
if ( ! sigExtra && ! (ui96 & 0x7FFFFFFF) ) goto ui96;
|
||||
if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
sign = signF128UI96( ui96 );
|
||||
switch ( roundingMode ) {
|
||||
case softfloat_round_near_even:
|
||||
if ( ! fracF128UI96( ui96 ) && ! sigExtra ) break;
|
||||
case softfloat_round_near_maxMag:
|
||||
if ( exp == 0x3FFE ) goto mag1;
|
||||
break;
|
||||
case softfloat_round_min:
|
||||
if ( sign ) goto mag1;
|
||||
break;
|
||||
case softfloat_round_max:
|
||||
if ( ! sign ) goto mag1;
|
||||
break;
|
||||
}
|
||||
ui96 = packToF128UI96( sign, 0, 0 );
|
||||
goto ui96;
|
||||
mag1:
|
||||
ui96 = packToF128UI96( sign, 0x3FFF, 0 );
|
||||
goto ui96;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( 0x406F <= exp ) {
|
||||
if (
|
||||
(exp == 0x7FFF)
|
||||
&& (fracF128UI96( ui96 )
|
||||
|| (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
|
||||
| aWPtr[indexWord( 4, 0 )]))
|
||||
) {
|
||||
softfloat_propagateNaNF128M( aWPtr, 0, zWPtr );
|
||||
return;
|
||||
}
|
||||
zWPtr[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
|
||||
zWPtr[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
|
||||
zWPtr[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
|
||||
goto ui96;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
bitPos = 0x406F - exp;
|
||||
roundNear =
|
||||
(roundingMode == softfloat_round_near_maxMag)
|
||||
|| (roundingMode == softfloat_round_near_even);
|
||||
bitPos -= roundNear;
|
||||
index = indexWordLo( 4 );
|
||||
lastIndex = indexWordHi( 4 );
|
||||
extra = 0;
|
||||
for (;;) {
|
||||
wordA = aWPtr[index];
|
||||
if ( bitPos < 32 ) break;
|
||||
if ( wordA ) extra = 1;
|
||||
zWPtr[index] = 0;
|
||||
index += wordIncr;
|
||||
bitPos -= 32;
|
||||
}
|
||||
bit = (uint32_t) 1<<bitPos;
|
||||
if ( roundNear ) {
|
||||
wordZ = wordA + bit;
|
||||
carry = (wordZ < wordA);
|
||||
bit <<= 1;
|
||||
extrasMask = bit - 1;
|
||||
if (
|
||||
(roundingMode == softfloat_round_near_even)
|
||||
&& ! extra && ! (wordZ & extrasMask)
|
||||
) {
|
||||
if ( ! bit ) {
|
||||
zWPtr[index] = wordZ;
|
||||
index += wordIncr;
|
||||
wordZ = aWPtr[index] + carry;
|
||||
carry &= ! wordZ;
|
||||
zWPtr[index] = wordZ & ~1;
|
||||
goto propagateCarry;
|
||||
}
|
||||
wordZ &= ~bit;
|
||||
}
|
||||
} else {
|
||||
extrasMask = bit - 1;
|
||||
wordZ = wordA;
|
||||
carry = 0;
|
||||
if (
|
||||
roundingMode
|
||||
== (signF128UI96( ui96 ) ? softfloat_round_min
|
||||
: softfloat_round_max)
|
||||
) {
|
||||
if ( extra || (wordA & extrasMask) ) {
|
||||
wordZ += bit;
|
||||
carry = (wordZ < wordA);
|
||||
}
|
||||
}
|
||||
}
|
||||
wordZ &= ~extrasMask;
|
||||
zWPtr[index] = wordZ;
|
||||
propagateCarry:
|
||||
while ( index != lastIndex ) {
|
||||
index += wordIncr;
|
||||
wordZ = aWPtr[index] + carry;
|
||||
zWPtr[index] = wordZ;
|
||||
carry &= ! wordZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exact && (softfloat_compare128M( aWPtr, zWPtr ) != 0) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
ui96:
|
||||
zWPtr[indexWordHi( 4 )] = ui96;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
228
ext/softfloat/f128M_sqrt.c
Normal file
228
ext/softfloat/f128M_sqrt.c
Normal file
@@ -0,0 +1,228 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void f128M_sqrt( const float128_t *aPtr, float128_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = f128_sqrt( *aPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void f128M_sqrt( const float128_t *aPtr, float128_t *zPtr )
|
||||
{
|
||||
const uint32_t *aWPtr;
|
||||
uint32_t *zWPtr;
|
||||
uint32_t uiA96;
|
||||
bool signA;
|
||||
int32_t rawExpA;
|
||||
uint32_t rem[6];
|
||||
int32_t expA, expZ;
|
||||
uint64_t rem64;
|
||||
uint32_t sig32A, recipSqrt32, sig32Z, qs[3], q;
|
||||
uint64_t sig64Z;
|
||||
uint32_t term[5];
|
||||
uint64_t x64;
|
||||
uint32_t y[5], rem32;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
zWPtr = (uint32_t *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
signA = signF128UI96( uiA96 );
|
||||
rawExpA = expF128UI96( uiA96 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( rawExpA == 0x7FFF ) {
|
||||
if (
|
||||
fracF128UI96( uiA96 )
|
||||
|| (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
|
||||
| aWPtr[indexWord( 4, 0 )])
|
||||
) {
|
||||
softfloat_propagateNaNF128M( aWPtr, 0, zWPtr );
|
||||
return;
|
||||
}
|
||||
if ( ! signA ) goto copyA;
|
||||
goto invalid;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expA = softfloat_shiftNormSigF128M( aWPtr, 13 - (rawExpA & 1), rem );
|
||||
if ( expA == -128 ) goto copyA;
|
||||
if ( signA ) goto invalid;
|
||||
/*------------------------------------------------------------------------
|
||||
| (`sig32Z' is guaranteed to be a lower bound on the square root of
|
||||
| `sig32A', which makes `sig32Z' also a lower bound on the square root of
|
||||
| `sigA'.)
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = ((expA - 0x3FFF)>>1) + 0x3FFE;
|
||||
expA &= 1;
|
||||
rem64 = (uint64_t) rem[indexWord( 4, 3 )]<<32 | rem[indexWord( 4, 2 )];
|
||||
if ( expA ) {
|
||||
if ( ! rawExpA ) {
|
||||
softfloat_shortShiftRight128M( rem, 1, rem );
|
||||
rem64 >>= 1;
|
||||
}
|
||||
sig32A = rem64>>29;
|
||||
} else {
|
||||
sig32A = rem64>>30;
|
||||
}
|
||||
recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
|
||||
sig32Z = ((uint64_t) sig32A * recipSqrt32)>>32;
|
||||
if ( expA ) sig32Z >>= 1;
|
||||
qs[2] = sig32Z;
|
||||
rem64 -= (uint64_t) sig32Z * sig32Z;
|
||||
rem[indexWord( 4, 3 )] = rem64>>32;
|
||||
rem[indexWord( 4, 2 )] = rem64;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
q = ((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32;
|
||||
sig64Z = ((uint64_t) sig32Z<<32) + ((uint64_t) q<<3);
|
||||
term[indexWord( 4, 3 )] = 0;
|
||||
term[indexWord( 4, 0 )] = 0;
|
||||
/*------------------------------------------------------------------------
|
||||
| (Repeating this loop is a rare occurrence.)
|
||||
*------------------------------------------------------------------------*/
|
||||
for (;;) {
|
||||
x64 = ((uint64_t) sig32Z<<32) + sig64Z;
|
||||
term[indexWord( 4, 2 )] = x64>>32;
|
||||
term[indexWord( 4, 1 )] = x64;
|
||||
softfloat_remStep128MBy32( rem, 29, term, q, y );
|
||||
rem32 = y[indexWord( 4, 3 )];
|
||||
if ( ! (rem32 & 0x80000000) ) break;
|
||||
--q;
|
||||
sig64Z -= 1<<3;
|
||||
}
|
||||
qs[1] = q;
|
||||
rem64 = (uint64_t) rem32<<32 | y[indexWord( 4, 2 )];
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
q = ((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32;
|
||||
if ( rem64>>34 ) q += recipSqrt32;
|
||||
sig64Z <<= 1;
|
||||
/*------------------------------------------------------------------------
|
||||
| (Repeating this loop is a rare occurrence.)
|
||||
*------------------------------------------------------------------------*/
|
||||
for (;;) {
|
||||
x64 = sig64Z + (q>>26);
|
||||
term[indexWord( 4, 2 )] = x64>>32;
|
||||
term[indexWord( 4, 1 )] = x64;
|
||||
term[indexWord( 4, 0 )] = q<<6;
|
||||
softfloat_remStep128MBy32(
|
||||
y, 29, term, q, &rem[indexMultiwordHi( 6, 4 )] );
|
||||
rem32 = rem[indexWordHi( 6 )];
|
||||
if ( ! (rem32 & 0x80000000) ) break;
|
||||
--q;
|
||||
}
|
||||
qs[0] = q;
|
||||
rem64 = (uint64_t) rem32<<32 | rem[indexWord( 6, 4 )];
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
q = (((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32) + 2;
|
||||
if ( rem64>>34 ) q += recipSqrt32;
|
||||
x64 = (uint64_t) q<<27;
|
||||
y[indexWord( 5, 0 )] = x64;
|
||||
x64 = ((uint64_t) qs[0]<<24) + (x64>>32);
|
||||
y[indexWord( 5, 1 )] = x64;
|
||||
x64 = ((uint64_t) qs[1]<<21) + (x64>>32);
|
||||
y[indexWord( 5, 2 )] = x64;
|
||||
x64 = ((uint64_t) qs[2]<<18) + (x64>>32);
|
||||
y[indexWord( 5, 3 )] = x64;
|
||||
y[indexWord( 5, 4 )] = x64>>32;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (q & 0xF) <= 2 ) {
|
||||
q &= ~3;
|
||||
y[indexWordLo( 5 )] = q<<27;
|
||||
term[indexWord( 5, 4 )] = 0;
|
||||
term[indexWord( 5, 3 )] = 0;
|
||||
term[indexWord( 5, 2 )] = 0;
|
||||
term[indexWord( 5, 1 )] = q>>6;
|
||||
term[indexWord( 5, 0 )] = q<<26;
|
||||
softfloat_sub160M( y, term, term );
|
||||
rem[indexWord( 6, 1 )] = 0;
|
||||
rem[indexWord( 6, 0 )] = 0;
|
||||
softfloat_remStep160MBy32(
|
||||
&rem[indexMultiwordLo( 6, 5 )],
|
||||
14,
|
||||
term,
|
||||
q,
|
||||
&rem[indexMultiwordLo( 6, 5 )]
|
||||
);
|
||||
rem32 = rem[indexWord( 6, 4 )];
|
||||
if ( rem32 & 0x80000000 ) {
|
||||
softfloat_sub1X160M( y );
|
||||
} else {
|
||||
if (
|
||||
rem32 || rem[indexWord( 6, 0 )] || rem[indexWord( 6, 1 )]
|
||||
|| (rem[indexWord( 6, 3 )] | rem[indexWord( 6, 2 )])
|
||||
) {
|
||||
y[indexWordLo( 5 )] |= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
softfloat_roundPackMToF128M( 0, expZ, y, zWPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_invalidF128M( zWPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
copyA:
|
||||
zWPtr[indexWordHi( 4 )] = uiA96;
|
||||
zWPtr[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
|
||||
zWPtr[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
|
||||
zWPtr[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
97
ext/softfloat/f128M_sub.c
Normal file
97
ext/softfloat/f128M_sub.c
Normal file
@@ -0,0 +1,97 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
f128M_sub( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
|
||||
{
|
||||
const uint64_t *aWPtr, *bWPtr;
|
||||
uint_fast64_t uiA64, uiA0;
|
||||
bool signA;
|
||||
uint_fast64_t uiB64, uiB0;
|
||||
bool signB;
|
||||
#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
|
||||
float128_t
|
||||
(*magsFuncPtr)(
|
||||
uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
|
||||
#endif
|
||||
|
||||
aWPtr = (const uint64_t *) aPtr;
|
||||
bWPtr = (const uint64_t *) bPtr;
|
||||
uiA64 = aWPtr[indexWord( 2, 1 )];
|
||||
uiA0 = aWPtr[indexWord( 2, 0 )];
|
||||
signA = signF128UI64( uiA64 );
|
||||
uiB64 = bWPtr[indexWord( 2, 1 )];
|
||||
uiB0 = bWPtr[indexWord( 2, 0 )];
|
||||
signB = signF128UI64( uiB64 );
|
||||
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
||||
if ( signA == signB ) {
|
||||
*zPtr = softfloat_subMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
} else {
|
||||
*zPtr = softfloat_addMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
}
|
||||
#else
|
||||
magsFuncPtr =
|
||||
(signA == signB) ? softfloat_subMagsF128 : softfloat_addMagsF128;
|
||||
*zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
f128M_sub( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
|
||||
{
|
||||
|
||||
softfloat_addF128M(
|
||||
(const uint32_t *) aPtr,
|
||||
(const uint32_t *) bPtr,
|
||||
(uint32_t *) zPtr,
|
||||
true
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
101
ext/softfloat/f128M_to_extF80M.c
Normal file
101
ext/softfloat/f128M_to_extF80M.c
Normal file
@@ -0,0 +1,101 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void f128M_to_extF80M( const float128_t *aPtr, extFloat80_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = f128_to_extF80( *aPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void f128M_to_extF80M( const float128_t *aPtr, extFloat80_t *zPtr )
|
||||
{
|
||||
const uint32_t *aWPtr;
|
||||
struct extFloat80M *zSPtr;
|
||||
uint32_t uiA96;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
struct commonNaN commonNaN;
|
||||
uint32_t sig[4];
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
zSPtr = (struct extFloat80M *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
sign = signF128UI96( uiA96 );
|
||||
exp = expF128UI96( uiA96 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( softfloat_isNaNF128M( aWPtr ) ) {
|
||||
softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
|
||||
softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
|
||||
return;
|
||||
}
|
||||
zSPtr->signExp = packToExtF80UI64( sign, 0x7FFF );
|
||||
zSPtr->signif = UINT64_C( 0x8000000000000000 );
|
||||
return;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
exp = softfloat_shiftNormSigF128M( aWPtr, 15, sig );
|
||||
if ( exp == -128 ) {
|
||||
zSPtr->signExp = packToExtF80UI64( sign, 0 );
|
||||
zSPtr->signif = 0;
|
||||
return;
|
||||
}
|
||||
if ( sig[indexWord( 4, 0 )] ) sig[indexWord( 4, 1 )] |= 1;
|
||||
softfloat_roundPackMToExtF80M(
|
||||
sign, exp, &sig[indexMultiwordHi( 4, 3 )], 80, zSPtr );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
113
ext/softfloat/f128M_to_f16.c
Normal file
113
ext/softfloat/f128M_to_f16.c
Normal file
@@ -0,0 +1,113 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
float16_t f128M_to_f16( const float128_t *aPtr )
|
||||
{
|
||||
|
||||
return f128_to_f16( *aPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
float16_t f128M_to_f16( const float128_t *aPtr )
|
||||
{
|
||||
const uint32_t *aWPtr;
|
||||
uint32_t uiA96;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint32_t frac32;
|
||||
struct commonNaN commonNaN;
|
||||
uint16_t uiZ, frac16;
|
||||
union ui16_f16 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
sign = signF128UI96( uiA96 );
|
||||
exp = expF128UI96( uiA96 );
|
||||
frac32 =
|
||||
fracF128UI96( uiA96 )
|
||||
| ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
|
||||
| aWPtr[indexWord( 4, 0 )])
|
||||
!= 0);
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( frac32 ) {
|
||||
softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
|
||||
uiZ = softfloat_commonNaNToF16UI( &commonNaN );
|
||||
} else {
|
||||
uiZ = packToF16UI( sign, 0x1F, 0 );
|
||||
}
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
frac16 = frac32>>2 | (frac32 & 3);
|
||||
if ( ! (exp | frac16) ) {
|
||||
uiZ = packToF16UI( sign, 0, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
exp -= 0x3FF1;
|
||||
if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
|
||||
if ( exp < -0x40 ) exp = -0x40;
|
||||
}
|
||||
return softfloat_roundPackToF16( sign, exp, frac16 | 0x4000 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
109
ext/softfloat/f128M_to_f32.c
Normal file
109
ext/softfloat/f128M_to_f32.c
Normal file
@@ -0,0 +1,109 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
float32_t f128M_to_f32( const float128_t *aPtr )
|
||||
{
|
||||
|
||||
return f128_to_f32( *aPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
float32_t f128M_to_f32( const float128_t *aPtr )
|
||||
{
|
||||
const uint32_t *aWPtr;
|
||||
uint32_t uiA96;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t frac64;
|
||||
struct commonNaN commonNaN;
|
||||
uint32_t uiZ, frac32;
|
||||
union ui32_f32 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
sign = signF128UI96( uiA96 );
|
||||
exp = expF128UI96( uiA96 );
|
||||
frac64 =
|
||||
(uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )]
|
||||
| ((aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )]) != 0);
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( frac64 ) {
|
||||
softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
|
||||
uiZ = softfloat_commonNaNToF32UI( &commonNaN );
|
||||
} else {
|
||||
uiZ = packToF32UI( sign, 0xFF, 0 );
|
||||
}
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
frac32 = softfloat_shortShiftRightJam64( frac64, 18 );
|
||||
if ( ! (exp | frac32) ) {
|
||||
uiZ = packToF32UI( sign, 0, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
exp -= 0x3F81;
|
||||
if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
|
||||
if ( exp < -0x1000 ) exp = -0x1000;
|
||||
}
|
||||
return softfloat_roundPackToF32( sign, exp, frac32 | 0x40000000 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
112
ext/softfloat/f128M_to_f64.c
Normal file
112
ext/softfloat/f128M_to_f64.c
Normal file
@@ -0,0 +1,112 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
float64_t f128M_to_f64( const float128_t *aPtr )
|
||||
{
|
||||
|
||||
return f128_to_f64( *aPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
float64_t f128M_to_f64( const float128_t *aPtr )
|
||||
{
|
||||
const uint32_t *aWPtr;
|
||||
uint32_t uiA96;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t frac64;
|
||||
struct commonNaN commonNaN;
|
||||
uint64_t uiZ;
|
||||
uint32_t frac32;
|
||||
union ui64_f64 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
sign = signF128UI96( uiA96 );
|
||||
exp = expF128UI96( uiA96 );
|
||||
frac64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( frac64 || aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) {
|
||||
softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
|
||||
uiZ = softfloat_commonNaNToF64UI( &commonNaN );
|
||||
} else {
|
||||
uiZ = packToF64UI( sign, 0x7FF, 0 );
|
||||
}
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
frac32 = aWPtr[indexWord( 4, 1 )];
|
||||
frac64 = frac64<<14 | frac32>>18;
|
||||
if ( (frac32 & 0x0003FFFF) || aWPtr[indexWord( 4, 0 )] ) frac64 |= 1;
|
||||
if ( ! (exp | frac64) ) {
|
||||
uiZ = packToF64UI( sign, 0, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
exp -= 0x3C01;
|
||||
if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
|
||||
if ( exp < -0x1000 ) exp = -0x1000;
|
||||
}
|
||||
return
|
||||
softfloat_roundPackToF64(
|
||||
sign, exp, frac64 | UINT64_C( 0x4000000000000000 ) );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
98
ext/softfloat/f128M_to_i32.c
Normal file
98
ext/softfloat/f128M_to_i32.c
Normal file
@@ -0,0 +1,98 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
int_fast32_t
|
||||
f128M_to_i32( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
|
||||
return f128_to_i32( *aPtr, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int_fast32_t
|
||||
f128M_to_i32( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
const uint32_t *aWPtr;
|
||||
uint32_t uiA96;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig64;
|
||||
int32_t shiftDist;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
sign = signF128UI96( uiA96 );
|
||||
exp = expF128UI96( uiA96 );
|
||||
sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
|
||||
if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
|
||||
if ( (exp == 0x7FFF) && sig64 ) {
|
||||
#if (i32_fromNaN == i32_fromPosOverflow)
|
||||
sign = 0;
|
||||
#elif (i32_fromNaN == i32_fromNegOverflow)
|
||||
sign = 1;
|
||||
#else
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return i32_fromNaN;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
|
||||
shiftDist = 0x4023 - exp;
|
||||
if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
|
||||
return softfloat_roundToI32( sign, sig64, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
106
ext/softfloat/f128M_to_i32_r_minMag.c
Normal file
106
ext/softfloat/f128M_to_i32_r_minMag.c
Normal file
@@ -0,0 +1,106 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
int_fast32_t f128M_to_i32_r_minMag( const float128_t *aPtr, bool exact )
|
||||
{
|
||||
|
||||
return f128_to_i32_r_minMag( *aPtr, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int_fast32_t f128M_to_i32_r_minMag( const float128_t *aPtr, bool exact )
|
||||
{
|
||||
const uint32_t *aWPtr;
|
||||
uint32_t uiA96;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig64;
|
||||
int32_t shiftDist;
|
||||
uint32_t absZ, uiZ;
|
||||
union { uint32_t ui; int32_t i; } uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
sign = signF128UI96( uiA96 );
|
||||
exp = expF128UI96( uiA96 );
|
||||
sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
|
||||
if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp < 0x3FFF ) {
|
||||
if ( exact && (exp | sig64) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( 0x401F <= exp ) goto invalid;
|
||||
shiftDist = 0x402F - exp;
|
||||
sig64 |= UINT64_C( 0x0001000000000000 );
|
||||
absZ = sig64>>shiftDist;
|
||||
uiZ = sign ? -absZ : absZ;
|
||||
if ( uiZ>>31 != sign ) goto invalid;
|
||||
if ( exact && ((uint64_t) absZ<<shiftDist != sig64) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
uZ.ui = uiZ;
|
||||
return uZ.i;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && sig64 ? i32_fromNaN
|
||||
: sign ? i32_fromNegOverflow : i32_fromPosOverflow;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
102
ext/softfloat/f128M_to_i64.c
Normal file
102
ext/softfloat/f128M_to_i64.c
Normal file
@@ -0,0 +1,102 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
int_fast64_t
|
||||
f128M_to_i64( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
|
||||
return f128_to_i64( *aPtr, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int_fast64_t
|
||||
f128M_to_i64( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
const uint32_t *aWPtr;
|
||||
uint32_t uiA96;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint32_t sig96;
|
||||
int32_t shiftDist;
|
||||
uint32_t sig[4];
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
sign = signF128UI96( uiA96 );
|
||||
exp = expF128UI96( uiA96 );
|
||||
sig96 = fracF128UI96( uiA96 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x404F - exp;
|
||||
if ( shiftDist < 17 ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF)
|
||||
&& (sig96
|
||||
|| (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
|
||||
| aWPtr[indexWord( 4, 0 )]))
|
||||
? i64_fromNaN
|
||||
: sign ? i64_fromNegOverflow : i64_fromPosOverflow;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp ) sig96 |= 0x00010000;
|
||||
sig[indexWord( 4, 3 )] = sig96;
|
||||
sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
|
||||
sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
|
||||
sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
|
||||
softfloat_shiftRightJam128M( sig, shiftDist, sig );
|
||||
return
|
||||
softfloat_roundMToI64(
|
||||
sign, sig + indexMultiwordLo( 4, 3 ), roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
124
ext/softfloat/f128M_to_i64_r_minMag.c
Normal file
124
ext/softfloat/f128M_to_i64_r_minMag.c
Normal file
@@ -0,0 +1,124 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
int_fast64_t f128M_to_i64_r_minMag( const float128_t *aPtr, bool exact )
|
||||
{
|
||||
|
||||
return f128_to_i64_r_minMag( *aPtr, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int_fast64_t f128M_to_i64_r_minMag( const float128_t *aPtr, bool exact )
|
||||
{
|
||||
const uint32_t *aWPtr;
|
||||
uint32_t uiA96;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint32_t sig96;
|
||||
int32_t shiftDist;
|
||||
uint32_t sig[4];
|
||||
uint64_t uiZ;
|
||||
union { uint64_t ui; int64_t i; } uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
sign = signF128UI96( uiA96 );
|
||||
exp = expF128UI96( uiA96 );
|
||||
sig96 = fracF128UI96( uiA96 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( shiftDist < 0 ) goto invalid;
|
||||
if ( exact ) {
|
||||
if ( exp ) sig96 |= 0x00010000;
|
||||
sig[indexWord( 4, 3 )] = sig96;
|
||||
sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
|
||||
sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
|
||||
sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
|
||||
softfloat_shiftRightJam128M( sig, shiftDist + 17, sig );
|
||||
uiZ = (uint64_t) sig[indexWord( 4, 2 )]<<32 | sig[indexWord( 4, 1 )];
|
||||
if ( uiZ>>63 && (! sign || (uiZ != UINT64_C( 0x8000000000000000 ))) ) {
|
||||
goto invalid;
|
||||
}
|
||||
if ( sig[indexWordLo( 4 )] ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
} else {
|
||||
if ( 64 <= shiftDist ) return 0;
|
||||
uiZ =
|
||||
(uint64_t) sig96<<47
|
||||
| (uint64_t) aWPtr[indexWord( 4, 2 )]<<15
|
||||
| aWPtr[indexWord( 4, 1 )]>>17;
|
||||
if ( shiftDist ) {
|
||||
uiZ |= UINT64_C( 0x8000000000000000 );
|
||||
uiZ >>= shiftDist;
|
||||
} else {
|
||||
if ( uiZ || ! sign ) goto invalid;
|
||||
uiZ |= UINT64_C( 0x8000000000000000 );
|
||||
}
|
||||
}
|
||||
if ( sign ) uiZ = -uiZ;
|
||||
uZ.ui = uiZ;
|
||||
return uZ.i;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF)
|
||||
&& (sig96
|
||||
|| (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
|
||||
| aWPtr[indexWord( 4, 0 )]))
|
||||
? i64_fromNaN
|
||||
: sign ? i64_fromNegOverflow : i64_fromPosOverflow;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
98
ext/softfloat/f128M_to_ui32.c
Normal file
98
ext/softfloat/f128M_to_ui32.c
Normal file
@@ -0,0 +1,98 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
uint_fast32_t
|
||||
f128M_to_ui32( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
|
||||
return f128_to_ui32( *aPtr, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
uint_fast32_t
|
||||
f128M_to_ui32( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
const uint32_t *aWPtr;
|
||||
uint32_t uiA96;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig64;
|
||||
int32_t shiftDist;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
sign = signF128UI96( uiA96 );
|
||||
exp = expF128UI96( uiA96 );
|
||||
sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
|
||||
if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
#if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
|
||||
if ( (exp == 0x7FFF) && sig64 ) {
|
||||
#if (ui32_fromNaN == ui32_fromPosOverflow)
|
||||
sign = 0;
|
||||
#elif (ui32_fromNaN == ui32_fromNegOverflow)
|
||||
sign = 1;
|
||||
#else
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return ui32_fromNaN;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
|
||||
shiftDist = 0x4023 - exp;
|
||||
if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
|
||||
return softfloat_roundToUI32( sign, sig64, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
102
ext/softfloat/f128M_to_ui32_r_minMag.c
Normal file
102
ext/softfloat/f128M_to_ui32_r_minMag.c
Normal file
@@ -0,0 +1,102 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
uint_fast32_t f128M_to_ui32_r_minMag( const float128_t *aPtr, bool exact )
|
||||
{
|
||||
|
||||
return f128_to_ui32_r_minMag( *aPtr, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
uint_fast32_t f128M_to_ui32_r_minMag( const float128_t *aPtr, bool exact )
|
||||
{
|
||||
const uint32_t *aWPtr;
|
||||
uint32_t uiA96;
|
||||
int32_t exp;
|
||||
uint64_t sig64;
|
||||
int32_t shiftDist;
|
||||
bool sign;
|
||||
uint32_t z;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
exp = expF128UI96( uiA96 );
|
||||
sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
|
||||
if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x402F - exp;
|
||||
if ( 49 <= shiftDist ) {
|
||||
if ( exact && (exp | sig64) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sign = signF128UI96( uiA96 );
|
||||
if ( sign || (shiftDist < 17) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && sig64 ? ui32_fromNaN
|
||||
: sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sig64 |= UINT64_C( 0x0001000000000000 );
|
||||
z = sig64>>shiftDist;
|
||||
if ( exact && ((uint64_t) z<<shiftDist != sig64) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return z;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
102
ext/softfloat/f128M_to_ui64.c
Normal file
102
ext/softfloat/f128M_to_ui64.c
Normal file
@@ -0,0 +1,102 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
uint_fast64_t
|
||||
f128M_to_ui64( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
|
||||
return f128_to_ui64( *aPtr, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
uint_fast64_t
|
||||
f128M_to_ui64( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
const uint32_t *aWPtr;
|
||||
uint32_t uiA96;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint32_t sig96;
|
||||
int32_t shiftDist;
|
||||
uint32_t sig[4];
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
sign = signF128UI96( uiA96 );
|
||||
exp = expF128UI96( uiA96 );
|
||||
sig96 = fracF128UI96( uiA96 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x404F - exp;
|
||||
if ( shiftDist < 17 ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF)
|
||||
&& (sig96
|
||||
|| (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
|
||||
| aWPtr[indexWord( 4, 0 )]))
|
||||
? ui64_fromNaN
|
||||
: sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp ) sig96 |= 0x00010000;
|
||||
sig[indexWord( 4, 3 )] = sig96;
|
||||
sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
|
||||
sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
|
||||
sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
|
||||
softfloat_shiftRightJam128M( sig, shiftDist, sig );
|
||||
return
|
||||
softfloat_roundMToUI64(
|
||||
sign, sig + indexMultiwordLo( 4, 3 ), roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
114
ext/softfloat/f128M_to_ui64_r_minMag.c
Normal file
114
ext/softfloat/f128M_to_ui64_r_minMag.c
Normal file
@@ -0,0 +1,114 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
uint_fast64_t f128M_to_ui64_r_minMag( const float128_t *aPtr, bool exact )
|
||||
{
|
||||
|
||||
return f128_to_ui64_r_minMag( *aPtr, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
uint_fast64_t f128M_to_ui64_r_minMag( const float128_t *aPtr, bool exact )
|
||||
{
|
||||
const uint32_t *aWPtr;
|
||||
uint32_t uiA96;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint32_t sig96;
|
||||
int32_t shiftDist;
|
||||
uint32_t sig[4];
|
||||
uint64_t z;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
sign = signF128UI96( uiA96 );
|
||||
exp = expF128UI96( uiA96 );
|
||||
sig96 = fracF128UI96( uiA96 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( shiftDist < 0 ) goto invalid;
|
||||
if ( exact ) {
|
||||
if ( exp ) sig96 |= 0x00010000;
|
||||
sig[indexWord( 4, 3 )] = sig96;
|
||||
sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
|
||||
sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
|
||||
sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
|
||||
softfloat_shiftRightJam128M( sig, shiftDist + 17, sig );
|
||||
z = (uint64_t) sig[indexWord( 4, 2 )]<<32 | sig[indexWord( 4, 1 )];
|
||||
if ( sign && z ) goto invalid;
|
||||
if ( sig[indexWordLo( 4 )] ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
} else {
|
||||
if ( 64 <= shiftDist ) return 0;
|
||||
if ( sign ) goto invalid;
|
||||
z = UINT64_C( 0x8000000000000000 )
|
||||
| (uint64_t) sig96<<47
|
||||
| (uint64_t) aWPtr[indexWord( 4, 2 )]<<15
|
||||
| aWPtr[indexWord( 4, 1 )]>>17;
|
||||
z >>= shiftDist;
|
||||
}
|
||||
return z;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF)
|
||||
&& (sig96
|
||||
|| (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
|
||||
| aWPtr[indexWord( 4, 0 )]))
|
||||
? ui64_fromNaN
|
||||
: sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -36,9 +36,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float128_t f128_add( float128_t a, float128_t b )
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "softfloat.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
uint_fast16_t f128_classify( float128_t a )
|
||||
{
|
||||
|
||||
@@ -36,11 +36,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "softfloat.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float128_t f128_div( float128_t a, float128_t b )
|
||||
{
|
||||
|
||||
@@ -36,11 +36,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "softfloat.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool f128_eq( float128_t a, float128_t b )
|
||||
{
|
||||
|
||||
@@ -36,9 +36,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool f128_eq_signaling( float128_t a, float128_t b )
|
||||
|
||||
@@ -35,11 +35,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "softfloat.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool f128_isSignalingNaN( float128_t a )
|
||||
{
|
||||
|
||||
@@ -36,9 +36,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool f128_le( float128_t a, float128_t b )
|
||||
|
||||
@@ -36,11 +36,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "softfloat.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool f128_le_quiet( float128_t a, float128_t b )
|
||||
{
|
||||
|
||||
@@ -36,9 +36,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool f128_lt( float128_t a, float128_t b )
|
||||
|
||||
@@ -36,11 +36,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "softfloat.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool f128_lt_quiet( float128_t a, float128_t b )
|
||||
{
|
||||
|
||||
@@ -36,11 +36,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "softfloat.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float128_t f128_mul( float128_t a, float128_t b )
|
||||
{
|
||||
|
||||
@@ -35,9 +35,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float128_t f128_mulAdd( float128_t a, float128_t b, float128_t c )
|
||||
|
||||
@@ -36,11 +36,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "softfloat.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float128_t f128_rem( float128_t a, float128_t b )
|
||||
{
|
||||
|
||||
@@ -36,11 +36,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "softfloat.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float128_t
|
||||
f128_roundToInt( float128_t a, uint_fast8_t roundingMode, bool exact )
|
||||
|
||||
@@ -36,11 +36,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "softfloat.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float128_t f128_sqrt( float128_t a )
|
||||
{
|
||||
|
||||
@@ -36,9 +36,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float128_t f128_sub( float128_t a, float128_t b )
|
||||
|
||||
109
ext/softfloat/f128_to_extF80.c
Normal file
109
ext/softfloat/f128_to_extF80.c
Normal file
@@ -0,0 +1,109 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3d, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
extFloat80_t f128_to_extF80( float128_t a )
|
||||
{
|
||||
union ui128_f128 uA;
|
||||
uint_fast64_t uiA64, uiA0;
|
||||
bool sign;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t frac64, frac0;
|
||||
struct commonNaN commonNaN;
|
||||
struct uint128 uiZ;
|
||||
uint_fast16_t uiZ64;
|
||||
uint_fast64_t uiZ0;
|
||||
struct exp32_sig128 normExpSig;
|
||||
struct uint128 sig128;
|
||||
union { struct extFloat80M s; extFloat80_t f; } uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.ui.v64;
|
||||
uiA0 = uA.ui.v0;
|
||||
sign = signF128UI64( uiA64 );
|
||||
exp = expF128UI64( uiA64 );
|
||||
frac64 = fracF128UI64( uiA64 );
|
||||
frac0 = uiA0;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( frac64 | frac0 ) {
|
||||
softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
|
||||
uiZ = softfloat_commonNaNToExtF80UI( &commonNaN );
|
||||
uiZ64 = uiZ.v64;
|
||||
uiZ0 = uiZ.v0;
|
||||
} else {
|
||||
uiZ64 = packToExtF80UI64( sign, 0x7FFF );
|
||||
uiZ0 = UINT64_C( 0x8000000000000000 );
|
||||
}
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! exp ) {
|
||||
if ( ! (frac64 | frac0) ) {
|
||||
uiZ64 = packToExtF80UI64( sign, 0 );
|
||||
uiZ0 = 0;
|
||||
goto uiZ;
|
||||
}
|
||||
normExpSig = softfloat_normSubnormalF128Sig( frac64, frac0 );
|
||||
exp = normExpSig.exp;
|
||||
frac64 = normExpSig.sig.v64;
|
||||
frac0 = normExpSig.sig.v0;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sig128 =
|
||||
softfloat_shortShiftLeft128(
|
||||
frac64 | UINT64_C( 0x0001000000000000 ), frac0, 15 );
|
||||
return softfloat_roundPackToExtF80( sign, exp, sig128.v64, sig128.v0, 80 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ:
|
||||
uZ.s.signExp = uiZ64;
|
||||
uZ.s.signif = uiZ0;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
@@ -36,11 +36,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "softfloat.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float16_t f128_to_f16( float128_t a )
|
||||
{
|
||||
|
||||
@@ -36,11 +36,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "softfloat.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float32_t f128_to_f32( float128_t a )
|
||||
{
|
||||
|
||||
@@ -36,11 +36,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "softfloat.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float64_t f128_to_f64( float128_t a )
|
||||
{
|
||||
|
||||
@@ -36,11 +36,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "softfloat.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
int_fast32_t f128_to_i32( float128_t a, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
|
||||
@@ -36,11 +36,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "internals.h"
|
||||
#include "platform.h"
|
||||
#include "softfloat.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
int_fast32_t f128_to_i32_r_minMag( float128_t a, bool exact )
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user