authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-03-09 15:06:06-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-03-09 15:06:06-05:00
log5a7a0e8518bcb9e63c06dba21d9c9e2bb0827330
tree6987d4b0f89b43f6e9a4cf57ca9f99031ae5923f
parent6db9be8900bf43632c8a98d91c6a92f30b33500a

update to SoftFloat-3e

closes #823

818 files changed, 43772 insertions(+), 40236 deletions(-)

CMakeLists.txt+112-112
......@@ -240,116 +240,116 @@ else()
240240 install(TARGETS embedded_lld_elf embedded_lld_coff embedded_lld_mingw embedded_lld_wasm embedded_lld_lib DESTINATION "${ZIG_CPP_LIB_DIR}")
241241endif()
242242
243# No patches have been applied to SoftFloat-3d
243# No patches have been applied to SoftFloat-3e
244244set(EMBEDDED_SOFTFLOAT_SOURCES
245 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/8086/f128M_isSignalingNaN.c"
246 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/8086/s_commonNaNToF128M.c"
247 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/8086/s_commonNaNToF32UI.c"
248 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/8086/s_commonNaNToF64UI.c"
249 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/8086/s_f128MToCommonNaN.c"
250 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/8086/s_f32UIToCommonNaN.c"
251 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/8086/s_f64UIToCommonNaN.c"
252 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/8086/s_propagateNaNF128M.c"
253 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/8086/softfloat_raiseFlags.c"
254 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_add.c"
255 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_div.c"
256 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_eq.c"
257 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_eq_signaling.c"
258 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_le.c"
259 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_le_quiet.c"
260 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_lt.c"
261 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_lt_quiet.c"
262 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_mul.c"
263 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_mulAdd.c"
264 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_rem.c"
265 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_roundToInt.c"
266 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_sqrt.c"
267 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_sub.c"
268 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_to_f16.c"
269 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_to_f32.c"
270 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_to_f64.c"
271 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_to_i32.c"
272 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_to_i32_r_minMag.c"
273 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_to_i64.c"
274 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_to_i64_r_minMag.c"
275 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_to_ui32.c"
276 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_to_ui32_r_minMag.c"
277 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_to_ui64.c"
278 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f128M_to_ui64_r_minMag.c"
279 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f32_to_f128M.c"
280 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/f64_to_f128M.c"
281 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_add256M.c"
282 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_addCarryM.c"
283 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_addComplCarryM.c"
284 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_addF128M.c"
285 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_addM.c"
286 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_addMagsF16.c"
287 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_addMagsF32.c"
288 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_addMagsF64.c"
289 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_approxRecip32_1.c"
290 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_approxRecipSqrt32_1.c"
291 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_approxRecipSqrt_1Ks.c"
292 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_approxRecip_1Ks.c"
293 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_compare128M.c"
294 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_compare96M.c"
295 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_countLeadingZeros16.c"
296 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_countLeadingZeros32.c"
297 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_countLeadingZeros64.c"
298 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_countLeadingZeros8.c"
299 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_eq128.c"
300 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_invalidF128M.c"
301 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_isNaNF128M.c"
302 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_le128.c"
303 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_lt128.c"
304 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_mul128MTo256M.c"
305 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_mul64To128M.c"
306 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_mulAddF128M.c"
307 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_mulAddF16.c"
308 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_mulAddF32.c"
309 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_mulAddF64.c"
310 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_negXM.c"
311 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_normRoundPackMToF128M.c"
312 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_normRoundPackToF16.c"
313 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_normRoundPackToF32.c"
314 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_normRoundPackToF64.c"
315 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_normSubnormalF128SigM.c"
316 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_normSubnormalF16Sig.c"
317 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_normSubnormalF32Sig.c"
318 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_normSubnormalF64Sig.c"
319 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_remStepMBy32.c"
320 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_roundMToI64.c"
321 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_roundMToUI64.c"
322 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_roundPackMToF128M.c"
323 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_roundPackToF16.c"
324 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_roundPackToF32.c"
325 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_roundPackToF64.c"
326 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_roundToI32.c"
327 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_roundToI64.c"
328 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_roundToUI32.c"
329 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_roundToUI64.c"
330 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_shiftLeftM.c"
331 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_shiftNormSigF128M.c"
332 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_shiftRightJam256M.c"
333 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_shiftRightJam32.c"
334 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_shiftRightJam64.c"
335 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_shiftRightJamM.c"
336 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_shiftRightM.c"
337 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_shortShiftLeft64To96M.c"
338 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_shortShiftLeftM.c"
339 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_shortShiftRightExtendM.c"
340 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_shortShiftRightJam64.c"
341 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_shortShiftRightJamM.c"
342 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_shortShiftRightM.c"
343 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_sub1XM.c"
344 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_sub256M.c"
345 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_subM.c"
346 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_subMagsF16.c"
347 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_subMagsF32.c"
348 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_subMagsF64.c"
349 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/s_tryPropagateNaNF128M.c"
350 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/softfloat_state.c"
351 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/ui32_to_f128M.c"
352 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/ui64_to_f128M.c"
245 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/f128M_isSignalingNaN.c"
246 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_commonNaNToF128M.c"
247 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_commonNaNToF32UI.c"
248 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_commonNaNToF64UI.c"
249 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_f128MToCommonNaN.c"
250 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_f32UIToCommonNaN.c"
251 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_f64UIToCommonNaN.c"
252 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_propagateNaNF128M.c"
253 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/softfloat_raiseFlags.c"
254 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_add.c"
255 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_div.c"
256 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_eq.c"
257 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_eq_signaling.c"
258 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_le.c"
259 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_le_quiet.c"
260 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_lt.c"
261 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_lt_quiet.c"
262 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_mul.c"
263 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_mulAdd.c"
264 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_rem.c"
265 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_roundToInt.c"
266 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_sqrt.c"
267 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_sub.c"
268 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_f16.c"
269 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_f32.c"
270 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_f64.c"
271 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_i32.c"
272 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_i32_r_minMag.c"
273 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_i64.c"
274 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_i64_r_minMag.c"
275 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_ui32.c"
276 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_ui32_r_minMag.c"
277 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_ui64.c"
278 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_ui64_r_minMag.c"
279 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f32_to_f128M.c"
280 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f64_to_f128M.c"
281 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_add256M.c"
282 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addCarryM.c"
283 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addComplCarryM.c"
284 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addF128M.c"
285 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addM.c"
286 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addMagsF16.c"
287 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addMagsF32.c"
288 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addMagsF64.c"
289 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_approxRecip32_1.c"
290 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_approxRecipSqrt32_1.c"
291 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_approxRecipSqrt_1Ks.c"
292 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_approxRecip_1Ks.c"
293 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_compare128M.c"
294 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_compare96M.c"
295 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_countLeadingZeros16.c"
296 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_countLeadingZeros32.c"
297 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_countLeadingZeros64.c"
298 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_countLeadingZeros8.c"
299 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_eq128.c"
300 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_invalidF128M.c"
301 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_isNaNF128M.c"
302 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_le128.c"
303 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_lt128.c"
304 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_mul128MTo256M.c"
305 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_mul64To128M.c"
306 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_mulAddF128M.c"
307 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_mulAddF16.c"
308 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_mulAddF32.c"
309 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_mulAddF64.c"
310 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_negXM.c"
311 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normRoundPackMToF128M.c"
312 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normRoundPackToF16.c"
313 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normRoundPackToF32.c"
314 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normRoundPackToF64.c"
315 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normSubnormalF128SigM.c"
316 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normSubnormalF16Sig.c"
317 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normSubnormalF32Sig.c"
318 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normSubnormalF64Sig.c"
319 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_remStepMBy32.c"
320 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundMToI64.c"
321 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundMToUI64.c"
322 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundPackMToF128M.c"
323 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundPackToF16.c"
324 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundPackToF32.c"
325 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundPackToF64.c"
326 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundToI32.c"
327 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundToI64.c"
328 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundToUI32.c"
329 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundToUI64.c"
330 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shiftLeftM.c"
331 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shiftNormSigF128M.c"
332 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shiftRightJam256M.c"
333 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shiftRightJam32.c"
334 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shiftRightJam64.c"
335 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shiftRightJamM.c"
336 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shiftRightM.c"
337 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shortShiftLeft64To96M.c"
338 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shortShiftLeftM.c"
339 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shortShiftRightExtendM.c"
340 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shortShiftRightJam64.c"
341 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shortShiftRightJamM.c"
342 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_shortShiftRightM.c"
343 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_sub1XM.c"
344 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_sub256M.c"
345 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_subM.c"
346 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_subMagsF16.c"
347 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_subMagsF32.c"
348 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_subMagsF64.c"
349 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_tryPropagateNaNF128M.c"
350 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/softfloat_state.c"
351 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/ui32_to_f128M.c"
352 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/ui64_to_f128M.c"
353353)
354354add_library(embedded_softfloat ${EMBEDDED_SOFTFLOAT_SOURCES})
355355if(MSVC)
......@@ -362,10 +362,10 @@ else()
362362 )
363363endif()
364364target_include_directories(embedded_softfloat PUBLIC
365 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d-prebuilt"
366 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/8086"
365 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e-prebuilt"
366 "${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086"
367367)
368include_directories("${CMAKE_SOURCE_DIR}/deps/SoftFloat-3d/source/include")
368include_directories("${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/include")
369369set(SOFTFLOAT_LIBRARIES embedded_softfloat)
370370
371371find_package(Threads)
deps/SoftFloat-3d-prebuilt/platform.h deleted-97
......@@ -1,97 +0,0 @@
1#ifndef ZIG_DEP_SOFTFLOAT_PLATFORM_H
2#define ZIG_DEP_SOFTFLOAT_PLATFORM_H
3
4#if defined(__BIG_ENDIAN__)
5#define BIGENDIAN 1
6#elif defined(__ARMEB__)
7#define BIGENDIAN 1
8#elif defined(__THUMBEB__)
9#define BIGENDIAN 1
10#elif defined(__AARCH64EB__)
11#define BIGENDIAN 1
12#elif defined(_MIPSEB)
13#define BIGENDIAN 1
14#elif defined(__MIPSEB)
15#define BIGENDIAN 1
16#elif defined(__MIPSEB__)
17#define BIGENDIAN 1
18#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
19#define BIGENDIAN 1
20#elif defined(_BIG_ENDIAN)
21#define BIGENDIAN 1
22#elif defined(__sparc)
23#define BIGENDIAN 1
24#elif defined(__sparc__)
25#define BIGENDIAN 1
26#elif defined(_POWER)
27#define BIGENDIAN 1
28#elif defined(__powerpc__)
29#define BIGENDIAN 1
30#elif defined(__ppc__)
31#define BIGENDIAN 1
32#elif defined(__hpux)
33#define BIGENDIAN 1
34#elif defined(__hppa)
35#define BIGENDIAN 1
36#elif defined(_POWER)
37#define BIGENDIAN 1
38#elif defined(__s390__)
39#define BIGENDIAN 1
40#elif defined(__LITTLE_ENDIAN__)
41#define LITTLEENDIAN 1
42#elif defined(__ARMEL__)
43#define LITTLEENDIAN 1
44#elif defined(__THUMBEL__)
45#define LITTLEENDIAN 1
46#elif defined(__AARCH64EL__)
47#define LITTLEENDIAN 1
48#elif defined(_MIPSEL)
49#define LITTLEENDIAN 1
50#elif defined(__MIPSEL)
51#define LITTLEENDIAN 1
52#elif defined(__MIPSEL__)
53#define LITTLEENDIAN 1
54#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
55#define LITTLEENDIAN 1
56#elif defined(_LITTLE_ENDIAN)
57#define LITTLEENDIAN 1
58#elif defined(__i386__)
59#define LITTLEENDIAN 1
60#elif defined(__alpha__)
61#define LITTLEENDIAN 1
62#elif defined(__ia64)
63#define LITTLEENDIAN 1
64#elif defined(__ia64__)
65#define LITTLEENDIAN 1
66#elif defined(_M_IX86)
67#define LITTLEENDIAN 1
68#elif defined(_M_IA64)
69#define LITTLEENDIAN 1
70#elif defined(_M_ALPHA)
71#define LITTLEENDIAN 1
72#elif defined(__amd64)
73#define LITTLEENDIAN 1
74#elif defined(__amd64__)
75#define LITTLEENDIAN 1
76#elif defined(_M_AMD64)
77#define LITTLEENDIAN 1
78#elif defined(__x86_64)
79#define LITTLEENDIAN 1
80#elif defined(__x86_64__)
81#define LITTLEENDIAN 1
82#elif defined(_M_X64)
83#define LITTLEENDIAN 1
84#elif defined(__bfin__)
85#define LITTLEENDIAN 1
86#else
87#error unable to detect endianness
88#endif
89
90#define INLINE inline
91#if _MSC_VER
92#define THREAD_LOCAL __declspec(thread)
93#else
94#define THREAD_LOCAL __thread
95#endif
96
97#endif
deps/SoftFloat-3d/COPYING.txt deleted-37
......@@ -1,37 +0,0 @@
1
2License for Berkeley SoftFloat Release 3d
3
4John R. Hauser
52017 August 10
6
7The following applies to the whole of SoftFloat Release 3d as well as to
8each source file individually.
9
10Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
11University of California. All rights reserved.
12
13Redistribution and use in source and binary forms, with or without
14modification, are permitted provided that the following conditions are met:
15
16 1. Redistributions of source code must retain the above copyright notice,
17 this list of conditions, and the following disclaimer.
18
19 2. Redistributions in binary form must reproduce the above copyright
20 notice, this list of conditions, and the following disclaimer in the
21 documentation and/or other materials provided with the distribution.
22
23 3. Neither the name of the University nor the names of its contributors
24 may be used to endorse or promote products derived from this software
25 without specific prior written permission.
26
27THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
28EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
29WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
30DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
31DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
32(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
34ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
36THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
deps/SoftFloat-3d/README.html deleted-49
......@@ -1,49 +0,0 @@
1
2<HTML>
3
4<HEAD>
5<TITLE>Berkeley SoftFloat Package Overview</TITLE>
6</HEAD>
7
8<BODY>
9
10<H1>Package Overview for Berkeley SoftFloat Release 3d</H1>
11
12<P>
13John R. Hauser<BR>
142017 August 10<BR>
15</P>
16
17<P>
18Berkeley SoftFloat is a software implementation of binary floating-point that
19conforms to the IEEE Standard for Floating-Point Arithmetic.
20SoftFloat is distributed in the form of C source code.
21Building the SoftFloat sources generates a library file (typically
22<CODE>softfloat.a</CODE> or <CODE>libsoftfloat.a</CODE>) containing the
23floating-point subroutines.
24</P>
25
26<P>
27The SoftFloat package is documented in the following files in the
28<CODE>doc</CODE> subdirectory:
29<BLOCKQUOTE>
30<TABLE>
31<TR>
32<TD><A HREF="doc/SoftFloat.html"><NOBR><CODE>SoftFloat.html</CODE></NOBR></A></TD>
33<TD>Documentation for using the SoftFloat functions.</TD>
34</TR>
35<TR>
36<TD><A HREF="doc/SoftFloat-source.html"><NOBR><CODE>SoftFloat-source.html</CODE></NOBR></A></TD>
37<TD>Documentation for building SoftFloat.</TD>
38</TR>
39<TR>
40<TD><A HREF="doc/SoftFloat-history.html"><NOBR><CODE>SoftFloat-history.html</CODE></A><CODE>&nbsp;&nbsp;&nbsp;</CODE></NOBR></TD>
41<TD>History of the major changes to SoftFloat.</TD>
42</TR>
43</TABLE>
44</BLOCKQUOTE>
45Other files in the package comprise the source code for SoftFloat.
46</P>
47
48</BODY>
49
deps/SoftFloat-3d/README.txt deleted-21
......@@ -1,21 +0,0 @@
1
2Package Overview for Berkeley SoftFloat Release 3d
3
4John R. Hauser
52017 August 10
6
7Berkeley SoftFloat is a software implementation of binary floating-point
8that conforms to the IEEE Standard for Floating-Point Arithmetic. SoftFloat
9is distributed in the form of C source code. Building the SoftFloat sources
10generates a library file (typically "softfloat.a" or "libsoftfloat.a")
11containing the floating-point subroutines.
12
13The SoftFloat package is documented in the following files in the "doc"
14subdirectory:
15
16 SoftFloat.html Documentation for using the SoftFloat functions.
17 SoftFloat-source.html Documentation for building SoftFloat.
18 SoftFloat-history.html History of the major changes to SoftFloat.
19
20Other files in the package comprise the source code for SoftFloat.
21
deps/SoftFloat-3d/doc/SoftFloat-history.html deleted-215
......@@ -1,215 +0,0 @@
1
2<HTML>
3
4<HEAD>
5<TITLE>Berkeley SoftFloat History</TITLE>
6</HEAD>
7
8<BODY>
9
10<H1>History of Berkeley SoftFloat, to Release 3d</H1>
11
12<P>
13John R. Hauser<BR>
142017 August 10<BR>
15</P>
16
17
18<H3>Release 3d (2017 August)</H3>
19
20<UL>
21
22<LI>
23Fixed bugs in the square root functions for <NOBR>64-bit</NOBR>
24double-precision, <NOBR>80-bit</NOBR> double-extended-precision, and
25<NOBR>128-bit</NOBR> quadruple-precision.
26For <NOBR>64-bit</NOBR> double-precision (<CODE>f64_sqrt</CODE>), the result
27could sometimes be off by <NOBR>1 unit</NOBR> in the last place
28(<NOBR>1 ulp</NOBR>) from what it should be.
29For the larger formats, the square root could be wrong in a large portion of
30the less-significant bits.
31(A bug in <CODE>f128_sqrt</CODE> was first reported by Alexei Sibidanov.)
32
33</UL>
34
35
36<H3>Release 3c (2017 February)</H3>
37
38<UL>
39
40<LI>
41Added optional rounding mode <CODE>odd</CODE> (round to odd, also known as
42<EM>jamming</EM>).
43
44<LI>
45Corrected the documentation concerning non-canonical representations in
46<NOBR>80-bit</NOBR> double-extended-precision.
47
48</UL>
49
50
51<H3>Release 3b (2016 July)</H3>
52
53<UL>
54
55<LI>
56Implemented the common <NOBR>16-bit</NOBR> &ldquo;half-precision&rdquo;
57floating-point format (<CODE>float16_t</CODE>).
58
59<LI>
60Made the integer values returned on invalid conversions to integer formats
61be determined by the port-specific specialization instead of being the same for
62all ports.
63
64<LI>
65Added preprocessor macro <CODE>THREAD_LOCAL</CODE> to allow the floating-point
66state (modes and exception flags) to be made per-thread.
67
68<LI>
69Modified the provided Makefiles to allow some options to be overridden from the
70<CODE>make</CODE> command.
71
72<LI>
73Made other minor improvements.
74
75</UL>
76
77
78<H3>Release 3a (2015 October)</H3>
79
80<UL>
81
82<LI>
83Replaced the license text supplied by the University of California, Berkeley.
84
85</UL>
86
87
88<H3>Release 3 (2015 February)</H3>
89
90<UL>
91
92<LI>
93Complete rewrite, funded by the University of California, Berkeley, and
94consequently having a different use license than earlier releases.
95Major changes included renaming most types and functions, upgrading some
96algorithms, restructuring the source files, and making SoftFloat into a true
97library.
98
99<LI>
100Added functions to convert between floating-point and unsigned integers, both
101<NOBR>32-bit</NOBR> and <NOBR>64-bit</NOBR> (<CODE>uint32_t</CODE> and
102<CODE>uint64_t</CODE>).
103
104<LI>
105Added functions for fused multiply-add, for all supported floating-point
106formats except <NOBR>80-bit</NOBR> double-extended-precision.
107
108<LI>
109Added support for a fifth rounding mode, <CODE>near_maxMag</CODE> (round to
110nearest, with ties to maximum magnitude, away from zero).
111
112<LI>
113Dropped the <CODE>timesoftfloat</CODE> program (now part of the Berkeley
114TestFloat package).
115
116</UL>
117
118
119<H3>Release 2c (2015 January)</H3>
120
121<UL>
122
123<LI>
124Fixed mistakes affecting some <NOBR>64-bit</NOBR> processors.
125
126<LI>
127Further improved the documentation and the wording for the legal restrictions
128on using SoftFloat releases <NOBR>through 2c</NOBR> (not applicable to
129<NOBR>Release 3</NOBR> or later).
130
131</UL>
132
133
134<H3>Release 2b (2002 May)</H3>
135
136<UL>
137
138<LI>
139Made minor updates to the documentation, including improved wording for the
140legal restrictions on using SoftFloat.
141
142</UL>
143
144
145<H3>Release 2a (1998 December)</H3>
146
147<UL>
148
149<LI>
150Added functions to convert between <NOBR>64-bit</NOBR> integers
151(<CODE>int64</CODE>) and all supported floating-point formats.
152
153<LI>
154Fixed a bug in all <NOBR>64-bit</NOBR>-version square root functions except
155<CODE>float32_sqrt</CODE> that caused the result sometimes to be off by
156<NOBR>1 unit</NOBR> in the last place (<NOBR>1 ulp</NOBR>) from what it should
157be.
158(Bug discovered by Paul Donahue.)
159
160<LI>
161Improved the Makefiles.
162</UL>
163
164
165<H3>Release 2 (1997 June)</H3>
166
167<UL>
168
169<LI>
170Created the <NOBR>64-bit</NOBR> (<CODE>bits64</CODE>) version, adding the
171<CODE>floatx80</CODE> and <CODE>float128</CODE> formats.
172
173<LI>
174Changed the source directory structure, splitting the sources into a
175<CODE>bits32</CODE> and a <CODE>bits64</CODE> version.
176Renamed <CODE>environment.h</CODE> to <CODE>milieu.h</CODE> to avoid confusion
177with environment variables.
178
179<LI>
180Fixed a small error that caused <CODE>float64_round_to_int</CODE> often to
181round the wrong way in nearest/even mode when the operand was between
1822<SUP>20</SUP> and 2<SUP>21</SUP> and halfway between two integers.
183
184</UL>
185
186
187<H3>Release 1a (1996 July)</H3>
188
189<UL>
190
191<LI>
192Corrected a mistake that caused borderline underflow cases not to raise the
193underflow flag when they should have.
194(Problem reported by Doug Priest.)
195
196<LI>
197Added the <CODE>float_detect_tininess</CODE> variable to control whether
198tininess is detected before or after rounding.
199
200</UL>
201
202
203<H3>Release 1 (1996 July)</H3>
204
205<UL>
206
207<LI>
208Original release, based on work done for the International Computer Science
209Institute (ICSI) in Berkeley, California.
210
211</UL>
212
213
214</BODY>
215
deps/SoftFloat-3d/doc/SoftFloat-source.html deleted-633
......@@ -1,633 +0,0 @@
1
2<HTML>
3
4<HEAD>
5<TITLE>Berkeley SoftFloat Source Documentation</TITLE>
6</HEAD>
7
8<BODY>
9
10<H1>Berkeley SoftFloat Release 3d: Source Documentation</H1>
11
12<P>
13John R. Hauser<BR>
142017 August 10<BR>
15</P>
16
17
18<H2>Contents</H2>
19
20<BLOCKQUOTE>
21<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>
22<COL WIDTH=25>
23<COL WIDTH=*>
24<TR><TD COLSPAN=2>1. Introduction</TD></TR>
25<TR><TD COLSPAN=2>2. Limitations</TD></TR>
26<TR><TD COLSPAN=2>3. Acknowledgments and License</TD></TR>
27<TR><TD COLSPAN=2>4. SoftFloat Package Directory Structure</TD></TR>
28<TR><TD COLSPAN=2>5. Issues for Porting SoftFloat to a New Target</TD></TR>
29<TR>
30 <TD></TD>
31 <TD>5.1. Standard Headers <CODE>&lt;stdbool.h&gt;</CODE> and
32 <CODE>&lt;stdint.h&gt;</CODE></TD>
33</TR>
34<TR><TD></TD><TD>5.2. Specializing Floating-Point Behavior</TD></TR>
35<TR><TD></TD><TD>5.3. Macros for Build Options</TD></TR>
36<TR><TD></TD><TD>5.4. Adapting a Template Target Directory</TD></TR>
37<TR>
38 <TD></TD><TD>5.5. Target-Specific Optimization of Primitive Functions</TD>
39</TR>
40<TR><TD COLSPAN=2>6. Testing SoftFloat</TD></TR>
41<TR>
42 <TD COLSPAN=2>7. Providing SoftFloat as a Common Library for Applications</TD>
43</TR>
44<TR><TD COLSPAN=2>8. Contact Information</TD></TR>
45</TABLE>
46</BLOCKQUOTE>
47
48
49<H2>1. Introduction</H2>
50
51<P>
52This document gives information needed for compiling and/or porting Berkeley
53SoftFloat, a library of C functions implementing binary floating-point
54conforming to the IEEE Standard for Floating-Point Arithmetic.
55For basic documentation about SoftFloat refer to
56<A HREF="SoftFloat.html"><NOBR><CODE>SoftFloat.html</CODE></NOBR></A>.
57</P>
58
59<P>
60The source code for SoftFloat is intended to be relatively machine-independent
61and should be compilable with any ISO-Standard C compiler that also supports
62<NOBR>64-bit</NOBR> integers.
63SoftFloat has been successfully compiled with the GNU C Compiler
64(<CODE>gcc</CODE>) for several platforms.
65</P>
66
67<P>
68<NOBR>Release 3</NOBR> of SoftFloat was a complete rewrite relative to
69<NOBR>Release 2</NOBR> or earlier.
70Changes to the interface of SoftFloat functions are documented in
71<A HREF="SoftFloat.html"><NOBR><CODE>SoftFloat.html</CODE></NOBR></A>.
72The current version of SoftFloat is <NOBR>Release 3d</NOBR>.
73</P>
74
75
76<H2>2. Limitations</H2>
77
78<P>
79SoftFloat assumes the computer has an addressable byte size of either 8 or
80<NOBR>16 bits</NOBR>.
81(Nearly all computers in use today have <NOBR>8-bit</NOBR> bytes.)
82</P>
83
84<P>
85SoftFloat is written in C and is designed to work with other C code.
86The C compiler used must conform at a minimum to the 1989 ANSI standard for the
87C language (same as the 1990 ISO standard) and must in addition support basic
88arithmetic on <NOBR>64-bit</NOBR> integers.
89Earlier releases of SoftFloat included implementations of <NOBR>32-bit</NOBR>
90single-precision and <NOBR>64-bit</NOBR> double-precision floating-point that
91did not require <NOBR>64-bit</NOBR> integers, but this option is not supported
92starting with <NOBR>Release 3</NOBR>.
93Since 1999, ISO standards for C have mandated compiler support for
94<NOBR>64-bit</NOBR> integers.
95A compiler conforming to the 1999 C Standard or later is recommended but not
96strictly required.
97</P>
98
99<P>
100<NOBR>C Standard</NOBR> header files <CODE>&lt;stdbool.h&gt;</CODE> and
101<CODE>&lt;stdint.h&gt;</CODE> are required for defining standard Boolean and
102integer types.
103If these headers are not supplied with the C compiler, minimal substitutes must
104be provided.
105SoftFloat&rsquo;s dependence on these headers is detailed later in
106<NOBR>section 5.1</NOBR>, <I>Standard Headers <CODE>&lt;stdbool.h&gt;</CODE>
107and <CODE>&lt;stdint.h&gt;</CODE></I>.
108</P>
109
110
111<H2>3. Acknowledgments and License</H2>
112
113<P>
114The SoftFloat package was written by me, <NOBR>John R.</NOBR> Hauser.
115<NOBR>Release 3</NOBR> of SoftFloat was a completely new implementation
116supplanting earlier releases.
117The project to create <NOBR>Release 3</NOBR> (now <NOBR>through 3d</NOBR>) was
118done in the employ of the University of California, Berkeley, within the
119Department of Electrical Engineering and Computer Sciences, first for the
120Parallel Computing Laboratory (Par Lab) and then for the ASPIRE Lab.
121The work was officially overseen by Prof. Krste Asanovic, with funding provided
122by these sources:
123<BLOCKQUOTE>
124<TABLE>
125<COL>
126<COL WIDTH=10>
127<COL>
128<TR>
129<TD VALIGN=TOP><NOBR>Par Lab:</NOBR></TD>
130<TD></TD>
131<TD>
132Microsoft (Award #024263), Intel (Award #024894), and U.C. Discovery
133(Award #DIG07-10227), with additional support from Par Lab affiliates Nokia,
134NVIDIA, Oracle, and Samsung.
135</TD>
136</TR>
137<TR>
138<TD VALIGN=TOP><NOBR>ASPIRE Lab:</NOBR></TD>
139<TD></TD>
140<TD>
141DARPA PERFECT program (Award #HR0011-12-2-0016), with additional support from
142ASPIRE industrial sponsor Intel and ASPIRE affiliates Google, Nokia, NVIDIA,
143Oracle, and Samsung.
144</TD>
145</TR>
146</TABLE>
147</BLOCKQUOTE>
148</P>
149
150<P>
151The following applies to the whole of SoftFloat <NOBR>Release 3d</NOBR> as well
152as to each source file individually.
153</P>
154
155<P>
156Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
157University of California.
158All rights reserved.
159</P>
160
161<P>
162Redistribution and use in source and binary forms, with or without
163modification, are permitted provided that the following conditions are met:
164<OL>
165
166<LI>
167<P>
168Redistributions of source code must retain the above copyright notice, this
169list of conditions, and the following disclaimer.
170</P>
171
172<LI>
173<P>
174Redistributions in binary form must reproduce the above copyright notice, this
175list of conditions, and the following disclaimer in the documentation and/or
176other materials provided with the distribution.
177</P>
178
179<LI>
180<P>
181Neither the name of the University nor the names of its contributors may be
182used to endorse or promote products derived from this software without specific
183prior written permission.
184</P>
185
186</OL>
187</P>
188
189<P>
190THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS &ldquo;AS IS&rdquo;,
191AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
192IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
193DISCLAIMED.
194IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
195INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
196BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
197DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
198LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
199OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
200ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
201</P>
202
203
204<H2>4. SoftFloat Package Directory Structure</H2>
205
206<P>
207Because SoftFloat is targeted to multiple platforms, its source code is
208slightly scattered between target-specific and target-independent directories
209and files.
210The supplied directory structure is as follows:
211<BLOCKQUOTE>
212<PRE>
213doc
214source
215 include
216 8086
217 8086-SSE
218build
219 template-FAST_INT64
220 template-not-FAST_INT64
221 Linux-386-GCC
222 Linux-386-SSE2-GCC
223 Linux-x86_64-GCC
224 Win32-MinGW
225 Win32-SSE2-MinGW
226 Win64-MinGW-w64
227</PRE>
228</BLOCKQUOTE>
229The majority of the SoftFloat sources are provided in the <CODE>source</CODE>
230directory.
231The <CODE>include</CODE> subdirectory of <CODE>source</CODE> contains several
232header files (unsurprisingly), while the <CODE>8086</CODE> and
233<NOBR><CODE>8086-SSE</CODE></NOBR> subdirectories contain source files that
234specialize the floating-point behavior to match the Intel x86 line of
235processors.
236The files in directory <CODE>8086</CODE> give floating-point behavior
237consistent solely with Intel&rsquo;s older, 8087-derived floating-point, while
238those in <NOBR><CODE>8086-SSE</CODE></NOBR> update the behavior of the
239non-extended formats (<CODE>float16_t</CODE>, <CODE>float32_t</CODE>,
240<CODE>float64_t</CODE>, and <CODE>float128_t</CODE>) to mirror Intel&rsquo;s
241more recent Streaming SIMD Extensions (SSE) and other compatible extensions.
242If other specializations are attempted, these would be expected to be other
243subdirectories of <CODE>source</CODE> alongside <CODE>8086</CODE> and
244<NOBR><CODE>8086-SSE</CODE></NOBR>.
245Specialization is covered later, in <NOBR>section 5.2</NOBR>, <I>Specializing
246Floating-Point Behavior</I>.
247</P>
248
249<P>
250The <CODE>build</CODE> directory is intended to contain a subdirectory for each
251target platform for which a build of the SoftFloat library may be created.
252For each build target, the target&rsquo;s subdirectory is where all derived
253object files and the completed SoftFloat library (typically
254<CODE>softfloat.a</CODE> or <CODE>libsoftfloat.a</CODE>) are created.
255The two <CODE>template</CODE> subdirectories are not actual build targets but
256contain sample files for creating new target directories.
257(The meaning of <CODE>FAST_INT64</CODE> will be explained later.)
258</P>
259
260<P>
261Ignoring the <CODE>template</CODE> directories, the supplied target directories
262are intended to follow a naming system of
263<NOBR><CODE>&lt;<I>execution-environment</I>&gt;-&lt;<I>compiler</I>&gt;</CODE></NOBR>.
264For the example targets,
265<NOBR><CODE>&lt;<I>execution-environment</I>&gt;</CODE></NOBR> is
266<NOBR><CODE>Linux-386</CODE></NOBR>, <NOBR><CODE>Linux-386-SSE2</CODE></NOBR>,
267<NOBR><CODE>Linux-x86_64</CODE></NOBR>, <CODE>Win32</CODE>,
268<NOBR><CODE>Win32-SSE2</CODE></NOBR>, or <CODE>Win64</CODE>, and
269<NOBR><CODE>&lt;<I>compiler</I>&gt;</CODE></NOBR> is <CODE>GCC</CODE>,
270<CODE>MinGW</CODE>, or <NOBR><CODE>MinGW-w64</CODE></NOBR>.
271</P>
272
273<P>
274At the current time, all of the supplied target directories are merely examples
275that may or may not be correct for compiling on any particular system.
276Despite requests, there are currently no plans to include and maintain in the
277SoftFloat package the build files needed for a great many users&rsquo;
278compilation environments, which after all can span a broad range of operating
279systems, compilers, and other tools.
280</P>
281
282<P>
283As supplied, each target directory contains two files:
284<BLOCKQUOTE>
285<PRE>
286Makefile
287platform.h
288</PRE>
289</BLOCKQUOTE>
290The provided <CODE>Makefile</CODE> is written for GNU <CODE>make</CODE>.
291A build of SoftFloat for the specific target is begun by executing the
292<CODE>make</CODE> command with the target directory as the current directory.
293A completely different build tool can be used if an appropriate
294<CODE>Makefile</CODE> equivalent is created.
295</P>
296
297<P>
298The <CODE>platform.h</CODE> header file exists to provide a location for
299additional C declarations specific to the build target.
300Every C source file of SoftFloat contains a <CODE>#include</CODE> for
301<CODE>platform.h</CODE>.
302In many cases, the contents of <CODE>platform.h</CODE> can be as simple as one
303or two lines of code.
304At the other extreme, to get maximal performance from SoftFloat, it may be
305desirable to include in header <CODE>platform.h</CODE> (directly or via
306<CODE>#include</CODE>) declarations for numerous target-specific optimizations.
307Such possibilities are discussed in the next section, <I>Issues for Porting
308SoftFloat to a New Target</I>.
309If the target&rsquo;s compiler or library has bugs or other shortcomings,
310workarounds for these issues may also be possible with target-specific
311declarations in <CODE>platform.h</CODE>, avoiding the need to modify the main
312SoftFloat sources.
313</P>
314
315
316<H2>5. Issues for Porting SoftFloat to a New Target</H2>
317
318<H3>5.1. Standard Headers <CODE>&lt;stdbool.h&gt;</CODE> and <CODE>&lt;stdint.h&gt;</CODE></H3>
319
320<P>
321The SoftFloat sources make use of standard headers
322<CODE>&lt;stdbool.h&gt;</CODE> and <CODE>&lt;stdint.h&gt;</CODE>, which have
323been part of the ISO C Standard Library since 1999.
324With any recent compiler, these standard headers are likely to be supported,
325even if the compiler does not claim complete conformance to the latest ISO C
326Standard.
327For older or nonstandard compilers, substitutes for
328<CODE>&lt;stdbool.h&gt;</CODE> and <CODE>&lt;stdint.h&gt;</CODE> may need to be
329created.
330SoftFloat depends on these names from <CODE>&lt;stdbool.h&gt;</CODE>:
331<BLOCKQUOTE>
332<PRE>
333bool
334true
335false
336</PRE>
337</BLOCKQUOTE>
338and on these names from <CODE>&lt;stdint.h&gt;</CODE>:
339<BLOCKQUOTE>
340<PRE>
341uint16_t
342uint32_t
343uint64_t
344int32_t
345int64_t
346UINT64_C
347INT64_C
348uint_least8_t
349uint_fast8_t
350uint_fast16_t
351uint_fast32_t
352uint_fast64_t
353int_fast8_t
354int_fast16_t
355int_fast32_t
356int_fast64_t
357</PRE>
358</BLOCKQUOTE>
359</P>
360
361
362<H3>5.2. Specializing Floating-Point Behavior</H3>
363
364<P>
365The IEEE Floating-Point Standard allows for some flexibility in a conforming
366implementation, particularly concerning NaNs.
367The SoftFloat <CODE>source</CODE> directory is supplied with some
368<I>specialization</I> subdirectories containing possible definitions for this
369implementation-specific behavior.
370For example, the <CODE>8086</CODE> and <NOBR><CODE>8086-SSE</CODE></NOBR>
371subdirectories have source files that specialize SoftFloat&rsquo;s behavior to
372match that of Intel&rsquo;s x86 line of processors.
373The files in a specialization subdirectory must determine:
374<UL>
375<LI>
376whether tininess for underflow is detected before or after rounding by default;
377<LI>
378how signaling NaNs are distinguished from quiet NaNs;
379<LI>
380what (if anything) special happens when exceptions are raised;
381<LI>
382the default generated quiet NaNs;
383<LI>
384how NaNs are propagated from function inputs to output; and
385<LI>
386the integer results returned when conversions to integer type raise the
387<I>invalid</I> exception.
388</UL>
389</P>
390
391<P>
392As provided, the build process for a target expects to involve exactly
393<EM>one</EM> specialization directory that defines <EM>all</EM> of these
394implementation-specific details for the target.
395A specialization directory such as <CODE>8086</CODE> is expected to contain a
396header file called <CODE>specialize.h</CODE>, together with whatever other
397source files are needed to complete the specialization.
398</P>
399
400<P>
401A new build target may use an existing specialization, such as the ones
402provided by the <CODE>8086</CODE> and <NOBR><CODE>8086-SSE</CODE></NOBR>
403subdirectories.
404If a build target needs a new specialization, different from any existing ones,
405it is recommended that a new specialization subdirectory be created in the
406<CODE>source</CODE> directory for this purpose.
407The <CODE>specialize.h</CODE> header file from any of the provided
408specialization subdirectories can be used as a model for what definitions are
409needed.
410</P>
411
412
413<H3>5.3. Macros for Build Options</H3>
414
415<P>
416The SoftFloat source files adapt the floating-point implementation according to
417several C preprocessor macros:
418<BLOCKQUOTE>
419<DL>
420<DT><CODE>LITTLEENDIAN</CODE>
421<DD>
422Must be defined for little-endian machines; must not be defined for big-endian
423machines.
424<DT><CODE>INLINE</CODE>
425<DD>
426Specifies the sequence of tokens used to indicate that a C function should be
427inlined.
428If macro <CODE>INLINE_LEVEL</CODE> is defined with a value of 1 or higher, this
429macro must be defined; otherwise, this macro is ignored and need not be
430defined.
431For compilers that conform to the C Standard&rsquo;s rules for inline
432functions, this macro can be defined as the single keyword <CODE>inline</CODE>.
433For other compilers that follow a convention pre-dating the standardization of
434<CODE>inline</CODE>, this macro may need to be defined to <CODE>extern</CODE>
435<CODE>inline</CODE>.
436<DT><CODE>THREAD_LOCAL</CODE>
437<DD>
438Can be defined to a sequence of tokens that, when appearing at the start of a
439variable declaration, indicates to the C compiler that the variable is
440<I>per-thread</I>, meaning that each execution thread gets its own separate
441instance of the variable.
442This macro is used in header <CODE>softfloat.h</CODE> in the declarations of
443variables <CODE>softfloat_roundingMode</CODE>,
444<CODE>softfloat_detectTininess</CODE>, <CODE>extF80_roundingPrecision</CODE>,
445and <CODE>softfloat_exceptionFlags</CODE>.
446If macro <CODE>THREAD_LOCAL</CODE> is left undefined, these variables will
447default to being ordinary global variables.
448Depending on the compiler, possible valid definitions of this macro include
449<CODE>_Thread_local</CODE> and <CODE>__thread</CODE>.
450</DL>
451<DL>
452<DT><CODE>SOFTFLOAT_ROUND_ODD</CODE>
453<DD>
454Can be defined to enable support for optional rounding mode
455<CODE>softfloat_round_odd</CODE>.
456</DL>
457<DL>
458<DT><CODE>INLINE_LEVEL</CODE>
459<DD>
460Can be defined to an integer to determine the degree of inlining requested of
461the compiler.
462Larger numbers request that more inlining be done.
463If this macro is not defined or is defined to a value less <NOBR>than 1</NOBR>
464(zero or negative), no inlining is requested.
465The maximum effective value is no higher <NOBR>than 5</NOBR>.
466Defining this macro to a value greater than 5 is the same as defining it
467<NOBR>to 5</NOBR>.
468<DT><CODE>SOFTFLOAT_FAST_INT64</CODE>
469<DD>
470Can be defined to indicate that the build target&rsquo;s implementation of
471<NOBR>64-bit</NOBR> arithmetic is efficient.
472For newer <NOBR>64-bit</NOBR> processors, this macro should usually be defined.
473For very small microprocessors whose buses and registers are <NOBR>8-bit</NOBR>
474or <NOBR>16-bit</NOBR> in size, this macro should usually not be defined.
475Whether this macro should be defined for a <NOBR>32-bit</NOBR> processor may
476depend on the target machine and the applications that will use SoftFloat.
477<DT><CODE>SOFTFLOAT_FAST_DIV32TO16</CODE>
478<DD>
479Can be defined to indicate that the target&rsquo;s division operator
480<NOBR>in C</NOBR> (written as <CODE>/</CODE>) is reasonably efficient for
481dividing a <NOBR>32-bit</NOBR> unsigned integer by a <NOBR>16-bit</NOBR>
482unsigned integer.
483Setting this macro may affect the performance of function <CODE>f16_div</CODE>.
484<DT><CODE>SOFTFLOAT_FAST_DIV64TO32</CODE>
485<DD>
486Can be defined to indicate that the target&rsquo;s division operator
487<NOBR>in C</NOBR> (written as <CODE>/</CODE>) is reasonably efficient for
488dividing a <NOBR>64-bit</NOBR> unsigned integer by a <NOBR>32-bit</NOBR>
489unsigned integer.
490Setting this macro may affect the performance of division, remainder, and
491square root operations other than <CODE>f16_div</CODE>.
492</DL>
493</BLOCKQUOTE>
494</P>
495
496<P>
497Following the usual custom <NOBR>for C</NOBR>, for most of these macros (all
498except <CODE>INLINE</CODE>, <CODE>THREAD_LOCAL</CODE>, and
499<CODE>INLINE_LEVEL</CODE>), the content of any definition is irrelevant;
500what matters is a macro&rsquo;s effect on <CODE>#ifdef</CODE> directives.
501</P>
502
503<P>
504It is recommended that any definitions of macros <CODE>LITTLEENDIAN</CODE>,
505<CODE>INLINE</CODE>, and <CODE>THREAD_LOCAL</CODE> be made in a build
506target&rsquo;s <CODE>platform.h</CODE> header file, because these macros are
507expected to be determined inflexibly by the target machine and compiler.
508The other five macros select options and control optimization, and thus might
509be better located in the target&rsquo;s Makefile (or its equivalent).
510</P>
511
512
513<H3>5.4. Adapting a Template Target Directory</H3>
514
515<P>
516In the <CODE>build</CODE> directory, two <CODE>template</CODE> subdirectories
517provide models for new target directories.
518Two different templates exist because different functions are needed in the
519SoftFloat library depending on whether macro <CODE>SOFTFLOAT_FAST_INT64</CODE>
520is defined.
521If macro <CODE>SOFTFLOAT_FAST_INT64</CODE> will be defined,
522<NOBR><CODE>template-FAST_INT64</CODE></NOBR> is the template to use;
523otherwise, <NOBR><CODE>template-not-FAST_INT64</CODE></NOBR> is the appropriate
524template.
525A new target directory can be created by copying the correct template directory
526and editing the files inside.
527To avoid confusion, it would be wise to refrain from editing the files within a
528template directory directly.
529</P>
530
531
532<H3>5.5. Target-Specific Optimization of Primitive Functions</H3>
533
534<P>
535Header file <CODE>primitives.h</CODE> (in directory
536<CODE>source/include</CODE>) declares macros and functions for numerous
537underlying arithmetic operations upon which many of SoftFloat&rsquo;s
538floating-point functions are ultimately built.
539The SoftFloat sources include implementations of all of these functions/macros,
540written as standard C code, so a complete and correct SoftFloat library can be
541created using only the supplied code for all functions.
542However, for many targets, SoftFloat&rsquo;s performance can be improved by
543substituting target-specific implementations of some of the functions/macros
544declared in <CODE>primitives.h</CODE>.
545</P>
546
547<P>
548For example, <CODE>primitives.h</CODE> declares a function called
549<CODE>softfloat_countLeadingZeros32</CODE> that takes an unsigned
550<NOBR>32-bit</NOBR> integer as an argument and returns the number of the
551integer&rsquo;s most-significant bits that are zeros.
552While the SoftFloat sources include an implementation of this function written
553in <NOBR>standard C</NOBR>, many processors can perform this same function
554directly in only one or two machine instructions.
555An alternative, target-specific implementation that maps to those instructions
556is likely to be more efficient than the generic C code from the SoftFloat
557package.
558</P>
559
560<P>
561A build target can replace the supplied version of any function or macro of
562<CODE>primitives.h</CODE> by defining a macro with the same name in the
563target&rsquo;s <CODE>platform.h</CODE> header file.
564For this purpose, it may be helpful for <CODE>platform.h</CODE> to
565<CODE>#include</CODE> header file <CODE>primitiveTypes.h</CODE>, which defines
566types used for arguments and results of functions declared in
567<CODE>primitives.h</CODE>.
568When a desired replacement implementation is a function, not a macro, it is
569sufficient for <CODE>platform.h</CODE> to include the line
570<BLOCKQUOTE>
571<PRE>
572#define &lt;<I>function-name</I>&gt; &lt;<I>function-name</I>&gt;
573</PRE>
574</BLOCKQUOTE>
575where <NOBR><CODE>&lt;<I>function-name</I>&gt;</CODE></NOBR> is the name of the
576function.
577This technically defines <NOBR><CODE>&lt;<I>function-name</I>&gt;</CODE></NOBR>
578as a macro, but one that resolves to the same name, which may then be a
579function.
580(A preprocessor that conforms to the C Standard must limit recursive macro
581expansion from being applied more than once.)
582</P>
583
584
585<H2>6. Testing SoftFloat</H2>
586
587<P>
588SoftFloat can be tested using the <CODE>testsoftfloat</CODE> program by the
589same author.
590This program is part of the Berkeley TestFloat package available at the Web
591page
592<A HREF="http://www.jhauser.us/arithmetic/TestFloat.html"><NOBR><CODE>http://www.jhauser.us/arithmetic/TestFloat.html</CODE></NOBR></A>.
593The TestFloat package also has a program called <CODE>timesoftfloat</CODE> that
594measures the speed of SoftFloat&rsquo;s floating-point functions.
595</P>
596
597
598<H2>7. Providing SoftFloat as a Common Library for Applications</H2>
599
600<P>
601Header file <CODE>softfloat.h</CODE> defines the SoftFloat interface as seen by
602clients.
603If the SoftFloat library will be made a common library for programs on a
604system, the supplied <CODE>softfloat.h</CODE> has a couple of deficiencies for
605this purpose:
606<UL>
607<LI>
608As supplied, <CODE>softfloat.h</CODE> depends on another header,
609<CODE>softfloat_types.h</CODE>, that is not intended for public use but which
610must also be visible to the programmer&rsquo;s compiler.
611<LI>
612More troubling, at the time <CODE>softfloat.h</CODE> is included in a C source
613file, macros <CODE>SOFTFLOAT_FAST_INT64</CODE> and <CODE>THREAD_LOCAL</CODE>
614must be defined, or not defined, consistent with how these macro were defined
615when the SoftFloat library was built.
616</UL>
617In the situation that new programs may regularly <CODE>#include</CODE> header
618file <CODE>softfloat.h</CODE>, it is recommended that a custom, self-contained
619version of this header file be created that eliminates these issues.
620</P>
621
622
623<H2>8. Contact Information</H2>
624
625<P>
626At the time of this writing, the most up-to-date information about SoftFloat
627and the latest release can be found at the Web page
628<A HREF="http://www.jhauser.us/arithmetic/SoftFloat.html"><NOBR><CODE>http://www.jhauser.us/arithmetic/SoftFloat.html</CODE></NOBR></A>.
629</P>
630
631
632</BODY>
633
deps/SoftFloat-3d/doc/SoftFloat.html deleted-1538
......@@ -1,1538 +0,0 @@
1
2<HTML>
3
4<HEAD>
5<TITLE>Berkeley SoftFloat Library Interface</TITLE>
6</HEAD>
7
8<BODY>
9
10<H1>Berkeley SoftFloat Release 3d: Library Interface</H1>
11
12<P>
13John R. Hauser<BR>
142017 August 10<BR>
15</P>
16
17
18<H2>Contents</H2>
19
20<BLOCKQUOTE>
21<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>
22<COL WIDTH=25>
23<COL WIDTH=*>
24<TR><TD COLSPAN=2>1. Introduction</TD></TR>
25<TR><TD COLSPAN=2>2. Limitations</TD></TR>
26<TR><TD COLSPAN=2>3. Acknowledgments and License</TD></TR>
27<TR><TD COLSPAN=2>4. Types and Functions</TD></TR>
28<TR><TD></TD><TD>4.1. Boolean and Integer Types</TD></TR>
29<TR><TD></TD><TD>4.2. Floating-Point Types</TD></TR>
30<TR><TD></TD><TD>4.3. Supported Floating-Point Functions</TD></TR>
31<TR>
32 <TD></TD>
33 <TD>4.4. Non-canonical Representations in <CODE>extFloat80_t</CODE></TD>
34</TR>
35<TR><TD></TD><TD>4.5. Conventions for Passing Arguments and Results</TD></TR>
36<TR><TD COLSPAN=2>5. Reserved Names</TD></TR>
37<TR><TD COLSPAN=2>6. Mode Variables</TD></TR>
38<TR><TD></TD><TD>6.1. Rounding Mode</TD></TR>
39<TR><TD></TD><TD>6.2. Underflow Detection</TD></TR>
40<TR>
41 <TD></TD>
42 <TD>6.3. Rounding Precision for the <NOBR>80-Bit</NOBR> Extended Format</TD>
43</TR>
44<TR><TD COLSPAN=2>7. Exceptions and Exception Flags</TD></TR>
45<TR><TD COLSPAN=2>8. Function Details</TD></TR>
46<TR><TD></TD><TD>8.1. Conversions from Integer to Floating-Point</TD></TR>
47<TR><TD></TD><TD>8.2. Conversions from Floating-Point to Integer</TD></TR>
48<TR><TD></TD><TD>8.3. Conversions Among Floating-Point Types</TD></TR>
49<TR><TD></TD><TD>8.4. Basic Arithmetic Functions</TD></TR>
50<TR><TD></TD><TD>8.5. Fused Multiply-Add Functions</TD></TR>
51<TR><TD></TD><TD>8.6. Remainder Functions</TD></TR>
52<TR><TD></TD><TD>8.7. Round-to-Integer Functions</TD></TR>
53<TR><TD></TD><TD>8.8. Comparison Functions</TD></TR>
54<TR><TD></TD><TD>8.9. Signaling NaN Test Functions</TD></TR>
55<TR><TD></TD><TD>8.10. Raise-Exception Function</TD></TR>
56<TR><TD COLSPAN=2>9. Changes from SoftFloat <NOBR>Release 2</NOBR></TD></TR>
57<TR><TD></TD><TD>9.1. Name Changes</TD></TR>
58<TR><TD></TD><TD>9.2. Changes to Function Arguments</TD></TR>
59<TR><TD></TD><TD>9.3. Added Capabilities</TD></TR>
60<TR><TD></TD><TD>9.4. Better Compatibility with the C Language</TD></TR>
61<TR><TD></TD><TD>9.5. New Organization as a Library</TD></TR>
62<TR><TD></TD><TD>9.6. Optimization Gains (and Losses)</TD></TR>
63<TR><TD COLSPAN=2>10. Future Directions</TD></TR>
64<TR><TD COLSPAN=2>11. Contact Information</TD></TR>
65</TABLE>
66</BLOCKQUOTE>
67
68
69<H2>1. Introduction</H2>
70
71<P>
72Berkeley SoftFloat is a software implementation of binary floating-point that
73conforms to the IEEE Standard for Floating-Point Arithmetic.
74The current release supports five binary formats: <NOBR>16-bit</NOBR>
75half-precision, <NOBR>32-bit</NOBR> single-precision, <NOBR>64-bit</NOBR>
76double-precision, <NOBR>80-bit</NOBR> double-extended-precision, and
77<NOBR>128-bit</NOBR> quadruple-precision.
78The following functions are supported for each format:
79<UL>
80<LI>
81addition, subtraction, multiplication, division, and square root;
82<LI>
83fused multiply-add as defined by the IEEE Standard, except for
84<NOBR>80-bit</NOBR> double-extended-precision;
85<LI>
86remainder as defined by the IEEE Standard;
87<LI>
88round to integral value;
89<LI>
90comparisons;
91<LI>
92conversions to/from other supported formats; and
93<LI>
94conversions to/from <NOBR>32-bit</NOBR> and <NOBR>64-bit</NOBR> integers,
95signed and unsigned.
96</UL>
97All operations required by the original 1985 version of the IEEE Floating-Point
98Standard are implemented, except for conversions to and from decimal.
99</P>
100
101<P>
102This document gives information about the types defined and the routines
103implemented by SoftFloat.
104It does not attempt to define or explain the IEEE Floating-Point Standard.
105Information about the standard is available elsewhere.
106</P>
107
108<P>
109The current version of SoftFloat is <NOBR>Release 3d</NOBR>.
110This release fixes bugs that were found in the square root functions for the
111<NOBR>64-bit</NOBR>, <NOBR>80-bit</NOBR>, and <NOBR>128-bit</NOBR>
112floating-point formats.
113(Thanks to Alexei Sibidanov at the University of Victoria for reporting an
114incorrect result.)
115The bugs affected all prior <NOBR>Release-3</NOBR> versions of SoftFloat.
116The flaw in the <NOBR>64-bit</NOBR> floating-point square root function was of
117very minor impact, causing a <NOBR>1-ulp</NOBR> error (<NOBR>1 unit</NOBR> in
118the last place) a few times out of a billion.
119The bugs in the <NOBR>80-bit</NOBR> and <NOBR>128-bit</NOBR> square root
120functions were more serious.
121Although incorrect results again occurred only a few times out of a billion,
122when they did occur a large portion of the less-significant bits could be
123wrong.
124</P>
125
126<P>
127<NOBR>Release 3d</NOBR> makes no changes to the SoftFloat library interface
128compared to the previous <NOBR>Release 3c</NOBR>.
129Since the original <NOBR>Release 3</NOBR>, the main changes to the interface
130have been that <NOBR>Release 3b</NOBR> added support for the
131<NOBR>16-bit</NOBR> half-precision format, and <NOBR>Release 3c</NOBR> added
132optional support for a rarely used rounding mode, <I>round to odd</I>, also
133known as <I>jamming</I>.
134For more about the evolution of SoftFloat releases, see
135<A HREF="SoftFloat-history.html"><NOBR><CODE>SoftFloat-history.html</CODE></NOBR></A>.
136</P>
137
138<P>
139The functional interface of SoftFloat <NOBR>Release 3</NOBR> and later differs
140in many details from the releases that came before.
141For specifics of these differences, see <NOBR>section 9</NOBR> below,
142<I>Changes from SoftFloat <NOBR>Release 2</NOBR></I>.
143</P>
144
145
146<H2>2. Limitations</H2>
147
148<P>
149SoftFloat assumes the computer has an addressable byte size of 8 or
150<NOBR>16 bits</NOBR>.
151(Nearly all computers in use today have <NOBR>8-bit</NOBR> bytes.)
152</P>
153
154<P>
155SoftFloat is written in C and is designed to work with other C code.
156The C compiler used must conform at a minimum to the 1989 ANSI standard for the
157C language (same as the 1990 ISO standard) and must in addition support basic
158arithmetic on <NOBR>64-bit</NOBR> integers.
159Earlier releases of SoftFloat included implementations of <NOBR>32-bit</NOBR>
160single-precision and <NOBR>64-bit</NOBR> double-precision floating-point that
161did not require <NOBR>64-bit</NOBR> integers, but this option is not supported
162starting with <NOBR>Release 3</NOBR>.
163Since 1999, ISO standards for C have mandated compiler support for
164<NOBR>64-bit</NOBR> integers.
165A compiler conforming to the 1999 C Standard or later is recommended but not
166strictly required.
167</P>
168
169<P>
170Most operations not required by the original 1985 version of the IEEE
171Floating-Point Standard but added in the 2008 version are not yet supported in
172SoftFloat <NOBR>Release 3d</NOBR>.
173</P>
174
175
176<H2>3. Acknowledgments and License</H2>
177
178<P>
179The SoftFloat package was written by me, <NOBR>John R.</NOBR> Hauser.
180<NOBR>Release 3</NOBR> of SoftFloat was a completely new implementation
181supplanting earlier releases.
182The project to create <NOBR>Release 3</NOBR> (now <NOBR>through 3d</NOBR>) was
183done in the employ of the University of California, Berkeley, within the
184Department of Electrical Engineering and Computer Sciences, first for the
185Parallel Computing Laboratory (Par Lab) and then for the ASPIRE Lab.
186The work was officially overseen by Prof. Krste Asanovic, with funding provided
187by these sources:
188<BLOCKQUOTE>
189<TABLE>
190<COL>
191<COL WIDTH=10>
192<COL>
193<TR>
194<TD VALIGN=TOP><NOBR>Par Lab:</NOBR></TD>
195<TD></TD>
196<TD>
197Microsoft (Award #024263), Intel (Award #024894), and U.C. Discovery
198(Award #DIG07-10227), with additional support from Par Lab affiliates Nokia,
199NVIDIA, Oracle, and Samsung.
200</TD>
201</TR>
202<TR>
203<TD VALIGN=TOP><NOBR>ASPIRE Lab:</NOBR></TD>
204<TD></TD>
205<TD>
206DARPA PERFECT program (Award #HR0011-12-2-0016), with additional support from
207ASPIRE industrial sponsor Intel and ASPIRE affiliates Google, Nokia, NVIDIA,
208Oracle, and Samsung.
209</TD>
210</TR>
211</TABLE>
212</BLOCKQUOTE>
213</P>
214
215<P>
216The following applies to the whole of SoftFloat <NOBR>Release 3d</NOBR> as well
217as to each source file individually.
218</P>
219
220<P>
221Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
222University of California.
223All rights reserved.
224</P>
225
226<P>
227Redistribution and use in source and binary forms, with or without
228modification, are permitted provided that the following conditions are met:
229<OL>
230
231<LI>
232<P>
233Redistributions of source code must retain the above copyright notice, this
234list of conditions, and the following disclaimer.
235</P>
236
237<LI>
238<P>
239Redistributions in binary form must reproduce the above copyright notice, this
240list of conditions, and the following disclaimer in the documentation and/or
241other materials provided with the distribution.
242</P>
243
244<LI>
245<P>
246Neither the name of the University nor the names of its contributors may be
247used to endorse or promote products derived from this software without specific
248prior written permission.
249</P>
250
251</OL>
252</P>
253
254<P>
255THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS &ldquo;AS IS&rdquo;,
256AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
257IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
258DISCLAIMED.
259IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
260INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
261BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
262DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
263LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
264OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
265ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
266</P>
267
268
269<H2>4. Types and Functions</H2>
270
271<P>
272The types and functions of SoftFloat are declared in header file
273<CODE>softfloat.h</CODE>.
274</P>
275
276<H3>4.1. Boolean and Integer Types</H3>
277
278<P>
279Header file <CODE>softfloat.h</CODE> depends on standard headers
280<CODE>&lt;stdbool.h&gt;</CODE> and <CODE>&lt;stdint.h&gt;</CODE> to define type
281<CODE>bool</CODE> and several integer types.
282These standard headers have been part of the ISO C Standard Library since 1999.
283With any recent compiler, they are likely to be supported, even if the compiler
284does not claim complete conformance to the latest ISO C Standard.
285For older or nonstandard compilers, a port of SoftFloat may have substitutes
286for these headers.
287Header <CODE>softfloat.h</CODE> depends only on the name <CODE>bool</CODE> from
288<CODE>&lt;stdbool.h&gt;</CODE> and on these type names from
289<CODE>&lt;stdint.h&gt;</CODE>:
290<BLOCKQUOTE>
291<PRE>
292uint16_t
293uint32_t
294uint64_t
295int32_t
296int64_t
297uint_fast8_t
298uint_fast32_t
299uint_fast64_t
300int_fast32_t
301int_fast64_t
302</PRE>
303</BLOCKQUOTE>
304</P>
305
306
307<H3>4.2. Floating-Point Types</H3>
308
309<P>
310The <CODE>softfloat.h</CODE> header defines five floating-point types:
311<BLOCKQUOTE>
312<TABLE CELLSPACING=0 CELLPADDING=0>
313<TR>
314<TD><CODE>float16_t</CODE></TD>
315<TD><NOBR>16-bit</NOBR> half-precision binary format</TD>
316</TR>
317<TR>
318<TD><CODE>float32_t</CODE></TD>
319<TD><NOBR>32-bit</NOBR> single-precision binary format</TD>
320</TR>
321<TR>
322<TD><CODE>float64_t</CODE></TD>
323<TD><NOBR>64-bit</NOBR> double-precision binary format</TD>
324</TR>
325<TR>
326<TD><CODE>extFloat80_t&nbsp;&nbsp;&nbsp;</CODE></TD>
327<TD><NOBR>80-bit</NOBR> double-extended-precision binary format (old Intel or
328Motorola format)</TD>
329</TR>
330<TR>
331<TD><CODE>float128_t</CODE></TD>
332<TD><NOBR>128-bit</NOBR> quadruple-precision binary format</TD>
333</TR>
334</TABLE>
335</BLOCKQUOTE>
336The non-extended types are each exactly the size specified:
337<NOBR>16 bits</NOBR> for <CODE>float16_t</CODE>, <NOBR>32 bits</NOBR> for
338<CODE>float32_t</CODE>, <NOBR>64 bits</NOBR> for <CODE>float64_t</CODE>, and
339<NOBR>128 bits</NOBR> for <CODE>float128_t</CODE>.
340Aside from these size requirements, the definitions of all these types may
341differ for different ports of SoftFloat to specific systems.
342A given port of SoftFloat may or may not define some of the floating-point
343types as aliases for the C standard types <CODE>float</CODE>,
344<CODE>double</CODE>, and <CODE>long</CODE> <CODE>double</CODE>.
345</P>
346
347<P>
348Header file <CODE>softfloat.h</CODE> also defines a structure,
349<CODE>struct</CODE> <CODE>extFloat80M</CODE>, for the representation of
350<NOBR>80-bit</NOBR> double-extended-precision floating-point values in memory.
351This structure is the same size as type <CODE>extFloat80_t</CODE> and contains
352at least these two fields (not necessarily in this order):
353<BLOCKQUOTE>
354<PRE>
355uint16_t signExp;
356uint64_t signif;
357</PRE>
358</BLOCKQUOTE>
359Field <CODE>signExp</CODE> contains the sign and exponent of the floating-point
360value, with the sign in the most significant bit (<NOBR>bit 15</NOBR>) and the
361encoded exponent in the other <NOBR>15 bits</NOBR>.
362Field <CODE>signif</CODE> is the complete <NOBR>64-bit</NOBR> significand of
363the floating-point value.
364(In the usual encoding for <NOBR>80-bit</NOBR> extended floating-point, the
365leading <NOBR>1 bit</NOBR> of normalized numbers is not implicit but is stored
366in the most significant bit of the significand.)
367</P>
368
369<H3>4.3. Supported Floating-Point Functions</H3>
370
371<P>
372SoftFloat implements these arithmetic operations for its floating-point types:
373<UL>
374<LI>
375conversions between any two floating-point formats;
376<LI>
377for each floating-point format, conversions to and from signed and unsigned
378<NOBR>32-bit</NOBR> and <NOBR>64-bit</NOBR> integers;
379<LI>
380for each format, the usual addition, subtraction, multiplication, division, and
381square root operations;
382<LI>
383for each format except <CODE>extFloat80_t</CODE>, the fused multiply-add
384operation defined by the IEEE Standard;
385<LI>
386for each format, the floating-point remainder operation defined by the IEEE
387Standard;
388<LI>
389for each format, a &ldquo;round to integer&rdquo; operation that rounds to the
390nearest integer value in the same format; and
391<LI>
392comparisons between two values in the same floating-point format.
393</UL>
394</P>
395
396<P>
397The following operations required by the 2008 IEEE Floating-Point Standard are
398not supported in SoftFloat <NOBR>Release 3d</NOBR>:
399<UL>
400<LI>
401<B>nextUp</B>, <B>nextDown</B>, <B>minNum</B>, <B>maxNum</B>, <B>minNumMag</B>,
402<B>maxNumMag</B>, <B>scaleB</B>, and <B>logB</B>;
403<LI>
404conversions between floating-point formats and decimal or hexadecimal character
405sequences;
406<LI>
407all &ldquo;quiet-computation&rdquo; operations (<B>copy</B>, <B>negate</B>,
408<B>abs</B>, and <B>copySign</B>, which all involve only simple copying and/or
409manipulation of the floating-point sign bit); and
410<LI>
411all &ldquo;non-computational&rdquo; operations other than <B>isSignaling</B>
412(which is supported).
413</UL>
414</P>
415
416<H3>4.4. Non-canonical Representations in <CODE>extFloat80_t</CODE></H3>
417
418<P>
419Because the <NOBR>80-bit</NOBR> double-extended-precision format,
420<CODE>extFloat80_t</CODE>, stores an explicit leading significand bit, many
421finite floating-point numbers are encodable in this type in multiple equivalent
422forms.
423Of these multiple encodings, there is always a unique one with the least
424encoded exponent value, and this encoding is considered the <I>canonical</I>
425representation of the floating-point number.
426Any other equivalent representations (having a higher encoded exponent value)
427are <I>non-canonical</I>.
428For a value in the subnormal range (including zero), the canonical
429representation always has an encoded exponent of zero and a leading significand
430bit <NOBR>of 0</NOBR>.
431For finite values outside the subnormal range, the canonical representation
432always has an encoded exponent that is nonzero and a leading significand bit
433<NOBR>of 1</NOBR>.
434</P>
435
436<P>
437For an infinity or NaN, the leading significand bit is similarly expected to
438<NOBR>be 1</NOBR>.
439An infinity or NaN with a leading significand bit <NOBR>of 0</NOBR> is again
440considered non-canonical.
441Hence, altogether, to be canonical, a value of type <CODE>extFloat80_t</CODE>
442must have a leading significand bit <NOBR>of 1</NOBR>, unless the value is
443subnormal or zero, in which case the leading significand bit and the encoded
444exponent must both be zero.
445</P>
446
447<P>
448SoftFloat's functions are not guaranteed to operate as expected when inputs of
449type <CODE>extFloat80_t</CODE> are non-canonical.
450Assuming all of a function&rsquo;s <CODE>extFloat80_t</CODE> inputs (if any)
451are canonical, function outputs of type <CODE>extFloat80_t</CODE> will always
452be canonical.
453</P>
454
455<H3>4.5. Conventions for Passing Arguments and Results</H3>
456
457<P>
458Values that are at most <NOBR>64 bits</NOBR> in size (i.e., not the
459<NOBR>80-bit</NOBR> or <NOBR>128-bit</NOBR> floating-point formats) are in all
460cases passed as function arguments by value.
461Likewise, when an output of a function is no more than <NOBR>64 bits</NOBR>, it
462is always returned directly as the function result.
463Thus, for example, the SoftFloat function for adding two <NOBR>64-bit</NOBR>
464floating-point values has this simple signature:
465<BLOCKQUOTE>
466<CODE>float64_t f64_add( float64_t, float64_t );</CODE>
467</BLOCKQUOTE>
468</P>
469
470<P>
471The story is more complex when function inputs and outputs are
472<NOBR>80-bit</NOBR> and <NOBR>128-bit</NOBR> floating-point.
473For these types, SoftFloat always provides a function that passes these larger
474values into or out of the function indirectly, via pointers.
475For example, for adding two <NOBR>128-bit</NOBR> floating-point values,
476SoftFloat supplies this function:
477<BLOCKQUOTE>
478<CODE>void f128M_add( const float128_t *, const float128_t *, float128_t * );</CODE>
479</BLOCKQUOTE>
480The first two arguments point to the values to be added, and the last argument
481points to the location where the sum will be stored.
482The <CODE>M</CODE> in the name <CODE>f128M_add</CODE> is mnemonic for the fact
483that the <NOBR>128-bit</NOBR> inputs and outputs are &ldquo;in memory&rdquo;,
484pointed to by pointer arguments.
485</P>
486
487<P>
488All ports of SoftFloat implement these <I>pass-by-pointer</I> functions for
489types <CODE>extFloat80_t</CODE> and <CODE>float128_t</CODE>.
490At the same time, SoftFloat ports may also implement alternate versions of
491these same functions that pass <CODE>extFloat80_t</CODE> and
492<CODE>float128_t</CODE> by value, like the smaller formats.
493Thus, besides the function with name <CODE>f128M_add</CODE> shown above, a
494SoftFloat port may also supply an equivalent function with this signature:
495<BLOCKQUOTE>
496<CODE>float128_t f128_add( float128_t, float128_t );</CODE>
497</BLOCKQUOTE>
498</P>
499
500<P>
501As a general rule, on computers where the machine word size is
502<NOBR>32 bits</NOBR> or smaller, only the pass-by-pointer versions of functions
503(e.g., <CODE>f128M_add</CODE>) are provided for types <CODE>extFloat80_t</CODE>
504and <CODE>float128_t</CODE>, because passing such large types directly can have
505significant extra cost.
506On computers where the word size is <NOBR>64 bits</NOBR> or larger, both
507function versions (<CODE>f128M_add</CODE> and <CODE>f128_add</CODE>) are
508provided, because the cost of passing by value is then more reasonable.
509Applications that must be portable accross both classes of computers must use
510the pointer-based functions, as these are always implemented.
511However, if it is known that SoftFloat includes the by-value functions for all
512platforms of interest, programmers can use whichever version they prefer.
513</P>
514
515
516<H2>5. Reserved Names</H2>
517
518<P>
519In addition to the variables and functions documented here, SoftFloat defines
520some symbol names for its own private use.
521These private names always begin with the prefix
522&lsquo;<CODE>softfloat_</CODE>&rsquo;.
523When a program includes header <CODE>softfloat.h</CODE> or links with the
524SoftFloat library, all names with prefix &lsquo;<CODE>softfloat_</CODE>&rsquo;
525are reserved for possible use by SoftFloat.
526Applications that use SoftFloat should not define their own names with this
527prefix, and should reference only such names as are documented.
528</P>
529
530
531<H2>6. Mode Variables</H2>
532
533<P>
534The following global variables control rounding mode, underflow detection, and
535the <NOBR>80-bit</NOBR> extended format&rsquo;s rounding precision:
536<BLOCKQUOTE>
537<CODE>softfloat_roundingMode</CODE><BR>
538<CODE>softfloat_detectTininess</CODE><BR>
539<CODE>extF80_roundingPrecision</CODE>
540</BLOCKQUOTE>
541These mode variables are covered in the next several subsections.
542For some SoftFloat ports, these variables may be <I>per-thread</I> (declared
543<CODE>thread_local</CODE>), meaning that different execution threads have their
544own separate copies of the variables.
545</P>
546
547<H3>6.1. Rounding Mode</H3>
548
549<P>
550All five rounding modes defined by the 2008 IEEE Floating-Point Standard are
551implemented for all operations that require rounding.
552Some ports of SoftFloat may also implement the <I>round-to-odd</I> mode.
553</P>
554
555<P>
556The rounding mode is selected by the global variable
557<BLOCKQUOTE>
558<CODE>uint_fast8_t softfloat_roundingMode;</CODE>
559</BLOCKQUOTE>
560This variable may be set to one of the values
561<BLOCKQUOTE>
562<TABLE CELLSPACING=0 CELLPADDING=0>
563<TR>
564<TD><CODE>softfloat_round_near_even</CODE></TD>
565<TD>round to nearest, with ties to even</TD>
566</TR>
567<TR>
568<TD><CODE>softfloat_round_near_maxMag&nbsp;&nbsp;</CODE></TD>
569<TD>round to nearest, with ties to maximum magnitude (away from zero)</TD>
570</TR>
571<TR>
572<TD><CODE>softfloat_round_minMag</CODE></TD>
573<TD>round to minimum magnitude (toward zero)</TD>
574</TR>
575<TR>
576<TD><CODE>softfloat_round_min</CODE></TD>
577<TD>round to minimum (down)</TD>
578</TR>
579<TR>
580<TD><CODE>softfloat_round_max</CODE></TD>
581<TD>round to maximum (up)</TD>
582</TR>
583<TR>
584<TD><CODE>softfloat_round_odd</CODE></TD>
585<TD>round to odd (jamming), if supported by the SoftFloat port</TD>
586</TR>
587</TABLE>
588</BLOCKQUOTE>
589Variable <CODE>softfloat_roundingMode</CODE> is initialized to
590<CODE>softfloat_round_near_even</CODE>.
591</P>
592
593<P>
594If supported, mode <CODE>softfloat_round_odd</CODE> first rounds a
595floating-point result to minimum magnitude, the same as
596<CODE>softfloat_round_minMag</CODE>, and then, if the result is inexact, the
597least-significant bit of the result is set <NOBR>to 1</NOBR>.
598This rounding mode is also known as <EM>jamming</EM>.
599As a special case, when <CODE>softfloat_round_odd</CODE> is the rounding mode
600for a function that rounds to an integer value (either conversion to an integer
601format or a &lsquo;<CODE>roundToInt</CODE>&rsquo; function), rounding is the
602same as <CODE>softfloat_round_minMag</CODE>, without any change to the
603least-significant integer bit.
604</P>
605
606<H3>6.2. Underflow Detection</H3>
607
608<P>
609In the terminology of the IEEE Standard, SoftFloat can detect tininess for
610underflow either before or after rounding.
611The choice is made by the global variable
612<BLOCKQUOTE>
613<CODE>uint_fast8_t softfloat_detectTininess;</CODE>
614</BLOCKQUOTE>
615which can be set to either
616<BLOCKQUOTE>
617<CODE>softfloat_tininess_beforeRounding</CODE><BR>
618<CODE>softfloat_tininess_afterRounding</CODE>
619</BLOCKQUOTE>
620Detecting tininess after rounding is usually better because it results in fewer
621spurious underflow signals.
622The other option is provided for compatibility with some systems.
623Like most systems (and as required by the newer 2008 IEEE Standard), SoftFloat
624always detects loss of accuracy for underflow as an inexact result.
625</P>
626
627<H3>6.3. Rounding Precision for the <NOBR>80-Bit</NOBR> Extended Format</H3>
628
629<P>
630For <CODE>extFloat80_t</CODE> only, the rounding precision of the basic
631arithmetic operations is controlled by the global variable
632<BLOCKQUOTE>
633<CODE>uint_fast8_t extF80_roundingPrecision;</CODE>
634</BLOCKQUOTE>
635The operations affected are:
636<BLOCKQUOTE>
637<CODE>extF80_add</CODE><BR>
638<CODE>extF80_sub</CODE><BR>
639<CODE>extF80_mul</CODE><BR>
640<CODE>extF80_div</CODE><BR>
641<CODE>extF80_sqrt</CODE>
642</BLOCKQUOTE>
643When <CODE>extF80_roundingPrecision</CODE> is set to its default value of 80,
644these operations are rounded to the full precision of the <NOBR>80-bit</NOBR>
645double-extended-precision format, like occurs for other formats.
646Setting <CODE>extF80_roundingPrecision</CODE> to 32 or to 64 causes the
647operations listed to be rounded to <NOBR>32-bit</NOBR> precision (equivalent to
648<CODE>float32_t</CODE>) or to <NOBR>64-bit</NOBR> precision (equivalent to
649<CODE>float64_t</CODE>), respectively.
650When rounding to reduced precision, additional bits in the result significand
651beyond the rounding point are set to zero.
652The consequences of setting <CODE>extF80_roundingPrecision</CODE> to a value
653other than 32, 64, or 80 is not specified.
654Operations other than the ones listed above are not affected by
655<CODE>extF80_roundingPrecision</CODE>.
656</P>
657
658
659<H2>7. Exceptions and Exception Flags</H2>
660
661<P>
662All five exception flags required by the IEEE Floating-Point Standard are
663implemented.
664Each flag is stored as a separate bit in the global variable
665<BLOCKQUOTE>
666<CODE>uint_fast8_t softfloat_exceptionFlags;</CODE>
667</BLOCKQUOTE>
668The positions of the exception flag bits within this variable are determined by
669the bit masks
670<BLOCKQUOTE>
671<CODE>softfloat_flag_inexact</CODE><BR>
672<CODE>softfloat_flag_underflow</CODE><BR>
673<CODE>softfloat_flag_overflow</CODE><BR>
674<CODE>softfloat_flag_infinite</CODE><BR>
675<CODE>softfloat_flag_invalid</CODE>
676</BLOCKQUOTE>
677Variable <CODE>softfloat_exceptionFlags</CODE> is initialized to all zeros,
678meaning no exceptions.
679</P>
680
681<P>
682For some SoftFloat ports, <CODE>softfloat_exceptionFlags</CODE> may be
683<I>per-thread</I> (declared <CODE>thread_local</CODE>), meaning that different
684execution threads have their own separate instances of it.
685</P>
686
687<P>
688An individual exception flag can be cleared with the statement
689<BLOCKQUOTE>
690<CODE>softfloat_exceptionFlags &= ~softfloat_flag_&lt;<I>exception</I>&gt;;</CODE>
691</BLOCKQUOTE>
692where <CODE>&lt;<I>exception</I>&gt;</CODE> is the appropriate name.
693To raise a floating-point exception, function <CODE>softfloat_raiseFlags</CODE>
694should normally be used.
695</P>
696
697<P>
698When SoftFloat detects an exception other than <I>inexact</I>, it calls
699<CODE>softfloat_raiseFlags</CODE>.
700The default version of this function simply raises the corresponding exception
701flags.
702Particular ports of SoftFloat may support alternate behavior, such as exception
703traps, by modifying the default <CODE>softfloat_raiseFlags</CODE>.
704A program may also supply its own <CODE>softfloat_raiseFlags</CODE> function to
705override the one from the SoftFloat library.
706</P>
707
708<P>
709Because inexact results occur frequently under most circumstances (and thus are
710hardly exceptional), SoftFloat does not ordinarily call
711<CODE>softfloat_raiseFlags</CODE> for <I>inexact</I> exceptions.
712It does always raise the <I>inexact</I> exception flag as required.
713</P>
714
715
716<H2>8. Function Details</H2>
717
718<P>
719In this section, <CODE>&lt;<I>float</I>&gt;</CODE> appears in function names as
720a substitute for one of these abbreviations:
721<BLOCKQUOTE>
722<TABLE CELLSPACING=0 CELLPADDING=0>
723<TR>
724<TD><CODE>f16</CODE></TD>
725<TD>indicates <CODE>float16_t</CODE>, passed by value</TD>
726</TR>
727<TR>
728<TD><CODE>f32</CODE></TD>
729<TD>indicates <CODE>float32_t</CODE>, passed by value</TD>
730</TR>
731<TR>
732<TD><CODE>f64</CODE></TD>
733<TD>indicates <CODE>float64_t</CODE>, passed by value</TD>
734</TR>
735<TR>
736<TD><CODE>extF80M&nbsp;&nbsp;&nbsp;</CODE></TD>
737<TD>indicates <CODE>extFloat80_t</CODE>, passed indirectly via pointers</TD>
738</TR>
739<TR>
740<TD><CODE>extF80</CODE></TD>
741<TD>indicates <CODE>extFloat80_t</CODE>, passed by value</TD>
742</TR>
743<TR>
744<TD><CODE>f128M</CODE></TD>
745<TD>indicates <CODE>float128_t</CODE>, passed indirectly via pointers</TD>
746</TR>
747<TR>
748<TD><CODE>f128</CODE></TD>
749<TD>indicates <CODE>float128_t</CODE>, passed by value</TD>
750</TR>
751</TABLE>
752</BLOCKQUOTE>
753The circumstances under which values of floating-point types
754<CODE>extFloat80_t</CODE> and <CODE>float128_t</CODE> may be passed either by
755value or indirectly via pointers was discussed earlier in
756<NOBR>section 4.5</NOBR>, <I>Conventions for Passing Arguments and Results</I>.
757</P>
758
759<H3>8.1. Conversions from Integer to Floating-Point</H3>
760
761<P>
762All conversions from a <NOBR>32-bit</NOBR> or <NOBR>64-bit</NOBR> integer,
763signed or unsigned, to a floating-point format are supported.
764Functions performing these conversions have these names:
765<BLOCKQUOTE>
766<CODE>ui32_to_&lt;<I>float</I>&gt;</CODE><BR>
767<CODE>ui64_to_&lt;<I>float</I>&gt;</CODE><BR>
768<CODE>i32_to_&lt;<I>float</I>&gt;</CODE><BR>
769<CODE>i64_to_&lt;<I>float</I>&gt;</CODE>
770</BLOCKQUOTE>
771Conversions from <NOBR>32-bit</NOBR> integers to <NOBR>64-bit</NOBR>
772double-precision and larger formats are always exact, and likewise conversions
773from <NOBR>64-bit</NOBR> integers to <NOBR>80-bit</NOBR>
774double-extended-precision and <NOBR>128-bit</NOBR> quadruple-precision are also
775always exact.
776</P>
777
778<P>
779Each conversion function takes one input of the appropriate type and generates
780one output.
781The following illustrates the signatures of these functions in cases when the
782floating-point result is passed either by value or via pointers:
783<BLOCKQUOTE>
784<PRE>
785float64_t i32_to_f64( int32_t <I>a</I> );
786</PRE>
787<PRE>
788void i32_to_f128M( int32_t <I>a</I>, float128_t *<I>destPtr</I> );
789</PRE>
790</BLOCKQUOTE>
791</P>
792
793<H3>8.2. Conversions from Floating-Point to Integer</H3>
794
795<P>
796Conversions from a floating-point format to a <NOBR>32-bit</NOBR> or
797<NOBR>64-bit</NOBR> integer, signed or unsigned, are supported with these
798functions:
799<BLOCKQUOTE>
800<CODE>&lt;<I>float</I>&gt;_to_ui32</CODE><BR>
801<CODE>&lt;<I>float</I>&gt;_to_ui64</CODE><BR>
802<CODE>&lt;<I>float</I>&gt;_to_i32</CODE><BR>
803<CODE>&lt;<I>float</I>&gt;_to_i64</CODE>
804</BLOCKQUOTE>
805The functions have signatures as follows, depending on whether the
806floating-point input is passed by value or via pointers:
807<BLOCKQUOTE>
808<PRE>
809int_fast32_t f64_to_i32( float64_t <I>a</I>, uint_fast8_t <I>roundingMode</I>, bool <I>exact</I> );
810</PRE>
811<PRE>
812int_fast32_t
813 f128M_to_i32( const float128_t *<I>aPtr</I>, uint_fast8_t <I>roundingMode</I>, bool <I>exact</I> );
814</PRE>
815</BLOCKQUOTE>
816</P>
817
818<P>
819The <CODE><I>roundingMode</I></CODE> argument specifies the rounding mode for
820the conversion.
821The variable that usually indicates rounding mode,
822<CODE>softfloat_roundingMode</CODE>, is ignored.
823If <CODE><I>roundingMode</I></CODE> is <CODE>softfloat_round_odd</CODE>,
824rounding is to minimum magnitude, the same as
825<CODE>softfloat_round_minMag</CODE>, rather than to an odd integer.
826</P>
827
828<P>
829Argument <CODE><I>exact</I></CODE> determines whether the <I>inexact</I>
830exception flag is raised if the conversion is not exact.
831If <CODE><I>exact</I></CODE> is <CODE>true</CODE>, the <I>inexact</I> flag may
832be raised;
833otherwise, it will not be, even if the conversion is inexact.
834</P>
835
836<P>
837A conversion from floating-point to integer format raises the <I>invalid</I>
838exception if the source value cannot be rounded to a representable integer of
839the desired size (32 or 64 bits).
840In such circumstances, the integer result returned is determined by the
841particular port of SoftFloat, although typically this value will be either the
842maximum or minimum value of the integer format.
843The functions that convert to integer types never raise the floating-point
844<I>overflow</I> exception.
845</P>
846
847<P>
848Because languages such <NOBR>as C</NOBR> require that conversions to integers
849be rounded toward zero, the following functions are provided for improved speed
850and convenience:
851<BLOCKQUOTE>
852<CODE>&lt;<I>float</I>&gt;_to_ui32_r_minMag</CODE><BR>
853<CODE>&lt;<I>float</I>&gt;_to_ui64_r_minMag</CODE><BR>
854<CODE>&lt;<I>float</I>&gt;_to_i32_r_minMag</CODE><BR>
855<CODE>&lt;<I>float</I>&gt;_to_i64_r_minMag</CODE>
856</BLOCKQUOTE>
857These functions round only toward zero (to minimum magnitude).
858The signatures for these functions are the same as above without the redundant
859<CODE><I>roundingMode</I></CODE> argument:
860<BLOCKQUOTE>
861<PRE>
862int_fast32_t f64_to_i32_r_minMag( float64_t <I>a</I>, bool <I>exact</I> );
863</PRE>
864<PRE>
865int_fast32_t f128M_to_i32_r_minMag( const float128_t *<I>aPtr</I>, bool <I>exact</I> );
866</PRE>
867</BLOCKQUOTE>
868</P>
869
870<H3>8.3. Conversions Among Floating-Point Types</H3>
871
872<P>
873Conversions between floating-point formats are done by functions with these
874names:
875<BLOCKQUOTE>
876<CODE>&lt;<I>float</I>&gt;_to_&lt;<I>float</I>&gt;</CODE>
877</BLOCKQUOTE>
878All combinations of source and result type are supported where the source and
879result are different formats.
880There are four different styles of signature for these functions, depending on
881whether the input and the output floating-point values are passed by value or
882via pointers:
883<BLOCKQUOTE>
884<PRE>
885float32_t f64_to_f32( float64_t <I>a</I> );
886</PRE>
887<PRE>
888float32_t f128M_to_f32( const float128_t *<I>aPtr</I> );
889</PRE>
890<PRE>
891void f32_to_f128M( float32_t <I>a</I>, float128_t *<I>destPtr</I> );
892</PRE>
893<PRE>
894void extF80M_to_f128M( const extFloat80_t *<I>aPtr</I>, float128_t *<I>destPtr</I> );
895</PRE>
896</BLOCKQUOTE>
897</P>
898
899<P>
900Conversions from a smaller to a larger floating-point format are always exact
901and so require no rounding.
902</P>
903
904<H3>8.4. Basic Arithmetic Functions</H3>
905
906<P>
907The following basic arithmetic functions are provided:
908<BLOCKQUOTE>
909<CODE>&lt;<I>float</I>&gt;_add</CODE><BR>
910<CODE>&lt;<I>float</I>&gt;_sub</CODE><BR>
911<CODE>&lt;<I>float</I>&gt;_mul</CODE><BR>
912<CODE>&lt;<I>float</I>&gt;_div</CODE><BR>
913<CODE>&lt;<I>float</I>&gt;_sqrt</CODE>
914</BLOCKQUOTE>
915Each floating-point operation takes two operands, except for <CODE>sqrt</CODE>
916(square root) which takes only one.
917The operands and result are all of the same floating-point format.
918Signatures for these functions take the following forms:
919<BLOCKQUOTE>
920<PRE>
921float64_t f64_add( float64_t <I>a</I>, float64_t <I>b</I> );
922</PRE>
923<PRE>
924void
925 f128M_add(
926 const float128_t *<I>aPtr</I>, const float128_t *<I>bPtr</I>, float128_t *<I>destPtr</I> );
927</PRE>
928<PRE>
929float64_t f64_sqrt( float64_t <I>a</I> );
930</PRE>
931<PRE>
932void f128M_sqrt( const float128_t *<I>aPtr</I>, float128_t *<I>destPtr</I> );
933</PRE>
934</BLOCKQUOTE>
935When floating-point values are passed indirectly through pointers, arguments
936<CODE><I>aPtr</I></CODE> and <CODE><I>bPtr</I></CODE> point to the input
937operands, and the last argument, <CODE><I>destPtr</I></CODE>, points to the
938location where the result is stored.
939</P>
940
941<P>
942Rounding of the <NOBR>80-bit</NOBR> double-extended-precision
943(<CODE>extFloat80_t</CODE>) functions is affected by variable
944<CODE>extF80_roundingPrecision</CODE>, as explained earlier in
945<NOBR>section 6.3</NOBR>,
946<I>Rounding Precision for the <NOBR>80-Bit</NOBR> Extended Format</I>.
947</P>
948
949<H3>8.5. Fused Multiply-Add Functions</H3>
950
951<P>
952The 2008 version of the IEEE Floating-Point Standard defines a <I>fused
953multiply-add</I> operation that does a combined multiplication and addition
954with only a single rounding.
955SoftFloat implements fused multiply-add with functions
956<BLOCKQUOTE>
957<CODE>&lt;<I>float</I>&gt;_mulAdd</CODE>
958</BLOCKQUOTE>
959Unlike other operations, fused multiple-add is not supported for the
960<NOBR>80-bit</NOBR> double-extended-precision format,
961<CODE>extFloat80_t</CODE>.
962</P>
963
964<P>
965Depending on whether floating-point values are passed by value or via pointers,
966the fused multiply-add functions have signatures of these forms:
967<BLOCKQUOTE>
968<PRE>
969float64_t f64_mulAdd( float64_t <I>a</I>, float64_t <I>b</I>, float64_t <I>c</I> );
970</PRE>
971<PRE>
972void
973 f128M_mulAdd(
974 const float128_t *<I>aPtr</I>,
975 const float128_t *<I>bPtr</I>,
976 const float128_t *<I>cPtr</I>,
977 float128_t *<I>destPtr</I>
978 );
979</PRE>
980</BLOCKQUOTE>
981The functions compute
982<NOBR>(<CODE><I>a</I></CODE> &times; <CODE><I>b</I></CODE>)
983 + <CODE><I>c</I></CODE></NOBR>
984with a single rounding.
985When floating-point values are passed indirectly through pointers, arguments
986<CODE><I>aPtr</I></CODE>, <CODE><I>bPtr</I></CODE>, and
987<CODE><I>cPtr</I></CODE> point to operands <CODE><I>a</I></CODE>,
988<CODE><I>b</I></CODE>, and <CODE><I>c</I></CODE> respectively, and
989<CODE><I>destPtr</I></CODE> points to the location where the result is stored.
990</P>
991
992<P>
993If one of the multiplication operands <CODE><I>a</I></CODE> and
994<CODE><I>b</I></CODE> is infinite and the other is zero, these functions raise
995the invalid exception even if operand <CODE><I>c</I></CODE> is a quiet NaN.
996</P>
997
998<H3>8.6. Remainder Functions</H3>
999
1000<P>
1001For each format, SoftFloat implements the remainder operation defined by the
1002IEEE Floating-Point Standard.
1003The remainder functions have names
1004<BLOCKQUOTE>
1005<CODE>&lt;<I>float</I>&gt;_rem</CODE>
1006</BLOCKQUOTE>
1007Each remainder operation takes two floating-point operands of the same format
1008and returns a result in the same format.
1009Depending on whether floating-point values are passed by value or via pointers,
1010the remainder functions have signatures of these forms:
1011<BLOCKQUOTE>
1012<PRE>
1013float64_t f64_rem( float64_t <I>a</I>, float64_t <I>b</I> );
1014</PRE>
1015<PRE>
1016void
1017 f128M_rem(
1018 const float128_t *<I>aPtr</I>, const float128_t *<I>bPtr</I>, float128_t *<I>destPtr</I> );
1019</PRE>
1020</BLOCKQUOTE>
1021When floating-point values are passed indirectly through pointers, arguments
1022<CODE><I>aPtr</I></CODE> and <CODE><I>bPtr</I></CODE> point to operands
1023<CODE><I>a</I></CODE> and <CODE><I>b</I></CODE> respectively, and
1024<CODE><I>destPtr</I></CODE> points to the location where the result is stored.
1025</P>
1026
1027<P>
1028The IEEE Standard remainder operation computes the value
1029<NOBR><CODE><I>a</I></CODE>
1030 &minus; <I>n</I> &times; <CODE><I>b</I></CODE></NOBR>,
1031where <I>n</I> is the integer closest to
1032<NOBR><CODE><I>a</I></CODE> &divide; <CODE><I>b</I></CODE></NOBR>.
1033If <NOBR><CODE><I>a</I></CODE> &divide; <CODE><I>b</I></CODE></NOBR> is exactly
1034halfway between two integers, <I>n</I> is the <EM>even</EM> integer closest to
1035<NOBR><CODE><I>a</I></CODE> &divide; <CODE><I>b</I></CODE></NOBR>.
1036The IEEE Standard&rsquo;s remainder operation is always exact and so requires
1037no rounding.
1038</P>
1039
1040<P>
1041Depending on the relative magnitudes of the operands, the remainder
1042functions can take considerably longer to execute than the other SoftFloat
1043functions.
1044This is an inherent characteristic of the remainder operation itself and is not
1045a flaw in the SoftFloat implementation.
1046</P>
1047
1048<H3>8.7. Round-to-Integer Functions</H3>
1049
1050<P>
1051For each format, SoftFloat implements the round-to-integer operation specified
1052by the IEEE Floating-Point Standard.
1053These functions are named
1054<BLOCKQUOTE>
1055<CODE>&lt;<I>float</I>&gt;_roundToInt</CODE>
1056</BLOCKQUOTE>
1057Each round-to-integer operation takes a single floating-point operand.
1058This operand is rounded to an integer according to a specified rounding mode,
1059and the resulting integer value is returned in the same floating-point format.
1060(Note that the result is not an integer type.)
1061</P>
1062
1063<P>
1064The signatures of the round-to-integer functions are similar to those for
1065conversions to an integer type:
1066<BLOCKQUOTE>
1067<PRE>
1068float64_t f64_roundToInt( float64_t <I>a</I>, uint_fast8_t <I>roundingMode</I>, bool <I>exact</I> );
1069</PRE>
1070<PRE>
1071void
1072 f128M_roundToInt(
1073 const float128_t *<I>aPtr</I>,
1074 uint_fast8_t <I>roundingMode</I>,
1075 bool <I>exact</I>,
1076 float128_t *<I>destPtr</I>
1077 );
1078</PRE>
1079</BLOCKQUOTE>
1080When floating-point values are passed indirectly through pointers,
1081<CODE><I>aPtr</I></CODE> points to the input operand and
1082<CODE><I>destPtr</I></CODE> points to the location where the result is stored.
1083</P>
1084
1085<P>
1086The <CODE><I>roundingMode</I></CODE> argument specifies the rounding mode to
1087apply.
1088The variable that usually indicates rounding mode,
1089<CODE>softfloat_roundingMode</CODE>, is ignored.
1090If <CODE><I>roundingMode</I></CODE> is <CODE>softfloat_round_odd</CODE>,
1091rounding is to minimum magnitude, the same as
1092<CODE>softfloat_round_minMag</CODE>, rather than to an odd integer value.
1093</P>
1094
1095<P>
1096Argument <CODE><I>exact</I></CODE> determines whether the <I>inexact</I>
1097exception flag is raised if the conversion is not exact.
1098If <CODE><I>exact</I></CODE> is <CODE>true</CODE>, the <I>inexact</I> flag may
1099be raised;
1100otherwise, it will not be, even if the conversion is inexact.
1101</P>
1102
1103<H3>8.8. Comparison Functions</H3>
1104
1105<P>
1106For each format, the following floating-point comparison functions are
1107provided:
1108<BLOCKQUOTE>
1109<CODE>&lt;<I>float</I>&gt;_eq</CODE><BR>
1110<CODE>&lt;<I>float</I>&gt;_le</CODE><BR>
1111<CODE>&lt;<I>float</I>&gt;_lt</CODE>
1112</BLOCKQUOTE>
1113Each comparison takes two operands of the same type and returns a Boolean.
1114The abbreviation <CODE>eq</CODE> stands for &ldquo;equal&rdquo; (=);
1115<CODE>le</CODE> stands for &ldquo;less than or equal&rdquo; (&le;);
1116and <CODE>lt</CODE> stands for &ldquo;less than&rdquo; (&lt;).
1117Depending on whether the floating-point operands are passed by value or via
1118pointers, the comparison functions have signatures of these forms:
1119<BLOCKQUOTE>
1120<PRE>
1121bool f64_eq( float64_t <I>a</I>, float64_t <I>b</I> );
1122</PRE>
1123<PRE>
1124bool f128M_eq( const float128_t *<I>aPtr</I>, const float128_t *<I>bPtr</I> );
1125</PRE>
1126</BLOCKQUOTE>
1127</P>
1128
1129<P>
1130The usual greater-than (&gt;), greater-than-or-equal (&ge;), and not-equal
1131(&ne;) comparisons are easily obtained from the functions provided.
1132The not-equal function is just the logical complement of the equal function.
1133The greater-than-or-equal function is identical to the less-than-or-equal
1134function with the arguments in reverse order, and likewise the greater-than
1135function is identical to the less-than function with the arguments reversed.
1136</P>
1137
1138<P>
1139The IEEE Floating-Point Standard specifies that the less-than-or-equal and
1140less-than comparisons by default raise the <I>invalid</I> exception if either
1141operand is any kind of NaN.
1142Equality comparisons, on the other hand, are defined by default to raise the
1143<I>invalid</I> exception only for signaling NaNs, not quiet NaNs.
1144For completeness, SoftFloat provides these complementary functions:
1145<BLOCKQUOTE>
1146<CODE>&lt;<I>float</I>&gt;_eq_signaling</CODE><BR>
1147<CODE>&lt;<I>float</I>&gt;_le_quiet</CODE><BR>
1148<CODE>&lt;<I>float</I>&gt;_lt_quiet</CODE>
1149</BLOCKQUOTE>
1150The <CODE>signaling</CODE> equality comparisons are identical to the default
1151equality comparisons except that the <I>invalid</I> exception is raised for any
1152NaN input, not just for signaling NaNs.
1153Similarly, the <CODE>quiet</CODE> comparison functions are identical to their
1154default counterparts except that the <I>invalid</I> exception is not raised for
1155quiet NaNs.
1156</P>
1157
1158<H3>8.9. Signaling NaN Test Functions</H3>
1159
1160<P>
1161Functions for testing whether a floating-point value is a signaling NaN are
1162provided with these names:
1163<BLOCKQUOTE>
1164<CODE>&lt;<I>float</I>&gt;_isSignalingNaN</CODE>
1165</BLOCKQUOTE>
1166The functions take one floating-point operand and return a Boolean indicating
1167whether the operand is a signaling NaN.
1168Accordingly, the functions have the forms
1169<BLOCKQUOTE>
1170<PRE>
1171bool f64_isSignalingNaN( float64_t <I>a</I> );
1172</PRE>
1173<PRE>
1174bool f128M_isSignalingNaN( const float128_t *<I>aPtr</I> );
1175</PRE>
1176</BLOCKQUOTE>
1177</P>
1178
1179<H3>8.10. Raise-Exception Function</H3>
1180
1181<P>
1182SoftFloat provides a single function for raising floating-point exceptions:
1183<BLOCKQUOTE>
1184<PRE>
1185void softfloat_raiseFlags( uint_fast8_t <I>exceptions</I> );
1186</PRE>
1187</BLOCKQUOTE>
1188The <CODE><I>exceptions</I></CODE> argument is a mask indicating the set of
1189exceptions to raise.
1190(See earlier section 7, <I>Exceptions and Exception Flags</I>.)
1191In addition to setting the specified exception flags in variable
1192<CODE>softfloat_exceptionFlags</CODE>, the <CODE>softfloat_raiseFlags</CODE>
1193function may cause a trap or abort appropriate for the current system.
1194</P>
1195
1196
1197<H2>9. Changes from SoftFloat <NOBR>Release 2</NOBR></H2>
1198
1199<P>
1200Apart from a change in the legal use license, <NOBR>Release 3</NOBR> of
1201SoftFloat introduced numerous technical differences compared to earlier
1202releases.
1203</P>
1204
1205<H3>9.1. Name Changes</H3>
1206
1207<P>
1208The most obvious and pervasive difference compared to <NOBR>Release 2</NOBR>
1209is that the names of most functions and variables have changed, even when the
1210behavior has not.
1211First, the floating-point types, the mode variables, the exception flags
1212variable, the function to raise exceptions, and various associated constants
1213have been renamed as follows:
1214<BLOCKQUOTE>
1215<TABLE>
1216<TR>
1217<TD>old name, Release 2:</TD>
1218<TD>new name, Release 3:</TD>
1219</TR>
1220<TR>
1221<TD><CODE>float32</CODE></TD>
1222<TD><CODE>float32_t</CODE></TD>
1223</TR>
1224<TR>
1225<TD><CODE>float64</CODE></TD>
1226<TD><CODE>float64_t</CODE></TD>
1227</TR>
1228<TR>
1229<TD><CODE>floatx80</CODE></TD>
1230<TD><CODE>extFloat80_t</CODE></TD>
1231</TR>
1232<TR>
1233<TD><CODE>float128</CODE></TD>
1234<TD><CODE>float128_t</CODE></TD>
1235</TR>
1236<TR>
1237<TD><CODE>float_rounding_mode</CODE></TD>
1238<TD><CODE>softfloat_roundingMode</CODE></TD>
1239</TR>
1240<TR>
1241<TD><CODE>float_round_nearest_even</CODE></TD>
1242<TD><CODE>softfloat_round_near_even</CODE></TD>
1243</TR>
1244<TR>
1245<TD><CODE>float_round_to_zero</CODE></TD>
1246<TD><CODE>softfloat_round_minMag</CODE></TD>
1247</TR>
1248<TR>
1249<TD><CODE>float_round_down</CODE></TD>
1250<TD><CODE>softfloat_round_min</CODE></TD>
1251</TR>
1252<TR>
1253<TD><CODE>float_round_up</CODE></TD>
1254<TD><CODE>softfloat_round_max</CODE></TD>
1255</TR>
1256<TR>
1257<TD><CODE>float_detect_tininess</CODE></TD>
1258<TD><CODE>softfloat_detectTininess</CODE></TD>
1259</TR>
1260<TR>
1261<TD><CODE>float_tininess_before_rounding&nbsp;&nbsp;&nbsp;&nbsp;</CODE></TD>
1262<TD><CODE>softfloat_tininess_beforeRounding</CODE></TD>
1263</TR>
1264<TR>
1265<TD><CODE>float_tininess_after_rounding</CODE></TD>
1266<TD><CODE>softfloat_tininess_afterRounding</CODE></TD>
1267</TR>
1268<TR>
1269<TD><CODE>floatx80_rounding_precision</CODE></TD>
1270<TD><CODE>extF80_roundingPrecision</CODE></TD>
1271</TR>
1272<TR>
1273<TD><CODE>float_exception_flags</CODE></TD>
1274<TD><CODE>softfloat_exceptionFlags</CODE></TD>
1275</TR>
1276<TR>
1277<TD><CODE>float_flag_inexact</CODE></TD>
1278<TD><CODE>softfloat_flag_inexact</CODE></TD>
1279</TR>
1280<TR>
1281<TD><CODE>float_flag_underflow</CODE></TD>
1282<TD><CODE>softfloat_flag_underflow</CODE></TD>
1283</TR>
1284<TR>
1285<TD><CODE>float_flag_overflow</CODE></TD>
1286<TD><CODE>softfloat_flag_overflow</CODE></TD>
1287</TR>
1288<TR>
1289<TD><CODE>float_flag_divbyzero</CODE></TD>
1290<TD><CODE>softfloat_flag_infinite</CODE></TD>
1291</TR>
1292<TR>
1293<TD><CODE>float_flag_invalid</CODE></TD>
1294<TD><CODE>softfloat_flag_invalid</CODE></TD>
1295</TR>
1296<TR>
1297<TD><CODE>float_raise</CODE></TD>
1298<TD><CODE>softfloat_raiseFlags</CODE></TD>
1299</TR>
1300</TABLE>
1301</BLOCKQUOTE>
1302</P>
1303
1304<P>
1305Furthermore, <NOBR>Release 3</NOBR> adopted the following new abbreviations for
1306function names:
1307<BLOCKQUOTE>
1308<TABLE>
1309<TR>
1310<TD>used in names in Release 2:<CODE>&nbsp;&nbsp;&nbsp;&nbsp;</CODE></TD>
1311<TD>used in names in Release 3:</TD>
1312</TR>
1313<TR> <TD><CODE>int32</CODE></TD> <TD><CODE>i32</CODE></TD> </TR>
1314<TR> <TD><CODE>int64</CODE></TD> <TD><CODE>i64</CODE></TD> </TR>
1315<TR> <TD><CODE>float32</CODE></TD> <TD><CODE>f32</CODE></TD> </TR>
1316<TR> <TD><CODE>float64</CODE></TD> <TD><CODE>f64</CODE></TD> </TR>
1317<TR> <TD><CODE>floatx80</CODE></TD> <TD><CODE>extF80</CODE></TD> </TR>
1318<TR> <TD><CODE>float128</CODE></TD> <TD><CODE>f128</CODE></TD> </TR>
1319</TABLE>
1320</BLOCKQUOTE>
1321Thus, for example, the function to add two <NOBR>32-bit</NOBR> floating-point
1322numbers, previously called <CODE>float32_add</CODE> in <NOBR>Release 2</NOBR>,
1323is now <CODE>f32_add</CODE>.
1324Lastly, there have been a few other changes to function names:
1325<BLOCKQUOTE>
1326<TABLE>
1327<TR>
1328<TD>used in names in Release 2:<CODE>&nbsp;&nbsp;&nbsp;</CODE></TD>
1329<TD>used in names in Release 3:<CODE>&nbsp;&nbsp;&nbsp;</CODE></TD>
1330<TD>relevant functions:</TD>
1331</TR>
1332<TR>
1333<TD><CODE>_round_to_zero</CODE></TD>
1334<TD><CODE>_r_minMag</CODE></TD>
1335<TD>conversions from floating-point to integer (<NOBR>section 8.2</NOBR>)</TD>
1336</TR>
1337<TR>
1338<TD><CODE>round_to_int</CODE></TD>
1339<TD><CODE>roundToInt</CODE></TD>
1340<TD>round-to-integer functions (<NOBR>section 8.7</NOBR>)</TD>
1341</TR>
1342<TR>
1343<TD><CODE>is_signaling_nan&nbsp;&nbsp;&nbsp;&nbsp;</CODE></TD>
1344<TD><CODE>isSignalingNaN</CODE></TD>
1345<TD>signaling NaN test functions (<NOBR>section 8.9</NOBR>)</TD>
1346</TR>
1347</TABLE>
1348</BLOCKQUOTE>
1349</P>
1350
1351<H3>9.2. Changes to Function Arguments</H3>
1352
1353<P>
1354Besides simple name changes, some operations were given a different interface
1355in <NOBR>Release 3</NOBR> than they had in <NOBR>Release 2</NOBR>:
1356<UL>
1357
1358<LI>
1359<P>
1360Since <NOBR>Release 3</NOBR>, integer arguments and results of functions have
1361standard types from header <CODE>&lt;stdint.h&gt;</CODE>, such as
1362<CODE>uint32_t</CODE>, whereas previously their types could be defined
1363differently for each port of SoftFloat, usually using traditional C types such
1364as <CODE>unsigned</CODE> <CODE>int</CODE>.
1365Likewise, functions in <NOBR>Release 3</NOBR> and later pass Booleans as
1366standard type <CODE>bool</CODE> from <CODE>&lt;stdbool.h&gt;</CODE>, whereas
1367previously these were again passed as a port-specific type (usually
1368<CODE>int</CODE>).
1369</P>
1370
1371<LI>
1372<P>
1373As explained earlier in <NOBR>section 4.5</NOBR>, <I>Conventions for Passing
1374Arguments and Results</I>, SoftFloat functions in <NOBR>Release 3</NOBR> and
1375later may pass <NOBR>80-bit</NOBR> and <NOBR>128-bit</NOBR> floating-point
1376values through pointers, meaning that functions take pointer arguments and then
1377read or write floating-point values at the locations indicated by the pointers.
1378In <NOBR>Release 2</NOBR>, floating-point arguments and results were always
1379passed by value, regardless of their size.
1380</P>
1381
1382<LI>
1383<P>
1384Functions that round to an integer have additional
1385<CODE><I>roundingMode</I></CODE> and <CODE><I>exact</I></CODE> arguments that
1386they did not have in <NOBR>Release 2</NOBR>.
1387Refer to sections 8.2 <NOBR>and 8.7</NOBR> for descriptions of these functions
1388since <NOBR>Release 3</NOBR>.
1389For <NOBR>Release 2</NOBR>, the rounding mode, when needed, was taken from the
1390same global variable that affects the basic arithmetic operations (now called
1391<CODE>softfloat_roundingMode</CODE> but previously known as
1392<CODE>float_rounding_mode</CODE>).
1393Also, for <NOBR>Release 2</NOBR>, if the original floating-point input was not
1394an exact integer value, and if the <I>invalid</I> exception was not raised by
1395the function, the <I>inexact</I> exception was always raised.
1396<NOBR>Release 2</NOBR> had no option to suppress raising <I>inexact</I> in this
1397case.
1398Applications using SoftFloat <NOBR>Release 3</NOBR> or later can get the same
1399effect as <NOBR>Release 2</NOBR> by passing variable
1400<CODE>softfloat_roundingMode</CODE> for argument
1401<CODE><I>roundingMode</I></CODE> and <CODE>true</CODE> for argument
1402<CODE><I>exact</I></CODE>.
1403</P>
1404
1405</UL>
1406</P>
1407
1408<H3>9.3. Added Capabilities</H3>
1409
1410<P>
1411With <NOBR>Release 3</NOBR>, some new features have been added that were not
1412present in <NOBR>Release 2</NOBR>:
1413<UL>
1414
1415<LI>
1416<P>
1417A port of SoftFloat can now define any of the floating-point types
1418<CODE>float32_t</CODE>, <CODE>float64_t</CODE>, <CODE>extFloat80_t</CODE>, and
1419<CODE>float128_t</CODE> as aliases for C&rsquo;s standard floating-point types
1420<CODE>float</CODE>, <CODE>double</CODE>, and <CODE>long</CODE>
1421<CODE>double</CODE>, using either <CODE>#define</CODE> or <CODE>typedef</CODE>.
1422This potential convenience was not supported under <NOBR>Release 2</NOBR>.
1423</P>
1424
1425<P>
1426(Note, however, that there may be a performance cost to defining
1427SoftFloat&rsquo;s floating-point types this way, depending on the platform and
1428the applications using SoftFloat.
1429Ports of SoftFloat may choose to forgo the convenience in favor of better
1430speed.)
1431</P>
1432
1433<P>
1434<LI>
1435As of <NOBR>Release 3b</NOBR>, <NOBR>16-bit</NOBR> half-precision,
1436<CODE>float16_t</CODE>, is supported.
1437</P>
1438
1439<P>
1440<LI>
1441Functions have been added for converting between the floating-point types and
1442unsigned integers.
1443<NOBR>Release 2</NOBR> supported only signed integers, not unsigned.
1444</P>
1445
1446<P>
1447<LI>
1448Fused multiply-add functions have been added for all floating-point formats
1449except <NOBR>80-bit</NOBR> double-extended-precision,
1450<CODE>extFloat80_t</CODE>.
1451</P>
1452
1453<P>
1454<LI>
1455New rounding modes are supported:
1456<CODE>softfloat_round_near_maxMag</CODE> (round to nearest, with ties to
1457maximum magnitude, away from zero), and, as of <NOBR>Release 3c</NOBR>,
1458optional <CODE>softfloat_round_odd</CODE> (round to odd, also known as
1459jamming).
1460</P>
1461
1462</UL>
1463</P>
1464
1465<H3>9.4. Better Compatibility with the C Language</H3>
1466
1467<P>
1468<NOBR>Release 3</NOBR> of SoftFloat was written to conform better to the ISO C
1469Standard&rsquo;s rules for portability.
1470For example, older releases of SoftFloat employed type conversions in ways
1471that, while commonly practiced, are not fully defined by the C Standard.
1472Such problematic type conversions have generally been replaced by the use of
1473unions, the behavior around which is more strictly regulated these days.
1474</P>
1475
1476<H3>9.5. New Organization as a Library</H3>
1477
1478<P>
1479Starting with <NOBR>Release 3</NOBR>, SoftFloat now builds as a library.
1480Previously, SoftFloat compiled into a single, monolithic object file containing
1481all the SoftFloat functions, with the consequence that a program linking with
1482SoftFloat would get every SoftFloat function in its binary file even if only a
1483few functions were actually used.
1484With SoftFloat in the form of a library, a program that is linked by a standard
1485linker will include only those functions of SoftFloat that it needs and no
1486others.
1487</P>
1488
1489<H3>9.6. Optimization Gains (and Losses)</H3>
1490
1491<P>
1492Individual SoftFloat functions have been variously improved in
1493<NOBR>Release 3</NOBR> compared to earlier releases.
1494In particular, better, faster algorithms have been deployed for the operations
1495of division, square root, and remainder.
1496For functions operating on the larger <NOBR>80-bit</NOBR> and
1497<NOBR>128-bit</NOBR> formats, <CODE>extFloat80_t</CODE> and
1498<CODE>float128_t</CODE>, code size has also generally been reduced.
1499</P>
1500
1501<P>
1502However, because <NOBR>Release 2</NOBR> compiled all of SoftFloat together as a
1503single object file, compilers could make optimizations across function calls
1504when one SoftFloat function calls another.
1505Now that the functions of SoftFloat are compiled separately and only afterward
1506linked together into a program, there is not usually the same opportunity to
1507optimize across function calls.
1508Some loss of speed has been observed due to this change.
1509</P>
1510
1511
1512<H2>10. Future Directions</H2>
1513
1514<P>
1515The following improvements are anticipated for future releases of SoftFloat:
1516<UL>
1517<LI>
1518more functions from the 2008 version of the IEEE Floating-Point Standard;
1519<LI>
1520consistent, defined behavior for non-canonical representations of extended
1521format <CODE>extFloat80_t</CODE> (discussed in <NOBR>section 4.4</NOBR>,
1522<I>Non-canonical Representations in <CODE>extFloat80_t</CODE></I>).
1523
1524</UL>
1525</P>
1526
1527
1528<H2>11. Contact Information</H2>
1529
1530<P>
1531At the time of this writing, the most up-to-date information about SoftFloat
1532and the latest release can be found at the Web page
1533<A HREF="http://www.jhauser.us/arithmetic/SoftFloat.html"><NOBR><CODE>http://www.jhauser.us/arithmetic/SoftFloat.html</CODE></NOBR></A>.
1534</P>
1535
1536
1537</BODY>
1538
deps/SoftFloat-3d/source/8086-SSE/extF80M_isSignalingNaN.c deleted-57
......@@ -1,57 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43*----------------------------------------------------------------------------*/
44bool extF80M_isSignalingNaN( const extFloat80_t *aPtr )
45{
46 const struct extFloat80M *aSPtr;
47 uint64_t uiA0;
48
49 aSPtr = (const struct extFloat80M *) aPtr;
50 if ( (aSPtr->signExp & 0x7FFF) != 0x7FFF ) return false;
51 uiA0 = aSPtr->signif;
52 return
53 ! (uiA0 & UINT64_C( 0x4000000000000000 ))
54 && (uiA0 & UINT64_C( 0x3FFFFFFFFFFFFFFF));
55
56}
57
deps/SoftFloat-3d/source/8086-SSE/f128M_isSignalingNaN.c deleted-60
......@@ -1,60 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "primitives.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44*----------------------------------------------------------------------------*/
45bool f128M_isSignalingNaN( const float128_t *aPtr )
46{
47 const uint32_t *aWPtr;
48 uint32_t uiA96;
49
50 aWPtr = (const uint32_t *) aPtr;
51 uiA96 = aWPtr[indexWordHi( 4 )];
52 if ( (uiA96 & 0x7FFF8000) != 0x7FFF0000 ) return false;
53 return
54 ((uiA96 & 0x00007FFF) != 0)
55 || ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
56 | aWPtr[indexWord( 4, 0 )])
57 != 0);
58
59}
60
deps/SoftFloat-3d/source/8086-SSE/s_commonNaNToExtF80M.c deleted-56
......@@ -1,56 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by `aPtr' into an 80-bit extended
44| floating-point NaN, and stores this NaN at the location pointed to by
45| `zSPtr'.
46*----------------------------------------------------------------------------*/
47void
48 softfloat_commonNaNToExtF80M(
49 const struct commonNaN *aPtr, struct extFloat80M *zSPtr )
50{
51
52 zSPtr->signExp = packToExtF80UI64( aPtr->sign, 0x7FFF );
53 zSPtr->signif = UINT64_C( 0xC000000000000000 ) | aPtr->v64>>1;
54
55}
56
deps/SoftFloat-3d/source/8086-SSE/s_commonNaNToExtF80UI.c deleted-56
......@@ -1,56 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by `aPtr' into an 80-bit extended
44| floating-point NaN, and returns the bit pattern of this value as an unsigned
45| integer.
46*----------------------------------------------------------------------------*/
47struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr )
48{
49 struct uint128 uiZ;
50
51 uiZ.v64 = (uint_fast16_t) aPtr->sign<<15 | 0x7FFF;
52 uiZ.v0 = UINT64_C( 0xC000000000000000 ) | aPtr->v64>>1;
53 return uiZ;
54
55}
56
deps/SoftFloat-3d/source/8086-SSE/s_commonNaNToF128M.c deleted-56
......@@ -1,56 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by `aPtr' into a 128-bit floating-point
44| NaN, and stores this NaN at the location pointed to by `zWPtr'. Argument
45| `zWPtr' points to an array of four 32-bit elements that concatenate in the
46| platform's normal endian order to form a 128-bit floating-point value.
47*----------------------------------------------------------------------------*/
48void
49 softfloat_commonNaNToF128M( const struct commonNaN *aPtr, uint32_t *zWPtr )
50{
51
52 softfloat_shortShiftRight128M( (const uint32_t *) &aPtr->v0, 16, zWPtr );
53 zWPtr[indexWordHi( 4 )] |= (uint32_t) aPtr->sign<<31 | 0x7FFF8000;
54
55}
56
deps/SoftFloat-3d/source/8086-SSE/s_commonNaNToF128UI.c deleted-55
......@@ -1,55 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by `aPtr' into a 128-bit floating-point
44| NaN, and returns the bit pattern of this value as an unsigned integer.
45*----------------------------------------------------------------------------*/
46struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN *aPtr )
47{
48 struct uint128 uiZ;
49
50 uiZ = softfloat_shortShiftRight128( aPtr->v64, aPtr->v0, 16 );
51 uiZ.v64 |= (uint_fast64_t) aPtr->sign<<63 | UINT64_C( 0x7FFF800000000000 );
52 return uiZ;
53
54}
55
deps/SoftFloat-3d/source/8086-SSE/s_commonNaNToF16UI.c deleted-51
......@@ -1,51 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40
41/*----------------------------------------------------------------------------
42| Converts the common NaN pointed to by `aPtr' into a 16-bit floating-point
43| NaN, and returns the bit pattern of this value as an unsigned integer.
44*----------------------------------------------------------------------------*/
45uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr )
46{
47
48 return (uint_fast16_t) aPtr->sign<<15 | 0x7E00 | aPtr->v64>>54;
49
50}
51
deps/SoftFloat-3d/source/8086-SSE/s_commonNaNToF32UI.c deleted-51
......@@ -1,51 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40
41/*----------------------------------------------------------------------------
42| Converts the common NaN pointed to by `aPtr' into a 32-bit floating-point
43| NaN, and returns the bit pattern of this value as an unsigned integer.
44*----------------------------------------------------------------------------*/
45uint_fast32_t softfloat_commonNaNToF32UI( const struct commonNaN *aPtr )
46{
47
48 return (uint_fast32_t) aPtr->sign<<31 | 0x7FC00000 | aPtr->v64>>41;
49
50}
51
deps/SoftFloat-3d/source/8086-SSE/s_commonNaNToF64UI.c deleted-53
......@@ -1,53 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40
41/*----------------------------------------------------------------------------
42| Converts the common NaN pointed to by `aPtr' into a 64-bit floating-point
43| NaN, and returns the bit pattern of this value as an unsigned integer.
44*----------------------------------------------------------------------------*/
45uint_fast64_t softfloat_commonNaNToF64UI( const struct commonNaN *aPtr )
46{
47
48 return
49 (uint_fast64_t) aPtr->sign<<63 | UINT64_C( 0x7FF8000000000000 )
50 | aPtr->v64>>12;
51
52}
53
deps/SoftFloat-3d/source/8086-SSE/s_extF80MToCommonNaN.c deleted-62
......@@ -1,62 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Assuming the 80-bit extended floating-point value pointed to by `aSPtr' is
45| a NaN, converts this NaN to the common NaN form, and stores the resulting
46| common NaN at the location pointed to by `zPtr'. If the NaN is a signaling
47| NaN, the invalid exception is raised.
48*----------------------------------------------------------------------------*/
49void
50 softfloat_extF80MToCommonNaN(
51 const struct extFloat80M *aSPtr, struct commonNaN *zPtr )
52{
53
54 if ( extF80M_isSignalingNaN( (const extFloat80_t *) aSPtr ) ) {
55 softfloat_raiseFlags( softfloat_flag_invalid );
56 }
57 zPtr->sign = signExtF80UI64( aSPtr->signExp );
58 zPtr->v64 = aSPtr->signif<<1;
59 zPtr->v0 = 0;
60
61}
62
deps/SoftFloat-3d/source/8086-SSE/s_extF80UIToCommonNaN.c deleted-62
......@@ -1,62 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming the unsigned integer formed from concatenating `uiA64' and `uiA0'
44| has the bit pattern of an 80-bit extended floating-point NaN, converts
45| this NaN to the common NaN form, and stores the resulting common NaN at the
46| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
47| exception is raised.
48*----------------------------------------------------------------------------*/
49void
50 softfloat_extF80UIToCommonNaN(
51 uint_fast16_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr )
52{
53
54 if ( softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ) {
55 softfloat_raiseFlags( softfloat_flag_invalid );
56 }
57 zPtr->sign = uiA64>>15;
58 zPtr->v64 = uiA0<<1;
59 zPtr->v0 = 0;
60
61}
62
deps/SoftFloat-3d/source/8086-SSE/s_f128MToCommonNaN.c deleted-62
......@@ -1,62 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Assuming the 128-bit floating-point value pointed to by `aWPtr' is a NaN,
45| converts this NaN to the common NaN form, and stores the resulting common
46| NaN at the location pointed to by `zPtr'. If the NaN is a signaling NaN,
47| the invalid exception is raised. Argument `aWPtr' points to an array of
48| four 32-bit elements that concatenate in the platform's normal endian order
49| to form a 128-bit floating-point value.
50*----------------------------------------------------------------------------*/
51void
52 softfloat_f128MToCommonNaN( const uint32_t *aWPtr, struct commonNaN *zPtr )
53{
54
55 if ( f128M_isSignalingNaN( (const float128_t *) aWPtr ) ) {
56 softfloat_raiseFlags( softfloat_flag_invalid );
57 }
58 zPtr->sign = aWPtr[indexWordHi( 4 )]>>31;
59 softfloat_shortShiftLeft128M( aWPtr, 16, (uint32_t *) &zPtr->v0 );
60
61}
62
deps/SoftFloat-3d/source/8086-SSE/s_f128UIToCommonNaN.c deleted-65
......@@ -1,65 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Assuming the unsigned integer formed from concatenating `uiA64' and `uiA0'
45| has the bit pattern of a 128-bit floating-point NaN, converts this NaN to
46| the common NaN form, and stores the resulting common NaN at the location
47| pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid exception
48| is raised.
49*----------------------------------------------------------------------------*/
50void
51 softfloat_f128UIToCommonNaN(
52 uint_fast64_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr )
53{
54 struct uint128 NaNSig;
55
56 if ( softfloat_isSigNaNF128UI( uiA64, uiA0 ) ) {
57 softfloat_raiseFlags( softfloat_flag_invalid );
58 }
59 NaNSig = softfloat_shortShiftLeft128( uiA64, uiA0, 16 );
60 zPtr->sign = uiA64>>63;
61 zPtr->v64 = NaNSig.v64;
62 zPtr->v0 = NaNSig.v0;
63
64}
65
deps/SoftFloat-3d/source/8086-SSE/s_f16UIToCommonNaN.c deleted-59
......@@ -1,59 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming `uiA' has the bit pattern of a 16-bit floating-point NaN, converts
44| this NaN to the common NaN form, and stores the resulting common NaN at the
45| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
46| exception is raised.
47*----------------------------------------------------------------------------*/
48void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr )
49{
50
51 if ( softfloat_isSigNaNF16UI( uiA ) ) {
52 softfloat_raiseFlags( softfloat_flag_invalid );
53 }
54 zPtr->sign = uiA>>15;
55 zPtr->v64 = (uint_fast64_t) uiA<<54;
56 zPtr->v0 = 0;
57
58}
59
deps/SoftFloat-3d/source/8086-SSE/s_f32UIToCommonNaN.c deleted-59
......@@ -1,59 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming `uiA' has the bit pattern of a 32-bit floating-point NaN, converts
44| this NaN to the common NaN form, and stores the resulting common NaN at the
45| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
46| exception is raised.
47*----------------------------------------------------------------------------*/
48void softfloat_f32UIToCommonNaN( uint_fast32_t uiA, struct commonNaN *zPtr )
49{
50
51 if ( softfloat_isSigNaNF32UI( uiA ) ) {
52 softfloat_raiseFlags( softfloat_flag_invalid );
53 }
54 zPtr->sign = uiA>>31;
55 zPtr->v64 = (uint_fast64_t) uiA<<41;
56 zPtr->v0 = 0;
57
58}
59
deps/SoftFloat-3d/source/8086-SSE/s_f64UIToCommonNaN.c deleted-59
......@@ -1,59 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming `uiA' has the bit pattern of a 64-bit floating-point NaN, converts
44| this NaN to the common NaN form, and stores the resulting common NaN at the
45| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
46| exception is raised.
47*----------------------------------------------------------------------------*/
48void softfloat_f64UIToCommonNaN( uint_fast64_t uiA, struct commonNaN *zPtr )
49{
50
51 if ( softfloat_isSigNaNF64UI( uiA ) ) {
52 softfloat_raiseFlags( softfloat_flag_invalid );
53 }
54 zPtr->sign = uiA>>63;
55 zPtr->v64 = uiA<<12;
56 zPtr->v0 = 0;
57
58}
59
deps/SoftFloat-3d/source/8086-SSE/s_propagateNaNExtF80M.c deleted-107
......@@ -1,107 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Assuming at least one of the two 80-bit extended floating-point values
46| pointed to by `aSPtr' and `bSPtr' is a NaN, stores the combined NaN result
47| at the location pointed to by `zSPtr'. If either original floating-point
48| value is a signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50void
51 softfloat_propagateNaNExtF80M(
52 const struct extFloat80M *aSPtr,
53 const struct extFloat80M *bSPtr,
54 struct extFloat80M *zSPtr
55 )
56{
57 bool isSigNaNA;
58 const struct extFloat80M *sPtr;
59 bool isSigNaNB;
60 uint_fast16_t uiB64;
61 uint64_t uiB0;
62 uint_fast16_t uiA64;
63 uint64_t uiA0;
64 uint_fast16_t uiMagA64, uiMagB64;
65
66 isSigNaNA = extF80M_isSignalingNaN( (const extFloat80_t *) aSPtr );
67 sPtr = aSPtr;
68 if ( ! bSPtr ) {
69 if ( isSigNaNA ) softfloat_raiseFlags( softfloat_flag_invalid );
70 goto copy;
71 }
72 isSigNaNB = extF80M_isSignalingNaN( (const extFloat80_t *) bSPtr );
73 if ( isSigNaNA | isSigNaNB ) {
74 softfloat_raiseFlags( softfloat_flag_invalid );
75 if ( isSigNaNA ) {
76 uiB64 = bSPtr->signExp;
77 if ( isSigNaNB ) goto returnLargerUIMag;
78 uiB0 = bSPtr->signif;
79 if ( isNaNExtF80UI( uiB64, uiB0 ) ) goto copyB;
80 goto copy;
81 } else {
82 uiA64 = aSPtr->signExp;
83 uiA0 = aSPtr->signif;
84 if ( isNaNExtF80UI( uiA64, uiA0 ) ) goto copy;
85 goto copyB;
86 }
87 }
88 uiB64 = bSPtr->signExp;
89 returnLargerUIMag:
90 uiA64 = aSPtr->signExp;
91 uiMagA64 = uiA64 & 0x7FFF;
92 uiMagB64 = uiB64 & 0x7FFF;
93 if ( uiMagA64 < uiMagB64 ) goto copyB;
94 if ( uiMagB64 < uiMagA64 ) goto copy;
95 uiA0 = aSPtr->signif;
96 uiB0 = bSPtr->signif;
97 if ( uiA0 < uiB0 ) goto copyB;
98 if ( uiB0 < uiA0 ) goto copy;
99 if ( uiA64 < uiB64 ) goto copy;
100 copyB:
101 sPtr = bSPtr;
102 copy:
103 zSPtr->signExp = sPtr->signExp;
104 zSPtr->signif = sPtr->signif | UINT64_C( 0xC000000000000000 );
105
106}
107
deps/SoftFloat-3d/source/8086-SSE/s_propagateNaNExtF80UI.c deleted-106
......@@ -1,106 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting the unsigned integer formed from concatenating `uiA64' and
46| `uiA0' as an 80-bit extended floating-point value, and likewise interpreting
47| the unsigned integer formed from concatenating `uiB64' and `uiB0' as another
48| 80-bit extended floating-point value, and assuming at least on of these
49| floating-point values is a NaN, returns the bit pattern of the combined NaN
50| result. If either original floating-point value is a signaling NaN, the
51| invalid exception is raised.
52*----------------------------------------------------------------------------*/
53struct uint128
54 softfloat_propagateNaNExtF80UI(
55 uint_fast16_t uiA64,
56 uint_fast64_t uiA0,
57 uint_fast16_t uiB64,
58 uint_fast64_t uiB0
59 )
60{
61 bool isSigNaNA, isSigNaNB;
62 uint_fast64_t uiNonsigA0, uiNonsigB0;
63 uint_fast16_t uiMagA64, uiMagB64;
64 struct uint128 uiZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 isSigNaNA = softfloat_isSigNaNExtF80UI( uiA64, uiA0 );
69 isSigNaNB = softfloat_isSigNaNExtF80UI( uiB64, uiB0 );
70 /*------------------------------------------------------------------------
71 | Make NaNs non-signaling.
72 *------------------------------------------------------------------------*/
73 uiNonsigA0 = uiA0 | UINT64_C( 0xC000000000000000 );
74 uiNonsigB0 = uiB0 | UINT64_C( 0xC000000000000000 );
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( isSigNaNA | isSigNaNB ) {
78 softfloat_raiseFlags( softfloat_flag_invalid );
79 if ( isSigNaNA ) {
80 if ( isSigNaNB ) goto returnLargerMag;
81 if ( isNaNExtF80UI( uiB64, uiB0 ) ) goto returnB;
82 goto returnA;
83 } else {
84 if ( isNaNExtF80UI( uiA64, uiA0 ) ) goto returnA;
85 goto returnB;
86 }
87 }
88 returnLargerMag:
89 uiMagA64 = uiA64 & 0x7FFF;
90 uiMagB64 = uiB64 & 0x7FFF;
91 if ( uiMagA64 < uiMagB64 ) goto returnB;
92 if ( uiMagB64 < uiMagA64 ) goto returnA;
93 if ( uiNonsigA0 < uiNonsigB0 ) goto returnB;
94 if ( uiNonsigB0 < uiNonsigA0 ) goto returnA;
95 if ( uiA64 < uiB64 ) goto returnA;
96 returnB:
97 uiZ.v64 = uiB64;
98 uiZ.v0 = uiNonsigB0;
99 return uiZ;
100 returnA:
101 uiZ.v64 = uiA64;
102 uiZ.v0 = uiNonsigA0;
103 return uiZ;
104
105}
106
deps/SoftFloat-3d/source/8086-SSE/s_propagateNaNF128M.c deleted-76
......@@ -1,76 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Assuming at least one of the two 128-bit floating-point values pointed to by
46| `aWPtr' and `bWPtr' is a NaN, stores the combined NaN result at the location
47| pointed to by `zWPtr'. If either original floating-point value is a
48| signaling NaN, the invalid exception is raised. Each of `aWPtr', `bWPtr',
49| and `zWPtr' points to an array of four 32-bit elements that concatenate in
50| the platform's normal endian order to form a 128-bit floating-point value.
51*----------------------------------------------------------------------------*/
52void
53 softfloat_propagateNaNF128M(
54 const uint32_t *aWPtr, const uint32_t *bWPtr, uint32_t *zWPtr )
55{
56 bool isSigNaNA;
57 const uint32_t *ptr;
58
59 ptr = aWPtr;
60 isSigNaNA = f128M_isSignalingNaN( (const float128_t *) aWPtr );
61 if (
62 isSigNaNA
63 || (bWPtr && f128M_isSignalingNaN( (const float128_t *) bWPtr ))
64 ) {
65 softfloat_raiseFlags( softfloat_flag_invalid );
66 if ( isSigNaNA ) goto copy;
67 }
68 if ( ! softfloat_isNaNF128M( aWPtr ) ) ptr = bWPtr;
69 copy:
70 zWPtr[indexWordHi( 4 )] = ptr[indexWordHi( 4 )] | 0x00008000;
71 zWPtr[indexWord( 4, 2 )] = ptr[indexWord( 4, 2 )];
72 zWPtr[indexWord( 4, 1 )] = ptr[indexWord( 4, 1 )];
73 zWPtr[indexWord( 4, 0 )] = ptr[indexWord( 4, 0 )];
74
75}
76
deps/SoftFloat-3d/source/8086-SSE/s_propagateNaNF128UI.c deleted-81
......@@ -1,81 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting the unsigned integer formed from concatenating `uiA64' and
46| `uiA0' as a 128-bit floating-point value, and likewise interpreting the
47| unsigned integer formed from concatenating `uiB64' and `uiB0' as another
48| 128-bit floating-point value, and assuming at least on of these floating-
49| point values is a NaN, returns the bit pattern of the combined NaN result.
50| If either original floating-point value is a signaling NaN, the invalid
51| exception is raised.
52*----------------------------------------------------------------------------*/
53struct uint128
54 softfloat_propagateNaNF128UI(
55 uint_fast64_t uiA64,
56 uint_fast64_t uiA0,
57 uint_fast64_t uiB64,
58 uint_fast64_t uiB0
59 )
60{
61 bool isSigNaNA;
62 struct uint128 uiZ;
63
64 isSigNaNA = softfloat_isSigNaNF128UI( uiA64, uiA0 );
65 if ( isSigNaNA || softfloat_isSigNaNF128UI( uiB64, uiB0 ) ) {
66 softfloat_raiseFlags( softfloat_flag_invalid );
67 if ( isSigNaNA ) goto returnNonsigA;
68 }
69 if ( isNaNF128UI( uiA64, uiA0 ) ) {
70 returnNonsigA:
71 uiZ.v64 = uiA64;
72 uiZ.v0 = uiA0;
73 } else {
74 uiZ.v64 = uiB64;
75 uiZ.v0 = uiB0;
76 }
77 uiZ.v64 |= UINT64_C( 0x0000800000000000 );
78 return uiZ;
79
80}
81
deps/SoftFloat-3d/source/8086-SSE/s_propagateNaNF16UI.c deleted-63
......@@ -1,63 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting `uiA' and `uiB' as the bit patterns of two 16-bit floating-
46| point values, at least one of which is a NaN, returns the bit pattern of
47| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
48| signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50uint_fast16_t
51 softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB )
52{
53 bool isSigNaNA;
54
55 isSigNaNA = softfloat_isSigNaNF16UI( uiA );
56 if ( isSigNaNA || softfloat_isSigNaNF16UI( uiB ) ) {
57 softfloat_raiseFlags( softfloat_flag_invalid );
58 if ( isSigNaNA ) return uiA | 0x0200;
59 }
60 return (isNaNF16UI( uiA ) ? uiA : uiB) | 0x0200;
61
62}
63
deps/SoftFloat-3d/source/8086-SSE/s_propagateNaNF32UI.c deleted-63
......@@ -1,63 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting `uiA' and `uiB' as the bit patterns of two 32-bit floating-
46| point values, at least one of which is a NaN, returns the bit pattern of
47| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
48| signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50uint_fast32_t
51 softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB )
52{
53 bool isSigNaNA;
54
55 isSigNaNA = softfloat_isSigNaNF32UI( uiA );
56 if ( isSigNaNA || softfloat_isSigNaNF32UI( uiB ) ) {
57 softfloat_raiseFlags( softfloat_flag_invalid );
58 if ( isSigNaNA ) return uiA | 0x00400000;
59 }
60 return (isNaNF32UI( uiA ) ? uiA : uiB) | 0x00400000;
61
62}
63
deps/SoftFloat-3d/source/8086-SSE/s_propagateNaNF64UI.c deleted-63
......@@ -1,63 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting `uiA' and `uiB' as the bit patterns of two 64-bit floating-
46| point values, at least one of which is a NaN, returns the bit pattern of
47| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
48| signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50uint_fast64_t
51 softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB )
52{
53 bool isSigNaNA;
54
55 isSigNaNA = softfloat_isSigNaNF64UI( uiA );
56 if ( isSigNaNA || softfloat_isSigNaNF64UI( uiB ) ) {
57 softfloat_raiseFlags( softfloat_flag_invalid );
58 if ( isSigNaNA ) return uiA | UINT64_C( 0x0008000000000000 );
59 }
60 return (isNaNF64UI( uiA ) ? uiA : uiB) | UINT64_C( 0x0008000000000000 );
61
62}
63
deps/SoftFloat-3d/source/8086-SSE/softfloat_raiseFlags.c deleted-52
......@@ -1,52 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include "platform.h"
38#include "softfloat.h"
39
40/*----------------------------------------------------------------------------
41| Raises the exceptions specified by `flags'. Floating-point traps can be
42| defined here if desired. It is currently not possible for such a trap
43| to substitute a result value. If traps are not implemented, this routine
44| should be simply `softfloat_exceptionFlags |= flags;'.
45*----------------------------------------------------------------------------*/
46void softfloat_raiseFlags( uint_fast8_t flags )
47{
48
49 softfloat_exceptionFlags |= flags;
50
51}
52
deps/SoftFloat-3d/source/8086-SSE/specialize.h deleted-375
......@@ -1,375 +0,0 @@
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#ifndef specialize_h
38#define specialize_h 1
39
40#include <stdbool.h>
41#include <stdint.h>
42#include "softfloat_types.h"
43
44/*----------------------------------------------------------------------------
45| Default value for `softfloat_detectTininess'.
46*----------------------------------------------------------------------------*/
47#define init_detectTininess softfloat_tininess_afterRounding
48
49/*----------------------------------------------------------------------------
50| The values to return on conversions to 32-bit integer formats that raise an
51| invalid exception.
52*----------------------------------------------------------------------------*/
53#define ui32_fromPosOverflow 0xFFFFFFFF
54#define ui32_fromNegOverflow 0
55#define ui32_fromNaN 0xFFFFFFFF
56#define i32_fromPosOverflow 0x7FFFFFFF
57#define i32_fromNegOverflow (-0x7FFFFFFF - 1)
58#define i32_fromNaN 0x7FFFFFFF
59
60/*----------------------------------------------------------------------------
61| The values to return on conversions to 64-bit integer formats that raise an
62| invalid exception.
63*----------------------------------------------------------------------------*/
64#define ui64_fromPosOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
65#define ui64_fromNegOverflow 0
66#define ui64_fromNaN UINT64_C( 0xFFFFFFFFFFFFFFFF )
67#define i64_fromPosOverflow UINT64_C( 0x7FFFFFFFFFFFFFFF )
68#define i64_fromNegOverflow (-UINT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
69#define i64_fromNaN UINT64_C( 0x7FFFFFFFFFFFFFFF )
70
71/*----------------------------------------------------------------------------
72| "Common NaN" structure, used to transfer NaN representations from one format
73| to another.
74*----------------------------------------------------------------------------*/
75struct commonNaN {
76 bool sign;
77#ifdef LITTLEENDIAN
78 uint64_t v0, v64;
79#else
80 uint64_t v64, v0;
81#endif
82};
83
84/*----------------------------------------------------------------------------
85| The bit pattern for a default generated 16-bit floating-point NaN.
86*----------------------------------------------------------------------------*/
87#define defaultNaNF16UI 0xFE00
88
89/*----------------------------------------------------------------------------
90| Returns true when 16-bit unsigned integer `uiA' has the bit pattern of a
91| 16-bit floating-point signaling NaN.
92| Note: This macro evaluates its argument more than once.
93*----------------------------------------------------------------------------*/
94#define softfloat_isSigNaNF16UI( uiA ) ((((uiA) & 0x7E00) == 0x7C00) && ((uiA) & 0x01FF))
95
96/*----------------------------------------------------------------------------
97| Assuming `uiA' has the bit pattern of a 16-bit floating-point NaN, converts
98| this NaN to the common NaN form, and stores the resulting common NaN at the
99| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
100| exception is raised.
101*----------------------------------------------------------------------------*/
102void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr );
103
104/*----------------------------------------------------------------------------
105| Converts the common NaN pointed to by `aPtr' into a 16-bit floating-point
106| NaN, and returns the bit pattern of this value as an unsigned integer.
107*----------------------------------------------------------------------------*/
108uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr );
109
110/*----------------------------------------------------------------------------
111| Interpreting `uiA' and `uiB' as the bit patterns of two 16-bit floating-
112| point values, at least one of which is a NaN, returns the bit pattern of
113| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
114| signaling NaN, the invalid exception is raised.
115*----------------------------------------------------------------------------*/
116uint_fast16_t
117 softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB );
118
119/*----------------------------------------------------------------------------
120| The bit pattern for a default generated 32-bit floating-point NaN.
121*----------------------------------------------------------------------------*/
122#define defaultNaNF32UI 0xFFC00000
123
124/*----------------------------------------------------------------------------
125| Returns true when 32-bit unsigned integer `uiA' has the bit pattern of a
126| 32-bit floating-point signaling NaN.
127| Note: This macro evaluates its argument more than once.
128*----------------------------------------------------------------------------*/
129#define softfloat_isSigNaNF32UI( uiA ) ((((uiA) & 0x7FC00000) == 0x7F800000) && ((uiA) & 0x003FFFFF))
130
131/*----------------------------------------------------------------------------
132| Assuming `uiA' has the bit pattern of a 32-bit floating-point NaN, converts
133| this NaN to the common NaN form, and stores the resulting common NaN at the
134| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
135| exception is raised.
136*----------------------------------------------------------------------------*/
137void softfloat_f32UIToCommonNaN( uint_fast32_t uiA, struct commonNaN *zPtr );
138
139/*----------------------------------------------------------------------------
140| Converts the common NaN pointed to by `aPtr' into a 32-bit floating-point
141| NaN, and returns the bit pattern of this value as an unsigned integer.
142*----------------------------------------------------------------------------*/
143uint_fast32_t softfloat_commonNaNToF32UI( const struct commonNaN *aPtr );
144
145/*----------------------------------------------------------------------------
146| Interpreting `uiA' and `uiB' as the bit patterns of two 32-bit floating-
147| point values, at least one of which is a NaN, returns the bit pattern of
148| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
149| signaling NaN, the invalid exception is raised.
150*----------------------------------------------------------------------------*/
151uint_fast32_t
152 softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB );
153
154/*----------------------------------------------------------------------------
155| The bit pattern for a default generated 64-bit floating-point NaN.
156*----------------------------------------------------------------------------*/
157#define defaultNaNF64UI UINT64_C( 0xFFF8000000000000 )
158
159/*----------------------------------------------------------------------------
160| Returns true when 64-bit unsigned integer `uiA' has the bit pattern of a
161| 64-bit floating-point signaling NaN.
162| Note: This macro evaluates its argument more than once.
163*----------------------------------------------------------------------------*/
164#define softfloat_isSigNaNF64UI( uiA ) ((((uiA) & UINT64_C( 0x7FF8000000000000 )) == UINT64_C( 0x7FF0000000000000 )) && ((uiA) & UINT64_C( 0x0007FFFFFFFFFFFF )))
165
166/*----------------------------------------------------------------------------
167| Assuming `uiA' has the bit pattern of a 64-bit floating-point NaN, converts
168| this NaN to the common NaN form, and stores the resulting common NaN at the
169| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
170| exception is raised.
171*----------------------------------------------------------------------------*/
172void softfloat_f64UIToCommonNaN( uint_fast64_t uiA, struct commonNaN *zPtr );
173
174/*----------------------------------------------------------------------------
175| Converts the common NaN pointed to by `aPtr' into a 64-bit floating-point
176| NaN, and returns the bit pattern of this value as an unsigned integer.
177*----------------------------------------------------------------------------*/
178uint_fast64_t softfloat_commonNaNToF64UI( const struct commonNaN *aPtr );
179
180/*----------------------------------------------------------------------------
181| Interpreting `uiA' and `uiB' as the bit patterns of two 64-bit floating-
182| point values, at least one of which is a NaN, returns the bit pattern of
183| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
184| signaling NaN, the invalid exception is raised.
185*----------------------------------------------------------------------------*/
186uint_fast64_t
187 softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB );
188
189/*----------------------------------------------------------------------------
190| The bit pattern for a default generated 80-bit extended floating-point NaN.
191*----------------------------------------------------------------------------*/
192#define defaultNaNExtF80UI64 0xFFFF
193#define defaultNaNExtF80UI0 UINT64_C( 0xC000000000000000 )
194
195/*----------------------------------------------------------------------------
196| Returns true when the 80-bit unsigned integer formed from concatenating
197| 16-bit `uiA64' and 64-bit `uiA0' has the bit pattern of an 80-bit extended
198| floating-point signaling NaN.
199| Note: This macro evaluates its arguments more than once.
200*----------------------------------------------------------------------------*/
201#define softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ((((uiA64) & 0x7FFF) == 0x7FFF) && ! ((uiA0) & UINT64_C( 0x4000000000000000 )) && ((uiA0) & UINT64_C( 0x3FFFFFFFFFFFFFFF )))
202
203#ifdef SOFTFLOAT_FAST_INT64
204
205/*----------------------------------------------------------------------------
206| The following functions are needed only when `SOFTFLOAT_FAST_INT64' is
207| defined.
208*----------------------------------------------------------------------------*/
209
210/*----------------------------------------------------------------------------
211| Assuming the unsigned integer formed from concatenating `uiA64' and `uiA0'
212| has the bit pattern of an 80-bit extended floating-point NaN, converts
213| this NaN to the common NaN form, and stores the resulting common NaN at the
214| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
215| exception is raised.
216*----------------------------------------------------------------------------*/
217void
218 softfloat_extF80UIToCommonNaN(
219 uint_fast16_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr );
220
221/*----------------------------------------------------------------------------
222| Converts the common NaN pointed to by `aPtr' into an 80-bit extended
223| floating-point NaN, and returns the bit pattern of this value as an unsigned
224| integer.
225*----------------------------------------------------------------------------*/
226struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr );
227
228/*----------------------------------------------------------------------------
229| Interpreting the unsigned integer formed from concatenating `uiA64' and
230| `uiA0' as an 80-bit extended floating-point value, and likewise interpreting
231| the unsigned integer formed from concatenating `uiB64' and `uiB0' as another
232| 80-bit extended floating-point value, and assuming at least on of these
233| floating-point values is a NaN, returns the bit pattern of the combined NaN
234| result. If either original floating-point value is a signaling NaN, the
235| invalid exception is raised.
236*----------------------------------------------------------------------------*/
237struct uint128
238 softfloat_propagateNaNExtF80UI(
239 uint_fast16_t uiA64,
240 uint_fast64_t uiA0,
241 uint_fast16_t uiB64,
242 uint_fast64_t uiB0
243 );
244
245/*----------------------------------------------------------------------------
246| The bit pattern for a default generated 128-bit floating-point NaN.
247*----------------------------------------------------------------------------*/
248#define defaultNaNF128UI64 UINT64_C( 0xFFFF800000000000 )
249#define defaultNaNF128UI0 UINT64_C( 0 )
250
251/*----------------------------------------------------------------------------
252| Returns true when the 128-bit unsigned integer formed from concatenating
253| 64-bit `uiA64' and 64-bit `uiA0' has the bit pattern of a 128-bit floating-
254| point signaling NaN.
255| Note: This macro evaluates its arguments more than once.
256*----------------------------------------------------------------------------*/
257#define softfloat_isSigNaNF128UI( uiA64, uiA0 ) ((((uiA64) & UINT64_C( 0x7FFF800000000000 )) == UINT64_C( 0x7FFF000000000000 )) && ((uiA0) || ((uiA64) & UINT64_C( 0x00007FFFFFFFFFFF ))))
258
259/*----------------------------------------------------------------------------
260| Assuming the unsigned integer formed from concatenating `uiA64' and `uiA0'
261| has the bit pattern of a 128-bit floating-point NaN, converts this NaN to
262| the common NaN form, and stores the resulting common NaN at the location
263| pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid exception
264| is raised.
265*----------------------------------------------------------------------------*/
266void
267 softfloat_f128UIToCommonNaN(
268 uint_fast64_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr );
269
270/*----------------------------------------------------------------------------
271| Converts the common NaN pointed to by `aPtr' into a 128-bit floating-point
272| NaN, and returns the bit pattern of this value as an unsigned integer.
273*----------------------------------------------------------------------------*/
274struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN * );
275
276/*----------------------------------------------------------------------------
277| Interpreting the unsigned integer formed from concatenating `uiA64' and
278| `uiA0' as a 128-bit floating-point value, and likewise interpreting the
279| unsigned integer formed from concatenating `uiB64' and `uiB0' as another
280| 128-bit floating-point value, and assuming at least on of these floating-
281| point values is a NaN, returns the bit pattern of the combined NaN result.
282| If either original floating-point value is a signaling NaN, the invalid
283| exception is raised.
284*----------------------------------------------------------------------------*/
285struct uint128
286 softfloat_propagateNaNF128UI(
287 uint_fast64_t uiA64,
288 uint_fast64_t uiA0,
289 uint_fast64_t uiB64,
290 uint_fast64_t uiB0
291 );
292
293#else
294
295/*----------------------------------------------------------------------------
296| The following functions are needed only when `SOFTFLOAT_FAST_INT64' is not
297| defined.
298*----------------------------------------------------------------------------*/
299
300/*----------------------------------------------------------------------------
301| Assuming the 80-bit extended floating-point value pointed to by `aSPtr' is
302| a NaN, converts this NaN to the common NaN form, and stores the resulting
303| common NaN at the location pointed to by `zPtr'. If the NaN is a signaling
304| NaN, the invalid exception is raised.
305*----------------------------------------------------------------------------*/
306void
307 softfloat_extF80MToCommonNaN(
308 const struct extFloat80M *aSPtr, struct commonNaN *zPtr );
309
310/*----------------------------------------------------------------------------
311| Converts the common NaN pointed to by `aPtr' into an 80-bit extended
312| floating-point NaN, and stores this NaN at the location pointed to by
313| `zSPtr'.
314*----------------------------------------------------------------------------*/
315void
316 softfloat_commonNaNToExtF80M(
317 const struct commonNaN *aPtr, struct extFloat80M *zSPtr );
318
319/*----------------------------------------------------------------------------
320| Assuming at least one of the two 80-bit extended floating-point values
321| pointed to by `aSPtr' and `bSPtr' is a NaN, stores the combined NaN result
322| at the location pointed to by `zSPtr'. If either original floating-point
323| value is a signaling NaN, the invalid exception is raised.
324*----------------------------------------------------------------------------*/
325void
326 softfloat_propagateNaNExtF80M(
327 const struct extFloat80M *aSPtr,
328 const struct extFloat80M *bSPtr,
329 struct extFloat80M *zSPtr
330 );
331
332/*----------------------------------------------------------------------------
333| The bit pattern for a default generated 128-bit floating-point NaN.
334*----------------------------------------------------------------------------*/
335#define defaultNaNF128UI96 0xFFFF8000
336#define defaultNaNF128UI64 0
337#define defaultNaNF128UI32 0
338#define defaultNaNF128UI0 0
339
340/*----------------------------------------------------------------------------
341| Assuming the 128-bit floating-point value pointed to by `aWPtr' is a NaN,
342| converts this NaN to the common NaN form, and stores the resulting common
343| NaN at the location pointed to by `zPtr'. If the NaN is a signaling NaN,
344| the invalid exception is raised. Argument `aWPtr' points to an array of
345| four 32-bit elements that concatenate in the platform's normal endian order
346| to form a 128-bit floating-point value.
347*----------------------------------------------------------------------------*/
348void
349 softfloat_f128MToCommonNaN( const uint32_t *aWPtr, struct commonNaN *zPtr );
350
351/*----------------------------------------------------------------------------
352| Converts the common NaN pointed to by `aPtr' into a 128-bit floating-point
353| NaN, and stores this NaN at the location pointed to by `zWPtr'. Argument
354| `zWPtr' points to an array of four 32-bit elements that concatenate in the
355| platform's normal endian order to form a 128-bit floating-point value.
356*----------------------------------------------------------------------------*/
357void
358 softfloat_commonNaNToF128M( const struct commonNaN *aPtr, uint32_t *zWPtr );
359
360/*----------------------------------------------------------------------------
361| Assuming at least one of the two 128-bit floating-point values pointed to by
362| `aWPtr' and `bWPtr' is a NaN, stores the combined NaN result at the location
363| pointed to by `zWPtr'. If either original floating-point value is a
364| signaling NaN, the invalid exception is raised. Each of `aWPtr', `bWPtr',
365| and `zWPtr' points to an array of four 32-bit elements that concatenate in
366| the platform's normal endian order to form a 128-bit floating-point value.
367*----------------------------------------------------------------------------*/
368void
369 softfloat_propagateNaNF128M(
370 const uint32_t *aWPtr, const uint32_t *bWPtr, uint32_t *zWPtr );
371
372#endif
373
374#endif
375
deps/SoftFloat-3d/source/8086/extF80M_isSignalingNaN.c deleted-57
......@@ -1,57 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43*----------------------------------------------------------------------------*/
44bool extF80M_isSignalingNaN( const extFloat80_t *aPtr )
45{
46 const struct extFloat80M *aSPtr;
47 uint64_t uiA0;
48
49 aSPtr = (const struct extFloat80M *) aPtr;
50 if ( (aSPtr->signExp & 0x7FFF) != 0x7FFF ) return false;
51 uiA0 = aSPtr->signif;
52 return
53 ! (uiA0 & UINT64_C( 0x4000000000000000 ))
54 && (uiA0 & UINT64_C( 0x3FFFFFFFFFFFFFFF));
55
56}
57
deps/SoftFloat-3d/source/8086/f128M_isSignalingNaN.c deleted-60
......@@ -1,60 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "primitives.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44*----------------------------------------------------------------------------*/
45bool f128M_isSignalingNaN( const float128_t *aPtr )
46{
47 const uint32_t *aWPtr;
48 uint32_t uiA96;
49
50 aWPtr = (const uint32_t *) aPtr;
51 uiA96 = aWPtr[indexWordHi( 4 )];
52 if ( (uiA96 & 0x7FFF8000) != 0x7FFF0000 ) return false;
53 return
54 ((uiA96 & 0x00007FFF) != 0)
55 || ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
56 | aWPtr[indexWord( 4, 0 )])
57 != 0);
58
59}
60
deps/SoftFloat-3d/source/8086/s_commonNaNToExtF80M.c deleted-56
......@@ -1,56 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by `aPtr' into an 80-bit extended
44| floating-point NaN, and stores this NaN at the location pointed to by
45| `zSPtr'.
46*----------------------------------------------------------------------------*/
47void
48 softfloat_commonNaNToExtF80M(
49 const struct commonNaN *aPtr, struct extFloat80M *zSPtr )
50{
51
52 zSPtr->signExp = packToExtF80UI64( aPtr->sign, 0x7FFF );
53 zSPtr->signif = UINT64_C( 0xC000000000000000 ) | aPtr->v64>>1;
54
55}
56
deps/SoftFloat-3d/source/8086/s_commonNaNToExtF80UI.c deleted-56
......@@ -1,56 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by `aPtr' into an 80-bit extended
44| floating-point NaN, and returns the bit pattern of this value as an unsigned
45| integer.
46*----------------------------------------------------------------------------*/
47struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr )
48{
49 struct uint128 uiZ;
50
51 uiZ.v64 = (uint_fast16_t) aPtr->sign<<15 | 0x7FFF;
52 uiZ.v0 = UINT64_C( 0xC000000000000000 ) | aPtr->v64>>1;
53 return uiZ;
54
55}
56
deps/SoftFloat-3d/source/8086/s_commonNaNToF128M.c deleted-56
......@@ -1,56 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by `aPtr' into a 128-bit floating-point
44| NaN, and stores this NaN at the location pointed to by `zWPtr'. Argument
45| `zWPtr' points to an array of four 32-bit elements that concatenate in the
46| platform's normal endian order to form a 128-bit floating-point value.
47*----------------------------------------------------------------------------*/
48void
49 softfloat_commonNaNToF128M( const struct commonNaN *aPtr, uint32_t *zWPtr )
50{
51
52 softfloat_shortShiftRight128M( (const uint32_t *) &aPtr->v0, 16, zWPtr );
53 zWPtr[indexWordHi( 4 )] |= (uint32_t) aPtr->sign<<31 | 0x7FFF8000;
54
55}
56
deps/SoftFloat-3d/source/8086/s_commonNaNToF128UI.c deleted-55
......@@ -1,55 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by `aPtr' into a 128-bit floating-point
44| NaN, and returns the bit pattern of this value as an unsigned integer.
45*----------------------------------------------------------------------------*/
46struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN *aPtr )
47{
48 struct uint128 uiZ;
49
50 uiZ = softfloat_shortShiftRight128( aPtr->v64, aPtr->v0, 16 );
51 uiZ.v64 |= (uint_fast64_t) aPtr->sign<<63 | UINT64_C( 0x7FFF800000000000 );
52 return uiZ;
53
54}
55
deps/SoftFloat-3d/source/8086/s_commonNaNToF16UI.c deleted-51
......@@ -1,51 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40
41/*----------------------------------------------------------------------------
42| Converts the common NaN pointed to by `aPtr' into a 16-bit floating-point
43| NaN, and returns the bit pattern of this value as an unsigned integer.
44*----------------------------------------------------------------------------*/
45uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr )
46{
47
48 return (uint_fast16_t) aPtr->sign<<15 | 0x7E00 | aPtr->v64>>54;
49
50}
51
deps/SoftFloat-3d/source/8086/s_commonNaNToF32UI.c deleted-51
......@@ -1,51 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40
41/*----------------------------------------------------------------------------
42| Converts the common NaN pointed to by `aPtr' into a 32-bit floating-point
43| NaN, and returns the bit pattern of this value as an unsigned integer.
44*----------------------------------------------------------------------------*/
45uint_fast32_t softfloat_commonNaNToF32UI( const struct commonNaN *aPtr )
46{
47
48 return (uint_fast32_t) aPtr->sign<<31 | 0x7FC00000 | aPtr->v64>>41;
49
50}
51
deps/SoftFloat-3d/source/8086/s_commonNaNToF64UI.c deleted-53
......@@ -1,53 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40
41/*----------------------------------------------------------------------------
42| Converts the common NaN pointed to by `aPtr' into a 64-bit floating-point
43| NaN, and returns the bit pattern of this value as an unsigned integer.
44*----------------------------------------------------------------------------*/
45uint_fast64_t softfloat_commonNaNToF64UI( const struct commonNaN *aPtr )
46{
47
48 return
49 (uint_fast64_t) aPtr->sign<<63 | UINT64_C( 0x7FF8000000000000 )
50 | aPtr->v64>>12;
51
52}
53
deps/SoftFloat-3d/source/8086/s_extF80MToCommonNaN.c deleted-62
......@@ -1,62 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Assuming the 80-bit extended floating-point value pointed to by `aSPtr' is
45| a NaN, converts this NaN to the common NaN form, and stores the resulting
46| common NaN at the location pointed to by `zPtr'. If the NaN is a signaling
47| NaN, the invalid exception is raised.
48*----------------------------------------------------------------------------*/
49void
50 softfloat_extF80MToCommonNaN(
51 const struct extFloat80M *aSPtr, struct commonNaN *zPtr )
52{
53
54 if ( extF80M_isSignalingNaN( (const extFloat80_t *) aSPtr ) ) {
55 softfloat_raiseFlags( softfloat_flag_invalid );
56 }
57 zPtr->sign = signExtF80UI64( aSPtr->signExp );
58 zPtr->v64 = aSPtr->signif<<1;
59 zPtr->v0 = 0;
60
61}
62
deps/SoftFloat-3d/source/8086/s_extF80UIToCommonNaN.c deleted-62
......@@ -1,62 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming the unsigned integer formed from concatenating `uiA64' and `uiA0'
44| has the bit pattern of an 80-bit extended floating-point NaN, converts
45| this NaN to the common NaN form, and stores the resulting common NaN at the
46| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
47| exception is raised.
48*----------------------------------------------------------------------------*/
49void
50 softfloat_extF80UIToCommonNaN(
51 uint_fast16_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr )
52{
53
54 if ( softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ) {
55 softfloat_raiseFlags( softfloat_flag_invalid );
56 }
57 zPtr->sign = uiA64>>15;
58 zPtr->v64 = uiA0<<1;
59 zPtr->v0 = 0;
60
61}
62
deps/SoftFloat-3d/source/8086/s_f128MToCommonNaN.c deleted-62
......@@ -1,62 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Assuming the 128-bit floating-point value pointed to by `aWPtr' is a NaN,
45| converts this NaN to the common NaN form, and stores the resulting common
46| NaN at the location pointed to by `zPtr'. If the NaN is a signaling NaN,
47| the invalid exception is raised. Argument `aWPtr' points to an array of
48| four 32-bit elements that concatenate in the platform's normal endian order
49| to form a 128-bit floating-point value.
50*----------------------------------------------------------------------------*/
51void
52 softfloat_f128MToCommonNaN( const uint32_t *aWPtr, struct commonNaN *zPtr )
53{
54
55 if ( f128M_isSignalingNaN( (const float128_t *) aWPtr ) ) {
56 softfloat_raiseFlags( softfloat_flag_invalid );
57 }
58 zPtr->sign = aWPtr[indexWordHi( 4 )]>>31;
59 softfloat_shortShiftLeft128M( aWPtr, 16, (uint32_t *) &zPtr->v0 );
60
61}
62
deps/SoftFloat-3d/source/8086/s_f128UIToCommonNaN.c deleted-65
......@@ -1,65 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Assuming the unsigned integer formed from concatenating `uiA64' and `uiA0'
45| has the bit pattern of a 128-bit floating-point NaN, converts this NaN to
46| the common NaN form, and stores the resulting common NaN at the location
47| pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid exception
48| is raised.
49*----------------------------------------------------------------------------*/
50void
51 softfloat_f128UIToCommonNaN(
52 uint_fast64_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr )
53{
54 struct uint128 NaNSig;
55
56 if ( softfloat_isSigNaNF128UI( uiA64, uiA0 ) ) {
57 softfloat_raiseFlags( softfloat_flag_invalid );
58 }
59 NaNSig = softfloat_shortShiftLeft128( uiA64, uiA0, 16 );
60 zPtr->sign = uiA64>>63;
61 zPtr->v64 = NaNSig.v64;
62 zPtr->v0 = NaNSig.v0;
63
64}
65
deps/SoftFloat-3d/source/8086/s_f16UIToCommonNaN.c deleted-59
......@@ -1,59 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming `uiA' has the bit pattern of a 16-bit floating-point NaN, converts
44| this NaN to the common NaN form, and stores the resulting common NaN at the
45| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
46| exception is raised.
47*----------------------------------------------------------------------------*/
48void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr )
49{
50
51 if ( softfloat_isSigNaNF16UI( uiA ) ) {
52 softfloat_raiseFlags( softfloat_flag_invalid );
53 }
54 zPtr->sign = uiA>>15;
55 zPtr->v64 = (uint_fast64_t) uiA<<54;
56 zPtr->v0 = 0;
57
58}
59
deps/SoftFloat-3d/source/8086/s_f32UIToCommonNaN.c deleted-59
......@@ -1,59 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming `uiA' has the bit pattern of a 32-bit floating-point NaN, converts
44| this NaN to the common NaN form, and stores the resulting common NaN at the
45| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
46| exception is raised.
47*----------------------------------------------------------------------------*/
48void softfloat_f32UIToCommonNaN( uint_fast32_t uiA, struct commonNaN *zPtr )
49{
50
51 if ( softfloat_isSigNaNF32UI( uiA ) ) {
52 softfloat_raiseFlags( softfloat_flag_invalid );
53 }
54 zPtr->sign = uiA>>31;
55 zPtr->v64 = (uint_fast64_t) uiA<<41;
56 zPtr->v0 = 0;
57
58}
59
deps/SoftFloat-3d/source/8086/s_f64UIToCommonNaN.c deleted-59
......@@ -1,59 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming `uiA' has the bit pattern of a 64-bit floating-point NaN, converts
44| this NaN to the common NaN form, and stores the resulting common NaN at the
45| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
46| exception is raised.
47*----------------------------------------------------------------------------*/
48void softfloat_f64UIToCommonNaN( uint_fast64_t uiA, struct commonNaN *zPtr )
49{
50
51 if ( softfloat_isSigNaNF64UI( uiA ) ) {
52 softfloat_raiseFlags( softfloat_flag_invalid );
53 }
54 zPtr->sign = uiA>>63;
55 zPtr->v64 = uiA<<12;
56 zPtr->v0 = 0;
57
58}
59
deps/SoftFloat-3d/source/8086/s_propagateNaNExtF80M.c deleted-107
......@@ -1,107 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Assuming at least one of the two 80-bit extended floating-point values
46| pointed to by `aSPtr' and `bSPtr' is a NaN, stores the combined NaN result
47| at the location pointed to by `zSPtr'. If either original floating-point
48| value is a signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50void
51 softfloat_propagateNaNExtF80M(
52 const struct extFloat80M *aSPtr,
53 const struct extFloat80M *bSPtr,
54 struct extFloat80M *zSPtr
55 )
56{
57 bool isSigNaNA;
58 const struct extFloat80M *sPtr;
59 bool isSigNaNB;
60 uint_fast16_t uiB64;
61 uint64_t uiB0;
62 uint_fast16_t uiA64;
63 uint64_t uiA0;
64 uint_fast16_t uiMagA64, uiMagB64;
65
66 isSigNaNA = extF80M_isSignalingNaN( (const extFloat80_t *) aSPtr );
67 sPtr = aSPtr;
68 if ( ! bSPtr ) {
69 if ( isSigNaNA ) softfloat_raiseFlags( softfloat_flag_invalid );
70 goto copy;
71 }
72 isSigNaNB = extF80M_isSignalingNaN( (const extFloat80_t *) bSPtr );
73 if ( isSigNaNA | isSigNaNB ) {
74 softfloat_raiseFlags( softfloat_flag_invalid );
75 if ( isSigNaNA ) {
76 uiB64 = bSPtr->signExp;
77 if ( isSigNaNB ) goto returnLargerUIMag;
78 uiB0 = bSPtr->signif;
79 if ( isNaNExtF80UI( uiB64, uiB0 ) ) goto copyB;
80 goto copy;
81 } else {
82 uiA64 = aSPtr->signExp;
83 uiA0 = aSPtr->signif;
84 if ( isNaNExtF80UI( uiA64, uiA0 ) ) goto copy;
85 goto copyB;
86 }
87 }
88 uiB64 = bSPtr->signExp;
89 returnLargerUIMag:
90 uiA64 = aSPtr->signExp;
91 uiMagA64 = uiA64 & 0x7FFF;
92 uiMagB64 = uiB64 & 0x7FFF;
93 if ( uiMagA64 < uiMagB64 ) goto copyB;
94 if ( uiMagB64 < uiMagA64 ) goto copy;
95 uiA0 = aSPtr->signif;
96 uiB0 = bSPtr->signif;
97 if ( uiA0 < uiB0 ) goto copyB;
98 if ( uiB0 < uiA0 ) goto copy;
99 if ( uiA64 < uiB64 ) goto copy;
100 copyB:
101 sPtr = bSPtr;
102 copy:
103 zSPtr->signExp = sPtr->signExp;
104 zSPtr->signif = sPtr->signif | UINT64_C( 0xC000000000000000 );
105
106}
107
deps/SoftFloat-3d/source/8086/s_propagateNaNExtF80UI.c deleted-106
......@@ -1,106 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting the unsigned integer formed from concatenating `uiA64' and
46| `uiA0' as an 80-bit extended floating-point value, and likewise interpreting
47| the unsigned integer formed from concatenating `uiB64' and `uiB0' as another
48| 80-bit extended floating-point value, and assuming at least on of these
49| floating-point values is a NaN, returns the bit pattern of the combined NaN
50| result. If either original floating-point value is a signaling NaN, the
51| invalid exception is raised.
52*----------------------------------------------------------------------------*/
53struct uint128
54 softfloat_propagateNaNExtF80UI(
55 uint_fast16_t uiA64,
56 uint_fast64_t uiA0,
57 uint_fast16_t uiB64,
58 uint_fast64_t uiB0
59 )
60{
61 bool isSigNaNA, isSigNaNB;
62 uint_fast64_t uiNonsigA0, uiNonsigB0;
63 uint_fast16_t uiMagA64, uiMagB64;
64 struct uint128 uiZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 isSigNaNA = softfloat_isSigNaNExtF80UI( uiA64, uiA0 );
69 isSigNaNB = softfloat_isSigNaNExtF80UI( uiB64, uiB0 );
70 /*------------------------------------------------------------------------
71 | Make NaNs non-signaling.
72 *------------------------------------------------------------------------*/
73 uiNonsigA0 = uiA0 | UINT64_C( 0xC000000000000000 );
74 uiNonsigB0 = uiB0 | UINT64_C( 0xC000000000000000 );
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( isSigNaNA | isSigNaNB ) {
78 softfloat_raiseFlags( softfloat_flag_invalid );
79 if ( isSigNaNA ) {
80 if ( isSigNaNB ) goto returnLargerMag;
81 if ( isNaNExtF80UI( uiB64, uiB0 ) ) goto returnB;
82 goto returnA;
83 } else {
84 if ( isNaNExtF80UI( uiA64, uiA0 ) ) goto returnA;
85 goto returnB;
86 }
87 }
88 returnLargerMag:
89 uiMagA64 = uiA64 & 0x7FFF;
90 uiMagB64 = uiB64 & 0x7FFF;
91 if ( uiMagA64 < uiMagB64 ) goto returnB;
92 if ( uiMagB64 < uiMagA64 ) goto returnA;
93 if ( uiNonsigA0 < uiNonsigB0 ) goto returnB;
94 if ( uiNonsigB0 < uiNonsigA0 ) goto returnA;
95 if ( uiA64 < uiB64 ) goto returnA;
96 returnB:
97 uiZ.v64 = uiB64;
98 uiZ.v0 = uiNonsigB0;
99 return uiZ;
100 returnA:
101 uiZ.v64 = uiA64;
102 uiZ.v0 = uiNonsigA0;
103 return uiZ;
104
105}
106
deps/SoftFloat-3d/source/8086/s_propagateNaNF128M.c deleted-108
......@@ -1,108 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Assuming at least one of the two 128-bit floating-point values pointed to by
46| `aWPtr' and `bWPtr' is a NaN, stores the combined NaN result at the location
47| pointed to by `zWPtr'. If either original floating-point value is a
48| signaling NaN, the invalid exception is raised. Each of `aWPtr', `bWPtr',
49| and `zWPtr' points to an array of four 32-bit elements that concatenate in
50| the platform's normal endian order to form a 128-bit floating-point value.
51*----------------------------------------------------------------------------*/
52void
53 softfloat_propagateNaNF128M(
54 const uint32_t *aWPtr, const uint32_t *bWPtr, uint32_t *zWPtr )
55{
56 bool isSigNaNA;
57 const uint32_t *ptr;
58 bool isSigNaNB;
59 uint32_t uiA96, uiB96, wordMagA, wordMagB;
60
61 isSigNaNA = f128M_isSignalingNaN( (const float128_t *) aWPtr );
62 ptr = aWPtr;
63 if ( ! bWPtr ) {
64 if ( isSigNaNA ) softfloat_raiseFlags( softfloat_flag_invalid );
65 goto copy;
66 }
67 isSigNaNB = f128M_isSignalingNaN( (const float128_t *) bWPtr );
68 if ( isSigNaNA | isSigNaNB ) {
69 softfloat_raiseFlags( softfloat_flag_invalid );
70 if ( isSigNaNA ) {
71 if ( isSigNaNB ) goto returnLargerUIMag;
72 if ( softfloat_isNaNF128M( bWPtr ) ) goto copyB;
73 goto copy;
74 } else {
75 if ( softfloat_isNaNF128M( aWPtr ) ) goto copy;
76 goto copyB;
77 }
78 }
79 returnLargerUIMag:
80 uiA96 = aWPtr[indexWordHi( 4 )];
81 uiB96 = bWPtr[indexWordHi( 4 )];
82 wordMagA = uiA96 & 0x7FFFFFFF;
83 wordMagB = uiB96 & 0x7FFFFFFF;
84 if ( wordMagA < wordMagB ) goto copyB;
85 if ( wordMagB < wordMagA ) goto copy;
86 wordMagA = aWPtr[indexWord( 4, 2 )];
87 wordMagB = bWPtr[indexWord( 4, 2 )];
88 if ( wordMagA < wordMagB ) goto copyB;
89 if ( wordMagB < wordMagA ) goto copy;
90 wordMagA = aWPtr[indexWord( 4, 1 )];
91 wordMagB = bWPtr[indexWord( 4, 1 )];
92 if ( wordMagA < wordMagB ) goto copyB;
93 if ( wordMagB < wordMagA ) goto copy;
94 wordMagA = aWPtr[indexWord( 4, 0 )];
95 wordMagB = bWPtr[indexWord( 4, 0 )];
96 if ( wordMagA < wordMagB ) goto copyB;
97 if ( wordMagB < wordMagA ) goto copy;
98 if ( uiA96 < uiB96 ) goto copy;
99 copyB:
100 ptr = bWPtr;
101 copy:
102 zWPtr[indexWordHi( 4 )] = ptr[indexWordHi( 4 )] | 0x00008000;
103 zWPtr[indexWord( 4, 2 )] = ptr[indexWord( 4, 2 )];
104 zWPtr[indexWord( 4, 1 )] = ptr[indexWord( 4, 1 )];
105 zWPtr[indexWord( 4, 0 )] = ptr[indexWord( 4, 0 )];
106
107}
108
deps/SoftFloat-3d/source/8086/s_propagateNaNF128UI.c deleted-105
......@@ -1,105 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting the unsigned integer formed from concatenating `uiA64' and
46| `uiA0' as a 128-bit floating-point value, and likewise interpreting the
47| unsigned integer formed from concatenating `uiB64' and `uiB0' as another
48| 128-bit floating-point value, and assuming at least on of these floating-
49| point values is a NaN, returns the bit pattern of the combined NaN result.
50| If either original floating-point value is a signaling NaN, the invalid
51| exception is raised.
52*----------------------------------------------------------------------------*/
53struct uint128
54 softfloat_propagateNaNF128UI(
55 uint_fast64_t uiA64,
56 uint_fast64_t uiA0,
57 uint_fast64_t uiB64,
58 uint_fast64_t uiB0
59 )
60{
61 bool isSigNaNA, isSigNaNB;
62 uint_fast64_t uiNonsigA64, uiNonsigB64, uiMagA64, uiMagB64;
63 struct uint128 uiZ;
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 isSigNaNA = softfloat_isSigNaNF128UI( uiA64, uiA0 );
68 isSigNaNB = softfloat_isSigNaNF128UI( uiB64, uiB0 );
69 /*------------------------------------------------------------------------
70 | Make NaNs non-signaling.
71 *------------------------------------------------------------------------*/
72 uiNonsigA64 = uiA64 | UINT64_C( 0x0000800000000000 );
73 uiNonsigB64 = uiB64 | UINT64_C( 0x0000800000000000 );
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( isSigNaNA | isSigNaNB ) {
77 softfloat_raiseFlags( softfloat_flag_invalid );
78 if ( isSigNaNA ) {
79 if ( isSigNaNB ) goto returnLargerMag;
80 if ( isNaNF128UI( uiB64, uiB0 ) ) goto returnB;
81 goto returnA;
82 } else {
83 if ( isNaNF128UI( uiA64, uiA0 ) ) goto returnA;
84 goto returnB;
85 }
86 }
87 returnLargerMag:
88 uiMagA64 = uiNonsigA64 & UINT64_C( 0x7FFFFFFFFFFFFFFF );
89 uiMagB64 = uiNonsigB64 & UINT64_C( 0x7FFFFFFFFFFFFFFF );
90 if ( uiMagA64 < uiMagB64 ) goto returnB;
91 if ( uiMagB64 < uiMagA64 ) goto returnA;
92 if ( uiA0 < uiB0 ) goto returnB;
93 if ( uiB0 < uiA0 ) goto returnA;
94 if ( uiNonsigA64 < uiNonsigB64 ) goto returnA;
95 returnB:
96 uiZ.v64 = uiNonsigB64;
97 uiZ.v0 = uiB0;
98 return uiZ;
99 returnA:
100 uiZ.v64 = uiNonsigA64;
101 uiZ.v0 = uiA0;
102 return uiZ;
103
104}
105
deps/SoftFloat-3d/source/8086/s_propagateNaNF16UI.c deleted-84
......@@ -1,84 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting `uiA' and `uiB' as the bit patterns of two 16-bit floating-
46| point values, at least one of which is a NaN, returns the bit pattern of
47| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
48| signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50uint_fast16_t
51 softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB )
52{
53 bool isSigNaNA, isSigNaNB;
54 uint_fast16_t uiNonsigA, uiNonsigB, uiMagA, uiMagB;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 isSigNaNA = softfloat_isSigNaNF16UI( uiA );
59 isSigNaNB = softfloat_isSigNaNF16UI( uiB );
60 /*------------------------------------------------------------------------
61 | Make NaNs non-signaling.
62 *------------------------------------------------------------------------*/
63 uiNonsigA = uiA | 0x0200;
64 uiNonsigB = uiB | 0x0200;
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( isSigNaNA | isSigNaNB ) {
68 softfloat_raiseFlags( softfloat_flag_invalid );
69 if ( isSigNaNA ) {
70 if ( isSigNaNB ) goto returnLargerMag;
71 return isNaNF16UI( uiB ) ? uiNonsigB : uiNonsigA;
72 } else {
73 return isNaNF16UI( uiA ) ? uiNonsigA : uiNonsigB;
74 }
75 }
76 returnLargerMag:
77 uiMagA = uiNonsigA & 0x7FFF;
78 uiMagB = uiNonsigB & 0x7FFF;
79 if ( uiMagA < uiMagB ) return uiNonsigB;
80 if ( uiMagB < uiMagA ) return uiNonsigA;
81 return (uiNonsigA < uiNonsigB) ? uiNonsigA : uiNonsigB;
82
83}
84
deps/SoftFloat-3d/source/8086/s_propagateNaNF32UI.c deleted-84
......@@ -1,84 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting `uiA' and `uiB' as the bit patterns of two 32-bit floating-
46| point values, at least one of which is a NaN, returns the bit pattern of
47| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
48| signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50uint_fast32_t
51 softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB )
52{
53 bool isSigNaNA, isSigNaNB;
54 uint_fast32_t uiNonsigA, uiNonsigB, uiMagA, uiMagB;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 isSigNaNA = softfloat_isSigNaNF32UI( uiA );
59 isSigNaNB = softfloat_isSigNaNF32UI( uiB );
60 /*------------------------------------------------------------------------
61 | Make NaNs non-signaling.
62 *------------------------------------------------------------------------*/
63 uiNonsigA = uiA | 0x00400000;
64 uiNonsigB = uiB | 0x00400000;
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( isSigNaNA | isSigNaNB ) {
68 softfloat_raiseFlags( softfloat_flag_invalid );
69 if ( isSigNaNA ) {
70 if ( isSigNaNB ) goto returnLargerMag;
71 return isNaNF32UI( uiB ) ? uiNonsigB : uiNonsigA;
72 } else {
73 return isNaNF32UI( uiA ) ? uiNonsigA : uiNonsigB;
74 }
75 }
76 returnLargerMag:
77 uiMagA = uiNonsigA & 0x7FFFFFFF;
78 uiMagB = uiNonsigB & 0x7FFFFFFF;
79 if ( uiMagA < uiMagB ) return uiNonsigB;
80 if ( uiMagB < uiMagA ) return uiNonsigA;
81 return (uiNonsigA < uiNonsigB) ? uiNonsigA : uiNonsigB;
82
83}
84
deps/SoftFloat-3d/source/8086/s_propagateNaNF64UI.c deleted-84
......@@ -1,84 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting `uiA' and `uiB' as the bit patterns of two 64-bit floating-
46| point values, at least one of which is a NaN, returns the bit pattern of
47| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
48| signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50uint_fast64_t
51 softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB )
52{
53 bool isSigNaNA, isSigNaNB;
54 uint_fast64_t uiNonsigA, uiNonsigB, uiMagA, uiMagB;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 isSigNaNA = softfloat_isSigNaNF64UI( uiA );
59 isSigNaNB = softfloat_isSigNaNF64UI( uiB );
60 /*------------------------------------------------------------------------
61 | Make NaNs non-signaling.
62 *------------------------------------------------------------------------*/
63 uiNonsigA = uiA | UINT64_C( 0x0008000000000000 );
64 uiNonsigB = uiB | UINT64_C( 0x0008000000000000 );
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( isSigNaNA | isSigNaNB ) {
68 softfloat_raiseFlags( softfloat_flag_invalid );
69 if ( isSigNaNA ) {
70 if ( isSigNaNB ) goto returnLargerMag;
71 return isNaNF64UI( uiB ) ? uiNonsigB : uiNonsigA;
72 } else {
73 return isNaNF64UI( uiA ) ? uiNonsigA : uiNonsigB;
74 }
75 }
76 returnLargerMag:
77 uiMagA = uiNonsigA & UINT64_C( 0x7FFFFFFFFFFFFFFF );
78 uiMagB = uiNonsigB & UINT64_C( 0x7FFFFFFFFFFFFFFF );
79 if ( uiMagA < uiMagB ) return uiNonsigB;
80 if ( uiMagB < uiMagA ) return uiNonsigA;
81 return (uiNonsigA < uiNonsigB) ? uiNonsigA : uiNonsigB;
82
83}
84
deps/SoftFloat-3d/source/8086/softfloat_raiseFlags.c deleted-52
......@@ -1,52 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include "platform.h"
38#include "softfloat.h"
39
40/*----------------------------------------------------------------------------
41| Raises the exceptions specified by `flags'. Floating-point traps can be
42| defined here if desired. It is currently not possible for such a trap
43| to substitute a result value. If traps are not implemented, this routine
44| should be simply `softfloat_exceptionFlags |= flags;'.
45*----------------------------------------------------------------------------*/
46void softfloat_raiseFlags( uint_fast8_t flags )
47{
48
49 softfloat_exceptionFlags |= flags;
50
51}
52
deps/SoftFloat-3d/source/8086/specialize.h deleted-375
......@@ -1,375 +0,0 @@
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#ifndef specialize_h
38#define specialize_h 1
39
40#include <stdbool.h>
41#include <stdint.h>
42#include "softfloat_types.h"
43
44/*----------------------------------------------------------------------------
45| Default value for `softfloat_detectTininess'.
46*----------------------------------------------------------------------------*/
47#define init_detectTininess softfloat_tininess_afterRounding
48
49/*----------------------------------------------------------------------------
50| The values to return on conversions to 32-bit integer formats that raise an
51| invalid exception.
52*----------------------------------------------------------------------------*/
53#define ui32_fromPosOverflow 0xFFFFFFFF
54#define ui32_fromNegOverflow 0
55#define ui32_fromNaN 0xFFFFFFFF
56#define i32_fromPosOverflow 0x7FFFFFFF
57#define i32_fromNegOverflow (-0x7FFFFFFF - 1)
58#define i32_fromNaN 0x7FFFFFFF
59
60/*----------------------------------------------------------------------------
61| The values to return on conversions to 64-bit integer formats that raise an
62| invalid exception.
63*----------------------------------------------------------------------------*/
64#define ui64_fromPosOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
65#define ui64_fromNegOverflow 0
66#define ui64_fromNaN UINT64_C( 0xFFFFFFFFFFFFFFFF )
67#define i64_fromPosOverflow UINT64_C( 0x7FFFFFFFFFFFFFFF )
68#define i64_fromNegOverflow (-UINT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
69#define i64_fromNaN UINT64_C( 0x7FFFFFFFFFFFFFFF )
70
71/*----------------------------------------------------------------------------
72| "Common NaN" structure, used to transfer NaN representations from one format
73| to another.
74*----------------------------------------------------------------------------*/
75struct commonNaN {
76 bool sign;
77#ifdef LITTLEENDIAN
78 uint64_t v0, v64;
79#else
80 uint64_t v64, v0;
81#endif
82};
83
84/*----------------------------------------------------------------------------
85| The bit pattern for a default generated 16-bit floating-point NaN.
86*----------------------------------------------------------------------------*/
87#define defaultNaNF16UI 0xFE00
88
89/*----------------------------------------------------------------------------
90| Returns true when 16-bit unsigned integer `uiA' has the bit pattern of a
91| 16-bit floating-point signaling NaN.
92| Note: This macro evaluates its argument more than once.
93*----------------------------------------------------------------------------*/
94#define softfloat_isSigNaNF16UI( uiA ) ((((uiA) & 0x7E00) == 0x7C00) && ((uiA) & 0x01FF))
95
96/*----------------------------------------------------------------------------
97| Assuming `uiA' has the bit pattern of a 16-bit floating-point NaN, converts
98| this NaN to the common NaN form, and stores the resulting common NaN at the
99| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
100| exception is raised.
101*----------------------------------------------------------------------------*/
102void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr );
103
104/*----------------------------------------------------------------------------
105| Converts the common NaN pointed to by `aPtr' into a 16-bit floating-point
106| NaN, and returns the bit pattern of this value as an unsigned integer.
107*----------------------------------------------------------------------------*/
108uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr );
109
110/*----------------------------------------------------------------------------
111| Interpreting `uiA' and `uiB' as the bit patterns of two 16-bit floating-
112| point values, at least one of which is a NaN, returns the bit pattern of
113| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
114| signaling NaN, the invalid exception is raised.
115*----------------------------------------------------------------------------*/
116uint_fast16_t
117 softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB );
118
119/*----------------------------------------------------------------------------
120| The bit pattern for a default generated 32-bit floating-point NaN.
121*----------------------------------------------------------------------------*/
122#define defaultNaNF32UI 0xFFC00000
123
124/*----------------------------------------------------------------------------
125| Returns true when 32-bit unsigned integer `uiA' has the bit pattern of a
126| 32-bit floating-point signaling NaN.
127| Note: This macro evaluates its argument more than once.
128*----------------------------------------------------------------------------*/
129#define softfloat_isSigNaNF32UI( uiA ) ((((uiA) & 0x7FC00000) == 0x7F800000) && ((uiA) & 0x003FFFFF))
130
131/*----------------------------------------------------------------------------
132| Assuming `uiA' has the bit pattern of a 32-bit floating-point NaN, converts
133| this NaN to the common NaN form, and stores the resulting common NaN at the
134| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
135| exception is raised.
136*----------------------------------------------------------------------------*/
137void softfloat_f32UIToCommonNaN( uint_fast32_t uiA, struct commonNaN *zPtr );
138
139/*----------------------------------------------------------------------------
140| Converts the common NaN pointed to by `aPtr' into a 32-bit floating-point
141| NaN, and returns the bit pattern of this value as an unsigned integer.
142*----------------------------------------------------------------------------*/
143uint_fast32_t softfloat_commonNaNToF32UI( const struct commonNaN *aPtr );
144
145/*----------------------------------------------------------------------------
146| Interpreting `uiA' and `uiB' as the bit patterns of two 32-bit floating-
147| point values, at least one of which is a NaN, returns the bit pattern of
148| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
149| signaling NaN, the invalid exception is raised.
150*----------------------------------------------------------------------------*/
151uint_fast32_t
152 softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB );
153
154/*----------------------------------------------------------------------------
155| The bit pattern for a default generated 64-bit floating-point NaN.
156*----------------------------------------------------------------------------*/
157#define defaultNaNF64UI UINT64_C( 0xFFF8000000000000 )
158
159/*----------------------------------------------------------------------------
160| Returns true when 64-bit unsigned integer `uiA' has the bit pattern of a
161| 64-bit floating-point signaling NaN.
162| Note: This macro evaluates its argument more than once.
163*----------------------------------------------------------------------------*/
164#define softfloat_isSigNaNF64UI( uiA ) ((((uiA) & UINT64_C( 0x7FF8000000000000 )) == UINT64_C( 0x7FF0000000000000 )) && ((uiA) & UINT64_C( 0x0007FFFFFFFFFFFF )))
165
166/*----------------------------------------------------------------------------
167| Assuming `uiA' has the bit pattern of a 64-bit floating-point NaN, converts
168| this NaN to the common NaN form, and stores the resulting common NaN at the
169| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
170| exception is raised.
171*----------------------------------------------------------------------------*/
172void softfloat_f64UIToCommonNaN( uint_fast64_t uiA, struct commonNaN *zPtr );
173
174/*----------------------------------------------------------------------------
175| Converts the common NaN pointed to by `aPtr' into a 64-bit floating-point
176| NaN, and returns the bit pattern of this value as an unsigned integer.
177*----------------------------------------------------------------------------*/
178uint_fast64_t softfloat_commonNaNToF64UI( const struct commonNaN *aPtr );
179
180/*----------------------------------------------------------------------------
181| Interpreting `uiA' and `uiB' as the bit patterns of two 64-bit floating-
182| point values, at least one of which is a NaN, returns the bit pattern of
183| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
184| signaling NaN, the invalid exception is raised.
185*----------------------------------------------------------------------------*/
186uint_fast64_t
187 softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB );
188
189/*----------------------------------------------------------------------------
190| The bit pattern for a default generated 80-bit extended floating-point NaN.
191*----------------------------------------------------------------------------*/
192#define defaultNaNExtF80UI64 0xFFFF
193#define defaultNaNExtF80UI0 UINT64_C( 0xC000000000000000 )
194
195/*----------------------------------------------------------------------------
196| Returns true when the 80-bit unsigned integer formed from concatenating
197| 16-bit `uiA64' and 64-bit `uiA0' has the bit pattern of an 80-bit extended
198| floating-point signaling NaN.
199| Note: This macro evaluates its arguments more than once.
200*----------------------------------------------------------------------------*/
201#define softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ((((uiA64) & 0x7FFF) == 0x7FFF) && ! ((uiA0) & UINT64_C( 0x4000000000000000 )) && ((uiA0) & UINT64_C( 0x3FFFFFFFFFFFFFFF )))
202
203#ifdef SOFTFLOAT_FAST_INT64
204
205/*----------------------------------------------------------------------------
206| The following functions are needed only when `SOFTFLOAT_FAST_INT64' is
207| defined.
208*----------------------------------------------------------------------------*/
209
210/*----------------------------------------------------------------------------
211| Assuming the unsigned integer formed from concatenating `uiA64' and `uiA0'
212| has the bit pattern of an 80-bit extended floating-point NaN, converts
213| this NaN to the common NaN form, and stores the resulting common NaN at the
214| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
215| exception is raised.
216*----------------------------------------------------------------------------*/
217void
218 softfloat_extF80UIToCommonNaN(
219 uint_fast16_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr );
220
221/*----------------------------------------------------------------------------
222| Converts the common NaN pointed to by `aPtr' into an 80-bit extended
223| floating-point NaN, and returns the bit pattern of this value as an unsigned
224| integer.
225*----------------------------------------------------------------------------*/
226struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr );
227
228/*----------------------------------------------------------------------------
229| Interpreting the unsigned integer formed from concatenating `uiA64' and
230| `uiA0' as an 80-bit extended floating-point value, and likewise interpreting
231| the unsigned integer formed from concatenating `uiB64' and `uiB0' as another
232| 80-bit extended floating-point value, and assuming at least on of these
233| floating-point values is a NaN, returns the bit pattern of the combined NaN
234| result. If either original floating-point value is a signaling NaN, the
235| invalid exception is raised.
236*----------------------------------------------------------------------------*/
237struct uint128
238 softfloat_propagateNaNExtF80UI(
239 uint_fast16_t uiA64,
240 uint_fast64_t uiA0,
241 uint_fast16_t uiB64,
242 uint_fast64_t uiB0
243 );
244
245/*----------------------------------------------------------------------------
246| The bit pattern for a default generated 128-bit floating-point NaN.
247*----------------------------------------------------------------------------*/
248#define defaultNaNF128UI64 UINT64_C( 0xFFFF800000000000 )
249#define defaultNaNF128UI0 UINT64_C( 0 )
250
251/*----------------------------------------------------------------------------
252| Returns true when the 128-bit unsigned integer formed from concatenating
253| 64-bit `uiA64' and 64-bit `uiA0' has the bit pattern of a 128-bit floating-
254| point signaling NaN.
255| Note: This macro evaluates its arguments more than once.
256*----------------------------------------------------------------------------*/
257#define softfloat_isSigNaNF128UI( uiA64, uiA0 ) ((((uiA64) & UINT64_C( 0x7FFF800000000000 )) == UINT64_C( 0x7FFF000000000000 )) && ((uiA0) || ((uiA64) & UINT64_C( 0x00007FFFFFFFFFFF ))))
258
259/*----------------------------------------------------------------------------
260| Assuming the unsigned integer formed from concatenating `uiA64' and `uiA0'
261| has the bit pattern of a 128-bit floating-point NaN, converts this NaN to
262| the common NaN form, and stores the resulting common NaN at the location
263| pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid exception
264| is raised.
265*----------------------------------------------------------------------------*/
266void
267 softfloat_f128UIToCommonNaN(
268 uint_fast64_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr );
269
270/*----------------------------------------------------------------------------
271| Converts the common NaN pointed to by `aPtr' into a 128-bit floating-point
272| NaN, and returns the bit pattern of this value as an unsigned integer.
273*----------------------------------------------------------------------------*/
274struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN * );
275
276/*----------------------------------------------------------------------------
277| Interpreting the unsigned integer formed from concatenating `uiA64' and
278| `uiA0' as a 128-bit floating-point value, and likewise interpreting the
279| unsigned integer formed from concatenating `uiB64' and `uiB0' as another
280| 128-bit floating-point value, and assuming at least on of these floating-
281| point values is a NaN, returns the bit pattern of the combined NaN result.
282| If either original floating-point value is a signaling NaN, the invalid
283| exception is raised.
284*----------------------------------------------------------------------------*/
285struct uint128
286 softfloat_propagateNaNF128UI(
287 uint_fast64_t uiA64,
288 uint_fast64_t uiA0,
289 uint_fast64_t uiB64,
290 uint_fast64_t uiB0
291 );
292
293#else
294
295/*----------------------------------------------------------------------------
296| The following functions are needed only when `SOFTFLOAT_FAST_INT64' is not
297| defined.
298*----------------------------------------------------------------------------*/
299
300/*----------------------------------------------------------------------------
301| Assuming the 80-bit extended floating-point value pointed to by `aSPtr' is
302| a NaN, converts this NaN to the common NaN form, and stores the resulting
303| common NaN at the location pointed to by `zPtr'. If the NaN is a signaling
304| NaN, the invalid exception is raised.
305*----------------------------------------------------------------------------*/
306void
307 softfloat_extF80MToCommonNaN(
308 const struct extFloat80M *aSPtr, struct commonNaN *zPtr );
309
310/*----------------------------------------------------------------------------
311| Converts the common NaN pointed to by `aPtr' into an 80-bit extended
312| floating-point NaN, and stores this NaN at the location pointed to by
313| `zSPtr'.
314*----------------------------------------------------------------------------*/
315void
316 softfloat_commonNaNToExtF80M(
317 const struct commonNaN *aPtr, struct extFloat80M *zSPtr );
318
319/*----------------------------------------------------------------------------
320| Assuming at least one of the two 80-bit extended floating-point values
321| pointed to by `aSPtr' and `bSPtr' is a NaN, stores the combined NaN result
322| at the location pointed to by `zSPtr'. If either original floating-point
323| value is a signaling NaN, the invalid exception is raised.
324*----------------------------------------------------------------------------*/
325void
326 softfloat_propagateNaNExtF80M(
327 const struct extFloat80M *aSPtr,
328 const struct extFloat80M *bSPtr,
329 struct extFloat80M *zSPtr
330 );
331
332/*----------------------------------------------------------------------------
333| The bit pattern for a default generated 128-bit floating-point NaN.
334*----------------------------------------------------------------------------*/
335#define defaultNaNF128UI96 0xFFFF8000
336#define defaultNaNF128UI64 0
337#define defaultNaNF128UI32 0
338#define defaultNaNF128UI0 0
339
340/*----------------------------------------------------------------------------
341| Assuming the 128-bit floating-point value pointed to by `aWPtr' is a NaN,
342| converts this NaN to the common NaN form, and stores the resulting common
343| NaN at the location pointed to by `zPtr'. If the NaN is a signaling NaN,
344| the invalid exception is raised. Argument `aWPtr' points to an array of
345| four 32-bit elements that concatenate in the platform's normal endian order
346| to form a 128-bit floating-point value.
347*----------------------------------------------------------------------------*/
348void
349 softfloat_f128MToCommonNaN( const uint32_t *aWPtr, struct commonNaN *zPtr );
350
351/*----------------------------------------------------------------------------
352| Converts the common NaN pointed to by `aPtr' into a 128-bit floating-point
353| NaN, and stores this NaN at the location pointed to by `zWPtr'. Argument
354| `zWPtr' points to an array of four 32-bit elements that concatenate in the
355| platform's normal endian order to form a 128-bit floating-point value.
356*----------------------------------------------------------------------------*/
357void
358 softfloat_commonNaNToF128M( const struct commonNaN *aPtr, uint32_t *zWPtr );
359
360/*----------------------------------------------------------------------------
361| Assuming at least one of the two 128-bit floating-point values pointed to by
362| `aWPtr' and `bWPtr' is a NaN, stores the combined NaN result at the location
363| pointed to by `zWPtr'. If either original floating-point value is a
364| signaling NaN, the invalid exception is raised. Each of `aWPtr', `bWPtr',
365| and `zWPtr' points to an array of four 32-bit elements that concatenate in
366| the platform's normal endian order to form a 128-bit floating-point value.
367*----------------------------------------------------------------------------*/
368void
369 softfloat_propagateNaNF128M(
370 const uint32_t *aWPtr, const uint32_t *bWPtr, uint32_t *zWPtr );
371
372#endif
373
374#endif
375
deps/SoftFloat-3d/source/extF80M_add.c deleted-100
......@@ -1,100 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void
45 extF80M_add(
46 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
47{
48 const struct extFloat80M *aSPtr, *bSPtr;
49 uint_fast16_t uiA64;
50 uint_fast64_t uiA0;
51 bool signA;
52 uint_fast16_t uiB64;
53 uint_fast64_t uiB0;
54 bool signB;
55#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
56 extFloat80_t
57 (*magsFuncPtr)(
58 uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
59#endif
60
61 aSPtr = (const struct extFloat80M *) aPtr;
62 bSPtr = (const struct extFloat80M *) bPtr;
63 uiA64 = aSPtr->signExp;
64 uiA0 = aSPtr->signif;
65 signA = signExtF80UI64( uiA64 );
66 uiB64 = bSPtr->signExp;
67 uiB0 = bSPtr->signif;
68 signB = signExtF80UI64( uiB64 );
69#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
70 if ( signA == signB ) {
71 *zPtr = softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
72 } else {
73 *zPtr = softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
74 }
75#else
76 magsFuncPtr =
77 (signA == signB) ? softfloat_addMagsExtF80 : softfloat_subMagsExtF80;
78 *zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
79#endif
80
81}
82
83#else
84
85void
86 extF80M_add(
87 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
88{
89
90 softfloat_addExtF80M(
91 (const struct extFloat80M *) aPtr,
92 (const struct extFloat80M *) bPtr,
93 (struct extFloat80M *) zPtr,
94 false
95 );
96
97}
98
99#endif
100
deps/SoftFloat-3d/source/extF80M_div.c deleted-194
......@@ -1,194 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void
47 extF80M_div(
48 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
49{
50
51 *zPtr = extF80_div( *aPtr, *bPtr );
52
53}
54
55#else
56
57void
58 extF80M_div(
59 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
60{
61 const struct extFloat80M *aSPtr, *bSPtr;
62 struct extFloat80M *zSPtr;
63 uint_fast16_t uiA64;
64 int32_t expA;
65 uint_fast16_t uiB64;
66 int32_t expB;
67 bool signZ;
68 uint64_t sigA, x64;
69 int32_t expZ;
70 int shiftDist;
71 uint32_t y[3], recip32, sigB[3];
72 int ix;
73 uint32_t q, qs[2];
74 uint_fast16_t uiZ64;
75 uint64_t uiZ0;
76
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 aSPtr = (const struct extFloat80M *) aPtr;
80 bSPtr = (const struct extFloat80M *) bPtr;
81 zSPtr = (struct extFloat80M *) zPtr;
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 uiA64 = aSPtr->signExp;
85 expA = expExtF80UI64( uiA64 );
86 uiB64 = bSPtr->signExp;
87 expB = expExtF80UI64( uiB64 );
88 signZ = signExtF80UI64( uiA64 ) ^ signExtF80UI64( uiB64 );
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
92 if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
93 if ( expA == 0x7FFF ) {
94 if ( expB == 0x7FFF ) goto invalid;
95 goto infinity;
96 }
97 goto zero;
98 }
99 /*------------------------------------------------------------------------
100 *------------------------------------------------------------------------*/
101 sigA = aSPtr->signif;
102 x64 = bSPtr->signif;
103 if ( ! expB ) expB = 1;
104 if ( ! (x64 & UINT64_C( 0x8000000000000000 )) ) {
105 if ( ! x64 ) {
106 if ( ! sigA ) goto invalid;
107 softfloat_raiseFlags( softfloat_flag_infinite );
108 goto infinity;
109 }
110 expB += softfloat_normExtF80SigM( &x64 );
111 }
112 if ( ! expA ) expA = 1;
113 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
114 if ( ! sigA ) goto zero;
115 expA += softfloat_normExtF80SigM( &sigA );
116 }
117 /*------------------------------------------------------------------------
118 *------------------------------------------------------------------------*/
119 expZ = expA - expB + 0x3FFF;
120 shiftDist = 29;
121 if ( sigA < x64 ) {
122 --expZ;
123 shiftDist = 30;
124 }
125 softfloat_shortShiftLeft64To96M( sigA, shiftDist, y );
126 recip32 = softfloat_approxRecip32_1( x64>>32 );
127 sigB[indexWord( 3, 0 )] = (uint32_t) x64<<30;
128 x64 >>= 2;
129 sigB[indexWord( 3, 2 )] = x64>>32;
130 sigB[indexWord( 3, 1 )] = x64;
131 ix = 2;
132 for (;;) {
133 x64 = (uint64_t) y[indexWordHi( 3 )] * recip32;
134 q = (x64 + 0x80000000)>>32;
135 --ix;
136 if ( ix < 0 ) break;
137 softfloat_remStep96MBy32( y, 29, sigB, q, y );
138 if ( y[indexWordHi( 3 )] & 0x80000000 ) {
139 --q;
140 softfloat_add96M( y, sigB, y );
141 }
142 qs[ix] = q;
143 }
144 /*------------------------------------------------------------------------
145 *------------------------------------------------------------------------*/
146 if ( ((q + 1) & 0x3FFFFF) < 2 ) {
147 softfloat_remStep96MBy32( y, 29, sigB, q, y );
148 if ( y[indexWordHi( 3 )] & 0x80000000 ) {
149 --q;
150 softfloat_add96M( y, sigB, y );
151 } else if ( softfloat_compare96M( sigB, y ) <= 0 ) {
152 ++q;
153 softfloat_sub96M( y, sigB, y );
154 }
155 if (
156 y[indexWordLo( 3 )] || y[indexWord( 3, 1 )] || y[indexWord( 3, 2 )]
157 ) {
158 q |= 1;
159 }
160 }
161 /*------------------------------------------------------------------------
162 *------------------------------------------------------------------------*/
163 x64 = (uint64_t) q<<9;
164 y[indexWord( 3, 0 )] = x64;
165 x64 = ((uint64_t) qs[0]<<6) + (x64>>32);
166 y[indexWord( 3, 1 )] = x64;
167 y[indexWord( 3, 2 )] = (qs[1]<<3) + (x64>>32);
168 softfloat_roundPackMToExtF80M(
169 signZ, expZ, y, extF80_roundingPrecision, zSPtr );
170 return;
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 invalid:
174 softfloat_invalidExtF80M( zSPtr );
175 return;
176 /*------------------------------------------------------------------------
177 *------------------------------------------------------------------------*/
178 infinity:
179 uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
180 uiZ0 = UINT64_C( 0x8000000000000000 );
181 goto uiZ;
182 /*------------------------------------------------------------------------
183 *------------------------------------------------------------------------*/
184 zero:
185 uiZ64 = packToExtF80UI64( signZ, 0 );
186 uiZ0 = 0;
187 uiZ:
188 zSPtr->signExp = uiZ64;
189 zSPtr->signif = uiZ0;
190
191}
192
193#endif
194
deps/SoftFloat-3d/source/extF80M_eq.c deleted-98
......@@ -1,98 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46bool extF80M_eq( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
47{
48
49 return extF80_eq( *aPtr, *bPtr );
50
51}
52
53#else
54
55bool extF80M_eq( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
56{
57 const struct extFloat80M *aSPtr, *bSPtr;
58 uint_fast16_t uiA64;
59 uint64_t uiA0;
60 uint_fast16_t uiB64;
61 uint64_t uiB0;
62
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 aSPtr = (const struct extFloat80M *) aPtr;
66 bSPtr = (const struct extFloat80M *) bPtr;
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 uiA64 = aSPtr->signExp;
70 uiA0 = aSPtr->signif;
71 uiB64 = bSPtr->signExp;
72 uiB0 = bSPtr->signif;
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
76 if (
77 softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
78 || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
79 ) {
80 softfloat_raiseFlags( softfloat_flag_invalid );
81 }
82 return false;
83 }
84 /*------------------------------------------------------------------------
85 *------------------------------------------------------------------------*/
86 if ( uiA0 == uiB0 ) {
87 return (uiA64 == uiB64) || ! uiA0;
88 } else {
89 if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
90 return ! softfloat_compareNonnormExtF80M( aSPtr, bSPtr );
91 }
92 return false;
93 }
94
95}
96
97#endif
98
deps/SoftFloat-3d/source/extF80M_eq_signaling.c deleted-92
......@@ -1,92 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43#ifdef SOFTFLOAT_FAST_INT64
44
45bool extF80M_eq_signaling( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
46{
47
48 return extF80_eq_signaling( *aPtr, *bPtr );
49
50}
51
52#else
53
54bool extF80M_eq_signaling( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
55{
56 const struct extFloat80M *aSPtr, *bSPtr;
57 uint_fast16_t uiA64;
58 uint64_t uiA0;
59 uint_fast16_t uiB64;
60 uint64_t uiB0;
61
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 aSPtr = (const struct extFloat80M *) aPtr;
65 bSPtr = (const struct extFloat80M *) bPtr;
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 uiA64 = aSPtr->signExp;
69 uiA0 = aSPtr->signif;
70 uiB64 = bSPtr->signExp;
71 uiB0 = bSPtr->signif;
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
75 softfloat_raiseFlags( softfloat_flag_invalid );
76 return false;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 if ( uiA0 == uiB0 ) {
81 return (uiA64 == uiB64) || ! uiA0;
82 } else {
83 if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
84 return ! softfloat_compareNonnormExtF80M( aSPtr, bSPtr );
85 }
86 return false;
87 }
88
89}
90
91#endif
92
deps/SoftFloat-3d/source/extF80M_le.c deleted-106
......@@ -1,106 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43#ifdef SOFTFLOAT_FAST_INT64
44
45bool extF80M_le( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
46{
47
48 return extF80_le( *aPtr, *bPtr );
49
50}
51
52#else
53
54bool extF80M_le( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
55{
56 const struct extFloat80M *aSPtr, *bSPtr;
57 uint_fast16_t uiA64;
58 uint64_t uiA0;
59 uint_fast16_t uiB64;
60 uint64_t uiB0;
61 bool signA, ltMags;
62
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 aSPtr = (const struct extFloat80M *) aPtr;
66 bSPtr = (const struct extFloat80M *) bPtr;
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 uiA64 = aSPtr->signExp;
70 uiA0 = aSPtr->signif;
71 uiB64 = bSPtr->signExp;
72 uiB0 = bSPtr->signif;
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
76 softfloat_raiseFlags( softfloat_flag_invalid );
77 return false;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 signA = signExtF80UI64( uiA64 );
82 if ( (uiA64 ^ uiB64) & 0x8000 ) {
83 /*--------------------------------------------------------------------
84 | Signs are different.
85 *--------------------------------------------------------------------*/
86 return signA || ! (uiA0 | uiB0);
87 } else {
88 /*--------------------------------------------------------------------
89 | Signs are the same.
90 *--------------------------------------------------------------------*/
91 if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
92 return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) <= 0);
93 }
94 if ( uiA64 == uiB64 ) {
95 if ( uiA0 == uiB0 ) return true;
96 ltMags = (uiA0 < uiB0);
97 } else {
98 ltMags = (uiA64 < uiB64);
99 }
100 return signA ^ ltMags;
101 }
102
103}
104
105#endif
106
deps/SoftFloat-3d/source/extF80M_le_quiet.c deleted-112
......@@ -1,112 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46bool extF80M_le_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
47{
48
49 return extF80_le_quiet( *aPtr, *bPtr );
50
51}
52
53#else
54
55bool extF80M_le_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
56{
57 const struct extFloat80M *aSPtr, *bSPtr;
58 uint_fast16_t uiA64;
59 uint64_t uiA0;
60 uint_fast16_t uiB64;
61 uint64_t uiB0;
62 bool signA, ltMags;
63
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 aSPtr = (const struct extFloat80M *) aPtr;
67 bSPtr = (const struct extFloat80M *) bPtr;
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 uiA64 = aSPtr->signExp;
71 uiA0 = aSPtr->signif;
72 uiB64 = bSPtr->signExp;
73 uiB0 = bSPtr->signif;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
77 if (
78 softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
79 || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
80 ) {
81 softfloat_raiseFlags( softfloat_flag_invalid );
82 }
83 return false;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 signA = signExtF80UI64( uiA64 );
88 if ( (uiA64 ^ uiB64) & 0x8000 ) {
89 /*--------------------------------------------------------------------
90 | Signs are different.
91 *--------------------------------------------------------------------*/
92 return signA || ! (uiA0 | uiB0);
93 } else {
94 /*--------------------------------------------------------------------
95 | Signs are the same.
96 *--------------------------------------------------------------------*/
97 if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
98 return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) <= 0);
99 }
100 if ( uiA64 == uiB64 ) {
101 if ( uiA0 == uiB0 ) return true;
102 ltMags = (uiA0 < uiB0);
103 } else {
104 ltMags = (uiA64 < uiB64);
105 }
106 return signA ^ ltMags;
107 }
108
109}
110
111#endif
112
deps/SoftFloat-3d/source/extF80M_lt.c deleted-106
......@@ -1,106 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43#ifdef SOFTFLOAT_FAST_INT64
44
45bool extF80M_lt( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
46{
47
48 return extF80_lt( *aPtr, *bPtr );
49
50}
51
52#else
53
54bool extF80M_lt( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
55{
56 const struct extFloat80M *aSPtr, *bSPtr;
57 uint_fast16_t uiA64;
58 uint64_t uiA0;
59 uint_fast16_t uiB64;
60 uint64_t uiB0;
61 bool signA, ltMags;
62
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 aSPtr = (const struct extFloat80M *) aPtr;
66 bSPtr = (const struct extFloat80M *) bPtr;
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 uiA64 = aSPtr->signExp;
70 uiA0 = aSPtr->signif;
71 uiB64 = bSPtr->signExp;
72 uiB0 = bSPtr->signif;
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
76 softfloat_raiseFlags( softfloat_flag_invalid );
77 return false;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 signA = signExtF80UI64( uiA64 );
82 if ( (uiA64 ^ uiB64) & 0x8000 ) {
83 /*--------------------------------------------------------------------
84 | Signs are different.
85 *--------------------------------------------------------------------*/
86 return signA && ((uiA0 | uiB0) != 0);
87 } else {
88 /*--------------------------------------------------------------------
89 | Signs are the same.
90 *--------------------------------------------------------------------*/
91 if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
92 return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) < 0);
93 }
94 if ( uiA64 == uiB64 ) {
95 if ( uiA0 == uiB0 ) return false;
96 ltMags = (uiA0 < uiB0);
97 } else {
98 ltMags = (uiA64 < uiB64);
99 }
100 return signA ^ ltMags;
101 }
102
103}
104
105#endif
106
deps/SoftFloat-3d/source/extF80M_lt_quiet.c deleted-112
......@@ -1,112 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46bool extF80M_lt_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
47{
48
49 return extF80_lt_quiet( *aPtr, *bPtr );
50
51}
52
53#else
54
55bool extF80M_lt_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
56{
57 const struct extFloat80M *aSPtr, *bSPtr;
58 uint_fast16_t uiA64;
59 uint64_t uiA0;
60 uint_fast16_t uiB64;
61 uint64_t uiB0;
62 bool signA, ltMags;
63
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 aSPtr = (const struct extFloat80M *) aPtr;
67 bSPtr = (const struct extFloat80M *) bPtr;
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 uiA64 = aSPtr->signExp;
71 uiA0 = aSPtr->signif;
72 uiB64 = bSPtr->signExp;
73 uiB0 = bSPtr->signif;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
77 if (
78 softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
79 || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
80 ) {
81 softfloat_raiseFlags( softfloat_flag_invalid );
82 }
83 return false;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 signA = signExtF80UI64( uiA64 );
88 if ( (uiA64 ^ uiB64) & 0x8000 ) {
89 /*--------------------------------------------------------------------
90 | Signs are different.
91 *--------------------------------------------------------------------*/
92 return signA && ((uiA0 | uiB0) != 0);
93 } else {
94 /*--------------------------------------------------------------------
95 | Signs are the same.
96 *--------------------------------------------------------------------*/
97 if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
98 return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) < 0);
99 }
100 if ( uiA64 == uiB64 ) {
101 if ( uiA0 == uiB0 ) return false;
102 ltMags = (uiA0 < uiB0);
103 } else {
104 ltMags = (uiA64 < uiB64);
105 }
106 return signA ^ ltMags;
107 }
108
109}
110
111#endif
112
deps/SoftFloat-3d/source/extF80M_mul.c deleted-139
......@@ -1,139 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void
47 extF80M_mul(
48 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
49{
50
51 *zPtr = extF80_mul( *aPtr, *bPtr );
52
53}
54
55#else
56
57void
58 extF80M_mul(
59 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
60{
61 const struct extFloat80M *aSPtr, *bSPtr;
62 struct extFloat80M *zSPtr;
63 uint_fast16_t uiA64;
64 int32_t expA;
65 uint_fast16_t uiB64;
66 int32_t expB;
67 bool signZ;
68 uint_fast16_t exp, uiZ64;
69 uint64_t uiZ0, sigA, sigB;
70 int32_t expZ;
71 uint32_t sigProd[4], *extSigZPtr;
72
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 aSPtr = (const struct extFloat80M *) aPtr;
76 bSPtr = (const struct extFloat80M *) bPtr;
77 zSPtr = (struct extFloat80M *) zPtr;
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 uiA64 = aSPtr->signExp;
81 expA = expExtF80UI64( uiA64 );
82 uiB64 = bSPtr->signExp;
83 expB = expExtF80UI64( uiB64 );
84 signZ = signExtF80UI64( uiA64 ) ^ signExtF80UI64( uiB64 );
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
88 if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
89 if (
90 (! aSPtr->signif && (expA != 0x7FFF))
91 || (! bSPtr->signif && (expB != 0x7FFF))
92 ) {
93 softfloat_invalidExtF80M( zSPtr );
94 return;
95 }
96 uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
97 uiZ0 = UINT64_C( 0x8000000000000000 );
98 goto uiZ;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 if ( ! expA ) expA = 1;
103 sigA = aSPtr->signif;
104 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
105 if ( ! sigA ) goto zero;
106 expA += softfloat_normExtF80SigM( &sigA );
107 }
108 if ( ! expB ) expB = 1;
109 sigB = bSPtr->signif;
110 if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
111 if ( ! sigB ) goto zero;
112 expB += softfloat_normExtF80SigM( &sigB );
113 }
114 /*------------------------------------------------------------------------
115 *------------------------------------------------------------------------*/
116 expZ = expA + expB - 0x3FFE;
117 softfloat_mul64To128M( sigA, sigB, sigProd );
118 if ( sigProd[indexWordLo( 4 )] ) sigProd[indexWord( 4, 1 )] |= 1;
119 extSigZPtr = &sigProd[indexMultiwordHi( 4, 3 )];
120 if ( sigProd[indexWordHi( 4 )] < 0x80000000 ) {
121 --expZ;
122 softfloat_add96M( extSigZPtr, extSigZPtr, extSigZPtr );
123 }
124 softfloat_roundPackMToExtF80M(
125 signZ, expZ, extSigZPtr, extF80_roundingPrecision, zSPtr );
126 return;
127 /*------------------------------------------------------------------------
128 *------------------------------------------------------------------------*/
129 zero:
130 uiZ64 = packToExtF80UI64( signZ, 0 );
131 uiZ0 = 0;
132 uiZ:
133 zSPtr->signExp = uiZ64;
134 zSPtr->signif = uiZ0;
135
136}
137
138#endif
139
deps/SoftFloat-3d/source/extF80M_rem.c deleted-204
......@@ -1,204 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void
47 extF80M_rem(
48 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
49{
50
51 *zPtr = extF80_rem( *aPtr, *bPtr );
52
53}
54
55#else
56
57void
58 extF80M_rem(
59 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
60{
61 const struct extFloat80M *aSPtr, *bSPtr;
62 struct extFloat80M *zSPtr;
63 uint_fast16_t uiA64;
64 int32_t expA, expB;
65 uint64_t x64;
66 bool signRem;
67 uint64_t sigA;
68 int32_t expDiff;
69 uint32_t rem[3], x[3], sig32B, q, recip32, rem2[3], *remPtr, *altRemPtr;
70 uint32_t *newRemPtr, wordMeanRem;
71
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 aSPtr = (const struct extFloat80M *) aPtr;
75 bSPtr = (const struct extFloat80M *) bPtr;
76 zSPtr = (struct extFloat80M *) zPtr;
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 uiA64 = aSPtr->signExp;
80 expA = expExtF80UI64( uiA64 );
81 expB = expExtF80UI64( bSPtr->signExp );
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
85 if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
86 if ( expA == 0x7FFF ) goto invalid;
87 /*--------------------------------------------------------------------
88 | If we get here, then argument b is an infinity and `expB' is 0x7FFF;
89 | Doubling `expB' is an easy way to ensure that `expDiff' later is
90 | less than -1, which will result in returning a canonicalized version
91 | of argument a.
92 *--------------------------------------------------------------------*/
93 expB += expB;
94 }
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 if ( ! expB ) expB = 1;
98 x64 = bSPtr->signif;
99 if ( ! (x64 & UINT64_C( 0x8000000000000000 )) ) {
100 if ( ! x64 ) goto invalid;
101 expB += softfloat_normExtF80SigM( &x64 );
102 }
103 signRem = signExtF80UI64( uiA64 );
104 if ( ! expA ) expA = 1;
105 sigA = aSPtr->signif;
106 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
107 if ( ! sigA ) {
108 expA = 0;
109 goto copyA;
110 }
111 expA += softfloat_normExtF80SigM( &sigA );
112 }
113 /*------------------------------------------------------------------------
114 *------------------------------------------------------------------------*/
115 expDiff = expA - expB;
116 if ( expDiff < -1 ) goto copyA;
117 rem[indexWord( 3, 2 )] = sigA>>34;
118 rem[indexWord( 3, 1 )] = sigA>>2;
119 rem[indexWord( 3, 0 )] = (uint32_t) sigA<<30;
120 x[indexWord( 3, 0 )] = (uint32_t) x64<<30;
121 sig32B = x64>>32;
122 x64 >>= 2;
123 x[indexWord( 3, 2 )] = x64>>32;
124 x[indexWord( 3, 1 )] = x64;
125 if ( expDiff < 1 ) {
126 if ( expDiff ) {
127 --expB;
128 softfloat_add96M( x, x, x );
129 q = 0;
130 } else {
131 q = (softfloat_compare96M( x, rem ) <= 0);
132 if ( q ) softfloat_sub96M( rem, x, rem );
133 }
134 } else {
135 recip32 = softfloat_approxRecip32_1( sig32B );
136 expDiff -= 30;
137 for (;;) {
138 x64 = (uint64_t) rem[indexWordHi( 3 )] * recip32;
139 if ( expDiff < 0 ) break;
140 q = (x64 + 0x80000000)>>32;
141 softfloat_remStep96MBy32( rem, 29, x, q, rem );
142 if ( rem[indexWordHi( 3 )] & 0x80000000 ) {
143 softfloat_add96M( rem, x, rem );
144 }
145 expDiff -= 29;
146 }
147 /*--------------------------------------------------------------------
148 | (`expDiff' cannot be less than -29 here.)
149 *--------------------------------------------------------------------*/
150 q = (uint32_t) (x64>>32)>>(~expDiff & 31);
151 softfloat_remStep96MBy32( rem, expDiff + 30, x, q, rem );
152 if ( rem[indexWordHi( 3 )] & 0x80000000 ) {
153 remPtr = rem;
154 altRemPtr = rem2;
155 softfloat_add96M( remPtr, x, altRemPtr );
156 goto selectRem;
157 }
158 }
159 /*------------------------------------------------------------------------
160 *------------------------------------------------------------------------*/
161 remPtr = rem;
162 altRemPtr = rem2;
163 do {
164 ++q;
165 newRemPtr = altRemPtr;
166 softfloat_sub96M( remPtr, x, newRemPtr );
167 altRemPtr = remPtr;
168 remPtr = newRemPtr;
169 } while ( ! (remPtr[indexWordHi( 3 )] & 0x80000000) );
170 selectRem:
171 softfloat_add96M( remPtr, altRemPtr, x );
172 wordMeanRem = x[indexWordHi( 3 )];
173 if (
174 (wordMeanRem & 0x80000000)
175 || (! wordMeanRem && (q & 1) && ! x[indexWord( 3, 0 )]
176 && ! x[indexWord( 3, 1 )])
177 ) {
178 remPtr = altRemPtr;
179 }
180 if ( remPtr[indexWordHi( 3 )] & 0x80000000 ) {
181 signRem = ! signRem;
182 softfloat_negX96M( remPtr );
183 }
184 softfloat_normRoundPackMToExtF80M( signRem, expB + 2, remPtr, 80, zSPtr );
185 return;
186 /*------------------------------------------------------------------------
187 *------------------------------------------------------------------------*/
188 invalid:
189 softfloat_invalidExtF80M( zSPtr );
190 return;
191 /*------------------------------------------------------------------------
192 *------------------------------------------------------------------------*/
193 copyA:
194 if ( expA < 1 ) {
195 sigA >>= 1 - expA;
196 expA = 0;
197 }
198 zSPtr->signExp = packToExtF80UI64( signRem, expA );
199 zSPtr->signif = sigA;
200
201}
202
203#endif
204
deps/SoftFloat-3d/source/extF80M_roundToInt.c deleted-169
......@@ -1,169 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void
47 extF80M_roundToInt(
48 const extFloat80_t *aPtr,
49 uint_fast8_t roundingMode,
50 bool exact,
51 extFloat80_t *zPtr
52 )
53{
54
55 *zPtr = extF80_roundToInt( *aPtr, roundingMode, exact );
56
57}
58
59#else
60
61void
62 extF80M_roundToInt(
63 const extFloat80_t *aPtr,
64 uint_fast8_t roundingMode,
65 bool exact,
66 extFloat80_t *zPtr
67 )
68{
69 const struct extFloat80M *aSPtr;
70 struct extFloat80M *zSPtr;
71 uint_fast16_t uiA64, signUI64;
72 int32_t exp;
73 uint64_t sigA;
74 uint_fast16_t uiZ64;
75 uint64_t sigZ, lastBitMask, roundBitsMask;
76
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 aSPtr = (const struct extFloat80M *) aPtr;
80 zSPtr = (struct extFloat80M *) zPtr;
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 uiA64 = aSPtr->signExp;
84 signUI64 = uiA64 & packToExtF80UI64( 1, 0 );
85 exp = expExtF80UI64( uiA64 );
86 sigA = aSPtr->signif;
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) && (exp != 0x7FFF) ) {
90 if ( ! sigA ) {
91 uiZ64 = signUI64;
92 sigZ = 0;
93 goto uiZ;
94 }
95 exp += softfloat_normExtF80SigM( &sigA );
96 }
97 /*------------------------------------------------------------------------
98 *------------------------------------------------------------------------*/
99 if ( exp <= 0x3FFE ) {
100 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
101 switch ( roundingMode ) {
102 case softfloat_round_near_even:
103 if ( ! (sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) break;
104 case softfloat_round_near_maxMag:
105 if ( exp == 0x3FFE ) goto mag1;
106 break;
107 case softfloat_round_min:
108 if ( signUI64 ) goto mag1;
109 break;
110 case softfloat_round_max:
111 if ( ! signUI64 ) goto mag1;
112 break;
113 }
114 uiZ64 = signUI64;
115 sigZ = 0;
116 goto uiZ;
117 mag1:
118 uiZ64 = signUI64 | 0x3FFF;
119 sigZ = UINT64_C( 0x8000000000000000 );
120 goto uiZ;
121 }
122 /*------------------------------------------------------------------------
123 *------------------------------------------------------------------------*/
124 if ( 0x403E <= exp ) {
125 if ( exp == 0x7FFF ) {
126 if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
127 softfloat_propagateNaNExtF80M( aSPtr, 0, zSPtr );
128 return;
129 }
130 sigZ = UINT64_C( 0x8000000000000000 );
131 } else {
132 sigZ = sigA;
133 }
134 uiZ64 = signUI64 | exp;
135 goto uiZ;
136 }
137 /*------------------------------------------------------------------------
138 *------------------------------------------------------------------------*/
139 uiZ64 = signUI64 | exp;
140 lastBitMask = (uint64_t) 1<<(0x403E - exp);
141 roundBitsMask = lastBitMask - 1;
142 sigZ = sigA;
143 if ( roundingMode == softfloat_round_near_maxMag ) {
144 sigZ += lastBitMask>>1;
145 } else if ( roundingMode == softfloat_round_near_even ) {
146 sigZ += lastBitMask>>1;
147 if ( ! (sigZ & roundBitsMask) ) sigZ &= ~lastBitMask;
148 } else if (
149 roundingMode == (signUI64 ? softfloat_round_min : softfloat_round_max)
150 ) {
151 sigZ += roundBitsMask;
152 }
153 sigZ &= ~roundBitsMask;
154 if ( ! sigZ ) {
155 ++uiZ64;
156 sigZ = UINT64_C( 0x8000000000000000 );
157 }
158 if ( exact && (sigZ != sigA) ) {
159 softfloat_exceptionFlags |= softfloat_flag_inexact;
160 }
161 uiZ:
162 zSPtr->signExp = uiZ64;
163 zSPtr->signif = sigZ;
164 return;
165
166}
167
168#endif
169
deps/SoftFloat-3d/source/extF80M_sqrt.c deleted-180
......@@ -1,180 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void extF80M_sqrt( const extFloat80_t *aPtr, extFloat80_t *zPtr )
47{
48
49 *zPtr = extF80_sqrt( *aPtr );
50
51}
52
53#else
54
55void extF80M_sqrt( const extFloat80_t *aPtr, extFloat80_t *zPtr )
56{
57 const struct extFloat80M *aSPtr;
58 struct extFloat80M *zSPtr;
59 uint_fast16_t uiA64, signUI64;
60 int32_t expA;
61 uint64_t rem64;
62 int32_t expZ;
63 uint32_t rem96[3], sig32A, recipSqrt32, sig32Z, q;
64 uint64_t sig64Z, x64;
65 uint32_t rem32, term[4], rem[4], extSigZ[3];
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 aSPtr = (const struct extFloat80M *) aPtr;
70 zSPtr = (struct extFloat80M *) zPtr;
71 /*------------------------------------------------------------------------
72 *------------------------------------------------------------------------*/
73 uiA64 = aSPtr->signExp;
74 signUI64 = uiA64 & packToExtF80UI64( 1, 0 );
75 expA = expExtF80UI64( uiA64 );
76 rem64 = aSPtr->signif;
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 if ( expA == 0x7FFF ) {
80 if ( rem64 & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
81 softfloat_propagateNaNExtF80M( aSPtr, 0, zSPtr );
82 return;
83 }
84 if ( signUI64 ) goto invalid;
85 rem64 = UINT64_C( 0x8000000000000000 );
86 goto copyA;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( ! expA ) expA = 1;
91 if ( ! (rem64 & UINT64_C( 0x8000000000000000 )) ) {
92 if ( ! rem64 ) {
93 uiA64 = signUI64;
94 goto copyA;
95 }
96 expA += softfloat_normExtF80SigM( &rem64 );
97 }
98 if ( signUI64 ) goto invalid;
99 /*------------------------------------------------------------------------
100 *------------------------------------------------------------------------*/
101 expZ = ((expA - 0x3FFF)>>1) + 0x3FFF;
102 expA &= 1;
103 softfloat_shortShiftLeft64To96M( rem64, 30 - expA, rem96 );
104 sig32A = rem64>>32;
105 recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
106 sig32Z = ((uint64_t) sig32A * recipSqrt32)>>32;
107 if ( expA ) sig32Z >>= 1;
108 rem64 =
109 ((uint64_t) rem96[indexWord( 3, 2 )]<<32 | rem96[indexWord( 3, 1 )])
110 - (uint64_t) sig32Z * sig32Z;
111 rem96[indexWord( 3, 2 )] = rem64>>32;
112 rem96[indexWord( 3, 1 )] = rem64;
113 /*------------------------------------------------------------------------
114 *------------------------------------------------------------------------*/
115 q = ((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32;
116 sig64Z = ((uint64_t) sig32Z<<32) + ((uint64_t) q<<3);
117 term[indexWord( 3, 2 )] = 0;
118 /*------------------------------------------------------------------------
119 | (Repeating this loop is a rare occurrence.)
120 *------------------------------------------------------------------------*/
121 for (;;) {
122 x64 = ((uint64_t) sig32Z<<32) + sig64Z;
123 term[indexWord( 3, 1 )] = x64>>32;
124 term[indexWord( 3, 0 )] = x64;
125 softfloat_remStep96MBy32(
126 rem96, 29, term, q, &rem[indexMultiwordHi( 4, 3 )] );
127 rem32 = rem[indexWord( 4, 3 )];
128 if ( ! (rem32 & 0x80000000) ) break;
129 --q;
130 sig64Z -= 1<<3;
131 }
132 rem64 = (uint64_t) rem32<<32 | rem[indexWord( 4, 2 )];
133 /*------------------------------------------------------------------------
134 *------------------------------------------------------------------------*/
135 q = (((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32) + 2;
136 if ( rem64>>34 ) q += recipSqrt32;
137 x64 = (uint64_t) q<<7;
138 extSigZ[indexWord( 3, 0 )] = x64;
139 x64 = (sig64Z<<1) + (x64>>32);
140 extSigZ[indexWord( 3, 2 )] = x64>>32;
141 extSigZ[indexWord( 3, 1 )] = x64;
142 /*------------------------------------------------------------------------
143 *------------------------------------------------------------------------*/
144 if ( (q & 0xFFFFFF) <= 2 ) {
145 q &= ~(uint32_t) 0xFFFF;
146 extSigZ[indexWordLo( 3 )] = q<<7;
147 x64 = sig64Z + (q>>27);
148 term[indexWord( 4, 3 )] = 0;
149 term[indexWord( 4, 2 )] = x64>>32;
150 term[indexWord( 4, 1 )] = x64;
151 term[indexWord( 4, 0 )] = q<<5;
152 rem[indexWord( 4, 0 )] = 0;
153 softfloat_remStep128MBy32( rem, 28, term, q, rem );
154 q = rem[indexWordHi( 4 )];
155 if ( q & 0x80000000 ) {
156 softfloat_sub1X96M( extSigZ );
157 } else {
158 if ( q || rem[indexWord( 4, 1 )] || rem[indexWord( 4, 2 )] ) {
159 extSigZ[indexWordLo( 3 )] |= 1;
160 }
161 }
162 }
163 softfloat_roundPackMToExtF80M(
164 0, expZ, extSigZ, extF80_roundingPrecision, zSPtr );
165 return;
166 /*------------------------------------------------------------------------
167 *------------------------------------------------------------------------*/
168 invalid:
169 softfloat_invalidExtF80M( zSPtr );
170 return;
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 copyA:
174 zSPtr->signExp = uiA64;
175 zSPtr->signif = rem64;
176
177}
178
179#endif
180
deps/SoftFloat-3d/source/extF80M_sub.c deleted-100
......@@ -1,100 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void
45 extF80M_sub(
46 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
47{
48 const struct extFloat80M *aSPtr, *bSPtr;
49 uint_fast16_t uiA64;
50 uint_fast64_t uiA0;
51 bool signA;
52 uint_fast16_t uiB64;
53 uint_fast64_t uiB0;
54 bool signB;
55#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
56 extFloat80_t
57 (*magsFuncPtr)(
58 uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
59#endif
60
61 aSPtr = (const struct extFloat80M *) aPtr;
62 bSPtr = (const struct extFloat80M *) bPtr;
63 uiA64 = aSPtr->signExp;
64 uiA0 = aSPtr->signif;
65 signA = signExtF80UI64( uiA64 );
66 uiB64 = bSPtr->signExp;
67 uiB0 = bSPtr->signif;
68 signB = signExtF80UI64( uiB64 );
69#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
70 if ( signA == signB ) {
71 *zPtr = softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
72 } else {
73 *zPtr = softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
74 }
75#else
76 magsFuncPtr =
77 (signA == signB) ? softfloat_subMagsExtF80 : softfloat_addMagsExtF80;
78 *zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
79#endif
80
81}
82
83#else
84
85void
86 extF80M_sub(
87 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
88{
89
90 softfloat_addExtF80M(
91 (const struct extFloat80M *) aPtr,
92 (const struct extFloat80M *) bPtr,
93 (struct extFloat80M *) zPtr,
94 true
95 );
96
97}
98
99#endif
100
deps/SoftFloat-3d/source/extF80M_to_f128M.c deleted-125
......@@ -1,125 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void extF80M_to_f128M( const extFloat80_t *aPtr, float128_t *zPtr )
47{
48
49 *zPtr = extF80_to_f128( *aPtr );
50
51}
52
53#else
54
55void extF80M_to_f128M( const extFloat80_t *aPtr, float128_t *zPtr )
56{
57 const struct extFloat80M *aSPtr;
58 uint32_t *zWPtr;
59 uint_fast16_t uiA64;
60 bool sign;
61 int32_t exp;
62 uint64_t sig;
63 struct commonNaN commonNaN;
64 uint32_t uiZ96;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aSPtr = (const struct extFloat80M *) aPtr;
69 zWPtr = (uint32_t *) zPtr;
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 uiA64 = aSPtr->signExp;
73 sign = signExtF80UI64( uiA64 );
74 exp = expExtF80UI64( uiA64 );
75 sig = aSPtr->signif;
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 zWPtr[indexWord( 4, 0 )] = 0;
79 if ( exp == 0x7FFF ) {
80 if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
81 softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
82 softfloat_commonNaNToF128M( &commonNaN, zWPtr );
83 return;
84 }
85 uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
86 goto uiZ;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( exp ) --exp;
91 if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
92 if ( ! sig ) {
93 uiZ96 = packToF128UI96( sign, 0, 0 );
94 goto uiZ;
95 }
96 exp += softfloat_normExtF80SigM( &sig );
97 }
98 /*------------------------------------------------------------------------
99 *------------------------------------------------------------------------*/
100 zWPtr[indexWord( 4, 1 )] = (uint32_t) sig<<17;
101 sig >>= 15;
102 zWPtr[indexWord( 4, 2 )] = sig;
103 if ( exp < 0 ) {
104 zWPtr[indexWordHi( 4 )] = sig>>32;
105 softfloat_shiftRight96M(
106 &zWPtr[indexMultiwordHi( 4, 3 )],
107 -exp,
108 &zWPtr[indexMultiwordHi( 4, 3 )]
109 );
110 exp = 0;
111 sig = (uint64_t) zWPtr[indexWordHi( 4 )]<<32;
112 }
113 zWPtr[indexWordHi( 4 )] = packToF128UI96( sign, exp, sig>>32 );
114 return;
115 /*------------------------------------------------------------------------
116 *------------------------------------------------------------------------*/
117 uiZ:
118 zWPtr[indexWord( 4, 3 )] = uiZ96;
119 zWPtr[indexWord( 4, 2 )] = 0;
120 zWPtr[indexWord( 4, 1 )] = 0;
121
122}
123
124#endif
125
deps/SoftFloat-3d/source/extF80M_to_f16.c deleted-112
......@@ -1,112 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46float16_t extF80M_to_f16( const extFloat80_t *aPtr )
47{
48
49 return extF80_to_f16( *aPtr );
50
51}
52
53#else
54
55float16_t extF80M_to_f16( const extFloat80_t *aPtr )
56{
57 const struct extFloat80M *aSPtr;
58 uint_fast16_t uiA64;
59 bool sign;
60 int32_t exp;
61 uint64_t sig;
62 struct commonNaN commonNaN;
63 uint16_t uiZ, sig16;
64 union ui16_f16 uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aSPtr = (const struct extFloat80M *) aPtr;
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 uiA64 = aSPtr->signExp;
72 sign = signExtF80UI64( uiA64 );
73 exp = expExtF80UI64( uiA64 );
74 sig = aSPtr->signif;
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp == 0x7FFF ) {
78 if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
79 softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
80 uiZ = softfloat_commonNaNToF16UI( &commonNaN );
81 } else {
82 uiZ = packToF16UI( sign, 0x1F, 0 );
83 }
84 goto uiZ;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
89 if ( ! sig ) {
90 uiZ = packToF16UI( sign, 0, 0 );
91 goto uiZ;
92 }
93 exp += softfloat_normExtF80SigM( &sig );
94 }
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 sig16 = softfloat_shortShiftRightJam64( sig, 49 );
98 exp -= 0x3FF1;
99 if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
100 if ( exp < -0x40 ) exp = -0x40;
101 }
102 return softfloat_roundPackToF16( sign, exp, sig16 );
103 /*------------------------------------------------------------------------
104 *------------------------------------------------------------------------*/
105 uiZ:
106 uZ.ui = uiZ;
107 return uZ.f;
108
109}
110
111#endif
112
deps/SoftFloat-3d/source/extF80M_to_f32.c deleted-112
......@@ -1,112 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46float32_t extF80M_to_f32( const extFloat80_t *aPtr )
47{
48
49 return extF80_to_f32( *aPtr );
50
51}
52
53#else
54
55float32_t extF80M_to_f32( const extFloat80_t *aPtr )
56{
57 const struct extFloat80M *aSPtr;
58 uint_fast16_t uiA64;
59 bool sign;
60 int32_t exp;
61 uint64_t sig;
62 struct commonNaN commonNaN;
63 uint32_t uiZ, sig32;
64 union ui32_f32 uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aSPtr = (const struct extFloat80M *) aPtr;
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 uiA64 = aSPtr->signExp;
72 sign = signExtF80UI64( uiA64 );
73 exp = expExtF80UI64( uiA64 );
74 sig = aSPtr->signif;
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp == 0x7FFF ) {
78 if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
79 softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
80 uiZ = softfloat_commonNaNToF32UI( &commonNaN );
81 } else {
82 uiZ = packToF32UI( sign, 0xFF, 0 );
83 }
84 goto uiZ;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
89 if ( ! sig ) {
90 uiZ = packToF32UI( sign, 0, 0 );
91 goto uiZ;
92 }
93 exp += softfloat_normExtF80SigM( &sig );
94 }
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 sig32 = softfloat_shortShiftRightJam64( sig, 33 );
98 exp -= 0x3F81;
99 if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
100 if ( exp < -0x1000 ) exp = -0x1000;
101 }
102 return softfloat_roundPackToF32( sign, exp, sig32 );
103 /*------------------------------------------------------------------------
104 *------------------------------------------------------------------------*/
105 uiZ:
106 uZ.ui = uiZ;
107 return uZ.f;
108
109}
110
111#endif
112
deps/SoftFloat-3d/source/extF80M_to_f64.c deleted-112
......@@ -1,112 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46float64_t extF80M_to_f64( const extFloat80_t *aPtr )
47{
48
49 return extF80_to_f64( *aPtr );
50
51}
52
53#else
54
55float64_t extF80M_to_f64( const extFloat80_t *aPtr )
56{
57 const struct extFloat80M *aSPtr;
58 uint_fast16_t uiA64;
59 bool sign;
60 int32_t exp;
61 uint64_t sig;
62 struct commonNaN commonNaN;
63 uint64_t uiZ;
64 union ui64_f64 uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aSPtr = (const struct extFloat80M *) aPtr;
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 uiA64 = aSPtr->signExp;
72 sign = signExtF80UI64( uiA64 );
73 exp = expExtF80UI64( uiA64 );
74 sig = aSPtr->signif;
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp == 0x7FFF ) {
78 if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
79 softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
80 uiZ = softfloat_commonNaNToF64UI( &commonNaN );
81 } else {
82 uiZ = packToF64UI( sign, 0x7FF, 0 );
83 }
84 goto uiZ;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
89 if ( ! sig ) {
90 uiZ = packToF64UI( sign, 0, 0 );
91 goto uiZ;
92 }
93 exp += softfloat_normExtF80SigM( &sig );
94 }
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 sig = softfloat_shortShiftRightJam64( sig, 1 );
98 exp -= 0x3C01;
99 if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
100 if ( exp < -0x1000 ) exp = -0x1000;
101 }
102 return softfloat_roundPackToF64( sign, exp, sig );
103 /*------------------------------------------------------------------------
104 *------------------------------------------------------------------------*/
105 uiZ:
106 uZ.ui = uiZ;
107 return uZ.f;
108
109}
110
111#endif
112
deps/SoftFloat-3d/source/extF80M_to_i32.c deleted-100
......@@ -1,100 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46int_fast32_t
47 extF80M_to_i32(
48 const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
49{
50
51 return extF80_to_i32( *aPtr, roundingMode, exact );
52
53}
54
55#else
56
57int_fast32_t
58 extF80M_to_i32(
59 const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
60{
61 const struct extFloat80M *aSPtr;
62 uint_fast16_t uiA64;
63 bool sign;
64 int32_t exp;
65 uint64_t sig;
66 int32_t shiftDist;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 aSPtr = (const struct extFloat80M *) aPtr;
71 uiA64 = aSPtr->signExp;
72 sign = signExtF80UI64( uiA64 );
73 exp = expExtF80UI64( uiA64 );
74 sig = aSPtr->signif;
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 shiftDist = 0x4032 - exp;
78 if ( shiftDist <= 0 ) {
79 if ( sig>>32 ) goto invalid;
80 if ( -32 < shiftDist ) {
81 sig <<= -shiftDist;
82 } else {
83 if ( (uint32_t) sig ) goto invalid;
84 }
85 } else {
86 sig = softfloat_shiftRightJam64( sig, shiftDist );
87 }
88 return softfloat_roundToI32( sign, sig, roundingMode, exact );
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 invalid:
92 softfloat_raiseFlags( softfloat_flag_invalid );
93 return
94 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ? i32_fromNaN
95 : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
96
97}
98
99#endif
100
deps/SoftFloat-3d/source/extF80M_to_i32_r_minMag.c deleted-120
......@@ -1,120 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46int_fast32_t extF80M_to_i32_r_minMag( const extFloat80_t *aPtr, bool exact )
47{
48
49 return extF80_to_i32_r_minMag( *aPtr, exact );
50
51}
52
53#else
54
55int_fast32_t extF80M_to_i32_r_minMag( const extFloat80_t *aPtr, bool exact )
56{
57 const struct extFloat80M *aSPtr;
58 uint_fast16_t uiA64;
59 int32_t exp;
60 uint64_t sig;
61 int32_t shiftDist;
62 bool sign, raiseInexact;
63 int32_t z;
64 uint64_t shiftedSig;
65 uint32_t absZ;
66 union { uint32_t ui; int32_t i; } u;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 aSPtr = (const struct extFloat80M *) aPtr;
71 uiA64 = aSPtr->signExp;
72 exp = expExtF80UI64( uiA64 );
73 sig = aSPtr->signif;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( ! sig && (exp != 0x7FFF) ) return 0;
77 shiftDist = 0x403E - exp;
78 if ( 64 <= shiftDist ) {
79 raiseInexact = exact;
80 z = 0;
81 } else {
82 sign = signExtF80UI64( uiA64 );
83 raiseInexact = false;
84 if ( shiftDist < 0 ) {
85 if ( sig>>32 || (shiftDist <= -31) ) goto invalid;
86 shiftedSig = (uint64_t) (uint32_t) sig<<-shiftDist;
87 if ( shiftedSig>>32 ) goto invalid;
88 absZ = shiftedSig;
89 } else {
90 shiftedSig = sig;
91 if ( shiftDist ) shiftedSig >>= shiftDist;
92 if ( shiftedSig>>32 ) goto invalid;
93 absZ = shiftedSig;
94 if ( exact && shiftDist ) {
95 raiseInexact = ((uint64_t) absZ<<shiftDist != sig);
96 }
97 }
98 if ( sign ) {
99 if ( 0x80000000 < absZ ) goto invalid;
100 u.ui = -absZ;
101 z = u.i;
102 } else {
103 if ( 0x80000000 <= absZ ) goto invalid;
104 z = absZ;
105 }
106 }
107 if ( raiseInexact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
108 return z;
109 /*------------------------------------------------------------------------
110 *------------------------------------------------------------------------*/
111 invalid:
112 softfloat_raiseFlags( softfloat_flag_invalid );
113 return
114 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ? i32_fromNaN
115 : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
116
117}
118
119#endif
120
deps/SoftFloat-3d/source/extF80M_to_i64.c deleted-97
......@@ -1,97 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46int_fast64_t
47 extF80M_to_i64(
48 const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
49{
50
51 return extF80_to_i64( *aPtr, roundingMode, exact );
52
53}
54
55#else
56
57int_fast64_t
58 extF80M_to_i64(
59 const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
60{
61 const struct extFloat80M *aSPtr;
62 uint_fast16_t uiA64;
63 bool sign;
64 int32_t exp;
65 uint64_t sig;
66 int32_t shiftDist;
67 uint32_t extSig[3];
68
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 aSPtr = (const struct extFloat80M *) aPtr;
72 uiA64 = aSPtr->signExp;
73 sign = signExtF80UI64( uiA64 );
74 exp = expExtF80UI64( uiA64 );
75 sig = aSPtr->signif;
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 shiftDist = 0x403E - exp;
79 if ( shiftDist < 0 ) {
80 softfloat_raiseFlags( softfloat_flag_invalid );
81 return
82 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
83 ? i64_fromNaN
84 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 extSig[indexWord( 3, 2 )] = sig>>32;
89 extSig[indexWord( 3, 1 )] = sig;
90 extSig[indexWord( 3, 0 )] = 0;
91 if ( shiftDist ) softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
92 return softfloat_roundMToI64( sign, extSig, roundingMode, exact );
93
94}
95
96#endif
97
deps/SoftFloat-3d/source/extF80M_to_i64_r_minMag.c deleted-115
......@@ -1,115 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46int_fast64_t extF80M_to_i64_r_minMag( const extFloat80_t *aPtr, bool exact )
47{
48
49 return extF80_to_i64_r_minMag( *aPtr, exact );
50
51}
52
53#else
54
55int_fast64_t extF80M_to_i64_r_minMag( const extFloat80_t *aPtr, bool exact )
56{
57 const struct extFloat80M *aSPtr;
58 uint_fast16_t uiA64;
59 int32_t exp;
60 uint64_t sig;
61 int32_t shiftDist;
62 bool sign, raiseInexact;
63 int64_t z;
64 uint64_t absZ;
65 union { uint64_t ui; int64_t i; } u;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 aSPtr = (const struct extFloat80M *) aPtr;
70 uiA64 = aSPtr->signExp;
71 exp = expExtF80UI64( uiA64 );
72 sig = aSPtr->signif;
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 if ( ! sig && (exp != 0x7FFF) ) return 0;
76 shiftDist = 0x403E - exp;
77 if ( 64 <= shiftDist ) {
78 raiseInexact = exact;
79 z = 0;
80 } else {
81 sign = signExtF80UI64( uiA64 );
82 raiseInexact = false;
83 if ( shiftDist < 0 ) {
84 if ( shiftDist <= -63 ) goto invalid;
85 shiftDist = -shiftDist;
86 absZ = sig<<shiftDist;
87 if ( absZ>>shiftDist != sig ) goto invalid;
88 } else {
89 absZ = sig;
90 if ( shiftDist ) absZ >>= shiftDist;
91 if ( exact && shiftDist ) raiseInexact = (absZ<<shiftDist != sig);
92 }
93 if ( sign ) {
94 if ( UINT64_C( 0x8000000000000000 ) < absZ ) goto invalid;
95 u.ui = -absZ;
96 z = u.i;
97 } else {
98 if ( UINT64_C( 0x8000000000000000 ) <= absZ ) goto invalid;
99 z = absZ;
100 }
101 }
102 if ( raiseInexact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
103 return z;
104 /*------------------------------------------------------------------------
105 *------------------------------------------------------------------------*/
106 invalid:
107 softfloat_raiseFlags( softfloat_flag_invalid );
108 return
109 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ? i64_fromNaN
110 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
111
112}
113
114#endif
115
deps/SoftFloat-3d/source/extF80M_to_ui32.c deleted-101
......@@ -1,101 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46uint_fast32_t
47 extF80M_to_ui32(
48 const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
49{
50
51 return extF80_to_ui32( *aPtr, roundingMode, exact );
52
53}
54
55#else
56
57uint_fast32_t
58 extF80M_to_ui32(
59 const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
60{
61 const struct extFloat80M *aSPtr;
62 uint_fast16_t uiA64;
63 bool sign;
64 int32_t exp;
65 uint64_t sig;
66 int32_t shiftDist;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 aSPtr = (const struct extFloat80M *) aPtr;
71 uiA64 = aSPtr->signExp;
72 sign = signExtF80UI64( uiA64 );
73 exp = expExtF80UI64( uiA64 );
74 sig = aSPtr->signif;
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 shiftDist = 0x4032 - exp;
78 if ( shiftDist <= 0 ) {
79 if ( sig>>32 ) goto invalid;
80 if ( -32 < shiftDist ) {
81 sig <<= -shiftDist;
82 } else {
83 if ( (uint32_t) sig ) goto invalid;
84 }
85 } else {
86 sig = softfloat_shiftRightJam64( sig, shiftDist );
87 }
88 return softfloat_roundToUI32( sign, sig, roundingMode, exact );
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 invalid:
92 softfloat_raiseFlags( softfloat_flag_invalid );
93 return
94 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
95 ? ui32_fromNaN
96 : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
97
98}
99
100#endif
101
deps/SoftFloat-3d/source/extF80M_to_ui32_r_minMag.c deleted-111
......@@ -1,111 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46uint_fast32_t extF80M_to_ui32_r_minMag( const extFloat80_t *aPtr, bool exact )
47{
48
49 return extF80_to_ui32_r_minMag( *aPtr, exact );
50
51}
52
53#else
54
55uint_fast32_t extF80M_to_ui32_r_minMag( const extFloat80_t *aPtr, bool exact )
56{
57 const struct extFloat80M *aSPtr;
58 uint_fast16_t uiA64;
59 int32_t exp;
60 uint64_t sig;
61 int32_t shiftDist;
62 bool sign;
63 uint64_t shiftedSig;
64 uint32_t z;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aSPtr = (const struct extFloat80M *) aPtr;
69 uiA64 = aSPtr->signExp;
70 exp = expExtF80UI64( uiA64 );
71 sig = aSPtr->signif;
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 if ( ! sig && (exp != 0x7FFF) ) return 0;
75 shiftDist = 0x403E - exp;
76 if ( 64 <= shiftDist ) {
77 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
78 return 0;
79 }
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 sign = signExtF80UI64( uiA64 );
83 if ( shiftDist < 0 ) {
84 if ( sign || sig>>32 || (shiftDist <= -31) ) goto invalid;
85 shiftedSig = (uint64_t) (uint32_t) sig<<-shiftDist;
86 if ( shiftedSig>>32 ) goto invalid;
87 z = shiftedSig;
88 } else {
89 shiftedSig = sig;
90 if ( shiftDist ) shiftedSig >>= shiftDist;
91 if ( shiftedSig>>32 ) goto invalid;
92 z = shiftedSig;
93 if ( sign && z ) goto invalid;
94 if ( exact && shiftDist && ((uint64_t) z<<shiftDist != sig) ) {
95 softfloat_exceptionFlags |= softfloat_flag_inexact;
96 }
97 }
98 return z;
99 /*------------------------------------------------------------------------
100 *------------------------------------------------------------------------*/
101 invalid:
102 softfloat_raiseFlags( softfloat_flag_invalid );
103 return
104 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
105 ? ui32_fromNaN
106 : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
107
108}
109
110#endif
111
deps/SoftFloat-3d/source/extF80M_to_ui64.c deleted-97
......@@ -1,97 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46uint_fast64_t
47 extF80M_to_ui64(
48 const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
49{
50
51 return extF80_to_ui64( *aPtr, roundingMode, exact );
52
53}
54
55#else
56
57uint_fast64_t
58 extF80M_to_ui64(
59 const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
60{
61 const struct extFloat80M *aSPtr;
62 uint_fast16_t uiA64;
63 bool sign;
64 int32_t exp;
65 uint64_t sig;
66 int32_t shiftDist;
67 uint32_t extSig[3];
68
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 aSPtr = (const struct extFloat80M *) aPtr;
72 uiA64 = aSPtr->signExp;
73 sign = signExtF80UI64( uiA64 );
74 exp = expExtF80UI64( uiA64 );
75 sig = aSPtr->signif;
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 shiftDist = 0x403E - exp;
79 if ( shiftDist < 0 ) {
80 softfloat_raiseFlags( softfloat_flag_invalid );
81 return
82 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
83 ? ui64_fromNaN
84 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 extSig[indexWord( 3, 2 )] = sig>>32;
89 extSig[indexWord( 3, 1 )] = sig;
90 extSig[indexWord( 3, 0 )] = 0;
91 if ( shiftDist ) softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
92 return softfloat_roundMToUI64( sign, extSig, roundingMode, exact );
93
94}
95
96#endif
97
deps/SoftFloat-3d/source/extF80M_to_ui64_r_minMag.c deleted-108
......@@ -1,108 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46uint_fast64_t extF80M_to_ui64_r_minMag( const extFloat80_t *aPtr, bool exact )
47{
48
49 return extF80_to_ui64_r_minMag( *aPtr, exact );
50
51}
52
53#else
54
55uint_fast64_t extF80M_to_ui64_r_minMag( const extFloat80_t *aPtr, bool exact )
56{
57 const struct extFloat80M *aSPtr;
58 uint_fast16_t uiA64;
59 int32_t exp;
60 uint64_t sig;
61 int32_t shiftDist;
62 bool sign;
63 uint64_t z;
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 aSPtr = (const struct extFloat80M *) aPtr;
68 uiA64 = aSPtr->signExp;
69 exp = expExtF80UI64( uiA64 );
70 sig = aSPtr->signif;
71 /*------------------------------------------------------------------------
72 *------------------------------------------------------------------------*/
73 if ( ! sig && (exp != 0x7FFF) ) return 0;
74 shiftDist = 0x403E - exp;
75 if ( 64 <= shiftDist ) {
76 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
77 return 0;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 sign = signExtF80UI64( uiA64 );
82 if ( shiftDist < 0 ) {
83 if ( sign || (shiftDist <= -63) ) goto invalid;
84 shiftDist = -shiftDist;
85 z = sig<<shiftDist;
86 if ( z>>shiftDist != sig ) goto invalid;
87 } else {
88 z = sig;
89 if ( shiftDist ) z >>= shiftDist;
90 if ( sign && z ) goto invalid;
91 if ( exact && shiftDist && (z<<shiftDist != sig) ) {
92 softfloat_exceptionFlags |= softfloat_flag_inexact;
93 }
94 }
95 return z;
96 /*------------------------------------------------------------------------
97 *------------------------------------------------------------------------*/
98 invalid:
99 softfloat_raiseFlags( softfloat_flag_invalid );
100 return
101 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
102 ? ui64_fromNaN
103 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
104
105}
106
107#endif
108
deps/SoftFloat-3d/source/extF80_add.c deleted-80
......@@ -1,80 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43extFloat80_t extF80_add( extFloat80_t a, extFloat80_t b )
44{
45 union { struct extFloat80M s; extFloat80_t f; } uA;
46 uint_fast16_t uiA64;
47 uint_fast64_t uiA0;
48 bool signA;
49 union { struct extFloat80M s; extFloat80_t f; } uB;
50 uint_fast16_t uiB64;
51 uint_fast64_t uiB0;
52 bool signB;
53#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
54 extFloat80_t
55 (*magsFuncPtr)(
56 uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
57#endif
58
59 uA.f = a;
60 uiA64 = uA.s.signExp;
61 uiA0 = uA.s.signif;
62 signA = signExtF80UI64( uiA64 );
63 uB.f = b;
64 uiB64 = uB.s.signExp;
65 uiB0 = uB.s.signif;
66 signB = signExtF80UI64( uiB64 );
67#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
68 if ( signA == signB ) {
69 return softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
70 } else {
71 return softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
72 }
73#else
74 magsFuncPtr =
75 (signA == signB) ? softfloat_addMagsExtF80 : softfloat_subMagsExtF80;
76 return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
77#endif
78
79}
80
deps/SoftFloat-3d/source/extF80_div.c deleted-203
......@@ -1,203 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t extF80_div( extFloat80_t a, extFloat80_t b )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 bool signA;
50 int_fast32_t expA;
51 uint_fast64_t sigA;
52 union { struct extFloat80M s; extFloat80_t f; } uB;
53 uint_fast16_t uiB64;
54 uint_fast64_t uiB0;
55 bool signB;
56 int_fast32_t expB;
57 uint_fast64_t sigB;
58 bool signZ;
59 struct exp32_sig64 normExpSig;
60 int_fast32_t expZ;
61 struct uint128 rem;
62 uint_fast32_t recip32;
63 uint_fast64_t sigZ;
64 int ix;
65 uint_fast64_t q64;
66 uint_fast32_t q;
67 struct uint128 term;
68 uint_fast64_t sigZExtra;
69 struct uint128 uiZ;
70 uint_fast16_t uiZ64;
71 uint_fast64_t uiZ0;
72 union { struct extFloat80M s; extFloat80_t f; } uZ;
73
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 uA.f = a;
77 uiA64 = uA.s.signExp;
78 uiA0 = uA.s.signif;
79 signA = signExtF80UI64( uiA64 );
80 expA = expExtF80UI64( uiA64 );
81 sigA = uiA0;
82 uB.f = b;
83 uiB64 = uB.s.signExp;
84 uiB0 = uB.s.signif;
85 signB = signExtF80UI64( uiB64 );
86 expB = expExtF80UI64( uiB64 );
87 sigB = uiB0;
88 signZ = signA ^ signB;
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 if ( expA == 0x7FFF ) {
92 if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
93 if ( expB == 0x7FFF ) {
94 if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
95 goto invalid;
96 }
97 goto infinity;
98 }
99 if ( expB == 0x7FFF ) {
100 if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
101 goto zero;
102 }
103 /*------------------------------------------------------------------------
104 *------------------------------------------------------------------------*/
105 if ( ! expB ) expB = 1;
106 if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
107 if ( ! sigB ) {
108 if ( ! sigA ) goto invalid;
109 softfloat_raiseFlags( softfloat_flag_infinite );
110 goto infinity;
111 }
112 normExpSig = softfloat_normSubnormalExtF80Sig( sigB );
113 expB += normExpSig.exp;
114 sigB = normExpSig.sig;
115 }
116 if ( ! expA ) expA = 1;
117 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
118 if ( ! sigA ) goto zero;
119 normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
120 expA += normExpSig.exp;
121 sigA = normExpSig.sig;
122 }
123 /*------------------------------------------------------------------------
124 *------------------------------------------------------------------------*/
125 expZ = expA - expB + 0x3FFF;
126 if ( sigA < sigB ) {
127 --expZ;
128 rem = softfloat_shortShiftLeft128( 0, sigA, 32 );
129 } else {
130 rem = softfloat_shortShiftLeft128( 0, sigA, 31 );
131 }
132 recip32 = softfloat_approxRecip32_1( sigB>>32 );
133 sigZ = 0;
134 ix = 2;
135 for (;;) {
136 q64 = (uint_fast64_t) (uint32_t) (rem.v64>>2) * recip32;
137 q = (q64 + 0x80000000)>>32;
138 --ix;
139 if ( ix < 0 ) break;
140 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
141 term = softfloat_mul64ByShifted32To128( sigB, q );
142 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
143 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
144 --q;
145 rem = softfloat_add128( rem.v64, rem.v0, sigB>>32, sigB<<32 );
146 }
147 sigZ = (sigZ<<29) + q;
148 }
149 /*------------------------------------------------------------------------
150 *------------------------------------------------------------------------*/
151 if ( ((q + 1) & 0x3FFFFF) < 2 ) {
152 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
153 term = softfloat_mul64ByShifted32To128( sigB, q );
154 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
155 term = softfloat_shortShiftLeft128( 0, sigB, 32 );
156 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
157 --q;
158 rem = softfloat_add128( rem.v64, rem.v0, term.v64, term.v0 );
159 } else if ( softfloat_le128( term.v64, term.v0, rem.v64, rem.v0 ) ) {
160 ++q;
161 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
162 }
163 if ( rem.v64 | rem.v0 ) q |= 1;
164 }
165 /*------------------------------------------------------------------------
166 *------------------------------------------------------------------------*/
167 sigZ = (sigZ<<6) + (q>>23);
168 sigZExtra = (uint64_t) ((uint_fast64_t) q<<41);
169 return
170 softfloat_roundPackToExtF80(
171 signZ, expZ, sigZ, sigZExtra, extF80_roundingPrecision );
172 /*------------------------------------------------------------------------
173 *------------------------------------------------------------------------*/
174 propagateNaN:
175 uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
176 uiZ64 = uiZ.v64;
177 uiZ0 = uiZ.v0;
178 goto uiZ;
179 /*------------------------------------------------------------------------
180 *------------------------------------------------------------------------*/
181 invalid:
182 softfloat_raiseFlags( softfloat_flag_invalid );
183 uiZ64 = defaultNaNExtF80UI64;
184 uiZ0 = defaultNaNExtF80UI0;
185 goto uiZ;
186 /*------------------------------------------------------------------------
187 *------------------------------------------------------------------------*/
188 infinity:
189 uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
190 uiZ0 = UINT64_C( 0x8000000000000000 );
191 goto uiZ;
192 /*------------------------------------------------------------------------
193 *------------------------------------------------------------------------*/
194 zero:
195 uiZ64 = packToExtF80UI64( signZ, 0 );
196 uiZ0 = 0;
197 uiZ:
198 uZ.s.signExp = uiZ64;
199 uZ.s.signif = uiZ0;
200 return uZ.f;
201
202}
203
deps/SoftFloat-3d/source/extF80_eq.c deleted-73
......@@ -1,73 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool extF80_eq( extFloat80_t a, extFloat80_t b )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 union { struct extFloat80M s; extFloat80_t f; } uB;
50 uint_fast16_t uiB64;
51 uint_fast64_t uiB0;
52
53 uA.f = a;
54 uiA64 = uA.s.signExp;
55 uiA0 = uA.s.signif;
56 uB.f = b;
57 uiB64 = uB.s.signExp;
58 uiB0 = uB.s.signif;
59 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
60 if (
61 softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
62 || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
63 ) {
64 softfloat_raiseFlags( softfloat_flag_invalid );
65 }
66 return false;
67 }
68 return
69 (uiA0 == uiB0)
70 && ((uiA64 == uiB64) || (! uiA0 && ! ((uiA64 | uiB64) & 0x7FFF)));
71
72}
73
deps/SoftFloat-3d/source/extF80_eq_signaling.c deleted-67
......@@ -1,67 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool extF80_eq_signaling( extFloat80_t a, extFloat80_t b )
44{
45 union { struct extFloat80M s; extFloat80_t f; } uA;
46 uint_fast16_t uiA64;
47 uint_fast64_t uiA0;
48 union { struct extFloat80M s; extFloat80_t f; } uB;
49 uint_fast16_t uiB64;
50 uint_fast64_t uiB0;
51
52 uA.f = a;
53 uiA64 = uA.s.signExp;
54 uiA0 = uA.s.signif;
55 uB.f = b;
56 uiB64 = uB.s.signExp;
57 uiB0 = uB.s.signif;
58 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
59 softfloat_raiseFlags( softfloat_flag_invalid );
60 return false;
61 }
62 return
63 (uiA0 == uiB0)
64 && ((uiA64 == uiB64) || (! uiA0 && ! ((uiA64 | uiB64) & 0x7FFF)));
65
66}
67
deps/SoftFloat-3d/source/extF80_isSignalingNaN.c deleted-51
......@@ -1,51 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43bool extF80_isSignalingNaN( extFloat80_t a )
44{
45 union { struct extFloat80M s; extFloat80_t f; } uA;
46
47 uA.f = a;
48 return softfloat_isSigNaNExtF80UI( uA.s.signExp, uA.s.signif );
49
50}
51
deps/SoftFloat-3d/source/extF80_le.c deleted-73
......@@ -1,73 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool extF80_le( extFloat80_t a, extFloat80_t b )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 union { struct extFloat80M s; extFloat80_t f; } uB;
50 uint_fast16_t uiB64;
51 uint_fast64_t uiB0;
52 bool signA, signB;
53
54 uA.f = a;
55 uiA64 = uA.s.signExp;
56 uiA0 = uA.s.signif;
57 uB.f = b;
58 uiB64 = uB.s.signExp;
59 uiB0 = uB.s.signif;
60 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
61 softfloat_raiseFlags( softfloat_flag_invalid );
62 return false;
63 }
64 signA = signExtF80UI64( uiA64 );
65 signB = signExtF80UI64( uiB64 );
66 return
67 (signA != signB)
68 ? signA || ! (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
69 : ((uiA64 == uiB64) && (uiA0 == uiB0))
70 || (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
71
72}
73
deps/SoftFloat-3d/source/extF80_le_quiet.c deleted-78
......@@ -1,78 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool extF80_le_quiet( extFloat80_t a, extFloat80_t b )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 union { struct extFloat80M s; extFloat80_t f; } uB;
50 uint_fast16_t uiB64;
51 uint_fast64_t uiB0;
52 bool signA, signB;
53
54 uA.f = a;
55 uiA64 = uA.s.signExp;
56 uiA0 = uA.s.signif;
57 uB.f = b;
58 uiB64 = uB.s.signExp;
59 uiB0 = uB.s.signif;
60 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
61 if (
62 softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
63 || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
64 ) {
65 softfloat_raiseFlags( softfloat_flag_invalid );
66 }
67 return false;
68 }
69 signA = signExtF80UI64( uiA64 );
70 signB = signExtF80UI64( uiB64 );
71 return
72 (signA != signB)
73 ? signA || ! (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
74 : ((uiA64 == uiB64) && (uiA0 == uiB0))
75 || (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
76
77}
78
deps/SoftFloat-3d/source/extF80_lt.c deleted-73
......@@ -1,73 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool extF80_lt( extFloat80_t a, extFloat80_t b )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 union { struct extFloat80M s; extFloat80_t f; } uB;
50 uint_fast16_t uiB64;
51 uint_fast64_t uiB0;
52 bool signA, signB;
53
54 uA.f = a;
55 uiA64 = uA.s.signExp;
56 uiA0 = uA.s.signif;
57 uB.f = b;
58 uiB64 = uB.s.signExp;
59 uiB0 = uB.s.signif;
60 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
61 softfloat_raiseFlags( softfloat_flag_invalid );
62 return false;
63 }
64 signA = signExtF80UI64( uiA64 );
65 signB = signExtF80UI64( uiB64 );
66 return
67 (signA != signB)
68 ? signA && (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
69 : ((uiA64 != uiB64) || (uiA0 != uiB0))
70 && (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
71
72}
73
deps/SoftFloat-3d/source/extF80_lt_quiet.c deleted-78
......@@ -1,78 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool extF80_lt_quiet( extFloat80_t a, extFloat80_t b )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 union { struct extFloat80M s; extFloat80_t f; } uB;
50 uint_fast16_t uiB64;
51 uint_fast64_t uiB0;
52 bool signA, signB;
53
54 uA.f = a;
55 uiA64 = uA.s.signExp;
56 uiA0 = uA.s.signif;
57 uB.f = b;
58 uiB64 = uB.s.signExp;
59 uiB0 = uB.s.signif;
60 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
61 if (
62 softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
63 || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
64 ) {
65 softfloat_raiseFlags( softfloat_flag_invalid );
66 }
67 return false;
68 }
69 signA = signExtF80UI64( uiA64 );
70 signB = signExtF80UI64( uiB64 );
71 return
72 (signA != signB)
73 ? signA && (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
74 : ((uiA64 != uiB64) || (uiA0 != uiB0))
75 && (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
76
77}
78
deps/SoftFloat-3d/source/extF80_mul.c deleted-158
......@@ -1,158 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t extF80_mul( extFloat80_t a, extFloat80_t b )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 bool signA;
50 int_fast32_t expA;
51 uint_fast64_t sigA;
52 union { struct extFloat80M s; extFloat80_t f; } uB;
53 uint_fast16_t uiB64;
54 uint_fast64_t uiB0;
55 bool signB;
56 int_fast32_t expB;
57 uint_fast64_t sigB;
58 bool signZ;
59 uint_fast64_t magBits;
60 struct exp32_sig64 normExpSig;
61 int_fast32_t expZ;
62 struct uint128 sig128Z, uiZ;
63 uint_fast16_t uiZ64;
64 uint_fast64_t uiZ0;
65 union { struct extFloat80M s; extFloat80_t f; } uZ;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 uA.f = a;
70 uiA64 = uA.s.signExp;
71 uiA0 = uA.s.signif;
72 signA = signExtF80UI64( uiA64 );
73 expA = expExtF80UI64( uiA64 );
74 sigA = uiA0;
75 uB.f = b;
76 uiB64 = uB.s.signExp;
77 uiB0 = uB.s.signif;
78 signB = signExtF80UI64( uiB64 );
79 expB = expExtF80UI64( uiB64 );
80 sigB = uiB0;
81 signZ = signA ^ signB;
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( expA == 0x7FFF ) {
85 if (
86 (sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
87 || ((expB == 0x7FFF) && (sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
88 ) {
89 goto propagateNaN;
90 }
91 magBits = expB | sigB;
92 goto infArg;
93 }
94 if ( expB == 0x7FFF ) {
95 if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
96 magBits = expA | sigA;
97 goto infArg;
98 }
99 /*------------------------------------------------------------------------
100 *------------------------------------------------------------------------*/
101 if ( ! expA ) expA = 1;
102 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
103 if ( ! sigA ) goto zero;
104 normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
105 expA += normExpSig.exp;
106 sigA = normExpSig.sig;
107 }
108 if ( ! expB ) expB = 1;
109 if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
110 if ( ! sigB ) goto zero;
111 normExpSig = softfloat_normSubnormalExtF80Sig( sigB );
112 expB += normExpSig.exp;
113 sigB = normExpSig.sig;
114 }
115 /*------------------------------------------------------------------------
116 *------------------------------------------------------------------------*/
117 expZ = expA + expB - 0x3FFE;
118 sig128Z = softfloat_mul64To128( sigA, sigB );
119 if ( sig128Z.v64 < UINT64_C( 0x8000000000000000 ) ) {
120 --expZ;
121 sig128Z =
122 softfloat_add128(
123 sig128Z.v64, sig128Z.v0, sig128Z.v64, sig128Z.v0 );
124 }
125 return
126 softfloat_roundPackToExtF80(
127 signZ, expZ, sig128Z.v64, sig128Z.v0, extF80_roundingPrecision );
128 /*------------------------------------------------------------------------
129 *------------------------------------------------------------------------*/
130 propagateNaN:
131 uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
132 uiZ64 = uiZ.v64;
133 uiZ0 = uiZ.v0;
134 goto uiZ;
135 /*------------------------------------------------------------------------
136 *------------------------------------------------------------------------*/
137 infArg:
138 if ( ! magBits ) {
139 softfloat_raiseFlags( softfloat_flag_invalid );
140 uiZ64 = defaultNaNExtF80UI64;
141 uiZ0 = defaultNaNExtF80UI0;
142 } else {
143 uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
144 uiZ0 = UINT64_C( 0x8000000000000000 );
145 }
146 goto uiZ;
147 /*------------------------------------------------------------------------
148 *------------------------------------------------------------------------*/
149 zero:
150 uiZ64 = packToExtF80UI64( signZ, 0 );
151 uiZ0 = 0;
152 uiZ:
153 uZ.s.signExp = uiZ64;
154 uZ.s.signif = uiZ0;
155 return uZ.f;
156
157}
158
deps/SoftFloat-3d/source/extF80_rem.c deleted-225
......@@ -1,225 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t extF80_rem( extFloat80_t a, extFloat80_t b )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 bool signA;
50 int_fast32_t expA;
51 uint_fast64_t sigA;
52 union { struct extFloat80M s; extFloat80_t f; } uB;
53 uint_fast16_t uiB64;
54 uint_fast64_t uiB0;
55 int_fast32_t expB;
56 uint_fast64_t sigB;
57 struct exp32_sig64 normExpSig;
58 int_fast32_t expDiff;
59 struct uint128 rem, shiftedSigB;
60 uint_fast32_t q, recip32;
61 uint_fast64_t q64;
62 struct uint128 term, altRem, meanRem;
63 bool signRem;
64 struct uint128 uiZ;
65 uint_fast16_t uiZ64;
66 uint_fast64_t uiZ0;
67 union { struct extFloat80M s; extFloat80_t f; } uZ;
68
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 uA.f = a;
72 uiA64 = uA.s.signExp;
73 uiA0 = uA.s.signif;
74 signA = signExtF80UI64( uiA64 );
75 expA = expExtF80UI64( uiA64 );
76 sigA = uiA0;
77 uB.f = b;
78 uiB64 = uB.s.signExp;
79 uiB0 = uB.s.signif;
80 expB = expExtF80UI64( uiB64 );
81 sigB = uiB0;
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( expA == 0x7FFF ) {
85 if (
86 (sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
87 || ((expB == 0x7FFF) && (sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
88 ) {
89 goto propagateNaN;
90 }
91 goto invalid;
92 }
93 if ( expB == 0x7FFF ) {
94 if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
95 /*--------------------------------------------------------------------
96 | Argument b is an infinity. Doubling `expB' is an easy way to ensure
97 | that `expDiff' later is less than -1, which will result in returning
98 | a canonicalized version of argument a.
99 *--------------------------------------------------------------------*/
100 expB += expB;
101 }
102 /*------------------------------------------------------------------------
103 *------------------------------------------------------------------------*/
104 if ( ! expB ) expB = 1;
105 if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
106 if ( ! sigB ) goto invalid;
107 normExpSig = softfloat_normSubnormalExtF80Sig( sigB );
108 expB += normExpSig.exp;
109 sigB = normExpSig.sig;
110 }
111 if ( ! expA ) expA = 1;
112 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
113 if ( ! sigA ) {
114 expA = 0;
115 goto copyA;
116 }
117 normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
118 expA += normExpSig.exp;
119 sigA = normExpSig.sig;
120 }
121 /*------------------------------------------------------------------------
122 *------------------------------------------------------------------------*/
123 expDiff = expA - expB;
124 if ( expDiff < -1 ) goto copyA;
125 rem = softfloat_shortShiftLeft128( 0, sigA, 32 );
126 shiftedSigB = softfloat_shortShiftLeft128( 0, sigB, 32 );
127 if ( expDiff < 1 ) {
128 if ( expDiff ) {
129 --expB;
130 shiftedSigB = softfloat_shortShiftLeft128( 0, sigB, 33 );
131 q = 0;
132 } else {
133 q = (sigB <= sigA);
134 if ( q ) {
135 rem =
136 softfloat_sub128(
137 rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
138 }
139 }
140 } else {
141 recip32 = softfloat_approxRecip32_1( sigB>>32 );
142 expDiff -= 30;
143 for (;;) {
144 q64 = (uint_fast64_t) (uint32_t) (rem.v64>>2) * recip32;
145 if ( expDiff < 0 ) break;
146 q = (q64 + 0x80000000)>>32;
147 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
148 term = softfloat_mul64ByShifted32To128( sigB, q );
149 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
150 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
151 rem =
152 softfloat_add128(
153 rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
154 }
155 expDiff -= 29;
156 }
157 /*--------------------------------------------------------------------
158 | (`expDiff' cannot be less than -29 here.)
159 *--------------------------------------------------------------------*/
160 q = (uint32_t) (q64>>32)>>(~expDiff & 31);
161 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, expDiff + 30 );
162 term = softfloat_mul64ByShifted32To128( sigB, q );
163 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
164 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
165 altRem =
166 softfloat_add128(
167 rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
168 goto selectRem;
169 }
170 }
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 do {
174 altRem = rem;
175 ++q;
176 rem =
177 softfloat_sub128(
178 rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
179 } while ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) );
180 selectRem:
181 meanRem = softfloat_add128( rem.v64, rem.v0, altRem.v64, altRem.v0 );
182 if (
183 (meanRem.v64 & UINT64_C( 0x8000000000000000 ))
184 || (! (meanRem.v64 | meanRem.v0) && (q & 1))
185 ) {
186 rem = altRem;
187 }
188 signRem = signA;
189 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
190 signRem = ! signRem;
191 rem = softfloat_sub128( 0, 0, rem.v64, rem.v0 );
192 }
193 return
194 softfloat_normRoundPackToExtF80(
195 signRem, rem.v64 | rem.v0 ? expB + 32 : 0, rem.v64, rem.v0, 80 );
196 /*------------------------------------------------------------------------
197 *------------------------------------------------------------------------*/
198 propagateNaN:
199 uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
200 uiZ64 = uiZ.v64;
201 uiZ0 = uiZ.v0;
202 goto uiZ;
203 /*------------------------------------------------------------------------
204 *------------------------------------------------------------------------*/
205 invalid:
206 softfloat_raiseFlags( softfloat_flag_invalid );
207 uiZ64 = defaultNaNExtF80UI64;
208 uiZ0 = defaultNaNExtF80UI0;
209 goto uiZ;
210 /*------------------------------------------------------------------------
211 *------------------------------------------------------------------------*/
212 copyA:
213 if ( expA < 1 ) {
214 sigA >>= 1 - expA;
215 expA = 0;
216 }
217 uiZ64 = packToExtF80UI64( signA, expA );
218 uiZ0 = sigA;
219 uiZ:
220 uZ.s.signExp = uiZ64;
221 uZ.s.signif = uiZ0;
222 return uZ.f;
223
224}
225
deps/SoftFloat-3d/source/extF80_roundToInt.c deleted-147
......@@ -1,147 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t
45 extF80_roundToInt( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
46{
47 union { struct extFloat80M s; extFloat80_t f; } uA;
48 uint_fast16_t uiA64, signUI64;
49 int_fast32_t exp;
50 uint_fast64_t sigA;
51 uint_fast16_t uiZ64;
52 uint_fast64_t sigZ;
53 struct exp32_sig64 normExpSig;
54 struct uint128 uiZ;
55 uint_fast64_t lastBitMask, roundBitsMask;
56 union { struct extFloat80M s; extFloat80_t f; } uZ;
57
58 /*------------------------------------------------------------------------
59 *------------------------------------------------------------------------*/
60 uA.f = a;
61 uiA64 = uA.s.signExp;
62 signUI64 = uiA64 & packToExtF80UI64( 1, 0 );
63 exp = expExtF80UI64( uiA64 );
64 sigA = uA.s.signif;
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) && (exp != 0x7FFF) ) {
68 if ( ! sigA ) {
69 uiZ64 = signUI64;
70 sigZ = 0;
71 goto uiZ;
72 }
73 normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
74 exp += normExpSig.exp;
75 sigA = normExpSig.sig;
76 }
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 if ( 0x403E <= exp ) {
80 if ( exp == 0x7FFF ) {
81 if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
82 uiZ = softfloat_propagateNaNExtF80UI( uiA64, sigA, 0, 0 );
83 uiZ64 = uiZ.v64;
84 sigZ = uiZ.v0;
85 goto uiZ;
86 }
87 sigZ = UINT64_C( 0x8000000000000000 );
88 } else {
89 sigZ = sigA;
90 }
91 uiZ64 = signUI64 | exp;
92 goto uiZ;
93 }
94 if ( exp <= 0x3FFE ) {
95 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
96 switch ( roundingMode ) {
97 case softfloat_round_near_even:
98 if ( ! (sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) break;
99 case softfloat_round_near_maxMag:
100 if ( exp == 0x3FFE ) goto mag1;
101 break;
102 case softfloat_round_min:
103 if ( signUI64 ) goto mag1;
104 break;
105 case softfloat_round_max:
106 if ( ! signUI64 ) goto mag1;
107 break;
108 }
109 uiZ64 = signUI64;
110 sigZ = 0;
111 goto uiZ;
112 mag1:
113 uiZ64 = signUI64 | 0x3FFF;
114 sigZ = UINT64_C( 0x8000000000000000 );
115 goto uiZ;
116 }
117 /*------------------------------------------------------------------------
118 *------------------------------------------------------------------------*/
119 uiZ64 = signUI64 | exp;
120 lastBitMask = (uint_fast64_t) 1<<(0x403E - exp);
121 roundBitsMask = lastBitMask - 1;
122 sigZ = sigA;
123 if ( roundingMode == softfloat_round_near_maxMag ) {
124 sigZ += lastBitMask>>1;
125 } else if ( roundingMode == softfloat_round_near_even ) {
126 sigZ += lastBitMask>>1;
127 if ( ! (sigZ & roundBitsMask) ) sigZ &= ~lastBitMask;
128 } else if (
129 roundingMode == (signUI64 ? softfloat_round_min : softfloat_round_max)
130 ) {
131 sigZ += roundBitsMask;
132 }
133 sigZ &= ~roundBitsMask;
134 if ( ! sigZ ) {
135 ++uiZ64;
136 sigZ = UINT64_C( 0x8000000000000000 );
137 }
138 if ( exact && (sigZ != sigA) ) {
139 softfloat_exceptionFlags |= softfloat_flag_inexact;
140 }
141 uiZ:
142 uZ.s.signExp = uiZ64;
143 uZ.s.signif = sigZ;
144 return uZ.f;
145
146}
147
deps/SoftFloat-3d/source/extF80_sqrt.c deleted-176
......@@ -1,176 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t extF80_sqrt( extFloat80_t a )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 bool signA;
50 int_fast32_t expA;
51 uint_fast64_t sigA;
52 struct uint128 uiZ;
53 uint_fast16_t uiZ64;
54 uint_fast64_t uiZ0;
55 struct exp32_sig64 normExpSig;
56 int_fast32_t expZ;
57 uint_fast32_t sig32A, recipSqrt32, sig32Z;
58 struct uint128 rem;
59 uint_fast64_t q, x64, sigZ;
60 struct uint128 y, term;
61 uint_fast64_t sigZExtra;
62 union { struct extFloat80M s; extFloat80_t f; } uZ;
63
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 uA.f = a;
67 uiA64 = uA.s.signExp;
68 uiA0 = uA.s.signif;
69 signA = signExtF80UI64( uiA64 );
70 expA = expExtF80UI64( uiA64 );
71 sigA = uiA0;
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 if ( expA == 0x7FFF ) {
75 if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
76 uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, 0, 0 );
77 uiZ64 = uiZ.v64;
78 uiZ0 = uiZ.v0;
79 goto uiZ;
80 }
81 if ( ! signA ) return a;
82 goto invalid;
83 }
84 /*------------------------------------------------------------------------
85 *------------------------------------------------------------------------*/
86 if ( signA ) {
87 if ( ! sigA ) goto zero;
88 goto invalid;
89 }
90 /*------------------------------------------------------------------------
91 *------------------------------------------------------------------------*/
92 if ( ! expA ) expA = 1;
93 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
94 if ( ! sigA ) goto zero;
95 normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
96 expA += normExpSig.exp;
97 sigA = normExpSig.sig;
98 }
99 /*------------------------------------------------------------------------
100 | (`sig32Z' is guaranteed to be a lower bound on the square root of
101 | `sig32A', which makes `sig32Z' also a lower bound on the square root of
102 | `sigA'.)
103 *------------------------------------------------------------------------*/
104 expZ = ((expA - 0x3FFF)>>1) + 0x3FFF;
105 expA &= 1;
106 sig32A = sigA>>32;
107 recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
108 sig32Z = ((uint_fast64_t) sig32A * recipSqrt32)>>32;
109 if ( expA ) {
110 sig32Z >>= 1;
111 rem = softfloat_shortShiftLeft128( 0, sigA, 61 );
112 } else {
113 rem = softfloat_shortShiftLeft128( 0, sigA, 62 );
114 }
115 rem.v64 -= (uint_fast64_t) sig32Z * sig32Z;
116 /*------------------------------------------------------------------------
117 *------------------------------------------------------------------------*/
118 q = ((uint32_t) (rem.v64>>2) * (uint_fast64_t) recipSqrt32)>>32;
119 x64 = (uint_fast64_t) sig32Z<<32;
120 sigZ = x64 + (q<<3);
121 y = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
122 /*------------------------------------------------------------------------
123 | (Repeating this loop is a rare occurrence.)
124 *------------------------------------------------------------------------*/
125 for (;;) {
126 term = softfloat_mul64ByShifted32To128( x64 + sigZ, q );
127 rem = softfloat_sub128( y.v64, y.v0, term.v64, term.v0 );
128 if ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) ) break;
129 --q;
130 sigZ -= 1<<3;
131 }
132 /*------------------------------------------------------------------------
133 *------------------------------------------------------------------------*/
134 q = (((rem.v64>>2) * recipSqrt32)>>32) + 2;
135 x64 = sigZ;
136 sigZ = (sigZ<<1) + (q>>25);
137 sigZExtra = (uint64_t) (q<<39);
138 /*------------------------------------------------------------------------
139 *------------------------------------------------------------------------*/
140 if ( (q & 0xFFFFFF) <= 2 ) {
141 q &= ~(uint_fast64_t) 0xFFFF;
142 sigZExtra = (uint64_t) (q<<39);
143 term = softfloat_mul64ByShifted32To128( x64 + (q>>27), q );
144 x64 = (uint32_t) (q<<5) * (uint_fast64_t) (uint32_t) q;
145 term = softfloat_add128( term.v64, term.v0, 0, x64 );
146 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 28 );
147 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
148 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
149 if ( ! sigZExtra ) --sigZ;
150 --sigZExtra;
151 } else {
152 if ( rem.v64 | rem.v0 ) sigZExtra |= 1;
153 }
154 }
155 return
156 softfloat_roundPackToExtF80(
157 0, expZ, sigZ, sigZExtra, extF80_roundingPrecision );
158 /*------------------------------------------------------------------------
159 *------------------------------------------------------------------------*/
160 invalid:
161 softfloat_raiseFlags( softfloat_flag_invalid );
162 uiZ64 = defaultNaNExtF80UI64;
163 uiZ0 = defaultNaNExtF80UI0;
164 goto uiZ;
165 /*------------------------------------------------------------------------
166 *------------------------------------------------------------------------*/
167 zero:
168 uiZ64 = packToExtF80UI64( signA, 0 );
169 uiZ0 = 0;
170 uiZ:
171 uZ.s.signExp = uiZ64;
172 uZ.s.signif = uiZ0;
173 return uZ.f;
174
175}
176
deps/SoftFloat-3d/source/extF80_sub.c deleted-80
......@@ -1,80 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43extFloat80_t extF80_sub( extFloat80_t a, extFloat80_t b )
44{
45 union { struct extFloat80M s; extFloat80_t f; } uA;
46 uint_fast16_t uiA64;
47 uint_fast64_t uiA0;
48 bool signA;
49 union { struct extFloat80M s; extFloat80_t f; } uB;
50 uint_fast16_t uiB64;
51 uint_fast64_t uiB0;
52 bool signB;
53#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
54 extFloat80_t
55 (*magsFuncPtr)(
56 uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
57#endif
58
59 uA.f = a;
60 uiA64 = uA.s.signExp;
61 uiA0 = uA.s.signif;
62 signA = signExtF80UI64( uiA64 );
63 uB.f = b;
64 uiB64 = uB.s.signExp;
65 uiB0 = uB.s.signif;
66 signB = signExtF80UI64( uiB64 );
67#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
68 if ( signA == signB ) {
69 return softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
70 } else {
71 return softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
72 }
73#else
74 magsFuncPtr =
75 (signA == signB) ? softfloat_subMagsExtF80 : softfloat_addMagsExtF80;
76 return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
77#endif
78
79}
80
deps/SoftFloat-3d/source/extF80_to_f128.c deleted-75
......@@ -1,75 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t extF80_to_f128( extFloat80_t a )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 uint_fast16_t exp;
50 uint_fast64_t frac;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 bool sign;
54 struct uint128 frac128;
55 union ui128_f128 uZ;
56
57 uA.f = a;
58 uiA64 = uA.s.signExp;
59 uiA0 = uA.s.signif;
60 exp = expExtF80UI64( uiA64 );
61 frac = uiA0 & UINT64_C( 0x7FFFFFFFFFFFFFFF );
62 if ( (exp == 0x7FFF) && frac ) {
63 softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
64 uiZ = softfloat_commonNaNToF128UI( &commonNaN );
65 } else {
66 sign = signExtF80UI64( uiA64 );
67 frac128 = softfloat_shortShiftLeft128( 0, frac, 49 );
68 uiZ.v64 = packToF128UI64( sign, exp, frac128.v64 );
69 uiZ.v0 = frac128.v0;
70 }
71 uZ.ui = uiZ;
72 return uZ.f;
73
74}
75
deps/SoftFloat-3d/source/extF80_to_f16.c deleted-96
......@@ -1,96 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t extF80_to_f16( extFloat80_t a )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig;
52 struct commonNaN commonNaN;
53 uint_fast16_t uiZ, sig16;
54 union ui16_f16 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.s.signExp;
60 uiA0 = uA.s.signif;
61 sign = signExtF80UI64( uiA64 );
62 exp = expExtF80UI64( uiA64 );
63 sig = uiA0;
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 if ( exp == 0x7FFF ) {
67 if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
68 softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
69 uiZ = softfloat_commonNaNToF16UI( &commonNaN );
70 } else {
71 uiZ = packToF16UI( sign, 0x1F, 0 );
72 }
73 goto uiZ;
74 }
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 sig16 = softfloat_shortShiftRightJam64( sig, 49 );
78 if ( ! (exp | sig16) ) {
79 uiZ = packToF16UI( sign, 0, 0 );
80 goto uiZ;
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 exp -= 0x3FF1;
85 if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
86 if ( exp < -0x40 ) exp = -0x40;
87 }
88 return softfloat_roundPackToF16( sign, exp, sig16 );
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 uiZ:
92 uZ.ui = uiZ;
93 return uZ.f;
94
95}
96
deps/SoftFloat-3d/source/extF80_to_f32.c deleted-96
......@@ -1,96 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t extF80_to_f32( extFloat80_t a )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig;
52 struct commonNaN commonNaN;
53 uint_fast32_t uiZ, sig32;
54 union ui32_f32 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.s.signExp;
60 uiA0 = uA.s.signif;
61 sign = signExtF80UI64( uiA64 );
62 exp = expExtF80UI64( uiA64 );
63 sig = uiA0;
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 if ( exp == 0x7FFF ) {
67 if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
68 softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
69 uiZ = softfloat_commonNaNToF32UI( &commonNaN );
70 } else {
71 uiZ = packToF32UI( sign, 0xFF, 0 );
72 }
73 goto uiZ;
74 }
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 sig32 = softfloat_shortShiftRightJam64( sig, 33 );
78 if ( ! (exp | sig32) ) {
79 uiZ = packToF32UI( sign, 0, 0 );
80 goto uiZ;
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 exp -= 0x3F81;
85 if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
86 if ( exp < -0x1000 ) exp = -0x1000;
87 }
88 return softfloat_roundPackToF32( sign, exp, sig32 );
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 uiZ:
92 uZ.ui = uiZ;
93 return uZ.f;
94
95}
96
deps/SoftFloat-3d/source/extF80_to_f64.c deleted-96
......@@ -1,96 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t extF80_to_f64( extFloat80_t a )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig;
52 struct commonNaN commonNaN;
53 uint_fast64_t uiZ;
54 union ui64_f64 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.s.signExp;
60 uiA0 = uA.s.signif;
61 sign = signExtF80UI64( uiA64 );
62 exp = expExtF80UI64( uiA64 );
63 sig = uiA0;
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 if ( ! (exp | sig) ) {
67 uiZ = packToF64UI( sign, 0, 0 );
68 goto uiZ;
69 }
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 if ( exp == 0x7FFF ) {
73 if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
74 softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
75 uiZ = softfloat_commonNaNToF64UI( &commonNaN );
76 } else {
77 uiZ = packToF64UI( sign, 0x7FF, 0 );
78 }
79 goto uiZ;
80 }
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 sig = softfloat_shortShiftRightJam64( sig, 1 );
84 exp -= 0x3C01;
85 if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
86 if ( exp < -0x1000 ) exp = -0x1000;
87 }
88 return softfloat_roundPackToF64( sign, exp, sig );
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 uiZ:
92 uZ.ui = uiZ;
93 return uZ.f;
94
95}
96
deps/SoftFloat-3d/source/extF80_to_i32.c deleted-83
......@@ -1,83 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t
45 extF80_to_i32( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
46{
47 union { struct extFloat80M s; extFloat80_t f; } uA;
48 uint_fast16_t uiA64;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig;
52 int_fast32_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.s.signExp;
58 sign = signExtF80UI64( uiA64 );
59 exp = expExtF80UI64( uiA64 );
60 sig = uA.s.signif;
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
64 if ( (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) {
65#if (i32_fromNaN == i32_fromPosOverflow)
66 sign = 0;
67#elif (i32_fromNaN == i32_fromNegOverflow)
68 sign = 1;
69#else
70 softfloat_raiseFlags( softfloat_flag_invalid );
71 return i32_fromNaN;
72#endif
73 }
74#endif
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 shiftDist = 0x4032 - exp;
78 if ( shiftDist <= 0 ) shiftDist = 1;
79 sig = softfloat_shiftRightJam64( sig, shiftDist );
80 return softfloat_roundToI32( sign, sig, roundingMode, exact );
81
82}
83
deps/SoftFloat-3d/source/extF80_to_i32_r_minMag.c deleted-97
......@@ -1,97 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t extF80_to_i32_r_minMag( extFloat80_t a, bool exact )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 int_fast32_t exp;
49 uint_fast64_t sig;
50 int_fast32_t shiftDist;
51 bool sign;
52 int_fast32_t absZ;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.s.signExp;
58 exp = expExtF80UI64( uiA64 );
59 sig = uA.s.signif;
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x403E - exp;
63 if ( 64 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signExtF80UI64( uiA64 );
72 if ( shiftDist < 33 ) {
73 if (
74 (uiA64 == packToExtF80UI64( 1, 0x401E ))
75 && (sig < UINT64_C( 0x8000000100000000 ))
76 ) {
77 if ( exact && (sig & UINT64_C( 0x00000000FFFFFFFF )) ) {
78 softfloat_exceptionFlags |= softfloat_flag_inexact;
79 }
80 return -0x7FFFFFFF - 1;
81 }
82 softfloat_raiseFlags( softfloat_flag_invalid );
83 return
84 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
85 ? i32_fromNaN
86 : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 absZ = sig>>shiftDist;
91 if ( exact && ((uint_fast64_t) (uint_fast32_t) absZ<<shiftDist != sig) ) {
92 softfloat_exceptionFlags |= softfloat_flag_inexact;
93 }
94 return sign ? -absZ : absZ;
95
96}
97
deps/SoftFloat-3d/source/extF80_to_i64.c deleted-89
......@@ -1,89 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t
45 extF80_to_i64( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
46{
47 union { struct extFloat80M s; extFloat80_t f; } uA;
48 uint_fast16_t uiA64;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig;
52 int_fast32_t shiftDist;
53 uint_fast64_t sigExtra;
54 struct uint64_extra sig64Extra;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.s.signExp;
60 sign = signExtF80UI64( uiA64 );
61 exp = expExtF80UI64( uiA64 );
62 sig = uA.s.signif;
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 shiftDist = 0x403E - exp;
66 if ( shiftDist <= 0 ) {
67 /*--------------------------------------------------------------------
68 *--------------------------------------------------------------------*/
69 if ( shiftDist ) {
70 softfloat_raiseFlags( softfloat_flag_invalid );
71 return
72 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
73 ? i64_fromNaN
74 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
75 }
76 /*--------------------------------------------------------------------
77 *--------------------------------------------------------------------*/
78 sigExtra = 0;
79 } else {
80 /*--------------------------------------------------------------------
81 *--------------------------------------------------------------------*/
82 sig64Extra = softfloat_shiftRightJam64Extra( sig, 0, shiftDist );
83 sig = sig64Extra.v;
84 sigExtra = sig64Extra.extra;
85 }
86 return softfloat_roundToI64( sign, sig, sigExtra, roundingMode, exact );
87
88}
89
deps/SoftFloat-3d/source/extF80_to_i64_r_minMag.c deleted-94
......@@ -1,94 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t extF80_to_i64_r_minMag( extFloat80_t a, bool exact )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 int_fast32_t exp;
49 uint_fast64_t sig;
50 int_fast32_t shiftDist;
51 bool sign;
52 int_fast64_t absZ;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.s.signExp;
58 exp = expExtF80UI64( uiA64 );
59 sig = uA.s.signif;
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x403E - exp;
63 if ( 64 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signExtF80UI64( uiA64 );
72 if ( shiftDist <= 0 ) {
73 if (
74 (uiA64 == packToExtF80UI64( 1, 0x403E ))
75 && (sig == UINT64_C( 0x8000000000000000 ))
76 ) {
77 return -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
78 }
79 softfloat_raiseFlags( softfloat_flag_invalid );
80 return
81 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
82 ? i64_fromNaN
83 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 absZ = sig>>shiftDist;
88 if ( exact && (uint64_t) (sig<<(-shiftDist & 63)) ) {
89 softfloat_exceptionFlags |= softfloat_flag_inexact;
90 }
91 return sign ? -absZ : absZ;
92
93}
94
deps/SoftFloat-3d/source/extF80_to_ui32.c deleted-83
......@@ -1,83 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t
45 extF80_to_ui32( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
46{
47 union { struct extFloat80M s; extFloat80_t f; } uA;
48 uint_fast16_t uiA64;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig;
52 int_fast32_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.s.signExp;
58 sign = signExtF80UI64( uiA64 );
59 exp = expExtF80UI64( uiA64 );
60 sig = uA.s.signif;
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63#if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
64 if ( (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) {
65#if (ui32_fromNaN == ui32_fromPosOverflow)
66 sign = 0;
67#elif (ui32_fromNaN == ui32_fromNegOverflow)
68 sign = 1;
69#else
70 softfloat_raiseFlags( softfloat_flag_invalid );
71 return ui32_fromNaN;
72#endif
73 }
74#endif
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 shiftDist = 0x4032 - exp;
78 if ( shiftDist <= 0 ) shiftDist = 1;
79 sig = softfloat_shiftRightJam64( sig, shiftDist );
80 return softfloat_roundToUI32( sign, sig, roundingMode, exact );
81
82}
83
deps/SoftFloat-3d/source/extF80_to_ui32_r_minMag.c deleted-88
......@@ -1,88 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t extF80_to_ui32_r_minMag( extFloat80_t a, bool exact )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 int_fast32_t exp;
49 uint_fast64_t sig;
50 int_fast32_t shiftDist;
51 bool sign;
52 uint_fast32_t z;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.s.signExp;
58 exp = expExtF80UI64( uiA64 );
59 sig = uA.s.signif;
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x403E - exp;
63 if ( 64 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signExtF80UI64( uiA64 );
72 if ( sign || (shiftDist < 32) ) {
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 return
75 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
76 ? ui32_fromNaN
77 : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 z = sig>>shiftDist;
82 if ( exact && ((uint_fast64_t) z<<shiftDist != sig) ) {
83 softfloat_exceptionFlags |= softfloat_flag_inexact;
84 }
85 return z;
86
87}
88
deps/SoftFloat-3d/source/extF80_to_ui64.c deleted-84
......@@ -1,84 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t
45 extF80_to_ui64( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
46{
47 union { struct extFloat80M s; extFloat80_t f; } uA;
48 uint_fast16_t uiA64;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig;
52 int_fast32_t shiftDist;
53 uint_fast64_t sigExtra;
54 struct uint64_extra sig64Extra;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.s.signExp;
60 sign = signExtF80UI64( uiA64 );
61 exp = expExtF80UI64( uiA64 );
62 sig = uA.s.signif;
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 shiftDist = 0x403E - exp;
66 if ( shiftDist < 0 ) {
67 softfloat_raiseFlags( softfloat_flag_invalid );
68 return
69 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
70 ? ui64_fromNaN
71 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
72 }
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 sigExtra = 0;
76 if ( shiftDist ) {
77 sig64Extra = softfloat_shiftRightJam64Extra( sig, 0, shiftDist );
78 sig = sig64Extra.v;
79 sigExtra = sig64Extra.extra;
80 }
81 return softfloat_roundToUI64( sign, sig, sigExtra, roundingMode, exact );
82
83}
84
deps/SoftFloat-3d/source/extF80_to_ui64_r_minMag.c deleted-88
......@@ -1,88 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t extF80_to_ui64_r_minMag( extFloat80_t a, bool exact )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 int_fast32_t exp;
49 uint_fast64_t sig;
50 int_fast32_t shiftDist;
51 bool sign;
52 uint_fast64_t z;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.s.signExp;
58 exp = expExtF80UI64( uiA64 );
59 sig = uA.s.signif;
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x403E - exp;
63 if ( 64 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signExtF80UI64( uiA64 );
72 if ( sign || (shiftDist < 0) ) {
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 return
75 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
76 ? ui64_fromNaN
77 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 z = sig>>shiftDist;
82 if ( exact && (z<<shiftDist != sig) ) {
83 softfloat_exceptionFlags |= softfloat_flag_inexact;
84 }
85 return z;
86
87}
88
deps/SoftFloat-3d/source/f128M_add.c deleted-97
......@@ -1,97 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43#ifdef SOFTFLOAT_FAST_INT64
44
45void
46 f128M_add( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
47{
48 const uint64_t *aWPtr, *bWPtr;
49 uint_fast64_t uiA64, uiA0;
50 bool signA;
51 uint_fast64_t uiB64, uiB0;
52 bool signB;
53#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
54 float128_t
55 (*magsFuncPtr)(
56 uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
57#endif
58
59 aWPtr = (const uint64_t *) aPtr;
60 bWPtr = (const uint64_t *) bPtr;
61 uiA64 = aWPtr[indexWord( 2, 1 )];
62 uiA0 = aWPtr[indexWord( 2, 0 )];
63 signA = signF128UI64( uiA64 );
64 uiB64 = bWPtr[indexWord( 2, 1 )];
65 uiB0 = bWPtr[indexWord( 2, 0 )];
66 signB = signF128UI64( uiB64 );
67#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
68 if ( signA == signB ) {
69 *zPtr = softfloat_addMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
70 } else {
71 *zPtr = softfloat_subMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
72 }
73#else
74 magsFuncPtr =
75 (signA == signB) ? softfloat_addMagsF128 : softfloat_subMagsF128;
76 *zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
77#endif
78
79}
80
81#else
82
83void
84 f128M_add( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
85{
86
87 softfloat_addF128M(
88 (const uint32_t *) aPtr,
89 (const uint32_t *) bPtr,
90 (uint32_t *) zPtr,
91 false
92 );
93
94}
95
96#endif
97
deps/SoftFloat-3d/source/f128M_div.c deleted-187
......@@ -1,187 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void
47 f128M_div( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
48{
49
50 *zPtr = f128_div( *aPtr, *bPtr );
51
52}
53
54#else
55
56void
57 f128M_div( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
58{
59 const uint32_t *aWPtr, *bWPtr;
60 uint32_t *zWPtr, uiA96;
61 bool signA;
62 int32_t expA;
63 uint32_t uiB96;
64 bool signB;
65 int32_t expB;
66 bool signZ;
67 uint32_t y[5], sigB[4];
68 int32_t expZ;
69 uint32_t recip32;
70 int ix;
71 uint64_t q64;
72 uint32_t q, qs[3], uiZ96;
73
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 aWPtr = (const uint32_t *) aPtr;
77 bWPtr = (const uint32_t *) bPtr;
78 zWPtr = (uint32_t *) zPtr;
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 uiA96 = aWPtr[indexWordHi( 4 )];
82 signA = signF128UI96( uiA96 );
83 expA = expF128UI96( uiA96 );
84 uiB96 = bWPtr[indexWordHi( 4 )];
85 signB = signF128UI96( uiB96 );
86 expB = expF128UI96( uiB96 );
87 signZ = signA ^ signB;
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
91 if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
92 if ( expA == 0x7FFF ) {
93 if ( expB == 0x7FFF ) goto invalid;
94 goto infinity;
95 }
96 goto zero;
97 }
98 /*------------------------------------------------------------------------
99 *------------------------------------------------------------------------*/
100 expA = softfloat_shiftNormSigF128M( aWPtr, 13, y );
101 expB = softfloat_shiftNormSigF128M( bWPtr, 13, sigB );
102 if ( expA == -128 ) {
103 if ( expB == -128 ) goto invalid;
104 goto zero;
105 }
106 if ( expB == -128 ) {
107 softfloat_raiseFlags( softfloat_flag_infinite );
108 goto infinity;
109 }
110 /*------------------------------------------------------------------------
111 *------------------------------------------------------------------------*/
112 expZ = expA - expB + 0x3FFE;
113 if ( softfloat_compare128M( y, sigB ) < 0 ) {
114 --expZ;
115 softfloat_add128M( y, y, y );
116 }
117 recip32 =
118 softfloat_approxRecip32_1(
119 ((uint64_t) sigB[indexWord( 4, 3 )]<<32 | sigB[indexWord( 4, 2 )])
120 >>30
121 );
122 ix = 3;
123 for (;;) {
124 q64 = (uint64_t) y[indexWordHi( 4 )] * recip32;
125 q = (q64 + 0x80000000)>>32;
126 --ix;
127 if ( ix < 0 ) break;
128 softfloat_remStep128MBy32( y, 29, sigB, q, y );
129 if ( y[indexWordHi( 4 )] & 0x80000000 ) {
130 --q;
131 softfloat_add128M( y, sigB, y );
132 }
133 qs[ix] = q;
134 }
135 /*------------------------------------------------------------------------
136 *------------------------------------------------------------------------*/
137 if ( ((q + 1) & 7) < 2 ) {
138 softfloat_remStep128MBy32( y, 29, sigB, q, y );
139 if ( y[indexWordHi( 4 )] & 0x80000000 ) {
140 --q;
141 softfloat_add128M( y, sigB, y );
142 } else if ( softfloat_compare128M( sigB, y ) <= 0 ) {
143 ++q;
144 softfloat_sub128M( y, sigB, y );
145 }
146 if (
147 y[indexWordLo( 4 )] || y[indexWord( 4, 1 )]
148 || (y[indexWord( 4, 2 )] | y[indexWord( 4, 3 )])
149 ) {
150 q |= 1;
151 }
152 }
153 /*------------------------------------------------------------------------
154 *------------------------------------------------------------------------*/
155 q64 = (uint64_t) q<<28;
156 y[indexWord( 5, 0 )] = q64;
157 q64 = ((uint64_t) qs[0]<<25) + (q64>>32);
158 y[indexWord( 5, 1 )] = q64;
159 q64 = ((uint64_t) qs[1]<<22) + (q64>>32);
160 y[indexWord( 5, 2 )] = q64;
161 q64 = ((uint64_t) qs[2]<<19) + (q64>>32);
162 y[indexWord( 5, 3 )] = q64;
163 y[indexWord( 5, 4 )] = q64>>32;
164 softfloat_roundPackMToF128M( signZ, expZ, y, zWPtr );
165 return;
166 /*------------------------------------------------------------------------
167 *------------------------------------------------------------------------*/
168 invalid:
169 softfloat_invalidF128M( zWPtr );
170 return;
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 infinity:
174 uiZ96 = packToF128UI96( signZ, 0x7FFF, 0 );
175 goto uiZ96;
176 zero:
177 uiZ96 = packToF128UI96( signZ, 0, 0 );
178 uiZ96:
179 zWPtr[indexWordHi( 4 )] = uiZ96;
180 zWPtr[indexWord( 4, 2 )] = 0;
181 zWPtr[indexWord( 4, 1 )] = 0;
182 zWPtr[indexWord( 4, 0 )] = 0;
183
184}
185
186#endif
187
deps/SoftFloat-3d/source/f128M_eq.c deleted-100
......@@ -1,100 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46bool f128M_eq( const float128_t *aPtr, const float128_t *bPtr )
47{
48
49 return f128_eq( *aPtr, *bPtr );
50
51}
52
53#else
54
55bool f128M_eq( const float128_t *aPtr, const float128_t *bPtr )
56{
57 const uint32_t *aWPtr, *bWPtr;
58 uint32_t wordA, wordB, uiA96, uiB96;
59 bool possibleOppositeZeros;
60 uint32_t mashWord;
61
62 aWPtr = (const uint32_t *) aPtr;
63 bWPtr = (const uint32_t *) bPtr;
64 wordA = aWPtr[indexWord( 4, 2 )];
65 wordB = bWPtr[indexWord( 4, 2 )];
66 if ( wordA != wordB ) goto false_checkSigNaNs;
67 uiA96 = aWPtr[indexWordHi( 4 )];
68 uiB96 = bWPtr[indexWordHi( 4 )];
69 possibleOppositeZeros = false;
70 if ( uiA96 != uiB96 ) {
71 possibleOppositeZeros = (((uiA96 | uiB96) & 0x7FFFFFFF) == 0);
72 if ( ! possibleOppositeZeros ) goto false_checkSigNaNs;
73 }
74 mashWord = wordA | wordB;
75 wordA = aWPtr[indexWord( 4, 1 )];
76 wordB = bWPtr[indexWord( 4, 1 )];
77 if ( wordA != wordB ) goto false_checkSigNaNs;
78 mashWord |= wordA | wordB;
79 wordA = aWPtr[indexWord( 4, 0 )];
80 wordB = bWPtr[indexWord( 4, 0 )];
81 if ( wordA != wordB ) goto false_checkSigNaNs;
82 if ( possibleOppositeZeros && ((mashWord | wordA | wordB) != 0) ) {
83 goto false_checkSigNaNs;
84 }
85 if ( ! softfloat_isNaNF128M( aWPtr ) && ! softfloat_isNaNF128M( bWPtr ) ) {
86 return true;
87 }
88 false_checkSigNaNs:
89 if (
90 f128M_isSignalingNaN( (const float128_t *) aWPtr )
91 || f128M_isSignalingNaN( (const float128_t *) bWPtr )
92 ) {
93 softfloat_raiseFlags( softfloat_flag_invalid );
94 }
95 return false;
96
97}
98
99#endif
100
deps/SoftFloat-3d/source/f128M_eq_signaling.c deleted-92
......@@ -1,92 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46bool f128M_eq_signaling( const float128_t *aPtr, const float128_t *bPtr )
47{
48
49 return f128_eq_signaling( *aPtr, *bPtr );
50
51}
52
53#else
54
55bool f128M_eq_signaling( const float128_t *aPtr, const float128_t *bPtr )
56{
57 const uint32_t *aWPtr, *bWPtr;
58 uint32_t wordA, wordB, uiA96, uiB96;
59 bool possibleOppositeZeros;
60 uint32_t mashWord;
61
62 aWPtr = (const uint32_t *) aPtr;
63 bWPtr = (const uint32_t *) bPtr;
64 if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
65 softfloat_raiseFlags( softfloat_flag_invalid );
66 return false;
67 }
68 wordA = aWPtr[indexWord( 4, 2 )];
69 wordB = bWPtr[indexWord( 4, 2 )];
70 if ( wordA != wordB ) return false;
71 uiA96 = aWPtr[indexWordHi( 4 )];
72 uiB96 = bWPtr[indexWordHi( 4 )];
73 possibleOppositeZeros = false;
74 if ( uiA96 != uiB96 ) {
75 possibleOppositeZeros = (((uiA96 | uiB96) & 0x7FFFFFFF) == 0);
76 if ( ! possibleOppositeZeros ) return false;
77 }
78 mashWord = wordA | wordB;
79 wordA = aWPtr[indexWord( 4, 1 )];
80 wordB = bWPtr[indexWord( 4, 1 )];
81 if ( wordA != wordB ) return false;
82 mashWord |= wordA | wordB;
83 wordA = aWPtr[indexWord( 4, 0 )];
84 wordB = bWPtr[indexWord( 4, 0 )];
85 return
86 (wordA == wordB)
87 && (! possibleOppositeZeros || ((mashWord | wordA | wordB) == 0));
88
89}
90
91#endif
92
deps/SoftFloat-3d/source/f128M_le.c deleted-93
......@@ -1,93 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43#ifdef SOFTFLOAT_FAST_INT64
44
45bool f128M_le( const float128_t *aPtr, const float128_t *bPtr )
46{
47
48 return f128_le( *aPtr, *bPtr );
49
50}
51
52#else
53
54bool f128M_le( const float128_t *aPtr, const float128_t *bPtr )
55{
56 const uint32_t *aWPtr, *bWPtr;
57 uint32_t uiA96, uiB96;
58 bool signA, signB;
59 uint32_t wordA, wordB;
60
61 aWPtr = (const uint32_t *) aPtr;
62 bWPtr = (const uint32_t *) bPtr;
63 if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
64 softfloat_raiseFlags( softfloat_flag_invalid );
65 return false;
66 }
67 uiA96 = aWPtr[indexWordHi( 4 )];
68 uiB96 = bWPtr[indexWordHi( 4 )];
69 signA = signF128UI96( uiA96 );
70 signB = signF128UI96( uiB96 );
71 if ( signA != signB ) {
72 if ( signA ) return true;
73 if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return false;
74 wordA = aWPtr[indexWord( 4, 2 )];
75 wordB = bWPtr[indexWord( 4, 2 )];
76 if ( wordA | wordB ) return false;
77 wordA = aWPtr[indexWord( 4, 1 )];
78 wordB = bWPtr[indexWord( 4, 1 )];
79 if ( wordA | wordB ) return false;
80 wordA = aWPtr[indexWord( 4, 0 )];
81 wordB = bWPtr[indexWord( 4, 0 )];
82 return ((wordA | wordB) == 0);
83 }
84 if ( signA ) {
85 aWPtr = (const uint32_t *) bPtr;
86 bWPtr = (const uint32_t *) aPtr;
87 }
88 return (softfloat_compare128M( aWPtr, bWPtr ) <= 0);
89
90}
91
92#endif
93
deps/SoftFloat-3d/source/f128M_le_quiet.c deleted-96
......@@ -1,96 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46bool f128M_le_quiet( const float128_t *aPtr, const float128_t *bPtr )
47{
48
49 return f128_le_quiet( *aPtr, *bPtr );
50
51}
52
53#else
54
55bool f128M_le_quiet( const float128_t *aPtr, const float128_t *bPtr )
56{
57 const uint32_t *aWPtr, *bWPtr;
58 uint32_t uiA96, uiB96;
59 bool signA, signB;
60 uint32_t wordA, wordB;
61
62 aWPtr = (const uint32_t *) aPtr;
63 bWPtr = (const uint32_t *) bPtr;
64 if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
65 if ( f128M_isSignalingNaN( aPtr ) || f128M_isSignalingNaN( bPtr ) ) {
66 softfloat_raiseFlags( softfloat_flag_invalid );
67 }
68 return false;
69 }
70 uiA96 = aWPtr[indexWordHi( 4 )];
71 uiB96 = bWPtr[indexWordHi( 4 )];
72 signA = signF128UI96( uiA96 );
73 signB = signF128UI96( uiB96 );
74 if ( signA != signB ) {
75 if ( signA ) return true;
76 if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return false;
77 wordA = aWPtr[indexWord( 4, 2 )];
78 wordB = bWPtr[indexWord( 4, 2 )];
79 if ( wordA | wordB ) return false;
80 wordA = aWPtr[indexWord( 4, 1 )];
81 wordB = bWPtr[indexWord( 4, 1 )];
82 if ( wordA | wordB ) return false;
83 wordA = aWPtr[indexWord( 4, 0 )];
84 wordB = bWPtr[indexWord( 4, 0 )];
85 return ((wordA | wordB) == 0);
86 }
87 if ( signA ) {
88 aWPtr = (const uint32_t *) bPtr;
89 bWPtr = (const uint32_t *) aPtr;
90 }
91 return (softfloat_compare128M( aWPtr, bWPtr ) <= 0);
92
93}
94
95#endif
96
deps/SoftFloat-3d/source/f128M_lt.c deleted-93
......@@ -1,93 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43#ifdef SOFTFLOAT_FAST_INT64
44
45bool f128M_lt( const float128_t *aPtr, const float128_t *bPtr )
46{
47
48 return f128_lt( *aPtr, *bPtr );
49
50}
51
52#else
53
54bool f128M_lt( const float128_t *aPtr, const float128_t *bPtr )
55{
56 const uint32_t *aWPtr, *bWPtr;
57 uint32_t uiA96, uiB96;
58 bool signA, signB;
59 uint32_t wordA, wordB;
60
61 aWPtr = (const uint32_t *) aPtr;
62 bWPtr = (const uint32_t *) bPtr;
63 if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
64 softfloat_raiseFlags( softfloat_flag_invalid );
65 return false;
66 }
67 uiA96 = aWPtr[indexWordHi( 4 )];
68 uiB96 = bWPtr[indexWordHi( 4 )];
69 signA = signF128UI96( uiA96 );
70 signB = signF128UI96( uiB96 );
71 if ( signA != signB ) {
72 if ( signB ) return false;
73 if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return true;
74 wordA = aWPtr[indexWord( 4, 2 )];
75 wordB = bWPtr[indexWord( 4, 2 )];
76 if ( wordA | wordB ) return true;
77 wordA = aWPtr[indexWord( 4, 1 )];
78 wordB = bWPtr[indexWord( 4, 1 )];
79 if ( wordA | wordB ) return true;
80 wordA = aWPtr[indexWord( 4, 0 )];
81 wordB = bWPtr[indexWord( 4, 0 )];
82 return ((wordA | wordB) != 0);
83 }
84 if ( signA ) {
85 aWPtr = (const uint32_t *) bPtr;
86 bWPtr = (const uint32_t *) aPtr;
87 }
88 return (softfloat_compare128M( aWPtr, bWPtr ) < 0);
89
90}
91
92#endif
93
deps/SoftFloat-3d/source/f128M_lt_quiet.c deleted-96
......@@ -1,96 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46bool f128M_lt_quiet( const float128_t *aPtr, const float128_t *bPtr )
47{
48
49 return f128_lt_quiet( *aPtr, *bPtr );
50
51}
52
53#else
54
55bool f128M_lt_quiet( const float128_t *aPtr, const float128_t *bPtr )
56{
57 const uint32_t *aWPtr, *bWPtr;
58 uint32_t uiA96, uiB96;
59 bool signA, signB;
60 uint32_t wordA, wordB;
61
62 aWPtr = (const uint32_t *) aPtr;
63 bWPtr = (const uint32_t *) bPtr;
64 if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
65 if ( f128M_isSignalingNaN( aPtr ) || f128M_isSignalingNaN( bPtr ) ) {
66 softfloat_raiseFlags( softfloat_flag_invalid );
67 }
68 return false;
69 }
70 uiA96 = aWPtr[indexWordHi( 4 )];
71 uiB96 = bWPtr[indexWordHi( 4 )];
72 signA = signF128UI96( uiA96 );
73 signB = signF128UI96( uiB96 );
74 if ( signA != signB ) {
75 if ( signB ) return false;
76 if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return true;
77 wordA = aWPtr[indexWord( 4, 2 )];
78 wordB = bWPtr[indexWord( 4, 2 )];
79 if ( wordA | wordB ) return true;
80 wordA = aWPtr[indexWord( 4, 1 )];
81 wordB = bWPtr[indexWord( 4, 1 )];
82 if ( wordA | wordB ) return true;
83 wordA = aWPtr[indexWord( 4, 0 )];
84 wordB = bWPtr[indexWord( 4, 0 )];
85 return ((wordA | wordB) != 0);
86 }
87 if ( signA ) {
88 aWPtr = (const uint32_t *) bPtr;
89 bWPtr = (const uint32_t *) aPtr;
90 }
91 return (softfloat_compare128M( aWPtr, bWPtr ) < 0);
92
93}
94
95#endif
96
deps/SoftFloat-3d/source/f128M_mul.c deleted-158
......@@ -1,158 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void
47 f128M_mul( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
48{
49
50 *zPtr = f128_mul( *aPtr, *bPtr );
51
52}
53
54#else
55
56void
57 f128M_mul( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
58{
59 const uint32_t *aWPtr, *bWPtr;
60 uint32_t *zWPtr;
61 uint32_t uiA96;
62 int32_t expA;
63 uint32_t uiB96;
64 int32_t expB;
65 bool signZ;
66 const uint32_t *ptr;
67 uint32_t uiZ96, sigA[4];
68 uint_fast8_t shiftDist;
69 uint32_t sigB[4];
70 int32_t expZ;
71 uint32_t sigProd[8], *extSigZPtr;
72
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 aWPtr = (const uint32_t *) aPtr;
76 bWPtr = (const uint32_t *) bPtr;
77 zWPtr = (uint32_t *) zPtr;
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 uiA96 = aWPtr[indexWordHi( 4 )];
81 expA = expF128UI96( uiA96 );
82 uiB96 = bWPtr[indexWordHi( 4 )];
83 expB = expF128UI96( uiB96 );
84 signZ = signF128UI96( uiA96 ) ^ signF128UI96( uiB96 );
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
88 if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
89 ptr = aWPtr;
90 if ( ! expA ) goto possiblyInvalid;
91 if ( ! expB ) {
92 ptr = bWPtr;
93 possiblyInvalid:
94 if (
95 ! fracF128UI96( ptr[indexWordHi( 4 )] )
96 && ! (ptr[indexWord( 4, 2 )] | ptr[indexWord( 4, 1 )]
97 | ptr[indexWord( 4, 0 )])
98 ) {
99 softfloat_invalidF128M( zWPtr );
100 return;
101 }
102 }
103 uiZ96 = packToF128UI96( signZ, 0x7FFF, 0 );
104 goto uiZ96;
105 }
106 /*------------------------------------------------------------------------
107 *------------------------------------------------------------------------*/
108 if ( expA ) {
109 sigA[indexWordHi( 4 )] = fracF128UI96( uiA96 ) | 0x00010000;
110 sigA[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
111 sigA[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
112 sigA[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
113 } else {
114 expA = softfloat_shiftNormSigF128M( aWPtr, 0, sigA );
115 if ( expA == -128 ) goto zero;
116 }
117 if ( expB ) {
118 sigB[indexWordHi( 4 )] = fracF128UI96( uiB96 ) | 0x00010000;
119 sigB[indexWord( 4, 2 )] = bWPtr[indexWord( 4, 2 )];
120 sigB[indexWord( 4, 1 )] = bWPtr[indexWord( 4, 1 )];
121 sigB[indexWord( 4, 0 )] = bWPtr[indexWord( 4, 0 )];
122 } else {
123 expB = softfloat_shiftNormSigF128M( bWPtr, 0, sigB );
124 if ( expB == -128 ) goto zero;
125 }
126 /*------------------------------------------------------------------------
127 *------------------------------------------------------------------------*/
128 expZ = expA + expB - 0x4000;
129 softfloat_mul128MTo256M( sigA, sigB, sigProd );
130 if (
131 sigProd[indexWord( 8, 2 )]
132 || (sigProd[indexWord( 8, 1 )] | sigProd[indexWord( 8, 0 )])
133 ) {
134 sigProd[indexWord( 8, 3 )] |= 1;
135 }
136 extSigZPtr = &sigProd[indexMultiwordHi( 8, 5 )];
137 shiftDist = 16;
138 if ( extSigZPtr[indexWordHi( 5 )] & 2 ) {
139 ++expZ;
140 shiftDist = 15;
141 }
142 softfloat_shortShiftLeft160M( extSigZPtr, shiftDist, extSigZPtr );
143 softfloat_roundPackMToF128M( signZ, expZ, extSigZPtr, zWPtr );
144 return;
145 /*------------------------------------------------------------------------
146 *------------------------------------------------------------------------*/
147 zero:
148 uiZ96 = packToF128UI96( signZ, 0, 0 );
149 uiZ96:
150 zWPtr[indexWordHi( 4 )] = uiZ96;
151 zWPtr[indexWord( 4, 2 )] = 0;
152 zWPtr[indexWord( 4, 1 )] = 0;
153 zWPtr[indexWord( 4, 0 )] = 0;
154
155}
156
157#endif
158
deps/SoftFloat-3d/source/f128M_mulAdd.c deleted-92
......@@ -1,92 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void
45 f128M_mulAdd(
46 const float128_t *aPtr,
47 const float128_t *bPtr,
48 const float128_t *cPtr,
49 float128_t *zPtr
50 )
51{
52 const uint64_t *aWPtr, *bWPtr, *cWPtr;
53 uint_fast64_t uiA64, uiA0;
54 uint_fast64_t uiB64, uiB0;
55 uint_fast64_t uiC64, uiC0;
56
57 aWPtr = (const uint64_t *) aPtr;
58 bWPtr = (const uint64_t *) bPtr;
59 cWPtr = (const uint64_t *) cPtr;
60 uiA64 = aWPtr[indexWord( 2, 1 )];
61 uiA0 = aWPtr[indexWord( 2, 0 )];
62 uiB64 = bWPtr[indexWord( 2, 1 )];
63 uiB0 = bWPtr[indexWord( 2, 0 )];
64 uiC64 = cWPtr[indexWord( 2, 1 )];
65 uiC0 = cWPtr[indexWord( 2, 0 )];
66 *zPtr = softfloat_mulAddF128( uiA64, uiA0, uiB64, uiB0, uiC64, uiC0, 0 );
67
68}
69
70#else
71
72void
73 f128M_mulAdd(
74 const float128_t *aPtr,
75 const float128_t *bPtr,
76 const float128_t *cPtr,
77 float128_t *zPtr
78 )
79{
80
81 softfloat_mulAddF128M(
82 (const uint32_t *) aPtr,
83 (const uint32_t *) bPtr,
84 (const uint32_t *) cPtr,
85 (uint32_t *) zPtr,
86 0
87 );
88
89}
90
91#endif
92
deps/SoftFloat-3d/source/f128M_rem.c deleted-182
......@@ -1,182 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void
47 f128M_rem( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
48{
49
50 *zPtr = f128_rem( *aPtr, *bPtr );
51
52}
53
54#else
55
56void
57 f128M_rem( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
58{
59 const uint32_t *aWPtr, *bWPtr;
60 uint32_t *zWPtr, uiA96;
61 int32_t expA, expB;
62 uint32_t x[4], rem1[5], *remPtr;
63 bool signRem;
64 int32_t expDiff;
65 uint32_t q, recip32;
66 uint64_t q64;
67 uint32_t rem2[5], *altRemPtr, *newRemPtr, wordMeanRem;
68
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 aWPtr = (const uint32_t *) aPtr;
72 bWPtr = (const uint32_t *) bPtr;
73 zWPtr = (uint32_t *) zPtr;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 uiA96 = aWPtr[indexWordHi( 4 )];
77 expA = expF128UI96( uiA96 );
78 expB = expF128UI96( bWPtr[indexWordHi( 4 )] );
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
82 if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
83 if ( expA == 0x7FFF ) goto invalid;
84 goto copyA;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 if ( expA < expB - 1 ) goto copyA;
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 expB = softfloat_shiftNormSigF128M( bWPtr, 13, x );
92 if ( expB == -128 ) goto invalid;
93 remPtr = &rem1[indexMultiwordLo( 5, 4 )];
94 expA = softfloat_shiftNormSigF128M( aWPtr, 13, remPtr );
95 if ( expA == -128 ) goto copyA;
96 signRem = signF128UI96( uiA96 );
97 /*------------------------------------------------------------------------
98 *------------------------------------------------------------------------*/
99 expDiff = expA - expB;
100 if ( expDiff < 1 ) {
101 if ( expDiff < -1 ) goto copyA;
102 if ( expDiff ) {
103 --expB;
104 softfloat_add128M( x, x, x );
105 q = 0;
106 } else {
107 q = (softfloat_compare128M( x, remPtr ) <= 0);
108 if ( q ) softfloat_sub128M( remPtr, x, remPtr );
109 }
110 } else {
111 recip32 =
112 softfloat_approxRecip32_1(
113 ((uint64_t) x[indexWord( 4, 3 )]<<32 | x[indexWord( 4, 2 )])
114 >>30
115 );
116 expDiff -= 30;
117 for (;;) {
118 q64 = (uint64_t) remPtr[indexWordHi( 4 )] * recip32;
119 if ( expDiff < 0 ) break;
120 q = (q64 + 0x80000000)>>32;
121 softfloat_remStep128MBy32( remPtr, 29, x, q, remPtr );
122 if ( remPtr[indexWordHi( 4 )] & 0x80000000 ) {
123 softfloat_add128M( remPtr, x, remPtr );
124 }
125 expDiff -= 29;
126 }
127 /*--------------------------------------------------------------------
128 | (`expDiff' cannot be less than -29 here.)
129 *--------------------------------------------------------------------*/
130 q = (uint32_t) (q64>>32)>>(~expDiff & 31);
131 softfloat_remStep128MBy32( remPtr, expDiff + 30, x, q, remPtr );
132 if ( remPtr[indexWordHi( 4 )] & 0x80000000 ) {
133 altRemPtr = &rem2[indexMultiwordLo( 5, 4 )];
134 softfloat_add128M( remPtr, x, altRemPtr );
135 goto selectRem;
136 }
137 }
138 /*------------------------------------------------------------------------
139 *------------------------------------------------------------------------*/
140 altRemPtr = &rem2[indexMultiwordLo( 5, 4 )];
141 do {
142 ++q;
143 newRemPtr = altRemPtr;
144 softfloat_sub128M( remPtr, x, newRemPtr );
145 altRemPtr = remPtr;
146 remPtr = newRemPtr;
147 } while ( ! (remPtr[indexWordHi( 4 )] & 0x80000000) );
148 selectRem:
149 softfloat_add128M( remPtr, altRemPtr, x );
150 wordMeanRem = x[indexWordHi( 4 )];
151 if (
152 (wordMeanRem & 0x80000000)
153 || (! wordMeanRem && (q & 1) && ! x[indexWord( 4, 0 )]
154 && ! (x[indexWord( 4, 2 )] | x[indexWord( 4, 1 )]))
155 ) {
156 remPtr = altRemPtr;
157 }
158 if ( remPtr[indexWordHi( 4 )] & 0x80000000 ) {
159 signRem = ! signRem;
160 softfloat_negX128M( remPtr );
161 }
162 remPtr -= indexMultiwordLo( 5, 4 );
163 remPtr[indexWordHi( 5 )] = 0;
164 softfloat_normRoundPackMToF128M( signRem, expB + 18, remPtr, zWPtr );
165 return;
166 /*------------------------------------------------------------------------
167 *------------------------------------------------------------------------*/
168 invalid:
169 softfloat_invalidF128M( zWPtr );
170 return;
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 copyA:
174 zWPtr[indexWordHi( 4 )] = uiA96;
175 zWPtr[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
176 zWPtr[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
177 zWPtr[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
178
179}
180
181#endif
182
deps/SoftFloat-3d/source/f128M_roundToInt.c deleted-216
......@@ -1,216 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void
47 f128M_roundToInt(
48 const float128_t *aPtr,
49 uint_fast8_t roundingMode,
50 bool exact,
51 float128_t *zPtr
52 )
53{
54
55 *zPtr = f128_roundToInt( *aPtr, roundingMode, exact );
56
57}
58
59#else
60
61void
62 f128M_roundToInt(
63 const float128_t *aPtr,
64 uint_fast8_t roundingMode,
65 bool exact,
66 float128_t *zPtr
67 )
68{
69 const uint32_t *aWPtr;
70 uint32_t *zWPtr;
71 uint32_t ui96;
72 int32_t exp;
73 uint32_t sigExtra;
74 bool sign;
75 uint_fast8_t bitPos;
76 bool roundNear;
77 unsigned int index, lastIndex;
78 bool extra;
79 uint32_t wordA, bit, wordZ;
80 uint_fast8_t carry;
81 uint32_t extrasMask;
82
83 /*------------------------------------------------------------------------
84 *------------------------------------------------------------------------*/
85 aWPtr = (const uint32_t *) aPtr;
86 zWPtr = (uint32_t *) zPtr;
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 ui96 = aWPtr[indexWordHi( 4 )];
90 exp = expF128UI96( ui96 );
91 /*------------------------------------------------------------------------
92 *------------------------------------------------------------------------*/
93 if ( exp < 0x3FFF ) {
94 zWPtr[indexWord( 4, 2 )] = 0;
95 zWPtr[indexWord( 4, 1 )] = 0;
96 zWPtr[indexWord( 4, 0 )] = 0;
97 sigExtra = aWPtr[indexWord( 4, 2 )];
98 if ( ! sigExtra ) {
99 sigExtra = aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )];
100 }
101 if ( ! sigExtra && ! (ui96 & 0x7FFFFFFF) ) goto ui96;
102 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
103 sign = signF128UI96( ui96 );
104 switch ( roundingMode ) {
105 case softfloat_round_near_even:
106 if ( ! fracF128UI96( ui96 ) && ! sigExtra ) break;
107 case softfloat_round_near_maxMag:
108 if ( exp == 0x3FFE ) goto mag1;
109 break;
110 case softfloat_round_min:
111 if ( sign ) goto mag1;
112 break;
113 case softfloat_round_max:
114 if ( ! sign ) goto mag1;
115 break;
116 }
117 ui96 = packToF128UI96( sign, 0, 0 );
118 goto ui96;
119 mag1:
120 ui96 = packToF128UI96( sign, 0x3FFF, 0 );
121 goto ui96;
122 }
123 /*------------------------------------------------------------------------
124 *------------------------------------------------------------------------*/
125 if ( 0x406F <= exp ) {
126 if (
127 (exp == 0x7FFF)
128 && (fracF128UI96( ui96 )
129 || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
130 | aWPtr[indexWord( 4, 0 )]))
131 ) {
132 softfloat_propagateNaNF128M( aWPtr, 0, zWPtr );
133 return;
134 }
135 zWPtr[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
136 zWPtr[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
137 zWPtr[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
138 goto ui96;
139 }
140 /*------------------------------------------------------------------------
141 *------------------------------------------------------------------------*/
142 bitPos = 0x406F - exp;
143 roundNear =
144 (roundingMode == softfloat_round_near_maxMag)
145 || (roundingMode == softfloat_round_near_even);
146 bitPos -= roundNear;
147 index = indexWordLo( 4 );
148 lastIndex = indexWordHi( 4 );
149 extra = 0;
150 for (;;) {
151 wordA = aWPtr[index];
152 if ( bitPos < 32 ) break;
153 if ( wordA ) extra = 1;
154 zWPtr[index] = 0;
155 index += wordIncr;
156 bitPos -= 32;
157 }
158 bit = (uint32_t) 1<<bitPos;
159 if ( roundNear ) {
160 wordZ = wordA + bit;
161 carry = (wordZ < wordA);
162 bit <<= 1;
163 extrasMask = bit - 1;
164 if (
165 (roundingMode == softfloat_round_near_even)
166 && ! extra && ! (wordZ & extrasMask)
167 ) {
168 if ( ! bit ) {
169 zWPtr[index] = wordZ;
170 index += wordIncr;
171 wordZ = aWPtr[index] + carry;
172 carry &= ! wordZ;
173 zWPtr[index] = wordZ & ~1;
174 goto propagateCarry;
175 }
176 wordZ &= ~bit;
177 }
178 } else {
179 extrasMask = bit - 1;
180 wordZ = wordA;
181 carry = 0;
182 if (
183 roundingMode
184 == (signF128UI96( ui96 ) ? softfloat_round_min
185 : softfloat_round_max)
186 ) {
187 if ( extra || (wordA & extrasMask) ) {
188 wordZ += bit;
189 carry = (wordZ < wordA);
190 }
191 }
192 }
193 wordZ &= ~extrasMask;
194 zWPtr[index] = wordZ;
195 propagateCarry:
196 while ( index != lastIndex ) {
197 index += wordIncr;
198 wordZ = aWPtr[index] + carry;
199 zWPtr[index] = wordZ;
200 carry &= ! wordZ;
201 }
202 /*------------------------------------------------------------------------
203 *------------------------------------------------------------------------*/
204 if ( exact && (softfloat_compare128M( aWPtr, zWPtr ) != 0) ) {
205 softfloat_exceptionFlags |= softfloat_flag_inexact;
206 }
207 return;
208 /*------------------------------------------------------------------------
209 *------------------------------------------------------------------------*/
210 ui96:
211 zWPtr[indexWordHi( 4 )] = ui96;
212
213}
214
215#endif
216
deps/SoftFloat-3d/source/f128M_sqrt.c deleted-228
......@@ -1,228 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void f128M_sqrt( const float128_t *aPtr, float128_t *zPtr )
47{
48
49 *zPtr = f128_sqrt( *aPtr );
50
51}
52
53#else
54
55void f128M_sqrt( const float128_t *aPtr, float128_t *zPtr )
56{
57 const uint32_t *aWPtr;
58 uint32_t *zWPtr;
59 uint32_t uiA96;
60 bool signA;
61 int32_t rawExpA;
62 uint32_t rem[6];
63 int32_t expA, expZ;
64 uint64_t rem64;
65 uint32_t sig32A, recipSqrt32, sig32Z, qs[3], q;
66 uint64_t sig64Z;
67 uint32_t term[5];
68 uint64_t x64;
69 uint32_t y[5], rem32;
70
71 /*------------------------------------------------------------------------
72 *------------------------------------------------------------------------*/
73 aWPtr = (const uint32_t *) aPtr;
74 zWPtr = (uint32_t *) zPtr;
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 uiA96 = aWPtr[indexWordHi( 4 )];
78 signA = signF128UI96( uiA96 );
79 rawExpA = expF128UI96( uiA96 );
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 if ( rawExpA == 0x7FFF ) {
83 if (
84 fracF128UI96( uiA96 )
85 || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
86 | aWPtr[indexWord( 4, 0 )])
87 ) {
88 softfloat_propagateNaNF128M( aWPtr, 0, zWPtr );
89 return;
90 }
91 if ( ! signA ) goto copyA;
92 goto invalid;
93 }
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 expA = softfloat_shiftNormSigF128M( aWPtr, 13 - (rawExpA & 1), rem );
97 if ( expA == -128 ) goto copyA;
98 if ( signA ) goto invalid;
99 /*------------------------------------------------------------------------
100 | (`sig32Z' is guaranteed to be a lower bound on the square root of
101 | `sig32A', which makes `sig32Z' also a lower bound on the square root of
102 | `sigA'.)
103 *------------------------------------------------------------------------*/
104 expZ = ((expA - 0x3FFF)>>1) + 0x3FFE;
105 expA &= 1;
106 rem64 = (uint64_t) rem[indexWord( 4, 3 )]<<32 | rem[indexWord( 4, 2 )];
107 if ( expA ) {
108 if ( ! rawExpA ) {
109 softfloat_shortShiftRight128M( rem, 1, rem );
110 rem64 >>= 1;
111 }
112 sig32A = rem64>>29;
113 } else {
114 sig32A = rem64>>30;
115 }
116 recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
117 sig32Z = ((uint64_t) sig32A * recipSqrt32)>>32;
118 if ( expA ) sig32Z >>= 1;
119 qs[2] = sig32Z;
120 rem64 -= (uint64_t) sig32Z * sig32Z;
121 rem[indexWord( 4, 3 )] = rem64>>32;
122 rem[indexWord( 4, 2 )] = rem64;
123 /*------------------------------------------------------------------------
124 *------------------------------------------------------------------------*/
125 q = ((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32;
126 sig64Z = ((uint64_t) sig32Z<<32) + ((uint64_t) q<<3);
127 term[indexWord( 4, 3 )] = 0;
128 term[indexWord( 4, 0 )] = 0;
129 /*------------------------------------------------------------------------
130 | (Repeating this loop is a rare occurrence.)
131 *------------------------------------------------------------------------*/
132 for (;;) {
133 x64 = ((uint64_t) sig32Z<<32) + sig64Z;
134 term[indexWord( 4, 2 )] = x64>>32;
135 term[indexWord( 4, 1 )] = x64;
136 softfloat_remStep128MBy32( rem, 29, term, q, y );
137 rem32 = y[indexWord( 4, 3 )];
138 if ( ! (rem32 & 0x80000000) ) break;
139 --q;
140 sig64Z -= 1<<3;
141 }
142 qs[1] = q;
143 rem64 = (uint64_t) rem32<<32 | y[indexWord( 4, 2 )];
144 /*------------------------------------------------------------------------
145 *------------------------------------------------------------------------*/
146 q = ((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32;
147 if ( rem64>>34 ) q += recipSqrt32;
148 sig64Z <<= 1;
149 /*------------------------------------------------------------------------
150 | (Repeating this loop is a rare occurrence.)
151 *------------------------------------------------------------------------*/
152 for (;;) {
153 x64 = sig64Z + (q>>26);
154 term[indexWord( 4, 2 )] = x64>>32;
155 term[indexWord( 4, 1 )] = x64;
156 term[indexWord( 4, 0 )] = q<<6;
157 softfloat_remStep128MBy32(
158 y, 29, term, q, &rem[indexMultiwordHi( 6, 4 )] );
159 rem32 = rem[indexWordHi( 6 )];
160 if ( ! (rem32 & 0x80000000) ) break;
161 --q;
162 }
163 qs[0] = q;
164 rem64 = (uint64_t) rem32<<32 | rem[indexWord( 6, 4 )];
165 /*------------------------------------------------------------------------
166 *------------------------------------------------------------------------*/
167 q = (((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32) + 2;
168 if ( rem64>>34 ) q += recipSqrt32;
169 x64 = (uint64_t) q<<27;
170 y[indexWord( 5, 0 )] = x64;
171 x64 = ((uint64_t) qs[0]<<24) + (x64>>32);
172 y[indexWord( 5, 1 )] = x64;
173 x64 = ((uint64_t) qs[1]<<21) + (x64>>32);
174 y[indexWord( 5, 2 )] = x64;
175 x64 = ((uint64_t) qs[2]<<18) + (x64>>32);
176 y[indexWord( 5, 3 )] = x64;
177 y[indexWord( 5, 4 )] = x64>>32;
178 /*------------------------------------------------------------------------
179 *------------------------------------------------------------------------*/
180 if ( (q & 0xF) <= 2 ) {
181 q &= ~3;
182 y[indexWordLo( 5 )] = q<<27;
183 term[indexWord( 5, 4 )] = 0;
184 term[indexWord( 5, 3 )] = 0;
185 term[indexWord( 5, 2 )] = 0;
186 term[indexWord( 5, 1 )] = q>>6;
187 term[indexWord( 5, 0 )] = q<<26;
188 softfloat_sub160M( y, term, term );
189 rem[indexWord( 6, 1 )] = 0;
190 rem[indexWord( 6, 0 )] = 0;
191 softfloat_remStep160MBy32(
192 &rem[indexMultiwordLo( 6, 5 )],
193 14,
194 term,
195 q,
196 &rem[indexMultiwordLo( 6, 5 )]
197 );
198 rem32 = rem[indexWord( 6, 4 )];
199 if ( rem32 & 0x80000000 ) {
200 softfloat_sub1X160M( y );
201 } else {
202 if (
203 rem32 || rem[indexWord( 6, 0 )] || rem[indexWord( 6, 1 )]
204 || (rem[indexWord( 6, 3 )] | rem[indexWord( 6, 2 )])
205 ) {
206 y[indexWordLo( 5 )] |= 1;
207 }
208 }
209 }
210 softfloat_roundPackMToF128M( 0, expZ, y, zWPtr );
211 return;
212 /*------------------------------------------------------------------------
213 *------------------------------------------------------------------------*/
214 invalid:
215 softfloat_invalidF128M( zWPtr );
216 return;
217 /*------------------------------------------------------------------------
218 *------------------------------------------------------------------------*/
219 copyA:
220 zWPtr[indexWordHi( 4 )] = uiA96;
221 zWPtr[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
222 zWPtr[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
223 zWPtr[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
224
225}
226
227#endif
228
deps/SoftFloat-3d/source/f128M_sub.c deleted-97
......@@ -1,97 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43#ifdef SOFTFLOAT_FAST_INT64
44
45void
46 f128M_sub( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
47{
48 const uint64_t *aWPtr, *bWPtr;
49 uint_fast64_t uiA64, uiA0;
50 bool signA;
51 uint_fast64_t uiB64, uiB0;
52 bool signB;
53#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
54 float128_t
55 (*magsFuncPtr)(
56 uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
57#endif
58
59 aWPtr = (const uint64_t *) aPtr;
60 bWPtr = (const uint64_t *) bPtr;
61 uiA64 = aWPtr[indexWord( 2, 1 )];
62 uiA0 = aWPtr[indexWord( 2, 0 )];
63 signA = signF128UI64( uiA64 );
64 uiB64 = bWPtr[indexWord( 2, 1 )];
65 uiB0 = bWPtr[indexWord( 2, 0 )];
66 signB = signF128UI64( uiB64 );
67#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
68 if ( signA == signB ) {
69 *zPtr = softfloat_subMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
70 } else {
71 *zPtr = softfloat_addMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
72 }
73#else
74 magsFuncPtr =
75 (signA == signB) ? softfloat_subMagsF128 : softfloat_addMagsF128;
76 *zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
77#endif
78
79}
80
81#else
82
83void
84 f128M_sub( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
85{
86
87 softfloat_addF128M(
88 (const uint32_t *) aPtr,
89 (const uint32_t *) bPtr,
90 (uint32_t *) zPtr,
91 true
92 );
93
94}
95
96#endif
97
deps/SoftFloat-3d/source/f128M_to_extF80M.c deleted-101
......@@ -1,101 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void f128M_to_extF80M( const float128_t *aPtr, extFloat80_t *zPtr )
47{
48
49 *zPtr = f128_to_extF80( *aPtr );
50
51}
52
53#else
54
55void f128M_to_extF80M( const float128_t *aPtr, extFloat80_t *zPtr )
56{
57 const uint32_t *aWPtr;
58 struct extFloat80M *zSPtr;
59 uint32_t uiA96;
60 bool sign;
61 int32_t exp;
62 struct commonNaN commonNaN;
63 uint32_t sig[4];
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 aWPtr = (const uint32_t *) aPtr;
68 zSPtr = (struct extFloat80M *) zPtr;
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 uiA96 = aWPtr[indexWordHi( 4 )];
72 sign = signF128UI96( uiA96 );
73 exp = expF128UI96( uiA96 );
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( exp == 0x7FFF ) {
77 if ( softfloat_isNaNF128M( aWPtr ) ) {
78 softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
79 softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
80 return;
81 }
82 zSPtr->signExp = packToExtF80UI64( sign, 0x7FFF );
83 zSPtr->signif = UINT64_C( 0x8000000000000000 );
84 return;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 exp = softfloat_shiftNormSigF128M( aWPtr, 15, sig );
89 if ( exp == -128 ) {
90 zSPtr->signExp = packToExtF80UI64( sign, 0 );
91 zSPtr->signif = 0;
92 return;
93 }
94 if ( sig[indexWord( 4, 0 )] ) sig[indexWord( 4, 1 )] |= 1;
95 softfloat_roundPackMToExtF80M(
96 sign, exp, &sig[indexMultiwordHi( 4, 3 )], 80, zSPtr );
97
98}
99
100#endif
101
deps/SoftFloat-3d/source/f128M_to_f16.c deleted-113
......@@ -1,113 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46float16_t f128M_to_f16( const float128_t *aPtr )
47{
48
49 return f128_to_f16( *aPtr );
50
51}
52
53#else
54
55float16_t f128M_to_f16( const float128_t *aPtr )
56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 bool sign;
60 int32_t exp;
61 uint32_t frac32;
62 struct commonNaN commonNaN;
63 uint16_t uiZ, frac16;
64 union ui16_f16 uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 uiA96 = aWPtr[indexWordHi( 4 )];
72 sign = signF128UI96( uiA96 );
73 exp = expF128UI96( uiA96 );
74 frac32 =
75 fracF128UI96( uiA96 )
76 | ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
77 | aWPtr[indexWord( 4, 0 )])
78 != 0);
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 if ( exp == 0x7FFF ) {
82 if ( frac32 ) {
83 softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
84 uiZ = softfloat_commonNaNToF16UI( &commonNaN );
85 } else {
86 uiZ = packToF16UI( sign, 0x1F, 0 );
87 }
88 goto uiZ;
89 }
90 /*------------------------------------------------------------------------
91 *------------------------------------------------------------------------*/
92 frac16 = frac32>>2 | (frac32 & 3);
93 if ( ! (exp | frac16) ) {
94 uiZ = packToF16UI( sign, 0, 0 );
95 goto uiZ;
96 }
97 /*------------------------------------------------------------------------
98 *------------------------------------------------------------------------*/
99 exp -= 0x3FF1;
100 if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
101 if ( exp < -0x40 ) exp = -0x40;
102 }
103 return softfloat_roundPackToF16( sign, exp, frac16 | 0x4000 );
104 /*------------------------------------------------------------------------
105 *------------------------------------------------------------------------*/
106 uiZ:
107 uZ.ui = uiZ;
108 return uZ.f;
109
110}
111
112#endif
113
deps/SoftFloat-3d/source/f128M_to_f32.c deleted-109
......@@ -1,109 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46float32_t f128M_to_f32( const float128_t *aPtr )
47{
48
49 return f128_to_f32( *aPtr );
50
51}
52
53#else
54
55float32_t f128M_to_f32( const float128_t *aPtr )
56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 bool sign;
60 int32_t exp;
61 uint64_t frac64;
62 struct commonNaN commonNaN;
63 uint32_t uiZ, frac32;
64 union ui32_f32 uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 uiA96 = aWPtr[indexWordHi( 4 )];
70 sign = signF128UI96( uiA96 );
71 exp = expF128UI96( uiA96 );
72 frac64 =
73 (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )]
74 | ((aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )]) != 0);
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp == 0x7FFF ) {
78 if ( frac64 ) {
79 softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
80 uiZ = softfloat_commonNaNToF32UI( &commonNaN );
81 } else {
82 uiZ = packToF32UI( sign, 0xFF, 0 );
83 }
84 goto uiZ;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 frac32 = softfloat_shortShiftRightJam64( frac64, 18 );
89 if ( ! (exp | frac32) ) {
90 uiZ = packToF32UI( sign, 0, 0 );
91 goto uiZ;
92 }
93 /*------------------------------------------------------------------------
94 *------------------------------------------------------------------------*/
95 exp -= 0x3F81;
96 if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
97 if ( exp < -0x1000 ) exp = -0x1000;
98 }
99 return softfloat_roundPackToF32( sign, exp, frac32 | 0x40000000 );
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 uiZ:
103 uZ.ui = uiZ;
104 return uZ.f;
105
106}
107
108#endif
109
deps/SoftFloat-3d/source/f128M_to_f64.c deleted-112
......@@ -1,112 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46float64_t f128M_to_f64( const float128_t *aPtr )
47{
48
49 return f128_to_f64( *aPtr );
50
51}
52
53#else
54
55float64_t f128M_to_f64( const float128_t *aPtr )
56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 bool sign;
60 int32_t exp;
61 uint64_t frac64;
62 struct commonNaN commonNaN;
63 uint64_t uiZ;
64 uint32_t frac32;
65 union ui64_f64 uZ;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 aWPtr = (const uint32_t *) aPtr;
70 uiA96 = aWPtr[indexWordHi( 4 )];
71 sign = signF128UI96( uiA96 );
72 exp = expF128UI96( uiA96 );
73 frac64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( exp == 0x7FFF ) {
77 if ( frac64 || aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) {
78 softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
79 uiZ = softfloat_commonNaNToF64UI( &commonNaN );
80 } else {
81 uiZ = packToF64UI( sign, 0x7FF, 0 );
82 }
83 goto uiZ;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 frac32 = aWPtr[indexWord( 4, 1 )];
88 frac64 = frac64<<14 | frac32>>18;
89 if ( (frac32 & 0x0003FFFF) || aWPtr[indexWord( 4, 0 )] ) frac64 |= 1;
90 if ( ! (exp | frac64) ) {
91 uiZ = packToF64UI( sign, 0, 0 );
92 goto uiZ;
93 }
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 exp -= 0x3C01;
97 if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
98 if ( exp < -0x1000 ) exp = -0x1000;
99 }
100 return
101 softfloat_roundPackToF64(
102 sign, exp, frac64 | UINT64_C( 0x4000000000000000 ) );
103 /*------------------------------------------------------------------------
104 *------------------------------------------------------------------------*/
105 uiZ:
106 uZ.ui = uiZ;
107 return uZ.f;
108
109}
110
111#endif
112
deps/SoftFloat-3d/source/f128M_to_i32.c deleted-98
......@@ -1,98 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46int_fast32_t
47 f128M_to_i32( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
48{
49
50 return f128_to_i32( *aPtr, roundingMode, exact );
51
52}
53
54#else
55
56int_fast32_t
57 f128M_to_i32( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
58{
59 const uint32_t *aWPtr;
60 uint32_t uiA96;
61 bool sign;
62 int32_t exp;
63 uint64_t sig64;
64 int32_t shiftDist;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 uiA96 = aWPtr[indexWordHi( 4 )];
70 sign = signF128UI96( uiA96 );
71 exp = expF128UI96( uiA96 );
72 sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
73 if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
77 if ( (exp == 0x7FFF) && sig64 ) {
78#if (i32_fromNaN == i32_fromPosOverflow)
79 sign = 0;
80#elif (i32_fromNaN == i32_fromNegOverflow)
81 sign = 1;
82#else
83 softfloat_raiseFlags( softfloat_flag_invalid );
84 return i32_fromNaN;
85#endif
86 }
87#endif
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
91 shiftDist = 0x4023 - exp;
92 if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
93 return softfloat_roundToI32( sign, sig64, roundingMode, exact );
94
95}
96
97#endif
98
deps/SoftFloat-3d/source/f128M_to_i32_r_minMag.c deleted-106
......@@ -1,106 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46int_fast32_t f128M_to_i32_r_minMag( const float128_t *aPtr, bool exact )
47{
48
49 return f128_to_i32_r_minMag( *aPtr, exact );
50
51}
52
53#else
54
55int_fast32_t f128M_to_i32_r_minMag( const float128_t *aPtr, bool exact )
56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 bool sign;
60 int32_t exp;
61 uint64_t sig64;
62 int32_t shiftDist;
63 uint32_t absZ, uiZ;
64 union { uint32_t ui; int32_t i; } uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 uiA96 = aWPtr[indexWordHi( 4 )];
70 sign = signF128UI96( uiA96 );
71 exp = expF128UI96( uiA96 );
72 sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
73 if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( exp < 0x3FFF ) {
77 if ( exact && (exp | sig64) ) {
78 softfloat_exceptionFlags |= softfloat_flag_inexact;
79 }
80 return 0;
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( 0x401F <= exp ) goto invalid;
85 shiftDist = 0x402F - exp;
86 sig64 |= UINT64_C( 0x0001000000000000 );
87 absZ = sig64>>shiftDist;
88 uiZ = sign ? -absZ : absZ;
89 if ( uiZ>>31 != sign ) goto invalid;
90 if ( exact && ((uint64_t) absZ<<shiftDist != sig64) ) {
91 softfloat_exceptionFlags |= softfloat_flag_inexact;
92 }
93 uZ.ui = uiZ;
94 return uZ.i;
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 invalid:
98 softfloat_raiseFlags( softfloat_flag_invalid );
99 return
100 (exp == 0x7FFF) && sig64 ? i32_fromNaN
101 : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
102
103}
104
105#endif
106
deps/SoftFloat-3d/source/f128M_to_i64.c deleted-102
......@@ -1,102 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46int_fast64_t
47 f128M_to_i64( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
48{
49
50 return f128_to_i64( *aPtr, roundingMode, exact );
51
52}
53
54#else
55
56int_fast64_t
57 f128M_to_i64( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
58{
59 const uint32_t *aWPtr;
60 uint32_t uiA96;
61 bool sign;
62 int32_t exp;
63 uint32_t sig96;
64 int32_t shiftDist;
65 uint32_t sig[4];
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 aWPtr = (const uint32_t *) aPtr;
70 uiA96 = aWPtr[indexWordHi( 4 )];
71 sign = signF128UI96( uiA96 );
72 exp = expF128UI96( uiA96 );
73 sig96 = fracF128UI96( uiA96 );
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 shiftDist = 0x404F - exp;
77 if ( shiftDist < 17 ) {
78 softfloat_raiseFlags( softfloat_flag_invalid );
79 return
80 (exp == 0x7FFF)
81 && (sig96
82 || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
83 | aWPtr[indexWord( 4, 0 )]))
84 ? i64_fromNaN
85 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
86 }
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 if ( exp ) sig96 |= 0x00010000;
90 sig[indexWord( 4, 3 )] = sig96;
91 sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
92 sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
93 sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
94 softfloat_shiftRightJam128M( sig, shiftDist, sig );
95 return
96 softfloat_roundMToI64(
97 sign, sig + indexMultiwordLo( 4, 3 ), roundingMode, exact );
98
99}
100
101#endif
102
deps/SoftFloat-3d/source/f128M_to_i64_r_minMag.c deleted-124
......@@ -1,124 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46int_fast64_t f128M_to_i64_r_minMag( const float128_t *aPtr, bool exact )
47{
48
49 return f128_to_i64_r_minMag( *aPtr, exact );
50
51}
52
53#else
54
55int_fast64_t f128M_to_i64_r_minMag( const float128_t *aPtr, bool exact )
56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 bool sign;
60 int32_t exp;
61 uint32_t sig96;
62 int32_t shiftDist;
63 uint32_t sig[4];
64 uint64_t uiZ;
65 union { uint64_t ui; int64_t i; } uZ;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 aWPtr = (const uint32_t *) aPtr;
70 uiA96 = aWPtr[indexWordHi( 4 )];
71 sign = signF128UI96( uiA96 );
72 exp = expF128UI96( uiA96 );
73 sig96 = fracF128UI96( uiA96 );
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 shiftDist = 0x403E - exp;
77 if ( shiftDist < 0 ) goto invalid;
78 if ( exact ) {
79 if ( exp ) sig96 |= 0x00010000;
80 sig[indexWord( 4, 3 )] = sig96;
81 sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
82 sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
83 sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
84 softfloat_shiftRightJam128M( sig, shiftDist + 17, sig );
85 uiZ = (uint64_t) sig[indexWord( 4, 2 )]<<32 | sig[indexWord( 4, 1 )];
86 if ( uiZ>>63 && (! sign || (uiZ != UINT64_C( 0x8000000000000000 ))) ) {
87 goto invalid;
88 }
89 if ( sig[indexWordLo( 4 )] ) {
90 softfloat_exceptionFlags |= softfloat_flag_inexact;
91 }
92 } else {
93 if ( 64 <= shiftDist ) return 0;
94 uiZ =
95 (uint64_t) sig96<<47
96 | (uint64_t) aWPtr[indexWord( 4, 2 )]<<15
97 | aWPtr[indexWord( 4, 1 )]>>17;
98 if ( shiftDist ) {
99 uiZ |= UINT64_C( 0x8000000000000000 );
100 uiZ >>= shiftDist;
101 } else {
102 if ( uiZ || ! sign ) goto invalid;
103 uiZ |= UINT64_C( 0x8000000000000000 );
104 }
105 }
106 if ( sign ) uiZ = -uiZ;
107 uZ.ui = uiZ;
108 return uZ.i;
109 /*------------------------------------------------------------------------
110 *------------------------------------------------------------------------*/
111 invalid:
112 softfloat_raiseFlags( softfloat_flag_invalid );
113 return
114 (exp == 0x7FFF)
115 && (sig96
116 || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
117 | aWPtr[indexWord( 4, 0 )]))
118 ? i64_fromNaN
119 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
120
121}
122
123#endif
124
deps/SoftFloat-3d/source/f128M_to_ui32.c deleted-98
......@@ -1,98 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46uint_fast32_t
47 f128M_to_ui32( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
48{
49
50 return f128_to_ui32( *aPtr, roundingMode, exact );
51
52}
53
54#else
55
56uint_fast32_t
57 f128M_to_ui32( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
58{
59 const uint32_t *aWPtr;
60 uint32_t uiA96;
61 bool sign;
62 int32_t exp;
63 uint64_t sig64;
64 int32_t shiftDist;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 uiA96 = aWPtr[indexWordHi( 4 )];
70 sign = signF128UI96( uiA96 );
71 exp = expF128UI96( uiA96 );
72 sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
73 if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76#if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
77 if ( (exp == 0x7FFF) && sig64 ) {
78#if (ui32_fromNaN == ui32_fromPosOverflow)
79 sign = 0;
80#elif (ui32_fromNaN == ui32_fromNegOverflow)
81 sign = 1;
82#else
83 softfloat_raiseFlags( softfloat_flag_invalid );
84 return ui32_fromNaN;
85#endif
86 }
87#endif
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
91 shiftDist = 0x4023 - exp;
92 if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
93 return softfloat_roundToUI32( sign, sig64, roundingMode, exact );
94
95}
96
97#endif
98
deps/SoftFloat-3d/source/f128M_to_ui32_r_minMag.c deleted-102
......@@ -1,102 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46uint_fast32_t f128M_to_ui32_r_minMag( const float128_t *aPtr, bool exact )
47{
48
49 return f128_to_ui32_r_minMag( *aPtr, exact );
50
51}
52
53#else
54
55uint_fast32_t f128M_to_ui32_r_minMag( const float128_t *aPtr, bool exact )
56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 int32_t exp;
60 uint64_t sig64;
61 int32_t shiftDist;
62 bool sign;
63 uint32_t z;
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 aWPtr = (const uint32_t *) aPtr;
68 uiA96 = aWPtr[indexWordHi( 4 )];
69 exp = expF128UI96( uiA96 );
70 sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
71 if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 shiftDist = 0x402F - exp;
75 if ( 49 <= shiftDist ) {
76 if ( exact && (exp | sig64) ) {
77 softfloat_exceptionFlags |= softfloat_flag_inexact;
78 }
79 return 0;
80 }
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 sign = signF128UI96( uiA96 );
84 if ( sign || (shiftDist < 17) ) {
85 softfloat_raiseFlags( softfloat_flag_invalid );
86 return
87 (exp == 0x7FFF) && sig64 ? ui32_fromNaN
88 : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
89 }
90 /*------------------------------------------------------------------------
91 *------------------------------------------------------------------------*/
92 sig64 |= UINT64_C( 0x0001000000000000 );
93 z = sig64>>shiftDist;
94 if ( exact && ((uint64_t) z<<shiftDist != sig64) ) {
95 softfloat_exceptionFlags |= softfloat_flag_inexact;
96 }
97 return z;
98
99}
100
101#endif
102
deps/SoftFloat-3d/source/f128M_to_ui64.c deleted-102
......@@ -1,102 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46uint_fast64_t
47 f128M_to_ui64( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
48{
49
50 return f128_to_ui64( *aPtr, roundingMode, exact );
51
52}
53
54#else
55
56uint_fast64_t
57 f128M_to_ui64( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
58{
59 const uint32_t *aWPtr;
60 uint32_t uiA96;
61 bool sign;
62 int32_t exp;
63 uint32_t sig96;
64 int32_t shiftDist;
65 uint32_t sig[4];
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 aWPtr = (const uint32_t *) aPtr;
70 uiA96 = aWPtr[indexWordHi( 4 )];
71 sign = signF128UI96( uiA96 );
72 exp = expF128UI96( uiA96 );
73 sig96 = fracF128UI96( uiA96 );
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 shiftDist = 0x404F - exp;
77 if ( shiftDist < 17 ) {
78 softfloat_raiseFlags( softfloat_flag_invalid );
79 return
80 (exp == 0x7FFF)
81 && (sig96
82 || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
83 | aWPtr[indexWord( 4, 0 )]))
84 ? ui64_fromNaN
85 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
86 }
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 if ( exp ) sig96 |= 0x00010000;
90 sig[indexWord( 4, 3 )] = sig96;
91 sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
92 sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
93 sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
94 softfloat_shiftRightJam128M( sig, shiftDist, sig );
95 return
96 softfloat_roundMToUI64(
97 sign, sig + indexMultiwordLo( 4, 3 ), roundingMode, exact );
98
99}
100
101#endif
102
deps/SoftFloat-3d/source/f128M_to_ui64_r_minMag.c deleted-114
......@@ -1,114 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46uint_fast64_t f128M_to_ui64_r_minMag( const float128_t *aPtr, bool exact )
47{
48
49 return f128_to_ui64_r_minMag( *aPtr, exact );
50
51}
52
53#else
54
55uint_fast64_t f128M_to_ui64_r_minMag( const float128_t *aPtr, bool exact )
56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 bool sign;
60 int32_t exp;
61 uint32_t sig96;
62 int32_t shiftDist;
63 uint32_t sig[4];
64 uint64_t z;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 uiA96 = aWPtr[indexWordHi( 4 )];
70 sign = signF128UI96( uiA96 );
71 exp = expF128UI96( uiA96 );
72 sig96 = fracF128UI96( uiA96 );
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 shiftDist = 0x403E - exp;
76 if ( shiftDist < 0 ) goto invalid;
77 if ( exact ) {
78 if ( exp ) sig96 |= 0x00010000;
79 sig[indexWord( 4, 3 )] = sig96;
80 sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
81 sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
82 sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
83 softfloat_shiftRightJam128M( sig, shiftDist + 17, sig );
84 z = (uint64_t) sig[indexWord( 4, 2 )]<<32 | sig[indexWord( 4, 1 )];
85 if ( sign && z ) goto invalid;
86 if ( sig[indexWordLo( 4 )] ) {
87 softfloat_exceptionFlags |= softfloat_flag_inexact;
88 }
89 } else {
90 if ( 64 <= shiftDist ) return 0;
91 if ( sign ) goto invalid;
92 z = UINT64_C( 0x8000000000000000 )
93 | (uint64_t) sig96<<47
94 | (uint64_t) aWPtr[indexWord( 4, 2 )]<<15
95 | aWPtr[indexWord( 4, 1 )]>>17;
96 z >>= shiftDist;
97 }
98 return z;
99 /*------------------------------------------------------------------------
100 *------------------------------------------------------------------------*/
101 invalid:
102 softfloat_raiseFlags( softfloat_flag_invalid );
103 return
104 (exp == 0x7FFF)
105 && (sig96
106 || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
107 | aWPtr[indexWord( 4, 0 )]))
108 ? ui64_fromNaN
109 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
110
111}
112
113#endif
114
deps/SoftFloat-3d/source/f128_add.c deleted-78
......@@ -1,78 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float128_t f128_add( float128_t a, float128_t b )
44{
45 union ui128_f128 uA;
46 uint_fast64_t uiA64, uiA0;
47 bool signA;
48 union ui128_f128 uB;
49 uint_fast64_t uiB64, uiB0;
50 bool signB;
51#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
52 float128_t
53 (*magsFuncPtr)(
54 uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
55#endif
56
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 signA = signF128UI64( uiA64 );
61 uB.f = b;
62 uiB64 = uB.ui.v64;
63 uiB0 = uB.ui.v0;
64 signB = signF128UI64( uiB64 );
65#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
66 if ( signA == signB ) {
67 return softfloat_addMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
68 } else {
69 return softfloat_subMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
70 }
71#else
72 magsFuncPtr =
73 (signA == signB) ? softfloat_addMagsF128 : softfloat_subMagsF128;
74 return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
75#endif
76
77}
78
deps/SoftFloat-3d/source/f128_div.c deleted-199
......@@ -1,199 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t f128_div( float128_t a, float128_t b )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool signA;
49 int_fast32_t expA;
50 struct uint128 sigA;
51 union ui128_f128 uB;
52 uint_fast64_t uiB64, uiB0;
53 bool signB;
54 int_fast32_t expB;
55 struct uint128 sigB;
56 bool signZ;
57 struct exp32_sig128 normExpSig;
58 int_fast32_t expZ;
59 struct uint128 rem;
60 uint_fast32_t recip32;
61 int ix;
62 uint_fast64_t q64;
63 uint_fast32_t q;
64 struct uint128 term;
65 uint_fast32_t qs[3];
66 uint_fast64_t sigZExtra;
67 struct uint128 sigZ, uiZ;
68 union ui128_f128 uZ;
69
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 uA.f = a;
73 uiA64 = uA.ui.v64;
74 uiA0 = uA.ui.v0;
75 signA = signF128UI64( uiA64 );
76 expA = expF128UI64( uiA64 );
77 sigA.v64 = fracF128UI64( uiA64 );
78 sigA.v0 = uiA0;
79 uB.f = b;
80 uiB64 = uB.ui.v64;
81 uiB0 = uB.ui.v0;
82 signB = signF128UI64( uiB64 );
83 expB = expF128UI64( uiB64 );
84 sigB.v64 = fracF128UI64( uiB64 );
85 sigB.v0 = uiB0;
86 signZ = signA ^ signB;
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 if ( expA == 0x7FFF ) {
90 if ( sigA.v64 | sigA.v0 ) goto propagateNaN;
91 if ( expB == 0x7FFF ) {
92 if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
93 goto invalid;
94 }
95 goto infinity;
96 }
97 if ( expB == 0x7FFF ) {
98 if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
99 goto zero;
100 }
101 /*------------------------------------------------------------------------
102 *------------------------------------------------------------------------*/
103 if ( ! expB ) {
104 if ( ! (sigB.v64 | sigB.v0) ) {
105 if ( ! (expA | sigA.v64 | sigA.v0) ) goto invalid;
106 softfloat_raiseFlags( softfloat_flag_infinite );
107 goto infinity;
108 }
109 normExpSig = softfloat_normSubnormalF128Sig( sigB.v64, sigB.v0 );
110 expB = normExpSig.exp;
111 sigB = normExpSig.sig;
112 }
113 if ( ! expA ) {
114 if ( ! (sigA.v64 | sigA.v0) ) goto zero;
115 normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
116 expA = normExpSig.exp;
117 sigA = normExpSig.sig;
118 }
119 /*------------------------------------------------------------------------
120 *------------------------------------------------------------------------*/
121 expZ = expA - expB + 0x3FFE;
122 sigA.v64 |= UINT64_C( 0x0001000000000000 );
123 sigB.v64 |= UINT64_C( 0x0001000000000000 );
124 rem = sigA;
125 if ( softfloat_lt128( sigA.v64, sigA.v0, sigB.v64, sigB.v0 ) ) {
126 --expZ;
127 rem = softfloat_add128( sigA.v64, sigA.v0, sigA.v64, sigA.v0 );
128 }
129 recip32 = softfloat_approxRecip32_1( sigB.v64>>17 );
130 ix = 3;
131 for (;;) {
132 q64 = (uint_fast64_t) (uint32_t) (rem.v64>>19) * recip32;
133 q = (q64 + 0x80000000)>>32;
134 --ix;
135 if ( ix < 0 ) break;
136 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
137 term = softfloat_mul128By32( sigB.v64, sigB.v0, q );
138 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
139 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
140 --q;
141 rem = softfloat_add128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
142 }
143 qs[ix] = q;
144 }
145 /*------------------------------------------------------------------------
146 *------------------------------------------------------------------------*/
147 if ( ((q + 1) & 7) < 2 ) {
148 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
149 term = softfloat_mul128By32( sigB.v64, sigB.v0, q );
150 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
151 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
152 --q;
153 rem = softfloat_add128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
154 } else if ( softfloat_le128( sigB.v64, sigB.v0, rem.v64, rem.v0 ) ) {
155 ++q;
156 rem = softfloat_sub128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
157 }
158 if ( rem.v64 | rem.v0 ) q |= 1;
159 }
160 /*------------------------------------------------------------------------
161 *------------------------------------------------------------------------*/
162 sigZExtra = (uint64_t) ((uint_fast64_t) q<<60);
163 term = softfloat_shortShiftLeft128( 0, qs[1], 54 );
164 sigZ =
165 softfloat_add128(
166 (uint_fast64_t) qs[2]<<19, ((uint_fast64_t) qs[0]<<25) + (q>>4),
167 term.v64, term.v0
168 );
169 return
170 softfloat_roundPackToF128( signZ, expZ, sigZ.v64, sigZ.v0, sigZExtra );
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 propagateNaN:
174 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
175 goto uiZ;
176 /*------------------------------------------------------------------------
177 *------------------------------------------------------------------------*/
178 invalid:
179 softfloat_raiseFlags( softfloat_flag_invalid );
180 uiZ.v64 = defaultNaNF128UI64;
181 uiZ.v0 = defaultNaNF128UI0;
182 goto uiZ;
183 /*------------------------------------------------------------------------
184 *------------------------------------------------------------------------*/
185 infinity:
186 uiZ.v64 = packToF128UI64( signZ, 0x7FFF, 0 );
187 goto uiZ0;
188 /*------------------------------------------------------------------------
189 *------------------------------------------------------------------------*/
190 zero:
191 uiZ.v64 = packToF128UI64( signZ, 0, 0 );
192 uiZ0:
193 uiZ.v0 = 0;
194 uiZ:
195 uZ.ui = uiZ;
196 return uZ.f;
197
198}
199
deps/SoftFloat-3d/source/f128_eq.c deleted-73
......@@ -1,73 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f128_eq( float128_t a, float128_t b )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 union ui128_f128 uB;
49 uint_fast64_t uiB64, uiB0;
50
51 uA.f = a;
52 uiA64 = uA.ui.v64;
53 uiA0 = uA.ui.v0;
54 uB.f = b;
55 uiB64 = uB.ui.v64;
56 uiB0 = uB.ui.v0;
57 if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
58 if (
59 softfloat_isSigNaNF128UI( uiA64, uiA0 )
60 || softfloat_isSigNaNF128UI( uiB64, uiB0 )
61 ) {
62 softfloat_raiseFlags( softfloat_flag_invalid );
63 }
64 return false;
65 }
66 return
67 (uiA0 == uiB0)
68 && ( (uiA64 == uiB64)
69 || (! uiA0 && ! ((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
70 );
71
72}
73
deps/SoftFloat-3d/source/f128_eq_signaling.c deleted-67
......@@ -1,67 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f128_eq_signaling( float128_t a, float128_t b )
44{
45 union ui128_f128 uA;
46 uint_fast64_t uiA64, uiA0;
47 union ui128_f128 uB;
48 uint_fast64_t uiB64, uiB0;
49
50 uA.f = a;
51 uiA64 = uA.ui.v64;
52 uiA0 = uA.ui.v0;
53 uB.f = b;
54 uiB64 = uB.ui.v64;
55 uiB0 = uB.ui.v0;
56 if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
57 softfloat_raiseFlags( softfloat_flag_invalid );
58 return false;
59 }
60 return
61 (uiA0 == uiB0)
62 && ( (uiA64 == uiB64)
63 || (! uiA0 && ! ((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
64 );
65
66}
67
deps/SoftFloat-3d/source/f128_isSignalingNaN.c deleted-51
......@@ -1,51 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43bool f128_isSignalingNaN( float128_t a )
44{
45 union ui128_f128 uA;
46
47 uA.f = a;
48 return softfloat_isSigNaNF128UI( uA.ui.v64, uA.ui.v0 );
49
50}
51
deps/SoftFloat-3d/source/f128_le.c deleted-72
......@@ -1,72 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f128_le( float128_t a, float128_t b )
44{
45 union ui128_f128 uA;
46 uint_fast64_t uiA64, uiA0;
47 union ui128_f128 uB;
48 uint_fast64_t uiB64, uiB0;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA64 = uA.ui.v64;
53 uiA0 = uA.ui.v0;
54 uB.f = b;
55 uiB64 = uB.ui.v64;
56 uiB0 = uB.ui.v0;
57 if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
58 softfloat_raiseFlags( softfloat_flag_invalid );
59 return false;
60 }
61 signA = signF128UI64( uiA64 );
62 signB = signF128UI64( uiB64 );
63 return
64 (signA != signB)
65 ? signA
66 || ! (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
67 | uiA0 | uiB0)
68 : ((uiA64 == uiB64) && (uiA0 == uiB0))
69 || (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
70
71}
72
deps/SoftFloat-3d/source/f128_le_quiet.c deleted-78
......@@ -1,78 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f128_le_quiet( float128_t a, float128_t b )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 union ui128_f128 uB;
49 uint_fast64_t uiB64, uiB0;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA64 = uA.ui.v64;
54 uiA0 = uA.ui.v0;
55 uB.f = b;
56 uiB64 = uB.ui.v64;
57 uiB0 = uB.ui.v0;
58 if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
59 if (
60 softfloat_isSigNaNF128UI( uiA64, uiA0 )
61 || softfloat_isSigNaNF128UI( uiB64, uiB0 )
62 ) {
63 softfloat_raiseFlags( softfloat_flag_invalid );
64 }
65 return false;
66 }
67 signA = signF128UI64( uiA64 );
68 signB = signF128UI64( uiB64 );
69 return
70 (signA != signB)
71 ? signA
72 || ! (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
73 | uiA0 | uiB0)
74 : ((uiA64 == uiB64) && (uiA0 == uiB0))
75 || (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
76
77}
78
deps/SoftFloat-3d/source/f128_lt.c deleted-72
......@@ -1,72 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f128_lt( float128_t a, float128_t b )
44{
45 union ui128_f128 uA;
46 uint_fast64_t uiA64, uiA0;
47 union ui128_f128 uB;
48 uint_fast64_t uiB64, uiB0;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA64 = uA.ui.v64;
53 uiA0 = uA.ui.v0;
54 uB.f = b;
55 uiB64 = uB.ui.v64;
56 uiB0 = uB.ui.v0;
57 if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
58 softfloat_raiseFlags( softfloat_flag_invalid );
59 return false;
60 }
61 signA = signF128UI64( uiA64 );
62 signB = signF128UI64( uiB64 );
63 return
64 (signA != signB)
65 ? signA
66 && (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
67 | uiA0 | uiB0)
68 : ((uiA64 != uiB64) || (uiA0 != uiB0))
69 && (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
70
71}
72
deps/SoftFloat-3d/source/f128_lt_quiet.c deleted-78
......@@ -1,78 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f128_lt_quiet( float128_t a, float128_t b )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 union ui128_f128 uB;
49 uint_fast64_t uiB64, uiB0;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA64 = uA.ui.v64;
54 uiA0 = uA.ui.v0;
55 uB.f = b;
56 uiB64 = uB.ui.v64;
57 uiB0 = uB.ui.v0;
58 if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
59 if (
60 softfloat_isSigNaNF128UI( uiA64, uiA0 )
61 || softfloat_isSigNaNF128UI( uiB64, uiB0 )
62 ) {
63 softfloat_raiseFlags( softfloat_flag_invalid );
64 }
65 return false;
66 }
67 signA = signF128UI64( uiA64 );
68 signB = signF128UI64( uiB64 );
69 return
70 (signA != signB)
71 ? signA
72 && (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
73 | uiA0 | uiB0)
74 : ((uiA64 != uiB64) || (uiA0 != uiB0))
75 && (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
76
77}
78
deps/SoftFloat-3d/source/f128_mul.c deleted-163
......@@ -1,163 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t f128_mul( float128_t a, float128_t b )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool signA;
49 int_fast32_t expA;
50 struct uint128 sigA;
51 union ui128_f128 uB;
52 uint_fast64_t uiB64, uiB0;
53 bool signB;
54 int_fast32_t expB;
55 struct uint128 sigB;
56 bool signZ;
57 uint_fast64_t magBits;
58 struct exp32_sig128 normExpSig;
59 int_fast32_t expZ;
60 uint64_t sig256Z[4];
61 uint_fast64_t sigZExtra;
62 struct uint128 sigZ;
63 struct uint128_extra sig128Extra;
64 struct uint128 uiZ;
65 union ui128_f128 uZ;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 uA.f = a;
70 uiA64 = uA.ui.v64;
71 uiA0 = uA.ui.v0;
72 signA = signF128UI64( uiA64 );
73 expA = expF128UI64( uiA64 );
74 sigA.v64 = fracF128UI64( uiA64 );
75 sigA.v0 = uiA0;
76 uB.f = b;
77 uiB64 = uB.ui.v64;
78 uiB0 = uB.ui.v0;
79 signB = signF128UI64( uiB64 );
80 expB = expF128UI64( uiB64 );
81 sigB.v64 = fracF128UI64( uiB64 );
82 sigB.v0 = uiB0;
83 signZ = signA ^ signB;
84 /*------------------------------------------------------------------------
85 *------------------------------------------------------------------------*/
86 if ( expA == 0x7FFF ) {
87 if (
88 (sigA.v64 | sigA.v0) || ((expB == 0x7FFF) && (sigB.v64 | sigB.v0))
89 ) {
90 goto propagateNaN;
91 }
92 magBits = expB | sigB.v64 | sigB.v0;
93 goto infArg;
94 }
95 if ( expB == 0x7FFF ) {
96 if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
97 magBits = expA | sigA.v64 | sigA.v0;
98 goto infArg;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 if ( ! expA ) {
103 if ( ! (sigA.v64 | sigA.v0) ) goto zero;
104 normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
105 expA = normExpSig.exp;
106 sigA = normExpSig.sig;
107 }
108 if ( ! expB ) {
109 if ( ! (sigB.v64 | sigB.v0) ) goto zero;
110 normExpSig = softfloat_normSubnormalF128Sig( sigB.v64, sigB.v0 );
111 expB = normExpSig.exp;
112 sigB = normExpSig.sig;
113 }
114 /*------------------------------------------------------------------------
115 *------------------------------------------------------------------------*/
116 expZ = expA + expB - 0x4000;
117 sigA.v64 |= UINT64_C( 0x0001000000000000 );
118 sigB = softfloat_shortShiftLeft128( sigB.v64, sigB.v0, 16 );
119 softfloat_mul128To256M( sigA.v64, sigA.v0, sigB.v64, sigB.v0, sig256Z );
120 sigZExtra = sig256Z[indexWord( 4, 1 )] | (sig256Z[indexWord( 4, 0 )] != 0);
121 sigZ =
122 softfloat_add128(
123 sig256Z[indexWord( 4, 3 )], sig256Z[indexWord( 4, 2 )],
124 sigA.v64, sigA.v0
125 );
126 if ( UINT64_C( 0x0002000000000000 ) <= sigZ.v64 ) {
127 ++expZ;
128 sig128Extra =
129 softfloat_shortShiftRightJam128Extra(
130 sigZ.v64, sigZ.v0, sigZExtra, 1 );
131 sigZ = sig128Extra.v;
132 sigZExtra = sig128Extra.extra;
133 }
134 return
135 softfloat_roundPackToF128( signZ, expZ, sigZ.v64, sigZ.v0, sigZExtra );
136 /*------------------------------------------------------------------------
137 *------------------------------------------------------------------------*/
138 propagateNaN:
139 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
140 goto uiZ;
141 /*------------------------------------------------------------------------
142 *------------------------------------------------------------------------*/
143 infArg:
144 if ( ! magBits ) {
145 softfloat_raiseFlags( softfloat_flag_invalid );
146 uiZ.v64 = defaultNaNF128UI64;
147 uiZ.v0 = defaultNaNF128UI0;
148 goto uiZ;
149 }
150 uiZ.v64 = packToF128UI64( signZ, 0x7FFF, 0 );
151 goto uiZ0;
152 /*------------------------------------------------------------------------
153 *------------------------------------------------------------------------*/
154 zero:
155 uiZ.v64 = packToF128UI64( signZ, 0, 0 );
156 uiZ0:
157 uiZ.v0 = 0;
158 uiZ:
159 uZ.ui = uiZ;
160 return uZ.f;
161
162}
163
deps/SoftFloat-3d/source/f128_mulAdd.c deleted-63
......@@ -1,63 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float128_t f128_mulAdd( float128_t a, float128_t b, float128_t c )
43{
44 union ui128_f128 uA;
45 uint_fast64_t uiA64, uiA0;
46 union ui128_f128 uB;
47 uint_fast64_t uiB64, uiB0;
48 union ui128_f128 uC;
49 uint_fast64_t uiC64, uiC0;
50
51 uA.f = a;
52 uiA64 = uA.ui.v64;
53 uiA0 = uA.ui.v0;
54 uB.f = b;
55 uiB64 = uB.ui.v64;
56 uiB0 = uB.ui.v0;
57 uC.f = c;
58 uiC64 = uC.ui.v64;
59 uiC0 = uC.ui.v0;
60 return softfloat_mulAddF128( uiA64, uiA0, uiB64, uiB0, uiC64, uiC0, 0 );
61
62}
63
deps/SoftFloat-3d/source/f128_rem.c deleted-190
......@@ -1,190 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t f128_rem( float128_t a, float128_t b )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool signA;
49 int_fast32_t expA;
50 struct uint128 sigA;
51 union ui128_f128 uB;
52 uint_fast64_t uiB64, uiB0;
53 int_fast32_t expB;
54 struct uint128 sigB;
55 struct exp32_sig128 normExpSig;
56 struct uint128 rem;
57 int_fast32_t expDiff;
58 uint_fast32_t q, recip32;
59 uint_fast64_t q64;
60 struct uint128 term, altRem, meanRem;
61 bool signRem;
62 struct uint128 uiZ;
63 union ui128_f128 uZ;
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 uA.f = a;
68 uiA64 = uA.ui.v64;
69 uiA0 = uA.ui.v0;
70 signA = signF128UI64( uiA64 );
71 expA = expF128UI64( uiA64 );
72 sigA.v64 = fracF128UI64( uiA64 );
73 sigA.v0 = uiA0;
74 uB.f = b;
75 uiB64 = uB.ui.v64;
76 uiB0 = uB.ui.v0;
77 expB = expF128UI64( uiB64 );
78 sigB.v64 = fracF128UI64( uiB64 );
79 sigB.v0 = uiB0;
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 if ( expA == 0x7FFF ) {
83 if (
84 (sigA.v64 | sigA.v0) || ((expB == 0x7FFF) && (sigB.v64 | sigB.v0))
85 ) {
86 goto propagateNaN;
87 }
88 goto invalid;
89 }
90 if ( expB == 0x7FFF ) {
91 if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
92 return a;
93 }
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 if ( ! expB ) {
97 if ( ! (sigB.v64 | sigB.v0) ) goto invalid;
98 normExpSig = softfloat_normSubnormalF128Sig( sigB.v64, sigB.v0 );
99 expB = normExpSig.exp;
100 sigB = normExpSig.sig;
101 }
102 if ( ! expA ) {
103 if ( ! (sigA.v64 | sigA.v0) ) return a;
104 normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
105 expA = normExpSig.exp;
106 sigA = normExpSig.sig;
107 }
108 /*------------------------------------------------------------------------
109 *------------------------------------------------------------------------*/
110 sigA.v64 |= UINT64_C( 0x0001000000000000 );
111 sigB.v64 |= UINT64_C( 0x0001000000000000 );
112 rem = sigA;
113 expDiff = expA - expB;
114 if ( expDiff < 1 ) {
115 if ( expDiff < -1 ) return a;
116 if ( expDiff ) {
117 --expB;
118 sigB = softfloat_add128( sigB.v64, sigB.v0, sigB.v64, sigB.v0 );
119 q = 0;
120 } else {
121 q = softfloat_le128( sigB.v64, sigB.v0, rem.v64, rem.v0 );
122 if ( q ) {
123 rem = softfloat_sub128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
124 }
125 }
126 } else {
127 recip32 = softfloat_approxRecip32_1( sigB.v64>>17 );
128 expDiff -= 30;
129 for (;;) {
130 q64 = (uint_fast64_t) (uint32_t) (rem.v64>>19) * recip32;
131 if ( expDiff < 0 ) break;
132 q = (q64 + 0x80000000)>>32;
133 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
134 term = softfloat_mul128By32( sigB.v64, sigB.v0, q );
135 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
136 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
137 rem = softfloat_add128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
138 }
139 expDiff -= 29;
140 }
141 /*--------------------------------------------------------------------
142 | (`expDiff' cannot be less than -29 here.)
143 *--------------------------------------------------------------------*/
144 q = (uint32_t) (q64>>32)>>(~expDiff & 31);
145 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, expDiff + 30 );
146 term = softfloat_mul128By32( sigB.v64, sigB.v0, q );
147 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
148 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
149 altRem = softfloat_add128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
150 goto selectRem;
151 }
152 }
153 /*------------------------------------------------------------------------
154 *------------------------------------------------------------------------*/
155 do {
156 altRem = rem;
157 ++q;
158 rem = softfloat_sub128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
159 } while ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) );
160 selectRem:
161 meanRem = softfloat_add128( rem.v64, rem.v0, altRem.v64, altRem.v0 );
162 if (
163 (meanRem.v64 & UINT64_C( 0x8000000000000000 ))
164 || (! (meanRem.v64 | meanRem.v0) && (q & 1))
165 ) {
166 rem = altRem;
167 }
168 signRem = signA;
169 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
170 signRem = ! signRem;
171 rem = softfloat_sub128( 0, 0, rem.v64, rem.v0 );
172 }
173 return softfloat_normRoundPackToF128( signRem, expB - 1, rem.v64, rem.v0 );
174 /*------------------------------------------------------------------------
175 *------------------------------------------------------------------------*/
176 propagateNaN:
177 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
178 goto uiZ;
179 /*------------------------------------------------------------------------
180 *------------------------------------------------------------------------*/
181 invalid:
182 softfloat_raiseFlags( softfloat_flag_invalid );
183 uiZ.v64 = defaultNaNF128UI64;
184 uiZ.v0 = defaultNaNF128UI0;
185 uiZ:
186 uZ.ui = uiZ;
187 return uZ.f;
188
189}
190
deps/SoftFloat-3d/source/f128_roundToInt.c deleted-160
......@@ -1,160 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t
45 f128_roundToInt( float128_t a, uint_fast8_t roundingMode, bool exact )
46{
47 union ui128_f128 uA;
48 uint_fast64_t uiA64, uiA0;
49 int_fast32_t exp;
50 struct uint128 uiZ;
51 uint_fast64_t lastBitMask, roundBitsMask;
52 bool roundNearEven;
53 union ui128_f128 uZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 exp = expF128UI64( uiA64 );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 if ( 0x402F <= exp ) {
64 /*--------------------------------------------------------------------
65 *--------------------------------------------------------------------*/
66 if ( 0x406F <= exp ) {
67 if ( (exp == 0x7FFF) && (fracF128UI64( uiA64 ) | uiA0) ) {
68 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, 0, 0 );
69 goto uiZ;
70 }
71 return a;
72 }
73 /*--------------------------------------------------------------------
74 *--------------------------------------------------------------------*/
75 lastBitMask = (uint_fast64_t) 2<<(0x406E - exp);
76 roundBitsMask = lastBitMask - 1;
77 uiZ.v64 = uiA64;
78 uiZ.v0 = uiA0;
79 roundNearEven = (roundingMode == softfloat_round_near_even);
80 if ( roundNearEven || (roundingMode == softfloat_round_near_maxMag) ) {
81 if ( exp == 0x402F ) {
82 if ( UINT64_C( 0x8000000000000000 ) <= uiZ.v0 ) {
83 ++uiZ.v64;
84 if (
85 roundNearEven
86 && (uiZ.v0 == UINT64_C( 0x8000000000000000 ))
87 ) {
88 uiZ.v64 &= ~1;
89 }
90 }
91 } else {
92 uiZ = softfloat_add128( uiZ.v64, uiZ.v0, 0, lastBitMask>>1 );
93 if ( roundNearEven && ! (uiZ.v0 & roundBitsMask) ) {
94 uiZ.v0 &= ~lastBitMask;
95 }
96 }
97 } else if (
98 roundingMode
99 == (signF128UI64( uiZ.v64 ) ? softfloat_round_min
100 : softfloat_round_max)
101 ) {
102 uiZ = softfloat_add128( uiZ.v64, uiZ.v0, 0, roundBitsMask );
103 }
104 uiZ.v0 &= ~roundBitsMask;
105 } else {
106 /*--------------------------------------------------------------------
107 *--------------------------------------------------------------------*/
108 if ( exp < 0x3FFF ) {
109 if ( ! ((uiA64 & UINT64_C( 0x7FFFFFFFFFFFFFFF )) | uiA0) ) {
110 return a;
111 }
112 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
113 uiZ.v64 = uiA64 & packToF128UI64( 1, 0, 0 );
114 uiZ.v0 = 0;
115 switch ( roundingMode ) {
116 case softfloat_round_near_even:
117 if ( ! (fracF128UI64( uiA64 ) | uiA0) ) break;
118 case softfloat_round_near_maxMag:
119 if ( exp == 0x3FFE ) uiZ.v64 |= packToF128UI64( 0, 0x3FFF, 0 );
120 break;
121 case softfloat_round_min:
122 if ( uiZ.v64 ) uiZ.v64 = packToF128UI64( 1, 0x3FFF, 0 );
123 break;
124 case softfloat_round_max:
125 if ( ! uiZ.v64 ) uiZ.v64 = packToF128UI64( 0, 0x3FFF, 0 );
126 break;
127 }
128 goto uiZ;
129 }
130 /*--------------------------------------------------------------------
131 *--------------------------------------------------------------------*/
132 uiZ.v64 = uiA64;
133 uiZ.v0 = 0;
134 lastBitMask = (uint_fast64_t) 1<<(0x402F - exp);
135 roundBitsMask = lastBitMask - 1;
136 if ( roundingMode == softfloat_round_near_maxMag ) {
137 uiZ.v64 += lastBitMask>>1;
138 } else if ( roundingMode == softfloat_round_near_even ) {
139 uiZ.v64 += lastBitMask>>1;
140 if ( ! ((uiZ.v64 & roundBitsMask) | uiA0) ) {
141 uiZ.v64 &= ~lastBitMask;
142 }
143 } else if (
144 roundingMode
145 == (signF128UI64( uiZ.v64 ) ? softfloat_round_min
146 : softfloat_round_max)
147 ) {
148 uiZ.v64 = (uiZ.v64 | (uiA0 != 0)) + roundBitsMask;
149 }
150 uiZ.v64 &= ~roundBitsMask;
151 }
152 if ( exact && ((uiZ.v64 != uiA64) || (uiZ.v0 != uiA0)) ) {
153 softfloat_exceptionFlags |= softfloat_flag_inexact;
154 }
155 uiZ:
156 uZ.ui = uiZ;
157 return uZ.f;
158
159}
160
deps/SoftFloat-3d/source/f128_sqrt.c deleted-201
......@@ -1,201 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t f128_sqrt( float128_t a )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool signA;
49 int_fast32_t expA;
50 struct uint128 sigA, uiZ;
51 struct exp32_sig128 normExpSig;
52 int_fast32_t expZ;
53 uint_fast32_t sig32A, recipSqrt32, sig32Z;
54 struct uint128 rem;
55 uint32_t qs[3];
56 uint_fast32_t q;
57 uint_fast64_t x64, sig64Z;
58 struct uint128 y, term;
59 uint_fast64_t sigZExtra;
60 struct uint128 sigZ;
61 union ui128_f128 uZ;
62
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 uA.f = a;
66 uiA64 = uA.ui.v64;
67 uiA0 = uA.ui.v0;
68 signA = signF128UI64( uiA64 );
69 expA = expF128UI64( uiA64 );
70 sigA.v64 = fracF128UI64( uiA64 );
71 sigA.v0 = uiA0;
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 if ( expA == 0x7FFF ) {
75 if ( sigA.v64 | sigA.v0 ) {
76 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, 0, 0 );
77 goto uiZ;
78 }
79 if ( ! signA ) return a;
80 goto invalid;
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( signA ) {
85 if ( ! (expA | sigA.v64 | sigA.v0) ) return a;
86 goto invalid;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( ! expA ) {
91 if ( ! (sigA.v64 | sigA.v0) ) return a;
92 normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
93 expA = normExpSig.exp;
94 sigA = normExpSig.sig;
95 }
96 /*------------------------------------------------------------------------
97 | (`sig32Z' is guaranteed to be a lower bound on the square root of
98 | `sig32A', which makes `sig32Z' also a lower bound on the square root of
99 | `sigA'.)
100 *------------------------------------------------------------------------*/
101 expZ = ((expA - 0x3FFF)>>1) + 0x3FFE;
102 expA &= 1;
103 sigA.v64 |= UINT64_C( 0x0001000000000000 );
104 sig32A = sigA.v64>>17;
105 recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
106 sig32Z = ((uint_fast64_t) sig32A * recipSqrt32)>>32;
107 if ( expA ) {
108 sig32Z >>= 1;
109 rem = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 12 );
110 } else {
111 rem = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 13 );
112 }
113 qs[2] = sig32Z;
114 rem.v64 -= (uint_fast64_t) sig32Z * sig32Z;
115 /*------------------------------------------------------------------------
116 *------------------------------------------------------------------------*/
117 q = ((uint32_t) (rem.v64>>2) * (uint_fast64_t) recipSqrt32)>>32;
118 x64 = (uint_fast64_t) sig32Z<<32;
119 sig64Z = x64 + ((uint_fast64_t) q<<3);
120 y = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
121 /*------------------------------------------------------------------------
122 | (Repeating this loop is a rare occurrence.)
123 *------------------------------------------------------------------------*/
124 for (;;) {
125 term = softfloat_mul64ByShifted32To128( x64 + sig64Z, q );
126 rem = softfloat_sub128( y.v64, y.v0, term.v64, term.v0 );
127 if ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) ) break;
128 --q;
129 sig64Z -= 1<<3;
130 }
131 qs[1] = q;
132 /*------------------------------------------------------------------------
133 *------------------------------------------------------------------------*/
134 q = ((rem.v64>>2) * recipSqrt32)>>32;
135 y = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
136 sig64Z <<= 1;
137 /*------------------------------------------------------------------------
138 | (Repeating this loop is a rare occurrence.)
139 *------------------------------------------------------------------------*/
140 for (;;) {
141 term = softfloat_shortShiftLeft128( 0, sig64Z, 32 );
142 term = softfloat_add128( term.v64, term.v0, 0, (uint_fast64_t) q<<6 );
143 term = softfloat_mul128By32( term.v64, term.v0, q );
144 rem = softfloat_sub128( y.v64, y.v0, term.v64, term.v0 );
145 if ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) ) break;
146 --q;
147 }
148 qs[0] = q;
149 /*------------------------------------------------------------------------
150 *------------------------------------------------------------------------*/
151 q = (((rem.v64>>2) * recipSqrt32)>>32) + 2;
152 sigZExtra = (uint64_t) ((uint_fast64_t) q<<59);
153 term = softfloat_shortShiftLeft128( 0, qs[1], 53 );
154 sigZ =
155 softfloat_add128(
156 (uint_fast64_t) qs[2]<<18, ((uint_fast64_t) qs[0]<<24) + (q>>5),
157 term.v64, term.v0
158 );
159 /*------------------------------------------------------------------------
160 *------------------------------------------------------------------------*/
161 if ( (q & 0xF) <= 2 ) {
162 q &= ~3;
163 sigZExtra = (uint64_t) ((uint_fast64_t) q<<59);
164 y = softfloat_shortShiftLeft128( sigZ.v64, sigZ.v0, 6 );
165 y.v0 |= sigZExtra>>58;
166 term = softfloat_sub128( y.v64, y.v0, 0, q );
167 y = softfloat_mul64ByShifted32To128( term.v0, q );
168 term = softfloat_mul64ByShifted32To128( term.v64, q );
169 term = softfloat_add128( term.v64, term.v0, 0, y.v64 );
170 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 20 );
171 term = softfloat_sub128( term.v64, term.v0, rem.v64, rem.v0 );
172 /*--------------------------------------------------------------------
173 | The concatenation of `term' and `y.v0' is now the negative remainder
174 | (3 words altogether).
175 *--------------------------------------------------------------------*/
176 if ( term.v64 & UINT64_C( 0x8000000000000000 ) ) {
177 sigZExtra |= 1;
178 } else {
179 if ( term.v64 | term.v0 | y.v0 ) {
180 if ( sigZExtra ) {
181 --sigZExtra;
182 } else {
183 sigZ = softfloat_sub128( sigZ.v64, sigZ.v0, 0, 1 );
184 sigZExtra = ~0;
185 }
186 }
187 }
188 }
189 return softfloat_roundPackToF128( 0, expZ, sigZ.v64, sigZ.v0, sigZExtra );
190 /*------------------------------------------------------------------------
191 *------------------------------------------------------------------------*/
192 invalid:
193 softfloat_raiseFlags( softfloat_flag_invalid );
194 uiZ.v64 = defaultNaNF128UI64;
195 uiZ.v0 = defaultNaNF128UI0;
196 uiZ:
197 uZ.ui = uiZ;
198 return uZ.f;
199
200}
201
deps/SoftFloat-3d/source/f128_sub.c deleted-78
......@@ -1,78 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float128_t f128_sub( float128_t a, float128_t b )
44{
45 union ui128_f128 uA;
46 uint_fast64_t uiA64, uiA0;
47 bool signA;
48 union ui128_f128 uB;
49 uint_fast64_t uiB64, uiB0;
50 bool signB;
51#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
52 float128_t
53 (*magsFuncPtr)(
54 uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
55#endif
56
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 signA = signF128UI64( uiA64 );
61 uB.f = b;
62 uiB64 = uB.ui.v64;
63 uiB0 = uB.ui.v0;
64 signB = signF128UI64( uiB64 );
65#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
66 if ( signA == signB ) {
67 return softfloat_subMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
68 } else {
69 return softfloat_addMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
70 }
71#else
72 magsFuncPtr =
73 (signA == signB) ? softfloat_subMagsF128 : softfloat_addMagsF128;
74 return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
75#endif
76
77}
78
deps/SoftFloat-3d/source/f128_to_extF80.c deleted-109
......@@ -1,109 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t f128_to_extF80( float128_t a )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t frac64, frac0;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 uint_fast16_t uiZ64;
54 uint_fast64_t uiZ0;
55 struct exp32_sig128 normExpSig;
56 struct uint128 sig128;
57 union { struct extFloat80M s; extFloat80_t f; } uZ;
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 uA.f = a;
62 uiA64 = uA.ui.v64;
63 uiA0 = uA.ui.v0;
64 sign = signF128UI64( uiA64 );
65 exp = expF128UI64( uiA64 );
66 frac64 = fracF128UI64( uiA64 );
67 frac0 = uiA0;
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 if ( exp == 0x7FFF ) {
71 if ( frac64 | frac0 ) {
72 softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
73 uiZ = softfloat_commonNaNToExtF80UI( &commonNaN );
74 uiZ64 = uiZ.v64;
75 uiZ0 = uiZ.v0;
76 } else {
77 uiZ64 = packToExtF80UI64( sign, 0x7FFF );
78 uiZ0 = UINT64_C( 0x8000000000000000 );
79 }
80 goto uiZ;
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( ! exp ) {
85 if ( ! (frac64 | frac0) ) {
86 uiZ64 = packToExtF80UI64( sign, 0 );
87 uiZ0 = 0;
88 goto uiZ;
89 }
90 normExpSig = softfloat_normSubnormalF128Sig( frac64, frac0 );
91 exp = normExpSig.exp;
92 frac64 = normExpSig.sig.v64;
93 frac0 = normExpSig.sig.v0;
94 }
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 sig128 =
98 softfloat_shortShiftLeft128(
99 frac64 | UINT64_C( 0x0001000000000000 ), frac0, 15 );
100 return softfloat_roundPackToExtF80( sign, exp, sig128.v64, sig128.v0, 80 );
101 /*------------------------------------------------------------------------
102 *------------------------------------------------------------------------*/
103 uiZ:
104 uZ.s.signExp = uiZ64;
105 uZ.s.signif = uiZ0;
106 return uZ.f;
107
108}
109
deps/SoftFloat-3d/source/f128_to_f16.c deleted-95
......@@ -1,95 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t f128_to_f16( float128_t a )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t frac64;
51 struct commonNaN commonNaN;
52 uint_fast16_t uiZ, frac16;
53 union ui16_f16 uZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 sign = signF128UI64( uiA64 );
61 exp = expF128UI64( uiA64 );
62 frac64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0x7FFF ) {
66 if ( frac64 ) {
67 softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
68 uiZ = softfloat_commonNaNToF16UI( &commonNaN );
69 } else {
70 uiZ = packToF16UI( sign, 0x1F, 0 );
71 }
72 goto uiZ;
73 }
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 frac16 = softfloat_shortShiftRightJam64( frac64, 34 );
77 if ( ! (exp | frac16) ) {
78 uiZ = packToF16UI( sign, 0, 0 );
79 goto uiZ;
80 }
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 exp -= 0x3FF1;
84 if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
85 if ( exp < -0x40 ) exp = -0x40;
86 }
87 return softfloat_roundPackToF16( sign, exp, frac16 | 0x4000 );
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 uiZ:
91 uZ.ui = uiZ;
92 return uZ.f;
93
94}
95
deps/SoftFloat-3d/source/f128_to_f32.c deleted-95
......@@ -1,95 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t f128_to_f32( float128_t a )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t frac64;
51 struct commonNaN commonNaN;
52 uint_fast32_t uiZ, frac32;
53 union ui32_f32 uZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 sign = signF128UI64( uiA64 );
61 exp = expF128UI64( uiA64 );
62 frac64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0x7FFF ) {
66 if ( frac64 ) {
67 softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
68 uiZ = softfloat_commonNaNToF32UI( &commonNaN );
69 } else {
70 uiZ = packToF32UI( sign, 0xFF, 0 );
71 }
72 goto uiZ;
73 }
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 frac32 = softfloat_shortShiftRightJam64( frac64, 18 );
77 if ( ! (exp | frac32) ) {
78 uiZ = packToF32UI( sign, 0, 0 );
79 goto uiZ;
80 }
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 exp -= 0x3F81;
84 if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
85 if ( exp < -0x1000 ) exp = -0x1000;
86 }
87 return softfloat_roundPackToF32( sign, exp, frac32 | 0x40000000 );
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 uiZ:
91 uZ.ui = uiZ;
92 return uZ.f;
93
94}
95
deps/SoftFloat-3d/source/f128_to_f64.c deleted-100
......@@ -1,100 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t f128_to_f64( float128_t a )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t frac64, frac0;
51 struct commonNaN commonNaN;
52 uint_fast64_t uiZ;
53 struct uint128 frac128;
54 union ui64_f64 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.ui.v64;
60 uiA0 = uA.ui.v0;
61 sign = signF128UI64( uiA64 );
62 exp = expF128UI64( uiA64 );
63 frac64 = fracF128UI64( uiA64 );
64 frac0 = uiA0;
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( exp == 0x7FFF ) {
68 if ( frac64 | frac0 ) {
69 softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
70 uiZ = softfloat_commonNaNToF64UI( &commonNaN );
71 } else {
72 uiZ = packToF64UI( sign, 0x7FF, 0 );
73 }
74 goto uiZ;
75 }
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 frac128 = softfloat_shortShiftLeft128( frac64, frac0, 14 );
79 frac64 = frac128.v64 | (frac128.v0 != 0);
80 if ( ! (exp | frac64) ) {
81 uiZ = packToF64UI( sign, 0, 0 );
82 goto uiZ;
83 }
84 /*------------------------------------------------------------------------
85 *------------------------------------------------------------------------*/
86 exp -= 0x3C01;
87 if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
88 if ( exp < -0x1000 ) exp = -0x1000;
89 }
90 return
91 softfloat_roundPackToF64(
92 sign, exp, frac64 | UINT64_C( 0x4000000000000000 ) );
93 /*------------------------------------------------------------------------
94 *------------------------------------------------------------------------*/
95 uiZ:
96 uZ.ui = uiZ;
97 return uZ.f;
98
99}
100
deps/SoftFloat-3d/source/f128_to_i32.c deleted-85
......@@ -1,85 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t f128_to_i32( float128_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t sig64, sig0;
51 int_fast32_t shiftDist;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 uA.f = a;
56 uiA64 = uA.ui.v64;
57 uiA0 = uA.ui.v0;
58 sign = signF128UI64( uiA64 );
59 exp = expF128UI64( uiA64 );
60 sig64 = fracF128UI64( uiA64 );
61 sig0 = uiA0;
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
65 if ( (exp == 0x7FFF) && (sig64 | sig0) ) {
66#if (i32_fromNaN == i32_fromPosOverflow)
67 sign = 0;
68#elif (i32_fromNaN == i32_fromNegOverflow)
69 sign = 1;
70#else
71 softfloat_raiseFlags( softfloat_flag_invalid );
72 return i32_fromNaN;
73#endif
74 }
75#endif
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
79 sig64 |= (sig0 != 0);
80 shiftDist = 0x4023 - exp;
81 if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
82 return softfloat_roundToI32( sign, sig64, roundingMode, exact );
83
84}
85
deps/SoftFloat-3d/source/f128_to_i32_r_minMag.c deleted-100
......@@ -1,100 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t f128_to_i32_r_minMag( float128_t a, bool exact )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 int_fast32_t exp;
49 uint_fast64_t sig64;
50 int_fast32_t shiftDist;
51 bool sign;
52 int_fast32_t absZ;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.ui.v64;
58 uiA0 = uA.ui.v0;
59 exp = expF128UI64( uiA64 );
60 sig64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 shiftDist = 0x402F - exp;
64 if ( 49 <= shiftDist ) {
65 if ( exact && (exp | sig64) ) {
66 softfloat_exceptionFlags |= softfloat_flag_inexact;
67 }
68 return 0;
69 }
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 sign = signF128UI64( uiA64 );
73 if ( shiftDist < 18 ) {
74 if (
75 sign && (shiftDist == 17)
76 && (sig64 < UINT64_C( 0x0000000000020000 ))
77 ) {
78 if ( exact && sig64 ) {
79 softfloat_exceptionFlags |= softfloat_flag_inexact;
80 }
81 return -0x7FFFFFFF - 1;
82 }
83 softfloat_raiseFlags( softfloat_flag_invalid );
84 return
85 (exp == 0x7FFF) && sig64 ? i32_fromNaN
86 : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 sig64 |= UINT64_C( 0x0001000000000000 );
91 absZ = sig64>>shiftDist;
92 if (
93 exact && ((uint_fast64_t) (uint_fast32_t) absZ<<shiftDist != sig64)
94 ) {
95 softfloat_exceptionFlags |= softfloat_flag_inexact;
96 }
97 return sign ? -absZ : absZ;
98
99}
100
deps/SoftFloat-3d/source/f128_to_i64.c deleted-95
......@@ -1,95 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t f128_to_i64( float128_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t sig64, sig0;
51 int_fast32_t shiftDist;
52 struct uint128 sig128;
53 struct uint64_extra sigExtra;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 sign = signF128UI64( uiA64 );
61 exp = expF128UI64( uiA64 );
62 sig64 = fracF128UI64( uiA64 );
63 sig0 = uiA0;
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 shiftDist = 0x402F - exp;
67 if ( shiftDist <= 0 ) {
68 /*--------------------------------------------------------------------
69 *--------------------------------------------------------------------*/
70 if ( shiftDist < -15 ) {
71 softfloat_raiseFlags( softfloat_flag_invalid );
72 return
73 (exp == 0x7FFF) && (sig64 | sig0) ? i64_fromNaN
74 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
75 }
76 /*--------------------------------------------------------------------
77 *--------------------------------------------------------------------*/
78 sig64 |= UINT64_C( 0x0001000000000000 );
79 if ( shiftDist ) {
80 sig128 = softfloat_shortShiftLeft128( sig64, sig0, -shiftDist );
81 sig64 = sig128.v64;
82 sig0 = sig128.v0;
83 }
84 } else {
85 /*--------------------------------------------------------------------
86 *--------------------------------------------------------------------*/
87 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
88 sigExtra = softfloat_shiftRightJam64Extra( sig64, sig0, shiftDist );
89 sig64 = sigExtra.v;
90 sig0 = sigExtra.extra;
91 }
92 return softfloat_roundToI64( sign, sig64, sig0, roundingMode, exact );
93
94}
95
deps/SoftFloat-3d/source/f128_to_i64_r_minMag.c deleted-113
......@@ -1,113 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t f128_to_i64_r_minMag( float128_t a, bool exact )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t sig64, sig0;
51 int_fast32_t shiftDist;
52 int_fast8_t negShiftDist;
53 int_fast64_t absZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 sign = signF128UI64( uiA64 );
61 exp = expF128UI64( uiA64 );
62 sig64 = fracF128UI64( uiA64 );
63 sig0 = uiA0;
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 shiftDist = 0x402F - exp;
67 if ( shiftDist < 0 ) {
68 /*--------------------------------------------------------------------
69 *--------------------------------------------------------------------*/
70 if ( shiftDist < -14 ) {
71 if (
72 (uiA64 == UINT64_C( 0xC03E000000000000 ))
73 && (sig0 < UINT64_C( 0x0002000000000000 ))
74 ) {
75 if ( exact && sig0 ) {
76 softfloat_exceptionFlags |= softfloat_flag_inexact;
77 }
78 return -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
79 }
80 softfloat_raiseFlags( softfloat_flag_invalid );
81 return
82 (exp == 0x7FFF) && (sig64 | sig0) ? i64_fromNaN
83 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
84 }
85 /*--------------------------------------------------------------------
86 *--------------------------------------------------------------------*/
87 sig64 |= UINT64_C( 0x0001000000000000 );
88 negShiftDist = -shiftDist;
89 absZ = sig64<<negShiftDist | sig0>>(shiftDist & 63);
90 if ( exact && (uint64_t) (sig0<<negShiftDist) ) {
91 softfloat_exceptionFlags |= softfloat_flag_inexact;
92 }
93 } else {
94 /*--------------------------------------------------------------------
95 *--------------------------------------------------------------------*/
96 if ( 49 <= shiftDist ) {
97 if ( exact && (exp | sig64 | sig0) ) {
98 softfloat_exceptionFlags |= softfloat_flag_inexact;
99 }
100 return 0;
101 }
102 /*--------------------------------------------------------------------
103 *--------------------------------------------------------------------*/
104 sig64 |= UINT64_C( 0x0001000000000000 );
105 absZ = sig64>>shiftDist;
106 if ( exact && (sig0 || (absZ<<shiftDist != sig64)) ) {
107 softfloat_exceptionFlags |= softfloat_flag_inexact;
108 }
109 }
110 return sign ? -absZ : absZ;
111
112}
113
deps/SoftFloat-3d/source/f128_to_ui32.c deleted-86
......@@ -1,86 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t
45 f128_to_ui32( float128_t a, uint_fast8_t roundingMode, bool exact )
46{
47 union ui128_f128 uA;
48 uint_fast64_t uiA64, uiA0;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig64;
52 int_fast32_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.ui.v64;
58 uiA0 = uA.ui.v0;
59 sign = signF128UI64( uiA64 );
60 exp = expF128UI64( uiA64 );
61 sig64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64#if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
65 if ( (exp == 0x7FFF) && sig64 ) {
66#if (ui32_fromNaN == ui32_fromPosOverflow)
67 sign = 0;
68#elif (ui32_fromNaN == ui32_fromNegOverflow)
69 sign = 1;
70#else
71 softfloat_raiseFlags( softfloat_flag_invalid );
72 return ui32_fromNaN;
73#endif
74 }
75#endif
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
79 shiftDist = 0x4023 - exp;
80 if ( 0 < shiftDist ) {
81 sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
82 }
83 return softfloat_roundToUI32( sign, sig64, roundingMode, exact );
84
85}
86
deps/SoftFloat-3d/source/f128_to_ui32_r_minMag.c deleted-89
......@@ -1,89 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t f128_to_ui32_r_minMag( float128_t a, bool exact )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 int_fast32_t exp;
49 uint_fast64_t sig64;
50 int_fast32_t shiftDist;
51 bool sign;
52 uint_fast32_t z;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.ui.v64;
58 uiA0 = uA.ui.v0;
59 exp = expF128UI64( uiA64 );
60 sig64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 shiftDist = 0x402F - exp;
64 if ( 49 <= shiftDist ) {
65 if ( exact && (exp | sig64) ) {
66 softfloat_exceptionFlags |= softfloat_flag_inexact;
67 }
68 return 0;
69 }
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 sign = signF128UI64( uiA64 );
73 if ( sign || (shiftDist < 17) ) {
74 softfloat_raiseFlags( softfloat_flag_invalid );
75 return
76 (exp == 0x7FFF) && sig64 ? ui32_fromNaN
77 : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 sig64 |= UINT64_C( 0x0001000000000000 );
82 z = sig64>>shiftDist;
83 if ( exact && ((uint_fast64_t) z<<shiftDist != sig64) ) {
84 softfloat_exceptionFlags |= softfloat_flag_inexact;
85 }
86 return z;
87
88}
89
deps/SoftFloat-3d/source/f128_to_ui64.c deleted-96
......@@ -1,96 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t
45 f128_to_ui64( float128_t a, uint_fast8_t roundingMode, bool exact )
46{
47 union ui128_f128 uA;
48 uint_fast64_t uiA64, uiA0;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig64, sig0;
52 int_fast32_t shiftDist;
53 struct uint128 sig128;
54 struct uint64_extra sigExtra;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.ui.v64;
60 uiA0 = uA.ui.v0;
61 sign = signF128UI64( uiA64 );
62 exp = expF128UI64( uiA64 );
63 sig64 = fracF128UI64( uiA64 );
64 sig0 = uiA0;
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 shiftDist = 0x402F - exp;
68 if ( shiftDist <= 0 ) {
69 /*--------------------------------------------------------------------
70 *--------------------------------------------------------------------*/
71 if ( shiftDist < -15 ) {
72 softfloat_raiseFlags( softfloat_flag_invalid );
73 return
74 (exp == 0x7FFF) && (sig64 | sig0) ? ui64_fromNaN
75 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
76 }
77 /*--------------------------------------------------------------------
78 *--------------------------------------------------------------------*/
79 sig64 |= UINT64_C( 0x0001000000000000 );
80 if ( shiftDist ) {
81 sig128 = softfloat_shortShiftLeft128( sig64, sig0, -shiftDist );
82 sig64 = sig128.v64;
83 sig0 = sig128.v0;
84 }
85 } else {
86 /*--------------------------------------------------------------------
87 *--------------------------------------------------------------------*/
88 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
89 sigExtra = softfloat_shiftRightJam64Extra( sig64, sig0, shiftDist );
90 sig64 = sigExtra.v;
91 sig0 = sigExtra.extra;
92 }
93 return softfloat_roundToUI64( sign, sig64, sig0, roundingMode, exact );
94
95}
96
deps/SoftFloat-3d/source/f128_to_ui64_r_minMag.c deleted-105
......@@ -1,105 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t f128_to_ui64_r_minMag( float128_t a, bool exact )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t sig64, sig0;
51 int_fast32_t shiftDist;
52 int_fast8_t negShiftDist;
53 uint_fast64_t z;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 sign = signF128UI64( uiA64 );
61 exp = expF128UI64( uiA64 );
62 sig64 = fracF128UI64( uiA64 );
63 sig0 = uiA0;
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 shiftDist = 0x402F - exp;
67 if ( shiftDist < 0 ) {
68 /*--------------------------------------------------------------------
69 *--------------------------------------------------------------------*/
70 if ( sign || (shiftDist < -15) ) goto invalid;
71 sig64 |= UINT64_C( 0x0001000000000000 );
72 negShiftDist = -shiftDist;
73 z = sig64<<negShiftDist | sig0>>(shiftDist & 63);
74 if ( exact && (uint64_t) (sig0<<negShiftDist) ) {
75 softfloat_exceptionFlags |= softfloat_flag_inexact;
76 }
77 } else {
78 /*--------------------------------------------------------------------
79 *--------------------------------------------------------------------*/
80 if ( 49 <= shiftDist ) {
81 if ( exact && (exp | sig64 | sig0) ) {
82 softfloat_exceptionFlags |= softfloat_flag_inexact;
83 }
84 return 0;
85 }
86 /*--------------------------------------------------------------------
87 *--------------------------------------------------------------------*/
88 if ( sign ) goto invalid;
89 sig64 |= UINT64_C( 0x0001000000000000 );
90 z = sig64>>shiftDist;
91 if ( exact && (sig0 || (z<<shiftDist != sig64)) ) {
92 softfloat_exceptionFlags |= softfloat_flag_inexact;
93 }
94 }
95 return z;
96 /*------------------------------------------------------------------------
97 *------------------------------------------------------------------------*/
98 invalid:
99 softfloat_raiseFlags( softfloat_flag_invalid );
100 return
101 (exp == 0x7FFF) && (sig64 | sig0) ? ui64_fromNaN
102 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
103
104}
105
deps/SoftFloat-3d/source/f16_add.c deleted-70
......@@ -1,70 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float16_t f16_add( float16_t a, float16_t b )
44{
45 union ui16_f16 uA;
46 uint_fast16_t uiA;
47 union ui16_f16 uB;
48 uint_fast16_t uiB;
49#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
50 float16_t (*magsFuncPtr)( uint_fast16_t, uint_fast16_t );
51#endif
52
53 uA.f = a;
54 uiA = uA.ui;
55 uB.f = b;
56 uiB = uB.ui;
57#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
58 if ( signF16UI( uiA ^ uiB ) ) {
59 return softfloat_subMagsF16( uiA, uiB );
60 } else {
61 return softfloat_addMagsF16( uiA, uiB );
62 }
63#else
64 magsFuncPtr =
65 signF16UI( uiA ^ uiB ) ? softfloat_subMagsF16 : softfloat_addMagsF16;
66 return (*magsFuncPtr)( uiA, uiB );
67#endif
68
69}
70
deps/SoftFloat-3d/source/f16_div.c deleted-186
......@@ -1,186 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extern const uint16_t softfloat_approxRecip_1k0s[];
45extern const uint16_t softfloat_approxRecip_1k1s[];
46
47float16_t f16_div( float16_t a, float16_t b )
48{
49 union ui16_f16 uA;
50 uint_fast16_t uiA;
51 bool signA;
52 int_fast8_t expA;
53 uint_fast16_t sigA;
54 union ui16_f16 uB;
55 uint_fast16_t uiB;
56 bool signB;
57 int_fast8_t expB;
58 uint_fast16_t sigB;
59 bool signZ;
60 struct exp8_sig16 normExpSig;
61 int_fast8_t expZ;
62#ifdef SOFTFLOAT_FAST_DIV32TO16
63 uint_fast32_t sig32A;
64 uint_fast16_t sigZ;
65#else
66 int index;
67 uint16_t r0;
68 uint_fast16_t sigZ, rem;
69#endif
70 uint_fast16_t uiZ;
71 union ui16_f16 uZ;
72
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 uA.f = a;
76 uiA = uA.ui;
77 signA = signF16UI( uiA );
78 expA = expF16UI( uiA );
79 sigA = fracF16UI( uiA );
80 uB.f = b;
81 uiB = uB.ui;
82 signB = signF16UI( uiB );
83 expB = expF16UI( uiB );
84 sigB = fracF16UI( uiB );
85 signZ = signA ^ signB;
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 if ( expA == 0x1F ) {
89 if ( sigA ) goto propagateNaN;
90 if ( expB == 0x1F ) {
91 if ( sigB ) goto propagateNaN;
92 goto invalid;
93 }
94 goto infinity;
95 }
96 if ( expB == 0x1F ) {
97 if ( sigB ) goto propagateNaN;
98 goto zero;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 if ( ! expB ) {
103 if ( ! sigB ) {
104 if ( ! (expA | sigA) ) goto invalid;
105 softfloat_raiseFlags( softfloat_flag_infinite );
106 goto infinity;
107 }
108 normExpSig = softfloat_normSubnormalF16Sig( sigB );
109 expB = normExpSig.exp;
110 sigB = normExpSig.sig;
111 }
112 if ( ! expA ) {
113 if ( ! sigA ) goto zero;
114 normExpSig = softfloat_normSubnormalF16Sig( sigA );
115 expA = normExpSig.exp;
116 sigA = normExpSig.sig;
117 }
118 /*------------------------------------------------------------------------
119 *------------------------------------------------------------------------*/
120 expZ = expA - expB + 0xE;
121 sigA |= 0x0400;
122 sigB |= 0x0400;
123#ifdef SOFTFLOAT_FAST_DIV32TO16
124 if ( sigA < sigB ) {
125 --expZ;
126 sig32A = (uint_fast32_t) sigA<<15;
127 } else {
128 sig32A = (uint_fast32_t) sigA<<14;
129 }
130 sigZ = sig32A / sigB;
131 if ( ! (sigZ & 7) ) sigZ |= ((uint_fast32_t) sigB * sigZ != sig32A);
132#else
133 if ( sigA < sigB ) {
134 --expZ;
135 sigA <<= 5;
136 } else {
137 sigA <<= 4;
138 }
139 index = sigB>>6 & 0xF;
140 r0 = softfloat_approxRecip_1k0s[index]
141 - (((uint_fast32_t) softfloat_approxRecip_1k1s[index]
142 * (sigB & 0x3F))
143 >>10);
144 sigZ = ((uint_fast32_t) sigA * r0)>>16;
145 rem = (sigA<<10) - sigZ * sigB;
146 sigZ += (rem * (uint_fast32_t) r0)>>26;
147 /*------------------------------------------------------------------------
148 *------------------------------------------------------------------------*/
149 ++sigZ;
150 if ( ! (sigZ & 7) ) {
151 sigZ &= ~1;
152 rem = (sigA<<10) - sigZ * sigB;
153 if ( rem & 0x8000 ) {
154 sigZ -= 2;
155 } else {
156 if ( rem ) sigZ |= 1;
157 }
158 }
159#endif
160 return softfloat_roundPackToF16( signZ, expZ, sigZ );
161 /*------------------------------------------------------------------------
162 *------------------------------------------------------------------------*/
163 propagateNaN:
164 uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
165 goto uiZ;
166 /*------------------------------------------------------------------------
167 *------------------------------------------------------------------------*/
168 invalid:
169 softfloat_raiseFlags( softfloat_flag_invalid );
170 uiZ = defaultNaNF16UI;
171 goto uiZ;
172 /*------------------------------------------------------------------------
173 *------------------------------------------------------------------------*/
174 infinity:
175 uiZ = packToF16UI( signZ, 0x1F, 0 );
176 goto uiZ;
177 /*------------------------------------------------------------------------
178 *------------------------------------------------------------------------*/
179 zero:
180 uiZ = packToF16UI( signZ, 0, 0 );
181 uiZ:
182 uZ.ui = uiZ;
183 return uZ.f;
184
185}
186
deps/SoftFloat-3d/source/f16_eq.c deleted-66
......@@ -1,66 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f16_eq( float16_t a, float16_t b )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 union ui16_f16 uB;
49 uint_fast16_t uiB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
56 if (
57 softfloat_isSigNaNF16UI( uiA ) || softfloat_isSigNaNF16UI( uiB )
58 ) {
59 softfloat_raiseFlags( softfloat_flag_invalid );
60 }
61 return false;
62 }
63 return (uiA == uiB) || ! (uint16_t) ((uiA | uiB)<<1);
64
65}
66
deps/SoftFloat-3d/source/f16_eq_signaling.c deleted-61
......@@ -1,61 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f16_eq_signaling( float16_t a, float16_t b )
44{
45 union ui16_f16 uA;
46 uint_fast16_t uiA;
47 union ui16_f16 uB;
48 uint_fast16_t uiB;
49
50 uA.f = a;
51 uiA = uA.ui;
52 uB.f = b;
53 uiB = uB.ui;
54 if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
55 softfloat_raiseFlags( softfloat_flag_invalid );
56 return false;
57 }
58 return (uiA == uiB) || ! (uint16_t) ((uiA | uiB)<<1);
59
60}
61
deps/SoftFloat-3d/source/f16_isSignalingNaN.c deleted-51
......@@ -1,51 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43bool f16_isSignalingNaN( float16_t a )
44{
45 union ui16_f16 uA;
46
47 uA.f = a;
48 return softfloat_isSigNaNF16UI( uA.ui );
49
50}
51
deps/SoftFloat-3d/source/f16_le.c deleted-66
......@@ -1,66 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f16_le( float16_t a, float16_t b )
44{
45 union ui16_f16 uA;
46 uint_fast16_t uiA;
47 union ui16_f16 uB;
48 uint_fast16_t uiB;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
56 softfloat_raiseFlags( softfloat_flag_invalid );
57 return false;
58 }
59 signA = signF16UI( uiA );
60 signB = signF16UI( uiB );
61 return
62 (signA != signB) ? signA || ! (uint16_t) ((uiA | uiB)<<1)
63 : (uiA == uiB) || (signA ^ (uiA < uiB));
64
65}
66
deps/SoftFloat-3d/source/f16_le_quiet.c deleted-71
......@@ -1,71 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f16_le_quiet( float16_t a, float16_t b )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 union ui16_f16 uB;
49 uint_fast16_t uiB;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA = uA.ui;
54 uB.f = b;
55 uiB = uB.ui;
56 if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
57 if (
58 softfloat_isSigNaNF16UI( uiA ) || softfloat_isSigNaNF16UI( uiB )
59 ) {
60 softfloat_raiseFlags( softfloat_flag_invalid );
61 }
62 return false;
63 }
64 signA = signF16UI( uiA );
65 signB = signF16UI( uiB );
66 return
67 (signA != signB) ? signA || ! (uint16_t) ((uiA | uiB)<<1)
68 : (uiA == uiB) || (signA ^ (uiA < uiB));
69
70}
71
deps/SoftFloat-3d/source/f16_lt.c deleted-66
......@@ -1,66 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f16_lt( float16_t a, float16_t b )
44{
45 union ui16_f16 uA;
46 uint_fast16_t uiA;
47 union ui16_f16 uB;
48 uint_fast16_t uiB;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
56 softfloat_raiseFlags( softfloat_flag_invalid );
57 return false;
58 }
59 signA = signF16UI( uiA );
60 signB = signF16UI( uiB );
61 return
62 (signA != signB) ? signA && ((uint16_t) ((uiA | uiB)<<1) != 0)
63 : (uiA != uiB) && (signA ^ (uiA < uiB));
64
65}
66
deps/SoftFloat-3d/source/f16_lt_quiet.c deleted-71
......@@ -1,71 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f16_lt_quiet( float16_t a, float16_t b )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 union ui16_f16 uB;
49 uint_fast16_t uiB;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA = uA.ui;
54 uB.f = b;
55 uiB = uB.ui;
56 if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
57 if (
58 softfloat_isSigNaNF16UI( uiA ) || softfloat_isSigNaNF16UI( uiB )
59 ) {
60 softfloat_raiseFlags( softfloat_flag_invalid );
61 }
62 return false;
63 }
64 signA = signF16UI( uiA );
65 signB = signF16UI( uiB );
66 return
67 (signA != signB) ? signA && ((uint16_t) ((uiA | uiB)<<1) != 0)
68 : (uiA != uiB) && (signA ^ (uiA < uiB));
69
70}
71
deps/SoftFloat-3d/source/f16_mul.c deleted-140
......@@ -1,140 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t f16_mul( float16_t a, float16_t b )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool signA;
49 int_fast8_t expA;
50 uint_fast16_t sigA;
51 union ui16_f16 uB;
52 uint_fast16_t uiB;
53 bool signB;
54 int_fast8_t expB;
55 uint_fast16_t sigB;
56 bool signZ;
57 uint_fast16_t magBits;
58 struct exp8_sig16 normExpSig;
59 int_fast8_t expZ;
60 uint_fast32_t sig32Z;
61 uint_fast16_t sigZ, uiZ;
62 union ui16_f16 uZ;
63
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 uA.f = a;
67 uiA = uA.ui;
68 signA = signF16UI( uiA );
69 expA = expF16UI( uiA );
70 sigA = fracF16UI( uiA );
71 uB.f = b;
72 uiB = uB.ui;
73 signB = signF16UI( uiB );
74 expB = expF16UI( uiB );
75 sigB = fracF16UI( uiB );
76 signZ = signA ^ signB;
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 if ( expA == 0x1F ) {
80 if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN;
81 magBits = expB | sigB;
82 goto infArg;
83 }
84 if ( expB == 0x1F ) {
85 if ( sigB ) goto propagateNaN;
86 magBits = expA | sigA;
87 goto infArg;
88 }
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 if ( ! expA ) {
92 if ( ! sigA ) goto zero;
93 normExpSig = softfloat_normSubnormalF16Sig( sigA );
94 expA = normExpSig.exp;
95 sigA = normExpSig.sig;
96 }
97 if ( ! expB ) {
98 if ( ! sigB ) goto zero;
99 normExpSig = softfloat_normSubnormalF16Sig( sigB );
100 expB = normExpSig.exp;
101 sigB = normExpSig.sig;
102 }
103 /*------------------------------------------------------------------------
104 *------------------------------------------------------------------------*/
105 expZ = expA + expB - 0xF;
106 sigA = (sigA | 0x0400)<<4;
107 sigB = (sigB | 0x0400)<<5;
108 sig32Z = (uint_fast32_t) sigA * sigB;
109 sigZ = sig32Z>>16;
110 if ( sig32Z & 0xFFFF ) sigZ |= 1;
111 if ( sigZ < 0x4000 ) {
112 --expZ;
113 sigZ <<= 1;
114 }
115 return softfloat_roundPackToF16( signZ, expZ, sigZ );
116 /*------------------------------------------------------------------------
117 *------------------------------------------------------------------------*/
118 propagateNaN:
119 uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
120 goto uiZ;
121 /*------------------------------------------------------------------------
122 *------------------------------------------------------------------------*/
123 infArg:
124 if ( ! magBits ) {
125 softfloat_raiseFlags( softfloat_flag_invalid );
126 uiZ = defaultNaNF16UI;
127 } else {
128 uiZ = packToF16UI( signZ, 0x1F, 0 );
129 }
130 goto uiZ;
131 /*------------------------------------------------------------------------
132 *------------------------------------------------------------------------*/
133 zero:
134 uiZ = packToF16UI( signZ, 0, 0 );
135 uiZ:
136 uZ.ui = uiZ;
137 return uZ.f;
138
139}
140
deps/SoftFloat-3d/source/f16_mulAdd.c deleted-60
......@@ -1,60 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float16_t f16_mulAdd( float16_t a, float16_t b, float16_t c )
43{
44 union ui16_f16 uA;
45 uint_fast16_t uiA;
46 union ui16_f16 uB;
47 uint_fast16_t uiB;
48 union ui16_f16 uC;
49 uint_fast16_t uiC;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 uC.f = c;
56 uiC = uC.ui;
57 return softfloat_mulAddF16( uiA, uiB, uiC, 0 );
58
59}
60
deps/SoftFloat-3d/source/f16_rem.c deleted-171
......@@ -1,171 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t f16_rem( float16_t a, float16_t b )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool signA;
49 int_fast8_t expA;
50 uint_fast16_t sigA;
51 union ui16_f16 uB;
52 uint_fast16_t uiB;
53 int_fast8_t expB;
54 uint_fast16_t sigB;
55 struct exp8_sig16 normExpSig;
56 uint16_t rem;
57 int_fast8_t expDiff;
58 uint_fast16_t q;
59 uint32_t recip32, q32;
60 uint16_t altRem, meanRem;
61 bool signRem;
62 uint_fast16_t uiZ;
63 union ui16_f16 uZ;
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 uA.f = a;
68 uiA = uA.ui;
69 signA = signF16UI( uiA );
70 expA = expF16UI( uiA );
71 sigA = fracF16UI( uiA );
72 uB.f = b;
73 uiB = uB.ui;
74 expB = expF16UI( uiB );
75 sigB = fracF16UI( uiB );
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( expA == 0x1F ) {
79 if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN;
80 goto invalid;
81 }
82 if ( expB == 0x1F ) {
83 if ( sigB ) goto propagateNaN;
84 return a;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 if ( ! expB ) {
89 if ( ! sigB ) goto invalid;
90 normExpSig = softfloat_normSubnormalF16Sig( sigB );
91 expB = normExpSig.exp;
92 sigB = normExpSig.sig;
93 }
94 if ( ! expA ) {
95 if ( ! sigA ) return a;
96 normExpSig = softfloat_normSubnormalF16Sig( sigA );
97 expA = normExpSig.exp;
98 sigA = normExpSig.sig;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 rem = sigA | 0x0400;
103 sigB |= 0x0400;
104 expDiff = expA - expB;
105 if ( expDiff < 1 ) {
106 if ( expDiff < -1 ) return a;
107 sigB <<= 3;
108 if ( expDiff ) {
109 rem <<= 2;
110 q = 0;
111 } else {
112 rem <<= 3;
113 q = (sigB <= rem);
114 if ( q ) rem -= sigB;
115 }
116 } else {
117 recip32 = softfloat_approxRecip32_1( (uint_fast32_t) sigB<<21 );
118 /*--------------------------------------------------------------------
119 | Changing the shift of `rem' here requires also changing the initial
120 | subtraction from `expDiff'.
121 *--------------------------------------------------------------------*/
122 rem <<= 4;
123 expDiff -= 31;
124 /*--------------------------------------------------------------------
125 | The scale of `sigB' affects how many bits are obtained during each
126 | cycle of the loop. Currently this is 29 bits per loop iteration,
127 | which is believed to be the maximum possible.
128 *--------------------------------------------------------------------*/
129 sigB <<= 3;
130 for (;;) {
131 q32 = (rem * (uint_fast64_t) recip32)>>16;
132 if ( expDiff < 0 ) break;
133 rem = -((uint_fast16_t) q32 * sigB);
134 expDiff -= 29;
135 }
136 /*--------------------------------------------------------------------
137 | (`expDiff' cannot be less than -30 here.)
138 *--------------------------------------------------------------------*/
139 q32 >>= ~expDiff & 31;
140 q = q32;
141 rem = (rem<<(expDiff + 30)) - q * sigB;
142 }
143 /*------------------------------------------------------------------------
144 *------------------------------------------------------------------------*/
145 do {
146 altRem = rem;
147 ++q;
148 rem -= sigB;
149 } while ( ! (rem & 0x8000) );
150 meanRem = rem + altRem;
151 if ( (meanRem & 0x8000) || (! meanRem && (q & 1)) ) rem = altRem;
152 signRem = signA;
153 if ( 0x8000 <= rem ) {
154 signRem = ! signRem;
155 rem = -rem;
156 }
157 return softfloat_normRoundPackToF16( signRem, expB, rem );
158 /*------------------------------------------------------------------------
159 *------------------------------------------------------------------------*/
160 propagateNaN:
161 uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
162 goto uiZ;
163 invalid:
164 softfloat_raiseFlags( softfloat_flag_invalid );
165 uiZ = defaultNaNF16UI;
166 uiZ:
167 uZ.ui = uiZ;
168 return uZ.f;
169
170}
171
deps/SoftFloat-3d/source/f16_roundToInt.c deleted-112
......@@ -1,112 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t f16_roundToInt( float16_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 int_fast8_t exp;
49 uint_fast16_t uiZ, lastBitMask, roundBitsMask;
50 union ui16_f16 uZ;
51
52 /*------------------------------------------------------------------------
53 *------------------------------------------------------------------------*/
54 uA.f = a;
55 uiA = uA.ui;
56 exp = expF16UI( uiA );
57 /*------------------------------------------------------------------------
58 *------------------------------------------------------------------------*/
59 if ( exp <= 0xE ) {
60 if ( ! (uint16_t) (uiA<<1) ) return a;
61 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
62 uiZ = uiA & packToF16UI( 1, 0, 0 );
63 switch ( roundingMode ) {
64 case softfloat_round_near_even:
65 if ( ! fracF16UI( uiA ) ) break;
66 case softfloat_round_near_maxMag:
67 if ( exp == 0xE ) uiZ |= packToF16UI( 0, 0xF, 0 );
68 break;
69 case softfloat_round_min:
70 if ( uiZ ) uiZ = packToF16UI( 1, 0xF, 0 );
71 break;
72 case softfloat_round_max:
73 if ( ! uiZ ) uiZ = packToF16UI( 0, 0xF, 0 );
74 break;
75 }
76 goto uiZ;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 if ( 0x19 <= exp ) {
81 if ( (exp == 0x1F) && fracF16UI( uiA ) ) {
82 uiZ = softfloat_propagateNaNF16UI( uiA, 0 );
83 goto uiZ;
84 }
85 return a;
86 }
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 uiZ = uiA;
90 lastBitMask = (uint_fast16_t) 1<<(0x19 - exp);
91 roundBitsMask = lastBitMask - 1;
92 if ( roundingMode == softfloat_round_near_maxMag ) {
93 uiZ += lastBitMask>>1;
94 } else if ( roundingMode == softfloat_round_near_even ) {
95 uiZ += lastBitMask>>1;
96 if ( ! (uiZ & roundBitsMask) ) uiZ &= ~lastBitMask;
97 } else if (
98 roundingMode
99 == (signF16UI( uiZ ) ? softfloat_round_min : softfloat_round_max)
100 ) {
101 uiZ += roundBitsMask;
102 }
103 uiZ &= ~roundBitsMask;
104 if ( exact && (uiZ != uiA) ) {
105 softfloat_exceptionFlags |= softfloat_flag_inexact;
106 }
107 uiZ:
108 uZ.ui = uiZ;
109 return uZ.f;
110
111}
112
deps/SoftFloat-3d/source/f16_sqrt.c deleted-136
......@@ -1,136 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extern const uint16_t softfloat_approxRecipSqrt_1k0s[];
45extern const uint16_t softfloat_approxRecipSqrt_1k1s[];
46
47float16_t f16_sqrt( float16_t a )
48{
49 union ui16_f16 uA;
50 uint_fast16_t uiA;
51 bool signA;
52 int_fast8_t expA;
53 uint_fast16_t sigA, uiZ;
54 struct exp8_sig16 normExpSig;
55 int_fast8_t expZ;
56 int index;
57 uint_fast16_t r0;
58 uint_fast32_t ESqrR0;
59 uint16_t sigma0;
60 uint_fast16_t recipSqrt16, sigZ, shiftedSigZ;
61 uint16_t negRem;
62 union ui16_f16 uZ;
63
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 uA.f = a;
67 uiA = uA.ui;
68 signA = signF16UI( uiA );
69 expA = expF16UI( uiA );
70 sigA = fracF16UI( uiA );
71 /*------------------------------------------------------------------------
72 *------------------------------------------------------------------------*/
73 if ( expA == 0x1F ) {
74 if ( sigA ) {
75 uiZ = softfloat_propagateNaNF16UI( uiA, 0 );
76 goto uiZ;
77 }
78 if ( ! signA ) return a;
79 goto invalid;
80 }
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 if ( signA ) {
84 if ( ! (expA | sigA) ) return a;
85 goto invalid;
86 }
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 if ( ! expA ) {
90 if ( ! sigA ) return a;
91 normExpSig = softfloat_normSubnormalF16Sig( sigA );
92 expA = normExpSig.exp;
93 sigA = normExpSig.sig;
94 }
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 expZ = ((expA - 0xF)>>1) + 0xE;
98 expA &= 1;
99 sigA |= 0x0400;
100 index = (sigA>>6 & 0xE) + expA;
101 r0 = softfloat_approxRecipSqrt_1k0s[index]
102 - (((uint_fast32_t) softfloat_approxRecipSqrt_1k1s[index]
103 * (sigA & 0x7F))
104 >>11);
105 ESqrR0 = ((uint_fast32_t) r0 * r0)>>1;
106 if ( expA ) ESqrR0 >>= 1;
107 sigma0 = ~(uint_fast16_t) ((ESqrR0 * sigA)>>16);
108 recipSqrt16 = r0 + (((uint_fast32_t) r0 * sigma0)>>25);
109 if ( ! (recipSqrt16 & 0x8000) ) recipSqrt16 = 0x8000;
110 sigZ = ((uint_fast32_t) (sigA<<5) * recipSqrt16)>>16;
111 if ( expA ) sigZ >>= 1;
112 /*------------------------------------------------------------------------
113 *------------------------------------------------------------------------*/
114 ++sigZ;
115 if ( ! (sigZ & 7) ) {
116 shiftedSigZ = sigZ>>1;
117 negRem = shiftedSigZ * shiftedSigZ;
118 sigZ &= ~1;
119 if ( negRem & 0x8000 ) {
120 sigZ |= 1;
121 } else {
122 if ( negRem ) --sigZ;
123 }
124 }
125 return softfloat_roundPackToF16( 0, expZ, sigZ );
126 /*------------------------------------------------------------------------
127 *------------------------------------------------------------------------*/
128 invalid:
129 softfloat_raiseFlags( softfloat_flag_invalid );
130 uiZ = defaultNaNF16UI;
131 uiZ:
132 uZ.ui = uiZ;
133 return uZ.f;
134
135}
136
deps/SoftFloat-3d/source/f16_sub.c deleted-70
......@@ -1,70 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float16_t f16_sub( float16_t a, float16_t b )
44{
45 union ui16_f16 uA;
46 uint_fast16_t uiA;
47 union ui16_f16 uB;
48 uint_fast16_t uiB;
49#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
50 float16_t (*magsFuncPtr)( uint_fast16_t, uint_fast16_t );
51#endif
52
53 uA.f = a;
54 uiA = uA.ui;
55 uB.f = b;
56 uiB = uB.ui;
57#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
58 if ( signF16UI( uiA ^ uiB ) ) {
59 return softfloat_addMagsF16( uiA, uiB );
60 } else {
61 return softfloat_subMagsF16( uiA, uiB );
62 }
63#else
64 magsFuncPtr =
65 signF16UI( uiA ^ uiB ) ? softfloat_addMagsF16 : softfloat_subMagsF16;
66 return (*magsFuncPtr)( uiA, uiB );
67#endif
68
69}
70
deps/SoftFloat-3d/source/f16_to_extF80.c deleted-101
......@@ -1,101 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t f16_to_extF80( float16_t a )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 uint_fast16_t uiZ64;
54 uint_fast64_t uiZ0;
55 struct exp8_sig16 normExpSig;
56 union { struct extFloat80M s; extFloat80_t f; } uZ;
57
58 /*------------------------------------------------------------------------
59 *------------------------------------------------------------------------*/
60 uA.f = a;
61 uiA = uA.ui;
62 sign = signF16UI( uiA );
63 exp = expF16UI( uiA );
64 frac = fracF16UI( uiA );
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( exp == 0x1F ) {
68 if ( frac ) {
69 softfloat_f16UIToCommonNaN( uiA, &commonNaN );
70 uiZ = softfloat_commonNaNToExtF80UI( &commonNaN );
71 uiZ64 = uiZ.v64;
72 uiZ0 = uiZ.v0;
73 } else {
74 uiZ64 = packToExtF80UI64( sign, 0x7FFF );
75 uiZ0 = UINT64_C( 0x8000000000000000 );
76 }
77 goto uiZ;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 if ( ! exp ) {
82 if ( ! frac ) {
83 uiZ64 = packToExtF80UI64( sign, 0 );
84 uiZ0 = 0;
85 goto uiZ;
86 }
87 normExpSig = softfloat_normSubnormalF16Sig( frac );
88 exp = normExpSig.exp;
89 frac = normExpSig.sig;
90 }
91 /*------------------------------------------------------------------------
92 *------------------------------------------------------------------------*/
93 uiZ64 = packToExtF80UI64( sign, exp + 0x3FF0 );
94 uiZ0 = (uint_fast64_t) (frac | 0x0400)<<53;
95 uiZ:
96 uZ.s.signExp = uiZ64;
97 uZ.s.signif = uiZ0;
98 return uZ.f;
99
100}
101
deps/SoftFloat-3d/source/f16_to_extF80M.c deleted-111
......@@ -1,111 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void f16_to_extF80M( float16_t a, extFloat80_t *zPtr )
47{
48
49 *zPtr = f16_to_extF80( a );
50
51}
52
53#else
54
55void f16_to_extF80M( float16_t a, extFloat80_t *zPtr )
56{
57 struct extFloat80M *zSPtr;
58 union ui16_f16 uA;
59 uint16_t uiA;
60 bool sign;
61 int_fast8_t exp;
62 uint16_t frac;
63 struct commonNaN commonNaN;
64 uint_fast16_t uiZ64;
65 uint32_t uiZ32;
66 struct exp8_sig16 normExpSig;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 zSPtr = (struct extFloat80M *) zPtr;
71 uA.f = a;
72 uiA = uA.ui;
73 sign = signF16UI( uiA );
74 exp = expF16UI( uiA );
75 frac = fracF16UI( uiA );
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( exp == 0x1F ) {
79 if ( frac ) {
80 softfloat_f16UIToCommonNaN( uiA, &commonNaN );
81 softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
82 return;
83 }
84 uiZ64 = packToExtF80UI64( sign, 0x7FFF );
85 uiZ32 = 0x80000000;
86 goto uiZ;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( ! exp ) {
91 if ( ! frac ) {
92 uiZ64 = packToExtF80UI64( sign, 0 );
93 uiZ32 = 0;
94 goto uiZ;
95 }
96 normExpSig = softfloat_normSubnormalF16Sig( frac );
97 exp = normExpSig.exp;
98 frac = normExpSig.sig;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 uiZ64 = packToExtF80UI64( sign, exp + 0x3FF0 );
103 uiZ32 = 0x80000000 | (uint32_t) frac<<21;
104 uiZ:
105 zSPtr->signExp = uiZ64;
106 zSPtr->signif = (uint64_t) uiZ32<<32;
107
108}
109
110#endif
111
deps/SoftFloat-3d/source/f16_to_f128.c deleted-96
......@@ -1,96 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t f16_to_f128( float16_t a )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 struct exp8_sig16 normExpSig;
54 union ui128_f128 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA = uA.ui;
60 sign = signF16UI( uiA );
61 exp = expF16UI( uiA );
62 frac = fracF16UI( uiA );
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0x1F ) {
66 if ( frac ) {
67 softfloat_f16UIToCommonNaN( uiA, &commonNaN );
68 uiZ = softfloat_commonNaNToF128UI( &commonNaN );
69 } else {
70 uiZ.v64 = packToF128UI64( sign, 0x7FFF, 0 );
71 uiZ.v0 = 0;
72 }
73 goto uiZ;
74 }
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( ! exp ) {
78 if ( ! frac ) {
79 uiZ.v64 = packToF128UI64( sign, 0, 0 );
80 uiZ.v0 = 0;
81 goto uiZ;
82 }
83 normExpSig = softfloat_normSubnormalF16Sig( frac );
84 exp = normExpSig.exp - 1;
85 frac = normExpSig.sig;
86 }
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 uiZ.v64 = packToF128UI64( sign, exp + 0x3FF0, (uint_fast64_t) frac<<38 );
90 uiZ.v0 = 0;
91 uiZ:
92 uZ.ui = uiZ;
93 return uZ.f;
94
95}
96
deps/SoftFloat-3d/source/f16_to_f128M.c deleted-111
......@@ -1,111 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void f16_to_f128M( float16_t a, float128_t *zPtr )
47{
48
49 *zPtr = f16_to_f128( a );
50
51}
52
53#else
54
55void f16_to_f128M( float16_t a, float128_t *zPtr )
56{
57 uint32_t *zWPtr;
58 union ui16_f16 uA;
59 uint16_t uiA;
60 bool sign;
61 int_fast8_t exp;
62 uint16_t frac;
63 struct commonNaN commonNaN;
64 uint32_t uiZ96;
65 struct exp8_sig16 normExpSig;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 zWPtr = (uint32_t *) zPtr;
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 uA.f = a;
73 uiA = uA.ui;
74 sign = signF16UI( uiA );
75 exp = expF16UI( uiA );
76 frac = fracF16UI( uiA );
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 if ( exp == 0x1F ) {
80 if ( frac ) {
81 softfloat_f16UIToCommonNaN( uiA, &commonNaN );
82 softfloat_commonNaNToF128M( &commonNaN, zWPtr );
83 return;
84 }
85 uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
86 goto uiZ;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( ! exp ) {
91 if ( ! frac ) {
92 uiZ96 = packToF128UI96( sign, 0, 0 );
93 goto uiZ;
94 }
95 normExpSig = softfloat_normSubnormalF16Sig( frac );
96 exp = normExpSig.exp - 1;
97 frac = normExpSig.sig;
98 }
99 /*------------------------------------------------------------------------
100 *------------------------------------------------------------------------*/
101 uiZ96 = packToF128UI96( sign, exp + 0x3FF0, (uint32_t) frac<<6 );
102 uiZ:
103 zWPtr[indexWord( 4, 3 )] = uiZ96;
104 zWPtr[indexWord( 4, 2 )] = 0;
105 zWPtr[indexWord( 4, 1 )] = 0;
106 zWPtr[indexWord( 4, 0 )] = 0;
107
108}
109
110#endif
111
deps/SoftFloat-3d/source/f16_to_f32.c deleted-93
......@@ -1,93 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t f16_to_f32( float16_t a )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 struct commonNaN commonNaN;
52 uint_fast32_t uiZ;
53 struct exp8_sig16 normExpSig;
54 union ui32_f32 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA = uA.ui;
60 sign = signF16UI( uiA );
61 exp = expF16UI( uiA );
62 frac = fracF16UI( uiA );
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0x1F ) {
66 if ( frac ) {
67 softfloat_f16UIToCommonNaN( uiA, &commonNaN );
68 uiZ = softfloat_commonNaNToF32UI( &commonNaN );
69 } else {
70 uiZ = packToF32UI( sign, 0xFF, 0 );
71 }
72 goto uiZ;
73 }
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( ! exp ) {
77 if ( ! frac ) {
78 uiZ = packToF32UI( sign, 0, 0 );
79 goto uiZ;
80 }
81 normExpSig = softfloat_normSubnormalF16Sig( frac );
82 exp = normExpSig.exp - 1;
83 frac = normExpSig.sig;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 uiZ = packToF32UI( sign, exp + 0x70, (uint_fast32_t) frac<<13 );
88 uiZ:
89 uZ.ui = uiZ;
90 return uZ.f;
91
92}
93
deps/SoftFloat-3d/source/f16_to_f64.c deleted-93
......@@ -1,93 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t f16_to_f64( float16_t a )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 struct commonNaN commonNaN;
52 uint_fast64_t uiZ;
53 struct exp8_sig16 normExpSig;
54 union ui64_f64 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA = uA.ui;
60 sign = signF16UI( uiA );
61 exp = expF16UI( uiA );
62 frac = fracF16UI( uiA );
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0x1F ) {
66 if ( frac ) {
67 softfloat_f16UIToCommonNaN( uiA, &commonNaN );
68 uiZ = softfloat_commonNaNToF64UI( &commonNaN );
69 } else {
70 uiZ = packToF64UI( sign, 0x7FF, 0 );
71 }
72 goto uiZ;
73 }
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( ! exp ) {
77 if ( ! frac ) {
78 uiZ = packToF64UI( sign, 0, 0 );
79 goto uiZ;
80 }
81 normExpSig = softfloat_normSubnormalF16Sig( frac );
82 exp = normExpSig.exp - 1;
83 frac = normExpSig.sig;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 uiZ = packToF64UI( sign, exp + 0x3F0, (uint_fast64_t) frac<<42 );
88 uiZ:
89 uZ.ui = uiZ;
90 return uZ.f;
91
92}
93
deps/SoftFloat-3d/source/f16_to_i32.c deleted-87
......@@ -1,87 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t f16_to_i32( float16_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 int_fast32_t sig32;
52 int_fast8_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF16UI( uiA );
59 exp = expF16UI( uiA );
60 frac = fracF16UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 if ( exp == 0x1F ) {
64 softfloat_raiseFlags( softfloat_flag_invalid );
65 return
66 frac ? i32_fromNaN
67 : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sig32 = frac;
72 if ( exp ) {
73 sig32 |= 0x0400;
74 shiftDist = exp - 0x19;
75 if ( 0 <= shiftDist ) {
76 sig32 <<= shiftDist;
77 return sign ? -sig32 : sig32;
78 }
79 shiftDist = exp - 0x0D;
80 if ( 0 < shiftDist ) sig32 <<= shiftDist;
81 }
82 return
83 softfloat_roundToI32(
84 sign, (uint_fast32_t) sig32, roundingMode, exact );
85
86}
87
deps/SoftFloat-3d/source/f16_to_i32_r_minMag.c deleted-88
......@@ -1,88 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t f16_to_i32_r_minMag( float16_t a, bool exact )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 int_fast8_t exp;
49 uint_fast16_t frac;
50 int_fast8_t shiftDist;
51 bool sign;
52 int_fast32_t alignedSig;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF16UI( uiA );
59 frac = fracF16UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = exp - 0x0F;
63 if ( shiftDist < 0 ) {
64 if ( exact && (exp | frac) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF16UI( uiA );
72 if ( exp == 0x1F ) {
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 return
75 (exp == 0x1F) && frac ? i32_fromNaN
76 : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 alignedSig = (int_fast32_t) (frac | 0x0400)<<shiftDist;
81 if ( exact && (alignedSig & 0x3FF) ) {
82 softfloat_exceptionFlags |= softfloat_flag_inexact;
83 }
84 alignedSig >>= 10;
85 return sign ? -alignedSig : alignedSig;
86
87}
88
deps/SoftFloat-3d/source/f16_to_i64.c deleted-87
......@@ -1,87 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t f16_to_i64( float16_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 int_fast32_t sig32;
52 int_fast8_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF16UI( uiA );
59 exp = expF16UI( uiA );
60 frac = fracF16UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 if ( exp == 0x1F ) {
64 softfloat_raiseFlags( softfloat_flag_invalid );
65 return
66 frac ? i64_fromNaN
67 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sig32 = frac;
72 if ( exp ) {
73 sig32 |= 0x0400;
74 shiftDist = exp - 0x19;
75 if ( 0 <= shiftDist ) {
76 sig32 <<= shiftDist;
77 return sign ? -sig32 : sig32;
78 }
79 shiftDist = exp - 0x0D;
80 if ( 0 < shiftDist ) sig32 <<= shiftDist;
81 }
82 return
83 softfloat_roundToI32(
84 sign, (uint_fast32_t) sig32, roundingMode, exact );
85
86}
87
deps/SoftFloat-3d/source/f16_to_i64_r_minMag.c deleted-88
......@@ -1,88 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t f16_to_i64_r_minMag( float16_t a, bool exact )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 int_fast8_t exp;
49 uint_fast16_t frac;
50 int_fast8_t shiftDist;
51 bool sign;
52 int_fast32_t alignedSig;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF16UI( uiA );
59 frac = fracF16UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = exp - 0x0F;
63 if ( shiftDist < 0 ) {
64 if ( exact && (exp | frac) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF16UI( uiA );
72 if ( exp == 0x1F ) {
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 return
75 (exp == 0x1F) && frac ? i64_fromNaN
76 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 alignedSig = (int_fast32_t) (frac | 0x0400)<<shiftDist;
81 if ( exact && (alignedSig & 0x3FF) ) {
82 softfloat_exceptionFlags |= softfloat_flag_inexact;
83 }
84 alignedSig >>= 10;
85 return sign ? -alignedSig : alignedSig;
86
87}
88
deps/SoftFloat-3d/source/f16_to_ui32.c deleted-84
......@@ -1,84 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t f16_to_ui32( float16_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 uint_fast32_t sig32;
52 int_fast8_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF16UI( uiA );
59 exp = expF16UI( uiA );
60 frac = fracF16UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 if ( exp == 0x1F ) {
64 softfloat_raiseFlags( softfloat_flag_invalid );
65 return
66 frac ? ui32_fromNaN
67 : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sig32 = frac;
72 if ( exp ) {
73 sig32 |= 0x0400;
74 shiftDist = exp - 0x19;
75 if ( (0 <= shiftDist) && ! sign ) {
76 return sig32<<shiftDist;
77 }
78 shiftDist = exp - 0x0D;
79 if ( 0 < shiftDist ) sig32 <<= shiftDist;
80 }
81 return softfloat_roundToUI32( sign, sig32, roundingMode, exact );
82
83}
84
deps/SoftFloat-3d/source/f16_to_ui32_r_minMag.c deleted-87
......@@ -1,87 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t f16_to_ui32_r_minMag( float16_t a, bool exact )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 int_fast8_t exp;
49 uint_fast16_t frac;
50 int_fast8_t shiftDist;
51 bool sign;
52 uint_fast32_t alignedSig;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF16UI( uiA );
59 frac = fracF16UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = exp - 0x0F;
63 if ( shiftDist < 0 ) {
64 if ( exact && (exp | frac) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF16UI( uiA );
72 if ( sign || (exp == 0x1F) ) {
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 return
75 (exp == 0x1F) && frac ? ui32_fromNaN
76 : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 alignedSig = (uint_fast32_t) (frac | 0x0400)<<shiftDist;
81 if ( exact && (alignedSig & 0x3FF) ) {
82 softfloat_exceptionFlags |= softfloat_flag_inexact;
83 }
84 return alignedSig>>10;
85
86}
87
deps/SoftFloat-3d/source/f16_to_ui64.c deleted-84
......@@ -1,84 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t f16_to_ui64( float16_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 uint_fast32_t sig32;
52 int_fast8_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF16UI( uiA );
59 exp = expF16UI( uiA );
60 frac = fracF16UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 if ( exp == 0x1F ) {
64 softfloat_raiseFlags( softfloat_flag_invalid );
65 return
66 frac ? ui64_fromNaN
67 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sig32 = frac;
72 if ( exp ) {
73 sig32 |= 0x0400;
74 shiftDist = exp - 0x19;
75 if ( (0 <= shiftDist) && ! sign ) {
76 return sig32<<shiftDist;
77 }
78 shiftDist = exp - 0x0D;
79 if ( 0 < shiftDist ) sig32 <<= shiftDist;
80 }
81 return softfloat_roundToUI32( sign, sig32, roundingMode, exact );
82
83}
84
deps/SoftFloat-3d/source/f16_to_ui64_r_minMag.c deleted-87
......@@ -1,87 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t f16_to_ui64_r_minMag( float16_t a, bool exact )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 int_fast8_t exp;
49 uint_fast16_t frac;
50 int_fast8_t shiftDist;
51 bool sign;
52 uint_fast32_t alignedSig;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF16UI( uiA );
59 frac = fracF16UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = exp - 0x0F;
63 if ( shiftDist < 0 ) {
64 if ( exact && (exp | frac) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF16UI( uiA );
72 if ( sign || (exp == 0x1F) ) {
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 return
75 (exp == 0x1F) && frac ? ui64_fromNaN
76 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 alignedSig = (uint_fast32_t) (frac | 0x0400)<<shiftDist;
81 if ( exact && (alignedSig & 0x3FF) ) {
82 softfloat_exceptionFlags |= softfloat_flag_inexact;
83 }
84 return alignedSig>>10;
85
86}
87
deps/SoftFloat-3d/source/f32_add.c deleted-70
......@@ -1,70 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float32_t f32_add( float32_t a, float32_t b )
44{
45 union ui32_f32 uA;
46 uint_fast32_t uiA;
47 union ui32_f32 uB;
48 uint_fast32_t uiB;
49#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
50 float32_t (*magsFuncPtr)( uint_fast32_t, uint_fast32_t );
51#endif
52
53 uA.f = a;
54 uiA = uA.ui;
55 uB.f = b;
56 uiB = uB.ui;
57#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
58 if ( signF32UI( uiA ^ uiB ) ) {
59 return softfloat_subMagsF32( uiA, uiB );
60 } else {
61 return softfloat_addMagsF32( uiA, uiB );
62 }
63#else
64 magsFuncPtr =
65 signF32UI( uiA ^ uiB ) ? softfloat_subMagsF32 : softfloat_addMagsF32;
66 return (*magsFuncPtr)( uiA, uiB );
67#endif
68
69}
70
deps/SoftFloat-3d/source/f32_div.c deleted-180
......@@ -1,180 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t f32_div( float32_t a, float32_t b )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast32_t sigA;
51 union ui32_f32 uB;
52 uint_fast32_t uiB;
53 bool signB;
54 int_fast16_t expB;
55 uint_fast32_t sigB;
56 bool signZ;
57 struct exp16_sig32 normExpSig;
58 int_fast16_t expZ;
59#ifdef SOFTFLOAT_FAST_DIV64TO32
60 uint_fast64_t sig64A;
61 uint_fast32_t sigZ;
62#else
63 uint_fast32_t sigZ;
64 uint_fast64_t rem;
65#endif
66 uint_fast32_t uiZ;
67 union ui32_f32 uZ;
68
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 uA.f = a;
72 uiA = uA.ui;
73 signA = signF32UI( uiA );
74 expA = expF32UI( uiA );
75 sigA = fracF32UI( uiA );
76 uB.f = b;
77 uiB = uB.ui;
78 signB = signF32UI( uiB );
79 expB = expF32UI( uiB );
80 sigB = fracF32UI( uiB );
81 signZ = signA ^ signB;
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( expA == 0xFF ) {
85 if ( sigA ) goto propagateNaN;
86 if ( expB == 0xFF ) {
87 if ( sigB ) goto propagateNaN;
88 goto invalid;
89 }
90 goto infinity;
91 }
92 if ( expB == 0xFF ) {
93 if ( sigB ) goto propagateNaN;
94 goto zero;
95 }
96 /*------------------------------------------------------------------------
97 *------------------------------------------------------------------------*/
98 if ( ! expB ) {
99 if ( ! sigB ) {
100 if ( ! (expA | sigA) ) goto invalid;
101 softfloat_raiseFlags( softfloat_flag_infinite );
102 goto infinity;
103 }
104 normExpSig = softfloat_normSubnormalF32Sig( sigB );
105 expB = normExpSig.exp;
106 sigB = normExpSig.sig;
107 }
108 if ( ! expA ) {
109 if ( ! sigA ) goto zero;
110 normExpSig = softfloat_normSubnormalF32Sig( sigA );
111 expA = normExpSig.exp;
112 sigA = normExpSig.sig;
113 }
114 /*------------------------------------------------------------------------
115 *------------------------------------------------------------------------*/
116 expZ = expA - expB + 0x7E;
117 sigA |= 0x00800000;
118 sigB |= 0x00800000;
119#ifdef SOFTFLOAT_FAST_DIV64TO32
120 if ( sigA < sigB ) {
121 --expZ;
122 sig64A = (uint_fast64_t) sigA<<31;
123 } else {
124 sig64A = (uint_fast64_t) sigA<<30;
125 }
126 sigZ = sig64A / sigB;
127 if ( ! (sigZ & 0x3F) ) sigZ |= ((uint_fast64_t) sigB * sigZ != sig64A);
128#else
129 if ( sigA < sigB ) {
130 --expZ;
131 sigA <<= 8;
132 } else {
133 sigA <<= 7;
134 }
135 sigB <<= 8;
136 sigZ = ((uint_fast64_t) sigA * softfloat_approxRecip32_1( sigB ))>>32;
137 /*------------------------------------------------------------------------
138 *------------------------------------------------------------------------*/
139 sigZ += 2;
140 if ( (sigZ & 0x3F) < 2 ) {
141 sigZ &= ~3;
142#ifdef SOFTFLOAT_FAST_INT64
143 rem = ((uint_fast64_t) sigA<<31) - (uint_fast64_t) sigZ * sigB;
144#else
145 rem = ((uint_fast64_t) sigA<<32) - (uint_fast64_t) (sigZ<<1) * sigB;
146#endif
147 if ( rem & UINT64_C( 0x8000000000000000 ) ) {
148 sigZ -= 4;
149 } else {
150 if ( rem ) sigZ |= 1;
151 }
152 }
153#endif
154 return softfloat_roundPackToF32( signZ, expZ, sigZ );
155 /*------------------------------------------------------------------------
156 *------------------------------------------------------------------------*/
157 propagateNaN:
158 uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
159 goto uiZ;
160 /*------------------------------------------------------------------------
161 *------------------------------------------------------------------------*/
162 invalid:
163 softfloat_raiseFlags( softfloat_flag_invalid );
164 uiZ = defaultNaNF32UI;
165 goto uiZ;
166 /*------------------------------------------------------------------------
167 *------------------------------------------------------------------------*/
168 infinity:
169 uiZ = packToF32UI( signZ, 0xFF, 0 );
170 goto uiZ;
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 zero:
174 uiZ = packToF32UI( signZ, 0, 0 );
175 uiZ:
176 uZ.ui = uiZ;
177 return uZ.f;
178
179}
180
deps/SoftFloat-3d/source/f32_eq.c deleted-66
......@@ -1,66 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f32_eq( float32_t a, float32_t b )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 union ui32_f32 uB;
49 uint_fast32_t uiB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
56 if (
57 softfloat_isSigNaNF32UI( uiA ) || softfloat_isSigNaNF32UI( uiB )
58 ) {
59 softfloat_raiseFlags( softfloat_flag_invalid );
60 }
61 return false;
62 }
63 return (uiA == uiB) || ! (uint32_t) ((uiA | uiB)<<1);
64
65}
66
deps/SoftFloat-3d/source/f32_eq_signaling.c deleted-61
......@@ -1,61 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f32_eq_signaling( float32_t a, float32_t b )
44{
45 union ui32_f32 uA;
46 uint_fast32_t uiA;
47 union ui32_f32 uB;
48 uint_fast32_t uiB;
49
50 uA.f = a;
51 uiA = uA.ui;
52 uB.f = b;
53 uiB = uB.ui;
54 if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
55 softfloat_raiseFlags( softfloat_flag_invalid );
56 return false;
57 }
58 return (uiA == uiB) || ! (uint32_t) ((uiA | uiB)<<1);
59
60}
61
deps/SoftFloat-3d/source/f32_isSignalingNaN.c deleted-51
......@@ -1,51 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43bool f32_isSignalingNaN( float32_t a )
44{
45 union ui32_f32 uA;
46
47 uA.f = a;
48 return softfloat_isSigNaNF32UI( uA.ui );
49
50}
51
deps/SoftFloat-3d/source/f32_le.c deleted-66
......@@ -1,66 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f32_le( float32_t a, float32_t b )
44{
45 union ui32_f32 uA;
46 uint_fast32_t uiA;
47 union ui32_f32 uB;
48 uint_fast32_t uiB;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
56 softfloat_raiseFlags( softfloat_flag_invalid );
57 return false;
58 }
59 signA = signF32UI( uiA );
60 signB = signF32UI( uiB );
61 return
62 (signA != signB) ? signA || ! (uint32_t) ((uiA | uiB)<<1)
63 : (uiA == uiB) || (signA ^ (uiA < uiB));
64
65}
66
deps/SoftFloat-3d/source/f32_le_quiet.c deleted-71
......@@ -1,71 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f32_le_quiet( float32_t a, float32_t b )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 union ui32_f32 uB;
49 uint_fast32_t uiB;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA = uA.ui;
54 uB.f = b;
55 uiB = uB.ui;
56 if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
57 if (
58 softfloat_isSigNaNF32UI( uiA ) || softfloat_isSigNaNF32UI( uiB )
59 ) {
60 softfloat_raiseFlags( softfloat_flag_invalid );
61 }
62 return false;
63 }
64 signA = signF32UI( uiA );
65 signB = signF32UI( uiB );
66 return
67 (signA != signB) ? signA || ! (uint32_t) ((uiA | uiB)<<1)
68 : (uiA == uiB) || (signA ^ (uiA < uiB));
69
70}
71
deps/SoftFloat-3d/source/f32_lt.c deleted-66
......@@ -1,66 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f32_lt( float32_t a, float32_t b )
44{
45 union ui32_f32 uA;
46 uint_fast32_t uiA;
47 union ui32_f32 uB;
48 uint_fast32_t uiB;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
56 softfloat_raiseFlags( softfloat_flag_invalid );
57 return false;
58 }
59 signA = signF32UI( uiA );
60 signB = signF32UI( uiB );
61 return
62 (signA != signB) ? signA && ((uint32_t) ((uiA | uiB)<<1) != 0)
63 : (uiA != uiB) && (signA ^ (uiA < uiB));
64
65}
66
deps/SoftFloat-3d/source/f32_lt_quiet.c deleted-71
......@@ -1,71 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f32_lt_quiet( float32_t a, float32_t b )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 union ui32_f32 uB;
49 uint_fast32_t uiB;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA = uA.ui;
54 uB.f = b;
55 uiB = uB.ui;
56 if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
57 if (
58 softfloat_isSigNaNF32UI( uiA ) || softfloat_isSigNaNF32UI( uiB )
59 ) {
60 softfloat_raiseFlags( softfloat_flag_invalid );
61 }
62 return false;
63 }
64 signA = signF32UI( uiA );
65 signB = signF32UI( uiB );
66 return
67 (signA != signB) ? signA && ((uint32_t) ((uiA | uiB)<<1) != 0)
68 : (uiA != uiB) && (signA ^ (uiA < uiB));
69
70}
71
deps/SoftFloat-3d/source/f32_mul.c deleted-137
......@@ -1,137 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t f32_mul( float32_t a, float32_t b )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast32_t sigA;
51 union ui32_f32 uB;
52 uint_fast32_t uiB;
53 bool signB;
54 int_fast16_t expB;
55 uint_fast32_t sigB;
56 bool signZ;
57 uint_fast32_t magBits;
58 struct exp16_sig32 normExpSig;
59 int_fast16_t expZ;
60 uint_fast32_t sigZ, uiZ;
61 union ui32_f32 uZ;
62
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 uA.f = a;
66 uiA = uA.ui;
67 signA = signF32UI( uiA );
68 expA = expF32UI( uiA );
69 sigA = fracF32UI( uiA );
70 uB.f = b;
71 uiB = uB.ui;
72 signB = signF32UI( uiB );
73 expB = expF32UI( uiB );
74 sigB = fracF32UI( uiB );
75 signZ = signA ^ signB;
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( expA == 0xFF ) {
79 if ( sigA || ((expB == 0xFF) && sigB) ) goto propagateNaN;
80 magBits = expB | sigB;
81 goto infArg;
82 }
83 if ( expB == 0xFF ) {
84 if ( sigB ) goto propagateNaN;
85 magBits = expA | sigA;
86 goto infArg;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( ! expA ) {
91 if ( ! sigA ) goto zero;
92 normExpSig = softfloat_normSubnormalF32Sig( sigA );
93 expA = normExpSig.exp;
94 sigA = normExpSig.sig;
95 }
96 if ( ! expB ) {
97 if ( ! sigB ) goto zero;
98 normExpSig = softfloat_normSubnormalF32Sig( sigB );
99 expB = normExpSig.exp;
100 sigB = normExpSig.sig;
101 }
102 /*------------------------------------------------------------------------
103 *------------------------------------------------------------------------*/
104 expZ = expA + expB - 0x7F;
105 sigA = (sigA | 0x00800000)<<7;
106 sigB = (sigB | 0x00800000)<<8;
107 sigZ = softfloat_shortShiftRightJam64( (uint_fast64_t) sigA * sigB, 32 );
108 if ( sigZ < 0x40000000 ) {
109 --expZ;
110 sigZ <<= 1;
111 }
112 return softfloat_roundPackToF32( signZ, expZ, sigZ );
113 /*------------------------------------------------------------------------
114 *------------------------------------------------------------------------*/
115 propagateNaN:
116 uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
117 goto uiZ;
118 /*------------------------------------------------------------------------
119 *------------------------------------------------------------------------*/
120 infArg:
121 if ( ! magBits ) {
122 softfloat_raiseFlags( softfloat_flag_invalid );
123 uiZ = defaultNaNF32UI;
124 } else {
125 uiZ = packToF32UI( signZ, 0xFF, 0 );
126 }
127 goto uiZ;
128 /*------------------------------------------------------------------------
129 *------------------------------------------------------------------------*/
130 zero:
131 uiZ = packToF32UI( signZ, 0, 0 );
132 uiZ:
133 uZ.ui = uiZ;
134 return uZ.f;
135
136}
137
deps/SoftFloat-3d/source/f32_mulAdd.c deleted-60
......@@ -1,60 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float32_t f32_mulAdd( float32_t a, float32_t b, float32_t c )
43{
44 union ui32_f32 uA;
45 uint_fast32_t uiA;
46 union ui32_f32 uB;
47 uint_fast32_t uiB;
48 union ui32_f32 uC;
49 uint_fast32_t uiC;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 uC.f = c;
56 uiC = uC.ui;
57 return softfloat_mulAddF32( uiA, uiB, uiC, 0 );
58
59}
60
deps/SoftFloat-3d/source/f32_rem.c deleted-168
......@@ -1,168 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t f32_rem( float32_t a, float32_t b )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast32_t sigA;
51 union ui32_f32 uB;
52 uint_fast32_t uiB;
53 int_fast16_t expB;
54 uint_fast32_t sigB;
55 struct exp16_sig32 normExpSig;
56 uint32_t rem;
57 int_fast16_t expDiff;
58 uint32_t q, recip32, altRem, meanRem;
59 bool signRem;
60 uint_fast32_t uiZ;
61 union ui32_f32 uZ;
62
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 uA.f = a;
66 uiA = uA.ui;
67 signA = signF32UI( uiA );
68 expA = expF32UI( uiA );
69 sigA = fracF32UI( uiA );
70 uB.f = b;
71 uiB = uB.ui;
72 expB = expF32UI( uiB );
73 sigB = fracF32UI( uiB );
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( expA == 0xFF ) {
77 if ( sigA || ((expB == 0xFF) && sigB) ) goto propagateNaN;
78 goto invalid;
79 }
80 if ( expB == 0xFF ) {
81 if ( sigB ) goto propagateNaN;
82 return a;
83 }
84 /*------------------------------------------------------------------------
85 *------------------------------------------------------------------------*/
86 if ( ! expB ) {
87 if ( ! sigB ) goto invalid;
88 normExpSig = softfloat_normSubnormalF32Sig( sigB );
89 expB = normExpSig.exp;
90 sigB = normExpSig.sig;
91 }
92 if ( ! expA ) {
93 if ( ! sigA ) return a;
94 normExpSig = softfloat_normSubnormalF32Sig( sigA );
95 expA = normExpSig.exp;
96 sigA = normExpSig.sig;
97 }
98 /*------------------------------------------------------------------------
99 *------------------------------------------------------------------------*/
100 rem = sigA | 0x00800000;
101 sigB |= 0x00800000;
102 expDiff = expA - expB;
103 if ( expDiff < 1 ) {
104 if ( expDiff < -1 ) return a;
105 sigB <<= 6;
106 if ( expDiff ) {
107 rem <<= 5;
108 q = 0;
109 } else {
110 rem <<= 6;
111 q = (sigB <= rem);
112 if ( q ) rem -= sigB;
113 }
114 } else {
115 recip32 = softfloat_approxRecip32_1( sigB<<8 );
116 /*--------------------------------------------------------------------
117 | Changing the shift of `rem' here requires also changing the initial
118 | subtraction from `expDiff'.
119 *--------------------------------------------------------------------*/
120 rem <<= 7;
121 expDiff -= 31;
122 /*--------------------------------------------------------------------
123 | The scale of `sigB' affects how many bits are obtained during each
124 | cycle of the loop. Currently this is 29 bits per loop iteration,
125 | which is believed to be the maximum possible.
126 *--------------------------------------------------------------------*/
127 sigB <<= 6;
128 for (;;) {
129 q = (rem * (uint_fast64_t) recip32)>>32;
130 if ( expDiff < 0 ) break;
131 rem = -(q * (uint32_t) sigB);
132 expDiff -= 29;
133 }
134 /*--------------------------------------------------------------------
135 | (`expDiff' cannot be less than -30 here.)
136 *--------------------------------------------------------------------*/
137 q >>= ~expDiff & 31;
138 rem = (rem<<(expDiff + 30)) - q * (uint32_t) sigB;
139 }
140 /*------------------------------------------------------------------------
141 *------------------------------------------------------------------------*/
142 do {
143 altRem = rem;
144 ++q;
145 rem -= sigB;
146 } while ( ! (rem & 0x80000000) );
147 meanRem = rem + altRem;
148 if ( (meanRem & 0x80000000) || (! meanRem && (q & 1)) ) rem = altRem;
149 signRem = signA;
150 if ( 0x80000000 <= rem ) {
151 signRem = ! signRem;
152 rem = -rem;
153 }
154 return softfloat_normRoundPackToF32( signRem, expB, rem );
155 /*------------------------------------------------------------------------
156 *------------------------------------------------------------------------*/
157 propagateNaN:
158 uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
159 goto uiZ;
160 invalid:
161 softfloat_raiseFlags( softfloat_flag_invalid );
162 uiZ = defaultNaNF32UI;
163 uiZ:
164 uZ.ui = uiZ;
165 return uZ.f;
166
167}
168
deps/SoftFloat-3d/source/f32_roundToInt.c deleted-112
......@@ -1,112 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t f32_roundToInt( float32_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 int_fast16_t exp;
49 uint_fast32_t uiZ, lastBitMask, roundBitsMask;
50 union ui32_f32 uZ;
51
52 /*------------------------------------------------------------------------
53 *------------------------------------------------------------------------*/
54 uA.f = a;
55 uiA = uA.ui;
56 exp = expF32UI( uiA );
57 /*------------------------------------------------------------------------
58 *------------------------------------------------------------------------*/
59 if ( exp <= 0x7E ) {
60 if ( ! (uint32_t) (uiA<<1) ) return a;
61 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
62 uiZ = uiA & packToF32UI( 1, 0, 0 );
63 switch ( roundingMode ) {
64 case softfloat_round_near_even:
65 if ( ! fracF32UI( uiA ) ) break;
66 case softfloat_round_near_maxMag:
67 if ( exp == 0x7E ) uiZ |= packToF32UI( 0, 0x7F, 0 );
68 break;
69 case softfloat_round_min:
70 if ( uiZ ) uiZ = packToF32UI( 1, 0x7F, 0 );
71 break;
72 case softfloat_round_max:
73 if ( ! uiZ ) uiZ = packToF32UI( 0, 0x7F, 0 );
74 break;
75 }
76 goto uiZ;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 if ( 0x96 <= exp ) {
81 if ( (exp == 0xFF) && fracF32UI( uiA ) ) {
82 uiZ = softfloat_propagateNaNF32UI( uiA, 0 );
83 goto uiZ;
84 }
85 return a;
86 }
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 uiZ = uiA;
90 lastBitMask = (uint_fast32_t) 1<<(0x96 - exp);
91 roundBitsMask = lastBitMask - 1;
92 if ( roundingMode == softfloat_round_near_maxMag ) {
93 uiZ += lastBitMask>>1;
94 } else if ( roundingMode == softfloat_round_near_even ) {
95 uiZ += lastBitMask>>1;
96 if ( ! (uiZ & roundBitsMask) ) uiZ &= ~lastBitMask;
97 } else if (
98 roundingMode
99 == (signF32UI( uiZ ) ? softfloat_round_min : softfloat_round_max)
100 ) {
101 uiZ += roundBitsMask;
102 }
103 uiZ &= ~roundBitsMask;
104 if ( exact && (uiZ != uiA) ) {
105 softfloat_exceptionFlags |= softfloat_flag_inexact;
106 }
107 uiZ:
108 uZ.ui = uiZ;
109 return uZ.f;
110
111}
112
deps/SoftFloat-3d/source/f32_sqrt.c deleted-121
......@@ -1,121 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t f32_sqrt( float32_t a )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast32_t sigA, uiZ;
51 struct exp16_sig32 normExpSig;
52 int_fast16_t expZ;
53 uint_fast32_t sigZ, shiftedSigZ;
54 uint32_t negRem;
55 union ui32_f32 uZ;
56
57 /*------------------------------------------------------------------------
58 *------------------------------------------------------------------------*/
59 uA.f = a;
60 uiA = uA.ui;
61 signA = signF32UI( uiA );
62 expA = expF32UI( uiA );
63 sigA = fracF32UI( uiA );
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 if ( expA == 0xFF ) {
67 if ( sigA ) {
68 uiZ = softfloat_propagateNaNF32UI( uiA, 0 );
69 goto uiZ;
70 }
71 if ( ! signA ) return a;
72 goto invalid;
73 }
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( signA ) {
77 if ( ! (expA | sigA) ) return a;
78 goto invalid;
79 }
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 if ( ! expA ) {
83 if ( ! sigA ) return a;
84 normExpSig = softfloat_normSubnormalF32Sig( sigA );
85 expA = normExpSig.exp;
86 sigA = normExpSig.sig;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 expZ = ((expA - 0x7F)>>1) + 0x7E;
91 expA &= 1;
92 sigA = (sigA | 0x00800000)<<8;
93 sigZ =
94 ((uint_fast64_t) sigA * softfloat_approxRecipSqrt32_1( expA, sigA ))
95 >>32;
96 if ( expA ) sigZ >>= 1;
97 /*------------------------------------------------------------------------
98 *------------------------------------------------------------------------*/
99 sigZ += 2;
100 if ( (sigZ & 0x3F) < 2 ) {
101 shiftedSigZ = sigZ>>2;
102 negRem = shiftedSigZ * shiftedSigZ;
103 sigZ &= ~3;
104 if ( negRem & 0x80000000 ) {
105 sigZ |= 1;
106 } else {
107 if ( negRem ) --sigZ;
108 }
109 }
110 return softfloat_roundPackToF32( 0, expZ, sigZ );
111 /*------------------------------------------------------------------------
112 *------------------------------------------------------------------------*/
113 invalid:
114 softfloat_raiseFlags( softfloat_flag_invalid );
115 uiZ = defaultNaNF32UI;
116 uiZ:
117 uZ.ui = uiZ;
118 return uZ.f;
119
120}
121
deps/SoftFloat-3d/source/f32_sub.c deleted-70
......@@ -1,70 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float32_t f32_sub( float32_t a, float32_t b )
44{
45 union ui32_f32 uA;
46 uint_fast32_t uiA;
47 union ui32_f32 uB;
48 uint_fast32_t uiB;
49#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
50 float32_t (*magsFuncPtr)( uint_fast32_t, uint_fast32_t );
51#endif
52
53 uA.f = a;
54 uiA = uA.ui;
55 uB.f = b;
56 uiB = uB.ui;
57#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
58 if ( signF32UI( uiA ^ uiB ) ) {
59 return softfloat_addMagsF32( uiA, uiB );
60 } else {
61 return softfloat_subMagsF32( uiA, uiB );
62 }
63#else
64 magsFuncPtr =
65 signF32UI( uiA ^ uiB ) ? softfloat_addMagsF32 : softfloat_subMagsF32;
66 return (*magsFuncPtr)( uiA, uiB );
67#endif
68
69}
70
deps/SoftFloat-3d/source/f32_to_extF80.c deleted-101
......@@ -1,101 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t f32_to_extF80( float32_t a )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t frac;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 uint_fast16_t uiZ64;
54 uint_fast64_t uiZ0;
55 struct exp16_sig32 normExpSig;
56 union { struct extFloat80M s; extFloat80_t f; } uZ;
57
58 /*------------------------------------------------------------------------
59 *------------------------------------------------------------------------*/
60 uA.f = a;
61 uiA = uA.ui;
62 sign = signF32UI( uiA );
63 exp = expF32UI( uiA );
64 frac = fracF32UI( uiA );
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( exp == 0xFF ) {
68 if ( frac ) {
69 softfloat_f32UIToCommonNaN( uiA, &commonNaN );
70 uiZ = softfloat_commonNaNToExtF80UI( &commonNaN );
71 uiZ64 = uiZ.v64;
72 uiZ0 = uiZ.v0;
73 } else {
74 uiZ64 = packToExtF80UI64( sign, 0x7FFF );
75 uiZ0 = UINT64_C( 0x8000000000000000 );
76 }
77 goto uiZ;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 if ( ! exp ) {
82 if ( ! frac ) {
83 uiZ64 = packToExtF80UI64( sign, 0 );
84 uiZ0 = 0;
85 goto uiZ;
86 }
87 normExpSig = softfloat_normSubnormalF32Sig( frac );
88 exp = normExpSig.exp;
89 frac = normExpSig.sig;
90 }
91 /*------------------------------------------------------------------------
92 *------------------------------------------------------------------------*/
93 uiZ64 = packToExtF80UI64( sign, exp + 0x3F80 );
94 uiZ0 = (uint_fast64_t) (frac | 0x00800000)<<40;
95 uiZ:
96 uZ.s.signExp = uiZ64;
97 uZ.s.signif = uiZ0;
98 return uZ.f;
99
100}
101
deps/SoftFloat-3d/source/f32_to_extF80M.c deleted-111
......@@ -1,111 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void f32_to_extF80M( float32_t a, extFloat80_t *zPtr )
47{
48
49 *zPtr = f32_to_extF80( a );
50
51}
52
53#else
54
55void f32_to_extF80M( float32_t a, extFloat80_t *zPtr )
56{
57 struct extFloat80M *zSPtr;
58 union ui32_f32 uA;
59 uint32_t uiA;
60 bool sign;
61 int_fast16_t exp;
62 uint32_t frac;
63 struct commonNaN commonNaN;
64 uint_fast16_t uiZ64;
65 uint32_t uiZ32;
66 struct exp16_sig32 normExpSig;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 zSPtr = (struct extFloat80M *) zPtr;
71 uA.f = a;
72 uiA = uA.ui;
73 sign = signF32UI( uiA );
74 exp = expF32UI( uiA );
75 frac = fracF32UI( uiA );
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( exp == 0xFF ) {
79 if ( frac ) {
80 softfloat_f32UIToCommonNaN( uiA, &commonNaN );
81 softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
82 return;
83 }
84 uiZ64 = packToExtF80UI64( sign, 0x7FFF );
85 uiZ32 = 0x80000000;
86 goto uiZ;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( ! exp ) {
91 if ( ! frac ) {
92 uiZ64 = packToExtF80UI64( sign, 0 );
93 uiZ32 = 0;
94 goto uiZ;
95 }
96 normExpSig = softfloat_normSubnormalF32Sig( frac );
97 exp = normExpSig.exp;
98 frac = normExpSig.sig;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 uiZ64 = packToExtF80UI64( sign, exp + 0x3F80 );
103 uiZ32 = 0x80000000 | (uint32_t) frac<<8;
104 uiZ:
105 zSPtr->signExp = uiZ64;
106 zSPtr->signif = (uint64_t) uiZ32<<32;
107
108}
109
110#endif
111
deps/SoftFloat-3d/source/f32_to_f128.c deleted-96
......@@ -1,96 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t f32_to_f128( float32_t a )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t frac;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 struct exp16_sig32 normExpSig;
54 union ui128_f128 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA = uA.ui;
60 sign = signF32UI( uiA );
61 exp = expF32UI( uiA );
62 frac = fracF32UI( uiA );
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0xFF ) {
66 if ( frac ) {
67 softfloat_f32UIToCommonNaN( uiA, &commonNaN );
68 uiZ = softfloat_commonNaNToF128UI( &commonNaN );
69 } else {
70 uiZ.v64 = packToF128UI64( sign, 0x7FFF, 0 );
71 uiZ.v0 = 0;
72 }
73 goto uiZ;
74 }
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( ! exp ) {
78 if ( ! frac ) {
79 uiZ.v64 = packToF128UI64( sign, 0, 0 );
80 uiZ.v0 = 0;
81 goto uiZ;
82 }
83 normExpSig = softfloat_normSubnormalF32Sig( frac );
84 exp = normExpSig.exp - 1;
85 frac = normExpSig.sig;
86 }
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 uiZ.v64 = packToF128UI64( sign, exp + 0x3F80, (uint_fast64_t) frac<<25 );
90 uiZ.v0 = 0;
91 uiZ:
92 uZ.ui = uiZ;
93 return uZ.f;
94
95}
96
deps/SoftFloat-3d/source/f32_to_f128M.c deleted-115
......@@ -1,115 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void f32_to_f128M( float32_t a, float128_t *zPtr )
47{
48
49 *zPtr = f32_to_f128( a );
50
51}
52
53#else
54
55void f32_to_f128M( float32_t a, float128_t *zPtr )
56{
57 uint32_t *zWPtr;
58 union ui32_f32 uA;
59 uint32_t uiA;
60 bool sign;
61 int_fast16_t exp;
62 uint32_t frac, uiZ64;
63 struct commonNaN commonNaN;
64 uint32_t uiZ96;
65 struct exp16_sig32 normExpSig;
66 uint64_t frac64;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 zWPtr = (uint32_t *) zPtr;
71 /*------------------------------------------------------------------------
72 *------------------------------------------------------------------------*/
73 uA.f = a;
74 uiA = uA.ui;
75 sign = signF32UI( uiA );
76 exp = expF32UI( uiA );
77 frac = fracF32UI( uiA );
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 uiZ64 = 0;
81 if ( exp == 0xFF ) {
82 if ( frac ) {
83 softfloat_f32UIToCommonNaN( uiA, &commonNaN );
84 softfloat_commonNaNToF128M( &commonNaN, zWPtr );
85 return;
86 }
87 uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
88 goto uiZ;
89 }
90 /*------------------------------------------------------------------------
91 *------------------------------------------------------------------------*/
92 if ( ! exp ) {
93 if ( ! frac ) {
94 uiZ96 = packToF128UI96( sign, 0, 0 );
95 goto uiZ;
96 }
97 normExpSig = softfloat_normSubnormalF32Sig( frac );
98 exp = normExpSig.exp - 1;
99 frac = normExpSig.sig;
100 }
101 /*------------------------------------------------------------------------
102 *------------------------------------------------------------------------*/
103 frac64 = (uint64_t) frac<<25;
104 uiZ96 = packToF128UI96( sign, exp + 0x3F80, frac64>>32 );
105 uiZ64 = frac64;
106 uiZ:
107 zWPtr[indexWord( 4, 3 )] = uiZ96;
108 zWPtr[indexWord( 4, 2 )] = uiZ64;
109 zWPtr[indexWord( 4, 1 )] = 0;
110 zWPtr[indexWord( 4, 0 )] = 0;
111
112}
113
114#endif
115
deps/SoftFloat-3d/source/f32_to_f16.c deleted-88
......@@ -1,88 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t f32_to_f16( float32_t a )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t frac;
51 struct commonNaN commonNaN;
52 uint_fast16_t uiZ, frac16;
53 union ui16_f16 uZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA = uA.ui;
59 sign = signF32UI( uiA );
60 exp = expF32UI( uiA );
61 frac = fracF32UI( uiA );
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 if ( exp == 0xFF ) {
65 if ( frac ) {
66 softfloat_f32UIToCommonNaN( uiA, &commonNaN );
67 uiZ = softfloat_commonNaNToF16UI( &commonNaN );
68 } else {
69 uiZ = packToF16UI( sign, 0x1F, 0 );
70 }
71 goto uiZ;
72 }
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 frac16 = frac>>9 | ((frac & 0x1FF) != 0);
76 if ( ! (exp | frac16) ) {
77 uiZ = packToF16UI( sign, 0, 0 );
78 goto uiZ;
79 }
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 return softfloat_roundPackToF16( sign, exp - 0x71, frac16 | 0x4000 );
83 uiZ:
84 uZ.ui = uiZ;
85 return uZ.f;
86
87}
88
deps/SoftFloat-3d/source/f32_to_f64.c deleted-93
......@@ -1,93 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t f32_to_f64( float32_t a )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t frac;
51 struct commonNaN commonNaN;
52 uint_fast64_t uiZ;
53 struct exp16_sig32 normExpSig;
54 union ui64_f64 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA = uA.ui;
60 sign = signF32UI( uiA );
61 exp = expF32UI( uiA );
62 frac = fracF32UI( uiA );
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0xFF ) {
66 if ( frac ) {
67 softfloat_f32UIToCommonNaN( uiA, &commonNaN );
68 uiZ = softfloat_commonNaNToF64UI( &commonNaN );
69 } else {
70 uiZ = packToF64UI( sign, 0x7FF, 0 );
71 }
72 goto uiZ;
73 }
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( ! exp ) {
77 if ( ! frac ) {
78 uiZ = packToF64UI( sign, 0, 0 );
79 goto uiZ;
80 }
81 normExpSig = softfloat_normSubnormalF32Sig( frac );
82 exp = normExpSig.exp - 1;
83 frac = normExpSig.sig;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 uiZ = packToF64UI( sign, exp + 0x380, (uint_fast64_t) frac<<29 );
88 uiZ:
89 uZ.ui = uiZ;
90 return uZ.f;
91
92}
93
deps/SoftFloat-3d/source/f32_to_i32.c deleted-84
......@@ -1,84 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t f32_to_i32( float32_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t sig;
51 uint_fast64_t sig64;
52 int_fast16_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF32UI( uiA );
59 exp = expF32UI( uiA );
60 sig = fracF32UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
64 if ( (exp == 0xFF) && sig ) {
65#if (i32_fromNaN == i32_fromPosOverflow)
66 sign = 0;
67#elif (i32_fromNaN == i32_fromNegOverflow)
68 sign = 1;
69#else
70 softfloat_raiseFlags( softfloat_flag_invalid );
71 return i32_fromNaN;
72#endif
73 }
74#endif
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp ) sig |= 0x00800000;
78 sig64 = (uint_fast64_t) sig<<32;
79 shiftDist = 0xAA - exp;
80 if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
81 return softfloat_roundToI32( sign, sig64, roundingMode, exact );
82
83}
84
deps/SoftFloat-3d/source/f32_to_i32_r_minMag.c deleted-89
......@@ -1,89 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t f32_to_i32_r_minMag( float32_t a, bool exact )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 int_fast16_t exp;
49 uint_fast32_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
52 int_fast32_t absZ;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF32UI( uiA );
59 sig = fracF32UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x9E - exp;
63 if ( 32 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF32UI( uiA );
72 if ( shiftDist <= 0 ) {
73 if ( uiA == packToF32UI( 1, 0x9E, 0 ) ) return -0x7FFFFFFF - 1;
74 softfloat_raiseFlags( softfloat_flag_invalid );
75 return
76 (exp == 0xFF) && sig ? i32_fromNaN
77 : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 sig = (sig | 0x00800000)<<8;
82 absZ = sig>>shiftDist;
83 if ( exact && ((uint_fast32_t) absZ<<shiftDist != sig) ) {
84 softfloat_exceptionFlags |= softfloat_flag_inexact;
85 }
86 return sign ? -absZ : absZ;
87
88}
89
deps/SoftFloat-3d/source/f32_to_i64.c deleted-96
......@@ -1,96 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t f32_to_i64( float32_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t sig;
51 int_fast16_t shiftDist;
52#ifdef SOFTFLOAT_FAST_INT64
53 uint_fast64_t sig64, extra;
54 struct uint64_extra sig64Extra;
55#else
56 uint32_t extSig[3];
57#endif
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 uA.f = a;
62 uiA = uA.ui;
63 sign = signF32UI( uiA );
64 exp = expF32UI( uiA );
65 sig = fracF32UI( uiA );
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 shiftDist = 0xBE - exp;
69 if ( shiftDist < 0 ) {
70 softfloat_raiseFlags( softfloat_flag_invalid );
71 return
72 (exp == 0xFF) && sig ? i64_fromNaN
73 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
74 }
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp ) sig |= 0x00800000;
78#ifdef SOFTFLOAT_FAST_INT64
79 sig64 = (uint_fast64_t) sig<<40;
80 extra = 0;
81 if ( shiftDist ) {
82 sig64Extra = softfloat_shiftRightJam64Extra( sig64, 0, shiftDist );
83 sig64 = sig64Extra.v;
84 extra = sig64Extra.extra;
85 }
86 return softfloat_roundToI64( sign, sig64, extra, roundingMode, exact );
87#else
88 extSig[indexWord( 3, 2 )] = sig<<8;
89 extSig[indexWord( 3, 1 )] = 0;
90 extSig[indexWord( 3, 0 )] = 0;
91 if ( shiftDist ) softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
92 return softfloat_roundMToI64( sign, extSig, roundingMode, exact );
93#endif
94
95}
96
deps/SoftFloat-3d/source/f32_to_i64_r_minMag.c deleted-94
......@@ -1,94 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t f32_to_i64_r_minMag( float32_t a, bool exact )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 int_fast16_t exp;
49 uint_fast32_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
52 uint_fast64_t sig64;
53 int_fast64_t absZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA = uA.ui;
59 exp = expF32UI( uiA );
60 sig = fracF32UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 shiftDist = 0xBE - exp;
64 if ( 64 <= shiftDist ) {
65 if ( exact && (exp | sig) ) {
66 softfloat_exceptionFlags |= softfloat_flag_inexact;
67 }
68 return 0;
69 }
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 sign = signF32UI( uiA );
73 if ( shiftDist <= 0 ) {
74 if ( uiA == packToF32UI( 1, 0xBE, 0 ) ) {
75 return -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
76 }
77 softfloat_raiseFlags( softfloat_flag_invalid );
78 return
79 (exp == 0xFF) && sig ? i64_fromNaN
80 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 sig |= 0x00800000;
85 sig64 = (uint_fast64_t) sig<<40;
86 absZ = sig64>>shiftDist;
87 shiftDist = 40 - shiftDist;
88 if ( exact && (shiftDist < 0) && (uint32_t) (sig<<(shiftDist & 31)) ) {
89 softfloat_exceptionFlags |= softfloat_flag_inexact;
90 }
91 return sign ? -absZ : absZ;
92
93}
94
deps/SoftFloat-3d/source/f32_to_ui32.c deleted-84
......@@ -1,84 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t f32_to_ui32( float32_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t sig;
51 uint_fast64_t sig64;
52 int_fast16_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF32UI( uiA );
59 exp = expF32UI( uiA );
60 sig = fracF32UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63#if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
64 if ( (exp == 0xFF) && sig ) {
65#if (ui32_fromNaN == ui32_fromPosOverflow)
66 sign = 0;
67#elif (ui32_fromNaN == ui32_fromNegOverflow)
68 sign = 1;
69#else
70 softfloat_raiseFlags( softfloat_flag_invalid );
71 return ui32_fromNaN;
72#endif
73 }
74#endif
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp ) sig |= 0x00800000;
78 sig64 = (uint_fast64_t) sig<<32;
79 shiftDist = 0xAA - exp;
80 if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
81 return softfloat_roundToUI32( sign, sig64, roundingMode, exact );
82
83}
84
deps/SoftFloat-3d/source/f32_to_ui32_r_minMag.c deleted-88
......@@ -1,88 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t f32_to_ui32_r_minMag( float32_t a, bool exact )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 int_fast16_t exp;
49 uint_fast32_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
52 uint_fast32_t z;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF32UI( uiA );
59 sig = fracF32UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x9E - exp;
63 if ( 32 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF32UI( uiA );
72 if ( sign || (shiftDist < 0) ) {
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 return
75 (exp == 0xFF) && sig ? ui32_fromNaN
76 : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 sig = (sig | 0x00800000)<<8;
81 z = sig>>shiftDist;
82 if ( exact && (z<<shiftDist != sig) ) {
83 softfloat_exceptionFlags |= softfloat_flag_inexact;
84 }
85 return z;
86
87}
88
deps/SoftFloat-3d/source/f32_to_ui64.c deleted-96
......@@ -1,96 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t f32_to_ui64( float32_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t sig;
51 int_fast16_t shiftDist;
52#ifdef SOFTFLOAT_FAST_INT64
53 uint_fast64_t sig64, extra;
54 struct uint64_extra sig64Extra;
55#else
56 uint32_t extSig[3];
57#endif
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 uA.f = a;
62 uiA = uA.ui;
63 sign = signF32UI( uiA );
64 exp = expF32UI( uiA );
65 sig = fracF32UI( uiA );
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 shiftDist = 0xBE - exp;
69 if ( shiftDist < 0 ) {
70 softfloat_raiseFlags( softfloat_flag_invalid );
71 return
72 (exp == 0xFF) && sig ? ui64_fromNaN
73 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
74 }
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp ) sig |= 0x00800000;
78#ifdef SOFTFLOAT_FAST_INT64
79 sig64 = (uint_fast64_t) sig<<40;
80 extra = 0;
81 if ( shiftDist ) {
82 sig64Extra = softfloat_shiftRightJam64Extra( sig64, 0, shiftDist );
83 sig64 = sig64Extra.v;
84 extra = sig64Extra.extra;
85 }
86 return softfloat_roundToUI64( sign, sig64, extra, roundingMode, exact );
87#else
88 extSig[indexWord( 3, 2 )] = sig<<8;
89 extSig[indexWord( 3, 1 )] = 0;
90 extSig[indexWord( 3, 0 )] = 0;
91 if ( shiftDist ) softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
92 return softfloat_roundMToUI64( sign, extSig, roundingMode, exact );
93#endif
94
95}
96
deps/SoftFloat-3d/source/f32_to_ui64_r_minMag.c deleted-90
......@@ -1,90 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t f32_to_ui64_r_minMag( float32_t a, bool exact )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 int_fast16_t exp;
49 uint_fast32_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
52 uint_fast64_t sig64, z;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF32UI( uiA );
59 sig = fracF32UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0xBE - exp;
63 if ( 64 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF32UI( uiA );
72 if ( sign || (shiftDist < 0) ) {
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 return
75 (exp == 0xFF) && sig ? ui64_fromNaN
76 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 sig |= 0x00800000;
81 sig64 = (uint_fast64_t) sig<<40;
82 z = sig64>>shiftDist;
83 shiftDist = 40 - shiftDist;
84 if ( exact && (shiftDist < 0) && (uint32_t) (sig<<(shiftDist & 31)) ) {
85 softfloat_exceptionFlags |= softfloat_flag_inexact;
86 }
87 return z;
88
89}
90
deps/SoftFloat-3d/source/f64_add.c deleted-74
......@@ -1,74 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float64_t f64_add( float64_t a, float64_t b )
44{
45 union ui64_f64 uA;
46 uint_fast64_t uiA;
47 bool signA;
48 union ui64_f64 uB;
49 uint_fast64_t uiB;
50 bool signB;
51#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
52 float64_t (*magsFuncPtr)( uint_fast64_t, uint_fast64_t, bool );
53#endif
54
55 uA.f = a;
56 uiA = uA.ui;
57 signA = signF64UI( uiA );
58 uB.f = b;
59 uiB = uB.ui;
60 signB = signF64UI( uiB );
61#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
62 if ( signA == signB ) {
63 return softfloat_addMagsF64( uiA, uiB, signA );
64 } else {
65 return softfloat_subMagsF64( uiA, uiB, signA );
66 }
67#else
68 magsFuncPtr =
69 (signA == signB) ? softfloat_addMagsF64 : softfloat_subMagsF64;
70 return (*magsFuncPtr)( uiA, uiB, signA );
71#endif
72
73}
74
deps/SoftFloat-3d/source/f64_div.c deleted-172
......@@ -1,172 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t f64_div( float64_t a, float64_t b )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast64_t sigA;
51 union ui64_f64 uB;
52 uint_fast64_t uiB;
53 bool signB;
54 int_fast16_t expB;
55 uint_fast64_t sigB;
56 bool signZ;
57 struct exp16_sig64 normExpSig;
58 int_fast16_t expZ;
59 uint32_t recip32, sig32Z, doubleTerm;
60 uint_fast64_t rem;
61 uint32_t q;
62 uint_fast64_t sigZ;
63 uint_fast64_t uiZ;
64 union ui64_f64 uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 uA.f = a;
69 uiA = uA.ui;
70 signA = signF64UI( uiA );
71 expA = expF64UI( uiA );
72 sigA = fracF64UI( uiA );
73 uB.f = b;
74 uiB = uB.ui;
75 signB = signF64UI( uiB );
76 expB = expF64UI( uiB );
77 sigB = fracF64UI( uiB );
78 signZ = signA ^ signB;
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 if ( expA == 0x7FF ) {
82 if ( sigA ) goto propagateNaN;
83 if ( expB == 0x7FF ) {
84 if ( sigB ) goto propagateNaN;
85 goto invalid;
86 }
87 goto infinity;
88 }
89 if ( expB == 0x7FF ) {
90 if ( sigB ) goto propagateNaN;
91 goto zero;
92 }
93 /*------------------------------------------------------------------------
94 *------------------------------------------------------------------------*/
95 if ( ! expB ) {
96 if ( ! sigB ) {
97 if ( ! (expA | sigA) ) goto invalid;
98 softfloat_raiseFlags( softfloat_flag_infinite );
99 goto infinity;
100 }
101 normExpSig = softfloat_normSubnormalF64Sig( sigB );
102 expB = normExpSig.exp;
103 sigB = normExpSig.sig;
104 }
105 if ( ! expA ) {
106 if ( ! sigA ) goto zero;
107 normExpSig = softfloat_normSubnormalF64Sig( sigA );
108 expA = normExpSig.exp;
109 sigA = normExpSig.sig;
110 }
111 /*------------------------------------------------------------------------
112 *------------------------------------------------------------------------*/
113 expZ = expA - expB + 0x3FE;
114 sigA |= UINT64_C( 0x0010000000000000 );
115 sigB |= UINT64_C( 0x0010000000000000 );
116 if ( sigA < sigB ) {
117 --expZ;
118 sigA <<= 11;
119 } else {
120 sigA <<= 10;
121 }
122 sigB <<= 11;
123 recip32 = softfloat_approxRecip32_1( sigB>>32 ) - 2;
124 sig32Z = ((uint32_t) (sigA>>32) * (uint_fast64_t) recip32)>>32;
125 doubleTerm = sig32Z<<1;
126 rem =
127 ((sigA - (uint_fast64_t) doubleTerm * (uint32_t) (sigB>>32))<<28)
128 - (uint_fast64_t) doubleTerm * ((uint32_t) sigB>>4);
129 q = (((uint32_t) (rem>>32) * (uint_fast64_t) recip32)>>32) + 4;
130 sigZ = ((uint_fast64_t) sig32Z<<32) + ((uint_fast64_t) q<<4);
131 /*------------------------------------------------------------------------
132 *------------------------------------------------------------------------*/
133 if ( (sigZ & 0x1FF) < 4<<4 ) {
134 q &= ~7;
135 sigZ &= ~(uint_fast64_t) 0x7F;
136 doubleTerm = q<<1;
137 rem =
138 ((rem - (uint_fast64_t) doubleTerm * (uint32_t) (sigB>>32))<<28)
139 - (uint_fast64_t) doubleTerm * ((uint32_t) sigB>>4);
140 if ( rem & UINT64_C( 0x8000000000000000 ) ) {
141 sigZ -= 1<<7;
142 } else {
143 if ( rem ) sigZ |= 1;
144 }
145 }
146 return softfloat_roundPackToF64( signZ, expZ, sigZ );
147 /*------------------------------------------------------------------------
148 *------------------------------------------------------------------------*/
149 propagateNaN:
150 uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
151 goto uiZ;
152 /*------------------------------------------------------------------------
153 *------------------------------------------------------------------------*/
154 invalid:
155 softfloat_raiseFlags( softfloat_flag_invalid );
156 uiZ = defaultNaNF64UI;
157 goto uiZ;
158 /*------------------------------------------------------------------------
159 *------------------------------------------------------------------------*/
160 infinity:
161 uiZ = packToF64UI( signZ, 0x7FF, 0 );
162 goto uiZ;
163 /*------------------------------------------------------------------------
164 *------------------------------------------------------------------------*/
165 zero:
166 uiZ = packToF64UI( signZ, 0, 0 );
167 uiZ:
168 uZ.ui = uiZ;
169 return uZ.f;
170
171}
172
deps/SoftFloat-3d/source/f64_eq.c deleted-66
......@@ -1,66 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f64_eq( float64_t a, float64_t b )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 union ui64_f64 uB;
49 uint_fast64_t uiB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
56 if (
57 softfloat_isSigNaNF64UI( uiA ) || softfloat_isSigNaNF64UI( uiB )
58 ) {
59 softfloat_raiseFlags( softfloat_flag_invalid );
60 }
61 return false;
62 }
63 return (uiA == uiB) || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ));
64
65}
66
deps/SoftFloat-3d/source/f64_eq_signaling.c deleted-61
......@@ -1,61 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f64_eq_signaling( float64_t a, float64_t b )
44{
45 union ui64_f64 uA;
46 uint_fast64_t uiA;
47 union ui64_f64 uB;
48 uint_fast64_t uiB;
49
50 uA.f = a;
51 uiA = uA.ui;
52 uB.f = b;
53 uiB = uB.ui;
54 if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
55 softfloat_raiseFlags( softfloat_flag_invalid );
56 return false;
57 }
58 return (uiA == uiB) || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ));
59
60}
61
deps/SoftFloat-3d/source/f64_isSignalingNaN.c deleted-51
......@@ -1,51 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43bool f64_isSignalingNaN( float64_t a )
44{
45 union ui64_f64 uA;
46
47 uA.f = a;
48 return softfloat_isSigNaNF64UI( uA.ui );
49
50}
51
deps/SoftFloat-3d/source/f64_le.c deleted-67
......@@ -1,67 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f64_le( float64_t a, float64_t b )
44{
45 union ui64_f64 uA;
46 uint_fast64_t uiA;
47 union ui64_f64 uB;
48 uint_fast64_t uiB;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
56 softfloat_raiseFlags( softfloat_flag_invalid );
57 return false;
58 }
59 signA = signF64UI( uiA );
60 signB = signF64UI( uiB );
61 return
62 (signA != signB)
63 ? signA || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
64 : (uiA == uiB) || (signA ^ (uiA < uiB));
65
66}
67
deps/SoftFloat-3d/source/f64_le_quiet.c deleted-72
......@@ -1,72 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f64_le_quiet( float64_t a, float64_t b )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 union ui64_f64 uB;
49 uint_fast64_t uiB;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA = uA.ui;
54 uB.f = b;
55 uiB = uB.ui;
56 if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
57 if (
58 softfloat_isSigNaNF64UI( uiA ) || softfloat_isSigNaNF64UI( uiB )
59 ) {
60 softfloat_raiseFlags( softfloat_flag_invalid );
61 }
62 return false;
63 }
64 signA = signF64UI( uiA );
65 signB = signF64UI( uiB );
66 return
67 (signA != signB)
68 ? signA || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
69 : (uiA == uiB) || (signA ^ (uiA < uiB));
70
71}
72
deps/SoftFloat-3d/source/f64_lt.c deleted-67
......@@ -1,67 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f64_lt( float64_t a, float64_t b )
44{
45 union ui64_f64 uA;
46 uint_fast64_t uiA;
47 union ui64_f64 uB;
48 uint_fast64_t uiB;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
56 softfloat_raiseFlags( softfloat_flag_invalid );
57 return false;
58 }
59 signA = signF64UI( uiA );
60 signB = signF64UI( uiB );
61 return
62 (signA != signB)
63 ? signA && ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
64 : (uiA != uiB) && (signA ^ (uiA < uiB));
65
66}
67
deps/SoftFloat-3d/source/f64_lt_quiet.c deleted-72
......@@ -1,72 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f64_lt_quiet( float64_t a, float64_t b )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 union ui64_f64 uB;
49 uint_fast64_t uiB;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA = uA.ui;
54 uB.f = b;
55 uiB = uB.ui;
56 if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
57 if (
58 softfloat_isSigNaNF64UI( uiA ) || softfloat_isSigNaNF64UI( uiB )
59 ) {
60 softfloat_raiseFlags( softfloat_flag_invalid );
61 }
62 return false;
63 }
64 signA = signF64UI( uiA );
65 signB = signF64UI( uiB );
66 return
67 (signA != signB)
68 ? signA && ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
69 : (uiA != uiB) && (signA ^ (uiA < uiB));
70
71}
72
deps/SoftFloat-3d/source/f64_mul.c deleted-150
......@@ -1,150 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t f64_mul( float64_t a, float64_t b )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast64_t sigA;
51 union ui64_f64 uB;
52 uint_fast64_t uiB;
53 bool signB;
54 int_fast16_t expB;
55 uint_fast64_t sigB;
56 bool signZ;
57 uint_fast64_t magBits;
58 struct exp16_sig64 normExpSig;
59 int_fast16_t expZ;
60#ifdef SOFTFLOAT_FAST_INT64
61 struct uint128 sig128Z;
62#else
63 uint32_t sig128Z[4];
64#endif
65 uint_fast64_t sigZ, uiZ;
66 union ui64_f64 uZ;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 uA.f = a;
71 uiA = uA.ui;
72 signA = signF64UI( uiA );
73 expA = expF64UI( uiA );
74 sigA = fracF64UI( uiA );
75 uB.f = b;
76 uiB = uB.ui;
77 signB = signF64UI( uiB );
78 expB = expF64UI( uiB );
79 sigB = fracF64UI( uiB );
80 signZ = signA ^ signB;
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 if ( expA == 0x7FF ) {
84 if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN;
85 magBits = expB | sigB;
86 goto infArg;
87 }
88 if ( expB == 0x7FF ) {
89 if ( sigB ) goto propagateNaN;
90 magBits = expA | sigA;
91 goto infArg;
92 }
93 /*------------------------------------------------------------------------
94 *------------------------------------------------------------------------*/
95 if ( ! expA ) {
96 if ( ! sigA ) goto zero;
97 normExpSig = softfloat_normSubnormalF64Sig( sigA );
98 expA = normExpSig.exp;
99 sigA = normExpSig.sig;
100 }
101 if ( ! expB ) {
102 if ( ! sigB ) goto zero;
103 normExpSig = softfloat_normSubnormalF64Sig( sigB );
104 expB = normExpSig.exp;
105 sigB = normExpSig.sig;
106 }
107 /*------------------------------------------------------------------------
108 *------------------------------------------------------------------------*/
109 expZ = expA + expB - 0x3FF;
110 sigA = (sigA | UINT64_C( 0x0010000000000000 ))<<10;
111 sigB = (sigB | UINT64_C( 0x0010000000000000 ))<<11;
112#ifdef SOFTFLOAT_FAST_INT64
113 sig128Z = softfloat_mul64To128( sigA, sigB );
114 sigZ = sig128Z.v64 | (sig128Z.v0 != 0);
115#else
116 softfloat_mul64To128M( sigA, sigB, sig128Z );
117 sigZ =
118 (uint64_t) sig128Z[indexWord( 4, 3 )]<<32 | sig128Z[indexWord( 4, 2 )];
119 if ( sig128Z[indexWord( 4, 1 )] || sig128Z[indexWord( 4, 0 )] ) sigZ |= 1;
120#endif
121 if ( sigZ < UINT64_C( 0x4000000000000000 ) ) {
122 --expZ;
123 sigZ <<= 1;
124 }
125 return softfloat_roundPackToF64( signZ, expZ, sigZ );
126 /*------------------------------------------------------------------------
127 *------------------------------------------------------------------------*/
128 propagateNaN:
129 uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
130 goto uiZ;
131 /*------------------------------------------------------------------------
132 *------------------------------------------------------------------------*/
133 infArg:
134 if ( ! magBits ) {
135 softfloat_raiseFlags( softfloat_flag_invalid );
136 uiZ = defaultNaNF64UI;
137 } else {
138 uiZ = packToF64UI( signZ, 0x7FF, 0 );
139 }
140 goto uiZ;
141 /*------------------------------------------------------------------------
142 *------------------------------------------------------------------------*/
143 zero:
144 uiZ = packToF64UI( signZ, 0, 0 );
145 uiZ:
146 uZ.ui = uiZ;
147 return uZ.f;
148
149}
150
deps/SoftFloat-3d/source/f64_mulAdd.c deleted-60
......@@ -1,60 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float64_t f64_mulAdd( float64_t a, float64_t b, float64_t c )
43{
44 union ui64_f64 uA;
45 uint_fast64_t uiA;
46 union ui64_f64 uB;
47 uint_fast64_t uiB;
48 union ui64_f64 uC;
49 uint_fast64_t uiC;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 uC.f = c;
56 uiC = uC.ui;
57 return softfloat_mulAddF64( uiA, uiB, uiC, 0 );
58
59}
60
deps/SoftFloat-3d/source/f64_rem.c deleted-189
......@@ -1,189 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t f64_rem( float64_t a, float64_t b )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast64_t sigA;
51 union ui64_f64 uB;
52 uint_fast64_t uiB;
53 int_fast16_t expB;
54 uint_fast64_t sigB;
55 struct exp16_sig64 normExpSig;
56 uint64_t rem;
57 int_fast16_t expDiff;
58 uint32_t q, recip32;
59 uint_fast64_t q64;
60 uint64_t altRem, meanRem;
61 bool signRem;
62 uint_fast64_t uiZ;
63 union ui64_f64 uZ;
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 uA.f = a;
68 uiA = uA.ui;
69 signA = signF64UI( uiA );
70 expA = expF64UI( uiA );
71 sigA = fracF64UI( uiA );
72 uB.f = b;
73 uiB = uB.ui;
74 expB = expF64UI( uiB );
75 sigB = fracF64UI( uiB );
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( expA == 0x7FF ) {
79 if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN;
80 goto invalid;
81 }
82 if ( expB == 0x7FF ) {
83 if ( sigB ) goto propagateNaN;
84 return a;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 if ( expA < expB - 1 ) return a;
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 if ( ! expB ) {
92 if ( ! sigB ) goto invalid;
93 normExpSig = softfloat_normSubnormalF64Sig( sigB );
94 expB = normExpSig.exp;
95 sigB = normExpSig.sig;
96 }
97 if ( ! expA ) {
98 if ( ! sigA ) return a;
99 normExpSig = softfloat_normSubnormalF64Sig( sigA );
100 expA = normExpSig.exp;
101 sigA = normExpSig.sig;
102 }
103 /*------------------------------------------------------------------------
104 *------------------------------------------------------------------------*/
105 rem = sigA | UINT64_C( 0x0010000000000000 );
106 sigB |= UINT64_C( 0x0010000000000000 );
107 expDiff = expA - expB;
108 if ( expDiff < 1 ) {
109 if ( expDiff < -1 ) return a;
110 sigB <<= 9;
111 if ( expDiff ) {
112 rem <<= 8;
113 q = 0;
114 } else {
115 rem <<= 9;
116 q = (sigB <= rem);
117 if ( q ) rem -= sigB;
118 }
119 } else {
120 recip32 = softfloat_approxRecip32_1( sigB>>21 );
121 /*--------------------------------------------------------------------
122 | Changing the shift of `rem' here requires also changing the initial
123 | subtraction from `expDiff'.
124 *--------------------------------------------------------------------*/
125 rem <<= 9;
126 expDiff -= 30;
127 /*--------------------------------------------------------------------
128 | The scale of `sigB' affects how many bits are obtained during each
129 | cycle of the loop. Currently this is 29 bits per loop iteration,
130 | the maximum possible.
131 *--------------------------------------------------------------------*/
132 sigB <<= 9;
133 for (;;) {
134 q64 = (uint32_t) (rem>>32) * (uint_fast64_t) recip32;
135 if ( expDiff < 0 ) break;
136 q = (q64 + 0x80000000)>>32;
137#ifdef SOFTFLOAT_FAST_INT64
138 rem <<= 29;
139#else
140 rem = (uint_fast64_t) (uint32_t) (rem>>3)<<32;
141#endif
142 rem -= q * (uint64_t) sigB;
143 if ( rem & UINT64_C( 0x8000000000000000 ) ) rem += sigB;
144 expDiff -= 29;
145 }
146 /*--------------------------------------------------------------------
147 | (`expDiff' cannot be less than -29 here.)
148 *--------------------------------------------------------------------*/
149 q = (uint32_t) (q64>>32)>>(~expDiff & 31);
150 rem = (rem<<(expDiff + 30)) - q * (uint64_t) sigB;
151 if ( rem & UINT64_C( 0x8000000000000000 ) ) {
152 altRem = rem + sigB;
153 goto selectRem;
154 }
155 }
156 /*------------------------------------------------------------------------
157 *------------------------------------------------------------------------*/
158 do {
159 altRem = rem;
160 ++q;
161 rem -= sigB;
162 } while ( ! (rem & UINT64_C( 0x8000000000000000 )) );
163 selectRem:
164 meanRem = rem + altRem;
165 if (
166 (meanRem & UINT64_C( 0x8000000000000000 )) || (! meanRem && (q & 1))
167 ) {
168 rem = altRem;
169 }
170 signRem = signA;
171 if ( rem & UINT64_C( 0x8000000000000000 ) ) {
172 signRem = ! signRem;
173 rem = -rem;
174 }
175 return softfloat_normRoundPackToF64( signRem, expB, rem );
176 /*------------------------------------------------------------------------
177 *------------------------------------------------------------------------*/
178 propagateNaN:
179 uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
180 goto uiZ;
181 invalid:
182 softfloat_raiseFlags( softfloat_flag_invalid );
183 uiZ = defaultNaNF64UI;
184 uiZ:
185 uZ.ui = uiZ;
186 return uZ.f;
187
188}
189
deps/SoftFloat-3d/source/f64_roundToInt.c deleted-112
......@@ -1,112 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t f64_roundToInt( float64_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 int_fast16_t exp;
49 uint_fast64_t uiZ, lastBitMask, roundBitsMask;
50 union ui64_f64 uZ;
51
52 /*------------------------------------------------------------------------
53 *------------------------------------------------------------------------*/
54 uA.f = a;
55 uiA = uA.ui;
56 exp = expF64UI( uiA );
57 /*------------------------------------------------------------------------
58 *------------------------------------------------------------------------*/
59 if ( exp <= 0x3FE ) {
60 if ( ! (uiA & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) return a;
61 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
62 uiZ = uiA & packToF64UI( 1, 0, 0 );
63 switch ( roundingMode ) {
64 case softfloat_round_near_even:
65 if ( ! fracF64UI( uiA ) ) break;
66 case softfloat_round_near_maxMag:
67 if ( exp == 0x3FE ) uiZ |= packToF64UI( 0, 0x3FF, 0 );
68 break;
69 case softfloat_round_min:
70 if ( uiZ ) uiZ = packToF64UI( 1, 0x3FF, 0 );
71 break;
72 case softfloat_round_max:
73 if ( ! uiZ ) uiZ = packToF64UI( 0, 0x3FF, 0 );
74 break;
75 }
76 goto uiZ;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 if ( 0x433 <= exp ) {
81 if ( (exp == 0x7FF) && fracF64UI( uiA ) ) {
82 uiZ = softfloat_propagateNaNF64UI( uiA, 0 );
83 goto uiZ;
84 }
85 return a;
86 }
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 uiZ = uiA;
90 lastBitMask = (uint_fast64_t) 1<<(0x433 - exp);
91 roundBitsMask = lastBitMask - 1;
92 if ( roundingMode == softfloat_round_near_maxMag ) {
93 uiZ += lastBitMask>>1;
94 } else if ( roundingMode == softfloat_round_near_even ) {
95 uiZ += lastBitMask>>1;
96 if ( ! (uiZ & roundBitsMask) ) uiZ &= ~lastBitMask;
97 } else if (
98 roundingMode
99 == (signF64UI( uiZ ) ? softfloat_round_min : softfloat_round_max)
100 ) {
101 uiZ += roundBitsMask;
102 }
103 uiZ &= ~roundBitsMask;
104 if ( exact && (uiZ != uiA) ) {
105 softfloat_exceptionFlags |= softfloat_flag_inexact;
106 }
107 uiZ:
108 uZ.ui = uiZ;
109 return uZ.f;
110
111}
112
deps/SoftFloat-3d/source/f64_sqrt.c deleted-133
......@@ -1,133 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t f64_sqrt( float64_t a )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast64_t sigA, uiZ;
51 struct exp16_sig64 normExpSig;
52 int_fast16_t expZ;
53 uint32_t sig32A, recipSqrt32, sig32Z;
54 uint_fast64_t rem;
55 uint32_t q;
56 uint_fast64_t sigZ, shiftedSigZ;
57 union ui64_f64 uZ;
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 uA.f = a;
62 uiA = uA.ui;
63 signA = signF64UI( uiA );
64 expA = expF64UI( uiA );
65 sigA = fracF64UI( uiA );
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 if ( expA == 0x7FF ) {
69 if ( sigA ) {
70 uiZ = softfloat_propagateNaNF64UI( uiA, 0 );
71 goto uiZ;
72 }
73 if ( ! signA ) return a;
74 goto invalid;
75 }
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( signA ) {
79 if ( ! (expA | sigA) ) return a;
80 goto invalid;
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( ! expA ) {
85 if ( ! sigA ) return a;
86 normExpSig = softfloat_normSubnormalF64Sig( sigA );
87 expA = normExpSig.exp;
88 sigA = normExpSig.sig;
89 }
90 /*------------------------------------------------------------------------
91 | (`sig32Z' is guaranteed to be a lower bound on the square root of
92 | `sig32A', which makes `sig32Z' also a lower bound on the square root of
93 | `sigA'.)
94 *------------------------------------------------------------------------*/
95 expZ = ((expA - 0x3FF)>>1) + 0x3FE;
96 expA &= 1;
97 sigA |= UINT64_C( 0x0010000000000000 );
98 sig32A = sigA>>21;
99 recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
100 sig32Z = ((uint_fast64_t) sig32A * recipSqrt32)>>32;
101 if ( expA ) {
102 sigA <<= 8;
103 sig32Z >>= 1;
104 } else {
105 sigA <<= 9;
106 }
107 rem = sigA - (uint_fast64_t) sig32Z * sig32Z;
108 q = ((uint32_t) (rem>>2) * (uint_fast64_t) recipSqrt32)>>32;
109 sigZ = ((uint_fast64_t) sig32Z<<32 | 1<<5) + ((uint_fast64_t) q<<3);
110 /*------------------------------------------------------------------------
111 *------------------------------------------------------------------------*/
112 if ( (sigZ & 0x1FF) < 0x22 ) {
113 sigZ &= ~(uint_fast64_t) 0x3F;
114 shiftedSigZ = sigZ>>6;
115 rem = (sigA<<52) - shiftedSigZ * shiftedSigZ;
116 if ( rem & UINT64_C( 0x8000000000000000 ) ) {
117 --sigZ;
118 } else {
119 if ( rem ) sigZ |= 1;
120 }
121 }
122 return softfloat_roundPackToF64( 0, expZ, sigZ );
123 /*------------------------------------------------------------------------
124 *------------------------------------------------------------------------*/
125 invalid:
126 softfloat_raiseFlags( softfloat_flag_invalid );
127 uiZ = defaultNaNF64UI;
128 uiZ:
129 uZ.ui = uiZ;
130 return uZ.f;
131
132}
133
deps/SoftFloat-3d/source/f64_sub.c deleted-74
......@@ -1,74 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float64_t f64_sub( float64_t a, float64_t b )
44{
45 union ui64_f64 uA;
46 uint_fast64_t uiA;
47 bool signA;
48 union ui64_f64 uB;
49 uint_fast64_t uiB;
50 bool signB;
51#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
52 float64_t (*magsFuncPtr)( uint_fast64_t, uint_fast64_t, bool );
53#endif
54
55 uA.f = a;
56 uiA = uA.ui;
57 signA = signF64UI( uiA );
58 uB.f = b;
59 uiB = uB.ui;
60 signB = signF64UI( uiB );
61#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
62 if ( signA == signB ) {
63 return softfloat_subMagsF64( uiA, uiB, signA );
64 } else {
65 return softfloat_addMagsF64( uiA, uiB, signA );
66 }
67#else
68 magsFuncPtr =
69 (signA == signB) ? softfloat_subMagsF64 : softfloat_addMagsF64;
70 return (*magsFuncPtr)( uiA, uiB, signA );
71#endif
72
73}
74
deps/SoftFloat-3d/source/f64_to_extF80.c deleted-101
......@@ -1,101 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t f64_to_extF80( float64_t a )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t frac;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 uint_fast16_t uiZ64;
54 uint_fast64_t uiZ0;
55 struct exp16_sig64 normExpSig;
56 union { struct extFloat80M s; extFloat80_t f; } uZ;
57
58 /*------------------------------------------------------------------------
59 *------------------------------------------------------------------------*/
60 uA.f = a;
61 uiA = uA.ui;
62 sign = signF64UI( uiA );
63 exp = expF64UI( uiA );
64 frac = fracF64UI( uiA );
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( exp == 0x7FF ) {
68 if ( frac ) {
69 softfloat_f64UIToCommonNaN( uiA, &commonNaN );
70 uiZ = softfloat_commonNaNToExtF80UI( &commonNaN );
71 uiZ64 = uiZ.v64;
72 uiZ0 = uiZ.v0;
73 } else {
74 uiZ64 = packToExtF80UI64( sign, 0x7FFF );
75 uiZ0 = UINT64_C( 0x8000000000000000 );
76 }
77 goto uiZ;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 if ( ! exp ) {
82 if ( ! frac ) {
83 uiZ64 = packToExtF80UI64( sign, 0 );
84 uiZ0 = 0;
85 goto uiZ;
86 }
87 normExpSig = softfloat_normSubnormalF64Sig( frac );
88 exp = normExpSig.exp;
89 frac = normExpSig.sig;
90 }
91 /*------------------------------------------------------------------------
92 *------------------------------------------------------------------------*/
93 uiZ64 = packToExtF80UI64( sign, exp + 0x3C00 );
94 uiZ0 = (frac | UINT64_C( 0x0010000000000000 ))<<11;
95 uiZ:
96 uZ.s.signExp = uiZ64;
97 uZ.s.signif = uiZ0;
98 return uZ.f;
99
100}
101
deps/SoftFloat-3d/source/f64_to_extF80M.c deleted-111
......@@ -1,111 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void f64_to_extF80M( float64_t a, extFloat80_t *zPtr )
47{
48
49 *zPtr = f64_to_extF80( a );
50
51}
52
53#else
54
55void f64_to_extF80M( float64_t a, extFloat80_t *zPtr )
56{
57 struct extFloat80M *zSPtr;
58 union ui64_f64 uA;
59 uint64_t uiA;
60 bool sign;
61 int_fast16_t exp;
62 uint64_t frac;
63 struct commonNaN commonNaN;
64 uint_fast16_t uiZ64;
65 uint64_t uiZ0;
66 struct exp16_sig64 normExpSig;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 zSPtr = (struct extFloat80M *) zPtr;
71 uA.f = a;
72 uiA = uA.ui;
73 sign = signF64UI( uiA );
74 exp = expF64UI( uiA );
75 frac = fracF64UI( uiA );
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( exp == 0x7FF ) {
79 if ( frac ) {
80 softfloat_f64UIToCommonNaN( uiA, &commonNaN );
81 softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
82 return;
83 }
84 uiZ64 = packToExtF80UI64( sign, 0x7FFF );
85 uiZ0 = UINT64_C( 0x8000000000000000 );
86 goto uiZ;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( ! exp ) {
91 if ( ! frac ) {
92 uiZ64 = packToExtF80UI64( sign, 0 );
93 uiZ0 = 0;
94 goto uiZ;
95 }
96 normExpSig = softfloat_normSubnormalF64Sig( frac );
97 exp = normExpSig.exp;
98 frac = normExpSig.sig;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 uiZ64 = packToExtF80UI64( sign, exp + 0x3C00 );
103 uiZ0 = UINT64_C( 0x8000000000000000 ) | frac<<11;
104 uiZ:
105 zSPtr->signExp = uiZ64;
106 zSPtr->signif = uiZ0;
107
108}
109
110#endif
111
deps/SoftFloat-3d/source/f64_to_f128.c deleted-98
......@@ -1,98 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t f64_to_f128( float64_t a )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t frac;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 struct exp16_sig64 normExpSig;
54 struct uint128 frac128;
55 union ui128_f128 uZ;
56
57 /*------------------------------------------------------------------------
58 *------------------------------------------------------------------------*/
59 uA.f = a;
60 uiA = uA.ui;
61 sign = signF64UI( uiA );
62 exp = expF64UI( uiA );
63 frac = fracF64UI( uiA );
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 if ( exp == 0x7FF ) {
67 if ( frac ) {
68 softfloat_f64UIToCommonNaN( uiA, &commonNaN );
69 uiZ = softfloat_commonNaNToF128UI( &commonNaN );
70 } else {
71 uiZ.v64 = packToF128UI64( sign, 0x7FFF, 0 );
72 uiZ.v0 = 0;
73 }
74 goto uiZ;
75 }
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( ! exp ) {
79 if ( ! frac ) {
80 uiZ.v64 = packToF128UI64( sign, 0, 0 );
81 uiZ.v0 = 0;
82 goto uiZ;
83 }
84 normExpSig = softfloat_normSubnormalF64Sig( frac );
85 exp = normExpSig.exp - 1;
86 frac = normExpSig.sig;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 frac128 = softfloat_shortShiftLeft128( 0, frac, 60 );
91 uiZ.v64 = packToF128UI64( sign, exp + 0x3C00, frac128.v64 );
92 uiZ.v0 = frac128.v0;
93 uiZ:
94 uZ.ui = uiZ;
95 return uZ.f;
96
97}
98
deps/SoftFloat-3d/source/f64_to_f128M.c deleted-117
......@@ -1,117 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void f64_to_f128M( float64_t a, float128_t *zPtr )
47{
48
49 *zPtr = f64_to_f128( a );
50
51}
52
53#else
54
55void f64_to_f128M( float64_t a, float128_t *zPtr )
56{
57 uint32_t *zWPtr;
58 union ui64_f64 uA;
59 uint64_t uiA;
60 bool sign;
61 int_fast16_t exp;
62 uint64_t frac;
63 struct commonNaN commonNaN;
64 uint32_t uiZ96;
65 struct exp16_sig64 normExpSig;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 zWPtr = (uint32_t *) zPtr;
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 uA.f = a;
73 uiA = uA.ui;
74 sign = signF64UI( uiA );
75 exp = expF64UI( uiA );
76 frac = fracF64UI( uiA );
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 zWPtr[indexWord( 4, 0 )] = 0;
80 if ( exp == 0x7FF ) {
81 if ( frac ) {
82 softfloat_f64UIToCommonNaN( uiA, &commonNaN );
83 softfloat_commonNaNToF128M( &commonNaN, zWPtr );
84 return;
85 }
86 uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
87 goto uiZ;
88 }
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 if ( ! exp ) {
92 if ( ! frac ) {
93 uiZ96 = packToF128UI96( sign, 0, 0 );
94 goto uiZ;
95 }
96 normExpSig = softfloat_normSubnormalF64Sig( frac );
97 exp = normExpSig.exp - 1;
98 frac = normExpSig.sig;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 zWPtr[indexWord( 4, 1 )] = (uint32_t) frac<<28;
103 frac >>= 4;
104 zWPtr[indexWordHi( 4 )] = packToF128UI96( sign, exp + 0x3C00, frac>>32 );
105 zWPtr[indexWord( 4, 2 )] = frac;
106 return;
107 /*------------------------------------------------------------------------
108 *------------------------------------------------------------------------*/
109 uiZ:
110 zWPtr[indexWord( 4, 3 )] = uiZ96;
111 zWPtr[indexWord( 4, 2 )] = 0;
112 zWPtr[indexWord( 4, 1 )] = 0;
113
114}
115
116#endif
117
deps/SoftFloat-3d/source/f64_to_f16.c deleted-88
......@@ -1,88 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t f64_to_f16( float64_t a )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t frac;
51 struct commonNaN commonNaN;
52 uint_fast16_t uiZ, frac16;
53 union ui16_f16 uZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA = uA.ui;
59 sign = signF64UI( uiA );
60 exp = expF64UI( uiA );
61 frac = fracF64UI( uiA );
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 if ( exp == 0x7FF ) {
65 if ( frac ) {
66 softfloat_f64UIToCommonNaN( uiA, &commonNaN );
67 uiZ = softfloat_commonNaNToF16UI( &commonNaN );
68 } else {
69 uiZ = packToF16UI( sign, 0x1F, 0 );
70 }
71 goto uiZ;
72 }
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 frac16 = softfloat_shortShiftRightJam64( frac, 38 );
76 if ( ! (exp | frac16) ) {
77 uiZ = packToF16UI( sign, 0, 0 );
78 goto uiZ;
79 }
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 return softfloat_roundPackToF16( sign, exp - 0x3F1, frac16 | 0x4000 );
83 uiZ:
84 uZ.ui = uiZ;
85 return uZ.f;
86
87}
88
deps/SoftFloat-3d/source/f64_to_f32.c deleted-88
......@@ -1,88 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t f64_to_f32( float64_t a )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t frac;
51 struct commonNaN commonNaN;
52 uint_fast32_t uiZ, frac32;
53 union ui32_f32 uZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA = uA.ui;
59 sign = signF64UI( uiA );
60 exp = expF64UI( uiA );
61 frac = fracF64UI( uiA );
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 if ( exp == 0x7FF ) {
65 if ( frac ) {
66 softfloat_f64UIToCommonNaN( uiA, &commonNaN );
67 uiZ = softfloat_commonNaNToF32UI( &commonNaN );
68 } else {
69 uiZ = packToF32UI( sign, 0xFF, 0 );
70 }
71 goto uiZ;
72 }
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 frac32 = softfloat_shortShiftRightJam64( frac, 22 );
76 if ( ! (exp | frac32) ) {
77 uiZ = packToF32UI( sign, 0, 0 );
78 goto uiZ;
79 }
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 return softfloat_roundPackToF32( sign, exp - 0x381, frac32 | 0x40000000 );
83 uiZ:
84 uZ.ui = uiZ;
85 return uZ.f;
86
87}
88
deps/SoftFloat-3d/source/f64_to_i32.c deleted-82
......@@ -1,82 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t f64_to_i32( float64_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t sig;
51 int_fast16_t shiftDist;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 uA.f = a;
56 uiA = uA.ui;
57 sign = signF64UI( uiA );
58 exp = expF64UI( uiA );
59 sig = fracF64UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
63 if ( (exp == 0x7FF) && sig ) {
64#if (i32_fromNaN == i32_fromPosOverflow)
65 sign = 0;
66#elif (i32_fromNaN == i32_fromNegOverflow)
67 sign = 1;
68#else
69 softfloat_raiseFlags( softfloat_flag_invalid );
70 return i32_fromNaN;
71#endif
72 }
73#endif
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
77 shiftDist = 0x427 - exp;
78 if ( 0 < shiftDist ) sig = softfloat_shiftRightJam64( sig, shiftDist );
79 return softfloat_roundToI32( sign, sig, roundingMode, exact );
80
81}
82
deps/SoftFloat-3d/source/f64_to_i32_r_minMag.c deleted-96
......@@ -1,96 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t f64_to_i32_r_minMag( float64_t a, bool exact )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 int_fast16_t exp;
49 uint_fast64_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
52 int_fast32_t absZ;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF64UI( uiA );
59 sig = fracF64UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x433 - exp;
63 if ( 53 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF64UI( uiA );
72 if ( shiftDist < 22 ) {
73 if (
74 sign && (exp == 0x41E) && (sig < UINT64_C( 0x0000000000200000 ))
75 ) {
76 if ( exact && sig ) {
77 softfloat_exceptionFlags |= softfloat_flag_inexact;
78 }
79 return -0x7FFFFFFF - 1;
80 }
81 softfloat_raiseFlags( softfloat_flag_invalid );
82 return
83 (exp == 0x7FF) && sig ? i32_fromNaN
84 : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 sig |= UINT64_C( 0x0010000000000000 );
89 absZ = sig>>shiftDist;
90 if ( exact && ((uint_fast64_t) (uint_fast32_t) absZ<<shiftDist != sig) ) {
91 softfloat_exceptionFlags |= softfloat_flag_inexact;
92 }
93 return sign ? -absZ : absZ;
94
95}
96
deps/SoftFloat-3d/source/f64_to_i64.c deleted-103
......@@ -1,103 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t f64_to_i64( float64_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t sig;
51 int_fast16_t shiftDist;
52#ifdef SOFTFLOAT_FAST_INT64
53 struct uint64_extra sigExtra;
54#else
55 uint32_t extSig[3];
56#endif
57
58 /*------------------------------------------------------------------------
59 *------------------------------------------------------------------------*/
60 uA.f = a;
61 uiA = uA.ui;
62 sign = signF64UI( uiA );
63 exp = expF64UI( uiA );
64 sig = fracF64UI( uiA );
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
68 shiftDist = 0x433 - exp;
69#ifdef SOFTFLOAT_FAST_INT64
70 if ( shiftDist <= 0 ) {
71 if ( shiftDist < -11 ) goto invalid;
72 sigExtra.v = sig<<-shiftDist;
73 sigExtra.extra = 0;
74 } else {
75 sigExtra = softfloat_shiftRightJam64Extra( sig, 0, shiftDist );
76 }
77 return
78 softfloat_roundToI64(
79 sign, sigExtra.v, sigExtra.extra, roundingMode, exact );
80#else
81 extSig[indexWord( 3, 0 )] = 0;
82 if ( shiftDist <= 0 ) {
83 if ( shiftDist < -11 ) goto invalid;
84 sig <<= -shiftDist;
85 extSig[indexWord( 3, 2 )] = sig>>32;
86 extSig[indexWord( 3, 1 )] = sig;
87 } else {
88 extSig[indexWord( 3, 2 )] = sig>>32;
89 extSig[indexWord( 3, 1 )] = sig;
90 softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
91 }
92 return softfloat_roundMToI64( sign, extSig, roundingMode, exact );
93#endif
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 invalid:
97 softfloat_raiseFlags( softfloat_flag_invalid );
98 return
99 (exp == 0x7FF) && fracF64UI( uiA ) ? i64_fromNaN
100 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
101
102}
103
deps/SoftFloat-3d/source/f64_to_i64_r_minMag.c deleted-100
......@@ -1,100 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t f64_to_i64_r_minMag( float64_t a, bool exact )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t sig;
51 int_fast16_t shiftDist;
52 int_fast64_t absZ;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF64UI( uiA );
59 exp = expF64UI( uiA );
60 sig = fracF64UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 shiftDist = 0x433 - exp;
64 if ( shiftDist <= 0 ) {
65 /*--------------------------------------------------------------------
66 *--------------------------------------------------------------------*/
67 if ( shiftDist < -10 ) {
68 if ( uiA == packToF64UI( 1, 0x43E, 0 ) ) {
69 return -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
70 }
71 softfloat_raiseFlags( softfloat_flag_invalid );
72 return
73 (exp == 0x7FF) && sig ? i64_fromNaN
74 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
75 }
76 /*--------------------------------------------------------------------
77 *--------------------------------------------------------------------*/
78 sig |= UINT64_C( 0x0010000000000000 );
79 absZ = sig<<-shiftDist;
80 } else {
81 /*--------------------------------------------------------------------
82 *--------------------------------------------------------------------*/
83 if ( 53 <= shiftDist ) {
84 if ( exact && (exp | sig) ) {
85 softfloat_exceptionFlags |= softfloat_flag_inexact;
86 }
87 return 0;
88 }
89 /*--------------------------------------------------------------------
90 *--------------------------------------------------------------------*/
91 sig |= UINT64_C( 0x0010000000000000 );
92 absZ = sig>>shiftDist;
93 if ( exact && (absZ<<shiftDist != sig) ) {
94 softfloat_exceptionFlags |= softfloat_flag_inexact;
95 }
96 }
97 return sign ? -absZ : absZ;
98
99}
100
deps/SoftFloat-3d/source/f64_to_ui32.c deleted-82
......@@ -1,82 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t f64_to_ui32( float64_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t sig;
51 int_fast16_t shiftDist;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 uA.f = a;
56 uiA = uA.ui;
57 sign = signF64UI( uiA );
58 exp = expF64UI( uiA );
59 sig = fracF64UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62#if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
63 if ( (exp == 0x7FF) && sig ) {
64#if (ui32_fromNaN == ui32_fromPosOverflow)
65 sign = 0;
66#elif (ui32_fromNaN == ui32_fromNegOverflow)
67 sign = 1;
68#else
69 softfloat_raiseFlags( softfloat_flag_invalid );
70 return ui32_fromNaN;
71#endif
72 }
73#endif
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
77 shiftDist = 0x427 - exp;
78 if ( 0 < shiftDist ) sig = softfloat_shiftRightJam64( sig, shiftDist );
79 return softfloat_roundToUI32( sign, sig, roundingMode, exact );
80
81}
82
deps/SoftFloat-3d/source/f64_to_ui32_r_minMag.c deleted-88
......@@ -1,88 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t f64_to_ui32_r_minMag( float64_t a, bool exact )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 int_fast16_t exp;
49 uint_fast64_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
52 uint_fast32_t z;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF64UI( uiA );
59 sig = fracF64UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x433 - exp;
63 if ( 53 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF64UI( uiA );
72 if ( sign || (shiftDist < 21) ) {
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 return
75 (exp == 0x7FF) && sig ? ui32_fromNaN
76 : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 sig |= UINT64_C( 0x0010000000000000 );
81 z = sig>>shiftDist;
82 if ( exact && ((uint_fast64_t) z<<shiftDist != sig) ) {
83 softfloat_exceptionFlags |= softfloat_flag_inexact;
84 }
85 return z;
86
87}
88
deps/SoftFloat-3d/source/f64_to_ui64.c deleted-103
......@@ -1,103 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t f64_to_ui64( float64_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t sig;
51 int_fast16_t shiftDist;
52#ifdef SOFTFLOAT_FAST_INT64
53 struct uint64_extra sigExtra;
54#else
55 uint32_t extSig[3];
56#endif
57
58 /*------------------------------------------------------------------------
59 *------------------------------------------------------------------------*/
60 uA.f = a;
61 uiA = uA.ui;
62 sign = signF64UI( uiA );
63 exp = expF64UI( uiA );
64 sig = fracF64UI( uiA );
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
68 shiftDist = 0x433 - exp;
69#ifdef SOFTFLOAT_FAST_INT64
70 if ( shiftDist <= 0 ) {
71 if ( shiftDist < -11 ) goto invalid;
72 sigExtra.v = sig<<-shiftDist;
73 sigExtra.extra = 0;
74 } else {
75 sigExtra = softfloat_shiftRightJam64Extra( sig, 0, shiftDist );
76 }
77 return
78 softfloat_roundToUI64(
79 sign, sigExtra.v, sigExtra.extra, roundingMode, exact );
80#else
81 extSig[indexWord( 3, 0 )] = 0;
82 if ( shiftDist <= 0 ) {
83 if ( shiftDist < -11 ) goto invalid;
84 sig <<= -shiftDist;
85 extSig[indexWord( 3, 2 )] = sig>>32;
86 extSig[indexWord( 3, 1 )] = sig;
87 } else {
88 extSig[indexWord( 3, 2 )] = sig>>32;
89 extSig[indexWord( 3, 1 )] = sig;
90 softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
91 }
92 return softfloat_roundMToUI64( sign, extSig, roundingMode, exact );
93#endif
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 invalid:
97 softfloat_raiseFlags( softfloat_flag_invalid );
98 return
99 (exp == 0x7FF) && fracF64UI( uiA ) ? ui64_fromNaN
100 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
101
102}
103
deps/SoftFloat-3d/source/f64_to_ui64_r_minMag.c deleted-93
......@@ -1,93 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t f64_to_ui64_r_minMag( float64_t a, bool exact )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 int_fast16_t exp;
49 uint_fast64_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
52 uint_fast64_t z;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF64UI( uiA );
59 sig = fracF64UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x433 - exp;
63 if ( 53 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF64UI( uiA );
72 if ( sign ) goto invalid;
73 if ( shiftDist <= 0 ) {
74 if ( shiftDist < -11 ) goto invalid;
75 z = (sig | UINT64_C( 0x0010000000000000 ))<<-shiftDist;
76 } else {
77 sig |= UINT64_C( 0x0010000000000000 );
78 z = sig>>shiftDist;
79 if ( exact && (uint64_t) (sig<<(-shiftDist & 63)) ) {
80 softfloat_exceptionFlags |= softfloat_flag_inexact;
81 }
82 }
83 return z;
84 /*------------------------------------------------------------------------
85 *------------------------------------------------------------------------*/
86 invalid:
87 softfloat_raiseFlags( softfloat_flag_invalid );
88 return
89 (exp == 0x7FF) && sig ? ui64_fromNaN
90 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
91
92}
93
deps/SoftFloat-3d/source/i32_to_extF80.c deleted-65
......@@ -1,65 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43extFloat80_t i32_to_extF80( int32_t a )
44{
45 uint_fast16_t uiZ64;
46 uint_fast32_t absA;
47 bool sign;
48 int_fast8_t shiftDist;
49 union { struct extFloat80M s; extFloat80_t f; } uZ;
50
51 uiZ64 = 0;
52 absA = 0;
53 if ( a ) {
54 sign = (a < 0);
55 absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
56 shiftDist = softfloat_countLeadingZeros32( absA );
57 uiZ64 = packToExtF80UI64( sign, 0x401E - shiftDist );
58 absA <<= shiftDist;
59 }
60 uZ.s.signExp = uiZ64;
61 uZ.s.signif = (uint_fast64_t) absA<<32;
62 return uZ.f;
63
64}
65
deps/SoftFloat-3d/source/i32_to_extF80M.c deleted-78
......@@ -1,78 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void i32_to_extF80M( int32_t a, extFloat80_t *zPtr )
45{
46
47 *zPtr = i32_to_extF80( a );
48
49}
50
51#else
52
53void i32_to_extF80M( int32_t a, extFloat80_t *zPtr )
54{
55 struct extFloat80M *zSPtr;
56 uint_fast16_t uiZ64;
57 uint64_t sigZ;
58 bool sign;
59 uint32_t absA;
60 int_fast8_t shiftDist;
61
62 zSPtr = (struct extFloat80M *) zPtr;
63 uiZ64 = 0;
64 sigZ = 0;
65 if ( a ) {
66 sign = (a < 0);
67 absA = sign ? -(uint32_t) a : (uint32_t) a;
68 shiftDist = softfloat_countLeadingZeros32( absA );
69 uiZ64 = packToExtF80UI64( sign, 0x401E - shiftDist );
70 sigZ = (uint64_t) (absA<<shiftDist)<<32;
71 }
72 zSPtr->signExp = uiZ64;
73 zSPtr->signif = sigZ;
74
75}
76
77#endif
78
deps/SoftFloat-3d/source/i32_to_f128.c deleted-64
......@@ -1,64 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float128_t i32_to_f128( int32_t a )
43{
44 uint_fast64_t uiZ64;
45 bool sign;
46 uint_fast32_t absA;
47 int_fast8_t shiftDist;
48 union ui128_f128 uZ;
49
50 uiZ64 = 0;
51 if ( a ) {
52 sign = (a < 0);
53 absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
54 shiftDist = softfloat_countLeadingZeros32( absA ) + 17;
55 uiZ64 =
56 packToF128UI64(
57 sign, 0x402E - shiftDist, (uint_fast64_t) absA<<shiftDist );
58 }
59 uZ.ui.v64 = uiZ64;
60 uZ.ui.v0 = 0;
61 return uZ.f;
62
63}
64
deps/SoftFloat-3d/source/i32_to_f128M.c deleted-81
......@@ -1,81 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void i32_to_f128M( int32_t a, float128_t *zPtr )
45{
46
47 *zPtr = i32_to_f128( a );
48
49}
50
51#else
52
53void i32_to_f128M( int32_t a, float128_t *zPtr )
54{
55 uint32_t *zWPtr;
56 uint32_t uiZ96, uiZ64;
57 bool sign;
58 uint32_t absA;
59 int_fast8_t shiftDist;
60 uint64_t normAbsA;
61
62 zWPtr = (uint32_t *) zPtr;
63 uiZ96 = 0;
64 uiZ64 = 0;
65 if ( a ) {
66 sign = (a < 0);
67 absA = sign ? -(uint32_t) a : (uint32_t) a;
68 shiftDist = softfloat_countLeadingZeros32( absA ) + 17;
69 normAbsA = (uint64_t) absA<<shiftDist;
70 uiZ96 = packToF128UI96( sign, 0x402E - shiftDist, normAbsA>>32 );
71 uiZ64 = normAbsA;
72 }
73 zWPtr[indexWord( 4, 3 )] = uiZ96;
74 zWPtr[indexWord( 4, 2 )] = uiZ64;
75 zWPtr[indexWord( 4, 1 )] = 0;
76 zWPtr[indexWord( 4, 0 )] = 0;
77
78}
79
80#endif
81
deps/SoftFloat-3d/source/i32_to_f16.c deleted-71
......@@ -1,71 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float16_t i32_to_f16( int32_t a )
44{
45 bool sign;
46 uint_fast32_t absA;
47 int_fast8_t shiftDist;
48 union ui16_f16 u;
49 uint_fast16_t sig;
50
51 sign = (a < 0);
52 absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
53 shiftDist = softfloat_countLeadingZeros32( absA ) - 21;
54 if ( 0 <= shiftDist ) {
55 u.ui =
56 a ? packToF16UI(
57 sign, 0x18 - shiftDist, (uint_fast16_t) absA<<shiftDist )
58 : 0;
59 return u.f;
60 } else {
61 shiftDist += 4;
62 sig =
63 (shiftDist < 0)
64 ? absA>>(-shiftDist)
65 | ((uint32_t) (absA<<(shiftDist & 31)) != 0)
66 : (uint_fast16_t) absA<<shiftDist;
67 return softfloat_roundPackToF16( sign, 0x1C - shiftDist, sig );
68 }
69
70}
71
deps/SoftFloat-3d/source/i32_to_f32.c deleted-58
......@@ -1,58 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float32_t i32_to_f32( int32_t a )
44{
45 bool sign;
46 union ui32_f32 uZ;
47 uint_fast32_t absA;
48
49 sign = (a < 0);
50 if ( ! (a & 0x7FFFFFFF) ) {
51 uZ.ui = sign ? packToF32UI( 1, 0x9E, 0 ) : 0;
52 return uZ.f;
53 }
54 absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
55 return softfloat_normRoundPackToF32( sign, 0x9C, absA );
56
57}
58
deps/SoftFloat-3d/source/i32_to_f64.c deleted-65
......@@ -1,65 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float64_t i32_to_f64( int32_t a )
44{
45 uint_fast64_t uiZ;
46 bool sign;
47 uint_fast32_t absA;
48 int_fast8_t shiftDist;
49 union ui64_f64 uZ;
50
51 if ( ! a ) {
52 uiZ = 0;
53 } else {
54 sign = (a < 0);
55 absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
56 shiftDist = softfloat_countLeadingZeros32( absA ) + 21;
57 uiZ =
58 packToF64UI(
59 sign, 0x432 - shiftDist, (uint_fast64_t) absA<<shiftDist );
60 }
61 uZ.ui = uiZ;
62 return uZ.f;
63
64}
65
deps/SoftFloat-3d/source/i64_to_extF80.c deleted-65
......@@ -1,65 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43extFloat80_t i64_to_extF80( int64_t a )
44{
45 uint_fast16_t uiZ64;
46 uint_fast64_t absA;
47 bool sign;
48 int_fast8_t shiftDist;
49 union { struct extFloat80M s; extFloat80_t f; } uZ;
50
51 uiZ64 = 0;
52 absA = 0;
53 if ( a ) {
54 sign = (a < 0);
55 absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
56 shiftDist = softfloat_countLeadingZeros64( absA );
57 uiZ64 = packToExtF80UI64( sign, 0x403E - shiftDist );
58 absA <<= shiftDist;
59 }
60 uZ.s.signExp = uiZ64;
61 uZ.s.signif = absA;
62 return uZ.f;
63
64}
65
deps/SoftFloat-3d/source/i64_to_extF80M.c deleted-78
......@@ -1,78 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void i64_to_extF80M( int64_t a, extFloat80_t *zPtr )
45{
46
47 *zPtr = i64_to_extF80( a );
48
49}
50
51#else
52
53void i64_to_extF80M( int64_t a, extFloat80_t *zPtr )
54{
55 struct extFloat80M *zSPtr;
56 uint_fast16_t uiZ64;
57 uint64_t sigZ;
58 bool sign;
59 uint64_t absA;
60 int_fast8_t shiftDist;
61
62 zSPtr = (struct extFloat80M *) zPtr;
63 uiZ64 = 0;
64 sigZ = 0;
65 if ( a ) {
66 sign = (a < 0);
67 absA = sign ? -(uint64_t) a : (uint64_t) a;
68 shiftDist = softfloat_countLeadingZeros64( absA );
69 uiZ64 = packToExtF80UI64( sign, 0x403E - shiftDist );
70 sigZ = absA<<shiftDist;
71 }
72 zSPtr->signExp = uiZ64;
73 zSPtr->signif = sigZ;
74
75}
76
77#endif
78
deps/SoftFloat-3d/source/i64_to_f128.c deleted-72
......@@ -1,72 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float128_t i64_to_f128( int64_t a )
43{
44 uint_fast64_t uiZ64, uiZ0;
45 bool sign;
46 uint_fast64_t absA;
47 int_fast8_t shiftDist;
48 struct uint128 zSig;
49 union ui128_f128 uZ;
50
51 if ( ! a ) {
52 uiZ64 = 0;
53 uiZ0 = 0;
54 } else {
55 sign = (a < 0);
56 absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
57 shiftDist = softfloat_countLeadingZeros64( absA ) + 49;
58 if ( 64 <= shiftDist ) {
59 zSig.v64 = absA<<(shiftDist - 64);
60 zSig.v0 = 0;
61 } else {
62 zSig = softfloat_shortShiftLeft128( 0, absA, shiftDist );
63 }
64 uiZ64 = packToF128UI64( sign, 0x406E - shiftDist, zSig.v64 );
65 uiZ0 = zSig.v0;
66 }
67 uZ.ui.v64 = uiZ64;
68 uZ.ui.v0 = uiZ0;
69 return uZ.f;
70
71}
72
deps/SoftFloat-3d/source/i64_to_f128M.c deleted-92
......@@ -1,92 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void i64_to_f128M( int64_t a, float128_t *zPtr )
45{
46
47 *zPtr = i64_to_f128( a );
48
49}
50
51#else
52
53void i64_to_f128M( int64_t a, float128_t *zPtr )
54{
55 uint32_t *zWPtr;
56 uint32_t uiZ96, uiZ64;
57 bool sign;
58 uint64_t absA;
59 uint_fast8_t shiftDist;
60 uint32_t *ptr;
61
62 zWPtr = (uint32_t *) zPtr;
63 uiZ96 = 0;
64 uiZ64 = 0;
65 zWPtr[indexWord( 4, 1 )] = 0;
66 zWPtr[indexWord( 4, 0 )] = 0;
67 if ( a ) {
68 sign = (a < 0);
69 absA = sign ? -(uint64_t) a : (uint64_t) a;
70 shiftDist = softfloat_countLeadingZeros64( absA ) + 17;
71 if ( shiftDist < 32 ) {
72 ptr = zWPtr + indexMultiwordHi( 4, 3 );
73 ptr[indexWord( 3, 2 )] = 0;
74 ptr[indexWord( 3, 1 )] = absA>>32;
75 ptr[indexWord( 3, 0 )] = absA;
76 softfloat_shortShiftLeft96M( ptr, shiftDist, ptr );
77 ptr[indexWordHi( 3 )] =
78 packToF128UI96(
79 sign, 0x404E - shiftDist, ptr[indexWordHi( 3 )] );
80 return;
81 }
82 absA <<= shiftDist - 32;
83 uiZ96 = packToF128UI96( sign, 0x404E - shiftDist, absA>>32 );
84 uiZ64 = absA;
85 }
86 zWPtr[indexWord( 4, 3 )] = uiZ96;
87 zWPtr[indexWord( 4, 2 )] = uiZ64;
88
89}
90
91#endif
92
deps/SoftFloat-3d/source/i64_to_f16.c deleted-70
......@@ -1,70 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float16_t i64_to_f16( int64_t a )
44{
45 bool sign;
46 uint_fast64_t absA;
47 int_fast8_t shiftDist;
48 union ui16_f16 u;
49 uint_fast16_t sig;
50
51 sign = (a < 0);
52 absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
53 shiftDist = softfloat_countLeadingZeros64( absA ) - 53;
54 if ( 0 <= shiftDist ) {
55 u.ui =
56 a ? packToF16UI(
57 sign, 0x18 - shiftDist, (uint_fast16_t) absA<<shiftDist )
58 : 0;
59 return u.f;
60 } else {
61 shiftDist += 4;
62 sig =
63 (shiftDist < 0)
64 ? softfloat_shortShiftRightJam64( absA, -shiftDist )
65 : (uint_fast16_t) absA<<shiftDist;
66 return softfloat_roundPackToF16( sign, 0x1C - shiftDist, sig );
67 }
68
69}
70
deps/SoftFloat-3d/source/i64_to_f32.c deleted-70
......@@ -1,70 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float32_t i64_to_f32( int64_t a )
44{
45 bool sign;
46 uint_fast64_t absA;
47 int_fast8_t shiftDist;
48 union ui32_f32 u;
49 uint_fast32_t sig;
50
51 sign = (a < 0);
52 absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
53 shiftDist = softfloat_countLeadingZeros64( absA ) - 40;
54 if ( 0 <= shiftDist ) {
55 u.ui =
56 a ? packToF32UI(
57 sign, 0x95 - shiftDist, (uint_fast32_t) absA<<shiftDist )
58 : 0;
59 return u.f;
60 } else {
61 shiftDist += 7;
62 sig =
63 (shiftDist < 0)
64 ? softfloat_shortShiftRightJam64( absA, -shiftDist )
65 : (uint_fast32_t) absA<<shiftDist;
66 return softfloat_roundPackToF32( sign, 0x9C - shiftDist, sig );
67 }
68
69}
70
deps/SoftFloat-3d/source/i64_to_f64.c deleted-58
......@@ -1,58 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float64_t i64_to_f64( int64_t a )
44{
45 bool sign;
46 union ui64_f64 uZ;
47 uint_fast64_t absA;
48
49 sign = (a < 0);
50 if ( ! (a & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) {
51 uZ.ui = sign ? packToF64UI( 1, 0x43E, 0 ) : 0;
52 return uZ.f;
53 }
54 absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
55 return softfloat_normRoundPackToF64( sign, 0x43C, absA );
56
57}
58
deps/SoftFloat-3d/source/include/internals.h deleted-278
......@@ -1,278 +0,0 @@
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#ifndef internals_h
38#define internals_h 1
39
40#include <stdbool.h>
41#include <stdint.h>
42#include "primitives.h"
43#include "softfloat_types.h"
44
45union ui16_f16 { uint16_t ui; float16_t f; };
46union ui32_f32 { uint32_t ui; float32_t f; };
47union ui64_f64 { uint64_t ui; float64_t f; };
48
49#ifdef SOFTFLOAT_FAST_INT64
50union extF80M_extF80 { struct extFloat80M fM; extFloat80_t f; };
51union ui128_f128 { struct uint128 ui; float128_t f; };
52#endif
53
54enum {
55 softfloat_mulAdd_subC = 1,
56 softfloat_mulAdd_subProd = 2
57};
58
59/*----------------------------------------------------------------------------
60*----------------------------------------------------------------------------*/
61uint_fast32_t softfloat_roundToUI32( bool, uint_fast64_t, uint_fast8_t, bool );
62
63#ifdef SOFTFLOAT_FAST_INT64
64uint_fast64_t
65 softfloat_roundToUI64(
66 bool, uint_fast64_t, uint_fast64_t, uint_fast8_t, bool );
67#else
68uint_fast64_t softfloat_roundMToUI64( bool, uint32_t *, uint_fast8_t, bool );
69#endif
70
71int_fast32_t softfloat_roundToI32( bool, uint_fast64_t, uint_fast8_t, bool );
72
73#ifdef SOFTFLOAT_FAST_INT64
74int_fast64_t
75 softfloat_roundToI64(
76 bool, uint_fast64_t, uint_fast64_t, uint_fast8_t, bool );
77#else
78int_fast64_t softfloat_roundMToI64( bool, uint32_t *, uint_fast8_t, bool );
79#endif
80
81/*----------------------------------------------------------------------------
82*----------------------------------------------------------------------------*/
83#define signF16UI( a ) ((bool) ((uint16_t) (a)>>15))
84#define expF16UI( a ) ((int_fast8_t) ((a)>>10) & 0x1F)
85#define fracF16UI( a ) ((a) & 0x03FF)
86#define packToF16UI( sign, exp, sig ) (((uint16_t) (sign)<<15) + ((uint16_t) (exp)<<10) + (sig))
87
88#define isNaNF16UI( a ) (((~(a) & 0x7C00) == 0) && ((a) & 0x03FF))
89
90struct exp8_sig16 { int_fast8_t exp; uint_fast16_t sig; };
91struct exp8_sig16 softfloat_normSubnormalF16Sig( uint_fast16_t );
92
93float16_t softfloat_roundPackToF16( bool, int_fast16_t, uint_fast16_t );
94float16_t softfloat_normRoundPackToF16( bool, int_fast16_t, uint_fast16_t );
95
96float16_t softfloat_addMagsF16( uint_fast16_t, uint_fast16_t );
97float16_t softfloat_subMagsF16( uint_fast16_t, uint_fast16_t );
98float16_t
99 softfloat_mulAddF16(
100 uint_fast16_t, uint_fast16_t, uint_fast16_t, uint_fast8_t );
101
102/*----------------------------------------------------------------------------
103*----------------------------------------------------------------------------*/
104#define signF32UI( a ) ((bool) ((uint32_t) (a)>>31))
105#define expF32UI( a ) ((int_fast16_t) ((a)>>23) & 0xFF)
106#define fracF32UI( a ) ((a) & 0x007FFFFF)
107#define packToF32UI( sign, exp, sig ) (((uint32_t) (sign)<<31) + ((uint32_t) (exp)<<23) + (sig))
108
109#define isNaNF32UI( a ) (((~(a) & 0x7F800000) == 0) && ((a) & 0x007FFFFF))
110
111struct exp16_sig32 { int_fast16_t exp; uint_fast32_t sig; };
112struct exp16_sig32 softfloat_normSubnormalF32Sig( uint_fast32_t );
113
114float32_t softfloat_roundPackToF32( bool, int_fast16_t, uint_fast32_t );
115float32_t softfloat_normRoundPackToF32( bool, int_fast16_t, uint_fast32_t );
116
117float32_t softfloat_addMagsF32( uint_fast32_t, uint_fast32_t );
118float32_t softfloat_subMagsF32( uint_fast32_t, uint_fast32_t );
119float32_t
120 softfloat_mulAddF32(
121 uint_fast32_t, uint_fast32_t, uint_fast32_t, uint_fast8_t );
122
123/*----------------------------------------------------------------------------
124*----------------------------------------------------------------------------*/
125#define signF64UI( a ) ((bool) ((uint64_t) (a)>>63))
126#define expF64UI( a ) ((int_fast16_t) ((a)>>52) & 0x7FF)
127#define fracF64UI( a ) ((a) & UINT64_C( 0x000FFFFFFFFFFFFF ))
128#define packToF64UI( sign, exp, sig ) ((uint64_t) (((uint_fast64_t) (sign)<<63) + ((uint_fast64_t) (exp)<<52) + (sig)))
129
130#define isNaNF64UI( a ) (((~(a) & UINT64_C( 0x7FF0000000000000 )) == 0) && ((a) & UINT64_C( 0x000FFFFFFFFFFFFF )))
131
132struct exp16_sig64 { int_fast16_t exp; uint_fast64_t sig; };
133struct exp16_sig64 softfloat_normSubnormalF64Sig( uint_fast64_t );
134
135float64_t softfloat_roundPackToF64( bool, int_fast16_t, uint_fast64_t );
136float64_t softfloat_normRoundPackToF64( bool, int_fast16_t, uint_fast64_t );
137
138float64_t softfloat_addMagsF64( uint_fast64_t, uint_fast64_t, bool );
139float64_t softfloat_subMagsF64( uint_fast64_t, uint_fast64_t, bool );
140float64_t
141 softfloat_mulAddF64(
142 uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast8_t );
143
144/*----------------------------------------------------------------------------
145*----------------------------------------------------------------------------*/
146#define signExtF80UI64( a64 ) ((bool) ((uint16_t) (a64)>>15))
147#define expExtF80UI64( a64 ) ((a64) & 0x7FFF)
148#define packToExtF80UI64( sign, exp ) ((uint_fast16_t) (sign)<<15 | (exp))
149
150#define isNaNExtF80UI( a64, a0 ) ((((a64) & 0x7FFF) == 0x7FFF) && ((a0) & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
151
152#ifdef SOFTFLOAT_FAST_INT64
153
154/*----------------------------------------------------------------------------
155*----------------------------------------------------------------------------*/
156
157struct exp32_sig64 { int_fast32_t exp; uint64_t sig; };
158struct exp32_sig64 softfloat_normSubnormalExtF80Sig( uint_fast64_t );
159
160extFloat80_t
161 softfloat_roundPackToExtF80(
162 bool, int_fast32_t, uint_fast64_t, uint_fast64_t, uint_fast8_t );
163extFloat80_t
164 softfloat_normRoundPackToExtF80(
165 bool, int_fast32_t, uint_fast64_t, uint_fast64_t, uint_fast8_t );
166
167extFloat80_t
168 softfloat_addMagsExtF80(
169 uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
170extFloat80_t
171 softfloat_subMagsExtF80(
172 uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
173
174/*----------------------------------------------------------------------------
175*----------------------------------------------------------------------------*/
176#define signF128UI64( a64 ) ((bool) ((uint64_t) (a64)>>63))
177#define expF128UI64( a64 ) ((int_fast32_t) ((a64)>>48) & 0x7FFF)
178#define fracF128UI64( a64 ) ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))
179#define packToF128UI64( sign, exp, sig64 ) (((uint_fast64_t) (sign)<<63) + ((uint_fast64_t) (exp)<<48) + (sig64))
180
181#define isNaNF128UI( a64, a0 ) (((~(a64) & UINT64_C( 0x7FFF000000000000 )) == 0) && (a0 || ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))))
182
183struct exp32_sig128 { int_fast32_t exp; struct uint128 sig; };
184struct exp32_sig128
185 softfloat_normSubnormalF128Sig( uint_fast64_t, uint_fast64_t );
186
187float128_t
188 softfloat_roundPackToF128(
189 bool, int_fast32_t, uint_fast64_t, uint_fast64_t, uint_fast64_t );
190float128_t
191 softfloat_normRoundPackToF128(
192 bool, int_fast32_t, uint_fast64_t, uint_fast64_t );
193
194float128_t
195 softfloat_addMagsF128(
196 uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
197float128_t
198 softfloat_subMagsF128(
199 uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
200float128_t
201 softfloat_mulAddF128(
202 uint_fast64_t,
203 uint_fast64_t,
204 uint_fast64_t,
205 uint_fast64_t,
206 uint_fast64_t,
207 uint_fast64_t,
208 uint_fast8_t
209 );
210
211#else
212
213/*----------------------------------------------------------------------------
214*----------------------------------------------------------------------------*/
215
216bool
217 softfloat_tryPropagateNaNExtF80M(
218 const struct extFloat80M *,
219 const struct extFloat80M *,
220 struct extFloat80M *
221 );
222void softfloat_invalidExtF80M( struct extFloat80M * );
223
224int softfloat_normExtF80SigM( uint64_t * );
225
226void
227 softfloat_roundPackMToExtF80M(
228 bool, int32_t, uint32_t *, uint_fast8_t, struct extFloat80M * );
229void
230 softfloat_normRoundPackMToExtF80M(
231 bool, int32_t, uint32_t *, uint_fast8_t, struct extFloat80M * );
232
233void
234 softfloat_addExtF80M(
235 const struct extFloat80M *,
236 const struct extFloat80M *,
237 struct extFloat80M *,
238 bool
239 );
240
241int
242 softfloat_compareNonnormExtF80M(
243 const struct extFloat80M *, const struct extFloat80M * );
244
245/*----------------------------------------------------------------------------
246*----------------------------------------------------------------------------*/
247#define signF128UI96( a96 ) ((bool) ((uint32_t) (a96)>>31))
248#define expF128UI96( a96 ) ((int32_t) ((a96)>>16) & 0x7FFF)
249#define fracF128UI96( a96 ) ((a96) & 0x0000FFFF)
250#define packToF128UI96( sign, exp, sig96 ) (((uint32_t) (sign)<<31) + ((uint32_t) (exp)<<16) + (sig96))
251
252bool softfloat_isNaNF128M( const uint32_t * );
253
254bool
255 softfloat_tryPropagateNaNF128M(
256 const uint32_t *, const uint32_t *, uint32_t * );
257void softfloat_invalidF128M( uint32_t * );
258
259int softfloat_shiftNormSigF128M( const uint32_t *, uint_fast8_t, uint32_t * );
260
261void softfloat_roundPackMToF128M( bool, int32_t, uint32_t *, uint32_t * );
262void softfloat_normRoundPackMToF128M( bool, int32_t, uint32_t *, uint32_t * );
263
264void
265 softfloat_addF128M( const uint32_t *, const uint32_t *, uint32_t *, bool );
266void
267 softfloat_mulAddF128M(
268 const uint32_t *,
269 const uint32_t *,
270 const uint32_t *,
271 uint32_t *,
272 uint_fast8_t
273 );
274
275#endif
276
277#endif
278
deps/SoftFloat-3d/source/include/primitiveTypes.h deleted-85
......@@ -1,85 +0,0 @@
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#ifndef primitiveTypes_h
38#define primitiveTypes_h 1
39
40#include <stdint.h>
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44#ifdef LITTLEENDIAN
45struct uint128 { uint64_t v0, v64; };
46struct uint64_extra { uint64_t extra, v; };
47struct uint128_extra { uint64_t extra; struct uint128 v; };
48#else
49struct uint128 { uint64_t v64, v0; };
50struct uint64_extra { uint64_t v, extra; };
51struct uint128_extra { struct uint128 v; uint64_t extra; };
52#endif
53
54#endif
55
56/*----------------------------------------------------------------------------
57| These macros are used to isolate the differences in word order between big-
58| endian and little-endian platforms.
59*----------------------------------------------------------------------------*/
60#ifdef LITTLEENDIAN
61#define wordIncr 1
62#define indexWord( total, n ) (n)
63#define indexWordHi( total ) ((total) - 1)
64#define indexWordLo( total ) 0
65#define indexMultiword( total, m, n ) (n)
66#define indexMultiwordHi( total, n ) ((total) - (n))
67#define indexMultiwordLo( total, n ) 0
68#define indexMultiwordHiBut( total, n ) (n)
69#define indexMultiwordLoBut( total, n ) 0
70#define INIT_UINTM4( v3, v2, v1, v0 ) { v0, v1, v2, v3 }
71#else
72#define wordIncr -1
73#define indexWord( total, n ) ((total) - 1 - (n))
74#define indexWordHi( total ) 0
75#define indexWordLo( total ) ((total) - 1)
76#define indexMultiword( total, m, n ) ((total) - 1 - (m))
77#define indexMultiwordHi( total, n ) 0
78#define indexMultiwordLo( total, n ) ((total) - (n))
79#define indexMultiwordHiBut( total, n ) 0
80#define indexMultiwordLoBut( total, n ) (n)
81#define INIT_UINTM4( v3, v2, v1, v0 ) { v3, v2, v1, v0 }
82#endif
83
84#endif
85
deps/SoftFloat-3d/source/include/primitives.h deleted-1160
......@@ -1,1160 +0,0 @@
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#ifndef primitives_h
38#define primitives_h 1
39
40#include <stdbool.h>
41#include <stdint.h>
42#include "primitiveTypes.h"
43
44#ifndef softfloat_shortShiftRightJam64
45/*----------------------------------------------------------------------------
46| Shifts 'a' right by the number of bits given in 'dist', which must be in
47| the range 1 to 63. If any nonzero bits are shifted off, they are "jammed"
48| into the least-significant bit of the shifted value by setting the least-
49| significant bit to 1. This shifted-and-jammed value is returned.
50*----------------------------------------------------------------------------*/
51#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
52INLINE
53uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist )
54 { return a>>dist | ((a & (((uint_fast64_t) 1<<dist) - 1)) != 0); }
55#else
56uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist );
57#endif
58#endif
59
60#ifndef softfloat_shiftRightJam32
61/*----------------------------------------------------------------------------
62| Shifts 'a' right by the number of bits given in 'dist', which must not
63| be zero. If any nonzero bits are shifted off, they are "jammed" into the
64| least-significant bit of the shifted value by setting the least-significant
65| bit to 1. This shifted-and-jammed value is returned.
66| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
67| greater than 32, the result will be either 0 or 1, depending on whether 'a'
68| is zero or nonzero.
69*----------------------------------------------------------------------------*/
70#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
71INLINE uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist )
72{
73 return
74 (dist < 31) ? a>>dist | ((uint32_t) (a<<(-dist & 31)) != 0) : (a != 0);
75}
76#else
77uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist );
78#endif
79#endif
80
81#ifndef softfloat_shiftRightJam64
82/*----------------------------------------------------------------------------
83| Shifts 'a' right by the number of bits given in 'dist', which must not
84| be zero. If any nonzero bits are shifted off, they are "jammed" into the
85| least-significant bit of the shifted value by setting the least-significant
86| bit to 1. This shifted-and-jammed value is returned.
87| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
88| greater than 64, the result will be either 0 or 1, depending on whether 'a'
89| is zero or nonzero.
90*----------------------------------------------------------------------------*/
91#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
92INLINE uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist )
93{
94 return
95 (dist < 63) ? a>>dist | ((uint64_t) (a<<(-dist & 63)) != 0) : (a != 0);
96}
97#else
98uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist );
99#endif
100#endif
101
102/*----------------------------------------------------------------------------
103| A constant table that translates an 8-bit unsigned integer (the array index)
104| into the number of leading 0 bits before the most-significant 1 of that
105| integer. For integer zero (index 0), the corresponding table element is 8.
106*----------------------------------------------------------------------------*/
107extern const uint_least8_t softfloat_countLeadingZeros8[256];
108
109#ifndef softfloat_countLeadingZeros16
110/*----------------------------------------------------------------------------
111| Returns the number of leading 0 bits before the most-significant 1 bit of
112| 'a'. If 'a' is zero, 16 is returned.
113*----------------------------------------------------------------------------*/
114#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
115INLINE uint_fast8_t softfloat_countLeadingZeros16( uint16_t a )
116{
117 uint_fast8_t count = 8;
118 if ( 0x100 <= a ) {
119 count = 0;
120 a >>= 8;
121 }
122 count += softfloat_countLeadingZeros8[a];
123 return count;
124}
125#else
126uint_fast8_t softfloat_countLeadingZeros16( uint16_t a );
127#endif
128#endif
129
130#ifndef softfloat_countLeadingZeros32
131/*----------------------------------------------------------------------------
132| Returns the number of leading 0 bits before the most-significant 1 bit of
133| 'a'. If 'a' is zero, 32 is returned.
134*----------------------------------------------------------------------------*/
135#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
136INLINE uint_fast8_t softfloat_countLeadingZeros32( uint32_t a )
137{
138 uint_fast8_t count = 0;
139 if ( a < 0x10000 ) {
140 count = 16;
141 a <<= 16;
142 }
143 if ( a < 0x1000000 ) {
144 count += 8;
145 a <<= 8;
146 }
147 count += softfloat_countLeadingZeros8[a>>24];
148 return count;
149}
150#else
151uint_fast8_t softfloat_countLeadingZeros32( uint32_t a );
152#endif
153#endif
154
155#ifndef softfloat_countLeadingZeros64
156/*----------------------------------------------------------------------------
157| Returns the number of leading 0 bits before the most-significant 1 bit of
158| 'a'. If 'a' is zero, 64 is returned.
159*----------------------------------------------------------------------------*/
160uint_fast8_t softfloat_countLeadingZeros64( uint64_t a );
161#endif
162
163extern const uint16_t softfloat_approxRecip_1k0s[16];
164extern const uint16_t softfloat_approxRecip_1k1s[16];
165
166#ifndef softfloat_approxRecip32_1
167/*----------------------------------------------------------------------------
168| Returns an approximation to the reciprocal of the number represented by 'a',
169| where 'a' is interpreted as an unsigned fixed-point number with one integer
170| bit and 31 fraction bits. The 'a' input must be "normalized", meaning that
171| its most-significant bit (bit 31) must be 1. Thus, if A is the value of
172| the fixed-point interpretation of 'a', then 1 <= A < 2. The returned value
173| is interpreted as a pure unsigned fraction, having no integer bits and 32
174| fraction bits. The approximation returned is never greater than the true
175| reciprocal 1/A, and it differs from the true reciprocal by at most 2.006 ulp
176| (units in the last place).
177*----------------------------------------------------------------------------*/
178#ifdef SOFTFLOAT_FAST_DIV64TO32
179#define softfloat_approxRecip32_1( a ) ((uint32_t) (UINT64_C( 0x7FFFFFFFFFFFFFFF ) / (uint32_t) (a)))
180#else
181uint32_t softfloat_approxRecip32_1( uint32_t a );
182#endif
183#endif
184
185extern const uint16_t softfloat_approxRecipSqrt_1k0s[16];
186extern const uint16_t softfloat_approxRecipSqrt_1k1s[16];
187
188#ifndef softfloat_approxRecipSqrt32_1
189/*----------------------------------------------------------------------------
190| Returns an approximation to the reciprocal of the square root of the number
191| represented by 'a', where 'a' is interpreted as an unsigned fixed-point
192| number either with one integer bit and 31 fraction bits or with two integer
193| bits and 30 fraction bits. The format of 'a' is determined by 'oddExpA',
194| which must be either 0 or 1. If 'oddExpA' is 1, 'a' is interpreted as
195| having one integer bit, and if 'oddExpA' is 0, 'a' is interpreted as having
196| two integer bits. The 'a' input must be "normalized", meaning that its
197| most-significant bit (bit 31) must be 1. Thus, if A is the value of the
198| fixed-point interpretation of 'a', it follows that 1 <= A < 2 when 'oddExpA'
199| is 1, and 2 <= A < 4 when 'oddExpA' is 0.
200| The returned value is interpreted as a pure unsigned fraction, having
201| no integer bits and 32 fraction bits. The approximation returned is never
202| greater than the true reciprocal 1/sqrt(A), and it differs from the true
203| reciprocal by at most 2.06 ulp (units in the last place). The approximation
204| returned is also always within the range 0.5 to 1; thus, the most-
205| significant bit of the result is always set.
206*----------------------------------------------------------------------------*/
207uint32_t softfloat_approxRecipSqrt32_1( unsigned int oddExpA, uint32_t a );
208#endif
209
210#ifdef SOFTFLOAT_FAST_INT64
211
212/*----------------------------------------------------------------------------
213| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is
214| defined.
215*----------------------------------------------------------------------------*/
216
217#ifndef softfloat_eq128
218/*----------------------------------------------------------------------------
219| Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
220| and 'a0' is equal to the 128-bit unsigned integer formed by concatenating
221| 'b64' and 'b0'.
222*----------------------------------------------------------------------------*/
223#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
224INLINE
225bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
226 { return (a64 == b64) && (a0 == b0); }
227#else
228bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
229#endif
230#endif
231
232#ifndef softfloat_le128
233/*----------------------------------------------------------------------------
234| Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
235| and 'a0' is less than or equal to the 128-bit unsigned integer formed by
236| concatenating 'b64' and 'b0'.
237*----------------------------------------------------------------------------*/
238#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
239INLINE
240bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
241 { return (a64 < b64) || ((a64 == b64) && (a0 <= b0)); }
242#else
243bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
244#endif
245#endif
246
247#ifndef softfloat_lt128
248/*----------------------------------------------------------------------------
249| Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
250| and 'a0' is less than the 128-bit unsigned integer formed by concatenating
251| 'b64' and 'b0'.
252*----------------------------------------------------------------------------*/
253#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
254INLINE
255bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
256 { return (a64 < b64) || ((a64 == b64) && (a0 < b0)); }
257#else
258bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
259#endif
260#endif
261
262#ifndef softfloat_shortShiftLeft128
263/*----------------------------------------------------------------------------
264| Shifts the 128 bits formed by concatenating 'a64' and 'a0' left by the
265| number of bits given in 'dist', which must be in the range 1 to 63.
266*----------------------------------------------------------------------------*/
267#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
268INLINE
269struct uint128
270 softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
271{
272 struct uint128 z;
273 z.v64 = a64<<dist | a0>>(-dist & 63);
274 z.v0 = a0<<dist;
275 return z;
276}
277#else
278struct uint128
279 softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist );
280#endif
281#endif
282
283#ifndef softfloat_shortShiftRight128
284/*----------------------------------------------------------------------------
285| Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
286| number of bits given in 'dist', which must be in the range 1 to 63.
287*----------------------------------------------------------------------------*/
288#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
289INLINE
290struct uint128
291 softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
292{
293 struct uint128 z;
294 z.v64 = a64>>dist;
295 z.v0 = a64<<(-dist & 63) | a0>>dist;
296 return z;
297}
298#else
299struct uint128
300 softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t dist );
301#endif
302#endif
303
304#ifndef softfloat_shortShiftRightJam64Extra
305/*----------------------------------------------------------------------------
306| This function is the same as 'softfloat_shiftRightJam64Extra' (below),
307| except that 'dist' must be in the range 1 to 63.
308*----------------------------------------------------------------------------*/
309#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
310INLINE
311struct uint64_extra
312 softfloat_shortShiftRightJam64Extra(
313 uint64_t a, uint64_t extra, uint_fast8_t dist )
314{
315 struct uint64_extra z;
316 z.v = a>>dist;
317 z.extra = a<<(-dist & 63) | (extra != 0);
318 return z;
319}
320#else
321struct uint64_extra
322 softfloat_shortShiftRightJam64Extra(
323 uint64_t a, uint64_t extra, uint_fast8_t dist );
324#endif
325#endif
326
327#ifndef softfloat_shortShiftRightJam128
328/*----------------------------------------------------------------------------
329| Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
330| number of bits given in 'dist', which must be in the range 1 to 63. If any
331| nonzero bits are shifted off, they are "jammed" into the least-significant
332| bit of the shifted value by setting the least-significant bit to 1. This
333| shifted-and-jammed value is returned.
334*----------------------------------------------------------------------------*/
335#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
336INLINE
337struct uint128
338 softfloat_shortShiftRightJam128(
339 uint64_t a64, uint64_t a0, uint_fast8_t dist )
340{
341 uint_fast8_t negDist = -dist;
342 struct uint128 z;
343 z.v64 = a64>>dist;
344 z.v0 =
345 a64<<(negDist & 63) | a0>>dist
346 | ((uint64_t) (a0<<(negDist & 63)) != 0);
347 return z;
348}
349#else
350struct uint128
351 softfloat_shortShiftRightJam128(
352 uint64_t a64, uint64_t a0, uint_fast8_t dist );
353#endif
354#endif
355
356#ifndef softfloat_shortShiftRightJam128Extra
357/*----------------------------------------------------------------------------
358| This function is the same as 'softfloat_shiftRightJam128Extra' (below),
359| except that 'dist' must be in the range 1 to 63.
360*----------------------------------------------------------------------------*/
361#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
362INLINE
363struct uint128_extra
364 softfloat_shortShiftRightJam128Extra(
365 uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist )
366{
367 uint_fast8_t negDist = -dist;
368 struct uint128_extra z;
369 z.v.v64 = a64>>dist;
370 z.v.v0 = a64<<(negDist & 63) | a0>>dist;
371 z.extra = a0<<(negDist & 63) | (extra != 0);
372 return z;
373}
374#else
375struct uint128_extra
376 softfloat_shortShiftRightJam128Extra(
377 uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist );
378#endif
379#endif
380
381#ifndef softfloat_shiftRightJam64Extra
382/*----------------------------------------------------------------------------
383| Shifts the 128 bits formed by concatenating 'a' and 'extra' right by 64
384| _plus_ the number of bits given in 'dist', which must not be zero. This
385| shifted value is at most 64 nonzero bits and is returned in the 'v' field
386| of the 'struct uint64_extra' result. The 64-bit 'extra' field of the result
387| contains a value formed as follows from the bits that were shifted off: The
388| _last_ bit shifted off is the most-significant bit of the 'extra' field, and
389| the other 63 bits of the 'extra' field are all zero if and only if _all_but_
390| _the_last_ bits shifted off were all zero.
391| (This function makes more sense if 'a' and 'extra' are considered to form
392| an unsigned fixed-point number with binary point between 'a' and 'extra'.
393| This fixed-point value is shifted right by the number of bits given in
394| 'dist', and the integer part of this shifted value is returned in the 'v'
395| field of the result. The fractional part of the shifted value is modified
396| as described above and returned in the 'extra' field of the result.)
397*----------------------------------------------------------------------------*/
398#if defined INLINE_LEVEL && (4 <= INLINE_LEVEL)
399INLINE
400struct uint64_extra
401 softfloat_shiftRightJam64Extra(
402 uint64_t a, uint64_t extra, uint_fast32_t dist )
403{
404 struct uint64_extra z;
405 if ( dist < 64 ) {
406 z.v = a>>dist;
407 z.extra = a<<(-dist & 63);
408 } else {
409 z.v = 0;
410 z.extra = (dist == 64) ? a : (a != 0);
411 }
412 z.extra |= (extra != 0);
413 return z;
414}
415#else
416struct uint64_extra
417 softfloat_shiftRightJam64Extra(
418 uint64_t a, uint64_t extra, uint_fast32_t dist );
419#endif
420#endif
421
422#ifndef softfloat_shiftRightJam128
423/*----------------------------------------------------------------------------
424| Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
425| number of bits given in 'dist', which must not be zero. If any nonzero bits
426| are shifted off, they are "jammed" into the least-significant bit of the
427| shifted value by setting the least-significant bit to 1. This shifted-and-
428| jammed value is returned.
429| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
430| greater than 128, the result will be either 0 or 1, depending on whether the
431| original 128 bits are all zeros.
432*----------------------------------------------------------------------------*/
433struct uint128
434 softfloat_shiftRightJam128( uint64_t a64, uint64_t a0, uint_fast32_t dist );
435#endif
436
437#ifndef softfloat_shiftRightJam128Extra
438/*----------------------------------------------------------------------------
439| Shifts the 192 bits formed by concatenating 'a64', 'a0', and 'extra' right
440| by 64 _plus_ the number of bits given in 'dist', which must not be zero.
441| This shifted value is at most 128 nonzero bits and is returned in the 'v'
442| field of the 'struct uint128_extra' result. The 64-bit 'extra' field of the
443| result contains a value formed as follows from the bits that were shifted
444| off: The _last_ bit shifted off is the most-significant bit of the 'extra'
445| field, and the other 63 bits of the 'extra' field are all zero if and only
446| if _all_but_the_last_ bits shifted off were all zero.
447| (This function makes more sense if 'a64', 'a0', and 'extra' are considered
448| to form an unsigned fixed-point number with binary point between 'a0' and
449| 'extra'. This fixed-point value is shifted right by the number of bits
450| given in 'dist', and the integer part of this shifted value is returned
451| in the 'v' field of the result. The fractional part of the shifted value
452| is modified as described above and returned in the 'extra' field of the
453| result.)
454*----------------------------------------------------------------------------*/
455struct uint128_extra
456 softfloat_shiftRightJam128Extra(
457 uint64_t a64, uint64_t a0, uint64_t extra, uint_fast32_t dist );
458#endif
459
460#ifndef softfloat_shiftRightJam256M
461/*----------------------------------------------------------------------------
462| Shifts the 256-bit unsigned integer pointed to by 'aPtr' right by the number
463| of bits given in 'dist', which must not be zero. If any nonzero bits are
464| shifted off, they are "jammed" into the least-significant bit of the shifted
465| value by setting the least-significant bit to 1. This shifted-and-jammed
466| value is stored at the location pointed to by 'zPtr'. Each of 'aPtr' and
467| 'zPtr' points to an array of four 64-bit elements that concatenate in the
468| platform's normal endian order to form a 256-bit integer.
469| The value of 'dist' can be arbitrarily large. In particular, if 'dist'
470| is greater than 256, the stored result will be either 0 or 1, depending on
471| whether the original 256 bits are all zeros.
472*----------------------------------------------------------------------------*/
473void
474 softfloat_shiftRightJam256M(
475 const uint64_t *aPtr, uint_fast32_t dist, uint64_t *zPtr );
476#endif
477
478#ifndef softfloat_add128
479/*----------------------------------------------------------------------------
480| Returns the sum of the 128-bit integer formed by concatenating 'a64' and
481| 'a0' and the 128-bit integer formed by concatenating 'b64' and 'b0'. The
482| addition is modulo 2^128, so any carry out is lost.
483*----------------------------------------------------------------------------*/
484#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
485INLINE
486struct uint128
487 softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
488{
489 struct uint128 z;
490 z.v0 = a0 + b0;
491 z.v64 = a64 + b64 + (z.v0 < a0);
492 return z;
493}
494#else
495struct uint128
496 softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
497#endif
498#endif
499
500#ifndef softfloat_add256M
501/*----------------------------------------------------------------------------
502| Adds the two 256-bit integers pointed to by 'aPtr' and 'bPtr'. The addition
503| is modulo 2^256, so any carry out is lost. The sum is stored at the
504| location pointed to by 'zPtr'. Each of 'aPtr', 'bPtr', and 'zPtr' points to
505| an array of four 64-bit elements that concatenate in the platform's normal
506| endian order to form a 256-bit integer.
507*----------------------------------------------------------------------------*/
508void
509 softfloat_add256M(
510 const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr );
511#endif
512
513#ifndef softfloat_sub128
514/*----------------------------------------------------------------------------
515| Returns the difference of the 128-bit integer formed by concatenating 'a64'
516| and 'a0' and the 128-bit integer formed by concatenating 'b64' and 'b0'.
517| The subtraction is modulo 2^128, so any borrow out (carry out) is lost.
518*----------------------------------------------------------------------------*/
519#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
520INLINE
521struct uint128
522 softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
523{
524 struct uint128 z;
525 z.v0 = a0 - b0;
526 z.v64 = a64 - b64;
527 z.v64 -= (a0 < b0);
528 return z;
529}
530#else
531struct uint128
532 softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
533#endif
534#endif
535
536#ifndef softfloat_sub256M
537/*----------------------------------------------------------------------------
538| Subtracts the 256-bit integer pointed to by 'bPtr' from the 256-bit integer
539| pointed to by 'aPtr'. The addition is modulo 2^256, so any borrow out
540| (carry out) is lost. The difference is stored at the location pointed to
541| by 'zPtr'. Each of 'aPtr', 'bPtr', and 'zPtr' points to an array of four
542| 64-bit elements that concatenate in the platform's normal endian order to
543| form a 256-bit integer.
544*----------------------------------------------------------------------------*/
545void
546 softfloat_sub256M(
547 const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr );
548#endif
549
550#ifndef softfloat_mul64ByShifted32To128
551/*----------------------------------------------------------------------------
552| Returns the 128-bit product of 'a', 'b', and 2^32.
553*----------------------------------------------------------------------------*/
554#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
555INLINE struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b )
556{
557 uint_fast64_t mid;
558 struct uint128 z;
559 mid = (uint_fast64_t) (uint32_t) a * b;
560 z.v0 = mid<<32;
561 z.v64 = (uint_fast64_t) (uint32_t) (a>>32) * b + (mid>>32);
562 return z;
563}
564#else
565struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b );
566#endif
567#endif
568
569#ifndef softfloat_mul64To128
570/*----------------------------------------------------------------------------
571| Returns the 128-bit product of 'a' and 'b'.
572*----------------------------------------------------------------------------*/
573struct uint128 softfloat_mul64To128( uint64_t a, uint64_t b );
574#endif
575
576#ifndef softfloat_mul128By32
577/*----------------------------------------------------------------------------
578| Returns the product of the 128-bit integer formed by concatenating 'a64' and
579| 'a0', multiplied by 'b'. The multiplication is modulo 2^128; any overflow
580| bits are discarded.
581*----------------------------------------------------------------------------*/
582#if defined INLINE_LEVEL && (4 <= INLINE_LEVEL)
583INLINE
584struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b )
585{
586 struct uint128 z;
587 uint_fast64_t mid;
588 uint_fast32_t carry;
589 z.v0 = a0 * b;
590 mid = (uint_fast64_t) (uint32_t) (a0>>32) * b;
591 carry = (uint32_t) ((uint_fast32_t) (z.v0>>32) - (uint_fast32_t) mid);
592 z.v64 = a64 * b + (uint_fast32_t) ((mid + carry)>>32);
593 return z;
594}
595#else
596struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b );
597#endif
598#endif
599
600#ifndef softfloat_mul128To256M
601/*----------------------------------------------------------------------------
602| Multiplies the 128-bit unsigned integer formed by concatenating 'a64' and
603| 'a0' by the 128-bit unsigned integer formed by concatenating 'b64' and
604| 'b0'. The 256-bit product is stored at the location pointed to by 'zPtr'.
605| Argument 'zPtr' points to an array of four 64-bit elements that concatenate
606| in the platform's normal endian order to form a 256-bit integer.
607*----------------------------------------------------------------------------*/
608void
609 softfloat_mul128To256M(
610 uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0, uint64_t *zPtr );
611#endif
612
613#else
614
615/*----------------------------------------------------------------------------
616| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is not
617| defined.
618*----------------------------------------------------------------------------*/
619
620#ifndef softfloat_compare96M
621/*----------------------------------------------------------------------------
622| Compares the two 96-bit unsigned integers pointed to by 'aPtr' and 'bPtr'.
623| Returns -1 if the first integer (A) is less than the second (B); returns 0
624| if the two integers are equal; and returns +1 if the first integer (A)
625| is greater than the second (B). (The result is thus the signum of A - B.)
626| Each of 'aPtr' and 'bPtr' points to an array of three 32-bit elements that
627| concatenate in the platform's normal endian order to form a 96-bit integer.
628*----------------------------------------------------------------------------*/
629int_fast8_t softfloat_compare96M( const uint32_t *aPtr, const uint32_t *bPtr );
630#endif
631
632#ifndef softfloat_compare128M
633/*----------------------------------------------------------------------------
634| Compares the two 128-bit unsigned integers pointed to by 'aPtr' and 'bPtr'.
635| Returns -1 if the first integer (A) is less than the second (B); returns 0
636| if the two integers are equal; and returns +1 if the first integer (A)
637| is greater than the second (B). (The result is thus the signum of A - B.)
638| Each of 'aPtr' and 'bPtr' points to an array of four 32-bit elements that
639| concatenate in the platform's normal endian order to form a 128-bit integer.
640*----------------------------------------------------------------------------*/
641int_fast8_t
642 softfloat_compare128M( const uint32_t *aPtr, const uint32_t *bPtr );
643#endif
644
645#ifndef softfloat_shortShiftLeft64To96M
646/*----------------------------------------------------------------------------
647| Extends 'a' to 96 bits and shifts the value left by the number of bits given
648| in 'dist', which must be in the range 1 to 31. The result is stored at the
649| location pointed to by 'zPtr'. Argument 'zPtr' points to an array of three
650| 32-bit elements that concatenate in the platform's normal endian order to
651| form a 96-bit integer.
652*----------------------------------------------------------------------------*/
653#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
654INLINE
655void
656 softfloat_shortShiftLeft64To96M(
657 uint64_t a, uint_fast8_t dist, uint32_t *zPtr )
658{
659 zPtr[indexWord( 3, 0 )] = (uint32_t) a<<dist;
660 a >>= 32 - dist;
661 zPtr[indexWord( 3, 2 )] = a>>32;
662 zPtr[indexWord( 3, 1 )] = a;
663}
664#else
665void
666 softfloat_shortShiftLeft64To96M(
667 uint64_t a, uint_fast8_t dist, uint32_t *zPtr );
668#endif
669#endif
670
671#ifndef softfloat_shortShiftLeftM
672/*----------------------------------------------------------------------------
673| Shifts the N-bit unsigned integer pointed to by 'aPtr' left by the number
674| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
675| must be in the range 1 to 31. Any nonzero bits shifted off are lost. The
676| shifted N-bit result is stored at the location pointed to by 'zPtr'. Each
677| of 'aPtr' and 'zPtr' points to a 'size_words'-long array of 32-bit elements
678| that concatenate in the platform's normal endian order to form an N-bit
679| integer.
680*----------------------------------------------------------------------------*/
681void
682 softfloat_shortShiftLeftM(
683 uint_fast8_t size_words,
684 const uint32_t *aPtr,
685 uint_fast8_t dist,
686 uint32_t *zPtr
687 );
688#endif
689
690#ifndef softfloat_shortShiftLeft96M
691/*----------------------------------------------------------------------------
692| This function or macro is the same as 'softfloat_shortShiftLeftM' with
693| 'size_words' = 3 (N = 96).
694*----------------------------------------------------------------------------*/
695#define softfloat_shortShiftLeft96M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 3, aPtr, dist, zPtr )
696#endif
697
698#ifndef softfloat_shortShiftLeft128M
699/*----------------------------------------------------------------------------
700| This function or macro is the same as 'softfloat_shortShiftLeftM' with
701| 'size_words' = 4 (N = 128).
702*----------------------------------------------------------------------------*/
703#define softfloat_shortShiftLeft128M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 4, aPtr, dist, zPtr )
704#endif
705
706#ifndef softfloat_shortShiftLeft160M
707/*----------------------------------------------------------------------------
708| This function or macro is the same as 'softfloat_shortShiftLeftM' with
709| 'size_words' = 5 (N = 160).
710*----------------------------------------------------------------------------*/
711#define softfloat_shortShiftLeft160M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 5, aPtr, dist, zPtr )
712#endif
713
714#ifndef softfloat_shiftLeftM
715/*----------------------------------------------------------------------------
716| Shifts the N-bit unsigned integer pointed to by 'aPtr' left by the number
717| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
718| must not be zero. Any nonzero bits shifted off are lost. The shifted
719| N-bit result is stored at the location pointed to by 'zPtr'. Each of 'aPtr'
720| and 'zPtr' points to a 'size_words'-long array of 32-bit elements that
721| concatenate in the platform's normal endian order to form an N-bit integer.
722| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
723| greater than N, the stored result will be 0.
724*----------------------------------------------------------------------------*/
725void
726 softfloat_shiftLeftM(
727 uint_fast8_t size_words,
728 const uint32_t *aPtr,
729 uint32_t dist,
730 uint32_t *zPtr
731 );
732#endif
733
734#ifndef softfloat_shiftLeft96M
735/*----------------------------------------------------------------------------
736| This function or macro is the same as 'softfloat_shiftLeftM' with
737| 'size_words' = 3 (N = 96).
738*----------------------------------------------------------------------------*/
739#define softfloat_shiftLeft96M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 3, aPtr, dist, zPtr )
740#endif
741
742#ifndef softfloat_shiftLeft128M
743/*----------------------------------------------------------------------------
744| This function or macro is the same as 'softfloat_shiftLeftM' with
745| 'size_words' = 4 (N = 128).
746*----------------------------------------------------------------------------*/
747#define softfloat_shiftLeft128M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 4, aPtr, dist, zPtr )
748#endif
749
750#ifndef softfloat_shiftLeft160M
751/*----------------------------------------------------------------------------
752| This function or macro is the same as 'softfloat_shiftLeftM' with
753| 'size_words' = 5 (N = 160).
754*----------------------------------------------------------------------------*/
755#define softfloat_shiftLeft160M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 5, aPtr, dist, zPtr )
756#endif
757
758#ifndef softfloat_shortShiftRightM
759/*----------------------------------------------------------------------------
760| Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
761| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
762| must be in the range 1 to 31. Any nonzero bits shifted off are lost. The
763| shifted N-bit result is stored at the location pointed to by 'zPtr'. Each
764| of 'aPtr' and 'zPtr' points to a 'size_words'-long array of 32-bit elements
765| that concatenate in the platform's normal endian order to form an N-bit
766| integer.
767*----------------------------------------------------------------------------*/
768void
769 softfloat_shortShiftRightM(
770 uint_fast8_t size_words,
771 const uint32_t *aPtr,
772 uint_fast8_t dist,
773 uint32_t *zPtr
774 );
775#endif
776
777#ifndef softfloat_shortShiftRight128M
778/*----------------------------------------------------------------------------
779| This function or macro is the same as 'softfloat_shortShiftRightM' with
780| 'size_words' = 4 (N = 128).
781*----------------------------------------------------------------------------*/
782#define softfloat_shortShiftRight128M( aPtr, dist, zPtr ) softfloat_shortShiftRightM( 4, aPtr, dist, zPtr )
783#endif
784
785#ifndef softfloat_shortShiftRight160M
786/*----------------------------------------------------------------------------
787| This function or macro is the same as 'softfloat_shortShiftRightM' with
788| 'size_words' = 5 (N = 160).
789*----------------------------------------------------------------------------*/
790#define softfloat_shortShiftRight160M( aPtr, dist, zPtr ) softfloat_shortShiftRightM( 5, aPtr, dist, zPtr )
791#endif
792
793#ifndef softfloat_shortShiftRightJamM
794/*----------------------------------------------------------------------------
795| Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
796| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
797| must be in the range 1 to 31. If any nonzero bits are shifted off, they are
798| "jammed" into the least-significant bit of the shifted value by setting the
799| least-significant bit to 1. This shifted-and-jammed N-bit result is stored
800| at the location pointed to by 'zPtr'. Each of 'aPtr' and 'zPtr' points
801| to a 'size_words'-long array of 32-bit elements that concatenate in the
802| platform's normal endian order to form an N-bit integer.
803*----------------------------------------------------------------------------*/
804void
805 softfloat_shortShiftRightJamM(
806 uint_fast8_t, const uint32_t *, uint_fast8_t, uint32_t * );
807#endif
808
809#ifndef softfloat_shortShiftRightJam160M
810/*----------------------------------------------------------------------------
811| This function or macro is the same as 'softfloat_shortShiftRightJamM' with
812| 'size_words' = 5 (N = 160).
813*----------------------------------------------------------------------------*/
814#define softfloat_shortShiftRightJam160M( aPtr, dist, zPtr ) softfloat_shortShiftRightJamM( 5, aPtr, dist, zPtr )
815#endif
816
817#ifndef softfloat_shiftRightM
818/*----------------------------------------------------------------------------
819| Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
820| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
821| must not be zero. Any nonzero bits shifted off are lost. The shifted
822| N-bit result is stored at the location pointed to by 'zPtr'. Each of 'aPtr'
823| and 'zPtr' points to a 'size_words'-long array of 32-bit elements that
824| concatenate in the platform's normal endian order to form an N-bit integer.
825| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
826| greater than N, the stored result will be 0.
827*----------------------------------------------------------------------------*/
828void
829 softfloat_shiftRightM(
830 uint_fast8_t size_words,
831 const uint32_t *aPtr,
832 uint32_t dist,
833 uint32_t *zPtr
834 );
835#endif
836
837#ifndef softfloat_shiftRight96M
838/*----------------------------------------------------------------------------
839| This function or macro is the same as 'softfloat_shiftRightM' with
840| 'size_words' = 3 (N = 96).
841*----------------------------------------------------------------------------*/
842#define softfloat_shiftRight96M( aPtr, dist, zPtr ) softfloat_shiftRightM( 3, aPtr, dist, zPtr )
843#endif
844
845#ifndef softfloat_shiftRightJamM
846/*----------------------------------------------------------------------------
847| Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
848| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
849| must not be zero. If any nonzero bits are shifted off, they are "jammed"
850| into the least-significant bit of the shifted value by setting the least-
851| significant bit to 1. This shifted-and-jammed N-bit result is stored
852| at the location pointed to by 'zPtr'. Each of 'aPtr' and 'zPtr' points
853| to a 'size_words'-long array of 32-bit elements that concatenate in the
854| platform's normal endian order to form an N-bit integer.
855| The value of 'dist' can be arbitrarily large. In particular, if 'dist'
856| is greater than N, the stored result will be either 0 or 1, depending on
857| whether the original N bits are all zeros.
858*----------------------------------------------------------------------------*/
859void
860 softfloat_shiftRightJamM(
861 uint_fast8_t size_words,
862 const uint32_t *aPtr,
863 uint32_t dist,
864 uint32_t *zPtr
865 );
866#endif
867
868#ifndef softfloat_shiftRightJam96M
869/*----------------------------------------------------------------------------
870| This function or macro is the same as 'softfloat_shiftRightJamM' with
871| 'size_words' = 3 (N = 96).
872*----------------------------------------------------------------------------*/
873#define softfloat_shiftRightJam96M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 3, aPtr, dist, zPtr )
874#endif
875
876#ifndef softfloat_shiftRightJam128M
877/*----------------------------------------------------------------------------
878| This function or macro is the same as 'softfloat_shiftRightJamM' with
879| 'size_words' = 4 (N = 128).
880*----------------------------------------------------------------------------*/
881#define softfloat_shiftRightJam128M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 4, aPtr, dist, zPtr )
882#endif
883
884#ifndef softfloat_shiftRightJam160M
885/*----------------------------------------------------------------------------
886| This function or macro is the same as 'softfloat_shiftRightJamM' with
887| 'size_words' = 5 (N = 160).
888*----------------------------------------------------------------------------*/
889#define softfloat_shiftRightJam160M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 5, aPtr, dist, zPtr )
890#endif
891
892#ifndef softfloat_addM
893/*----------------------------------------------------------------------------
894| Adds the two N-bit integers pointed to by 'aPtr' and 'bPtr', where N =
895| 'size_words' * 32. The addition is modulo 2^N, so any carry out is lost.
896| The N-bit sum is stored at the location pointed to by 'zPtr'. Each of
897| 'aPtr', 'bPtr', and 'zPtr' points to a 'size_words'-long array of 32-bit
898| elements that concatenate in the platform's normal endian order to form an
899| N-bit integer.
900*----------------------------------------------------------------------------*/
901void
902 softfloat_addM(
903 uint_fast8_t size_words,
904 const uint32_t *aPtr,
905 const uint32_t *bPtr,
906 uint32_t *zPtr
907 );
908#endif
909
910#ifndef softfloat_add96M
911/*----------------------------------------------------------------------------
912| This function or macro is the same as 'softfloat_addM' with 'size_words'
913| = 3 (N = 96).
914*----------------------------------------------------------------------------*/
915#define softfloat_add96M( aPtr, bPtr, zPtr ) softfloat_addM( 3, aPtr, bPtr, zPtr )
916#endif
917
918#ifndef softfloat_add128M
919/*----------------------------------------------------------------------------
920| This function or macro is the same as 'softfloat_addM' with 'size_words'
921| = 4 (N = 128).
922*----------------------------------------------------------------------------*/
923#define softfloat_add128M( aPtr, bPtr, zPtr ) softfloat_addM( 4, aPtr, bPtr, zPtr )
924#endif
925
926#ifndef softfloat_add160M
927/*----------------------------------------------------------------------------
928| This function or macro is the same as 'softfloat_addM' with 'size_words'
929| = 5 (N = 160).
930*----------------------------------------------------------------------------*/
931#define softfloat_add160M( aPtr, bPtr, zPtr ) softfloat_addM( 5, aPtr, bPtr, zPtr )
932#endif
933
934#ifndef softfloat_addCarryM
935/*----------------------------------------------------------------------------
936| Adds the two N-bit unsigned integers pointed to by 'aPtr' and 'bPtr', where
937| N = 'size_words' * 32, plus 'carry', which must be either 0 or 1. The N-bit
938| sum (modulo 2^N) is stored at the location pointed to by 'zPtr', and any
939| carry out is returned as the result. Each of 'aPtr', 'bPtr', and 'zPtr'
940| points to a 'size_words'-long array of 32-bit elements that concatenate in
941| the platform's normal endian order to form an N-bit integer.
942*----------------------------------------------------------------------------*/
943uint_fast8_t
944 softfloat_addCarryM(
945 uint_fast8_t size_words,
946 const uint32_t *aPtr,
947 const uint32_t *bPtr,
948 uint_fast8_t carry,
949 uint32_t *zPtr
950 );
951#endif
952
953#ifndef softfloat_addComplCarryM
954/*----------------------------------------------------------------------------
955| This function or macro is the same as 'softfloat_addCarryM', except that
956| the value of the unsigned integer pointed to by 'bPtr' is bit-wise completed
957| before the addition.
958*----------------------------------------------------------------------------*/
959uint_fast8_t
960 softfloat_addComplCarryM(
961 uint_fast8_t size_words,
962 const uint32_t *aPtr,
963 const uint32_t *bPtr,
964 uint_fast8_t carry,
965 uint32_t *zPtr
966 );
967#endif
968
969#ifndef softfloat_addComplCarry96M
970/*----------------------------------------------------------------------------
971| This function or macro is the same as 'softfloat_addComplCarryM' with
972| 'size_words' = 3 (N = 96).
973*----------------------------------------------------------------------------*/
974#define softfloat_addComplCarry96M( aPtr, bPtr, carry, zPtr ) softfloat_addComplCarryM( 3, aPtr, bPtr, carry, zPtr )
975#endif
976
977#ifndef softfloat_negXM
978/*----------------------------------------------------------------------------
979| Replaces the N-bit unsigned integer pointed to by 'zPtr' by the
980| 2s-complement of itself, where N = 'size_words' * 32. Argument 'zPtr'
981| points to a 'size_words'-long array of 32-bit elements that concatenate in
982| the platform's normal endian order to form an N-bit integer.
983*----------------------------------------------------------------------------*/
984void softfloat_negXM( uint_fast8_t size_words, uint32_t *zPtr );
985#endif
986
987#ifndef softfloat_negX96M
988/*----------------------------------------------------------------------------
989| This function or macro is the same as 'softfloat_negXM' with 'size_words'
990| = 3 (N = 96).
991*----------------------------------------------------------------------------*/
992#define softfloat_negX96M( zPtr ) softfloat_negXM( 3, zPtr )
993#endif
994
995#ifndef softfloat_negX128M
996/*----------------------------------------------------------------------------
997| This function or macro is the same as 'softfloat_negXM' with 'size_words'
998| = 4 (N = 128).
999*----------------------------------------------------------------------------*/
1000#define softfloat_negX128M( zPtr ) softfloat_negXM( 4, zPtr )
1001#endif
1002
1003#ifndef softfloat_negX160M
1004/*----------------------------------------------------------------------------
1005| This function or macro is the same as 'softfloat_negXM' with 'size_words'
1006| = 5 (N = 160).
1007*----------------------------------------------------------------------------*/
1008#define softfloat_negX160M( zPtr ) softfloat_negXM( 5, zPtr )
1009#endif
1010
1011#ifndef softfloat_negX256M
1012/*----------------------------------------------------------------------------
1013| This function or macro is the same as 'softfloat_negXM' with 'size_words'
1014| = 8 (N = 256).
1015*----------------------------------------------------------------------------*/
1016#define softfloat_negX256M( zPtr ) softfloat_negXM( 8, zPtr )
1017#endif
1018
1019#ifndef softfloat_sub1XM
1020/*----------------------------------------------------------------------------
1021| Subtracts 1 from the N-bit integer pointed to by 'zPtr', where N =
1022| 'size_words' * 32. The subtraction is modulo 2^N, so any borrow out (carry
1023| out) is lost. Argument 'zPtr' points to a 'size_words'-long array of 32-bit
1024| elements that concatenate in the platform's normal endian order to form an
1025| N-bit integer.
1026*----------------------------------------------------------------------------*/
1027void softfloat_sub1XM( uint_fast8_t size_words, uint32_t *zPtr );
1028#endif
1029
1030#ifndef softfloat_sub1X96M
1031/*----------------------------------------------------------------------------
1032| This function or macro is the same as 'softfloat_sub1XM' with 'size_words'
1033| = 3 (N = 96).
1034*----------------------------------------------------------------------------*/
1035#define softfloat_sub1X96M( zPtr ) softfloat_sub1XM( 3, zPtr )
1036#endif
1037
1038#ifndef softfloat_sub1X160M
1039/*----------------------------------------------------------------------------
1040| This function or macro is the same as 'softfloat_sub1XM' with 'size_words'
1041| = 5 (N = 160).
1042*----------------------------------------------------------------------------*/
1043#define softfloat_sub1X160M( zPtr ) softfloat_sub1XM( 5, zPtr )
1044#endif
1045
1046#ifndef softfloat_subM
1047/*----------------------------------------------------------------------------
1048| Subtracts the two N-bit integers pointed to by 'aPtr' and 'bPtr', where N =
1049| 'size_words' * 32. The subtraction is modulo 2^N, so any borrow out (carry
1050| out) is lost. The N-bit difference is stored at the location pointed to by
1051| 'zPtr'. Each of 'aPtr', 'bPtr', and 'zPtr' points to a 'size_words'-long
1052| array of 32-bit elements that concatenate in the platform's normal endian
1053| order to form an N-bit integer.
1054*----------------------------------------------------------------------------*/
1055void
1056 softfloat_subM(
1057 uint_fast8_t size_words,
1058 const uint32_t *aPtr,
1059 const uint32_t *bPtr,
1060 uint32_t *zPtr
1061 );
1062#endif
1063
1064#ifndef softfloat_sub96M
1065/*----------------------------------------------------------------------------
1066| This function or macro is the same as 'softfloat_subM' with 'size_words'
1067| = 3 (N = 96).
1068*----------------------------------------------------------------------------*/
1069#define softfloat_sub96M( aPtr, bPtr, zPtr ) softfloat_subM( 3, aPtr, bPtr, zPtr )
1070#endif
1071
1072#ifndef softfloat_sub128M
1073/*----------------------------------------------------------------------------
1074| This function or macro is the same as 'softfloat_subM' with 'size_words'
1075| = 4 (N = 128).
1076*----------------------------------------------------------------------------*/
1077#define softfloat_sub128M( aPtr, bPtr, zPtr ) softfloat_subM( 4, aPtr, bPtr, zPtr )
1078#endif
1079
1080#ifndef softfloat_sub160M
1081/*----------------------------------------------------------------------------
1082| This function or macro is the same as 'softfloat_subM' with 'size_words'
1083| = 5 (N = 160).
1084*----------------------------------------------------------------------------*/
1085#define softfloat_sub160M( aPtr, bPtr, zPtr ) softfloat_subM( 5, aPtr, bPtr, zPtr )
1086#endif
1087
1088#ifndef softfloat_mul64To128M
1089/*----------------------------------------------------------------------------
1090| Multiplies 'a' and 'b' and stores the 128-bit product at the location
1091| pointed to by 'zPtr'. Argument 'zPtr' points to an array of four 32-bit
1092| elements that concatenate in the platform's normal endian order to form a
1093| 128-bit integer.
1094*----------------------------------------------------------------------------*/
1095void softfloat_mul64To128M( uint64_t a, uint64_t b, uint32_t *zPtr );
1096#endif
1097
1098#ifndef softfloat_mul128MTo256M
1099/*----------------------------------------------------------------------------
1100| Multiplies the two 128-bit unsigned integers pointed to by 'aPtr' and
1101| 'bPtr', and stores the 256-bit product at the location pointed to by 'zPtr'.
1102| Each of 'aPtr' and 'bPtr' points to an array of four 32-bit elements that
1103| concatenate in the platform's normal endian order to form a 128-bit integer.
1104| Argument 'zPtr' points to an array of eight 32-bit elements that concatenate
1105| to form a 256-bit integer.
1106*----------------------------------------------------------------------------*/
1107void
1108 softfloat_mul128MTo256M(
1109 const uint32_t *aPtr, const uint32_t *bPtr, uint32_t *zPtr );
1110#endif
1111
1112#ifndef softfloat_remStepMBy32
1113/*----------------------------------------------------------------------------
1114| Performs a "remainder reduction step" as follows: Arguments 'remPtr' and
1115| 'bPtr' both point to N-bit unsigned integers, where N = 'size_words' * 32.
1116| Defining R and B as the values of those integers, the expression (R<<'dist')
1117| - B * q is computed modulo 2^N, and the N-bit result is stored at the
1118| location pointed to by 'zPtr'. Each of 'remPtr', 'bPtr', and 'zPtr' points
1119| to a 'size_words'-long array of 32-bit elements that concatenate in the
1120| platform's normal endian order to form an N-bit integer.
1121*----------------------------------------------------------------------------*/
1122void
1123 softfloat_remStepMBy32(
1124 uint_fast8_t size_words,
1125 const uint32_t *remPtr,
1126 uint_fast8_t dist,
1127 const uint32_t *bPtr,
1128 uint32_t q,
1129 uint32_t *zPtr
1130 );
1131#endif
1132
1133#ifndef softfloat_remStep96MBy32
1134/*----------------------------------------------------------------------------
1135| This function or macro is the same as 'softfloat_remStepMBy32' with
1136| 'size_words' = 3 (N = 96).
1137*----------------------------------------------------------------------------*/
1138#define softfloat_remStep96MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 3, remPtr, dist, bPtr, q, zPtr )
1139#endif
1140
1141#ifndef softfloat_remStep128MBy32
1142/*----------------------------------------------------------------------------
1143| This function or macro is the same as 'softfloat_remStepMBy32' with
1144| 'size_words' = 4 (N = 128).
1145*----------------------------------------------------------------------------*/
1146#define softfloat_remStep128MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 4, remPtr, dist, bPtr, q, zPtr )
1147#endif
1148
1149#ifndef softfloat_remStep160MBy32
1150/*----------------------------------------------------------------------------
1151| This function or macro is the same as 'softfloat_remStepMBy32' with
1152| 'size_words' = 5 (N = 160).
1153*----------------------------------------------------------------------------*/
1154#define softfloat_remStep160MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 5, remPtr, dist, bPtr, q, zPtr )
1155#endif
1156
1157#endif
1158
1159#endif
1160
deps/SoftFloat-3d/source/include/softfloat.h deleted-372
......@@ -1,372 +0,0 @@
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37
38/*============================================================================
39| Note: If SoftFloat is made available as a general library for programs to
40| use, it is strongly recommended that a platform-specific version of this
41| header, "softfloat.h", be created that folds in "softfloat_types.h" and that
42| eliminates all dependencies on compile-time macros.
43*============================================================================*/
44
45
46#ifndef softfloat_h
47#define softfloat_h 1
48
49#include <stdbool.h>
50#include <stdint.h>
51#include "softfloat_types.h"
52
53#ifndef THREAD_LOCAL
54#define THREAD_LOCAL
55#endif
56
57/*----------------------------------------------------------------------------
58| Software floating-point underflow tininess-detection mode.
59*----------------------------------------------------------------------------*/
60extern THREAD_LOCAL uint_fast8_t softfloat_detectTininess;
61enum {
62 softfloat_tininess_beforeRounding = 0,
63 softfloat_tininess_afterRounding = 1
64};
65
66/*----------------------------------------------------------------------------
67| Software floating-point rounding mode. (Mode "odd" is supported only if
68| SoftFloat is compiled with macro 'SOFTFLOAT_ROUND_ODD' defined.)
69*----------------------------------------------------------------------------*/
70extern THREAD_LOCAL uint_fast8_t softfloat_roundingMode;
71enum {
72 softfloat_round_near_even = 0,
73 softfloat_round_minMag = 1,
74 softfloat_round_min = 2,
75 softfloat_round_max = 3,
76 softfloat_round_near_maxMag = 4,
77 softfloat_round_odd = 5
78};
79
80/*----------------------------------------------------------------------------
81| Software floating-point exception flags.
82*----------------------------------------------------------------------------*/
83extern THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags;
84enum {
85 softfloat_flag_inexact = 1,
86 softfloat_flag_underflow = 2,
87 softfloat_flag_overflow = 4,
88 softfloat_flag_infinite = 8,
89 softfloat_flag_invalid = 16
90};
91
92/*----------------------------------------------------------------------------
93| Routine to raise any or all of the software floating-point exception flags.
94*----------------------------------------------------------------------------*/
95void softfloat_raiseFlags( uint_fast8_t );
96
97/*----------------------------------------------------------------------------
98| Integer-to-floating-point conversion routines.
99*----------------------------------------------------------------------------*/
100float16_t ui32_to_f16( uint32_t );
101float32_t ui32_to_f32( uint32_t );
102float64_t ui32_to_f64( uint32_t );
103#ifdef SOFTFLOAT_FAST_INT64
104extFloat80_t ui32_to_extF80( uint32_t );
105float128_t ui32_to_f128( uint32_t );
106#endif
107void ui32_to_extF80M( uint32_t, extFloat80_t * );
108void ui32_to_f128M( uint32_t, float128_t * );
109float16_t ui64_to_f16( uint64_t );
110float32_t ui64_to_f32( uint64_t );
111float64_t ui64_to_f64( uint64_t );
112#ifdef SOFTFLOAT_FAST_INT64
113extFloat80_t ui64_to_extF80( uint64_t );
114float128_t ui64_to_f128( uint64_t );
115#endif
116void ui64_to_extF80M( uint64_t, extFloat80_t * );
117void ui64_to_f128M( uint64_t, float128_t * );
118float16_t i32_to_f16( int32_t );
119float32_t i32_to_f32( int32_t );
120float64_t i32_to_f64( int32_t );
121#ifdef SOFTFLOAT_FAST_INT64
122extFloat80_t i32_to_extF80( int32_t );
123float128_t i32_to_f128( int32_t );
124#endif
125void i32_to_extF80M( int32_t, extFloat80_t * );
126void i32_to_f128M( int32_t, float128_t * );
127float16_t i64_to_f16( int64_t );
128float32_t i64_to_f32( int64_t );
129float64_t i64_to_f64( int64_t );
130#ifdef SOFTFLOAT_FAST_INT64
131extFloat80_t i64_to_extF80( int64_t );
132float128_t i64_to_f128( int64_t );
133#endif
134void i64_to_extF80M( int64_t, extFloat80_t * );
135void i64_to_f128M( int64_t, float128_t * );
136
137/*----------------------------------------------------------------------------
138| 16-bit (half-precision) floating-point operations.
139*----------------------------------------------------------------------------*/
140uint_fast32_t f16_to_ui32( float16_t, uint_fast8_t, bool );
141uint_fast64_t f16_to_ui64( float16_t, uint_fast8_t, bool );
142int_fast32_t f16_to_i32( float16_t, uint_fast8_t, bool );
143int_fast64_t f16_to_i64( float16_t, uint_fast8_t, bool );
144uint_fast32_t f16_to_ui32_r_minMag( float16_t, bool );
145uint_fast64_t f16_to_ui64_r_minMag( float16_t, bool );
146int_fast32_t f16_to_i32_r_minMag( float16_t, bool );
147int_fast64_t f16_to_i64_r_minMag( float16_t, bool );
148float32_t f16_to_f32( float16_t );
149float64_t f16_to_f64( float16_t );
150#ifdef SOFTFLOAT_FAST_INT64
151extFloat80_t f16_to_extF80( float16_t );
152float128_t f16_to_f128( float16_t );
153#endif
154void f16_to_extF80M( float16_t, extFloat80_t * );
155void f16_to_f128M( float16_t, float128_t * );
156float16_t f16_roundToInt( float16_t, uint_fast8_t, bool );
157float16_t f16_add( float16_t, float16_t );
158float16_t f16_sub( float16_t, float16_t );
159float16_t f16_mul( float16_t, float16_t );
160float16_t f16_mulAdd( float16_t, float16_t, float16_t );
161float16_t f16_div( float16_t, float16_t );
162float16_t f16_rem( float16_t, float16_t );
163float16_t f16_sqrt( float16_t );
164bool f16_eq( float16_t, float16_t );
165bool f16_le( float16_t, float16_t );
166bool f16_lt( float16_t, float16_t );
167bool f16_eq_signaling( float16_t, float16_t );
168bool f16_le_quiet( float16_t, float16_t );
169bool f16_lt_quiet( float16_t, float16_t );
170bool f16_isSignalingNaN( float16_t );
171
172/*----------------------------------------------------------------------------
173| 32-bit (single-precision) floating-point operations.
174*----------------------------------------------------------------------------*/
175uint_fast32_t f32_to_ui32( float32_t, uint_fast8_t, bool );
176uint_fast64_t f32_to_ui64( float32_t, uint_fast8_t, bool );
177int_fast32_t f32_to_i32( float32_t, uint_fast8_t, bool );
178int_fast64_t f32_to_i64( float32_t, uint_fast8_t, bool );
179uint_fast32_t f32_to_ui32_r_minMag( float32_t, bool );
180uint_fast64_t f32_to_ui64_r_minMag( float32_t, bool );
181int_fast32_t f32_to_i32_r_minMag( float32_t, bool );
182int_fast64_t f32_to_i64_r_minMag( float32_t, bool );
183float16_t f32_to_f16( float32_t );
184float64_t f32_to_f64( float32_t );
185#ifdef SOFTFLOAT_FAST_INT64
186extFloat80_t f32_to_extF80( float32_t );
187float128_t f32_to_f128( float32_t );
188#endif
189void f32_to_extF80M( float32_t, extFloat80_t * );
190void f32_to_f128M( float32_t, float128_t * );
191float32_t f32_roundToInt( float32_t, uint_fast8_t, bool );
192float32_t f32_add( float32_t, float32_t );
193float32_t f32_sub( float32_t, float32_t );
194float32_t f32_mul( float32_t, float32_t );
195float32_t f32_mulAdd( float32_t, float32_t, float32_t );
196float32_t f32_div( float32_t, float32_t );
197float32_t f32_rem( float32_t, float32_t );
198float32_t f32_sqrt( float32_t );
199bool f32_eq( float32_t, float32_t );
200bool f32_le( float32_t, float32_t );
201bool f32_lt( float32_t, float32_t );
202bool f32_eq_signaling( float32_t, float32_t );
203bool f32_le_quiet( float32_t, float32_t );
204bool f32_lt_quiet( float32_t, float32_t );
205bool f32_isSignalingNaN( float32_t );
206
207/*----------------------------------------------------------------------------
208| 64-bit (double-precision) floating-point operations.
209*----------------------------------------------------------------------------*/
210uint_fast32_t f64_to_ui32( float64_t, uint_fast8_t, bool );
211uint_fast64_t f64_to_ui64( float64_t, uint_fast8_t, bool );
212int_fast32_t f64_to_i32( float64_t, uint_fast8_t, bool );
213int_fast64_t f64_to_i64( float64_t, uint_fast8_t, bool );
214uint_fast32_t f64_to_ui32_r_minMag( float64_t, bool );
215uint_fast64_t f64_to_ui64_r_minMag( float64_t, bool );
216int_fast32_t f64_to_i32_r_minMag( float64_t, bool );
217int_fast64_t f64_to_i64_r_minMag( float64_t, bool );
218float16_t f64_to_f16( float64_t );
219float32_t f64_to_f32( float64_t );
220#ifdef SOFTFLOAT_FAST_INT64
221extFloat80_t f64_to_extF80( float64_t );
222float128_t f64_to_f128( float64_t );
223#endif
224void f64_to_extF80M( float64_t, extFloat80_t * );
225void f64_to_f128M( float64_t, float128_t * );
226float64_t f64_roundToInt( float64_t, uint_fast8_t, bool );
227float64_t f64_add( float64_t, float64_t );
228float64_t f64_sub( float64_t, float64_t );
229float64_t f64_mul( float64_t, float64_t );
230float64_t f64_mulAdd( float64_t, float64_t, float64_t );
231float64_t f64_div( float64_t, float64_t );
232float64_t f64_rem( float64_t, float64_t );
233float64_t f64_sqrt( float64_t );
234bool f64_eq( float64_t, float64_t );
235bool f64_le( float64_t, float64_t );
236bool f64_lt( float64_t, float64_t );
237bool f64_eq_signaling( float64_t, float64_t );
238bool f64_le_quiet( float64_t, float64_t );
239bool f64_lt_quiet( float64_t, float64_t );
240bool f64_isSignalingNaN( float64_t );
241
242/*----------------------------------------------------------------------------
243| Rounding precision for 80-bit extended double-precision floating-point.
244| Valid values are 32, 64, and 80.
245*----------------------------------------------------------------------------*/
246extern THREAD_LOCAL uint_fast8_t extF80_roundingPrecision;
247
248/*----------------------------------------------------------------------------
249| 80-bit extended double-precision floating-point operations.
250*----------------------------------------------------------------------------*/
251#ifdef SOFTFLOAT_FAST_INT64
252uint_fast32_t extF80_to_ui32( extFloat80_t, uint_fast8_t, bool );
253uint_fast64_t extF80_to_ui64( extFloat80_t, uint_fast8_t, bool );
254int_fast32_t extF80_to_i32( extFloat80_t, uint_fast8_t, bool );
255int_fast64_t extF80_to_i64( extFloat80_t, uint_fast8_t, bool );
256uint_fast32_t extF80_to_ui32_r_minMag( extFloat80_t, bool );
257uint_fast64_t extF80_to_ui64_r_minMag( extFloat80_t, bool );
258int_fast32_t extF80_to_i32_r_minMag( extFloat80_t, bool );
259int_fast64_t extF80_to_i64_r_minMag( extFloat80_t, bool );
260float16_t extF80_to_f16( extFloat80_t );
261float32_t extF80_to_f32( extFloat80_t );
262float64_t extF80_to_f64( extFloat80_t );
263float128_t extF80_to_f128( extFloat80_t );
264extFloat80_t extF80_roundToInt( extFloat80_t, uint_fast8_t, bool );
265extFloat80_t extF80_add( extFloat80_t, extFloat80_t );
266extFloat80_t extF80_sub( extFloat80_t, extFloat80_t );
267extFloat80_t extF80_mul( extFloat80_t, extFloat80_t );
268extFloat80_t extF80_div( extFloat80_t, extFloat80_t );
269extFloat80_t extF80_rem( extFloat80_t, extFloat80_t );
270extFloat80_t extF80_sqrt( extFloat80_t );
271bool extF80_eq( extFloat80_t, extFloat80_t );
272bool extF80_le( extFloat80_t, extFloat80_t );
273bool extF80_lt( extFloat80_t, extFloat80_t );
274bool extF80_eq_signaling( extFloat80_t, extFloat80_t );
275bool extF80_le_quiet( extFloat80_t, extFloat80_t );
276bool extF80_lt_quiet( extFloat80_t, extFloat80_t );
277bool extF80_isSignalingNaN( extFloat80_t );
278#endif
279uint_fast32_t extF80M_to_ui32( const extFloat80_t *, uint_fast8_t, bool );
280uint_fast64_t extF80M_to_ui64( const extFloat80_t *, uint_fast8_t, bool );
281int_fast32_t extF80M_to_i32( const extFloat80_t *, uint_fast8_t, bool );
282int_fast64_t extF80M_to_i64( const extFloat80_t *, uint_fast8_t, bool );
283uint_fast32_t extF80M_to_ui32_r_minMag( const extFloat80_t *, bool );
284uint_fast64_t extF80M_to_ui64_r_minMag( const extFloat80_t *, bool );
285int_fast32_t extF80M_to_i32_r_minMag( const extFloat80_t *, bool );
286int_fast64_t extF80M_to_i64_r_minMag( const extFloat80_t *, bool );
287float16_t extF80M_to_f16( const extFloat80_t * );
288float32_t extF80M_to_f32( const extFloat80_t * );
289float64_t extF80M_to_f64( const extFloat80_t * );
290void extF80M_to_f128M( const extFloat80_t *, float128_t * );
291void
292 extF80M_roundToInt(
293 const extFloat80_t *, uint_fast8_t, bool, extFloat80_t * );
294void extF80M_add( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
295void extF80M_sub( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
296void extF80M_mul( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
297void extF80M_div( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
298void extF80M_rem( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
299void extF80M_sqrt( const extFloat80_t *, extFloat80_t * );
300bool extF80M_eq( const extFloat80_t *, const extFloat80_t * );
301bool extF80M_le( const extFloat80_t *, const extFloat80_t * );
302bool extF80M_lt( const extFloat80_t *, const extFloat80_t * );
303bool extF80M_eq_signaling( const extFloat80_t *, const extFloat80_t * );
304bool extF80M_le_quiet( const extFloat80_t *, const extFloat80_t * );
305bool extF80M_lt_quiet( const extFloat80_t *, const extFloat80_t * );
306bool extF80M_isSignalingNaN( const extFloat80_t * );
307
308/*----------------------------------------------------------------------------
309| 128-bit (quadruple-precision) floating-point operations.
310*----------------------------------------------------------------------------*/
311#ifdef SOFTFLOAT_FAST_INT64
312uint_fast32_t f128_to_ui32( float128_t, uint_fast8_t, bool );
313uint_fast64_t f128_to_ui64( float128_t, uint_fast8_t, bool );
314int_fast32_t f128_to_i32( float128_t, uint_fast8_t, bool );
315int_fast64_t f128_to_i64( float128_t, uint_fast8_t, bool );
316uint_fast32_t f128_to_ui32_r_minMag( float128_t, bool );
317uint_fast64_t f128_to_ui64_r_minMag( float128_t, bool );
318int_fast32_t f128_to_i32_r_minMag( float128_t, bool );
319int_fast64_t f128_to_i64_r_minMag( float128_t, bool );
320float16_t f128_to_f16( float128_t );
321float32_t f128_to_f32( float128_t );
322float64_t f128_to_f64( float128_t );
323extFloat80_t f128_to_extF80( float128_t );
324float128_t f128_roundToInt( float128_t, uint_fast8_t, bool );
325float128_t f128_add( float128_t, float128_t );
326float128_t f128_sub( float128_t, float128_t );
327float128_t f128_mul( float128_t, float128_t );
328float128_t f128_mulAdd( float128_t, float128_t, float128_t );
329float128_t f128_div( float128_t, float128_t );
330float128_t f128_rem( float128_t, float128_t );
331float128_t f128_sqrt( float128_t );
332bool f128_eq( float128_t, float128_t );
333bool f128_le( float128_t, float128_t );
334bool f128_lt( float128_t, float128_t );
335bool f128_eq_signaling( float128_t, float128_t );
336bool f128_le_quiet( float128_t, float128_t );
337bool f128_lt_quiet( float128_t, float128_t );
338bool f128_isSignalingNaN( float128_t );
339#endif
340uint_fast32_t f128M_to_ui32( const float128_t *, uint_fast8_t, bool );
341uint_fast64_t f128M_to_ui64( const float128_t *, uint_fast8_t, bool );
342int_fast32_t f128M_to_i32( const float128_t *, uint_fast8_t, bool );
343int_fast64_t f128M_to_i64( const float128_t *, uint_fast8_t, bool );
344uint_fast32_t f128M_to_ui32_r_minMag( const float128_t *, bool );
345uint_fast64_t f128M_to_ui64_r_minMag( const float128_t *, bool );
346int_fast32_t f128M_to_i32_r_minMag( const float128_t *, bool );
347int_fast64_t f128M_to_i64_r_minMag( const float128_t *, bool );
348float16_t f128M_to_f16( const float128_t * );
349float32_t f128M_to_f32( const float128_t * );
350float64_t f128M_to_f64( const float128_t * );
351void f128M_to_extF80M( const float128_t *, extFloat80_t * );
352void f128M_roundToInt( const float128_t *, uint_fast8_t, bool, float128_t * );
353void f128M_add( const float128_t *, const float128_t *, float128_t * );
354void f128M_sub( const float128_t *, const float128_t *, float128_t * );
355void f128M_mul( const float128_t *, const float128_t *, float128_t * );
356void
357 f128M_mulAdd(
358 const float128_t *, const float128_t *, const float128_t *, float128_t *
359 );
360void f128M_div( const float128_t *, const float128_t *, float128_t * );
361void f128M_rem( const float128_t *, const float128_t *, float128_t * );
362void f128M_sqrt( const float128_t *, float128_t * );
363bool f128M_eq( const float128_t *, const float128_t * );
364bool f128M_le( const float128_t *, const float128_t * );
365bool f128M_lt( const float128_t *, const float128_t * );
366bool f128M_eq_signaling( const float128_t *, const float128_t * );
367bool f128M_le_quiet( const float128_t *, const float128_t * );
368bool f128M_lt_quiet( const float128_t *, const float128_t * );
369bool f128M_isSignalingNaN( const float128_t * );
370
371#endif
372
deps/SoftFloat-3d/source/include/softfloat_types.h deleted-81
......@@ -1,81 +0,0 @@
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#ifndef softfloat_types_h
38#define softfloat_types_h 1
39
40#include <stdint.h>
41
42/*----------------------------------------------------------------------------
43| Types used to pass 16-bit, 32-bit, 64-bit, and 128-bit floating-point
44| arguments and results to/from functions. These types must be exactly
45| 16 bits, 32 bits, 64 bits, and 128 bits in size, respectively. Where a
46| platform has "native" support for IEEE-Standard floating-point formats,
47| the types below may, if desired, be defined as aliases for the native types
48| (typically 'float' and 'double', and possibly 'long double').
49*----------------------------------------------------------------------------*/
50typedef struct { uint16_t v; } float16_t;
51typedef struct { uint32_t v; } float32_t;
52typedef struct { uint64_t v; } float64_t;
53typedef struct { uint64_t v[2]; } float128_t;
54
55/*----------------------------------------------------------------------------
56| The format of an 80-bit extended floating-point number in memory. This
57| structure must contain a 16-bit field named 'signExp' and a 64-bit field
58| named 'signif'.
59*----------------------------------------------------------------------------*/
60#ifdef LITTLEENDIAN
61struct extFloat80M { uint64_t signif; uint16_t signExp; };
62#else
63struct extFloat80M { uint16_t signExp; uint64_t signif; };
64#endif
65
66/*----------------------------------------------------------------------------
67| The type used to pass 80-bit extended floating-point arguments and
68| results to/from functions. This type must have size identical to
69| 'struct extFloat80M'. Type 'extFloat80_t' can be defined as an alias for
70| 'struct extFloat80M'. Alternatively, if a platform has "native" support
71| for IEEE-Standard 80-bit extended floating-point, it may be possible,
72| if desired, to define 'extFloat80_t' as an alias for the native type
73| (presumably either 'long double' or a nonstandard compiler-intrinsic type).
74| In that case, the 'signif' and 'signExp' fields of 'struct extFloat80M'
75| must align exactly with the locations in memory of the sign, exponent, and
76| significand of the native type.
77*----------------------------------------------------------------------------*/
78typedef struct extFloat80M extFloat80_t;
79
80#endif
81
deps/SoftFloat-3d/source/s_add128.c deleted-55
......@@ -1,55 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_add128
42
43struct uint128
44 softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
45{
46 struct uint128 z;
47
48 z.v0 = a0 + b0;
49 z.v64 = a64 + b64 + (z.v0 < a0);
50 return z;
51
52}
53
54#endif
55
deps/SoftFloat-3d/source/s_add256M.c deleted-65
......@@ -1,65 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_add256M
42
43void
44 softfloat_add256M(
45 const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr )
46{
47 unsigned int index;
48 uint_fast8_t carry;
49 uint64_t wordA, wordZ;
50
51 index = indexWordLo( 4 );
52 carry = 0;
53 for (;;) {
54 wordA = aPtr[index];
55 wordZ = wordA + bPtr[index] + carry;
56 zPtr[index] = wordZ;
57 if ( index == indexWordHi( 4 ) ) break;
58 if ( wordZ != wordA ) carry = (wordZ < wordA);
59 index += wordIncr;
60 }
61
62}
63
64#endif
65
deps/SoftFloat-3d/source/s_addCarryM.c deleted-70
......@@ -1,70 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_addCarryM
42
43uint_fast8_t
44 softfloat_addCarryM(
45 uint_fast8_t size_words,
46 const uint32_t *aPtr,
47 const uint32_t *bPtr,
48 uint_fast8_t carry,
49 uint32_t *zPtr
50 )
51{
52 unsigned int index, lastIndex;
53 uint32_t wordA, wordZ;
54
55 index = indexWordLo( size_words );
56 lastIndex = indexWordHi( size_words );
57 for (;;) {
58 wordA = aPtr[index];
59 wordZ = wordA + bPtr[index] + carry;
60 zPtr[index] = wordZ;
61 if ( wordZ != wordA ) carry = (wordZ < wordA);
62 if ( index == lastIndex ) break;
63 index += wordIncr;
64 }
65 return carry;
66
67}
68
69#endif
70
deps/SoftFloat-3d/source/s_addComplCarryM.c deleted-70
......@@ -1,70 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_addComplCarryM
42
43uint_fast8_t
44 softfloat_addComplCarryM(
45 uint_fast8_t size_words,
46 const uint32_t *aPtr,
47 const uint32_t *bPtr,
48 uint_fast8_t carry,
49 uint32_t *zPtr
50 )
51{
52 unsigned int index, lastIndex;
53 uint32_t wordA, wordZ;
54
55 index = indexWordLo( size_words );
56 lastIndex = indexWordHi( size_words );
57 for (;;) {
58 wordA = aPtr[index];
59 wordZ = wordA + ~bPtr[index] + carry;
60 zPtr[index] = wordZ;
61 if ( wordZ != wordA ) carry = (wordZ < wordA);
62 if ( index == lastIndex ) break;
63 index += wordIncr;
64 }
65 return carry;
66
67}
68
69#endif
70
deps/SoftFloat-3d/source/s_addExtF80M.c deleted-186
......@@ -1,186 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44void
45 softfloat_addExtF80M(
46 const struct extFloat80M *aSPtr,
47 const struct extFloat80M *bSPtr,
48 struct extFloat80M *zSPtr,
49 bool negateB
50 )
51{
52 uint32_t uiA64;
53 int32_t expA;
54 uint32_t uiB64;
55 int32_t expB;
56 uint32_t uiZ64;
57 bool signZ, signB;
58 const struct extFloat80M *tempSPtr;
59 uint64_t sigZ, sigB;
60 void
61 (*roundPackRoutinePtr)(
62 bool, int32_t, uint32_t *, uint_fast8_t, struct extFloat80M * );
63 int32_t expDiff;
64 uint32_t extSigX[3], sigZExtra;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 uiA64 = aSPtr->signExp;
69 expA = expExtF80UI64( uiA64 );
70 uiB64 = bSPtr->signExp;
71 expB = expExtF80UI64( uiB64 );
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
75 if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
76 uiZ64 = uiA64;
77 if ( expB == 0x7FFF ) {
78 uiZ64 = uiB64 ^ packToExtF80UI64( negateB, 0 );
79 if ( (expA == 0x7FFF) && (uiZ64 != uiA64) ) {
80 softfloat_invalidExtF80M( zSPtr );
81 return;
82 }
83 }
84 zSPtr->signExp = uiZ64;
85 zSPtr->signif = UINT64_C( 0x8000000000000000 );
86 return;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 signZ = signExtF80UI64( uiA64 );
91 signB = signExtF80UI64( uiB64 ) ^ negateB;
92 negateB = (signZ != signB);
93 if ( expA < expB ) {
94 signZ = signB;
95 expA = expB;
96 expB = expExtF80UI64( uiA64 );
97 tempSPtr = aSPtr;
98 aSPtr = bSPtr;
99 bSPtr = tempSPtr;
100 }
101 if ( ! expB ) {
102 expB = 1;
103 if ( ! expA ) expA = 1;
104 }
105 sigZ = aSPtr->signif;
106 sigB = bSPtr->signif;
107 /*------------------------------------------------------------------------
108 *------------------------------------------------------------------------*/
109 roundPackRoutinePtr = softfloat_roundPackMToExtF80M;
110 expDiff = expA - expB;
111 if ( expDiff ) {
112 /*--------------------------------------------------------------------
113 *--------------------------------------------------------------------*/
114 extSigX[indexWord( 3, 2 )] = sigB>>32;
115 extSigX[indexWord( 3, 1 )] = sigB;
116 extSigX[indexWord( 3, 0 )] = 0;
117 softfloat_shiftRightJam96M( extSigX, expDiff, extSigX );
118 sigB =
119 (uint64_t) extSigX[indexWord( 3, 2 )]<<32
120 | extSigX[indexWord( 3, 1 )];
121 if ( negateB ) {
122 sigZ -= sigB;
123 sigZExtra = extSigX[indexWordLo( 3 )];
124 if ( sigZExtra ) {
125 --sigZ;
126 sigZExtra = -sigZExtra;
127 }
128 if ( ! (sigZ & UINT64_C( 0x8000000000000000 )) ) {
129 if ( sigZ & UINT64_C( 0x4000000000000000 ) ) {
130 --expA;
131 sigZ = sigZ<<1 | sigZExtra>>31;
132 sigZExtra <<= 1;
133 } else {
134 roundPackRoutinePtr = softfloat_normRoundPackMToExtF80M;
135 }
136 }
137 } else {
138 sigZ += sigB;
139 if ( sigZ & UINT64_C( 0x8000000000000000 ) ) goto sigZ;
140 sigZExtra = (uint32_t) sigZ<<31 | (extSigX[indexWordLo( 3 )] != 0);
141 goto completeNormAfterAdd;
142 }
143 } else {
144 /*--------------------------------------------------------------------
145 *--------------------------------------------------------------------*/
146 sigZExtra = 0;
147 if ( negateB ) {
148 if ( sigZ < sigB ) {
149 signZ = ! signZ;
150 sigZ = sigB - sigZ;
151 } else {
152 sigZ -= sigB;
153 if ( ! sigZ ) {
154 signZ = (softfloat_roundingMode == softfloat_round_min);
155 zSPtr->signExp = packToExtF80UI64( signZ, 0 );
156 zSPtr->signif = 0;
157 return;
158 }
159 }
160 roundPackRoutinePtr = softfloat_normRoundPackMToExtF80M;
161 } else {
162 sigZ += sigB;
163 if ( sigZ < sigB ) {
164 sigZExtra = (uint32_t) sigZ<<31;
165 completeNormAfterAdd:
166 ++expA;
167 sigZ = UINT64_C( 0x8000000000000000 ) | sigZ>>1;
168 } else {
169 if ( ! (sigZ & UINT64_C( 0x8000000000000000 )) ) {
170 roundPackRoutinePtr = softfloat_normRoundPackMToExtF80M;
171 }
172 }
173 }
174 }
175 extSigX[indexWord( 3, 0 )] = sigZExtra;
176 sigZ:
177 extSigX[indexWord( 3, 2 )] = sigZ>>32;
178 extSigX[indexWord( 3, 1 )] = sigZ;
179 /*------------------------------------------------------------------------
180 *------------------------------------------------------------------------*/
181 roundPack:
182 (*roundPackRoutinePtr)(
183 signZ, expA, extSigX, extF80_roundingPrecision, zSPtr );
184
185}
186
deps/SoftFloat-3d/source/s_addF128M.c deleted-211
......@@ -1,211 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44void
45 softfloat_addF128M(
46 const uint32_t *aWPtr,
47 const uint32_t *bWPtr,
48 uint32_t *zWPtr,
49 bool negateB
50 )
51{
52 uint32_t uiA96;
53 int32_t expA;
54 uint32_t uiB96;
55 int32_t expB;
56 uint32_t uiZ96;
57 bool signZ, signB;
58 const uint32_t *tempPtr;
59 uint32_t sig96A, sig96B;
60 int32_t expDiff;
61 uint_fast8_t
62 (*addCarryMRoutinePtr)(
63 uint_fast8_t,
64 const uint32_t *,
65 const uint32_t *,
66 uint_fast8_t,
67 uint32_t *
68 );
69 uint32_t extSigZ[5], wordSigZ;
70 uint_fast8_t carry;
71 void (*roundPackRoutinePtr)( bool, int32_t, uint32_t *, uint32_t * );
72
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 uiA96 = aWPtr[indexWordHi( 4 )];
76 expA = expF128UI96( uiA96 );
77 uiB96 = bWPtr[indexWordHi( 4 )];
78 expB = expF128UI96( uiB96 );
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
82 if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
83 uiZ96 = uiA96;
84 if ( expB == 0x7FFF ) {
85 uiZ96 = uiB96 ^ packToF128UI96( negateB, 0, 0 );
86 if ( (expA == 0x7FFF) && (uiZ96 != uiA96) ) {
87 softfloat_invalidF128M( zWPtr );
88 return;
89 }
90 }
91 zWPtr[indexWordHi( 4 )] = uiZ96;
92 zWPtr[indexWord( 4, 2 )] = 0;
93 zWPtr[indexWord( 4, 1 )] = 0;
94 zWPtr[indexWord( 4, 0 )] = 0;
95 return;
96 }
97 /*------------------------------------------------------------------------
98 *------------------------------------------------------------------------*/
99 signZ = signF128UI96( uiA96 );
100 signB = signF128UI96( uiB96 ) ^ negateB;
101 negateB = (signZ != signB);
102 if ( (uint32_t) (uiA96<<1) < (uint32_t) (uiB96<<1) ) {
103 signZ = signB;
104 expA = expB;
105 expB = expF128UI96( uiA96 );
106 tempPtr = aWPtr;
107 aWPtr = bWPtr;
108 bWPtr = tempPtr;
109 uiA96 = uiB96;
110 uiB96 = bWPtr[indexWordHi( 4 )];
111 }
112 sig96A = fracF128UI96( uiA96 );
113 sig96B = fracF128UI96( uiB96 );
114 if ( expA ) {
115 --expA;
116 sig96A |= 0x00010000;
117 if ( expB ) {
118 --expB;
119 sig96B |= 0x00010000;
120 }
121 }
122 /*------------------------------------------------------------------------
123 *------------------------------------------------------------------------*/
124 addCarryMRoutinePtr =
125 negateB ? softfloat_addComplCarryM : softfloat_addCarryM;
126 expDiff = expA - expB;
127 if ( expDiff ) {
128 /*--------------------------------------------------------------------
129 *--------------------------------------------------------------------*/
130 extSigZ[indexWordHi( 5 )] = sig96B;
131 extSigZ[indexWord( 5, 3 )] = bWPtr[indexWord( 4, 2 )];
132 extSigZ[indexWord( 5, 2 )] = bWPtr[indexWord( 4, 1 )];
133 extSigZ[indexWord( 5, 1 )] = bWPtr[indexWord( 4, 0 )];
134 extSigZ[indexWord( 5, 0 )] = 0;
135 softfloat_shiftRightJam160M( extSigZ, expDiff, extSigZ );
136 sig96B = extSigZ[indexWordHi( 5 )];
137 carry = 0;
138 if ( negateB ) {
139 sig96B = ~sig96B;
140 wordSigZ = extSigZ[indexWordLo( 5 )];
141 extSigZ[indexWordLo( 5 )] = -wordSigZ;
142 carry = ! wordSigZ;
143 }
144 carry =
145 (*addCarryMRoutinePtr)(
146 3,
147 &aWPtr[indexMultiwordLo( 4, 3 )],
148 &extSigZ[indexMultiword( 5, 3, 1 )],
149 carry,
150 &extSigZ[indexMultiword( 5, 3, 1 )]
151 );
152 wordSigZ = sig96A + sig96B + carry;
153 } else {
154 /*--------------------------------------------------------------------
155 *--------------------------------------------------------------------*/
156 extSigZ[indexWordLo( 5 )] = 0;
157 carry =
158 (*addCarryMRoutinePtr)(
159 3,
160 &aWPtr[indexMultiwordLo( 4, 3 )],
161 &bWPtr[indexMultiwordLo( 4, 3 )],
162 negateB,
163 &extSigZ[indexMultiword( 5, 3, 1 )]
164 );
165 if ( negateB ) {
166 wordSigZ = sig96A + ~sig96B + carry;
167 if ( wordSigZ & 0x80000000 ) {
168 signZ = ! signZ;
169 carry =
170 softfloat_addComplCarry96M(
171 &bWPtr[indexMultiwordLo( 4, 3 )],
172 &aWPtr[indexMultiwordLo( 4, 3 )],
173 1,
174 &extSigZ[indexMultiword( 5, 3, 1 )]
175 );
176 wordSigZ = sig96B + ~sig96A + carry;
177 } else {
178 if (
179 ! wordSigZ && ! extSigZ[indexWord( 5, 3 )]
180 && ! ( extSigZ[indexWord( 5, 2 )]
181 | extSigZ[indexWord( 5, 1 )]
182 | extSigZ[indexWord( 5, 0 )]
183 )
184 ) {
185 signZ = (softfloat_roundingMode == softfloat_round_min);
186 zWPtr[indexWordHi( 4 )] = packToF128UI96( signZ, 0, 0 );
187 zWPtr[indexWord( 4, 2 )] = 0;
188 zWPtr[indexWord( 4, 1 )] = 0;
189 zWPtr[indexWord( 4, 0 )] = 0;
190 return;
191 }
192 }
193 } else {
194 wordSigZ = sig96A + sig96B + carry;
195 }
196 }
197 extSigZ[indexWordHi( 5 )] = wordSigZ;
198 /*------------------------------------------------------------------------
199 *------------------------------------------------------------------------*/
200 roundPackRoutinePtr = softfloat_normRoundPackMToF128M;
201 if ( 0x00010000 <= wordSigZ ) {
202 if ( 0x00020000 <= wordSigZ ) {
203 ++expA;
204 softfloat_shortShiftRightJam160M( extSigZ, 1, extSigZ );
205 }
206 roundPackRoutinePtr = softfloat_roundPackMToF128M;
207 }
208 (*roundPackRoutinePtr)( signZ, expA, extSigZ, zWPtr );
209
210}
211
deps/SoftFloat-3d/source/s_addM.c deleted-70
......@@ -1,70 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_addM
42
43void
44 softfloat_addM(
45 uint_fast8_t size_words,
46 const uint32_t *aPtr,
47 const uint32_t *bPtr,
48 uint32_t *zPtr
49 )
50{
51 unsigned int index, lastIndex;
52 uint_fast8_t carry;
53 uint32_t wordA, wordZ;
54
55 index = indexWordLo( size_words );
56 lastIndex = indexWordHi( size_words );
57 carry = 0;
58 for (;;) {
59 wordA = aPtr[index];
60 wordZ = wordA + bPtr[index] + carry;
61 zPtr[index] = wordZ;
62 if ( index == lastIndex ) break;
63 if ( wordZ != wordA ) carry = (wordZ < wordA);
64 index += wordIncr;
65 }
66
67}
68
69#endif
70
deps/SoftFloat-3d/source/s_addMagsExtF80.c deleted-156
......@@ -1,156 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t
45 softfloat_addMagsExtF80(
46 uint_fast16_t uiA64,
47 uint_fast64_t uiA0,
48 uint_fast16_t uiB64,
49 uint_fast64_t uiB0,
50 bool signZ
51 )
52{
53 int_fast32_t expA;
54 uint_fast64_t sigA;
55 int_fast32_t expB;
56 uint_fast64_t sigB;
57 int_fast32_t expDiff;
58 uint_fast16_t uiZ64;
59 uint_fast64_t uiZ0, sigZ, sigZExtra;
60 struct exp32_sig64 normExpSig;
61 int_fast32_t expZ;
62 struct uint64_extra sig64Extra;
63 struct uint128 uiZ;
64 union { struct extFloat80M s; extFloat80_t f; } uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 expA = expExtF80UI64( uiA64 );
69 sigA = uiA0;
70 expB = expExtF80UI64( uiB64 );
71 sigB = uiB0;
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 expDiff = expA - expB;
75 if ( ! expDiff ) {
76 if ( expA == 0x7FFF ) {
77 if ( (sigA | sigB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
78 goto propagateNaN;
79 }
80 uiZ64 = uiA64;
81 uiZ0 = uiA0;
82 goto uiZ;
83 }
84 sigZ = sigA + sigB;
85 sigZExtra = 0;
86 if ( ! expA ) {
87 normExpSig = softfloat_normSubnormalExtF80Sig( sigZ );
88 expZ = normExpSig.exp + 1;
89 sigZ = normExpSig.sig;
90 goto roundAndPack;
91 }
92 expZ = expA;
93 goto shiftRight1;
94 }
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 if ( expDiff < 0 ) {
98 if ( expB == 0x7FFF ) {
99 if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
100 uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
101 uiZ0 = uiB0;
102 goto uiZ;
103 }
104 expZ = expB;
105 if ( ! expA ) {
106 ++expDiff;
107 sigZExtra = 0;
108 if ( ! expDiff ) goto newlyAligned;
109 }
110 sig64Extra = softfloat_shiftRightJam64Extra( sigA, 0, -expDiff );
111 sigA = sig64Extra.v;
112 sigZExtra = sig64Extra.extra;
113 } else {
114 if ( expA == 0x7FFF ) {
115 if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
116 uiZ64 = uiA64;
117 uiZ0 = uiA0;
118 goto uiZ;
119 }
120 expZ = expA;
121 if ( ! expB ) {
122 --expDiff;
123 sigZExtra = 0;
124 if ( ! expDiff ) goto newlyAligned;
125 }
126 sig64Extra = softfloat_shiftRightJam64Extra( sigB, 0, expDiff );
127 sigB = sig64Extra.v;
128 sigZExtra = sig64Extra.extra;
129 }
130 newlyAligned:
131 sigZ = sigA + sigB;
132 if ( sigZ & UINT64_C( 0x8000000000000000 ) ) goto roundAndPack;
133 /*------------------------------------------------------------------------
134 *------------------------------------------------------------------------*/
135 shiftRight1:
136 sig64Extra = softfloat_shortShiftRightJam64Extra( sigZ, sigZExtra, 1 );
137 sigZ = sig64Extra.v | UINT64_C( 0x8000000000000000 );
138 sigZExtra = sig64Extra.extra;
139 ++expZ;
140 roundAndPack:
141 return
142 softfloat_roundPackToExtF80(
143 signZ, expZ, sigZ, sigZExtra, extF80_roundingPrecision );
144 /*------------------------------------------------------------------------
145 *------------------------------------------------------------------------*/
146 propagateNaN:
147 uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
148 uiZ64 = uiZ.v64;
149 uiZ0 = uiZ.v0;
150 uiZ:
151 uZ.s.signExp = uiZ64;
152 uZ.s.signif = uiZ0;
153 return uZ.f;
154
155}
156
deps/SoftFloat-3d/source/s_addMagsF128.c deleted-154
......@@ -1,154 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42
43float128_t
44 softfloat_addMagsF128(
45 uint_fast64_t uiA64,
46 uint_fast64_t uiA0,
47 uint_fast64_t uiB64,
48 uint_fast64_t uiB0,
49 bool signZ
50 )
51{
52 int_fast32_t expA;
53 struct uint128 sigA;
54 int_fast32_t expB;
55 struct uint128 sigB;
56 int_fast32_t expDiff;
57 struct uint128 uiZ, sigZ;
58 int_fast32_t expZ;
59 uint_fast64_t sigZExtra;
60 struct uint128_extra sig128Extra;
61 union ui128_f128 uZ;
62
63 expA = expF128UI64( uiA64 );
64 sigA.v64 = fracF128UI64( uiA64 );
65 sigA.v0 = uiA0;
66 expB = expF128UI64( uiB64 );
67 sigB.v64 = fracF128UI64( uiB64 );
68 sigB.v0 = uiB0;
69 expDiff = expA - expB;
70 if ( ! expDiff ) {
71 if ( expA == 0x7FFF ) {
72 if ( sigA.v64 | sigA.v0 | sigB.v64 | sigB.v0 ) goto propagateNaN;
73 uiZ.v64 = uiA64;
74 uiZ.v0 = uiA0;
75 goto uiZ;
76 }
77 sigZ = softfloat_add128( sigA.v64, sigA.v0, sigB.v64, sigB.v0 );
78 if ( ! expA ) {
79 uiZ.v64 = packToF128UI64( signZ, 0, sigZ.v64 );
80 uiZ.v0 = sigZ.v0;
81 goto uiZ;
82 }
83 expZ = expA;
84 sigZ.v64 |= UINT64_C( 0x0002000000000000 );
85 sigZExtra = 0;
86 goto shiftRight1;
87 }
88 if ( expDiff < 0 ) {
89 if ( expB == 0x7FFF ) {
90 if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
91 uiZ.v64 = packToF128UI64( signZ, 0x7FFF, 0 );
92 uiZ.v0 = 0;
93 goto uiZ;
94 }
95 expZ = expB;
96 if ( expA ) {
97 sigA.v64 |= UINT64_C( 0x0001000000000000 );
98 } else {
99 ++expDiff;
100 sigZExtra = 0;
101 if ( ! expDiff ) goto newlyAligned;
102 }
103 sig128Extra =
104 softfloat_shiftRightJam128Extra( sigA.v64, sigA.v0, 0, -expDiff );
105 sigA = sig128Extra.v;
106 sigZExtra = sig128Extra.extra;
107 } else {
108 if ( expA == 0x7FFF ) {
109 if ( sigA.v64 | sigA.v0 ) goto propagateNaN;
110 uiZ.v64 = uiA64;
111 uiZ.v0 = uiA0;
112 goto uiZ;
113 }
114 expZ = expA;
115 if ( expB ) {
116 sigB.v64 |= UINT64_C( 0x0001000000000000 );
117 } else {
118 --expDiff;
119 sigZExtra = 0;
120 if ( ! expDiff ) goto newlyAligned;
121 }
122 sig128Extra =
123 softfloat_shiftRightJam128Extra( sigB.v64, sigB.v0, 0, expDiff );
124 sigB = sig128Extra.v;
125 sigZExtra = sig128Extra.extra;
126 }
127 newlyAligned:
128 sigZ =
129 softfloat_add128(
130 sigA.v64 | UINT64_C( 0x0001000000000000 ),
131 sigA.v0,
132 sigB.v64,
133 sigB.v0
134 );
135 --expZ;
136 if ( sigZ.v64 < UINT64_C( 0x0002000000000000 ) ) goto roundAndPack;
137 ++expZ;
138 shiftRight1:
139 sig128Extra =
140 softfloat_shortShiftRightJam128Extra(
141 sigZ.v64, sigZ.v0, sigZExtra, 1 );
142 sigZ = sig128Extra.v;
143 sigZExtra = sig128Extra.extra;
144 roundAndPack:
145 return
146 softfloat_roundPackToF128( signZ, expZ, sigZ.v64, sigZ.v0, sigZExtra );
147 propagateNaN:
148 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
149 uiZ:
150 uZ.ui = uiZ;
151 return uZ.f;
152
153}
154
deps/SoftFloat-3d/source/s_addMagsF16.c deleted-183
......@@ -1,183 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t softfloat_addMagsF16( uint_fast16_t uiA, uint_fast16_t uiB )
45{
46 int_fast8_t expA;
47 uint_fast16_t sigA;
48 int_fast8_t expB;
49 uint_fast16_t sigB;
50 int_fast8_t expDiff;
51 uint_fast16_t uiZ;
52 bool signZ;
53 int_fast8_t expZ;
54 uint_fast16_t sigZ;
55 uint_fast16_t sigX, sigY;
56 int_fast8_t shiftDist;
57 uint_fast32_t sig32Z;
58 int_fast8_t roundingMode;
59 union ui16_f16 uZ;
60
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 expA = expF16UI( uiA );
64 sigA = fracF16UI( uiA );
65 expB = expF16UI( uiB );
66 sigB = fracF16UI( uiB );
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 expDiff = expA - expB;
70 if ( ! expDiff ) {
71 /*--------------------------------------------------------------------
72 *--------------------------------------------------------------------*/
73 if ( ! expA ) {
74 uiZ = uiA + sigB;
75 goto uiZ;
76 }
77 if ( expA == 0x1F ) {
78 if ( sigA | sigB ) goto propagateNaN;
79 uiZ = uiA;
80 goto uiZ;
81 }
82 signZ = signF16UI( uiA );
83 expZ = expA;
84 sigZ = 0x0800 + sigA + sigB;
85 if ( ! (sigZ & 1) && (expZ < 0x1E) ) {
86 sigZ >>= 1;
87 goto pack;
88 }
89 sigZ <<= 3;
90 } else {
91 /*--------------------------------------------------------------------
92 *--------------------------------------------------------------------*/
93 signZ = signF16UI( uiA );
94 if ( expDiff < 0 ) {
95 /*----------------------------------------------------------------
96 *----------------------------------------------------------------*/
97 if ( expB == 0x1F ) {
98 if ( sigB ) goto propagateNaN;
99 uiZ = packToF16UI( signZ, 0x1F, 0 );
100 goto uiZ;
101 }
102 if ( expDiff <= -13 ) {
103 uiZ = packToF16UI( signZ, expB, sigB );
104 if ( expA | sigA ) goto addEpsilon;
105 goto uiZ;
106 }
107 expZ = expB;
108 sigX = sigB | 0x0400;
109 sigY = sigA + (expA ? 0x0400 : sigA);
110 shiftDist = 19 + expDiff;
111 } else {
112 /*----------------------------------------------------------------
113 *----------------------------------------------------------------*/
114 uiZ = uiA;
115 if ( expA == 0x1F ) {
116 if ( sigA ) goto propagateNaN;
117 goto uiZ;
118 }
119 if ( 13 <= expDiff ) {
120 if ( expB | sigB ) goto addEpsilon;
121 goto uiZ;
122 }
123 expZ = expA;
124 sigX = sigA | 0x0400;
125 sigY = sigB + (expB ? 0x0400 : sigB);
126 shiftDist = 19 - expDiff;
127 }
128 sig32Z =
129 ((uint_fast32_t) sigX<<19) + ((uint_fast32_t) sigY<<shiftDist);
130 if ( sig32Z < 0x40000000 ) {
131 --expZ;
132 sig32Z <<= 1;
133 }
134 sigZ = sig32Z>>16;
135 if ( sig32Z & 0xFFFF ) {
136 sigZ |= 1;
137 } else {
138 if ( ! (sigZ & 0xF) && (expZ < 0x1E) ) {
139 sigZ >>= 4;
140 goto pack;
141 }
142 }
143 }
144 return softfloat_roundPackToF16( signZ, expZ, sigZ );
145 /*------------------------------------------------------------------------
146 *------------------------------------------------------------------------*/
147 propagateNaN:
148 uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
149 goto uiZ;
150 /*------------------------------------------------------------------------
151 *------------------------------------------------------------------------*/
152 addEpsilon:
153 roundingMode = softfloat_roundingMode;
154 if ( roundingMode != softfloat_round_near_even ) {
155 if (
156 roundingMode
157 == (signF16UI( uiZ ) ? softfloat_round_min
158 : softfloat_round_max)
159 ) {
160 ++uiZ;
161 if ( (uint16_t) (uiZ<<1) == 0xF800 ) {
162 softfloat_raiseFlags(
163 softfloat_flag_overflow | softfloat_flag_inexact );
164 }
165 }
166#ifdef SOFTFLOAT_ROUND_ODD
167 else if ( roundingMode == softfloat_round_odd ) {
168 uiZ |= 1;
169 }
170#endif
171 }
172 softfloat_exceptionFlags |= softfloat_flag_inexact;
173 goto uiZ;
174 /*------------------------------------------------------------------------
175 *------------------------------------------------------------------------*/
176 pack:
177 uiZ = packToF16UI( signZ, expZ, sigZ );
178 uiZ:
179 uZ.ui = uiZ;
180 return uZ.f;
181
182}
183
deps/SoftFloat-3d/source/s_addMagsF32.c deleted-126
......@@ -1,126 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42
43float32_t softfloat_addMagsF32( uint_fast32_t uiA, uint_fast32_t uiB )
44{
45 int_fast16_t expA;
46 uint_fast32_t sigA;
47 int_fast16_t expB;
48 uint_fast32_t sigB;
49 int_fast16_t expDiff;
50 uint_fast32_t uiZ;
51 bool signZ;
52 int_fast16_t expZ;
53 uint_fast32_t sigZ;
54 union ui32_f32 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 expA = expF32UI( uiA );
59 sigA = fracF32UI( uiA );
60 expB = expF32UI( uiB );
61 sigB = fracF32UI( uiB );
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 expDiff = expA - expB;
65 if ( ! expDiff ) {
66 /*--------------------------------------------------------------------
67 *--------------------------------------------------------------------*/
68 if ( ! expA ) {
69 uiZ = uiA + sigB;
70 goto uiZ;
71 }
72 if ( expA == 0xFF ) {
73 if ( sigA | sigB ) goto propagateNaN;
74 uiZ = uiA;
75 goto uiZ;
76 }
77 signZ = signF32UI( uiA );
78 expZ = expA;
79 sigZ = 0x01000000 + sigA + sigB;
80 if ( ! (sigZ & 1) && (expZ < 0xFE) ) {
81 uiZ = packToF32UI( signZ, expZ, sigZ>>1 );
82 goto uiZ;
83 }
84 sigZ <<= 6;
85 } else {
86 /*--------------------------------------------------------------------
87 *--------------------------------------------------------------------*/
88 signZ = signF32UI( uiA );
89 sigA <<= 6;
90 sigB <<= 6;
91 if ( expDiff < 0 ) {
92 if ( expB == 0xFF ) {
93 if ( sigB ) goto propagateNaN;
94 uiZ = packToF32UI( signZ, 0xFF, 0 );
95 goto uiZ;
96 }
97 expZ = expB;
98 sigA += expA ? 0x20000000 : sigA;
99 sigA = softfloat_shiftRightJam32( sigA, -expDiff );
100 } else {
101 if ( expA == 0xFF ) {
102 if ( sigA ) goto propagateNaN;
103 uiZ = uiA;
104 goto uiZ;
105 }
106 expZ = expA;
107 sigB += expB ? 0x20000000 : sigB;
108 sigB = softfloat_shiftRightJam32( sigB, expDiff );
109 }
110 sigZ = 0x20000000 + sigA + sigB;
111 if ( sigZ < 0x40000000 ) {
112 --expZ;
113 sigZ <<= 1;
114 }
115 }
116 return softfloat_roundPackToF32( signZ, expZ, sigZ );
117 /*------------------------------------------------------------------------
118 *------------------------------------------------------------------------*/
119 propagateNaN:
120 uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
121 uiZ:
122 uZ.ui = uiZ;
123 return uZ.f;
124
125}
126
deps/SoftFloat-3d/source/s_addMagsF64.c deleted-128
......@@ -1,128 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42
43float64_t
44 softfloat_addMagsF64( uint_fast64_t uiA, uint_fast64_t uiB, bool signZ )
45{
46 int_fast16_t expA;
47 uint_fast64_t sigA;
48 int_fast16_t expB;
49 uint_fast64_t sigB;
50 int_fast16_t expDiff;
51 uint_fast64_t uiZ;
52 int_fast16_t expZ;
53 uint_fast64_t sigZ;
54 union ui64_f64 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 expA = expF64UI( uiA );
59 sigA = fracF64UI( uiA );
60 expB = expF64UI( uiB );
61 sigB = fracF64UI( uiB );
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 expDiff = expA - expB;
65 if ( ! expDiff ) {
66 /*--------------------------------------------------------------------
67 *--------------------------------------------------------------------*/
68 if ( ! expA ) {
69 uiZ = uiA + sigB;
70 goto uiZ;
71 }
72 if ( expA == 0x7FF ) {
73 if ( sigA | sigB ) goto propagateNaN;
74 uiZ = uiA;
75 goto uiZ;
76 }
77 expZ = expA;
78 sigZ = UINT64_C( 0x0020000000000000 ) + sigA + sigB;
79 sigZ <<= 9;
80 } else {
81 /*--------------------------------------------------------------------
82 *--------------------------------------------------------------------*/
83 sigA <<= 9;
84 sigB <<= 9;
85 if ( expDiff < 0 ) {
86 if ( expB == 0x7FF ) {
87 if ( sigB ) goto propagateNaN;
88 uiZ = packToF64UI( signZ, 0x7FF, 0 );
89 goto uiZ;
90 }
91 expZ = expB;
92 if ( expA ) {
93 sigA += UINT64_C( 0x2000000000000000 );
94 } else {
95 sigA <<= 1;
96 }
97 sigA = softfloat_shiftRightJam64( sigA, -expDiff );
98 } else {
99 if ( expA == 0x7FF ) {
100 if ( sigA ) goto propagateNaN;
101 uiZ = uiA;
102 goto uiZ;
103 }
104 expZ = expA;
105 if ( expB ) {
106 sigB += UINT64_C( 0x2000000000000000 );
107 } else {
108 sigB <<= 1;
109 }
110 sigB = softfloat_shiftRightJam64( sigB, expDiff );
111 }
112 sigZ = UINT64_C( 0x2000000000000000 ) + sigA + sigB;
113 if ( sigZ < UINT64_C( 0x4000000000000000 ) ) {
114 --expZ;
115 sigZ <<= 1;
116 }
117 }
118 return softfloat_roundPackToF64( signZ, expZ, sigZ );
119 /*------------------------------------------------------------------------
120 *------------------------------------------------------------------------*/
121 propagateNaN:
122 uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
123 uiZ:
124 uZ.ui = uiZ;
125 return uZ.f;
126
127}
128
deps/SoftFloat-3d/source/s_approxRecip32_1.c deleted-66
......@@ -1,66 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_approxRecip32_1
41
42extern const uint16_t softfloat_approxRecip_1k0s[16];
43extern const uint16_t softfloat_approxRecip_1k1s[16];
44
45uint32_t softfloat_approxRecip32_1( uint32_t a )
46{
47 int index;
48 uint16_t eps, r0;
49 uint32_t sigma0;
50 uint_fast32_t r;
51 uint32_t sqrSigma0;
52
53 index = a>>27 & 0xF;
54 eps = (uint16_t) (a>>11);
55 r0 = softfloat_approxRecip_1k0s[index]
56 - ((softfloat_approxRecip_1k1s[index] * (uint_fast32_t) eps)>>20);
57 sigma0 = ~(uint_fast32_t) ((r0 * (uint_fast64_t) a)>>7);
58 r = ((uint_fast32_t) r0<<16) + ((r0 * (uint_fast64_t) sigma0)>>24);
59 sqrSigma0 = ((uint_fast64_t) sigma0 * sigma0)>>32;
60 r += ((uint32_t) r * (uint_fast64_t) sqrSigma0)>>48;
61 return r;
62
63}
64
65#endif
66
deps/SoftFloat-3d/source/s_approxRecipSqrt32_1.c deleted-73
......@@ -1,73 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_approxRecipSqrt32_1
41
42extern const uint16_t softfloat_approxRecipSqrt_1k0s[];
43extern const uint16_t softfloat_approxRecipSqrt_1k1s[];
44
45uint32_t softfloat_approxRecipSqrt32_1( unsigned int oddExpA, uint32_t a )
46{
47 int index;
48 uint16_t eps, r0;
49 uint_fast32_t ESqrR0;
50 uint32_t sigma0;
51 uint_fast32_t r;
52 uint32_t sqrSigma0;
53
54 index = (a>>27 & 0xE) + oddExpA;
55 eps = (uint16_t) (a>>12);
56 r0 = softfloat_approxRecipSqrt_1k0s[index]
57 - ((softfloat_approxRecipSqrt_1k1s[index] * (uint_fast32_t) eps)
58 >>20);
59 ESqrR0 = (uint_fast32_t) r0 * r0;
60 if ( ! oddExpA ) ESqrR0 <<= 1;
61 sigma0 = ~(uint_fast32_t) (((uint32_t) ESqrR0 * (uint_fast64_t) a)>>23);
62 r = ((uint_fast32_t) r0<<16) + ((r0 * (uint_fast64_t) sigma0)>>25);
63 sqrSigma0 = ((uint_fast64_t) sigma0 * sigma0)>>32;
64 r += ((uint32_t) ((r>>1) + (r>>3) - ((uint_fast32_t) r0<<14))
65 * (uint_fast64_t) sqrSigma0)
66 >>48;
67 if ( ! (r & 0x80000000) ) r = 0x80000000;
68 return r;
69
70}
71
72#endif
73
deps/SoftFloat-3d/source/s_approxRecipSqrt_1Ks.c deleted-49
......@@ -1,49 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40
41const uint16_t softfloat_approxRecipSqrt_1k0s[16] = {
42 0xB4C9, 0xFFAB, 0xAA7D, 0xF11C, 0xA1C5, 0xE4C7, 0x9A43, 0xDA29,
43 0x93B5, 0xD0E5, 0x8DED, 0xC8B7, 0x88C6, 0xC16D, 0x8424, 0xBAE1
44};
45const uint16_t softfloat_approxRecipSqrt_1k1s[16] = {
46 0xA5A5, 0xEA42, 0x8C21, 0xC62D, 0x788F, 0xAA7F, 0x6928, 0x94B6,
47 0x5CC7, 0x8335, 0x52A6, 0x74E2, 0x4A3E, 0x68FE, 0x432B, 0x5EFD
48};
49
deps/SoftFloat-3d/source/s_approxRecip_1Ks.c deleted-49
......@@ -1,49 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40
41const uint16_t softfloat_approxRecip_1k0s[16] = {
42 0xFFC4, 0xF0BE, 0xE363, 0xD76F, 0xCCAD, 0xC2F0, 0xBA16, 0xB201,
43 0xAA97, 0xA3C6, 0x9D7A, 0x97A6, 0x923C, 0x8D32, 0x887E, 0x8417
44};
45const uint16_t softfloat_approxRecip_1k1s[16] = {
46 0xF0F1, 0xD62C, 0xBFA1, 0xAC77, 0x9C0A, 0x8DDB, 0x8185, 0x76BA,
47 0x6D3B, 0x64D4, 0x5D5C, 0x56B1, 0x50B6, 0x4B55, 0x4679, 0x4211
48};
49
deps/SoftFloat-3d/source/s_compare128M.c deleted-62
......@@ -1,62 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_compare128M
42
43int_fast8_t softfloat_compare128M( const uint32_t *aPtr, const uint32_t *bPtr )
44{
45 unsigned int index, lastIndex;
46 uint32_t wordA, wordB;
47
48 index = indexWordHi( 4 );
49 lastIndex = indexWordLo( 4 );
50 for (;;) {
51 wordA = aPtr[index];
52 wordB = bPtr[index];
53 if ( wordA != wordB ) return (wordA < wordB) ? -1 : 1;
54 if ( index == lastIndex ) break;
55 index -= wordIncr;
56 }
57 return 0;
58
59}
60
61#endif
62
deps/SoftFloat-3d/source/s_compare96M.c deleted-62
......@@ -1,62 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_compare96M
42
43int_fast8_t softfloat_compare96M( const uint32_t *aPtr, const uint32_t *bPtr )
44{
45 unsigned int index, lastIndex;
46 uint32_t wordA, wordB;
47
48 index = indexWordHi( 3 );
49 lastIndex = indexWordLo( 3 );
50 for (;;) {
51 wordA = aPtr[index];
52 wordB = bPtr[index];
53 if ( wordA != wordB ) return (wordA < wordB) ? -1 : 1;
54 if ( index == lastIndex ) break;
55 index -= wordIncr;
56 }
57 return 0;
58
59}
60
61#endif
62
deps/SoftFloat-3d/source/s_compareNonnormExtF80M.c deleted-111
......@@ -1,111 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat_types.h"
41
42int
43 softfloat_compareNonnormExtF80M(
44 const struct extFloat80M *aSPtr, const struct extFloat80M *bSPtr )
45{
46 uint_fast16_t uiA64, uiB64;
47 uint64_t sigA;
48 bool signB;
49 uint64_t sigB;
50 int32_t expA, expB;
51
52 /*------------------------------------------------------------------------
53 *------------------------------------------------------------------------*/
54 uiA64 = aSPtr->signExp;
55 uiB64 = bSPtr->signExp;
56 sigA = aSPtr->signif;
57 signB = signExtF80UI64( uiB64 );
58 sigB = bSPtr->signif;
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 if ( (uiA64 ^ uiB64) & 0x8000 ) {
62 if ( ! (sigA | sigB) ) return 0;
63 goto resultFromSignB;
64 }
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 expA = expExtF80UI64( uiA64 );
68 expB = expExtF80UI64( uiB64 );
69 if ( expA == 0x7FFF ) {
70 if (expB == 0x7FFF) return 0;
71 signB = ! signB;
72 goto resultFromSignB;
73 }
74 if ( expB == 0x7FFF ) {
75 goto resultFromSignB;
76 }
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 if ( ! expA ) expA = 1;
80 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
81 if ( sigA ) {
82 expA += softfloat_normExtF80SigM( &sigA );
83 } else {
84 expA = -128;
85 }
86 }
87 if ( ! expB ) expB = 1;
88 if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
89 if ( sigB ) {
90 expB += softfloat_normExtF80SigM( &sigB );
91 } else {
92 expB = -128;
93 }
94 }
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 if ( signB ) {
98 if ( expA < expB ) return 1;
99 if ( (expB < expA) || (sigB < sigA) ) return -1;
100 } else {
101 if ( expB < expA ) return 1;
102 if ( (expA < expB) || (sigA < sigB) ) return -1;
103 }
104 return (sigA != sigB);
105 /*------------------------------------------------------------------------
106 *------------------------------------------------------------------------*/
107 resultFromSignB:
108 return signB ? 1 : -1;
109
110}
111
deps/SoftFloat-3d/source/s_countLeadingZeros16.c deleted-60
......@@ -1,60 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_countLeadingZeros16
41
42#define softfloat_countLeadingZeros16 softfloat_countLeadingZeros16
43#include "primitives.h"
44
45uint_fast8_t softfloat_countLeadingZeros16( uint16_t a )
46{
47 uint_fast8_t count;
48
49 count = 8;
50 if ( 0x100 <= a ) {
51 count = 0;
52 a >>= 8;
53 }
54 count += softfloat_countLeadingZeros8[a];
55 return count;
56
57}
58
59#endif
60
deps/SoftFloat-3d/source/s_countLeadingZeros32.c deleted-64
......@@ -1,64 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_countLeadingZeros32
41
42#define softfloat_countLeadingZeros32 softfloat_countLeadingZeros32
43#include "primitives.h"
44
45uint_fast8_t softfloat_countLeadingZeros32( uint32_t a )
46{
47 uint_fast8_t count;
48
49 count = 0;
50 if ( a < 0x10000 ) {
51 count = 16;
52 a <<= 16;
53 }
54 if ( a < 0x1000000 ) {
55 count += 8;
56 a <<= 8;
57 }
58 count += softfloat_countLeadingZeros8[a>>24];
59 return count;
60
61}
62
63#endif
64
deps/SoftFloat-3d/source/s_countLeadingZeros64.c deleted-73
......@@ -1,73 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_countLeadingZeros64
41
42#define softfloat_countLeadingZeros64 softfloat_countLeadingZeros64
43#include "primitives.h"
44
45uint_fast8_t softfloat_countLeadingZeros64( uint64_t a )
46{
47 uint_fast8_t count;
48 uint32_t a32;
49
50 count = 0;
51 a32 = a>>32;
52 if ( ! a32 ) {
53 count = 32;
54 a32 = a;
55 }
56 /*------------------------------------------------------------------------
57 | From here, result is current count + count leading zeros of `a32'.
58 *------------------------------------------------------------------------*/
59 if ( a32 < 0x10000 ) {
60 count += 16;
61 a32 <<= 16;
62 }
63 if ( a32 < 0x1000000 ) {
64 count += 8;
65 a32 <<= 8;
66 }
67 count += softfloat_countLeadingZeros8[a32>>24];
68 return count;
69
70}
71
72#endif
73
deps/SoftFloat-3d/source/s_countLeadingZeros8.c deleted-59
......@@ -1,59 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40
41const uint_least8_t softfloat_countLeadingZeros8[256] = {
42 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
43 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
44 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
45 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
46 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
47 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
48 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
49 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
50 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
51 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
52 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
53 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
54 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
55 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
56 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
58};
59
deps/SoftFloat-3d/source/s_eq128.c deleted-51
......@@ -1,51 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40
41#ifndef softfloat_eq128
42
43bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
44{
45
46 return (a64 == b64) && (a0 == b0);
47
48}
49
50#endif
51
deps/SoftFloat-3d/source/s_invalidExtF80M.c deleted-49
......@@ -1,49 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include "platform.h"
38#include "specialize.h"
39#include "softfloat.h"
40
41void softfloat_invalidExtF80M( struct extFloat80M *zSPtr )
42{
43
44 softfloat_raiseFlags( softfloat_flag_invalid );
45 zSPtr->signExp = defaultNaNExtF80UI64;
46 zSPtr->signif = defaultNaNExtF80UI0;
47
48}
49
deps/SoftFloat-3d/source/s_invalidF128M.c deleted-53
......@@ -1,53 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43void softfloat_invalidF128M( uint32_t *zWPtr )
44{
45
46 softfloat_raiseFlags( softfloat_flag_invalid );
47 zWPtr[indexWord( 4, 3 )] = defaultNaNF128UI96;
48 zWPtr[indexWord( 4, 2 )] = defaultNaNF128UI64;
49 zWPtr[indexWord( 4, 1 )] = defaultNaNF128UI32;
50 zWPtr[indexWord( 4, 0 )] = defaultNaNF128UI0;
51
52}
53
deps/SoftFloat-3d/source/s_isNaNF128M.c deleted-57
......@@ -1,57 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "primitives.h"
41
42/*----------------------------------------------------------------------------
43*----------------------------------------------------------------------------*/
44bool softfloat_isNaNF128M( const uint32_t *aWPtr )
45{
46 uint32_t uiA96;
47
48 uiA96 = aWPtr[indexWordHi( 4 )];
49 if ( (~uiA96 & 0x7FFF0000) != 0 ) return false;
50 return
51 ((uiA96 & 0x0000FFFF) != 0)
52 || ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
53 | aWPtr[indexWord( 4, 0 )])
54 != 0);
55
56}
57
deps/SoftFloat-3d/source/s_le128.c deleted-51
......@@ -1,51 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40
41#ifndef softfloat_le128
42
43bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
44{
45
46 return (a64 < b64) || ((a64 == b64) && (a0 <= b0));
47
48}
49
50#endif
51
deps/SoftFloat-3d/source/s_lt128.c deleted-51
......@@ -1,51 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40
41#ifndef softfloat_lt128
42
43bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
44{
45
46 return (a64 < b64) || ((a64 == b64) && (a0 < b0));
47
48}
49
50#endif
51
deps/SoftFloat-3d/source/s_mul128By32.c deleted-58
......@@ -1,58 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_mul128By32
42
43struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b )
44{
45 struct uint128 z;
46 uint_fast64_t mid;
47 uint_fast32_t carry;
48
49 z.v0 = a0 * b;
50 mid = (uint_fast64_t) (uint32_t) (a0>>32) * b;
51 carry = (uint32_t) ((uint_fast32_t) (z.v0>>32) - (uint_fast32_t) mid);
52 z.v64 = a64 * b + (uint_fast32_t) ((mid + carry)>>32);
53 return z;
54
55}
56
57#endif
58
deps/SoftFloat-3d/source/s_mul128MTo256M.c deleted-100
......@@ -1,100 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_mul128MTo256M
42
43void
44 softfloat_mul128MTo256M(
45 const uint32_t *aPtr, const uint32_t *bPtr, uint32_t *zPtr )
46{
47 uint32_t *lastZPtr, wordB;
48 uint64_t dwordProd;
49 uint32_t wordZ;
50 uint_fast8_t carry;
51
52 bPtr += indexWordLo( 4 );
53 lastZPtr = zPtr + indexMultiwordHi( 8, 5 );
54 zPtr += indexMultiwordLo( 8, 5 );
55 wordB = *bPtr;
56 dwordProd = (uint64_t) aPtr[indexWord( 4, 0 )] * wordB;
57 zPtr[indexWord( 5, 0 )] = dwordProd;
58 dwordProd = (uint64_t) aPtr[indexWord( 4, 1 )] * wordB + (dwordProd>>32);
59 zPtr[indexWord( 5, 1 )] = dwordProd;
60 dwordProd = (uint64_t) aPtr[indexWord( 4, 2 )] * wordB + (dwordProd>>32);
61 zPtr[indexWord( 5, 2 )] = dwordProd;
62 dwordProd = (uint64_t) aPtr[indexWord( 4, 3 )] * wordB + (dwordProd>>32);
63 zPtr[indexWord( 5, 3 )] = dwordProd;
64 zPtr[indexWord( 5, 4 )] = dwordProd>>32;
65 do {
66 bPtr += wordIncr;
67 zPtr += wordIncr;
68 wordB = *bPtr;
69 dwordProd = (uint64_t) aPtr[indexWord( 4, 0 )] * wordB;
70 wordZ = zPtr[indexWord( 5, 0 )] + (uint32_t) dwordProd;
71 zPtr[indexWord( 5, 0 )] = wordZ;
72 carry = (wordZ < (uint32_t) dwordProd);
73 dwordProd =
74 (uint64_t) aPtr[indexWord( 4, 1 )] * wordB + (dwordProd>>32);
75 wordZ = zPtr[indexWord( 5, 1 )] + (uint32_t) dwordProd + carry;
76 zPtr[indexWord( 5, 1 )] = wordZ;
77 if ( wordZ != (uint32_t) dwordProd ) {
78 carry = (wordZ < (uint32_t) dwordProd);
79 }
80 dwordProd =
81 (uint64_t) aPtr[indexWord( 4, 2 )] * wordB + (dwordProd>>32);
82 wordZ = zPtr[indexWord( 5, 2 )] + (uint32_t) dwordProd + carry;
83 zPtr[indexWord( 5, 2 )] = wordZ;
84 if ( wordZ != (uint32_t) dwordProd ) {
85 carry = (wordZ < (uint32_t) dwordProd);
86 }
87 dwordProd =
88 (uint64_t) aPtr[indexWord( 4, 3 )] * wordB + (dwordProd>>32);
89 wordZ = zPtr[indexWord( 5, 3 )] + (uint32_t) dwordProd + carry;
90 zPtr[indexWord( 5, 3 )] = wordZ;
91 if ( wordZ != (uint32_t) dwordProd ) {
92 carry = (wordZ < (uint32_t) dwordProd);
93 }
94 zPtr[indexWord( 5, 4 )] = (dwordProd>>32) + carry;
95 } while ( zPtr != lastZPtr );
96
97}
98
99#endif
100
deps/SoftFloat-3d/source/s_mul128To256M.c deleted-71
......@@ -1,71 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_mul128To256M
41
42#define softfloat_mul128To256M softfloat_mul128To256M
43#include "primitives.h"
44
45void
46 softfloat_mul128To256M(
47 uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0, uint64_t *zPtr )
48{
49 struct uint128 p0, p64, p128;
50 uint_fast64_t z64, z128, z192;
51
52 p0 = softfloat_mul64To128( a0, b0 );
53 zPtr[indexWord( 4, 0 )] = p0.v0;
54 p64 = softfloat_mul64To128( a64, b0 );
55 z64 = p64.v0 + p0.v64;
56 z128 = p64.v64 + (z64 < p64.v0);
57 p128 = softfloat_mul64To128( a64, b64 );
58 z128 += p128.v0;
59 z192 = p128.v64 + (z128 < p128.v0);
60 p64 = softfloat_mul64To128( a0, b64 );
61 z64 += p64.v0;
62 zPtr[indexWord( 4, 1 )] = z64;
63 p64.v64 += (z64 < p64.v0);
64 z128 += p64.v64;
65 zPtr[indexWord( 4, 2 )] = z128;
66 zPtr[indexWord( 4, 3 )] = z192 + (z128 < p64.v64);
67
68}
69
70#endif
71
deps/SoftFloat-3d/source/s_mul64ByShifted32To128.c deleted-56
......@@ -1,56 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_mul64ByShifted32To128
42
43struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b )
44{
45 uint_fast64_t mid;
46 struct uint128 z;
47
48 mid = (uint_fast64_t) (uint32_t) a * b;
49 z.v0 = mid<<32;
50 z.v64 = (uint_fast64_t) (uint32_t) (a>>32) * b + (mid>>32);
51 return z;
52
53}
54
55#endif
56
deps/SoftFloat-3d/source/s_mul64To128.c deleted-66
......@@ -1,66 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_mul64To128
42
43struct uint128 softfloat_mul64To128( uint64_t a, uint64_t b )
44{
45 uint32_t a32, a0, b32, b0;
46 struct uint128 z;
47 uint64_t mid1, mid;
48
49 a32 = a>>32;
50 a0 = a;
51 b32 = b>>32;
52 b0 = b;
53 z.v0 = (uint_fast64_t) a0 * b0;
54 mid1 = (uint_fast64_t) a32 * b0;
55 mid = mid1 + (uint_fast64_t) a0 * b32;
56 z.v64 = (uint_fast64_t) a32 * b32;
57 z.v64 += (uint_fast64_t) (mid < mid1)<<32 | mid>>32;
58 mid <<= 32;
59 z.v0 += mid;
60 z.v64 += (z.v0 < mid);
61 return z;
62
63}
64
65#endif
66
deps/SoftFloat-3d/source/s_mul64To128M.c deleted-68
......@@ -1,68 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_mul64To128M
42
43void softfloat_mul64To128M( uint64_t a, uint64_t b, uint32_t *zPtr )
44{
45 uint32_t a32, a0, b32, b0;
46 uint64_t z0, mid1, z64, mid;
47
48 a32 = a>>32;
49 a0 = a;
50 b32 = b>>32;
51 b0 = b;
52 z0 = (uint64_t) a0 * b0;
53 mid1 = (uint64_t) a32 * b0;
54 mid = mid1 + (uint64_t) a0 * b32;
55 z64 = (uint64_t) a32 * b32;
56 z64 += (uint64_t) (mid < mid1)<<32 | mid>>32;
57 mid <<= 32;
58 z0 += mid;
59 zPtr[indexWord( 4, 1 )] = z0>>32;
60 zPtr[indexWord( 4, 0 )] = z0;
61 z64 += (z0 < mid);
62 zPtr[indexWord( 4, 3 )] = z64>>32;
63 zPtr[indexWord( 4, 2 )] = z64;
64
65}
66
67#endif
68
deps/SoftFloat-3d/source/s_mulAddF128.c deleted-350
......@@ -1,350 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t
45 softfloat_mulAddF128(
46 uint_fast64_t uiA64,
47 uint_fast64_t uiA0,
48 uint_fast64_t uiB64,
49 uint_fast64_t uiB0,
50 uint_fast64_t uiC64,
51 uint_fast64_t uiC0,
52 uint_fast8_t op
53 )
54{
55 bool signA;
56 int_fast32_t expA;
57 struct uint128 sigA;
58 bool signB;
59 int_fast32_t expB;
60 struct uint128 sigB;
61 bool signC;
62 int_fast32_t expC;
63 struct uint128 sigC;
64 bool signZ;
65 uint_fast64_t magBits;
66 struct uint128 uiZ;
67 struct exp32_sig128 normExpSig;
68 int_fast32_t expZ;
69 uint64_t sig256Z[4];
70 struct uint128 sigZ;
71 int_fast32_t shiftDist, expDiff;
72 struct uint128 x128;
73 uint64_t sig256C[4];
74 static uint64_t zero256[4] = INIT_UINTM4( 0, 0, 0, 0 );
75 uint_fast64_t sigZExtra, sig256Z0;
76 union ui128_f128 uZ;
77
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 signA = signF128UI64( uiA64 );
81 expA = expF128UI64( uiA64 );
82 sigA.v64 = fracF128UI64( uiA64 );
83 sigA.v0 = uiA0;
84 signB = signF128UI64( uiB64 );
85 expB = expF128UI64( uiB64 );
86 sigB.v64 = fracF128UI64( uiB64 );
87 sigB.v0 = uiB0;
88 signC = signF128UI64( uiC64 ) ^ (op == softfloat_mulAdd_subC);
89 expC = expF128UI64( uiC64 );
90 sigC.v64 = fracF128UI64( uiC64 );
91 sigC.v0 = uiC0;
92 signZ = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
93 /*------------------------------------------------------------------------
94 *------------------------------------------------------------------------*/
95 if ( expA == 0x7FFF ) {
96 if (
97 (sigA.v64 | sigA.v0) || ((expB == 0x7FFF) && (sigB.v64 | sigB.v0))
98 ) {
99 goto propagateNaN_ABC;
100 }
101 magBits = expB | sigB.v64 | sigB.v0;
102 goto infProdArg;
103 }
104 if ( expB == 0x7FFF ) {
105 if ( sigB.v64 | sigB.v0 ) goto propagateNaN_ABC;
106 magBits = expA | sigA.v64 | sigA.v0;
107 goto infProdArg;
108 }
109 if ( expC == 0x7FFF ) {
110 if ( sigC.v64 | sigC.v0 ) {
111 uiZ.v64 = 0;
112 uiZ.v0 = 0;
113 goto propagateNaN_ZC;
114 }
115 uiZ.v64 = uiC64;
116 uiZ.v0 = uiC0;
117 goto uiZ;
118 }
119 /*------------------------------------------------------------------------
120 *------------------------------------------------------------------------*/
121 if ( ! expA ) {
122 if ( ! (sigA.v64 | sigA.v0) ) goto zeroProd;
123 normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
124 expA = normExpSig.exp;
125 sigA = normExpSig.sig;
126 }
127 if ( ! expB ) {
128 if ( ! (sigB.v64 | sigB.v0) ) goto zeroProd;
129 normExpSig = softfloat_normSubnormalF128Sig( sigB.v64, sigB.v0 );
130 expB = normExpSig.exp;
131 sigB = normExpSig.sig;
132 }
133 /*------------------------------------------------------------------------
134 *------------------------------------------------------------------------*/
135 expZ = expA + expB - 0x3FFE;
136 sigA.v64 |= UINT64_C( 0x0001000000000000 );
137 sigB.v64 |= UINT64_C( 0x0001000000000000 );
138 sigA = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 8 );
139 sigB = softfloat_shortShiftLeft128( sigB.v64, sigB.v0, 15 );
140 softfloat_mul128To256M( sigA.v64, sigA.v0, sigB.v64, sigB.v0, sig256Z );
141 sigZ.v64 = sig256Z[indexWord( 4, 3 )];
142 sigZ.v0 = sig256Z[indexWord( 4, 2 )];
143 shiftDist = 0;
144 if ( ! (sigZ.v64 & UINT64_C( 0x0100000000000000 )) ) {
145 --expZ;
146 shiftDist = -1;
147 }
148 if ( ! expC ) {
149 if ( ! (sigC.v64 | sigC.v0) ) {
150 shiftDist += 8;
151 goto sigZ;
152 }
153 normExpSig = softfloat_normSubnormalF128Sig( sigC.v64, sigC.v0 );
154 expC = normExpSig.exp;
155 sigC = normExpSig.sig;
156 }
157 sigC.v64 |= UINT64_C( 0x0001000000000000 );
158 sigC = softfloat_shortShiftLeft128( sigC.v64, sigC.v0, 8 );
159 /*------------------------------------------------------------------------
160 *------------------------------------------------------------------------*/
161 expDiff = expZ - expC;
162 if ( expDiff < 0 ) {
163 expZ = expC;
164 if ( (signZ == signC) || (expDiff < -1) ) {
165 shiftDist -= expDiff;
166 if ( shiftDist ) {
167 sigZ =
168 softfloat_shiftRightJam128( sigZ.v64, sigZ.v0, shiftDist );
169 }
170 } else {
171 if ( ! shiftDist ) {
172 x128 =
173 softfloat_shortShiftRight128(
174 sig256Z[indexWord( 4, 1 )], sig256Z[indexWord( 4, 0 )],
175 1
176 );
177 sig256Z[indexWord( 4, 1 )] = (sigZ.v0<<63) | x128.v64;
178 sig256Z[indexWord( 4, 0 )] = x128.v0;
179 sigZ = softfloat_shortShiftRight128( sigZ.v64, sigZ.v0, 1 );
180 sig256Z[indexWord( 4, 3 )] = sigZ.v64;
181 sig256Z[indexWord( 4, 2 )] = sigZ.v0;
182 }
183 }
184 } else {
185 if ( shiftDist ) softfloat_add256M( sig256Z, sig256Z, sig256Z );
186 if ( ! expDiff ) {
187 sigZ.v64 = sig256Z[indexWord( 4, 3 )];
188 sigZ.v0 = sig256Z[indexWord( 4, 2 )];
189 } else {
190 sig256C[indexWord( 4, 3 )] = sigC.v64;
191 sig256C[indexWord( 4, 2 )] = sigC.v0;
192 sig256C[indexWord( 4, 1 )] = 0;
193 sig256C[indexWord( 4, 0 )] = 0;
194 softfloat_shiftRightJam256M( sig256C, expDiff, sig256C );
195 }
196 }
197 /*------------------------------------------------------------------------
198 *------------------------------------------------------------------------*/
199 shiftDist = 8;
200 if ( signZ == signC ) {
201 /*--------------------------------------------------------------------
202 *--------------------------------------------------------------------*/
203 if ( expDiff <= 0 ) {
204 sigZ = softfloat_add128( sigC.v64, sigC.v0, sigZ.v64, sigZ.v0 );
205 } else {
206 softfloat_add256M( sig256Z, sig256C, sig256Z );
207 sigZ.v64 = sig256Z[indexWord( 4, 3 )];
208 sigZ.v0 = sig256Z[indexWord( 4, 2 )];
209 }
210 if ( sigZ.v64 & UINT64_C( 0x0200000000000000 ) ) {
211 ++expZ;
212 shiftDist = 9;
213 }
214 } else {
215 /*--------------------------------------------------------------------
216 *--------------------------------------------------------------------*/
217 if ( expDiff < 0 ) {
218 signZ = signC;
219 if ( expDiff < -1 ) {
220 sigZ =
221 softfloat_sub128( sigC.v64, sigC.v0, sigZ.v64, sigZ.v0 );
222 sigZExtra =
223 sig256Z[indexWord( 4, 1 )] | sig256Z[indexWord( 4, 0 )];
224 if ( sigZExtra ) {
225 sigZ = softfloat_sub128( sigZ.v64, sigZ.v0, 0, 1 );
226 }
227 if ( ! (sigZ.v64 & UINT64_C( 0x0100000000000000 )) ) {
228 --expZ;
229 shiftDist = 7;
230 }
231 goto shiftRightRoundPack;
232 } else {
233 sig256C[indexWord( 4, 3 )] = sigC.v64;
234 sig256C[indexWord( 4, 2 )] = sigC.v0;
235 sig256C[indexWord( 4, 1 )] = 0;
236 sig256C[indexWord( 4, 0 )] = 0;
237 softfloat_sub256M( sig256C, sig256Z, sig256Z );
238 }
239 } else if ( ! expDiff ) {
240 sigZ = softfloat_sub128( sigZ.v64, sigZ.v0, sigC.v64, sigC.v0 );
241 if (
242 ! (sigZ.v64 | sigZ.v0) && ! sig256Z[indexWord( 4, 1 )]
243 && ! sig256Z[indexWord( 4, 0 )]
244 ) {
245 goto completeCancellation;
246 }
247 sig256Z[indexWord( 4, 3 )] = sigZ.v64;
248 sig256Z[indexWord( 4, 2 )] = sigZ.v0;
249 if ( sigZ.v64 & UINT64_C( 0x8000000000000000 ) ) {
250 signZ = ! signZ;
251 softfloat_sub256M( zero256, sig256Z, sig256Z );
252 }
253 } else {
254 softfloat_sub256M( sig256Z, sig256C, sig256Z );
255 if ( 1 < expDiff ) {
256 sigZ.v64 = sig256Z[indexWord( 4, 3 )];
257 sigZ.v0 = sig256Z[indexWord( 4, 2 )];
258 if ( ! (sigZ.v64 & UINT64_C( 0x0100000000000000 )) ) {
259 --expZ;
260 shiftDist = 7;
261 }
262 goto sigZ;
263 }
264 }
265 /*--------------------------------------------------------------------
266 *--------------------------------------------------------------------*/
267 sigZ.v64 = sig256Z[indexWord( 4, 3 )];
268 sigZ.v0 = sig256Z[indexWord( 4, 2 )];
269 sigZExtra = sig256Z[indexWord( 4, 1 )];
270 sig256Z0 = sig256Z[indexWord( 4, 0 )];
271 if ( sigZ.v64 ) {
272 if ( sig256Z0 ) sigZExtra |= 1;
273 } else {
274 expZ -= 64;
275 sigZ.v64 = sigZ.v0;
276 sigZ.v0 = sigZExtra;
277 sigZExtra = sig256Z0;
278 if ( ! sigZ.v64 ) {
279 expZ -= 64;
280 sigZ.v64 = sigZ.v0;
281 sigZ.v0 = sigZExtra;
282 sigZExtra = 0;
283 if ( ! sigZ.v64 ) {
284 expZ -= 64;
285 sigZ.v64 = sigZ.v0;
286 sigZ.v0 = 0;
287 }
288 }
289 }
290 shiftDist = softfloat_countLeadingZeros64( sigZ.v64 );
291 expZ += 7 - shiftDist;
292 shiftDist = 15 - shiftDist;
293 if ( 0 < shiftDist ) goto shiftRightRoundPack;
294 if ( shiftDist ) {
295 shiftDist = -shiftDist;
296 sigZ = softfloat_shortShiftLeft128( sigZ.v64, sigZ.v0, shiftDist );
297 x128 = softfloat_shortShiftLeft128( 0, sigZExtra, shiftDist );
298 sigZ.v0 |= x128.v64;
299 sigZExtra = x128.v0;
300 }
301 goto roundPack;
302 }
303 sigZ:
304 sigZExtra = sig256Z[indexWord( 4, 1 )] | sig256Z[indexWord( 4, 0 )];
305 shiftRightRoundPack:
306 sigZExtra = (uint64_t) (sigZ.v0<<(64 - shiftDist)) | (sigZExtra != 0);
307 sigZ = softfloat_shortShiftRight128( sigZ.v64, sigZ.v0, shiftDist );
308 roundPack:
309 return
310 softfloat_roundPackToF128(
311 signZ, expZ - 1, sigZ.v64, sigZ.v0, sigZExtra );
312 /*------------------------------------------------------------------------
313 *------------------------------------------------------------------------*/
314 propagateNaN_ABC:
315 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
316 goto propagateNaN_ZC;
317 /*------------------------------------------------------------------------
318 *------------------------------------------------------------------------*/
319 infProdArg:
320 if ( magBits ) {
321 uiZ.v64 = packToF128UI64( signZ, 0x7FFF, 0 );
322 uiZ.v0 = 0;
323 if ( expC != 0x7FFF ) goto uiZ;
324 if ( sigC.v64 | sigC.v0 ) goto propagateNaN_ZC;
325 if ( signZ == signC ) goto uiZ;
326 }
327 softfloat_raiseFlags( softfloat_flag_invalid );
328 uiZ.v64 = defaultNaNF128UI64;
329 uiZ.v0 = defaultNaNF128UI0;
330 propagateNaN_ZC:
331 uiZ = softfloat_propagateNaNF128UI( uiZ.v64, uiZ.v0, uiC64, uiC0 );
332 goto uiZ;
333 /*------------------------------------------------------------------------
334 *------------------------------------------------------------------------*/
335 zeroProd:
336 uiZ.v64 = uiC64;
337 uiZ.v0 = uiC0;
338 if ( ! (expC | sigC.v64 | sigC.v0) && (signZ != signC) ) {
339 completeCancellation:
340 uiZ.v64 =
341 packToF128UI64(
342 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
343 uiZ.v0 = 0;
344 }
345 uiZ:
346 uZ.ui = uiZ;
347 return uZ.f;
348
349}
350
deps/SoftFloat-3d/source/s_mulAddF128M.c deleted-382
......@@ -1,382 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44void
45 softfloat_mulAddF128M(
46 const uint32_t *aWPtr,
47 const uint32_t *bWPtr,
48 const uint32_t *cWPtr,
49 uint32_t *zWPtr,
50 uint_fast8_t op
51 )
52{
53 uint32_t uiA96;
54 int32_t expA;
55 uint32_t uiB96;
56 int32_t expB;
57 uint32_t uiC96;
58 bool signC;
59 int32_t expC;
60 bool signProd, prodIsInfinite;
61 uint32_t *ptr, uiZ96, sigA[4];
62 uint_fast8_t shiftDist;
63 uint32_t sigX[5];
64 int32_t expProd;
65 uint32_t sigProd[8], wordSig;
66 bool doSub;
67 uint_fast8_t
68 (*addCarryMRoutinePtr)(
69 uint_fast8_t,
70 const uint32_t *,
71 const uint32_t *,
72 uint_fast8_t,
73 uint32_t *
74 );
75 int32_t expDiff;
76 bool signZ;
77 int32_t expZ;
78 uint32_t *extSigPtr;
79 uint_fast8_t carry;
80 void (*roundPackRoutinePtr)( bool, int32_t, uint32_t *, uint32_t * );
81
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 uiA96 = aWPtr[indexWordHi( 4 )];
85 expA = expF128UI96( uiA96 );
86 uiB96 = bWPtr[indexWordHi( 4 )];
87 expB = expF128UI96( uiB96 );
88 uiC96 = cWPtr[indexWordHi( 4 )];
89 signC = signF128UI96( uiC96 ) ^ (op == softfloat_mulAdd_subC);
90 expC = expF128UI96( uiC96 );
91 signProd =
92 signF128UI96( uiA96 ) ^ signF128UI96( uiB96 )
93 ^ (op == softfloat_mulAdd_subProd);
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 prodIsInfinite = false;
97 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
98 if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) {
99 goto propagateNaN_ZC;
100 }
101 ptr = (uint32_t *) aWPtr;
102 if ( ! (uint32_t) (uiA96<<1) ) goto possibleInvalidProd;
103 if ( ! (uint32_t) (uiB96<<1) ) {
104 ptr = (uint32_t *) bWPtr;
105 possibleInvalidProd:
106 if (
107 ! (ptr[indexWord( 4, 2 )] | ptr[indexWord( 4, 1 )]
108 | ptr[indexWord( 4, 0 )])
109 ) {
110 goto invalid;
111 }
112 }
113 prodIsInfinite = true;
114 }
115 if ( expC == 0x7FFF ) {
116 if (
117 fracF128UI96( uiC96 )
118 || (cWPtr[indexWord( 4, 2 )] | cWPtr[indexWord( 4, 1 )]
119 | cWPtr[indexWord( 4, 0 )])
120 ) {
121 zWPtr[indexWordHi( 4 )] = 0;
122 goto propagateNaN_ZC;
123 }
124 if ( prodIsInfinite && (signProd != signC) ) goto invalid;
125 goto copyC;
126 }
127 if ( prodIsInfinite ) {
128 uiZ96 = packToF128UI96( signProd, 0x7FFF, 0 );
129 goto uiZ;
130 }
131 /*------------------------------------------------------------------------
132 *------------------------------------------------------------------------*/
133 if ( expA ) {
134 sigA[indexWordHi( 4 )] = fracF128UI96( uiA96 ) | 0x00010000;
135 sigA[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
136 sigA[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
137 sigA[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
138 } else {
139 expA = softfloat_shiftNormSigF128M( aWPtr, 0, sigA );
140 if ( expA == -128 ) goto zeroProd;
141 }
142 if ( expB ) {
143 sigX[indexWordHi( 4 )] = fracF128UI96( uiB96 ) | 0x00010000;
144 sigX[indexWord( 4, 2 )] = bWPtr[indexWord( 4, 2 )];
145 sigX[indexWord( 4, 1 )] = bWPtr[indexWord( 4, 1 )];
146 sigX[indexWord( 4, 0 )] = bWPtr[indexWord( 4, 0 )];
147 } else {
148 expB = softfloat_shiftNormSigF128M( bWPtr, 0, sigX );
149 if ( expB == -128 ) goto zeroProd;
150 }
151 /*------------------------------------------------------------------------
152 *------------------------------------------------------------------------*/
153 expProd = expA + expB - 0x3FF0;
154 softfloat_mul128MTo256M( sigA, sigX, sigProd );
155 /*------------------------------------------------------------------------
156 *------------------------------------------------------------------------*/
157 wordSig = fracF128UI96( uiC96 );
158 if ( expC ) {
159 --expC;
160 wordSig |= 0x00010000;
161 }
162 sigX[indexWordHi( 5 )] = wordSig;
163 sigX[indexWord( 5, 3 )] = cWPtr[indexWord( 4, 2 )];
164 sigX[indexWord( 5, 2 )] = cWPtr[indexWord( 4, 1 )];
165 sigX[indexWord( 5, 1 )] = cWPtr[indexWord( 4, 0 )];
166 /*------------------------------------------------------------------------
167 *------------------------------------------------------------------------*/
168 doSub = (signProd != signC);
169 addCarryMRoutinePtr =
170 doSub ? softfloat_addComplCarryM : softfloat_addCarryM;
171 expDiff = expProd - expC;
172 if ( expDiff <= 0 ) {
173 /*--------------------------------------------------------------------
174 *--------------------------------------------------------------------*/
175 signZ = signC;
176 expZ = expC;
177 if (
178 sigProd[indexWord( 8, 2 )]
179 || (sigProd[indexWord( 8, 1 )] | sigProd[indexWord( 8, 0 )])
180 ) {
181 sigProd[indexWord( 8, 3 )] |= 1;
182 }
183 extSigPtr = &sigProd[indexMultiwordHi( 8, 5 )];
184 if ( expDiff ) {
185 softfloat_shiftRightJam160M( extSigPtr, -expDiff, extSigPtr );
186 }
187 carry = 0;
188 if ( doSub ) {
189 wordSig = extSigPtr[indexWordLo( 5 )];
190 extSigPtr[indexWordLo( 5 )] = -wordSig;
191 carry = ! wordSig;
192 }
193 (*addCarryMRoutinePtr)(
194 4,
195 &sigX[indexMultiwordHi( 5, 4 )],
196 extSigPtr + indexMultiwordHi( 5, 4 ),
197 carry,
198 extSigPtr + indexMultiwordHi( 5, 4 )
199 );
200 wordSig = extSigPtr[indexWordHi( 5 )];
201 if ( ! expZ ) {
202 if ( wordSig & 0x80000000 ) {
203 signZ = ! signZ;
204 softfloat_negX160M( extSigPtr );
205 wordSig = extSigPtr[indexWordHi( 5 )];
206 }
207 goto checkCancellation;
208 }
209 if ( wordSig < 0x00010000 ) {
210 --expZ;
211 softfloat_add160M( extSigPtr, extSigPtr, extSigPtr );
212 goto roundPack;
213 }
214 goto extSigReady_noCancellation;
215 } else {
216 /*--------------------------------------------------------------------
217 *--------------------------------------------------------------------*/
218 signZ = signProd;
219 expZ = expProd;
220 sigX[indexWordLo( 5 )] = 0;
221 expDiff -= 128;
222 if ( 0 <= expDiff ) {
223 /*----------------------------------------------------------------
224 *----------------------------------------------------------------*/
225 if ( expDiff ) softfloat_shiftRightJam160M( sigX, expDiff, sigX );
226 wordSig = sigX[indexWordLo( 5 )];
227 carry = 0;
228 if ( doSub ) {
229 carry = ! wordSig;
230 wordSig = -wordSig;
231 }
232 carry =
233 (*addCarryMRoutinePtr)(
234 4,
235 &sigProd[indexMultiwordLo( 8, 4 )],
236 &sigX[indexMultiwordHi( 5, 4 )],
237 carry,
238 &sigProd[indexMultiwordLo( 8, 4 )]
239 );
240 sigProd[indexWord( 8, 2 )] |= wordSig;
241 ptr = &sigProd[indexWord( 8, 4 )];
242 } else {
243 /*----------------------------------------------------------------
244 *----------------------------------------------------------------*/
245 shiftDist = expDiff & 31;
246 if ( shiftDist ) {
247 softfloat_shortShiftRight160M( sigX, shiftDist, sigX );
248 }
249 expDiff >>= 5;
250 extSigPtr =
251 &sigProd[indexMultiwordLo( 8, 5 )] - wordIncr
252 + expDiff * -wordIncr;
253 carry =
254 (*addCarryMRoutinePtr)( 5, extSigPtr, sigX, doSub, extSigPtr );
255 if ( expDiff == -4 ) {
256 /*------------------------------------------------------------
257 *------------------------------------------------------------*/
258 wordSig = sigProd[indexWordHi( 8 )];
259 if ( wordSig & 0x80000000 ) {
260 signZ = ! signZ;
261 softfloat_negX256M( sigProd );
262 wordSig = sigProd[indexWordHi( 8 )];
263 }
264 /*------------------------------------------------------------
265 *------------------------------------------------------------*/
266 if ( wordSig ) goto expProdBigger_noWordShift;
267 wordSig = sigProd[indexWord( 8, 6 )];
268 if ( 0x00040000 <= wordSig ) goto expProdBigger_noWordShift;
269 expZ -= 32;
270 extSigPtr = &sigProd[indexMultiwordHi( 8, 5 )] - wordIncr;
271 for (;;) {
272 if ( wordSig ) break;
273 wordSig = extSigPtr[indexWord( 5, 3 )];
274 if ( 0x00040000 <= wordSig ) break;
275 expZ -= 32;
276 extSigPtr -= wordIncr;
277 if ( extSigPtr == &sigProd[indexMultiwordLo( 8, 5 )] ) {
278 goto checkCancellation;
279 }
280 }
281 /*------------------------------------------------------------
282 *------------------------------------------------------------*/
283 ptr = extSigPtr + indexWordLo( 5 );
284 do {
285 ptr -= wordIncr;
286 if ( *ptr ) {
287 extSigPtr[indexWordLo( 5 )] |= 1;
288 break;
289 }
290 } while ( ptr != &sigProd[indexWordLo( 8 )] );
291 wordSig = extSigPtr[indexWordHi( 5 )];
292 goto extSigReady;
293 }
294 ptr = extSigPtr + indexWordHi( 5 ) + wordIncr;
295 }
296 /*--------------------------------------------------------------------
297 *--------------------------------------------------------------------*/
298 if ( carry != doSub ) {
299 if ( doSub ) {
300 do {
301 wordSig = *ptr;
302 *ptr = wordSig - 1;
303 ptr += wordIncr;
304 } while ( ! wordSig );
305 } else {
306 do {
307 wordSig = *ptr + 1;
308 *ptr = wordSig;
309 ptr += wordIncr;
310 } while ( ! wordSig );
311 }
312 }
313 /*--------------------------------------------------------------------
314 *--------------------------------------------------------------------*/
315 expProdBigger_noWordShift:
316 if (
317 sigProd[indexWord( 8, 2 )]
318 || (sigProd[indexWord( 8, 1 )] | sigProd[indexWord( 8, 0 )])
319 ) {
320 sigProd[indexWord( 8, 3 )] |= 1;
321 }
322 extSigPtr = &sigProd[indexMultiwordHi( 8, 5 )];
323 wordSig = extSigPtr[indexWordHi( 5 )];
324 }
325 extSigReady:
326 roundPackRoutinePtr = softfloat_normRoundPackMToF128M;
327 if ( wordSig < 0x00010000 ) goto doRoundPack;
328 extSigReady_noCancellation:
329 if ( 0x00020000 <= wordSig ) {
330 ++expZ;
331 softfloat_shortShiftRightJam160M( extSigPtr, 1, extSigPtr );
332 }
333 roundPack:
334 roundPackRoutinePtr = softfloat_roundPackMToF128M;
335 doRoundPack:
336 (*roundPackRoutinePtr)( signZ, expZ, extSigPtr, zWPtr );
337 return;
338 /*------------------------------------------------------------------------
339 *------------------------------------------------------------------------*/
340 invalid:
341 softfloat_invalidF128M( zWPtr );
342 propagateNaN_ZC:
343 softfloat_propagateNaNF128M( zWPtr, cWPtr, zWPtr );
344 return;
345 /*------------------------------------------------------------------------
346 *------------------------------------------------------------------------*/
347 zeroProd:
348 if (
349 ! (uint32_t) (uiC96<<1) && (signProd != signC)
350 && ! cWPtr[indexWord( 4, 2 )]
351 && ! (cWPtr[indexWord( 4, 1 )] | cWPtr[indexWord( 4, 0 )])
352 ) {
353 goto completeCancellation;
354 }
355 copyC:
356 zWPtr[indexWordHi( 4 )] = uiC96;
357 zWPtr[indexWord( 4, 2 )] = cWPtr[indexWord( 4, 2 )];
358 zWPtr[indexWord( 4, 1 )] = cWPtr[indexWord( 4, 1 )];
359 zWPtr[indexWord( 4, 0 )] = cWPtr[indexWord( 4, 0 )];
360 return;
361 /*------------------------------------------------------------------------
362 *------------------------------------------------------------------------*/
363 checkCancellation:
364 if (
365 wordSig
366 || (extSigPtr[indexWord( 5, 3 )] | extSigPtr[indexWord( 5, 2 )])
367 || (extSigPtr[indexWord( 5, 1 )] | extSigPtr[indexWord( 5, 0 )])
368 ) {
369 goto extSigReady;
370 }
371 completeCancellation:
372 uiZ96 =
373 packToF128UI96(
374 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
375 uiZ:
376 zWPtr[indexWordHi( 4 )] = uiZ96;
377 zWPtr[indexWord( 4, 2 )] = 0;
378 zWPtr[indexWord( 4, 1 )] = 0;
379 zWPtr[indexWord( 4, 0 )] = 0;
380
381}
382
deps/SoftFloat-3d/source/s_mulAddF16.c deleted-226
......@@ -1,226 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t
45 softfloat_mulAddF16(
46 uint_fast16_t uiA, uint_fast16_t uiB, uint_fast16_t uiC, uint_fast8_t op )
47{
48 bool signA;
49 int_fast8_t expA;
50 uint_fast16_t sigA;
51 bool signB;
52 int_fast8_t expB;
53 uint_fast16_t sigB;
54 bool signC;
55 int_fast8_t expC;
56 uint_fast16_t sigC;
57 bool signProd;
58 uint_fast16_t magBits, uiZ;
59 struct exp8_sig16 normExpSig;
60 int_fast8_t expProd;
61 uint_fast32_t sigProd;
62 bool signZ;
63 int_fast8_t expZ;
64 uint_fast16_t sigZ;
65 int_fast8_t expDiff;
66 uint_fast32_t sig32Z, sig32C;
67 int_fast8_t shiftDist;
68 union ui16_f16 uZ;
69
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 signA = signF16UI( uiA );
73 expA = expF16UI( uiA );
74 sigA = fracF16UI( uiA );
75 signB = signF16UI( uiB );
76 expB = expF16UI( uiB );
77 sigB = fracF16UI( uiB );
78 signC = signF16UI( uiC ) ^ (op == softfloat_mulAdd_subC);
79 expC = expF16UI( uiC );
80 sigC = fracF16UI( uiC );
81 signProd = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( expA == 0x1F ) {
85 if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN_ABC;
86 magBits = expB | sigB;
87 goto infProdArg;
88 }
89 if ( expB == 0x1F ) {
90 if ( sigB ) goto propagateNaN_ABC;
91 magBits = expA | sigA;
92 goto infProdArg;
93 }
94 if ( expC == 0x1F ) {
95 if ( sigC ) {
96 uiZ = 0;
97 goto propagateNaN_ZC;
98 }
99 uiZ = uiC;
100 goto uiZ;
101 }
102 /*------------------------------------------------------------------------
103 *------------------------------------------------------------------------*/
104 if ( ! expA ) {
105 if ( ! sigA ) goto zeroProd;
106 normExpSig = softfloat_normSubnormalF16Sig( sigA );
107 expA = normExpSig.exp;
108 sigA = normExpSig.sig;
109 }
110 if ( ! expB ) {
111 if ( ! sigB ) goto zeroProd;
112 normExpSig = softfloat_normSubnormalF16Sig( sigB );
113 expB = normExpSig.exp;
114 sigB = normExpSig.sig;
115 }
116 /*------------------------------------------------------------------------
117 *------------------------------------------------------------------------*/
118 expProd = expA + expB - 0xE;
119 sigA = (sigA | 0x0400)<<4;
120 sigB = (sigB | 0x0400)<<4;
121 sigProd = (uint_fast32_t) sigA * sigB;
122 if ( sigProd < 0x20000000 ) {
123 --expProd;
124 sigProd <<= 1;
125 }
126 signZ = signProd;
127 if ( ! expC ) {
128 if ( ! sigC ) {
129 expZ = expProd - 1;
130 sigZ = sigProd>>15 | ((sigProd & 0x7FFF) != 0);
131 goto roundPack;
132 }
133 normExpSig = softfloat_normSubnormalF16Sig( sigC );
134 expC = normExpSig.exp;
135 sigC = normExpSig.sig;
136 }
137 sigC = (sigC | 0x0400)<<3;
138 /*------------------------------------------------------------------------
139 *------------------------------------------------------------------------*/
140 expDiff = expProd - expC;
141 if ( signProd == signC ) {
142 /*--------------------------------------------------------------------
143 *--------------------------------------------------------------------*/
144 if ( expDiff <= 0 ) {
145 expZ = expC;
146 sigZ = sigC + softfloat_shiftRightJam32( sigProd, 16 - expDiff );
147 } else {
148 expZ = expProd;
149 sig32Z =
150 sigProd
151 + softfloat_shiftRightJam32(
152 (uint_fast32_t) sigC<<16, expDiff );
153 sigZ = sig32Z>>16 | ((sig32Z & 0xFFFF) != 0 );
154 }
155 if ( sigZ < 0x4000 ) {
156 --expZ;
157 sigZ <<= 1;
158 }
159 } else {
160 /*--------------------------------------------------------------------
161 *--------------------------------------------------------------------*/
162 sig32C = (uint_fast32_t) sigC<<16;
163 if ( expDiff < 0 ) {
164 signZ = signC;
165 expZ = expC;
166 sig32Z = sig32C - softfloat_shiftRightJam32( sigProd, -expDiff );
167 } else if ( ! expDiff ) {
168 expZ = expProd;
169 sig32Z = sigProd - sig32C;
170 if ( ! sig32Z ) goto completeCancellation;
171 if ( sig32Z & 0x80000000 ) {
172 signZ = ! signZ;
173 sig32Z = -sig32Z;
174 }
175 } else {
176 expZ = expProd;
177 sig32Z = sigProd - softfloat_shiftRightJam32( sig32C, expDiff );
178 }
179 shiftDist = softfloat_countLeadingZeros32( sig32Z ) - 1;
180 expZ -= shiftDist;
181 shiftDist -= 16;
182 if ( shiftDist < 0 ) {
183 sigZ =
184 sig32Z>>(-shiftDist)
185 | ((uint32_t) (sig32Z<<(shiftDist & 31)) != 0);
186 } else {
187 sigZ = (uint_fast16_t) sig32Z<<shiftDist;
188 }
189 }
190 roundPack:
191 return softfloat_roundPackToF16( signZ, expZ, sigZ );
192 /*------------------------------------------------------------------------
193 *------------------------------------------------------------------------*/
194 propagateNaN_ABC:
195 uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
196 goto propagateNaN_ZC;
197 /*------------------------------------------------------------------------
198 *------------------------------------------------------------------------*/
199 infProdArg:
200 if ( magBits ) {
201 uiZ = packToF16UI( signProd, 0x1F, 0 );
202 if ( expC != 0x1F ) goto uiZ;
203 if ( sigC ) goto propagateNaN_ZC;
204 if ( signProd == signC ) goto uiZ;
205 }
206 softfloat_raiseFlags( softfloat_flag_invalid );
207 uiZ = defaultNaNF16UI;
208 propagateNaN_ZC:
209 uiZ = softfloat_propagateNaNF16UI( uiZ, uiC );
210 goto uiZ;
211 /*------------------------------------------------------------------------
212 *------------------------------------------------------------------------*/
213 zeroProd:
214 uiZ = uiC;
215 if ( ! (expC | sigC) && (signProd != signC) ) {
216 completeCancellation:
217 uiZ =
218 packToF16UI(
219 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
220 }
221 uiZ:
222 uZ.ui = uiZ;
223 return uZ.f;
224
225}
226
deps/SoftFloat-3d/source/s_mulAddF32.c deleted-224
......@@ -1,224 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t
45 softfloat_mulAddF32(
46 uint_fast32_t uiA, uint_fast32_t uiB, uint_fast32_t uiC, uint_fast8_t op )
47{
48 bool signA;
49 int_fast16_t expA;
50 uint_fast32_t sigA;
51 bool signB;
52 int_fast16_t expB;
53 uint_fast32_t sigB;
54 bool signC;
55 int_fast16_t expC;
56 uint_fast32_t sigC;
57 bool signProd;
58 uint_fast32_t magBits, uiZ;
59 struct exp16_sig32 normExpSig;
60 int_fast16_t expProd;
61 uint_fast64_t sigProd;
62 bool signZ;
63 int_fast16_t expZ;
64 uint_fast32_t sigZ;
65 int_fast16_t expDiff;
66 uint_fast64_t sig64Z, sig64C;
67 int_fast8_t shiftDist;
68 union ui32_f32 uZ;
69
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 signA = signF32UI( uiA );
73 expA = expF32UI( uiA );
74 sigA = fracF32UI( uiA );
75 signB = signF32UI( uiB );
76 expB = expF32UI( uiB );
77 sigB = fracF32UI( uiB );
78 signC = signF32UI( uiC ) ^ (op == softfloat_mulAdd_subC);
79 expC = expF32UI( uiC );
80 sigC = fracF32UI( uiC );
81 signProd = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( expA == 0xFF ) {
85 if ( sigA || ((expB == 0xFF) && sigB) ) goto propagateNaN_ABC;
86 magBits = expB | sigB;
87 goto infProdArg;
88 }
89 if ( expB == 0xFF ) {
90 if ( sigB ) goto propagateNaN_ABC;
91 magBits = expA | sigA;
92 goto infProdArg;
93 }
94 if ( expC == 0xFF ) {
95 if ( sigC ) {
96 uiZ = 0;
97 goto propagateNaN_ZC;
98 }
99 uiZ = uiC;
100 goto uiZ;
101 }
102 /*------------------------------------------------------------------------
103 *------------------------------------------------------------------------*/
104 if ( ! expA ) {
105 if ( ! sigA ) goto zeroProd;
106 normExpSig = softfloat_normSubnormalF32Sig( sigA );
107 expA = normExpSig.exp;
108 sigA = normExpSig.sig;
109 }
110 if ( ! expB ) {
111 if ( ! sigB ) goto zeroProd;
112 normExpSig = softfloat_normSubnormalF32Sig( sigB );
113 expB = normExpSig.exp;
114 sigB = normExpSig.sig;
115 }
116 /*------------------------------------------------------------------------
117 *------------------------------------------------------------------------*/
118 expProd = expA + expB - 0x7E;
119 sigA = (sigA | 0x00800000)<<7;
120 sigB = (sigB | 0x00800000)<<7;
121 sigProd = (uint_fast64_t) sigA * sigB;
122 if ( sigProd < UINT64_C( 0x2000000000000000 ) ) {
123 --expProd;
124 sigProd <<= 1;
125 }
126 signZ = signProd;
127 if ( ! expC ) {
128 if ( ! sigC ) {
129 expZ = expProd - 1;
130 sigZ = softfloat_shortShiftRightJam64( sigProd, 31 );
131 goto roundPack;
132 }
133 normExpSig = softfloat_normSubnormalF32Sig( sigC );
134 expC = normExpSig.exp;
135 sigC = normExpSig.sig;
136 }
137 sigC = (sigC | 0x00800000)<<6;
138 /*------------------------------------------------------------------------
139 *------------------------------------------------------------------------*/
140 expDiff = expProd - expC;
141 if ( signProd == signC ) {
142 /*--------------------------------------------------------------------
143 *--------------------------------------------------------------------*/
144 if ( expDiff <= 0 ) {
145 expZ = expC;
146 sigZ = sigC + softfloat_shiftRightJam64( sigProd, 32 - expDiff );
147 } else {
148 expZ = expProd;
149 sig64Z =
150 sigProd
151 + softfloat_shiftRightJam64(
152 (uint_fast64_t) sigC<<32, expDiff );
153 sigZ = softfloat_shortShiftRightJam64( sig64Z, 32 );
154 }
155 if ( sigZ < 0x40000000 ) {
156 --expZ;
157 sigZ <<= 1;
158 }
159 } else {
160 /*--------------------------------------------------------------------
161 *--------------------------------------------------------------------*/
162 sig64C = (uint_fast64_t) sigC<<32;
163 if ( expDiff < 0 ) {
164 signZ = signC;
165 expZ = expC;
166 sig64Z = sig64C - softfloat_shiftRightJam64( sigProd, -expDiff );
167 } else if ( ! expDiff ) {
168 expZ = expProd;
169 sig64Z = sigProd - sig64C;
170 if ( ! sig64Z ) goto completeCancellation;
171 if ( sig64Z & UINT64_C( 0x8000000000000000 ) ) {
172 signZ = ! signZ;
173 sig64Z = -sig64Z;
174 }
175 } else {
176 expZ = expProd;
177 sig64Z = sigProd - softfloat_shiftRightJam64( sig64C, expDiff );
178 }
179 shiftDist = softfloat_countLeadingZeros64( sig64Z ) - 1;
180 expZ -= shiftDist;
181 shiftDist -= 32;
182 if ( shiftDist < 0 ) {
183 sigZ = softfloat_shortShiftRightJam64( sig64Z, -shiftDist );
184 } else {
185 sigZ = (uint_fast32_t) sig64Z<<shiftDist;
186 }
187 }
188 roundPack:
189 return softfloat_roundPackToF32( signZ, expZ, sigZ );
190 /*------------------------------------------------------------------------
191 *------------------------------------------------------------------------*/
192 propagateNaN_ABC:
193 uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
194 goto propagateNaN_ZC;
195 /*------------------------------------------------------------------------
196 *------------------------------------------------------------------------*/
197 infProdArg:
198 if ( magBits ) {
199 uiZ = packToF32UI( signProd, 0xFF, 0 );
200 if ( expC != 0xFF ) goto uiZ;
201 if ( sigC ) goto propagateNaN_ZC;
202 if ( signProd == signC ) goto uiZ;
203 }
204 softfloat_raiseFlags( softfloat_flag_invalid );
205 uiZ = defaultNaNF32UI;
206 propagateNaN_ZC:
207 uiZ = softfloat_propagateNaNF32UI( uiZ, uiC );
208 goto uiZ;
209 /*------------------------------------------------------------------------
210 *------------------------------------------------------------------------*/
211 zeroProd:
212 uiZ = uiC;
213 if ( ! (expC | sigC) && (signProd != signC) ) {
214 completeCancellation:
215 uiZ =
216 packToF32UI(
217 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
218 }
219 uiZ:
220 uZ.ui = uiZ;
221 return uZ.f;
222
223}
224
deps/SoftFloat-3d/source/s_mulAddF64.c deleted-496
......@@ -1,496 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46float64_t
47 softfloat_mulAddF64(
48 uint_fast64_t uiA, uint_fast64_t uiB, uint_fast64_t uiC, uint_fast8_t op )
49{
50 bool signA;
51 int_fast16_t expA;
52 uint_fast64_t sigA;
53 bool signB;
54 int_fast16_t expB;
55 uint_fast64_t sigB;
56 bool signC;
57 int_fast16_t expC;
58 uint_fast64_t sigC;
59 bool signZ;
60 uint_fast64_t magBits, uiZ;
61 struct exp16_sig64 normExpSig;
62 int_fast16_t expZ;
63 struct uint128 sig128Z;
64 uint_fast64_t sigZ;
65 int_fast16_t expDiff;
66 struct uint128 sig128C;
67 int_fast8_t shiftDist;
68 union ui64_f64 uZ;
69
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 signA = signF64UI( uiA );
73 expA = expF64UI( uiA );
74 sigA = fracF64UI( uiA );
75 signB = signF64UI( uiB );
76 expB = expF64UI( uiB );
77 sigB = fracF64UI( uiB );
78 signC = signF64UI( uiC ) ^ (op == softfloat_mulAdd_subC);
79 expC = expF64UI( uiC );
80 sigC = fracF64UI( uiC );
81 signZ = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( expA == 0x7FF ) {
85 if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN_ABC;
86 magBits = expB | sigB;
87 goto infProdArg;
88 }
89 if ( expB == 0x7FF ) {
90 if ( sigB ) goto propagateNaN_ABC;
91 magBits = expA | sigA;
92 goto infProdArg;
93 }
94 if ( expC == 0x7FF ) {
95 if ( sigC ) {
96 uiZ = 0;
97 goto propagateNaN_ZC;
98 }
99 uiZ = uiC;
100 goto uiZ;
101 }
102 /*------------------------------------------------------------------------
103 *------------------------------------------------------------------------*/
104 if ( ! expA ) {
105 if ( ! sigA ) goto zeroProd;
106 normExpSig = softfloat_normSubnormalF64Sig( sigA );
107 expA = normExpSig.exp;
108 sigA = normExpSig.sig;
109 }
110 if ( ! expB ) {
111 if ( ! sigB ) goto zeroProd;
112 normExpSig = softfloat_normSubnormalF64Sig( sigB );
113 expB = normExpSig.exp;
114 sigB = normExpSig.sig;
115 }
116 /*------------------------------------------------------------------------
117 *------------------------------------------------------------------------*/
118 expZ = expA + expB - 0x3FE;
119 sigA = (sigA | UINT64_C( 0x0010000000000000 ))<<10;
120 sigB = (sigB | UINT64_C( 0x0010000000000000 ))<<10;
121 sig128Z = softfloat_mul64To128( sigA, sigB );
122 if ( sig128Z.v64 < UINT64_C( 0x2000000000000000 ) ) {
123 --expZ;
124 sig128Z =
125 softfloat_add128(
126 sig128Z.v64, sig128Z.v0, sig128Z.v64, sig128Z.v0 );
127 }
128 if ( ! expC ) {
129 if ( ! sigC ) {
130 --expZ;
131 sigZ = sig128Z.v64<<1 | (sig128Z.v0 != 0);
132 goto roundPack;
133 }
134 normExpSig = softfloat_normSubnormalF64Sig( sigC );
135 expC = normExpSig.exp;
136 sigC = normExpSig.sig;
137 }
138 sigC = (sigC | UINT64_C( 0x0010000000000000 ))<<9;
139 /*------------------------------------------------------------------------
140 *------------------------------------------------------------------------*/
141 expDiff = expZ - expC;
142 if ( expDiff < 0 ) {
143 expZ = expC;
144 if ( (signZ == signC) || (expDiff < -1) ) {
145 sig128Z.v64 = softfloat_shiftRightJam64( sig128Z.v64, -expDiff );
146 } else {
147 sig128Z =
148 softfloat_shortShiftRightJam128( sig128Z.v64, sig128Z.v0, 1 );
149 }
150 } else if ( expDiff ) {
151 sig128C = softfloat_shiftRightJam128( sigC, 0, expDiff );
152 }
153 /*------------------------------------------------------------------------
154 *------------------------------------------------------------------------*/
155 if ( signZ == signC ) {
156 /*--------------------------------------------------------------------
157 *--------------------------------------------------------------------*/
158 if ( expDiff <= 0 ) {
159 sigZ = (sigC + sig128Z.v64) | (sig128Z.v0 != 0);
160 } else {
161 sig128Z =
162 softfloat_add128(
163 sig128Z.v64, sig128Z.v0, sig128C.v64, sig128C.v0 );
164 sigZ = sig128Z.v64 | (sig128Z.v0 != 0);
165 }
166 if ( sigZ < UINT64_C( 0x4000000000000000 ) ) {
167 --expZ;
168 sigZ <<= 1;
169 }
170 } else {
171 /*--------------------------------------------------------------------
172 *--------------------------------------------------------------------*/
173 if ( expDiff < 0 ) {
174 signZ = signC;
175 sig128Z = softfloat_sub128( sigC, 0, sig128Z.v64, sig128Z.v0 );
176 } else if ( ! expDiff ) {
177 sig128Z.v64 = sig128Z.v64 - sigC;
178 if ( ! (sig128Z.v64 | sig128Z.v0) ) goto completeCancellation;
179 if ( sig128Z.v64 & UINT64_C( 0x8000000000000000 ) ) {
180 signZ = ! signZ;
181 sig128Z = softfloat_sub128( 0, 0, sig128Z.v64, sig128Z.v0 );
182 }
183 } else {
184 sig128Z =
185 softfloat_sub128(
186 sig128Z.v64, sig128Z.v0, sig128C.v64, sig128C.v0 );
187 }
188 /*--------------------------------------------------------------------
189 *--------------------------------------------------------------------*/
190 if ( ! sig128Z.v64 ) {
191 expZ -= 64;
192 sig128Z.v64 = sig128Z.v0;
193 sig128Z.v0 = 0;
194 }
195 shiftDist = softfloat_countLeadingZeros64( sig128Z.v64 ) - 1;
196 expZ -= shiftDist;
197 if ( shiftDist < 0 ) {
198 sigZ = softfloat_shortShiftRightJam64( sig128Z.v64, -shiftDist );
199 } else {
200 sig128Z =
201 softfloat_shortShiftLeft128(
202 sig128Z.v64, sig128Z.v0, shiftDist );
203 sigZ = sig128Z.v64;
204 }
205 sigZ |= (sig128Z.v0 != 0);
206 }
207 roundPack:
208 return softfloat_roundPackToF64( signZ, expZ, sigZ );
209 /*------------------------------------------------------------------------
210 *------------------------------------------------------------------------*/
211 propagateNaN_ABC:
212 uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
213 goto propagateNaN_ZC;
214 /*------------------------------------------------------------------------
215 *------------------------------------------------------------------------*/
216 infProdArg:
217 if ( magBits ) {
218 uiZ = packToF64UI( signZ, 0x7FF, 0 );
219 if ( expC != 0x7FF ) goto uiZ;
220 if ( sigC ) goto propagateNaN_ZC;
221 if ( signZ == signC ) goto uiZ;
222 }
223 softfloat_raiseFlags( softfloat_flag_invalid );
224 uiZ = defaultNaNF64UI;
225 propagateNaN_ZC:
226 uiZ = softfloat_propagateNaNF64UI( uiZ, uiC );
227 goto uiZ;
228 /*------------------------------------------------------------------------
229 *------------------------------------------------------------------------*/
230 zeroProd:
231 uiZ = uiC;
232 if ( ! (expC | sigC) && (signZ != signC) ) {
233 completeCancellation:
234 uiZ =
235 packToF64UI(
236 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
237 }
238 uiZ:
239 uZ.ui = uiZ;
240 return uZ.f;
241
242}
243
244#else
245
246float64_t
247 softfloat_mulAddF64(
248 uint_fast64_t uiA, uint_fast64_t uiB, uint_fast64_t uiC, uint_fast8_t op )
249{
250 bool signA;
251 int_fast16_t expA;
252 uint64_t sigA;
253 bool signB;
254 int_fast16_t expB;
255 uint64_t sigB;
256 bool signC;
257 int_fast16_t expC;
258 uint64_t sigC;
259 bool signZ;
260 uint64_t magBits, uiZ;
261 struct exp16_sig64 normExpSig;
262 int_fast16_t expZ;
263 uint32_t sig128Z[4];
264 uint64_t sigZ;
265 int_fast16_t shiftDist, expDiff;
266 uint32_t sig128C[4];
267 union ui64_f64 uZ;
268
269 /*------------------------------------------------------------------------
270 *------------------------------------------------------------------------*/
271 signA = signF64UI( uiA );
272 expA = expF64UI( uiA );
273 sigA = fracF64UI( uiA );
274 signB = signF64UI( uiB );
275 expB = expF64UI( uiB );
276 sigB = fracF64UI( uiB );
277 signC = signF64UI( uiC ) ^ (op == softfloat_mulAdd_subC);
278 expC = expF64UI( uiC );
279 sigC = fracF64UI( uiC );
280 signZ = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
281 /*------------------------------------------------------------------------
282 *------------------------------------------------------------------------*/
283 if ( expA == 0x7FF ) {
284 if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN_ABC;
285 magBits = expB | sigB;
286 goto infProdArg;
287 }
288 if ( expB == 0x7FF ) {
289 if ( sigB ) goto propagateNaN_ABC;
290 magBits = expA | sigA;
291 goto infProdArg;
292 }
293 if ( expC == 0x7FF ) {
294 if ( sigC ) {
295 uiZ = 0;
296 goto propagateNaN_ZC;
297 }
298 uiZ = uiC;
299 goto uiZ;
300 }
301 /*------------------------------------------------------------------------
302 *------------------------------------------------------------------------*/
303 if ( ! expA ) {
304 if ( ! sigA ) goto zeroProd;
305 normExpSig = softfloat_normSubnormalF64Sig( sigA );
306 expA = normExpSig.exp;
307 sigA = normExpSig.sig;
308 }
309 if ( ! expB ) {
310 if ( ! sigB ) goto zeroProd;
311 normExpSig = softfloat_normSubnormalF64Sig( sigB );
312 expB = normExpSig.exp;
313 sigB = normExpSig.sig;
314 }
315 /*------------------------------------------------------------------------
316 *------------------------------------------------------------------------*/
317 expZ = expA + expB - 0x3FE;
318 sigA = (sigA | UINT64_C( 0x0010000000000000 ))<<10;
319 sigB = (sigB | UINT64_C( 0x0010000000000000 ))<<11;
320 softfloat_mul64To128M( sigA, sigB, sig128Z );
321 sigZ =
322 (uint64_t) sig128Z[indexWord( 4, 3 )]<<32 | sig128Z[indexWord( 4, 2 )];
323 shiftDist = 0;
324 if ( ! (sigZ & UINT64_C( 0x4000000000000000 )) ) {
325 --expZ;
326 shiftDist = -1;
327 }
328 if ( ! expC ) {
329 if ( ! sigC ) {
330 if ( shiftDist ) sigZ <<= 1;
331 goto sigZ;
332 }
333 normExpSig = softfloat_normSubnormalF64Sig( sigC );
334 expC = normExpSig.exp;
335 sigC = normExpSig.sig;
336 }
337 sigC = (sigC | UINT64_C( 0x0010000000000000 ))<<10;
338 /*------------------------------------------------------------------------
339 *------------------------------------------------------------------------*/
340 expDiff = expZ - expC;
341 if ( expDiff < 0 ) {
342 expZ = expC;
343 if ( (signZ == signC) || (expDiff < -1) ) {
344 shiftDist -= expDiff;
345 if ( shiftDist) {
346 sigZ = softfloat_shiftRightJam64( sigZ, shiftDist );
347 }
348 } else {
349 if ( ! shiftDist ) {
350 softfloat_shortShiftRight128M( sig128Z, 1, sig128Z );
351 }
352 }
353 } else {
354 if ( shiftDist ) softfloat_add128M( sig128Z, sig128Z, sig128Z );
355 if ( ! expDiff ) {
356 sigZ =
357 (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
358 | sig128Z[indexWord( 4, 2 )];
359 } else {
360 sig128C[indexWord( 4, 3 )] = sigC>>32;
361 sig128C[indexWord( 4, 2 )] = sigC;
362 sig128C[indexWord( 4, 1 )] = 0;
363 sig128C[indexWord( 4, 0 )] = 0;
364 softfloat_shiftRightJam128M( sig128C, expDiff, sig128C );
365 }
366 }
367 /*------------------------------------------------------------------------
368 *------------------------------------------------------------------------*/
369 if ( signZ == signC ) {
370 /*--------------------------------------------------------------------
371 *--------------------------------------------------------------------*/
372 if ( expDiff <= 0 ) {
373 sigZ += sigC;
374 } else {
375 softfloat_add128M( sig128Z, sig128C, sig128Z );
376 sigZ =
377 (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
378 | sig128Z[indexWord( 4, 2 )];
379 }
380 if ( sigZ & UINT64_C( 0x8000000000000000 ) ) {
381 ++expZ;
382 sigZ = softfloat_shortShiftRightJam64( sigZ, 1 );
383 }
384 } else {
385 /*--------------------------------------------------------------------
386 *--------------------------------------------------------------------*/
387 if ( expDiff < 0 ) {
388 signZ = signC;
389 if ( expDiff < -1 ) {
390 sigZ = sigC - sigZ;
391 if (
392 sig128Z[indexWord( 4, 1 )] || sig128Z[indexWord( 4, 0 )]
393 ) {
394 sigZ = (sigZ - 1) | 1;
395 }
396 if ( ! (sigZ & UINT64_C( 0x4000000000000000 )) ) {
397 --expZ;
398 sigZ <<= 1;
399 }
400 goto roundPack;
401 } else {
402 sig128C[indexWord( 4, 3 )] = sigC>>32;
403 sig128C[indexWord( 4, 2 )] = sigC;
404 sig128C[indexWord( 4, 1 )] = 0;
405 sig128C[indexWord( 4, 0 )] = 0;
406 softfloat_sub128M( sig128C, sig128Z, sig128Z );
407 }
408 } else if ( ! expDiff ) {
409 sigZ -= sigC;
410 if (
411 ! sigZ && ! sig128Z[indexWord( 4, 1 )]
412 && ! sig128Z[indexWord( 4, 0 )]
413 ) {
414 goto completeCancellation;
415 }
416 sig128Z[indexWord( 4, 3 )] = sigZ>>32;
417 sig128Z[indexWord( 4, 2 )] = sigZ;
418 if ( sigZ & UINT64_C( 0x8000000000000000 ) ) {
419 signZ = ! signZ;
420 softfloat_negX128M( sig128Z );
421 }
422 } else {
423 softfloat_sub128M( sig128Z, sig128C, sig128Z );
424 if ( 1 < expDiff ) {
425 sigZ =
426 (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
427 | sig128Z[indexWord( 4, 2 )];
428 if ( ! (sigZ & UINT64_C( 0x4000000000000000 )) ) {
429 --expZ;
430 sigZ <<= 1;
431 }
432 goto sigZ;
433 }
434 }
435 /*--------------------------------------------------------------------
436 *--------------------------------------------------------------------*/
437 shiftDist = 0;
438 sigZ =
439 (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
440 | sig128Z[indexWord( 4, 2 )];
441 if ( ! sigZ ) {
442 shiftDist = 64;
443 sigZ =
444 (uint64_t) sig128Z[indexWord( 4, 1 )]<<32
445 | sig128Z[indexWord( 4, 0 )];
446 }
447 shiftDist += softfloat_countLeadingZeros64( sigZ ) - 1;
448 if ( shiftDist ) {
449 expZ -= shiftDist;
450 softfloat_shiftLeft128M( sig128Z, shiftDist, sig128Z );
451 sigZ =
452 (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
453 | sig128Z[indexWord( 4, 2 )];
454 }
455 }
456 sigZ:
457 if ( sig128Z[indexWord( 4, 1 )] || sig128Z[indexWord( 4, 0 )] ) sigZ |= 1;
458 roundPack:
459 return softfloat_roundPackToF64( signZ, expZ - 1, sigZ );
460 /*------------------------------------------------------------------------
461 *------------------------------------------------------------------------*/
462 propagateNaN_ABC:
463 uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
464 goto propagateNaN_ZC;
465 /*------------------------------------------------------------------------
466 *------------------------------------------------------------------------*/
467 infProdArg:
468 if ( magBits ) {
469 uiZ = packToF64UI( signZ, 0x7FF, 0 );
470 if ( expC != 0x7FF ) goto uiZ;
471 if ( sigC ) goto propagateNaN_ZC;
472 if ( signZ == signC ) goto uiZ;
473 }
474 softfloat_raiseFlags( softfloat_flag_invalid );
475 uiZ = defaultNaNF64UI;
476 propagateNaN_ZC:
477 uiZ = softfloat_propagateNaNF64UI( uiZ, uiC );
478 goto uiZ;
479 /*------------------------------------------------------------------------
480 *------------------------------------------------------------------------*/
481 zeroProd:
482 uiZ = uiC;
483 if ( ! (expC | sigC) && (signZ != signC) ) {
484 completeCancellation:
485 uiZ =
486 packToF64UI(
487 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
488 }
489 uiZ:
490 uZ.ui = uiZ;
491 return uZ.f;
492
493}
494
495#endif
496
deps/SoftFloat-3d/source/s_negXM.c deleted-63
......@@ -1,63 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_negXM
42
43void softfloat_negXM( uint_fast8_t size_words, uint32_t *zPtr )
44{
45 unsigned int index, lastIndex;
46 uint_fast8_t carry;
47 uint32_t word;
48
49 index = indexWordLo( size_words );
50 lastIndex = indexWordHi( size_words );
51 carry = 1;
52 for (;;) {
53 word = ~zPtr[index] + carry;
54 zPtr[index] = word;
55 if ( index == lastIndex ) break;
56 index += wordIncr;
57 if ( word ) carry = 0;
58 }
59
60}
61
62#endif
63
deps/SoftFloat-3d/source/s_normExtF80SigM.c deleted-52
......@@ -1,52 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40
41int softfloat_normExtF80SigM( uint64_t *sigPtr )
42{
43 uint64_t sig;
44 int_fast8_t shiftDist;
45
46 sig = *sigPtr;
47 shiftDist = softfloat_countLeadingZeros64( sig );
48 *sigPtr = sig<<shiftDist;
49 return -shiftDist;
50
51}
52
deps/SoftFloat-3d/source/s_normRoundPackMToExtF80M.c deleted-78
......@@ -1,78 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41
42void
43 softfloat_normRoundPackMToExtF80M(
44 bool sign,
45 int32_t exp,
46 uint32_t *extSigPtr,
47 uint_fast8_t roundingPrecision,
48 struct extFloat80M *zSPtr
49 )
50{
51 int_fast16_t shiftDist;
52 uint32_t wordSig;
53
54 shiftDist = 0;
55 wordSig = extSigPtr[indexWord( 3, 2 )];
56 if ( ! wordSig ) {
57 shiftDist = 32;
58 wordSig = extSigPtr[indexWord( 3, 1 )];
59 if ( ! wordSig ) {
60 shiftDist = 64;
61 wordSig = extSigPtr[indexWord( 3, 0 )];
62 if ( ! wordSig ) {
63 zSPtr->signExp = packToExtF80UI64( sign, 0 );
64 zSPtr->signif = 0;
65 return;
66 }
67 }
68 }
69 shiftDist += softfloat_countLeadingZeros32( wordSig );
70 if ( shiftDist ) {
71 exp -= shiftDist;
72 softfloat_shiftLeft96M( extSigPtr, shiftDist, extSigPtr );
73 }
74 softfloat_roundPackMToExtF80M(
75 sign, exp, extSigPtr, roundingPrecision, zSPtr );
76
77}
78
deps/SoftFloat-3d/source/s_normRoundPackMToF128M.c deleted-73
......@@ -1,73 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41
42void
43 softfloat_normRoundPackMToF128M(
44 bool sign, int32_t exp, uint32_t *extSigPtr, uint32_t *zWPtr )
45{
46 const uint32_t *ptr;
47 int_fast16_t shiftDist;
48 uint32_t wordSig;
49
50 ptr = extSigPtr + indexWordHi( 5 );
51 shiftDist = 0;
52 for (;;) {
53 wordSig = *ptr;
54 if ( wordSig ) break;
55 shiftDist += 32;
56 if ( 160 <= shiftDist ) {
57 zWPtr[indexWordHi( 4 )] = packToF128UI96( sign, 0, 0 );
58 zWPtr[indexWord( 4, 2 )] = 0;
59 zWPtr[indexWord( 4, 1 )] = 0;
60 zWPtr[indexWord( 4, 0 )] = 0;
61 return;
62 }
63 ptr -= wordIncr;
64 }
65 shiftDist += softfloat_countLeadingZeros32( wordSig ) - 15;
66 if ( shiftDist ) {
67 exp -= shiftDist;
68 softfloat_shiftLeft160M( extSigPtr, shiftDist, extSigPtr );
69 }
70 softfloat_roundPackMToF128M( sign, exp, extSigPtr, zWPtr );
71
72}
73
deps/SoftFloat-3d/source/s_normRoundPackToExtF80.c deleted-71
......@@ -1,71 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41
42extFloat80_t
43 softfloat_normRoundPackToExtF80(
44 bool sign,
45 int_fast32_t exp,
46 uint_fast64_t sig,
47 uint_fast64_t sigExtra,
48 uint_fast8_t roundingPrecision
49 )
50{
51 int_fast8_t shiftDist;
52 struct uint128 sig128;
53
54 if ( ! sig ) {
55 exp -= 64;
56 sig = sigExtra;
57 sigExtra = 0;
58 }
59 shiftDist = softfloat_countLeadingZeros64( sig );
60 exp -= shiftDist;
61 if ( shiftDist ) {
62 sig128 = softfloat_shortShiftLeft128( sig, sigExtra, shiftDist );
63 sig = sig128.v64;
64 sigExtra = sig128.v0;
65 }
66 return
67 softfloat_roundPackToExtF80(
68 sign, exp, sig, sigExtra, roundingPrecision );
69
70}
71
deps/SoftFloat-3d/source/s_normRoundPackToF128.c deleted-81
......@@ -1,81 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41
42float128_t
43 softfloat_normRoundPackToF128(
44 bool sign, int_fast32_t exp, uint_fast64_t sig64, uint_fast64_t sig0 )
45{
46 int_fast8_t shiftDist;
47 struct uint128 sig128;
48 union ui128_f128 uZ;
49 uint_fast64_t sigExtra;
50 struct uint128_extra sig128Extra;
51
52 if ( ! sig64 ) {
53 exp -= 64;
54 sig64 = sig0;
55 sig0 = 0;
56 }
57 shiftDist = softfloat_countLeadingZeros64( sig64 ) - 15;
58 exp -= shiftDist;
59 if ( 0 <= shiftDist ) {
60 if ( shiftDist ) {
61 sig128 = softfloat_shortShiftLeft128( sig64, sig0, shiftDist );
62 sig64 = sig128.v64;
63 sig0 = sig128.v0;
64 }
65 if ( (uint32_t) exp < 0x7FFD ) {
66 uZ.ui.v64 = packToF128UI64( sign, sig64 | sig0 ? exp : 0, sig64 );
67 uZ.ui.v0 = sig0;
68 return uZ.f;
69 }
70 sigExtra = 0;
71 } else {
72 sig128Extra =
73 softfloat_shortShiftRightJam128Extra( sig64, sig0, 0, -shiftDist );
74 sig64 = sig128Extra.v.v64;
75 sig0 = sig128Extra.v.v0;
76 sigExtra = sig128Extra.extra;
77 }
78 return softfloat_roundPackToF128( sign, exp, sig64, sig0, sigExtra );
79
80}
81
deps/SoftFloat-3d/source/s_normRoundPackToF16.c deleted-58
......@@ -1,58 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41
42float16_t
43 softfloat_normRoundPackToF16( bool sign, int_fast16_t exp, uint_fast16_t sig )
44{
45 int_fast8_t shiftDist;
46 union ui16_f16 uZ;
47
48 shiftDist = softfloat_countLeadingZeros16( sig ) - 1;
49 exp -= shiftDist;
50 if ( (4 <= shiftDist) && ((unsigned int) exp < 0x1D) ) {
51 uZ.ui = packToF16UI( sign, sig ? exp : 0, sig<<(shiftDist - 4) );
52 return uZ.f;
53 } else {
54 return softfloat_roundPackToF16( sign, exp, sig<<shiftDist );
55 }
56
57}
58
deps/SoftFloat-3d/source/s_normRoundPackToF32.c deleted-58
......@@ -1,58 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41
42float32_t
43 softfloat_normRoundPackToF32( bool sign, int_fast16_t exp, uint_fast32_t sig )
44{
45 int_fast8_t shiftDist;
46 union ui32_f32 uZ;
47
48 shiftDist = softfloat_countLeadingZeros32( sig ) - 1;
49 exp -= shiftDist;
50 if ( (7 <= shiftDist) && ((unsigned int) exp < 0xFD) ) {
51 uZ.ui = packToF32UI( sign, sig ? exp : 0, sig<<(shiftDist - 7) );
52 return uZ.f;
53 } else {
54 return softfloat_roundPackToF32( sign, exp, sig<<shiftDist );
55 }
56
57}
58
deps/SoftFloat-3d/source/s_normRoundPackToF64.c deleted-58
......@@ -1,58 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41
42float64_t
43 softfloat_normRoundPackToF64( bool sign, int_fast16_t exp, uint_fast64_t sig )
44{
45 int_fast8_t shiftDist;
46 union ui64_f64 uZ;
47
48 shiftDist = softfloat_countLeadingZeros64( sig ) - 1;
49 exp -= shiftDist;
50 if ( (10 <= shiftDist) && ((unsigned int) exp < 0x7FD) ) {
51 uZ.ui = packToF64UI( sign, sig ? exp : 0, sig<<(shiftDist - 10) );
52 return uZ.f;
53 } else {
54 return softfloat_roundPackToF64( sign, exp, sig<<shiftDist );
55 }
56
57}
58
deps/SoftFloat-3d/source/s_normSubnormalExtF80Sig.c deleted-52
......@@ -1,52 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40
41struct exp32_sig64 softfloat_normSubnormalExtF80Sig( uint_fast64_t sig )
42{
43 int_fast8_t shiftDist;
44 struct exp32_sig64 z;
45
46 shiftDist = softfloat_countLeadingZeros64( sig );
47 z.exp = -shiftDist;
48 z.sig = sig<<shiftDist;
49 return z;
50
51}
52
deps/SoftFloat-3d/source/s_normSubnormalF128Sig.c deleted-65
......@@ -1,65 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40
41struct exp32_sig128
42 softfloat_normSubnormalF128Sig( uint_fast64_t sig64, uint_fast64_t sig0 )
43{
44 int_fast8_t shiftDist;
45 struct exp32_sig128 z;
46
47 if ( ! sig64 ) {
48 shiftDist = softfloat_countLeadingZeros64( sig0 ) - 15;
49 z.exp = -63 - shiftDist;
50 if ( shiftDist < 0 ) {
51 z.sig.v64 = sig0>>-shiftDist;
52 z.sig.v0 = sig0<<(shiftDist & 63);
53 } else {
54 z.sig.v64 = sig0<<shiftDist;
55 z.sig.v0 = 0;
56 }
57 } else {
58 shiftDist = softfloat_countLeadingZeros64( sig64 ) - 15;
59 z.exp = 1 - shiftDist;
60 z.sig = softfloat_shortShiftLeft128( sig64, sig0, shiftDist );
61 }
62 return z;
63
64}
65
deps/SoftFloat-3d/source/s_normSubnormalF128SigM.c deleted-61
......@@ -1,61 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40
41int softfloat_normSubnormalF128SigM( uint32_t *sigPtr )
42{
43 const uint32_t *ptr;
44 int_fast16_t shiftDist;
45 uint32_t wordSig;
46
47 ptr = sigPtr + indexWordHi( 4 );
48 shiftDist = 0;
49 for (;;) {
50 wordSig = *ptr;
51 if ( wordSig ) break;
52 shiftDist += 32;
53 if ( 128 <= shiftDist ) return 1;
54 ptr -= wordIncr;
55 }
56 shiftDist += softfloat_countLeadingZeros32( wordSig ) - 15;
57 if ( shiftDist ) softfloat_shiftLeft128M( sigPtr, shiftDist, sigPtr );
58 return 1 - shiftDist;
59
60}
61
deps/SoftFloat-3d/source/s_normSubnormalF16Sig.c deleted-52
......@@ -1,52 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40
41struct exp8_sig16 softfloat_normSubnormalF16Sig( uint_fast16_t sig )
42{
43 int_fast8_t shiftDist;
44 struct exp8_sig16 z;
45
46 shiftDist = softfloat_countLeadingZeros16( sig ) - 5;
47 z.exp = 1 - shiftDist;
48 z.sig = sig<<shiftDist;
49 return z;
50
51}
52
deps/SoftFloat-3d/source/s_normSubnormalF32Sig.c deleted-52
......@@ -1,52 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40
41struct exp16_sig32 softfloat_normSubnormalF32Sig( uint_fast32_t sig )
42{
43 int_fast8_t shiftDist;
44 struct exp16_sig32 z;
45
46 shiftDist = softfloat_countLeadingZeros32( sig ) - 8;
47 z.exp = 1 - shiftDist;
48 z.sig = sig<<shiftDist;
49 return z;
50
51}
52
deps/SoftFloat-3d/source/s_normSubnormalF64Sig.c deleted-52
......@@ -1,52 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40
41struct exp16_sig64 softfloat_normSubnormalF64Sig( uint_fast64_t sig )
42{
43 int_fast8_t shiftDist;
44 struct exp16_sig64 z;
45
46 shiftDist = softfloat_countLeadingZeros64( sig ) - 11;
47 z.exp = 1 - shiftDist;
48 z.sig = sig<<shiftDist;
49 return z;
50
51}
52
deps/SoftFloat-3d/source/s_remStepMBy32.c deleted-86
......@@ -1,86 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_remStepMBy32
42
43void
44 softfloat_remStepMBy32(
45 uint_fast8_t size_words,
46 const uint32_t *remPtr,
47 uint_fast8_t dist,
48 const uint32_t *bPtr,
49 uint32_t q,
50 uint32_t *zPtr
51 )
52{
53 unsigned int index, lastIndex;
54 uint64_t dwordProd;
55 uint32_t wordRem, wordShiftedRem, wordProd;
56 uint_fast8_t uNegDist, borrow;
57
58 index = indexWordLo( size_words );
59 lastIndex = indexWordHi( size_words );
60 dwordProd = (uint64_t) bPtr[index] * q;
61 wordRem = remPtr[index];
62 wordShiftedRem = wordRem<<dist;
63 wordProd = dwordProd;
64 zPtr[index] = wordShiftedRem - wordProd;
65 if ( index != lastIndex ) {
66 uNegDist = -dist;
67 borrow = (wordShiftedRem < wordProd);
68 for (;;) {
69 wordShiftedRem = wordRem>>(uNegDist & 31);
70 index += wordIncr;
71 dwordProd = (uint64_t) bPtr[index] * q + (dwordProd>>32);
72 wordRem = remPtr[index];
73 wordShiftedRem |= wordRem<<dist;
74 wordProd = dwordProd;
75 zPtr[index] = wordShiftedRem - wordProd - borrow;
76 if ( index == lastIndex ) break;
77 borrow =
78 borrow ? (wordShiftedRem <= wordProd)
79 : (wordShiftedRem < wordProd);
80 }
81 }
82
83}
84
85#endif
86
deps/SoftFloat-3d/source/s_roundMToI64.c deleted-88
......@@ -1,88 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t
45 softfloat_roundMToI64(
46 bool sign, uint32_t *extSigPtr, uint_fast8_t roundingMode, bool exact )
47{
48 bool roundNearEven;
49 uint32_t sigExtra;
50 bool doIncrement;
51 uint64_t sig;
52 union { uint64_t ui; int64_t i; } uZ;
53 int64_t z;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 roundNearEven = (roundingMode == softfloat_round_near_even);
58 sigExtra = extSigPtr[indexWordLo( 3 )];
59 doIncrement = (0x80000000 <= sigExtra);
60 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
61 doIncrement =
62 (roundingMode
63 == (sign ? softfloat_round_min : softfloat_round_max))
64 && sigExtra;
65 }
66 sig =
67 (uint64_t) extSigPtr[indexWord( 3, 2 )]<<32
68 | extSigPtr[indexWord( 3, 1 )];
69 if ( doIncrement ) {
70 ++sig;
71 if ( ! sig ) goto invalid;
72 if ( ! (sigExtra & 0x7FFFFFFF) && roundNearEven ) sig &= ~1;
73 }
74 uZ.ui = sign ? -sig : sig;
75 z = uZ.i;
76 if ( z && ((z < 0) ^ sign) ) goto invalid;
77 if ( exact && sigExtra ) {
78 softfloat_exceptionFlags |= softfloat_flag_inexact;
79 }
80 return z;
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 invalid:
84 softfloat_raiseFlags( softfloat_flag_invalid );
85 return sign ? i64_fromNegOverflow : i64_fromPosOverflow;
86
87}
88
deps/SoftFloat-3d/source/s_roundMToUI64.c deleted-84
......@@ -1,84 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t
45 softfloat_roundMToUI64(
46 bool sign, uint32_t *extSigPtr, uint_fast8_t roundingMode, bool exact )
47{
48 bool roundNearEven;
49 uint32_t sigExtra;
50 bool doIncrement;
51 uint64_t sig;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 roundNearEven = (roundingMode == softfloat_round_near_even);
56 sigExtra = extSigPtr[indexWordLo( 3 )];
57 doIncrement = (0x80000000 <= sigExtra);
58 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
59 doIncrement =
60 (roundingMode
61 == (sign ? softfloat_round_min : softfloat_round_max))
62 && sigExtra;
63 }
64 sig =
65 (uint64_t) extSigPtr[indexWord( 3, 2 )]<<32
66 | extSigPtr[indexWord( 3, 1 )];
67 if ( doIncrement ) {
68 ++sig;
69 if ( ! sig ) goto invalid;
70 if ( ! (sigExtra & 0x7FFFFFFF) && roundNearEven ) sig &= ~1;
71 }
72 if ( sign && sig ) goto invalid;
73 if ( exact && sigExtra ) {
74 softfloat_exceptionFlags |= softfloat_flag_inexact;
75 }
76 return sig;
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 invalid:
80 softfloat_raiseFlags( softfloat_flag_invalid );
81 return sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
82
83}
84
deps/SoftFloat-3d/source/s_roundPackMToExtF80M.c deleted-256
......@@ -1,256 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43void
44 softfloat_roundPackMToExtF80M(
45 bool sign,
46 int32_t exp,
47 uint32_t *extSigPtr,
48 uint_fast8_t roundingPrecision,
49 struct extFloat80M *zSPtr
50 )
51{
52 uint_fast8_t roundingMode;
53 bool roundNearEven;
54 uint64_t sig, roundIncrement, roundMask, roundBits;
55 bool isTiny;
56 uint32_t sigExtra;
57 bool doIncrement;
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 roundingMode = softfloat_roundingMode;
62 roundNearEven = (roundingMode == softfloat_round_near_even);
63 sig =
64 (uint64_t) extSigPtr[indexWord( 3, 2 )]<<32
65 | extSigPtr[indexWord( 3, 1 )];
66 if ( roundingPrecision == 80 ) goto precision80;
67 if ( roundingPrecision == 64 ) {
68 roundIncrement = UINT64_C( 0x0000000000000400 );
69 roundMask = UINT64_C( 0x00000000000007FF );
70 } else if ( roundingPrecision == 32 ) {
71 roundIncrement = UINT64_C( 0x0000008000000000 );
72 roundMask = UINT64_C( 0x000000FFFFFFFFFF );
73 } else {
74 goto precision80;
75 }
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( extSigPtr[indexWordLo( 3 )] ) sig |= 1;
79 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
80 roundIncrement =
81 (roundingMode
82 == (sign ? softfloat_round_min : softfloat_round_max))
83 ? roundMask
84 : 0;
85 }
86 roundBits = sig & roundMask;
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 if ( 0x7FFD <= (uint32_t) (exp - 1) ) {
90 if ( exp <= 0 ) {
91 /*----------------------------------------------------------------
92 *----------------------------------------------------------------*/
93 isTiny =
94 (softfloat_detectTininess
95 == softfloat_tininess_beforeRounding)
96 || (exp < 0)
97 || (sig <= (uint64_t) (sig + roundIncrement));
98 sig = softfloat_shiftRightJam64( sig, 1 - exp );
99 roundBits = sig & roundMask;
100 if ( roundBits ) {
101 if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );
102 softfloat_exceptionFlags |= softfloat_flag_inexact;
103#ifdef SOFTFLOAT_ROUND_ODD
104 if ( roundingMode == softfloat_round_odd ) {
105 sig |= roundMask + 1;
106 }
107#endif
108 }
109 sig += roundIncrement;
110 exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);
111 roundIncrement = roundMask + 1;
112 if ( roundNearEven && (roundBits<<1 == roundIncrement) ) {
113 roundMask |= roundIncrement;
114 }
115 sig &= ~roundMask;
116 goto packReturn;
117 }
118 if (
119 (0x7FFE < exp)
120 || ((exp == 0x7FFE) && ((uint64_t) (sig + roundIncrement) < sig))
121 ) {
122 goto overflow;
123 }
124 }
125 /*------------------------------------------------------------------------
126 *------------------------------------------------------------------------*/
127 if ( roundBits ) {
128 softfloat_exceptionFlags |= softfloat_flag_inexact;
129#ifdef SOFTFLOAT_ROUND_ODD
130 if ( roundingMode == softfloat_round_odd ) {
131 sig = (sig & ~roundMask) | (roundMask + 1);
132 goto packReturn;
133 }
134#endif
135 }
136 sig += roundIncrement;
137 if ( sig < roundIncrement ) {
138 ++exp;
139 sig = UINT64_C( 0x8000000000000000 );
140 }
141 roundIncrement = roundMask + 1;
142 if ( roundNearEven && (roundBits<<1 == roundIncrement) ) {
143 roundMask |= roundIncrement;
144 }
145 sig &= ~roundMask;
146 goto packReturn;
147 /*------------------------------------------------------------------------
148 *------------------------------------------------------------------------*/
149 precision80:
150 sigExtra = extSigPtr[indexWordLo( 3 )];
151 doIncrement = (0x80000000 <= sigExtra);
152 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
153 doIncrement =
154 (roundingMode
155 == (sign ? softfloat_round_min : softfloat_round_max))
156 && sigExtra;
157 }
158 /*------------------------------------------------------------------------
159 *------------------------------------------------------------------------*/
160 if ( 0x7FFD <= (uint32_t) (exp - 1) ) {
161 if ( exp <= 0 ) {
162 /*----------------------------------------------------------------
163 *----------------------------------------------------------------*/
164 isTiny =
165 (softfloat_detectTininess
166 == softfloat_tininess_beforeRounding)
167 || (exp < 0)
168 || ! doIncrement
169 || (sig < UINT64_C( 0xFFFFFFFFFFFFFFFF ));
170 softfloat_shiftRightJam96M( extSigPtr, 1 - exp, extSigPtr );
171 exp = 0;
172 sig =
173 (uint64_t) extSigPtr[indexWord( 3, 2 )]<<32
174 | extSigPtr[indexWord( 3, 1 )];
175 sigExtra = extSigPtr[indexWordLo( 3 )];
176 if ( sigExtra ) {
177 if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );
178 softfloat_exceptionFlags |= softfloat_flag_inexact;
179#ifdef SOFTFLOAT_ROUND_ODD
180 if ( roundingMode == softfloat_round_odd ) {
181 sig |= 1;
182 goto packReturn;
183 }
184#endif
185 }
186 doIncrement = (0x80000000 <= sigExtra);
187 if (
188 ! roundNearEven
189 && (roundingMode != softfloat_round_near_maxMag)
190 ) {
191 doIncrement =
192 (roundingMode
193 == (sign ? softfloat_round_min : softfloat_round_max))
194 && sigExtra;
195 }
196 if ( doIncrement ) {
197 ++sig;
198 sig &= ~(uint64_t) (! (sigExtra & 0x7FFFFFFF) & roundNearEven);
199 exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);
200 }
201 goto packReturn;
202 }
203 if (
204 (0x7FFE < exp)
205 || ((exp == 0x7FFE) && (sig == UINT64_C( 0xFFFFFFFFFFFFFFFF ))
206 && doIncrement)
207 ) {
208 /*----------------------------------------------------------------
209 *----------------------------------------------------------------*/
210 roundMask = 0;
211 overflow:
212 softfloat_raiseFlags(
213 softfloat_flag_overflow | softfloat_flag_inexact );
214 if (
215 roundNearEven
216 || (roundingMode == softfloat_round_near_maxMag)
217 || (roundingMode
218 == (sign ? softfloat_round_min : softfloat_round_max))
219 ) {
220 exp = 0x7FFF;
221 sig = UINT64_C( 0x8000000000000000 );
222 } else {
223 exp = 0x7FFE;
224 sig = ~roundMask;
225 }
226 goto packReturn;
227 }
228 }
229 /*------------------------------------------------------------------------
230 *------------------------------------------------------------------------*/
231 if ( sigExtra ) {
232 softfloat_exceptionFlags |= softfloat_flag_inexact;
233#ifdef SOFTFLOAT_ROUND_ODD
234 if ( roundingMode == softfloat_round_odd ) {
235 sig |= 1;
236 goto packReturn;
237 }
238#endif
239 }
240 if ( doIncrement ) {
241 ++sig;
242 if ( ! sig ) {
243 ++exp;
244 sig = UINT64_C( 0x8000000000000000 );
245 } else {
246 sig &= ~(uint64_t) (! (sigExtra & 0x7FFFFFFF) & roundNearEven);
247 }
248 }
249 /*------------------------------------------------------------------------
250 *------------------------------------------------------------------------*/
251 packReturn:
252 zSPtr->signExp = packToExtF80UI64( sign, exp );
253 zSPtr->signif = sig;
254
255}
256
deps/SoftFloat-3d/source/s_roundPackMToF128M.c deleted-178
......@@ -1,178 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43void
44 softfloat_roundPackMToF128M(
45 bool sign, int32_t exp, uint32_t *extSigPtr, uint32_t *zWPtr )
46{
47 uint_fast8_t roundingMode;
48 bool roundNearEven;
49 uint32_t sigExtra;
50 bool doIncrement, isTiny;
51 static const uint32_t maxSig[4] =
52 INIT_UINTM4( 0x0001FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF );
53 uint32_t ui, uj;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 roundingMode = softfloat_roundingMode;
58 roundNearEven = (roundingMode == softfloat_round_near_even);
59 sigExtra = extSigPtr[indexWordLo( 5 )];
60 doIncrement = (0x80000000 <= sigExtra);
61 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
62 doIncrement =
63 (roundingMode
64 == (sign ? softfloat_round_min : softfloat_round_max))
65 && sigExtra;
66 }
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 if ( 0x7FFD <= (uint32_t) exp ) {
70 if ( exp < 0 ) {
71 /*----------------------------------------------------------------
72 *----------------------------------------------------------------*/
73 isTiny =
74 (softfloat_detectTininess
75 == softfloat_tininess_beforeRounding)
76 || (exp < -1)
77 || ! doIncrement
78 || (softfloat_compare128M(
79 extSigPtr + indexMultiwordHi( 5, 4 ), maxSig )
80 < 0);
81 softfloat_shiftRightJam160M( extSigPtr, -exp, extSigPtr );
82 exp = 0;
83 sigExtra = extSigPtr[indexWordLo( 5 )];
84 if ( isTiny && sigExtra ) {
85 softfloat_raiseFlags( softfloat_flag_underflow );
86 }
87 doIncrement = (0x80000000 <= sigExtra);
88 if (
89 ! roundNearEven
90 && (roundingMode != softfloat_round_near_maxMag)
91 ) {
92 doIncrement =
93 (roundingMode
94 == (sign ? softfloat_round_min : softfloat_round_max))
95 && sigExtra;
96 }
97 } else if (
98 (0x7FFD < exp)
99 || ((exp == 0x7FFD) && doIncrement
100 && (softfloat_compare128M(
101 extSigPtr + indexMultiwordHi( 5, 4 ), maxSig )
102 == 0))
103 ) {
104 /*----------------------------------------------------------------
105 *----------------------------------------------------------------*/
106 softfloat_raiseFlags(
107 softfloat_flag_overflow | softfloat_flag_inexact );
108 if (
109 roundNearEven
110 || (roundingMode == softfloat_round_near_maxMag)
111 || (roundingMode
112 == (sign ? softfloat_round_min : softfloat_round_max))
113 ) {
114 ui = packToF128UI96( sign, 0x7FFF, 0 );
115 uj = 0;
116 } else {
117 ui = packToF128UI96( sign, 0x7FFE, 0x0000FFFF );
118 uj = 0xFFFFFFFF;
119 }
120 zWPtr[indexWordHi( 4 )] = ui;
121 zWPtr[indexWord( 4, 2 )] = uj;
122 zWPtr[indexWord( 4, 1 )] = uj;
123 zWPtr[indexWord( 4, 0 )] = uj;
124 return;
125 }
126 }
127 /*------------------------------------------------------------------------
128 *------------------------------------------------------------------------*/
129 uj = extSigPtr[indexWord( 5, 1 )];
130 if ( sigExtra ) {
131 softfloat_exceptionFlags |= softfloat_flag_inexact;
132#ifdef SOFTFLOAT_ROUND_ODD
133 if ( roundingMode == softfloat_round_odd ) {
134 uj |= 1;
135 goto noIncrementPackReturn;
136 }
137#endif
138 }
139 if ( doIncrement ) {
140 ++uj;
141 if ( uj ) {
142 if ( ! (sigExtra & 0x7FFFFFFF) && roundNearEven ) uj &= ~1;
143 zWPtr[indexWord( 4, 2 )] = extSigPtr[indexWord( 5, 3 )];
144 zWPtr[indexWord( 4, 1 )] = extSigPtr[indexWord( 5, 2 )];
145 zWPtr[indexWord( 4, 0 )] = uj;
146 ui = extSigPtr[indexWordHi( 5 )];
147 } else {
148 zWPtr[indexWord( 4, 0 )] = uj;
149 ui = extSigPtr[indexWord( 5, 2 )] + 1;
150 zWPtr[indexWord( 4, 1 )] = ui;
151 uj = extSigPtr[indexWord( 5, 3 )];
152 if ( ui ) {
153 zWPtr[indexWord( 4, 2 )] = uj;
154 ui = extSigPtr[indexWordHi( 5 )];
155 } else {
156 ++uj;
157 zWPtr[indexWord( 4, 2 )] = uj;
158 ui = extSigPtr[indexWordHi( 5 )];
159 if ( ! uj ) ++ui;
160 }
161 }
162 } else {
163 noIncrementPackReturn:
164 zWPtr[indexWord( 4, 0 )] = uj;
165 ui = extSigPtr[indexWord( 5, 2 )];
166 zWPtr[indexWord( 4, 1 )] = ui;
167 uj |= ui;
168 ui = extSigPtr[indexWord( 5, 3 )];
169 zWPtr[indexWord( 4, 2 )] = ui;
170 uj |= ui;
171 ui = extSigPtr[indexWordHi( 5 )];
172 uj |= ui;
173 if ( ! uj ) exp = 0;
174 }
175 zWPtr[indexWordHi( 4 )] = packToF128UI96( sign, exp, ui );
176
177}
178
deps/SoftFloat-3d/source/s_roundPackToExtF80.c deleted-256
......@@ -1,256 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43extFloat80_t
44 softfloat_roundPackToExtF80(
45 bool sign,
46 int_fast32_t exp,
47 uint_fast64_t sig,
48 uint_fast64_t sigExtra,
49 uint_fast8_t roundingPrecision
50 )
51{
52 uint_fast8_t roundingMode;
53 bool roundNearEven;
54 uint_fast64_t roundIncrement, roundMask, roundBits;
55 bool isTiny, doIncrement;
56 struct uint64_extra sig64Extra;
57 union { struct extFloat80M s; extFloat80_t f; } uZ;
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 roundingMode = softfloat_roundingMode;
62 roundNearEven = (roundingMode == softfloat_round_near_even);
63 if ( roundingPrecision == 80 ) goto precision80;
64 if ( roundingPrecision == 64 ) {
65 roundIncrement = UINT64_C( 0x0000000000000400 );
66 roundMask = UINT64_C( 0x00000000000007FF );
67 } else if ( roundingPrecision == 32 ) {
68 roundIncrement = UINT64_C( 0x0000008000000000 );
69 roundMask = UINT64_C( 0x000000FFFFFFFFFF );
70 } else {
71 goto precision80;
72 }
73 sig |= (sigExtra != 0);
74 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
75 roundIncrement =
76 (roundingMode
77 == (sign ? softfloat_round_min : softfloat_round_max))
78 ? roundMask
79 : 0;
80 }
81 roundBits = sig & roundMask;
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( 0x7FFD <= (uint32_t) (exp - 1) ) {
85 if ( exp <= 0 ) {
86 /*----------------------------------------------------------------
87 *----------------------------------------------------------------*/
88 isTiny =
89 (softfloat_detectTininess
90 == softfloat_tininess_beforeRounding)
91 || (exp < 0)
92 || (sig <= (uint64_t) (sig + roundIncrement));
93 sig = softfloat_shiftRightJam64( sig, 1 - exp );
94 roundBits = sig & roundMask;
95 if ( roundBits ) {
96 if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );
97 softfloat_exceptionFlags |= softfloat_flag_inexact;
98#ifdef SOFTFLOAT_ROUND_ODD
99 if ( roundingMode == softfloat_round_odd ) {
100 sig |= roundMask + 1;
101 }
102#endif
103 }
104 sig += roundIncrement;
105 exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);
106 roundIncrement = roundMask + 1;
107 if ( roundNearEven && (roundBits<<1 == roundIncrement) ) {
108 roundMask |= roundIncrement;
109 }
110 sig &= ~roundMask;
111 goto packReturn;
112 }
113 if (
114 (0x7FFE < exp)
115 || ((exp == 0x7FFE) && ((uint64_t) (sig + roundIncrement) < sig))
116 ) {
117 goto overflow;
118 }
119 }
120 /*------------------------------------------------------------------------
121 *------------------------------------------------------------------------*/
122 if ( roundBits ) {
123 softfloat_exceptionFlags |= softfloat_flag_inexact;
124#ifdef SOFTFLOAT_ROUND_ODD
125 if ( roundingMode == softfloat_round_odd ) {
126 sig = (sig & ~roundMask) | (roundMask + 1);
127 goto packReturn;
128 }
129#endif
130 }
131 sig = (uint64_t) (sig + roundIncrement);
132 if ( sig < roundIncrement ) {
133 ++exp;
134 sig = UINT64_C( 0x8000000000000000 );
135 }
136 roundIncrement = roundMask + 1;
137 if ( roundNearEven && (roundBits<<1 == roundIncrement) ) {
138 roundMask |= roundIncrement;
139 }
140 sig &= ~roundMask;
141 goto packReturn;
142 /*------------------------------------------------------------------------
143 *------------------------------------------------------------------------*/
144 precision80:
145 doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
146 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
147 doIncrement =
148 (roundingMode
149 == (sign ? softfloat_round_min : softfloat_round_max))
150 && sigExtra;
151 }
152 /*------------------------------------------------------------------------
153 *------------------------------------------------------------------------*/
154 if ( 0x7FFD <= (uint32_t) (exp - 1) ) {
155 if ( exp <= 0 ) {
156 /*----------------------------------------------------------------
157 *----------------------------------------------------------------*/
158 isTiny =
159 (softfloat_detectTininess
160 == softfloat_tininess_beforeRounding)
161 || (exp < 0)
162 || ! doIncrement
163 || (sig < UINT64_C( 0xFFFFFFFFFFFFFFFF ));
164 sig64Extra =
165 softfloat_shiftRightJam64Extra( sig, sigExtra, 1 - exp );
166 exp = 0;
167 sig = sig64Extra.v;
168 sigExtra = sig64Extra.extra;
169 if ( sigExtra ) {
170 if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );
171 softfloat_exceptionFlags |= softfloat_flag_inexact;
172#ifdef SOFTFLOAT_ROUND_ODD
173 if ( roundingMode == softfloat_round_odd ) {
174 sig |= 1;
175 goto packReturn;
176 }
177#endif
178 }
179 doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
180 if (
181 ! roundNearEven
182 && (roundingMode != softfloat_round_near_maxMag)
183 ) {
184 doIncrement =
185 (roundingMode
186 == (sign ? softfloat_round_min : softfloat_round_max))
187 && sigExtra;
188 }
189 if ( doIncrement ) {
190 ++sig;
191 sig &=
192 ~(uint_fast64_t)
193 (! (sigExtra & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
194 & roundNearEven);
195 exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);
196 }
197 goto packReturn;
198 }
199 if (
200 (0x7FFE < exp)
201 || ((exp == 0x7FFE) && (sig == UINT64_C( 0xFFFFFFFFFFFFFFFF ))
202 && doIncrement)
203 ) {
204 /*----------------------------------------------------------------
205 *----------------------------------------------------------------*/
206 roundMask = 0;
207 overflow:
208 softfloat_raiseFlags(
209 softfloat_flag_overflow | softfloat_flag_inexact );
210 if (
211 roundNearEven
212 || (roundingMode == softfloat_round_near_maxMag)
213 || (roundingMode
214 == (sign ? softfloat_round_min : softfloat_round_max))
215 ) {
216 exp = 0x7FFF;
217 sig = UINT64_C( 0x8000000000000000 );
218 } else {
219 exp = 0x7FFE;
220 sig = ~roundMask;
221 }
222 goto packReturn;
223 }
224 }
225 /*------------------------------------------------------------------------
226 *------------------------------------------------------------------------*/
227 if ( sigExtra ) {
228 softfloat_exceptionFlags |= softfloat_flag_inexact;
229#ifdef SOFTFLOAT_ROUND_ODD
230 if ( roundingMode == softfloat_round_odd ) {
231 sig |= 1;
232 goto packReturn;
233 }
234#endif
235 }
236 if ( doIncrement ) {
237 ++sig;
238 if ( ! sig ) {
239 ++exp;
240 sig = UINT64_C( 0x8000000000000000 );
241 } else {
242 sig &=
243 ~(uint_fast64_t)
244 (! (sigExtra & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
245 & roundNearEven);
246 }
247 }
248 /*------------------------------------------------------------------------
249 *------------------------------------------------------------------------*/
250 packReturn:
251 uZ.s.signExp = packToExtF80UI64( sign, exp );
252 uZ.s.signif = sig;
253 return uZ.f;
254
255}
256
deps/SoftFloat-3d/source/s_roundPackToF128.c deleted-171
......@@ -1,171 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float128_t
44 softfloat_roundPackToF128(
45 bool sign,
46 int_fast32_t exp,
47 uint_fast64_t sig64,
48 uint_fast64_t sig0,
49 uint_fast64_t sigExtra
50 )
51{
52 uint_fast8_t roundingMode;
53 bool roundNearEven, doIncrement, isTiny;
54 struct uint128_extra sig128Extra;
55 uint_fast64_t uiZ64, uiZ0;
56 struct uint128 sig128;
57 union ui128_f128 uZ;
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 roundingMode = softfloat_roundingMode;
62 roundNearEven = (roundingMode == softfloat_round_near_even);
63 doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
64 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
65 doIncrement =
66 (roundingMode
67 == (sign ? softfloat_round_min : softfloat_round_max))
68 && sigExtra;
69 }
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 if ( 0x7FFD <= (uint32_t) exp ) {
73 if ( exp < 0 ) {
74 /*----------------------------------------------------------------
75 *----------------------------------------------------------------*/
76 isTiny =
77 (softfloat_detectTininess
78 == softfloat_tininess_beforeRounding)
79 || (exp < -1)
80 || ! doIncrement
81 || softfloat_lt128(
82 sig64,
83 sig0,
84 UINT64_C( 0x0001FFFFFFFFFFFF ),
85 UINT64_C( 0xFFFFFFFFFFFFFFFF )
86 );
87 sig128Extra =
88 softfloat_shiftRightJam128Extra( sig64, sig0, sigExtra, -exp );
89 sig64 = sig128Extra.v.v64;
90 sig0 = sig128Extra.v.v0;
91 sigExtra = sig128Extra.extra;
92 exp = 0;
93 if ( isTiny && sigExtra ) {
94 softfloat_raiseFlags( softfloat_flag_underflow );
95 }
96 doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
97 if (
98 ! roundNearEven
99 && (roundingMode != softfloat_round_near_maxMag)
100 ) {
101 doIncrement =
102 (roundingMode
103 == (sign ? softfloat_round_min : softfloat_round_max))
104 && sigExtra;
105 }
106 } else if (
107 (0x7FFD < exp)
108 || ((exp == 0x7FFD)
109 && softfloat_eq128(
110 sig64,
111 sig0,
112 UINT64_C( 0x0001FFFFFFFFFFFF ),
113 UINT64_C( 0xFFFFFFFFFFFFFFFF )
114 )
115 && doIncrement)
116 ) {
117 /*----------------------------------------------------------------
118 *----------------------------------------------------------------*/
119 softfloat_raiseFlags(
120 softfloat_flag_overflow | softfloat_flag_inexact );
121 if (
122 roundNearEven
123 || (roundingMode == softfloat_round_near_maxMag)
124 || (roundingMode
125 == (sign ? softfloat_round_min : softfloat_round_max))
126 ) {
127 uiZ64 = packToF128UI64( sign, 0x7FFF, 0 );
128 uiZ0 = 0;
129 } else {
130 uiZ64 =
131 packToF128UI64(
132 sign, 0x7FFE, UINT64_C( 0x0000FFFFFFFFFFFF ) );
133 uiZ0 = UINT64_C( 0xFFFFFFFFFFFFFFFF );
134 }
135 goto uiZ;
136 }
137 }
138 /*------------------------------------------------------------------------
139 *------------------------------------------------------------------------*/
140 if ( sigExtra ) {
141 softfloat_exceptionFlags |= softfloat_flag_inexact;
142#ifdef SOFTFLOAT_ROUND_ODD
143 if ( roundingMode == softfloat_round_odd ) {
144 sig0 |= 1;
145 goto packReturn;
146 }
147#endif
148 }
149 if ( doIncrement ) {
150 sig128 = softfloat_add128( sig64, sig0, 0, 1 );
151 sig64 = sig128.v64;
152 sig0 =
153 sig128.v0
154 & ~(uint64_t)
155 (! (sigExtra & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
156 & roundNearEven);
157 } else {
158 if ( ! (sig64 | sig0) ) exp = 0;
159 }
160 /*------------------------------------------------------------------------
161 *------------------------------------------------------------------------*/
162 packReturn:
163 uiZ64 = packToF128UI64( sign, exp, sig64 );
164 uiZ0 = sig0;
165 uiZ:
166 uZ.ui.v64 = uiZ64;
167 uZ.ui.v0 = uiZ0;
168 return uZ.f;
169
170}
171
deps/SoftFloat-3d/source/s_roundPackToF16.c deleted-113
......@@ -1,113 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float16_t
44 softfloat_roundPackToF16( bool sign, int_fast16_t exp, uint_fast16_t sig )
45{
46 uint_fast8_t roundingMode;
47 bool roundNearEven;
48 uint_fast8_t roundIncrement, roundBits;
49 bool isTiny;
50 uint_fast16_t uiZ;
51 union ui16_f16 uZ;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 roundingMode = softfloat_roundingMode;
56 roundNearEven = (roundingMode == softfloat_round_near_even);
57 roundIncrement = 0x8;
58 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
59 roundIncrement =
60 (roundingMode
61 == (sign ? softfloat_round_min : softfloat_round_max))
62 ? 0xF
63 : 0;
64 }
65 roundBits = sig & 0xF;
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 if ( 0x1D <= (unsigned int) exp ) {
69 if ( exp < 0 ) {
70 /*----------------------------------------------------------------
71 *----------------------------------------------------------------*/
72 isTiny =
73 (softfloat_detectTininess == softfloat_tininess_beforeRounding)
74 || (exp < -1) || (sig + roundIncrement < 0x8000);
75 sig = softfloat_shiftRightJam32( sig, -exp );
76 exp = 0;
77 roundBits = sig & 0xF;
78 if ( isTiny && roundBits ) {
79 softfloat_raiseFlags( softfloat_flag_underflow );
80 }
81 } else if ( (0x1D < exp) || (0x8000 <= sig + roundIncrement) ) {
82 /*----------------------------------------------------------------
83 *----------------------------------------------------------------*/
84 softfloat_raiseFlags(
85 softfloat_flag_overflow | softfloat_flag_inexact );
86 uiZ = packToF16UI( sign, 0x1F, 0 ) - ! roundIncrement;
87 goto uiZ;
88 }
89 }
90 /*------------------------------------------------------------------------
91 *------------------------------------------------------------------------*/
92 sig = (sig + roundIncrement)>>4;
93 if ( roundBits ) {
94 softfloat_exceptionFlags |= softfloat_flag_inexact;
95#ifdef SOFTFLOAT_ROUND_ODD
96 if ( roundingMode == softfloat_round_odd ) {
97 sig |= 1;
98 goto packReturn;
99 }
100#endif
101 }
102 sig &= ~(uint_fast16_t) (! (roundBits ^ 8) & roundNearEven);
103 if ( ! sig ) exp = 0;
104 /*------------------------------------------------------------------------
105 *------------------------------------------------------------------------*/
106 packReturn:
107 uiZ = packToF16UI( sign, exp, sig );
108 uiZ:
109 uZ.ui = uiZ;
110 return uZ.f;
111
112}
113
deps/SoftFloat-3d/source/s_roundPackToF32.c deleted-113
......@@ -1,113 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float32_t
44 softfloat_roundPackToF32( bool sign, int_fast16_t exp, uint_fast32_t sig )
45{
46 uint_fast8_t roundingMode;
47 bool roundNearEven;
48 uint_fast8_t roundIncrement, roundBits;
49 bool isTiny;
50 uint_fast32_t uiZ;
51 union ui32_f32 uZ;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 roundingMode = softfloat_roundingMode;
56 roundNearEven = (roundingMode == softfloat_round_near_even);
57 roundIncrement = 0x40;
58 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
59 roundIncrement =
60 (roundingMode
61 == (sign ? softfloat_round_min : softfloat_round_max))
62 ? 0x7F
63 : 0;
64 }
65 roundBits = sig & 0x7F;
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 if ( 0xFD <= (unsigned int) exp ) {
69 if ( exp < 0 ) {
70 /*----------------------------------------------------------------
71 *----------------------------------------------------------------*/
72 isTiny =
73 (softfloat_detectTininess == softfloat_tininess_beforeRounding)
74 || (exp < -1) || (sig + roundIncrement < 0x80000000);
75 sig = softfloat_shiftRightJam32( sig, -exp );
76 exp = 0;
77 roundBits = sig & 0x7F;
78 if ( isTiny && roundBits ) {
79 softfloat_raiseFlags( softfloat_flag_underflow );
80 }
81 } else if ( (0xFD < exp) || (0x80000000 <= sig + roundIncrement) ) {
82 /*----------------------------------------------------------------
83 *----------------------------------------------------------------*/
84 softfloat_raiseFlags(
85 softfloat_flag_overflow | softfloat_flag_inexact );
86 uiZ = packToF32UI( sign, 0xFF, 0 ) - ! roundIncrement;
87 goto uiZ;
88 }
89 }
90 /*------------------------------------------------------------------------
91 *------------------------------------------------------------------------*/
92 sig = (sig + roundIncrement)>>7;
93 if ( roundBits ) {
94 softfloat_exceptionFlags |= softfloat_flag_inexact;
95#ifdef SOFTFLOAT_ROUND_ODD
96 if ( roundingMode == softfloat_round_odd ) {
97 sig |= 1;
98 goto packReturn;
99 }
100#endif
101 }
102 sig &= ~(uint_fast32_t) (! (roundBits ^ 0x40) & roundNearEven);
103 if ( ! sig ) exp = 0;
104 /*------------------------------------------------------------------------
105 *------------------------------------------------------------------------*/
106 packReturn:
107 uiZ = packToF32UI( sign, exp, sig );
108 uiZ:
109 uZ.ui = uiZ;
110 return uZ.f;
111
112}
113
deps/SoftFloat-3d/source/s_roundPackToF64.c deleted-117
......@@ -1,117 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float64_t
44 softfloat_roundPackToF64( bool sign, int_fast16_t exp, uint_fast64_t sig )
45{
46 uint_fast8_t roundingMode;
47 bool roundNearEven;
48 uint_fast16_t roundIncrement, roundBits;
49 bool isTiny;
50 uint_fast64_t uiZ;
51 union ui64_f64 uZ;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 roundingMode = softfloat_roundingMode;
56 roundNearEven = (roundingMode == softfloat_round_near_even);
57 roundIncrement = 0x200;
58 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
59 roundIncrement =
60 (roundingMode
61 == (sign ? softfloat_round_min : softfloat_round_max))
62 ? 0x3FF
63 : 0;
64 }
65 roundBits = sig & 0x3FF;
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 if ( 0x7FD <= (uint16_t) exp ) {
69 if ( exp < 0 ) {
70 /*----------------------------------------------------------------
71 *----------------------------------------------------------------*/
72 isTiny =
73 (softfloat_detectTininess == softfloat_tininess_beforeRounding)
74 || (exp < -1)
75 || (sig + roundIncrement < UINT64_C( 0x8000000000000000 ));
76 sig = softfloat_shiftRightJam64( sig, -exp );
77 exp = 0;
78 roundBits = sig & 0x3FF;
79 if ( isTiny && roundBits ) {
80 softfloat_raiseFlags( softfloat_flag_underflow );
81 }
82 } else if (
83 (0x7FD < exp)
84 || (UINT64_C( 0x8000000000000000 ) <= sig + roundIncrement)
85 ) {
86 /*----------------------------------------------------------------
87 *----------------------------------------------------------------*/
88 softfloat_raiseFlags(
89 softfloat_flag_overflow | softfloat_flag_inexact );
90 uiZ = packToF64UI( sign, 0x7FF, 0 ) - ! roundIncrement;
91 goto uiZ;
92 }
93 }
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 sig = (sig + roundIncrement)>>10;
97 if ( roundBits ) {
98 softfloat_exceptionFlags |= softfloat_flag_inexact;
99#ifdef SOFTFLOAT_ROUND_ODD
100 if ( roundingMode == softfloat_round_odd ) {
101 sig |= 1;
102 goto packReturn;
103 }
104#endif
105 }
106 sig &= ~(uint_fast64_t) (! (roundBits ^ 0x200) & roundNearEven);
107 if ( ! sig ) exp = 0;
108 /*------------------------------------------------------------------------
109 *------------------------------------------------------------------------*/
110 packReturn:
111 uiZ = packToF64UI( sign, exp, sig );
112 uiZ:
113 uZ.ui = uiZ;
114 return uZ.f;
115
116}
117
deps/SoftFloat-3d/source/s_roundToI32.c deleted-84
......@@ -1,84 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t
45 softfloat_roundToI32(
46 bool sign, uint_fast64_t sig, uint_fast8_t roundingMode, bool exact )
47{
48 bool roundNearEven;
49 uint_fast16_t roundIncrement, roundBits;
50 uint_fast32_t sig32;
51 union { uint32_t ui; int32_t i; } uZ;
52 int_fast32_t z;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 roundNearEven = (roundingMode == softfloat_round_near_even);
57 roundIncrement = 0x800;
58 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
59 roundIncrement =
60 (roundingMode
61 == (sign ? softfloat_round_min : softfloat_round_max))
62 ? 0xFFF
63 : 0;
64 }
65 roundBits = sig & 0xFFF;
66 sig += roundIncrement;
67 if ( sig & UINT64_C( 0xFFFFF00000000000 ) ) goto invalid;
68 sig32 = sig>>12;
69 sig32 &= ~(uint_fast32_t) (! (roundBits ^ 0x800) & roundNearEven);
70 uZ.ui = sign ? -sig32 : sig32;
71 z = uZ.i;
72 if ( z && ((z < 0) ^ sign) ) goto invalid;
73 if ( exact && roundBits ) {
74 softfloat_exceptionFlags |= softfloat_flag_inexact;
75 }
76 return z;
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 invalid:
80 softfloat_raiseFlags( softfloat_flag_invalid );
81 return sign ? i32_fromNegOverflow : i32_fromPosOverflow;
82
83}
84
deps/SoftFloat-3d/source/s_roundToI64.c deleted-89
......@@ -1,89 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t
45 softfloat_roundToI64(
46 bool sign,
47 uint_fast64_t sig,
48 uint_fast64_t sigExtra,
49 uint_fast8_t roundingMode,
50 bool exact
51 )
52{
53 bool roundNearEven, doIncrement;
54 union { uint64_t ui; int64_t i; } uZ;
55 int_fast64_t z;
56
57 /*------------------------------------------------------------------------
58 *------------------------------------------------------------------------*/
59 roundNearEven = (roundingMode == softfloat_round_near_even);
60 doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
61 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
62 doIncrement =
63 (roundingMode
64 == (sign ? softfloat_round_min : softfloat_round_max))
65 && sigExtra;
66 }
67 if ( doIncrement ) {
68 ++sig;
69 if ( ! sig ) goto invalid;
70 sig &=
71 ~(uint_fast64_t)
72 (! (sigExtra & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
73 & roundNearEven);
74 }
75 uZ.ui = sign ? -sig : sig;
76 z = uZ.i;
77 if ( z && ((z < 0) ^ sign) ) goto invalid;
78 if ( exact && sigExtra ) {
79 softfloat_exceptionFlags |= softfloat_flag_inexact;
80 }
81 return z;
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 invalid:
85 softfloat_raiseFlags( softfloat_flag_invalid );
86 return sign ? i64_fromNegOverflow : i64_fromPosOverflow;
87
88}
89
deps/SoftFloat-3d/source/s_roundToUI32.c deleted-80
......@@ -1,80 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t
45 softfloat_roundToUI32(
46 bool sign, uint_fast64_t sig, uint_fast8_t roundingMode, bool exact )
47{
48 bool roundNearEven;
49 uint_fast16_t roundIncrement, roundBits;
50 uint_fast32_t z;
51
52 /*------------------------------------------------------------------------
53 *------------------------------------------------------------------------*/
54 roundNearEven = (roundingMode == softfloat_round_near_even);
55 roundIncrement = 0x800;
56 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
57 roundIncrement =
58 (roundingMode
59 == (sign ? softfloat_round_min : softfloat_round_max))
60 ? 0xFFF
61 : 0;
62 }
63 roundBits = sig & 0xFFF;
64 sig += roundIncrement;
65 if ( sig & UINT64_C( 0xFFFFF00000000000 ) ) goto invalid;
66 z = sig>>12;
67 z &= ~(uint_fast32_t) (! (roundBits ^ 0x800) & roundNearEven);
68 if ( sign && z ) goto invalid;
69 if ( exact && roundBits ) {
70 softfloat_exceptionFlags |= softfloat_flag_inexact;
71 }
72 return z;
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 invalid:
76 softfloat_raiseFlags( softfloat_flag_invalid );
77 return sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
78
79}
80
deps/SoftFloat-3d/source/s_roundToUI64.c deleted-85
......@@ -1,85 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t
45 softfloat_roundToUI64(
46 bool sign,
47 uint_fast64_t sig,
48 uint_fast64_t sigExtra,
49 uint_fast8_t roundingMode,
50 bool exact
51 )
52{
53 bool roundNearEven, doIncrement;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 roundNearEven = (roundingMode == softfloat_round_near_even);
58 doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
59 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
60 doIncrement =
61 (roundingMode
62 == (sign ? softfloat_round_min : softfloat_round_max))
63 && sigExtra;
64 }
65 if ( doIncrement ) {
66 ++sig;
67 if ( ! sig ) goto invalid;
68 sig &=
69 ~(uint_fast64_t)
70 (! (sigExtra & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
71 & roundNearEven);
72 }
73 if ( sign && sig ) goto invalid;
74 if ( exact && sigExtra ) {
75 softfloat_exceptionFlags |= softfloat_flag_inexact;
76 }
77 return sig;
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 invalid:
81 softfloat_raiseFlags( softfloat_flag_invalid );
82 return sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
83
84}
85
deps/SoftFloat-3d/source/s_shiftLeftM.c deleted-91
......@@ -1,91 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_shiftLeftM
41
42#define softfloat_shiftLeftM softfloat_shiftLeftM
43#include "primitives.h"
44
45void
46 softfloat_shiftLeftM(
47 uint_fast8_t size_words,
48 const uint32_t *aPtr,
49 uint32_t dist,
50 uint32_t *zPtr
51 )
52{
53 uint32_t wordDist;
54 uint_fast8_t innerDist;
55 uint32_t *destPtr;
56 uint_fast8_t i;
57
58 wordDist = dist>>5;
59 if ( wordDist < size_words ) {
60 aPtr += indexMultiwordLoBut( size_words, wordDist );
61 innerDist = dist & 31;
62 if ( innerDist ) {
63 softfloat_shortShiftLeftM(
64 size_words - wordDist,
65 aPtr,
66 innerDist,
67 zPtr + indexMultiwordHiBut( size_words, wordDist )
68 );
69 if ( ! wordDist ) return;
70 } else {
71 aPtr += indexWordHi( size_words - wordDist );
72 destPtr = zPtr + indexWordHi( size_words );
73 for ( i = size_words - wordDist; i; --i ) {
74 *destPtr = *aPtr;
75 aPtr -= wordIncr;
76 destPtr -= wordIncr;
77 }
78 }
79 zPtr += indexMultiwordLo( size_words, wordDist );
80 } else {
81 wordDist = size_words;
82 }
83 do {
84 *zPtr++ = 0;
85 --wordDist;
86 } while ( wordDist );
87
88}
89
90#endif
91
deps/SoftFloat-3d/source/s_shiftNormSigF128M.c deleted-78
......@@ -1,78 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40
41int
42 softfloat_shiftNormSigF128M(
43 const uint32_t *wPtr, uint_fast8_t shiftDist, uint32_t *sigPtr )
44{
45 uint32_t wordSig;
46 int32_t exp;
47 uint32_t leadingBit;
48
49 wordSig = wPtr[indexWordHi( 4 )];
50 exp = expF128UI96( wordSig );
51 if ( exp ) {
52 softfloat_shortShiftLeft128M( wPtr, shiftDist, sigPtr );
53 leadingBit = 0x00010000<<shiftDist;
54 sigPtr[indexWordHi( 4 )] =
55 (sigPtr[indexWordHi( 4 )] & (leadingBit - 1)) | leadingBit;
56 } else {
57 exp = 16;
58 wordSig &= 0x7FFFFFFF;
59 if ( ! wordSig ) {
60 exp = -16;
61 wordSig = wPtr[indexWord( 4, 2 )];
62 if ( ! wordSig ) {
63 exp = -48;
64 wordSig = wPtr[indexWord( 4, 1 )];
65 if ( ! wordSig ) {
66 wordSig = wPtr[indexWord( 4, 0 )];
67 if ( ! wordSig ) return -128;
68 exp = -80;
69 }
70 }
71 }
72 exp -= softfloat_countLeadingZeros32( wordSig );
73 softfloat_shiftLeft128M( wPtr, 1 - exp + shiftDist, sigPtr );
74 }
75 return exp;
76
77}
78
deps/SoftFloat-3d/source/s_shiftRightJam128.c deleted-69
......@@ -1,69 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shiftRightJam128
42
43struct uint128
44 softfloat_shiftRightJam128( uint64_t a64, uint64_t a0, uint_fast32_t dist )
45{
46 uint_fast8_t u8NegDist;
47 struct uint128 z;
48
49 if ( dist < 64 ) {
50 u8NegDist = -dist;
51 z.v64 = a64>>dist;
52 z.v0 =
53 a64<<(u8NegDist & 63) | a0>>dist
54 | ((uint64_t) (a0<<(u8NegDist & 63)) != 0);
55 } else {
56 z.v64 = 0;
57 z.v0 =
58 (dist < 127)
59 ? a64>>(dist & 63)
60 | (((a64 & (((uint_fast64_t) 1<<(dist & 63)) - 1)) | a0)
61 != 0)
62 : ((a64 | a0) != 0);
63 }
64 return z;
65
66}
67
68#endif
69
deps/SoftFloat-3d/source/s_shiftRightJam128Extra.c deleted-77
......@@ -1,77 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shiftRightJam128Extra
42
43struct uint128_extra
44 softfloat_shiftRightJam128Extra(
45 uint64_t a64, uint64_t a0, uint64_t extra, uint_fast32_t dist )
46{
47 uint_fast8_t u8NegDist;
48 struct uint128_extra z;
49
50 u8NegDist = -dist;
51 if ( dist < 64 ) {
52 z.v.v64 = a64>>dist;
53 z.v.v0 = a64<<(u8NegDist & 63) | a0>>dist;
54 z.extra = a0<<(u8NegDist & 63);
55 } else {
56 z.v.v64 = 0;
57 if ( dist == 64 ) {
58 z.v.v0 = a64;
59 z.extra = a0;
60 } else {
61 extra |= a0;
62 if ( dist < 128 ) {
63 z.v.v0 = a64>>(dist & 63);
64 z.extra = a64<<(u8NegDist & 63);
65 } else {
66 z.v.v0 = 0;
67 z.extra = (dist == 128) ? a64 : (a64 != 0);
68 }
69 }
70 }
71 z.extra |= (extra != 0);
72 return z;
73
74}
75
76#endif
77
deps/SoftFloat-3d/source/s_shiftRightJam256M.c deleted-126
......@@ -1,126 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shiftRightJam256M
42
43static
44 void
45 softfloat_shortShiftRightJamM(
46 uint_fast8_t size_words,
47 const uint64_t *aPtr,
48 uint_fast8_t dist,
49 uint64_t *zPtr
50 )
51{
52 uint_fast8_t uNegDist;
53 unsigned int index, lastIndex;
54 uint64_t partWordZ, wordA;
55
56 uNegDist = -dist;
57 index = indexWordLo( size_words );
58 lastIndex = indexWordHi( size_words );
59 wordA = aPtr[index];
60 partWordZ = wordA>>dist;
61 if ( partWordZ<<dist != wordA ) partWordZ |= 1;
62 while ( index != lastIndex ) {
63 wordA = aPtr[index + wordIncr];
64 zPtr[index] = wordA<<(uNegDist & 63) | partWordZ;
65 index += wordIncr;
66 partWordZ = wordA>>dist;
67 }
68 zPtr[index] = partWordZ;
69
70}
71
72void
73 softfloat_shiftRightJam256M(
74 const uint64_t *aPtr, uint_fast32_t dist, uint64_t *zPtr )
75{
76 uint64_t wordJam;
77 uint_fast32_t wordDist;
78 uint64_t *ptr;
79 uint_fast8_t i, innerDist;
80
81 wordJam = 0;
82 wordDist = dist>>6;
83 if ( wordDist ) {
84 if ( 4 < wordDist ) wordDist = 4;
85 ptr = (uint64_t *) (aPtr + indexMultiwordLo( 4, wordDist ));
86 i = wordDist;
87 do {
88 wordJam = *ptr++;
89 if ( wordJam ) break;
90 --i;
91 } while ( i );
92 ptr = zPtr;
93 }
94 if ( wordDist < 4 ) {
95 aPtr += indexMultiwordHiBut( 4, wordDist );
96 innerDist = dist & 63;
97 if ( innerDist ) {
98 softfloat_shortShiftRightJamM(
99 4 - wordDist,
100 aPtr,
101 innerDist,
102 zPtr + indexMultiwordLoBut( 4, wordDist )
103 );
104 if ( ! wordDist ) goto wordJam;
105 } else {
106 aPtr += indexWordLo( 4 - wordDist );
107 ptr = zPtr + indexWordLo( 4 );
108 for ( i = 4 - wordDist; i; --i ) {
109 *ptr = *aPtr;
110 aPtr += wordIncr;
111 ptr += wordIncr;
112 }
113 }
114 ptr = zPtr + indexMultiwordHi( 4, wordDist );
115 }
116 do {
117 *ptr++ = 0;
118 --wordDist;
119 } while ( wordDist );
120 wordJam:
121 if ( wordJam ) zPtr[indexWordLo( 4 )] |= 1;
122
123}
124
125#endif
126
deps/SoftFloat-3d/source/s_shiftRightJam32.c deleted-51
......@@ -1,51 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_shiftRightJam32
41
42uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist )
43{
44
45 return
46 (dist < 31) ? a>>dist | ((uint32_t) (a<<(-dist & 31)) != 0) : (a != 0);
47
48}
49
50#endif
51
deps/SoftFloat-3d/source/s_shiftRightJam64.c deleted-51
......@@ -1,51 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_shiftRightJam64
41
42uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist )
43{
44
45 return
46 (dist < 63) ? a>>dist | ((uint64_t) (a<<(-dist & 63)) != 0) : (a != 0);
47
48}
49
50#endif
51
deps/SoftFloat-3d/source/s_shiftRightJam64Extra.c deleted-62
......@@ -1,62 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shiftRightJam64Extra
42
43struct uint64_extra
44 softfloat_shiftRightJam64Extra(
45 uint64_t a, uint64_t extra, uint_fast32_t dist )
46{
47 struct uint64_extra z;
48
49 if ( dist < 64 ) {
50 z.v = a>>dist;
51 z.extra = a<<(-dist & 63);
52 } else {
53 z.v = 0;
54 z.extra = (dist == 64) ? a : (a != 0);
55 }
56 z.extra |= (extra != 0);
57 return z;
58
59}
60
61#endif
62
deps/SoftFloat-3d/source/s_shiftRightJamM.c deleted-101
......@@ -1,101 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_shiftRightJamM
41
42#define softfloat_shiftRightJamM softfloat_shiftRightJamM
43#include "primitives.h"
44
45void
46 softfloat_shiftRightJamM(
47 uint_fast8_t size_words,
48 const uint32_t *aPtr,
49 uint32_t dist,
50 uint32_t *zPtr
51 )
52{
53 uint32_t wordJam, wordDist, *ptr;
54 uint_fast8_t i, innerDist;
55
56 wordJam = 0;
57 wordDist = dist>>5;
58 if ( wordDist ) {
59 if ( size_words < wordDist ) wordDist = size_words;
60 ptr = (uint32_t *) (aPtr + indexMultiwordLo( size_words, wordDist ));
61 i = wordDist;
62 do {
63 wordJam = *ptr++;
64 if ( wordJam ) break;
65 --i;
66 } while ( i );
67 ptr = zPtr;
68 }
69 if ( wordDist < size_words ) {
70 aPtr += indexMultiwordHiBut( size_words, wordDist );
71 innerDist = dist & 31;
72 if ( innerDist ) {
73 softfloat_shortShiftRightJamM(
74 size_words - wordDist,
75 aPtr,
76 innerDist,
77 zPtr + indexMultiwordLoBut( size_words, wordDist )
78 );
79 if ( ! wordDist ) goto wordJam;
80 } else {
81 aPtr += indexWordLo( size_words - wordDist );
82 ptr = zPtr + indexWordLo( size_words );
83 for ( i = size_words - wordDist; i; --i ) {
84 *ptr = *aPtr;
85 aPtr += wordIncr;
86 ptr += wordIncr;
87 }
88 }
89 ptr = zPtr + indexMultiwordHi( size_words, wordDist );
90 }
91 do {
92 *ptr++ = 0;
93 --wordDist;
94 } while ( wordDist );
95 wordJam:
96 if ( wordJam ) zPtr[indexWordLo( size_words )] |= 1;
97
98}
99
100#endif
101
deps/SoftFloat-3d/source/s_shiftRightM.c deleted-91
......@@ -1,91 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_shiftRightM
41
42#define softfloat_shiftRightM softfloat_shiftRightM
43#include "primitives.h"
44
45void
46 softfloat_shiftRightM(
47 uint_fast8_t size_words,
48 const uint32_t *aPtr,
49 uint32_t dist,
50 uint32_t *zPtr
51 )
52{
53 uint32_t wordDist;
54 uint_fast8_t innerDist;
55 uint32_t *destPtr;
56 uint_fast8_t i;
57
58 wordDist = dist>>5;
59 if ( wordDist < size_words ) {
60 aPtr += indexMultiwordHiBut( size_words, wordDist );
61 innerDist = dist & 31;
62 if ( innerDist ) {
63 softfloat_shortShiftRightM(
64 size_words - wordDist,
65 aPtr,
66 innerDist,
67 zPtr + indexMultiwordLoBut( size_words, wordDist )
68 );
69 if ( ! wordDist ) return;
70 } else {
71 aPtr += indexWordLo( size_words - wordDist );
72 destPtr = zPtr + indexWordLo( size_words );
73 for ( i = size_words - wordDist; i; --i ) {
74 *destPtr = *aPtr;
75 aPtr += wordIncr;
76 destPtr += wordIncr;
77 }
78 }
79 zPtr += indexMultiwordHi( size_words, wordDist );
80 } else {
81 wordDist = size_words;
82 }
83 do {
84 *zPtr++ = 0;
85 --wordDist;
86 } while ( wordDist );
87
88}
89
90#endif
91
deps/SoftFloat-3d/source/s_shortShiftLeft128.c deleted-55
......@@ -1,55 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftLeft128
42
43struct uint128
44 softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
45{
46 struct uint128 z;
47
48 z.v64 = a64<<dist | a0>>(-dist & 63);
49 z.v0 = a0<<dist;
50 return z;
51
52}
53
54#endif
55
deps/SoftFloat-3d/source/s_shortShiftLeft64To96M.c deleted-56
......@@ -1,56 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftLeft64To96M
42
43void
44 softfloat_shortShiftLeft64To96M(
45 uint64_t a, uint_fast8_t dist, uint32_t *zPtr )
46{
47
48 zPtr[indexWord( 3, 0 )] = (uint32_t) a<<dist;
49 a >>= 32 - dist;
50 zPtr[indexWord( 3, 2 )] = a>>32;
51 zPtr[indexWord( 3, 1 )] = a;
52
53}
54
55#endif
56
deps/SoftFloat-3d/source/s_shortShiftLeftM.c deleted-70
......@@ -1,70 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftLeftM
42
43void
44 softfloat_shortShiftLeftM(
45 uint_fast8_t size_words,
46 const uint32_t *aPtr,
47 uint_fast8_t dist,
48 uint32_t *zPtr
49 )
50{
51 uint_fast8_t uNegDist;
52 unsigned int index, lastIndex;
53 uint32_t partWordZ, wordA;
54
55 uNegDist = -dist;
56 index = indexWordHi( size_words );
57 lastIndex = indexWordLo( size_words );
58 partWordZ = aPtr[index]<<dist;
59 while ( index != lastIndex ) {
60 wordA = aPtr[index - wordIncr];
61 zPtr[index] = partWordZ | wordA>>(uNegDist & 31);
62 index -= wordIncr;
63 partWordZ = wordA<<dist;
64 }
65 zPtr[index] = partWordZ;
66
67}
68
69#endif
70
deps/SoftFloat-3d/source/s_shortShiftRight128.c deleted-55
......@@ -1,55 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftRight128
42
43struct uint128
44 softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
45{
46 struct uint128 z;
47
48 z.v64 = a64>>dist;
49 z.v0 = a64<<(-dist & 63) | a0>>dist;
50 return z;
51
52}
53
54#endif
55
deps/SoftFloat-3d/source/s_shortShiftRightExtendM.c deleted-73
......@@ -1,73 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftRightExtendM
42
43void
44 softfloat_shortShiftRightExtendM(
45 uint_fast8_t size_words,
46 const uint32_t *aPtr,
47 uint_fast8_t dist,
48 uint32_t *zPtr
49 )
50{
51 uint_fast8_t uNegDist;
52 unsigned int indexA, lastIndexA;
53 uint32_t partWordZ, wordA;
54
55 uNegDist = -dist;
56 indexA = indexWordLo( size_words );
57 lastIndexA = indexWordHi( size_words );
58 zPtr += indexWordLo( size_words + 1 );
59 partWordZ = 0;
60 for (;;) {
61 wordA = aPtr[indexA];
62 *zPtr = wordA<<(uNegDist & 31) | partWordZ;
63 zPtr += wordIncr;
64 partWordZ = wordA>>dist;
65 if ( indexA == lastIndexA ) break;
66 indexA += wordIncr;
67 }
68 *zPtr = partWordZ;
69
70}
71
72#endif
73
deps/SoftFloat-3d/source/s_shortShiftRightJam128.c deleted-60
......@@ -1,60 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftRightJam128
42
43struct uint128
44 softfloat_shortShiftRightJam128(
45 uint64_t a64, uint64_t a0, uint_fast8_t dist )
46{
47 uint_fast8_t uNegDist;
48 struct uint128 z;
49
50 uNegDist = -dist;
51 z.v64 = a64>>dist;
52 z.v0 =
53 a64<<(uNegDist & 63) | a0>>dist
54 | ((uint64_t) (a0<<(uNegDist & 63)) != 0);
55 return z;
56
57}
58
59#endif
60
deps/SoftFloat-3d/source/s_shortShiftRightJam128Extra.c deleted-59
......@@ -1,59 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftRightJam128Extra
42
43struct uint128_extra
44 softfloat_shortShiftRightJam128Extra(
45 uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist )
46{
47 uint_fast8_t uNegDist;
48 struct uint128_extra z;
49
50 uNegDist = -dist;
51 z.v.v64 = a64>>dist;
52 z.v.v0 = a64<<(uNegDist & 63) | a0>>dist;
53 z.extra = a0<<(uNegDist & 63) | (extra != 0);
54 return z;
55
56}
57
58#endif
59
deps/SoftFloat-3d/source/s_shortShiftRightJam64.c deleted-50
......@@ -1,50 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_shortShiftRightJam64
41
42uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist )
43{
44
45 return a>>dist | ((a & (((uint_fast64_t) 1<<dist) - 1)) != 0);
46
47}
48
49#endif
50
deps/SoftFloat-3d/source/s_shortShiftRightJam64Extra.c deleted-56
......@@ -1,56 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftRightJam64Extra
42
43struct uint64_extra
44 softfloat_shortShiftRightJam64Extra(
45 uint64_t a, uint64_t extra, uint_fast8_t dist )
46{
47 struct uint64_extra z;
48
49 z.v = a>>dist;
50 z.extra = a<<(-dist & 63) | (extra != 0);
51 return z;
52
53}
54
55#endif
56
deps/SoftFloat-3d/source/s_shortShiftRightJamM.c deleted-72
......@@ -1,72 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftRightJamM
42
43void
44 softfloat_shortShiftRightJamM(
45 uint_fast8_t size_words,
46 const uint32_t *aPtr,
47 uint_fast8_t dist,
48 uint32_t *zPtr
49 )
50{
51 uint_fast8_t uNegDist;
52 unsigned int index, lastIndex;
53 uint32_t partWordZ, wordA;
54
55 uNegDist = -dist;
56 index = indexWordLo( size_words );
57 lastIndex = indexWordHi( size_words );
58 wordA = aPtr[index];
59 partWordZ = wordA>>dist;
60 if ( partWordZ<<dist != wordA ) partWordZ |= 1;
61 while ( index != lastIndex ) {
62 wordA = aPtr[index + wordIncr];
63 zPtr[index] = wordA<<(uNegDist & 31) | partWordZ;
64 index += wordIncr;
65 partWordZ = wordA>>dist;
66 }
67 zPtr[index] = partWordZ;
68
69}
70
71#endif
72
deps/SoftFloat-3d/source/s_shortShiftRightM.c deleted-70
......@@ -1,70 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftRightM
42
43void
44 softfloat_shortShiftRightM(
45 uint_fast8_t size_words,
46 const uint32_t *aPtr,
47 uint_fast8_t dist,
48 uint32_t *zPtr
49 )
50{
51 uint_fast8_t uNegDist;
52 unsigned int index, lastIndex;
53 uint32_t partWordZ, wordA;
54
55 uNegDist = -dist;
56 index = indexWordLo( size_words );
57 lastIndex = indexWordHi( size_words );
58 partWordZ = aPtr[index]>>dist;
59 while ( index != lastIndex ) {
60 wordA = aPtr[index + wordIncr];
61 zPtr[index] = wordA<<(uNegDist & 31) | partWordZ;
62 index += wordIncr;
63 partWordZ = wordA>>dist;
64 }
65 zPtr[index] = partWordZ;
66
67}
68
69#endif
70
deps/SoftFloat-3d/source/s_sub128.c deleted-55
......@@ -1,55 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_sub128
42
43struct uint128
44 softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
45{
46 struct uint128 z;
47
48 z.v0 = a0 - b0;
49 z.v64 = a64 - b64 - (a0 < b0);
50 return z;
51
52}
53
54#endif
55
deps/SoftFloat-3d/source/s_sub1XM.c deleted-60
......@@ -1,60 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_sub1XM
42
43void softfloat_sub1XM( uint_fast8_t size_words, uint32_t *zPtr )
44{
45 unsigned int index, lastIndex;
46 uint32_t wordA;
47
48 index = indexWordLo( size_words );
49 lastIndex = indexWordHi( size_words );
50 for (;;) {
51 wordA = zPtr[index];
52 zPtr[index] = wordA - 1;
53 if ( wordA || (index == lastIndex) ) break;
54 index += wordIncr;
55 }
56
57}
58
59#endif
60
deps/SoftFloat-3d/source/s_sub256M.c deleted-65
......@@ -1,65 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_sub256M
42
43void
44 softfloat_sub256M(
45 const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr )
46{
47 unsigned int index;
48 uint_fast8_t borrow;
49 uint64_t wordA, wordB;
50
51 index = indexWordLo( 4 );
52 borrow = 0;
53 for (;;) {
54 wordA = aPtr[index];
55 wordB = bPtr[index];
56 zPtr[index] = wordA - wordB - borrow;
57 if ( index == indexWordHi( 4 ) ) break;
58 borrow = borrow ? (wordA <= wordB) : (wordA < wordB);
59 index += wordIncr;
60 }
61
62}
63
64#endif
65
deps/SoftFloat-3d/source/s_subM.c deleted-70
......@@ -1,70 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_subM
42
43void
44 softfloat_subM(
45 uint_fast8_t size_words,
46 const uint32_t *aPtr,
47 const uint32_t *bPtr,
48 uint32_t *zPtr
49 )
50{
51 unsigned int index, lastIndex;
52 uint_fast8_t borrow;
53 uint32_t wordA, wordB;
54
55 index = indexWordLo( size_words );
56 lastIndex = indexWordHi( size_words );
57 borrow = 0;
58 for (;;) {
59 wordA = aPtr[index];
60 wordB = bPtr[index];
61 zPtr[index] = wordA - wordB - borrow;
62 if ( index == lastIndex ) break;
63 borrow = borrow ? (wordA <= wordB) : (wordA < wordB);
64 index += wordIncr;
65 }
66
67}
68
69#endif
70
deps/SoftFloat-3d/source/s_subMagsExtF80.c deleted-158
......@@ -1,158 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t
45 softfloat_subMagsExtF80(
46 uint_fast16_t uiA64,
47 uint_fast64_t uiA0,
48 uint_fast16_t uiB64,
49 uint_fast64_t uiB0,
50 bool signZ
51 )
52{
53 int_fast32_t expA;
54 uint_fast64_t sigA;
55 int_fast32_t expB;
56 uint_fast64_t sigB;
57 int_fast32_t expDiff;
58 uint_fast16_t uiZ64;
59 uint_fast64_t uiZ0;
60 int_fast32_t expZ;
61 uint_fast64_t sigExtra;
62 struct uint128 sig128, uiZ;
63 union { struct extFloat80M s; extFloat80_t f; } uZ;
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 expA = expExtF80UI64( uiA64 );
68 sigA = uiA0;
69 expB = expExtF80UI64( uiB64 );
70 sigB = uiB0;
71 /*------------------------------------------------------------------------
72 *------------------------------------------------------------------------*/
73 expDiff = expA - expB;
74 if ( 0 < expDiff ) goto expABigger;
75 if ( expDiff < 0 ) goto expBBigger;
76 if ( expA == 0x7FFF ) {
77 if ( (sigA | sigB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
78 goto propagateNaN;
79 }
80 softfloat_raiseFlags( softfloat_flag_invalid );
81 uiZ64 = defaultNaNExtF80UI64;
82 uiZ0 = defaultNaNExtF80UI0;
83 goto uiZ;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 expZ = expA;
88 if ( ! expZ ) expZ = 1;
89 sigExtra = 0;
90 if ( sigB < sigA ) goto aBigger;
91 if ( sigA < sigB ) goto bBigger;
92 uiZ64 =
93 packToExtF80UI64( (softfloat_roundingMode == softfloat_round_min), 0 );
94 uiZ0 = 0;
95 goto uiZ;
96 /*------------------------------------------------------------------------
97 *------------------------------------------------------------------------*/
98 expBBigger:
99 if ( expB == 0x7FFF ) {
100 if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
101 uiZ64 = packToExtF80UI64( signZ ^ 1, 0x7FFF );
102 uiZ0 = UINT64_C( 0x8000000000000000 );
103 goto uiZ;
104 }
105 if ( ! expA ) {
106 ++expDiff;
107 sigExtra = 0;
108 if ( ! expDiff ) goto newlyAlignedBBigger;
109 }
110 sig128 = softfloat_shiftRightJam128( sigA, 0, -expDiff );
111 sigA = sig128.v64;
112 sigExtra = sig128.v0;
113 newlyAlignedBBigger:
114 expZ = expB;
115 bBigger:
116 signZ = ! signZ;
117 sig128 = softfloat_sub128( sigB, 0, sigA, sigExtra );
118 goto normRoundPack;
119 /*------------------------------------------------------------------------
120 *------------------------------------------------------------------------*/
121 expABigger:
122 if ( expA == 0x7FFF ) {
123 if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
124 uiZ64 = uiA64;
125 uiZ0 = uiA0;
126 goto uiZ;
127 }
128 if ( ! expB ) {
129 --expDiff;
130 sigExtra = 0;
131 if ( ! expDiff ) goto newlyAlignedABigger;
132 }
133 sig128 = softfloat_shiftRightJam128( sigB, 0, expDiff );
134 sigB = sig128.v64;
135 sigExtra = sig128.v0;
136 newlyAlignedABigger:
137 expZ = expA;
138 aBigger:
139 sig128 = softfloat_sub128( sigA, 0, sigB, sigExtra );
140 /*------------------------------------------------------------------------
141 *------------------------------------------------------------------------*/
142 normRoundPack:
143 return
144 softfloat_normRoundPackToExtF80(
145 signZ, expZ, sig128.v64, sig128.v0, extF80_roundingPrecision );
146 /*------------------------------------------------------------------------
147 *------------------------------------------------------------------------*/
148 propagateNaN:
149 uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
150 uiZ64 = uiZ.v64;
151 uiZ0 = uiZ.v0;
152 uiZ:
153 uZ.s.signExp = uiZ64;
154 uZ.s.signif = uiZ0;
155 return uZ.f;
156
157}
158
deps/SoftFloat-3d/source/s_subMagsF128.c deleted-139
......@@ -1,139 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t
45 softfloat_subMagsF128(
46 uint_fast64_t uiA64,
47 uint_fast64_t uiA0,
48 uint_fast64_t uiB64,
49 uint_fast64_t uiB0,
50 bool signZ
51 )
52{
53 int_fast32_t expA;
54 struct uint128 sigA;
55 int_fast32_t expB;
56 struct uint128 sigB, sigZ;
57 int_fast32_t expDiff, expZ;
58 struct uint128 uiZ;
59 union ui128_f128 uZ;
60
61 expA = expF128UI64( uiA64 );
62 sigA.v64 = fracF128UI64( uiA64 );
63 sigA.v0 = uiA0;
64 expB = expF128UI64( uiB64 );
65 sigB.v64 = fracF128UI64( uiB64 );
66 sigB.v0 = uiB0;
67 sigA = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 4 );
68 sigB = softfloat_shortShiftLeft128( sigB.v64, sigB.v0, 4 );
69 expDiff = expA - expB;
70 if ( 0 < expDiff ) goto expABigger;
71 if ( expDiff < 0 ) goto expBBigger;
72 if ( expA == 0x7FFF ) {
73 if ( sigA.v64 | sigA.v0 | sigB.v64 | sigB.v0 ) goto propagateNaN;
74 softfloat_raiseFlags( softfloat_flag_invalid );
75 uiZ.v64 = defaultNaNF128UI64;
76 uiZ.v0 = defaultNaNF128UI0;
77 goto uiZ;
78 }
79 expZ = expA;
80 if ( ! expZ ) expZ = 1;
81 if ( sigB.v64 < sigA.v64 ) goto aBigger;
82 if ( sigA.v64 < sigB.v64 ) goto bBigger;
83 if ( sigB.v0 < sigA.v0 ) goto aBigger;
84 if ( sigA.v0 < sigB.v0 ) goto bBigger;
85 uiZ.v64 =
86 packToF128UI64(
87 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
88 uiZ.v0 = 0;
89 goto uiZ;
90 expBBigger:
91 if ( expB == 0x7FFF ) {
92 if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
93 uiZ.v64 = packToF128UI64( signZ ^ 1, 0x7FFF, 0 );
94 uiZ.v0 = 0;
95 goto uiZ;
96 }
97 if ( expA ) {
98 sigA.v64 |= UINT64_C( 0x0010000000000000 );
99 } else {
100 ++expDiff;
101 if ( ! expDiff ) goto newlyAlignedBBigger;
102 }
103 sigA = softfloat_shiftRightJam128( sigA.v64, sigA.v0, -expDiff );
104 newlyAlignedBBigger:
105 expZ = expB;
106 sigB.v64 |= UINT64_C( 0x0010000000000000 );
107 bBigger:
108 signZ = ! signZ;
109 sigZ = softfloat_sub128( sigB.v64, sigB.v0, sigA.v64, sigA.v0 );
110 goto normRoundPack;
111 expABigger:
112 if ( expA == 0x7FFF ) {
113 if ( sigA.v64 | sigA.v0 ) goto propagateNaN;
114 uiZ.v64 = uiA64;
115 uiZ.v0 = uiA0;
116 goto uiZ;
117 }
118 if ( expB ) {
119 sigB.v64 |= UINT64_C( 0x0010000000000000 );
120 } else {
121 --expDiff;
122 if ( ! expDiff ) goto newlyAlignedABigger;
123 }
124 sigB = softfloat_shiftRightJam128( sigB.v64, sigB.v0, expDiff );
125 newlyAlignedABigger:
126 expZ = expA;
127 sigA.v64 |= UINT64_C( 0x0010000000000000 );
128 aBigger:
129 sigZ = softfloat_sub128( sigA.v64, sigA.v0, sigB.v64, sigB.v0 );
130 normRoundPack:
131 return softfloat_normRoundPackToF128( signZ, expZ - 5, sigZ.v64, sigZ.v0 );
132 propagateNaN:
133 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
134 uiZ:
135 uZ.ui = uiZ;
136 return uZ.f;
137
138}
139
deps/SoftFloat-3d/source/s_subMagsF16.c deleted-187
......@@ -1,187 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t softfloat_subMagsF16( uint_fast16_t uiA, uint_fast16_t uiB )
45{
46 int_fast8_t expA;
47 uint_fast16_t sigA;
48 int_fast8_t expB;
49 uint_fast16_t sigB;
50 int_fast8_t expDiff;
51 uint_fast16_t uiZ;
52 int_fast16_t sigDiff;
53 bool signZ;
54 int_fast8_t shiftDist, expZ;
55 uint_fast16_t sigZ, sigX, sigY;
56 uint_fast32_t sig32Z;
57 int_fast8_t roundingMode;
58 union ui16_f16 uZ;
59
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 expA = expF16UI( uiA );
63 sigA = fracF16UI( uiA );
64 expB = expF16UI( uiB );
65 sigB = fracF16UI( uiB );
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 expDiff = expA - expB;
69 if ( ! expDiff ) {
70 /*--------------------------------------------------------------------
71 *--------------------------------------------------------------------*/
72 if ( expA == 0x1F ) {
73 if ( sigA | sigB ) goto propagateNaN;
74 softfloat_raiseFlags( softfloat_flag_invalid );
75 uiZ = defaultNaNF16UI;
76 goto uiZ;
77 }
78 sigDiff = sigA - sigB;
79 if ( ! sigDiff ) {
80 uiZ =
81 packToF16UI(
82 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
83 goto uiZ;
84 }
85 if ( expA ) --expA;
86 signZ = signF16UI( uiA );
87 if ( sigDiff < 0 ) {
88 signZ = ! signZ;
89 sigDiff = -sigDiff;
90 }
91 shiftDist = softfloat_countLeadingZeros16( sigDiff ) - 5;
92 expZ = expA - shiftDist;
93 if ( expZ < 0 ) {
94 shiftDist = expA;
95 expZ = 0;
96 }
97 sigZ = sigDiff<<shiftDist;
98 goto pack;
99 } else {
100 /*--------------------------------------------------------------------
101 *--------------------------------------------------------------------*/
102 signZ = signF16UI( uiA );
103 if ( expDiff < 0 ) {
104 /*----------------------------------------------------------------
105 *----------------------------------------------------------------*/
106 signZ = ! signZ;
107 if ( expB == 0x1F ) {
108 if ( sigB ) goto propagateNaN;
109 uiZ = packToF16UI( signZ, 0x1F, 0 );
110 goto uiZ;
111 }
112 if ( expDiff <= -13 ) {
113 uiZ = packToF16UI( signZ, expB, sigB );
114 if ( expA | sigA ) goto subEpsilon;
115 goto uiZ;
116 }
117 expZ = expA + 19;
118 sigX = sigB | 0x0400;
119 sigY = sigA + (expA ? 0x0400 : sigA);
120 expDiff = -expDiff;
121 } else {
122 /*----------------------------------------------------------------
123 *----------------------------------------------------------------*/
124 uiZ = uiA;
125 if ( expA == 0x1F ) {
126 if ( sigA ) goto propagateNaN;
127 goto uiZ;
128 }
129 if ( 13 <= expDiff ) {
130 if ( expB | sigB ) goto subEpsilon;
131 goto uiZ;
132 }
133 expZ = expB + 19;
134 sigX = sigA | 0x0400;
135 sigY = sigB + (expB ? 0x0400 : sigB);
136 }
137 sig32Z = ((uint_fast32_t) sigX<<expDiff) - sigY;
138 shiftDist = softfloat_countLeadingZeros32( sig32Z ) - 1;
139 sig32Z <<= shiftDist;
140 expZ -= shiftDist;
141 sigZ = sig32Z>>16;
142 if ( sig32Z & 0xFFFF ) {
143 sigZ |= 1;
144 } else {
145 if ( ! (sigZ & 0xF) && ((unsigned int) expZ < 0x1E) ) {
146 sigZ >>= 4;
147 goto pack;
148 }
149 }
150 return softfloat_roundPackToF16( signZ, expZ, sigZ );
151 }
152 /*------------------------------------------------------------------------
153 *------------------------------------------------------------------------*/
154 propagateNaN:
155 uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
156 goto uiZ;
157 /*------------------------------------------------------------------------
158 *------------------------------------------------------------------------*/
159 subEpsilon:
160 roundingMode = softfloat_roundingMode;
161 if ( roundingMode != softfloat_round_near_even ) {
162 if (
163 (roundingMode == softfloat_round_minMag)
164 || (roundingMode
165 == (signF16UI( uiZ ) ? softfloat_round_max
166 : softfloat_round_min))
167 ) {
168 --uiZ;
169 }
170#ifdef SOFTFLOAT_ROUND_ODD
171 else if ( roundingMode == softfloat_round_odd ) {
172 uiZ = (uiZ - 1) | 1;
173 }
174#endif
175 }
176 softfloat_exceptionFlags |= softfloat_flag_inexact;
177 goto uiZ;
178 /*------------------------------------------------------------------------
179 *------------------------------------------------------------------------*/
180 pack:
181 uiZ = packToF16UI( signZ, expZ, sigZ );
182 uiZ:
183 uZ.ui = uiZ;
184 return uZ.f;
185
186}
187
deps/SoftFloat-3d/source/s_subMagsF32.c deleted-143
......@@ -1,143 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t softfloat_subMagsF32( uint_fast32_t uiA, uint_fast32_t uiB )
45{
46 int_fast16_t expA;
47 uint_fast32_t sigA;
48 int_fast16_t expB;
49 uint_fast32_t sigB;
50 int_fast16_t expDiff;
51 uint_fast32_t uiZ;
52 int_fast32_t sigDiff;
53 bool signZ;
54 int_fast8_t shiftDist;
55 int_fast16_t expZ;
56 uint_fast32_t sigX, sigY;
57 union ui32_f32 uZ;
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 expA = expF32UI( uiA );
62 sigA = fracF32UI( uiA );
63 expB = expF32UI( uiB );
64 sigB = fracF32UI( uiB );
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 expDiff = expA - expB;
68 if ( ! expDiff ) {
69 /*--------------------------------------------------------------------
70 *--------------------------------------------------------------------*/
71 if ( expA == 0xFF ) {
72 if ( sigA | sigB ) goto propagateNaN;
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 uiZ = defaultNaNF32UI;
75 goto uiZ;
76 }
77 sigDiff = sigA - sigB;
78 if ( ! sigDiff ) {
79 uiZ =
80 packToF32UI(
81 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
82 goto uiZ;
83 }
84 if ( expA ) --expA;
85 signZ = signF32UI( uiA );
86 if ( sigDiff < 0 ) {
87 signZ = ! signZ;
88 sigDiff = -sigDiff;
89 }
90 shiftDist = softfloat_countLeadingZeros32( sigDiff ) - 8;
91 expZ = expA - shiftDist;
92 if ( expZ < 0 ) {
93 shiftDist = expA;
94 expZ = 0;
95 }
96 uiZ = packToF32UI( signZ, expZ, sigDiff<<shiftDist );
97 goto uiZ;
98 } else {
99 /*--------------------------------------------------------------------
100 *--------------------------------------------------------------------*/
101 signZ = signF32UI( uiA );
102 sigA <<= 7;
103 sigB <<= 7;
104 if ( expDiff < 0 ) {
105 /*----------------------------------------------------------------
106 *----------------------------------------------------------------*/
107 signZ = ! signZ;
108 if ( expB == 0xFF ) {
109 if ( sigB ) goto propagateNaN;
110 uiZ = packToF32UI( signZ, 0xFF, 0 );
111 goto uiZ;
112 }
113 expZ = expB - 1;
114 sigX = sigB | 0x40000000;
115 sigY = sigA + (expA ? 0x40000000 : sigA);
116 expDiff = -expDiff;
117 } else {
118 /*----------------------------------------------------------------
119 *----------------------------------------------------------------*/
120 if ( expA == 0xFF ) {
121 if ( sigA ) goto propagateNaN;
122 uiZ = uiA;
123 goto uiZ;
124 }
125 expZ = expA - 1;
126 sigX = sigA | 0x40000000;
127 sigY = sigB + (expB ? 0x40000000 : sigB);
128 }
129 return
130 softfloat_normRoundPackToF32(
131 signZ, expZ, sigX - softfloat_shiftRightJam32( sigY, expDiff )
132 );
133 }
134 /*------------------------------------------------------------------------
135 *------------------------------------------------------------------------*/
136 propagateNaN:
137 uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
138 uiZ:
139 uZ.ui = uiZ;
140 return uZ.f;
141
142}
143
deps/SoftFloat-3d/source/s_subMagsF64.c deleted-141
......@@ -1,141 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t
45 softfloat_subMagsF64( uint_fast64_t uiA, uint_fast64_t uiB, bool signZ )
46{
47 int_fast16_t expA;
48 uint_fast64_t sigA;
49 int_fast16_t expB;
50 uint_fast64_t sigB;
51 int_fast16_t expDiff;
52 uint_fast64_t uiZ;
53 int_fast64_t sigDiff;
54 int_fast8_t shiftDist;
55 int_fast16_t expZ;
56 uint_fast64_t sigZ;
57 union ui64_f64 uZ;
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 expA = expF64UI( uiA );
62 sigA = fracF64UI( uiA );
63 expB = expF64UI( uiB );
64 sigB = fracF64UI( uiB );
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 expDiff = expA - expB;
68 if ( ! expDiff ) {
69 /*--------------------------------------------------------------------
70 *--------------------------------------------------------------------*/
71 if ( expA == 0x7FF ) {
72 if ( sigA | sigB ) goto propagateNaN;
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 uiZ = defaultNaNF64UI;
75 goto uiZ;
76 }
77 sigDiff = sigA - sigB;
78 if ( ! sigDiff ) {
79 uiZ =
80 packToF64UI(
81 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
82 goto uiZ;
83 }
84 if ( expA ) --expA;
85 if ( sigDiff < 0 ) {
86 signZ = ! signZ;
87 sigDiff = -sigDiff;
88 }
89 shiftDist = softfloat_countLeadingZeros64( sigDiff ) - 11;
90 expZ = expA - shiftDist;
91 if ( expZ < 0 ) {
92 shiftDist = expA;
93 expZ = 0;
94 }
95 uiZ = packToF64UI( signZ, expZ, sigDiff<<shiftDist );
96 goto uiZ;
97 } else {
98 /*--------------------------------------------------------------------
99 *--------------------------------------------------------------------*/
100 sigA <<= 10;
101 sigB <<= 10;
102 if ( expDiff < 0 ) {
103 /*----------------------------------------------------------------
104 *----------------------------------------------------------------*/
105 signZ = ! signZ;
106 if ( expB == 0x7FF ) {
107 if ( sigB ) goto propagateNaN;
108 uiZ = packToF64UI( signZ, 0x7FF, 0 );
109 goto uiZ;
110 }
111 sigA += expA ? UINT64_C( 0x4000000000000000 ) : sigA;
112 sigA = softfloat_shiftRightJam64( sigA, -expDiff );
113 sigB |= UINT64_C( 0x4000000000000000 );
114 expZ = expB;
115 sigZ = sigB - sigA;
116 } else {
117 /*----------------------------------------------------------------
118 *----------------------------------------------------------------*/
119 if ( expA == 0x7FF ) {
120 if ( sigA ) goto propagateNaN;
121 uiZ = uiA;
122 goto uiZ;
123 }
124 sigB += expB ? UINT64_C( 0x4000000000000000 ) : sigB;
125 sigB = softfloat_shiftRightJam64( sigB, expDiff );
126 sigA |= UINT64_C( 0x4000000000000000 );
127 expZ = expA;
128 sigZ = sigA - sigB;
129 }
130 return softfloat_normRoundPackToF64( signZ, expZ - 1, sigZ );
131 }
132 /*------------------------------------------------------------------------
133 *------------------------------------------------------------------------*/
134 propagateNaN:
135 uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
136 uiZ:
137 uZ.ui = uiZ;
138 return uZ.f;
139
140}
141
deps/SoftFloat-3d/source/s_tryPropagateNaNExtF80M.c deleted-64
......@@ -1,64 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41
42bool
43 softfloat_tryPropagateNaNExtF80M(
44 const struct extFloat80M *aSPtr,
45 const struct extFloat80M *bSPtr,
46 struct extFloat80M *zSPtr
47 )
48{
49 uint_fast16_t ui64;
50 uint64_t ui0;
51
52 ui64 = aSPtr->signExp;
53 ui0 = aSPtr->signif;
54 if ( isNaNExtF80UI( ui64, ui0 ) ) goto propagateNaN;
55 ui64 = bSPtr->signExp;
56 ui0 = bSPtr->signif;
57 if ( isNaNExtF80UI( ui64, ui0 ) ) goto propagateNaN;
58 return false;
59 propagateNaN:
60 softfloat_propagateNaNExtF80M( aSPtr, bSPtr, zSPtr );
61 return true;
62
63}
64
deps/SoftFloat-3d/source/s_tryPropagateNaNF128M.c deleted-55
......@@ -1,55 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42
43bool
44 softfloat_tryPropagateNaNF128M(
45 const uint32_t *aWPtr, const uint32_t *bWPtr, uint32_t *zWPtr )
46{
47
48 if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
49 softfloat_propagateNaNF128M( aWPtr, bWPtr, zWPtr );
50 return true;
51 }
52 return false;
53
54}
55
deps/SoftFloat-3d/source/softfloat_state.c deleted-52
......@@ -1,52 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43#ifndef THREAD_LOCAL
44#define THREAD_LOCAL
45#endif
46
47THREAD_LOCAL uint_fast8_t softfloat_roundingMode = softfloat_round_near_even;
48THREAD_LOCAL uint_fast8_t softfloat_detectTininess = init_detectTininess;
49THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags = 0;
50
51THREAD_LOCAL uint_fast8_t extF80_roundingPrecision = 80;
52
deps/SoftFloat-3d/source/ui32_to_extF80.c deleted-59
......@@ -1,59 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42extFloat80_t ui32_to_extF80( uint32_t a )
43{
44 uint_fast16_t uiZ64;
45 int_fast8_t shiftDist;
46 union { struct extFloat80M s; extFloat80_t f; } uZ;
47
48 uiZ64 = 0;
49 if ( a ) {
50 shiftDist = softfloat_countLeadingZeros32( a );
51 uiZ64 = 0x401E - shiftDist;
52 a <<= shiftDist;
53 }
54 uZ.s.signExp = uiZ64;
55 uZ.s.signif = (uint_fast64_t) a<<32;
56 return uZ.f;
57
58}
59
deps/SoftFloat-3d/source/ui32_to_extF80M.c deleted-74
......@@ -1,74 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void ui32_to_extF80M( uint32_t a, extFloat80_t *zPtr )
45{
46
47 *zPtr = ui32_to_extF80( a );
48
49}
50
51#else
52
53void ui32_to_extF80M( uint32_t a, extFloat80_t *zPtr )
54{
55 struct extFloat80M *zSPtr;
56 uint_fast16_t uiZ64;
57 uint64_t sigZ;
58 int_fast8_t shiftDist;
59
60 zSPtr = (struct extFloat80M *) zPtr;
61 uiZ64 = 0;
62 sigZ = 0;
63 if ( a ) {
64 shiftDist = softfloat_countLeadingZeros32( a );
65 uiZ64 = packToExtF80UI64( 0, 0x401E - shiftDist );
66 sigZ = (uint64_t) (a<<shiftDist)<<32;
67 }
68 zSPtr->signExp = uiZ64;
69 zSPtr->signif = sigZ;
70
71}
72
73#endif
74
deps/SoftFloat-3d/source/ui32_to_f128.c deleted-60
......@@ -1,60 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float128_t ui32_to_f128( uint32_t a )
43{
44 uint_fast64_t uiZ64;
45 int_fast8_t shiftDist;
46 union ui128_f128 uZ;
47
48 uiZ64 = 0;
49 if ( a ) {
50 shiftDist = softfloat_countLeadingZeros32( a ) + 17;
51 uiZ64 =
52 packToF128UI64(
53 0, 0x402E - shiftDist, (uint_fast64_t) a<<shiftDist );
54 }
55 uZ.ui.v64 = uiZ64;
56 uZ.ui.v0 = 0;
57 return uZ.f;
58
59}
60
deps/SoftFloat-3d/source/ui32_to_f128M.c deleted-76
......@@ -1,76 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void ui32_to_f128M( uint32_t a, float128_t *zPtr )
45{
46
47 *zPtr = ui32_to_f128( a );
48
49}
50
51#else
52
53void ui32_to_f128M( uint32_t a, float128_t *zPtr )
54{
55 uint32_t *zWPtr, uiZ96, uiZ64;
56 int_fast8_t shiftDist;
57 uint64_t normA;
58
59 zWPtr = (uint32_t *) zPtr;
60 uiZ96 = 0;
61 uiZ64 = 0;
62 if ( a ) {
63 shiftDist = softfloat_countLeadingZeros32( a ) + 17;
64 normA = (uint64_t) a<<shiftDist;
65 uiZ96 = packToF128UI96( 0, 0x402E - shiftDist, normA>>32 );
66 uiZ64 = normA;
67 }
68 zWPtr[indexWord( 4, 3 )] = uiZ96;
69 zWPtr[indexWord( 4, 2 )] = uiZ64;
70 zWPtr[indexWord( 4, 1 )] = 0;
71 zWPtr[indexWord( 4, 0 )] = 0;
72
73}
74
75#endif
76
deps/SoftFloat-3d/source/ui32_to_f16.c deleted-65
......@@ -1,65 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float16_t ui32_to_f16( uint32_t a )
43{
44 int_fast8_t shiftDist;
45 union ui16_f16 u;
46 uint_fast16_t sig;
47
48 shiftDist = softfloat_countLeadingZeros32( a ) - 21;
49 if ( 0 <= shiftDist ) {
50 u.ui =
51 a ? packToF16UI(
52 0, 0x18 - shiftDist, (uint_fast16_t) a<<shiftDist )
53 : 0;
54 return u.f;
55 } else {
56 shiftDist += 4;
57 sig =
58 (shiftDist < 0)
59 ? a>>(-shiftDist) | ((uint32_t) (a<<(shiftDist & 31)) != 0)
60 : (uint_fast16_t) a<<shiftDist;
61 return softfloat_roundPackToF16( 0, 0x1C - shiftDist, sig );
62 }
63
64}
65
deps/SoftFloat-3d/source/ui32_to_f32.c deleted-57
......@@ -1,57 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float32_t ui32_to_f32( uint32_t a )
43{
44 union ui32_f32 uZ;
45
46 if ( ! a ) {
47 uZ.ui = 0;
48 return uZ.f;
49 }
50 if ( a & 0x80000000 ) {
51 return softfloat_roundPackToF32( 0, 0x9D, a>>1 | (a & 1) );
52 } else {
53 return softfloat_normRoundPackToF32( 0, 0x9C, a );
54 }
55
56}
57
deps/SoftFloat-3d/source/ui32_to_f64.c deleted-59
......@@ -1,59 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float64_t ui32_to_f64( uint32_t a )
43{
44 uint_fast64_t uiZ;
45 int_fast8_t shiftDist;
46 union ui64_f64 uZ;
47
48 if ( ! a ) {
49 uiZ = 0;
50 } else {
51 shiftDist = softfloat_countLeadingZeros32( a ) + 21;
52 uiZ =
53 packToF64UI( 0, 0x432 - shiftDist, (uint_fast64_t) a<<shiftDist );
54 }
55 uZ.ui = uiZ;
56 return uZ.f;
57
58}
59
deps/SoftFloat-3d/source/ui64_to_extF80.c deleted-59
......@@ -1,59 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42extFloat80_t ui64_to_extF80( uint64_t a )
43{
44 uint_fast16_t uiZ64;
45 int_fast8_t shiftDist;
46 union { struct extFloat80M s; extFloat80_t f; } uZ;
47
48 uiZ64 = 0;
49 if ( a ) {
50 shiftDist = softfloat_countLeadingZeros64( a );
51 uiZ64 = 0x403E - shiftDist;
52 a <<= shiftDist;
53 }
54 uZ.s.signExp = uiZ64;
55 uZ.s.signif = a;
56 return uZ.f;
57
58}
59
deps/SoftFloat-3d/source/ui64_to_extF80M.c deleted-74
......@@ -1,74 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void ui64_to_extF80M( uint64_t a, extFloat80_t *zPtr )
45{
46
47 *zPtr = ui64_to_extF80( a );
48
49}
50
51#else
52
53void ui64_to_extF80M( uint64_t a, extFloat80_t *zPtr )
54{
55 struct extFloat80M *zSPtr;
56 uint_fast16_t uiZ64;
57 uint64_t sigZ;
58 int_fast8_t shiftDist;
59
60 zSPtr = (struct extFloat80M *) zPtr;
61 uiZ64 = 0;
62 sigZ = 0;
63 if ( a ) {
64 shiftDist = softfloat_countLeadingZeros64( a );
65 uiZ64 = packToExtF80UI64( 0, 0x403E - shiftDist );
66 sigZ = a<<shiftDist;
67 }
68 zSPtr->signExp = uiZ64;
69 zSPtr->signif = sigZ;
70
71}
72
73#endif
74
deps/SoftFloat-3d/source/ui64_to_f128.c deleted-68
......@@ -1,68 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float128_t ui64_to_f128( uint64_t a )
43{
44 uint_fast64_t uiZ64, uiZ0;
45 int_fast8_t shiftDist;
46 struct uint128 zSig;
47 union ui128_f128 uZ;
48
49 if ( ! a ) {
50 uiZ64 = 0;
51 uiZ0 = 0;
52 } else {
53 shiftDist = softfloat_countLeadingZeros64( a ) + 49;
54 if ( 64 <= shiftDist ) {
55 zSig.v64 = a<<(shiftDist - 64);
56 zSig.v0 = 0;
57 } else {
58 zSig = softfloat_shortShiftLeft128( 0, a, shiftDist );
59 }
60 uiZ64 = packToF128UI64( 0, 0x406E - shiftDist, zSig.v64 );
61 uiZ0 = zSig.v0;
62 }
63 uZ.ui.v64 = uiZ64;
64 uZ.ui.v0 = uiZ0;
65 return uZ.f;
66
67}
68
deps/SoftFloat-3d/source/ui64_to_f128M.c deleted-86
......@@ -1,86 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void ui64_to_f128M( uint64_t a, float128_t *zPtr )
45{
46
47 *zPtr = ui64_to_f128( a );
48
49}
50
51#else
52
53void ui64_to_f128M( uint64_t a, float128_t *zPtr )
54{
55 uint32_t *zWPtr, uiZ96, uiZ64;
56 uint_fast8_t shiftDist;
57 uint32_t *ptr;
58
59 zWPtr = (uint32_t *) zPtr;
60 uiZ96 = 0;
61 uiZ64 = 0;
62 zWPtr[indexWord( 4, 1 )] = 0;
63 zWPtr[indexWord( 4, 0 )] = 0;
64 if ( a ) {
65 shiftDist = softfloat_countLeadingZeros64( a ) + 17;
66 if ( shiftDist < 32 ) {
67 ptr = zWPtr + indexMultiwordHi( 4, 3 );
68 ptr[indexWord( 3, 2 )] = 0;
69 ptr[indexWord( 3, 1 )] = a>>32;
70 ptr[indexWord( 3, 0 )] = a;
71 softfloat_shortShiftLeft96M( ptr, shiftDist, ptr );
72 ptr[indexWordHi( 3 )] =
73 packToF128UI96( 0, 0x404E - shiftDist, ptr[indexWordHi( 3 )] );
74 return;
75 }
76 a <<= shiftDist - 32;
77 uiZ96 = packToF128UI96( 0, 0x404E - shiftDist, a>>32 );
78 uiZ64 = a;
79 }
80 zWPtr[indexWord( 4, 3 )] = uiZ96;
81 zWPtr[indexWord( 4, 2 )] = uiZ64;
82
83}
84
85#endif
86
deps/SoftFloat-3d/source/ui64_to_f16.c deleted-64
......@@ -1,64 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float16_t ui64_to_f16( uint64_t a )
43{
44 int_fast8_t shiftDist;
45 union ui16_f16 u;
46 uint_fast16_t sig;
47
48 shiftDist = softfloat_countLeadingZeros64( a ) - 53;
49 if ( 0 <= shiftDist ) {
50 u.ui =
51 a ? packToF16UI(
52 0, 0x18 - shiftDist, (uint_fast16_t) a<<shiftDist )
53 : 0;
54 return u.f;
55 } else {
56 shiftDist += 4;
57 sig =
58 (shiftDist < 0) ? softfloat_shortShiftRightJam64( a, -shiftDist )
59 : (uint_fast16_t) a<<shiftDist;
60 return softfloat_roundPackToF16( 0, 0x1C - shiftDist, sig );
61 }
62
63}
64
deps/SoftFloat-3d/source/ui64_to_f32.c deleted-64
......@@ -1,64 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float32_t ui64_to_f32( uint64_t a )
43{
44 int_fast8_t shiftDist;
45 union ui32_f32 u;
46 uint_fast32_t sig;
47
48 shiftDist = softfloat_countLeadingZeros64( a ) - 40;
49 if ( 0 <= shiftDist ) {
50 u.ui =
51 a ? packToF32UI(
52 0, 0x95 - shiftDist, (uint_fast32_t) a<<shiftDist )
53 : 0;
54 return u.f;
55 } else {
56 shiftDist += 7;
57 sig =
58 (shiftDist < 0) ? softfloat_shortShiftRightJam64( a, -shiftDist )
59 : (uint_fast32_t) a<<shiftDist;
60 return softfloat_roundPackToF32( 0, 0x9C - shiftDist, sig );
61 }
62
63}
64
deps/SoftFloat-3d/source/ui64_to_f64.c deleted-59
......@@ -1,59 +0,0 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3d, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float64_t ui64_to_f64( uint64_t a )
43{
44 union ui64_f64 uZ;
45
46 if ( ! a ) {
47 uZ.ui = 0;
48 return uZ.f;
49 }
50 if ( a & UINT64_C( 0x8000000000000000 ) ) {
51 return
52 softfloat_roundPackToF64(
53 0, 0x43D, softfloat_shortShiftRightJam64( a, 1 ) );
54 } else {
55 return softfloat_normRoundPackToF64( 0, 0x43C, a );
56 }
57
58}
59
deps/SoftFloat-3e-prebuilt/platform.h created+97
......@@ -0,0 +1,97 @@
1#ifndef ZIG_DEP_SOFTFLOAT_PLATFORM_H
2#define ZIG_DEP_SOFTFLOAT_PLATFORM_H
3
4#if defined(__BIG_ENDIAN__)
5#define BIGENDIAN 1
6#elif defined(__ARMEB__)
7#define BIGENDIAN 1
8#elif defined(__THUMBEB__)
9#define BIGENDIAN 1
10#elif defined(__AARCH64EB__)
11#define BIGENDIAN 1
12#elif defined(_MIPSEB)
13#define BIGENDIAN 1
14#elif defined(__MIPSEB)
15#define BIGENDIAN 1
16#elif defined(__MIPSEB__)
17#define BIGENDIAN 1
18#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
19#define BIGENDIAN 1
20#elif defined(_BIG_ENDIAN)
21#define BIGENDIAN 1
22#elif defined(__sparc)
23#define BIGENDIAN 1
24#elif defined(__sparc__)
25#define BIGENDIAN 1
26#elif defined(_POWER)
27#define BIGENDIAN 1
28#elif defined(__powerpc__)
29#define BIGENDIAN 1
30#elif defined(__ppc__)
31#define BIGENDIAN 1
32#elif defined(__hpux)
33#define BIGENDIAN 1
34#elif defined(__hppa)
35#define BIGENDIAN 1
36#elif defined(_POWER)
37#define BIGENDIAN 1
38#elif defined(__s390__)
39#define BIGENDIAN 1
40#elif defined(__LITTLE_ENDIAN__)
41#define LITTLEENDIAN 1
42#elif defined(__ARMEL__)
43#define LITTLEENDIAN 1
44#elif defined(__THUMBEL__)
45#define LITTLEENDIAN 1
46#elif defined(__AARCH64EL__)
47#define LITTLEENDIAN 1
48#elif defined(_MIPSEL)
49#define LITTLEENDIAN 1
50#elif defined(__MIPSEL)
51#define LITTLEENDIAN 1
52#elif defined(__MIPSEL__)
53#define LITTLEENDIAN 1
54#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
55#define LITTLEENDIAN 1
56#elif defined(_LITTLE_ENDIAN)
57#define LITTLEENDIAN 1
58#elif defined(__i386__)
59#define LITTLEENDIAN 1
60#elif defined(__alpha__)
61#define LITTLEENDIAN 1
62#elif defined(__ia64)
63#define LITTLEENDIAN 1
64#elif defined(__ia64__)
65#define LITTLEENDIAN 1
66#elif defined(_M_IX86)
67#define LITTLEENDIAN 1
68#elif defined(_M_IA64)
69#define LITTLEENDIAN 1
70#elif defined(_M_ALPHA)
71#define LITTLEENDIAN 1
72#elif defined(__amd64)
73#define LITTLEENDIAN 1
74#elif defined(__amd64__)
75#define LITTLEENDIAN 1
76#elif defined(_M_AMD64)
77#define LITTLEENDIAN 1
78#elif defined(__x86_64)
79#define LITTLEENDIAN 1
80#elif defined(__x86_64__)
81#define LITTLEENDIAN 1
82#elif defined(_M_X64)
83#define LITTLEENDIAN 1
84#elif defined(__bfin__)
85#define LITTLEENDIAN 1
86#else
87#error unable to detect endianness
88#endif
89
90#define INLINE inline
91#if _MSC_VER
92#define THREAD_LOCAL __declspec(thread)
93#else
94#define THREAD_LOCAL __thread
95#endif
96
97#endif
deps/SoftFloat-3e/COPYING.txt created+37
......@@ -0,0 +1,37 @@
1
2License for Berkeley SoftFloat Release 3e
3
4John R. Hauser
52018 January 20
6
7The following applies to the whole of SoftFloat Release 3e as well as to
8each source file individually.
9
10Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The Regents of the
11University of California. All rights reserved.
12
13Redistribution and use in source and binary forms, with or without
14modification, are permitted provided that the following conditions are met:
15
16 1. Redistributions of source code must retain the above copyright notice,
17 this list of conditions, and the following disclaimer.
18
19 2. Redistributions in binary form must reproduce the above copyright
20 notice, this list of conditions, and the following disclaimer in the
21 documentation and/or other materials provided with the distribution.
22
23 3. Neither the name of the University nor the names of its contributors
24 may be used to endorse or promote products derived from this software
25 without specific prior written permission.
26
27THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
28EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
29WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
30DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
31DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
32(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
34ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
36THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
deps/SoftFloat-3e/README.html created+49
......@@ -0,0 +1,49 @@
1
2<HTML>
3
4<HEAD>
5<TITLE>Berkeley SoftFloat Package Overview</TITLE>
6</HEAD>
7
8<BODY>
9
10<H1>Package Overview for Berkeley SoftFloat Release 3e</H1>
11
12<P>
13John R. Hauser<BR>
142018 January 20<BR>
15</P>
16
17<P>
18Berkeley SoftFloat is a software implementation of binary floating-point that
19conforms to the IEEE Standard for Floating-Point Arithmetic.
20SoftFloat is distributed in the form of C source code.
21Building the SoftFloat sources generates a library file (typically
22<CODE>softfloat.a</CODE> or <CODE>libsoftfloat.a</CODE>) containing the
23floating-point subroutines.
24</P>
25
26<P>
27The SoftFloat package is documented in the following files in the
28<CODE>doc</CODE> subdirectory:
29<BLOCKQUOTE>
30<TABLE>
31<TR>
32<TD><A HREF="doc/SoftFloat.html"><NOBR><CODE>SoftFloat.html</CODE></NOBR></A></TD>
33<TD>Documentation for using the SoftFloat functions.</TD>
34</TR>
35<TR>
36<TD><A HREF="doc/SoftFloat-source.html"><NOBR><CODE>SoftFloat-source.html</CODE></NOBR></A></TD>
37<TD>Documentation for building SoftFloat.</TD>
38</TR>
39<TR>
40<TD><A HREF="doc/SoftFloat-history.html"><NOBR><CODE>SoftFloat-history.html</CODE></A><CODE>&nbsp;&nbsp;&nbsp;</CODE></NOBR></TD>
41<TD>History of the major changes to SoftFloat.</TD>
42</TR>
43</TABLE>
44</BLOCKQUOTE>
45Other files in the package comprise the source code for SoftFloat.
46</P>
47
48</BODY>
49
deps/SoftFloat-3e/README.txt created+21
......@@ -0,0 +1,21 @@
1
2Package Overview for Berkeley SoftFloat Release 3e
3
4John R. Hauser
52018 January 20
6
7Berkeley SoftFloat is a software implementation of binary floating-point
8that conforms to the IEEE Standard for Floating-Point Arithmetic. SoftFloat
9is distributed in the form of C source code. Building the SoftFloat sources
10generates a library file (typically "softfloat.a" or "libsoftfloat.a")
11containing the floating-point subroutines.
12
13The SoftFloat package is documented in the following files in the "doc"
14subdirectory:
15
16 SoftFloat.html Documentation for using the SoftFloat functions.
17 SoftFloat-source.html Documentation for building SoftFloat.
18 SoftFloat-history.html History of the major changes to SoftFloat.
19
20Other files in the package comprise the source code for SoftFloat.
21
deps/SoftFloat-3e/doc/SoftFloat-history.html created+258
......@@ -0,0 +1,258 @@
1
2<HTML>
3
4<HEAD>
5<TITLE>Berkeley SoftFloat History</TITLE>
6</HEAD>
7
8<BODY>
9
10<H1>History of Berkeley SoftFloat, to Release 3e</H1>
11
12<P>
13John R. Hauser<BR>
142018 January 20<BR>
15</P>
16
17
18<H3>Release 3e (2018 January)</H3>
19
20<UL>
21
22<LI>
23Changed the default numeric code for optional rounding mode <CODE>odd</CODE>
24(round to odd, also known as <EM>jamming</EM>) from 5 to 6.
25
26<LI>
27Modified the behavior of rounding mode <CODE>odd</CODE> when rounding to an
28integer value (either conversion to an integer format or a
29&lsquo;<CODE>roundToInt</CODE>&rsquo; function).
30Previously, for those cases only, rounding mode <CODE>odd</CODE> acted the same
31as rounding to minimum magnitude.
32Now all operations are rounded consistently.
33
34<LI>
35Fixed some errors in the specialization code modeling Intel x86 floating-point,
36specifically the integers returned on invalid operations and the propagation of
37NaN payloads in a few rare cases.
38
39<LI>
40Added specialization code modeling ARM floating-point, conforming to VFPv2 or
41later.
42
43<LI>
44Added an example target for ARM processors.
45
46<LI>
47Fixed a minor bug whereby function <CODE>f16_to_ui64</CODE> might return a
48different integer than expected in the case that the floating-point operand is
49negative.
50
51<LI>
52Added example target-specific optimization for GCC, employing GCC instrinsics
53and support for <NOBR>128-bit</NOBR> integer arithmetic.
54
55<LI>
56Made other minor improvements.
57
58</UL>
59
60
61<H3>Release 3d (2017 August)</H3>
62
63<UL>
64
65<LI>
66Fixed bugs in the square root functions for <NOBR>64-bit</NOBR>
67double-precision, <NOBR>80-bit</NOBR> double-extended-precision, and
68<NOBR>128-bit</NOBR> quadruple-precision.
69For <NOBR>64-bit</NOBR> double-precision (<CODE>f64_sqrt</CODE>), the result
70could sometimes be off by <NOBR>1 unit</NOBR> in the last place
71(<NOBR>1 ulp</NOBR>) from what it should be.
72For the larger formats, the square root could be wrong in a large portion of
73the less-significant bits.
74(A bug in <CODE>f128_sqrt</CODE> was first reported by Alexei Sibidanov.)
75
76</UL>
77
78
79<H3>Release 3c (2017 February)</H3>
80
81<UL>
82
83<LI>
84Added optional rounding mode <CODE>odd</CODE> (round to odd, also known as
85<EM>jamming</EM>).
86
87<LI>
88Corrected the documentation concerning non-canonical representations in
89<NOBR>80-bit</NOBR> double-extended-precision.
90
91</UL>
92
93
94<H3>Release 3b (2016 July)</H3>
95
96<UL>
97
98<LI>
99Implemented the common <NOBR>16-bit</NOBR> &ldquo;half-precision&rdquo;
100floating-point format (<CODE>float16_t</CODE>).
101
102<LI>
103Made the integer values returned on invalid conversions to integer formats
104be determined by the port-specific specialization instead of being the same for
105all ports.
106
107<LI>
108Added preprocessor macro <CODE>THREAD_LOCAL</CODE> to allow the floating-point
109state (modes and exception flags) to be made per-thread.
110
111<LI>
112Modified the provided Makefiles to allow some options to be overridden from the
113<CODE>make</CODE> command.
114
115<LI>
116Made other minor improvements.
117
118</UL>
119
120
121<H3>Release 3a (2015 October)</H3>
122
123<UL>
124
125<LI>
126Replaced the license text supplied by the University of California, Berkeley.
127
128</UL>
129
130
131<H3>Release 3 (2015 February)</H3>
132
133<UL>
134
135<LI>
136Complete rewrite, funded by the University of California, Berkeley, and
137consequently having a different use license than earlier releases.
138Major changes included renaming most types and functions, upgrading some
139algorithms, restructuring the source files, and making SoftFloat into a true
140library.
141
142<LI>
143Added functions to convert between floating-point and unsigned integers, both
144<NOBR>32-bit</NOBR> and <NOBR>64-bit</NOBR> (<CODE>uint32_t</CODE> and
145<CODE>uint64_t</CODE>).
146
147<LI>
148Added functions for fused multiply-add, for all supported floating-point
149formats except <NOBR>80-bit</NOBR> double-extended-precision.
150
151<LI>
152Added support for a fifth rounding mode, <CODE>near_maxMag</CODE> (round to
153nearest, with ties to maximum magnitude, away from zero).
154
155<LI>
156Dropped the <CODE>timesoftfloat</CODE> program (now part of the Berkeley
157TestFloat package).
158
159</UL>
160
161
162<H3>Release 2c (2015 January)</H3>
163
164<UL>
165
166<LI>
167Fixed mistakes affecting some <NOBR>64-bit</NOBR> processors.
168
169<LI>
170Further improved the documentation and the wording for the legal restrictions
171on using SoftFloat releases <NOBR>through 2c</NOBR> (not applicable to
172<NOBR>Release 3</NOBR> or later).
173
174</UL>
175
176
177<H3>Release 2b (2002 May)</H3>
178
179<UL>
180
181<LI>
182Made minor updates to the documentation, including improved wording for the
183legal restrictions on using SoftFloat.
184
185</UL>
186
187
188<H3>Release 2a (1998 December)</H3>
189
190<UL>
191
192<LI>
193Added functions to convert between <NOBR>64-bit</NOBR> integers
194(<CODE>int64</CODE>) and all supported floating-point formats.
195
196<LI>
197Fixed a bug in all <NOBR>64-bit</NOBR>-version square root functions except
198<CODE>float32_sqrt</CODE> that caused the result sometimes to be off by
199<NOBR>1 unit</NOBR> in the last place (<NOBR>1 ulp</NOBR>) from what it should
200be.
201(Bug discovered by Paul Donahue.)
202
203<LI>
204Improved the Makefiles.
205</UL>
206
207
208<H3>Release 2 (1997 June)</H3>
209
210<UL>
211
212<LI>
213Created the <NOBR>64-bit</NOBR> (<CODE>bits64</CODE>) version, adding the
214<CODE>floatx80</CODE> and <CODE>float128</CODE> formats.
215
216<LI>
217Changed the source directory structure, splitting the sources into a
218<CODE>bits32</CODE> and a <CODE>bits64</CODE> version.
219Renamed <CODE>environment.h</CODE> to <CODE>milieu.h</CODE> to avoid confusion
220with environment variables.
221
222<LI>
223Fixed a small error that caused <CODE>float64_round_to_int</CODE> often to
224round the wrong way in nearest/even mode when the operand was between
2252<SUP>20</SUP> and 2<SUP>21</SUP> and halfway between two integers.
226
227</UL>
228
229
230<H3>Release 1a (1996 July)</H3>
231
232<UL>
233
234<LI>
235Corrected a mistake that caused borderline underflow cases not to raise the
236underflow flag when they should have.
237(Problem reported by Doug Priest.)
238
239<LI>
240Added the <CODE>float_detect_tininess</CODE> variable to control whether
241tininess is detected before or after rounding.
242
243</UL>
244
245
246<H3>Release 1 (1996 July)</H3>
247
248<UL>
249
250<LI>
251Original release, based on work done for the International Computer Science
252Institute (ICSI) in Berkeley, California.
253
254</UL>
255
256
257</BODY>
258
deps/SoftFloat-3e/doc/SoftFloat-source.html created+686
......@@ -0,0 +1,686 @@
1
2<HTML>
3
4<HEAD>
5<TITLE>Berkeley SoftFloat Source Documentation</TITLE>
6</HEAD>
7
8<BODY>
9
10<H1>Berkeley SoftFloat Release 3e: Source Documentation</H1>
11
12<P>
13John R. Hauser<BR>
142018 January 20<BR>
15</P>
16
17
18<H2>Contents</H2>
19
20<BLOCKQUOTE>
21<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>
22<COL WIDTH=25>
23<COL WIDTH=*>
24<TR><TD COLSPAN=2>1. Introduction</TD></TR>
25<TR><TD COLSPAN=2>2. Limitations</TD></TR>
26<TR><TD COLSPAN=2>3. Acknowledgments and License</TD></TR>
27<TR><TD COLSPAN=2>4. SoftFloat Package Directory Structure</TD></TR>
28<TR><TD COLSPAN=2>5. Issues for Porting SoftFloat to a New Target</TD></TR>
29<TR>
30 <TD></TD>
31 <TD>5.1. Standard Headers <CODE>&lt;stdbool.h&gt;</CODE> and
32 <CODE>&lt;stdint.h&gt;</CODE></TD>
33</TR>
34<TR><TD></TD><TD>5.2. Specializing Floating-Point Behavior</TD></TR>
35<TR><TD></TD><TD>5.3. Macros for Build Options</TD></TR>
36<TR><TD></TD><TD>5.4. Adapting a Template Target Directory</TD></TR>
37<TR>
38 <TD></TD><TD>5.5. Target-Specific Optimization of Primitive Functions</TD>
39</TR>
40<TR><TD COLSPAN=2>6. Testing SoftFloat</TD></TR>
41<TR>
42 <TD COLSPAN=2>7. Providing SoftFloat as a Common Library for Applications</TD>
43</TR>
44<TR><TD COLSPAN=2>8. Contact Information</TD></TR>
45</TABLE>
46</BLOCKQUOTE>
47
48
49<H2>1. Introduction</H2>
50
51<P>
52This document gives information needed for compiling and/or porting Berkeley
53SoftFloat, a library of C functions implementing binary floating-point
54conforming to the IEEE Standard for Floating-Point Arithmetic.
55For basic documentation about SoftFloat refer to
56<A HREF="SoftFloat.html"><NOBR><CODE>SoftFloat.html</CODE></NOBR></A>.
57</P>
58
59<P>
60The source code for SoftFloat is intended to be relatively machine-independent
61and should be compilable with any ISO-Standard C compiler that also supports
62<NOBR>64-bit</NOBR> integers.
63SoftFloat has been successfully compiled with the GNU C Compiler
64(<CODE>gcc</CODE>) for several platforms.
65</P>
66
67<P>
68<NOBR>Release 3</NOBR> of SoftFloat was a complete rewrite relative to
69<NOBR>Release 2</NOBR> or earlier.
70Changes to the interface of SoftFloat functions are documented in
71<A HREF="SoftFloat.html"><NOBR><CODE>SoftFloat.html</CODE></NOBR></A>.
72The current version of SoftFloat is <NOBR>Release 3e</NOBR>.
73</P>
74
75
76<H2>2. Limitations</H2>
77
78<P>
79SoftFloat assumes the computer has an addressable byte size of either 8 or
80<NOBR>16 bits</NOBR>.
81(Nearly all computers in use today have <NOBR>8-bit</NOBR> bytes.)
82</P>
83
84<P>
85SoftFloat is written in C and is designed to work with other C code.
86The C compiler used must conform at a minimum to the 1989 ANSI standard for the
87C language (same as the 1990 ISO standard) and must in addition support basic
88arithmetic on <NOBR>64-bit</NOBR> integers.
89Earlier releases of SoftFloat included implementations of <NOBR>32-bit</NOBR>
90single-precision and <NOBR>64-bit</NOBR> double-precision floating-point that
91did not require <NOBR>64-bit</NOBR> integers, but this option is not supported
92starting with <NOBR>Release 3</NOBR>.
93Since 1999, ISO standards for C have mandated compiler support for
94<NOBR>64-bit</NOBR> integers.
95A compiler conforming to the 1999 C Standard or later is recommended but not
96strictly required.
97</P>
98
99<P>
100<NOBR>C Standard</NOBR> header files <CODE>&lt;stdbool.h&gt;</CODE> and
101<CODE>&lt;stdint.h&gt;</CODE> are required for defining standard Boolean and
102integer types.
103If these headers are not supplied with the C compiler, minimal substitutes must
104be provided.
105SoftFloat&rsquo;s dependence on these headers is detailed later in
106<NOBR>section 5.1</NOBR>, <I>Standard Headers <CODE>&lt;stdbool.h&gt;</CODE>
107and <CODE>&lt;stdint.h&gt;</CODE></I>.
108</P>
109
110
111<H2>3. Acknowledgments and License</H2>
112
113<P>
114The SoftFloat package was written by me, <NOBR>John R.</NOBR> Hauser.
115<NOBR>Release 3</NOBR> of SoftFloat was a completely new implementation
116supplanting earlier releases.
117The project to create <NOBR>Release 3</NOBR> (now <NOBR>through 3e</NOBR>) was
118done in the employ of the University of California, Berkeley, within the
119Department of Electrical Engineering and Computer Sciences, first for the
120Parallel Computing Laboratory (Par Lab) and then for the ASPIRE Lab.
121The work was officially overseen by Prof. Krste Asanovic, with funding provided
122by these sources:
123<BLOCKQUOTE>
124<TABLE>
125<COL>
126<COL WIDTH=10>
127<COL>
128<TR>
129<TD VALIGN=TOP><NOBR>Par Lab:</NOBR></TD>
130<TD></TD>
131<TD>
132Microsoft (Award #024263), Intel (Award #024894), and U.C. Discovery
133(Award #DIG07-10227), with additional support from Par Lab affiliates Nokia,
134NVIDIA, Oracle, and Samsung.
135</TD>
136</TR>
137<TR>
138<TD VALIGN=TOP><NOBR>ASPIRE Lab:</NOBR></TD>
139<TD></TD>
140<TD>
141DARPA PERFECT program (Award #HR0011-12-2-0016), with additional support from
142ASPIRE industrial sponsor Intel and ASPIRE affiliates Google, Nokia, NVIDIA,
143Oracle, and Samsung.
144</TD>
145</TR>
146</TABLE>
147</BLOCKQUOTE>
148</P>
149
150<P>
151The following applies to the whole of SoftFloat <NOBR>Release 3e</NOBR> as well
152as to each source file individually.
153</P>
154
155<P>
156Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The Regents of the
157University of California.
158All rights reserved.
159</P>
160
161<P>
162Redistribution and use in source and binary forms, with or without
163modification, are permitted provided that the following conditions are met:
164<OL>
165
166<LI>
167<P>
168Redistributions of source code must retain the above copyright notice, this
169list of conditions, and the following disclaimer.
170</P>
171
172<LI>
173<P>
174Redistributions in binary form must reproduce the above copyright notice, this
175list of conditions, and the following disclaimer in the documentation and/or
176other materials provided with the distribution.
177</P>
178
179<LI>
180<P>
181Neither the name of the University nor the names of its contributors may be
182used to endorse or promote products derived from this software without specific
183prior written permission.
184</P>
185
186</OL>
187</P>
188
189<P>
190THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS &ldquo;AS IS&rdquo;,
191AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
192IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
193DISCLAIMED.
194IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
195INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
196BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
197DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
198LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
199OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
200ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
201</P>
202
203
204<H2>4. SoftFloat Package Directory Structure</H2>
205
206<P>
207Because SoftFloat is targeted to multiple platforms, its source code is
208slightly scattered between target-specific and target-independent directories
209and files.
210The supplied directory structure is as follows:
211<BLOCKQUOTE>
212<PRE>
213doc
214source
215 include
216 8086
217 8086-SSE
218 ARM-VFPv2
219 ARM-VFPv2-defaultNaN
220build
221 template-FAST_INT64
222 template-not-FAST_INT64
223 Linux-386-GCC
224 Linux-386-SSE2-GCC
225 Linux-x86_64-GCC
226 Linux-ARM-VFPv2-GCC
227 Win32-MinGW
228 Win32-SSE2-MinGW
229 Win64-MinGW-w64
230</PRE>
231</BLOCKQUOTE>
232The majority of the SoftFloat sources are provided in the <CODE>source</CODE>
233directory.
234The <CODE>include</CODE> subdirectory contains several header files
235(unsurprisingly), while the other subdirectories of <CODE>source</CODE> contain
236source files that specialize the floating-point behavior to match particular
237processor families:
238<BLOCKQUOTE>
239<DL>
240<DT><CODE>8086</CODE></DT>
241<DD>
242Intel&rsquo;s older, 8087-derived floating-point, extended to all supported
243floating-point types
244</DD>
245<DT><CODE>8086-SSE</CODE></DT>
246<DD>
247Intel&rsquo;s x86 processors with Streaming SIMD Extensions (SSE) and later
248compatible extensions, having 8087 behavior for <NOBR>80-bit</NOBR>
249double-extended-precision (<CODE>extFloat80_t</CODE>) and SSE behavior for
250other floating-point types
251</DD>
252<DT><CODE>ARM-VFPv2</CODE></DT>
253<DD>
254ARM&rsquo;s VFPv2 or later floating-point, with NaN payload propagation
255</DD>
256<DT><CODE>ARM-VFPv2-defaultNaN</CODE></DT>
257<DD>
258ARM&rsquo;s VFPv2 or later floating-point, with the &ldquo;default NaN&rdquo;
259option
260</DD>
261</DL>
262</BLOCKQUOTE>
263If other specializations are attempted, these would be expected to be other
264subdirectories of <CODE>source</CODE> alongside the ones listed above.
265Specialization is covered later, in <NOBR>section 5.2</NOBR>, <I>Specializing
266Floating-Point Behavior</I>.
267</P>
268
269<P>
270The <CODE>build</CODE> directory is intended to contain a subdirectory for each
271target platform for which a build of the SoftFloat library may be created.
272For each build target, the target&rsquo;s subdirectory is where all derived
273object files and the completed SoftFloat library (typically
274<CODE>softfloat.a</CODE> or <CODE>libsoftfloat.a</CODE>) are created.
275The two <CODE>template</CODE> subdirectories are not actual build targets but
276contain sample files for creating new target directories.
277(The meaning of <CODE>FAST_INT64</CODE> will be explained later.)
278</P>
279
280<P>
281Ignoring the <CODE>template</CODE> directories, the supplied target directories
282are intended to follow a naming system of
283<NOBR><CODE>&lt;<I>execution-environment</I>&gt;-&lt;<I>compiler</I>&gt;</CODE></NOBR>.
284For the example targets,
285<NOBR><CODE>&lt;<I>execution-environment</I>&gt;</CODE></NOBR> is
286<NOBR><CODE>Linux-386</CODE></NOBR>, <NOBR><CODE>Linux-386-SSE2</CODE></NOBR>,
287<NOBR><CODE>Linux-x86_64</CODE></NOBR>,
288<NOBR><CODE>Linux-ARM-VFPv2</CODE></NOBR>, <CODE>Win32</CODE>,
289<NOBR><CODE>Win32-SSE2</CODE></NOBR>, or <CODE>Win64</CODE>, and
290<NOBR><CODE>&lt;<I>compiler</I>&gt;</CODE></NOBR> is <CODE>GCC</CODE>,
291<CODE>MinGW</CODE>, or <NOBR><CODE>MinGW-w64</CODE></NOBR>.
292</P>
293
294<P>
295All of the supplied target directories are merely examples that may or may not
296be correct for compiling on any particular system.
297Despite requests, there are currently no plans to include and maintain in the
298SoftFloat package the build files needed for a great many users&rsquo;
299compilation environments, which can span a huge range of operating systems,
300compilers, and other tools.
301</P>
302
303<P>
304As supplied, each target directory contains two files:
305<BLOCKQUOTE>
306<PRE>
307Makefile
308platform.h
309</PRE>
310</BLOCKQUOTE>
311The provided <CODE>Makefile</CODE> is written for GNU <CODE>make</CODE>.
312A build of SoftFloat for the specific target is begun by executing the
313<CODE>make</CODE> command with the target directory as the current directory.
314A completely different build tool can be used if an appropriate
315<CODE>Makefile</CODE> equivalent is created.
316</P>
317
318<P>
319The <CODE>platform.h</CODE> header file exists to provide a location for
320additional C declarations specific to the build target.
321Every C source file of SoftFloat contains a <CODE>#include</CODE> for
322<CODE>platform.h</CODE>.
323In many cases, the contents of <CODE>platform.h</CODE> can be as simple as one
324or two lines of code.
325At the other extreme, to get maximal performance from SoftFloat, it may be
326desirable to include in header <CODE>platform.h</CODE> (directly or via
327<CODE>#include</CODE>) declarations for numerous target-specific optimizations.
328Such possibilities are discussed in the next section, <I>Issues for Porting
329SoftFloat to a New Target</I>.
330If the target&rsquo;s compiler or library has bugs or other shortcomings,
331workarounds for these issues may also be possible with target-specific
332declarations in <CODE>platform.h</CODE>, avoiding the need to modify the main
333SoftFloat sources.
334</P>
335
336
337<H2>5. Issues for Porting SoftFloat to a New Target</H2>
338
339<H3>5.1. Standard Headers <CODE>&lt;stdbool.h&gt;</CODE> and <CODE>&lt;stdint.h&gt;</CODE></H3>
340
341<P>
342The SoftFloat sources make use of standard headers
343<CODE>&lt;stdbool.h&gt;</CODE> and <CODE>&lt;stdint.h&gt;</CODE>, which have
344been part of the ISO C Standard Library since 1999.
345With any recent compiler, these standard headers are likely to be supported,
346even if the compiler does not claim complete conformance to the latest ISO C
347Standard.
348For older or nonstandard compilers, substitutes for
349<CODE>&lt;stdbool.h&gt;</CODE> and <CODE>&lt;stdint.h&gt;</CODE> may need to be
350created.
351SoftFloat depends on these names from <CODE>&lt;stdbool.h&gt;</CODE>:
352<BLOCKQUOTE>
353<PRE>
354bool
355true
356false
357</PRE>
358</BLOCKQUOTE>
359and on these names from <CODE>&lt;stdint.h&gt;</CODE>:
360<BLOCKQUOTE>
361<PRE>
362uint16_t
363uint32_t
364uint64_t
365int32_t
366int64_t
367UINT64_C
368INT64_C
369uint_least8_t
370uint_fast8_t
371uint_fast16_t
372uint_fast32_t
373uint_fast64_t
374int_fast8_t
375int_fast16_t
376int_fast32_t
377int_fast64_t
378</PRE>
379</BLOCKQUOTE>
380</P>
381
382
383<H3>5.2. Specializing Floating-Point Behavior</H3>
384
385<P>
386The IEEE Floating-Point Standard allows for some flexibility in a conforming
387implementation, particularly concerning NaNs.
388The SoftFloat <CODE>source</CODE> directory is supplied with some
389<I>specialization</I> subdirectories containing possible definitions for this
390implementation-specific behavior.
391For example, the <CODE>8086</CODE> and <NOBR><CODE>8086-SSE</CODE></NOBR>
392subdirectories have source files that specialize SoftFloat&rsquo;s behavior to
393match that of Intel&rsquo;s x86 line of processors.
394The files in a specialization subdirectory must determine:
395<UL>
396<LI>
397whether tininess for underflow is detected before or after rounding by default;
398<LI>
399how signaling NaNs are distinguished from quiet NaNs;
400<LI>
401what (if anything) special happens when exceptions are raised;
402<LI>
403the default generated quiet NaNs;
404<LI>
405how NaNs are propagated from function inputs to output; and
406<LI>
407the integer results returned when conversions to integer type raise the
408<I>invalid</I> exception.
409</UL>
410</P>
411
412<P>
413As provided, the build process for a target expects to involve exactly
414<EM>one</EM> specialization directory that defines <EM>all</EM> of these
415implementation-specific details for the target.
416A specialization directory such as <CODE>8086</CODE> is expected to contain a
417header file called <CODE>specialize.h</CODE>, together with whatever other
418source files are needed to complete the specialization.
419</P>
420
421<P>
422A new build target may use an existing specialization, such as the ones
423provided by the <CODE>8086</CODE> and <NOBR><CODE>8086-SSE</CODE></NOBR>
424subdirectories.
425If a build target needs a new specialization, different from any existing ones,
426it is recommended that a new specialization directory be created for this
427purpose.
428The <CODE>specialize.h</CODE> header file from any of the provided
429specialization subdirectories can be used as a model for what definitions are
430needed.
431</P>
432
433
434<H3>5.3. Macros for Build Options</H3>
435
436<P>
437The SoftFloat source files adapt the floating-point implementation according to
438several C preprocessor macros:
439<BLOCKQUOTE>
440<DL>
441<DT><CODE>LITTLEENDIAN</CODE>
442<DD>
443Must be defined for little-endian machines; must not be defined for big-endian
444machines.
445<DT><CODE>INLINE</CODE>
446<DD>
447Specifies the sequence of tokens used to indicate that a C function should be
448inlined.
449If macro <CODE>INLINE_LEVEL</CODE> is defined with a value of 1 or higher, this
450macro must be defined; otherwise, this macro is ignored and need not be
451defined.
452For compilers that conform to the C Standard&rsquo;s rules for inline
453functions, this macro can be defined as the single keyword <CODE>inline</CODE>.
454For other compilers that follow a convention pre-dating the standardization of
455<CODE>inline</CODE>, this macro may need to be defined to <CODE>extern</CODE>
456<CODE>inline</CODE>.
457<DT><CODE>THREAD_LOCAL</CODE>
458<DD>
459Can be defined to a sequence of tokens that, when appearing at the start of a
460variable declaration, indicates to the C compiler that the variable is
461<I>per-thread</I>, meaning that each execution thread gets its own separate
462instance of the variable.
463This macro is used in header <CODE>softfloat.h</CODE> in the declarations of
464variables <CODE>softfloat_roundingMode</CODE>,
465<CODE>softfloat_detectTininess</CODE>, <CODE>extF80_roundingPrecision</CODE>,
466and <CODE>softfloat_exceptionFlags</CODE>.
467If macro <CODE>THREAD_LOCAL</CODE> is left undefined, these variables will
468default to being ordinary global variables.
469Depending on the compiler, possible valid definitions of this macro include
470<CODE>_Thread_local</CODE> and <CODE>__thread</CODE>.
471</DL>
472<DL>
473<DT><CODE>SOFTFLOAT_ROUND_ODD</CODE>
474<DD>
475Can be defined to enable support for optional rounding mode
476<CODE>softfloat_round_odd</CODE>.
477</DL>
478<DL>
479<DT><CODE>INLINE_LEVEL</CODE>
480<DD>
481Can be defined to an integer to determine the degree of inlining requested of
482the compiler.
483Larger numbers request that more inlining be done.
484If this macro is not defined or is defined to a value less <NOBR>than 1</NOBR>
485(zero or negative), no inlining is requested.
486The maximum effective value is no higher <NOBR>than 5</NOBR>.
487Defining this macro to a value greater than 5 is the same as defining it
488<NOBR>to 5</NOBR>.
489<DT><CODE>SOFTFLOAT_FAST_INT64</CODE>
490<DD>
491Can be defined to indicate that the build target&rsquo;s implementation of
492<NOBR>64-bit</NOBR> arithmetic is efficient.
493For newer <NOBR>64-bit</NOBR> processors, this macro should usually be defined.
494For very small microprocessors whose buses and registers are <NOBR>8-bit</NOBR>
495or <NOBR>16-bit</NOBR> in size, this macro should usually not be defined.
496Whether this macro should be defined for a <NOBR>32-bit</NOBR> processor may
497depend on the target machine and the applications that will use SoftFloat.
498<DT><CODE>SOFTFLOAT_FAST_DIV32TO16</CODE>
499<DD>
500Can be defined to indicate that the target&rsquo;s division operator
501<NOBR>in C</NOBR> (written as <CODE>/</CODE>) is reasonably efficient for
502dividing a <NOBR>32-bit</NOBR> unsigned integer by a <NOBR>16-bit</NOBR>
503unsigned integer.
504Setting this macro may affect the performance of function <CODE>f16_div</CODE>.
505<DT><CODE>SOFTFLOAT_FAST_DIV64TO32</CODE>
506<DD>
507Can be defined to indicate that the target&rsquo;s division operator
508<NOBR>in C</NOBR> (written as <CODE>/</CODE>) is reasonably efficient for
509dividing a <NOBR>64-bit</NOBR> unsigned integer by a <NOBR>32-bit</NOBR>
510unsigned integer.
511Setting this macro may affect the performance of division, remainder, and
512square root operations other than <CODE>f16_div</CODE>.
513</DL>
514</BLOCKQUOTE>
515</P>
516
517<P>
518Following the usual custom <NOBR>for C</NOBR>, for most of these macros (all
519except <CODE>INLINE</CODE>, <CODE>THREAD_LOCAL</CODE>, and
520<CODE>INLINE_LEVEL</CODE>), the content of any definition is irrelevant;
521what matters is a macro&rsquo;s effect on <CODE>#ifdef</CODE> directives.
522</P>
523
524<P>
525It is recommended that any definitions of macros <CODE>LITTLEENDIAN</CODE>,
526<CODE>INLINE</CODE>, and <CODE>THREAD_LOCAL</CODE> be made in a build
527target&rsquo;s <CODE>platform.h</CODE> header file, because these macros are
528expected to be determined inflexibly by the target machine and compiler.
529The other five macros select options and control optimization, and thus might
530be better located in the target&rsquo;s Makefile (or its equivalent).
531</P>
532
533
534<H3>5.4. Adapting a Template Target Directory</H3>
535
536<P>
537In the <CODE>build</CODE> directory, two <CODE>template</CODE> subdirectories
538provide models for new target directories.
539Two different templates exist because different functions are needed in the
540SoftFloat library depending on whether macro <CODE>SOFTFLOAT_FAST_INT64</CODE>
541is defined.
542If macro <CODE>SOFTFLOAT_FAST_INT64</CODE> will be defined,
543<NOBR><CODE>template-FAST_INT64</CODE></NOBR> is the template to use;
544otherwise, <NOBR><CODE>template-not-FAST_INT64</CODE></NOBR> is the appropriate
545template.
546A new target directory can be created by copying the correct template directory
547and editing the files inside.
548To avoid confusion, it would be wise to refrain from editing the files within a
549template directory directly.
550</P>
551
552
553<H3>5.5. Target-Specific Optimization of Primitive Functions</H3>
554
555<P>
556Header file <CODE>primitives.h</CODE> (in directory
557<CODE>source/include</CODE>) declares macros and functions for numerous
558underlying arithmetic operations upon which many of SoftFloat&rsquo;s
559floating-point functions are ultimately built.
560The SoftFloat sources include implementations of all of these functions/macros,
561written as standard C code, so a complete and correct SoftFloat library can be
562created using only the supplied code for all functions.
563However, for many targets, SoftFloat&rsquo;s performance can be improved by
564substituting target-specific implementations of some of the functions/macros
565declared in <CODE>primitives.h</CODE>.
566</P>
567
568<P>
569For example, <CODE>primitives.h</CODE> declares a function called
570<CODE>softfloat_countLeadingZeros32</CODE> that takes an unsigned
571<NOBR>32-bit</NOBR> integer as an argument and returns the number of the
572integer&rsquo;s most-significant bits that are zeros.
573While the SoftFloat sources include an implementation of this function written
574in <NOBR>standard C</NOBR>, many processors can perform this same function
575directly in only one or two machine instructions.
576An alternative, target-specific implementation that maps to those instructions
577is likely to be more efficient than the generic C code from the SoftFloat
578package.
579</P>
580
581<P>
582A build target can replace the supplied version of any function or macro of
583<CODE>primitives.h</CODE> by defining a macro with the same name in the
584target&rsquo;s <CODE>platform.h</CODE> header file.
585For this purpose, it may be helpful for <CODE>platform.h</CODE> to
586<CODE>#include</CODE> header file <CODE>primitiveTypes.h</CODE>, which defines
587types used for arguments and results of functions declared in
588<CODE>primitives.h</CODE>.
589When a desired replacement implementation is a function, not a macro, it is
590sufficient for <CODE>platform.h</CODE> to include the line
591<BLOCKQUOTE>
592<PRE>
593#define &lt;<I>function-name</I>&gt; &lt;<I>function-name</I>&gt;
594</PRE>
595</BLOCKQUOTE>
596where <NOBR><CODE>&lt;<I>function-name</I>&gt;</CODE></NOBR> is the name of the
597function.
598This technically defines <NOBR><CODE>&lt;<I>function-name</I>&gt;</CODE></NOBR>
599as a macro, but one that resolves to the same name, which may then be a
600function.
601(A preprocessor that conforms to the C Standard is required to limit recursive
602macro expansion from being applied more than once.)
603</P>
604
605<P>
606The supplied header file <CODE>opts-GCC.h</CODE> (in directory
607<CODE>source/include</CODE>) provides an example of target-specific
608optimization for the GCC compiler.
609Each GCC target example in the <CODE>build</CODE> directory has
610<BLOCKQUOTE>
611<CODE>#include "opts-GCC.h"</CODE>
612</BLOCKQUOTE>
613in its <CODE>platform.h</CODE> header file.
614Before <CODE>opts-GCC.h</CODE> is included, the following macros must be
615defined (or not) to control which features are invoked:
616<BLOCKQUOTE>
617<DL>
618<DT><CODE>SOFTFLOAT_BUILTIN_CLZ</CODE></DT>
619<DD>
620If defined, SoftFloat&rsquo;s internal
621&lsquo;<CODE>countLeadingZeros</CODE>&rsquo; functions use intrinsics
622<CODE>__builtin_clz</CODE> and <CODE>__builtin_clzll</CODE>.
623</DD>
624<DT><CODE>SOFTFLOAT_INTRINSIC_INT128</CODE></DT>
625<DD>
626If defined, SoftFloat makes use of GCC&rsquo;s nonstandard <NOBR>128-bit</NOBR>
627integer type <CODE>__int128</CODE>.
628</DD>
629</DL>
630</BLOCKQUOTE>
631On some machines, these improvements are observed to increase the speeds of
632<CODE>f64_mul</CODE> and <CODE>f128_mul</CODE> by around 20 to 25%, although
633other functions receive less dramatic boosts, or none at all.
634Results can vary greatly across different platforms.
635</P>
636
637
638<H2>6. Testing SoftFloat</H2>
639
640<P>
641SoftFloat can be tested using the <CODE>testsoftfloat</CODE> program by the
642same author.
643This program is part of the Berkeley TestFloat package available at the Web
644page
645<A HREF="http://www.jhauser.us/arithmetic/TestFloat.html"><NOBR><CODE>http://www.jhauser.us/arithmetic/TestFloat.html</CODE></NOBR></A>.
646The TestFloat package also has a program called <CODE>timesoftfloat</CODE> that
647measures the speed of SoftFloat&rsquo;s floating-point functions.
648</P>
649
650
651<H2>7. Providing SoftFloat as a Common Library for Applications</H2>
652
653<P>
654Header file <CODE>softfloat.h</CODE> defines the SoftFloat interface as seen by
655clients.
656If the SoftFloat library will be made a common library for programs on a
657system, the supplied <CODE>softfloat.h</CODE> has a couple of deficiencies for
658this purpose:
659<UL>
660<LI>
661As supplied, <CODE>softfloat.h</CODE> depends on another header,
662<CODE>softfloat_types.h</CODE>, that is not intended for public use but which
663must also be visible to the programmer&rsquo;s compiler.
664<LI>
665More troubling, at the time <CODE>softfloat.h</CODE> is included in a C source
666file, macros <CODE>SOFTFLOAT_FAST_INT64</CODE> and <CODE>THREAD_LOCAL</CODE>
667must be defined, or not defined, consistent with how these macro were defined
668when the SoftFloat library was built.
669</UL>
670In the situation that new programs may regularly <CODE>#include</CODE> header
671file <CODE>softfloat.h</CODE>, it is recommended that a custom, self-contained
672version of this header file be created that eliminates these issues.
673</P>
674
675
676<H2>8. Contact Information</H2>
677
678<P>
679At the time of this writing, the most up-to-date information about SoftFloat
680and the latest release can be found at the Web page
681<A HREF="http://www.jhauser.us/arithmetic/SoftFloat.html"><NOBR><CODE>http://www.jhauser.us/arithmetic/SoftFloat.html</CODE></NOBR></A>.
682</P>
683
684
685</BODY>
686
deps/SoftFloat-3e/doc/SoftFloat.html created+1527
......@@ -0,0 +1,1527 @@
1
2<HTML>
3
4<HEAD>
5<TITLE>Berkeley SoftFloat Library Interface</TITLE>
6</HEAD>
7
8<BODY>
9
10<H1>Berkeley SoftFloat Release 3e: Library Interface</H1>
11
12<P>
13John R. Hauser<BR>
142018 January 20<BR>
15</P>
16
17
18<H2>Contents</H2>
19
20<BLOCKQUOTE>
21<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>
22<COL WIDTH=25>
23<COL WIDTH=*>
24<TR><TD COLSPAN=2>1. Introduction</TD></TR>
25<TR><TD COLSPAN=2>2. Limitations</TD></TR>
26<TR><TD COLSPAN=2>3. Acknowledgments and License</TD></TR>
27<TR><TD COLSPAN=2>4. Types and Functions</TD></TR>
28<TR><TD></TD><TD>4.1. Boolean and Integer Types</TD></TR>
29<TR><TD></TD><TD>4.2. Floating-Point Types</TD></TR>
30<TR><TD></TD><TD>4.3. Supported Floating-Point Functions</TD></TR>
31<TR>
32 <TD></TD>
33 <TD>4.4. Non-canonical Representations in <CODE>extFloat80_t</CODE></TD>
34</TR>
35<TR><TD></TD><TD>4.5. Conventions for Passing Arguments and Results</TD></TR>
36<TR><TD COLSPAN=2>5. Reserved Names</TD></TR>
37<TR><TD COLSPAN=2>6. Mode Variables</TD></TR>
38<TR><TD></TD><TD>6.1. Rounding Mode</TD></TR>
39<TR><TD></TD><TD>6.2. Underflow Detection</TD></TR>
40<TR>
41 <TD></TD>
42 <TD>6.3. Rounding Precision for the <NOBR>80-Bit</NOBR> Extended Format</TD>
43</TR>
44<TR><TD COLSPAN=2>7. Exceptions and Exception Flags</TD></TR>
45<TR><TD COLSPAN=2>8. Function Details</TD></TR>
46<TR><TD></TD><TD>8.1. Conversions from Integer to Floating-Point</TD></TR>
47<TR><TD></TD><TD>8.2. Conversions from Floating-Point to Integer</TD></TR>
48<TR><TD></TD><TD>8.3. Conversions Among Floating-Point Types</TD></TR>
49<TR><TD></TD><TD>8.4. Basic Arithmetic Functions</TD></TR>
50<TR><TD></TD><TD>8.5. Fused Multiply-Add Functions</TD></TR>
51<TR><TD></TD><TD>8.6. Remainder Functions</TD></TR>
52<TR><TD></TD><TD>8.7. Round-to-Integer Functions</TD></TR>
53<TR><TD></TD><TD>8.8. Comparison Functions</TD></TR>
54<TR><TD></TD><TD>8.9. Signaling NaN Test Functions</TD></TR>
55<TR><TD></TD><TD>8.10. Raise-Exception Function</TD></TR>
56<TR><TD COLSPAN=2>9. Changes from SoftFloat <NOBR>Release 2</NOBR></TD></TR>
57<TR><TD></TD><TD>9.1. Name Changes</TD></TR>
58<TR><TD></TD><TD>9.2. Changes to Function Arguments</TD></TR>
59<TR><TD></TD><TD>9.3. Added Capabilities</TD></TR>
60<TR><TD></TD><TD>9.4. Better Compatibility with the C Language</TD></TR>
61<TR><TD></TD><TD>9.5. New Organization as a Library</TD></TR>
62<TR><TD></TD><TD>9.6. Optimization Gains (and Losses)</TD></TR>
63<TR><TD COLSPAN=2>10. Future Directions</TD></TR>
64<TR><TD COLSPAN=2>11. Contact Information</TD></TR>
65</TABLE>
66</BLOCKQUOTE>
67
68
69<H2>1. Introduction</H2>
70
71<P>
72Berkeley SoftFloat is a software implementation of binary floating-point that
73conforms to the IEEE Standard for Floating-Point Arithmetic.
74The current release supports five binary formats: <NOBR>16-bit</NOBR>
75half-precision, <NOBR>32-bit</NOBR> single-precision, <NOBR>64-bit</NOBR>
76double-precision, <NOBR>80-bit</NOBR> double-extended-precision, and
77<NOBR>128-bit</NOBR> quadruple-precision.
78The following functions are supported for each format:
79<UL>
80<LI>
81addition, subtraction, multiplication, division, and square root;
82<LI>
83fused multiply-add as defined by the IEEE Standard, except for
84<NOBR>80-bit</NOBR> double-extended-precision;
85<LI>
86remainder as defined by the IEEE Standard;
87<LI>
88round to integral value;
89<LI>
90comparisons;
91<LI>
92conversions to/from other supported formats; and
93<LI>
94conversions to/from <NOBR>32-bit</NOBR> and <NOBR>64-bit</NOBR> integers,
95signed and unsigned.
96</UL>
97All operations required by the original 1985 version of the IEEE Floating-Point
98Standard are implemented, except for conversions to and from decimal.
99</P>
100
101<P>
102This document gives information about the types defined and the routines
103implemented by SoftFloat.
104It does not attempt to define or explain the IEEE Floating-Point Standard.
105Information about the standard is available elsewhere.
106</P>
107
108<P>
109The current version of SoftFloat is <NOBR>Release 3e</NOBR>.
110This release modifies the behavior of the rarely used <I>odd</I> rounding mode
111(<I>round to odd</I>, also known as <I>jamming</I>), and also adds some new
112specialization and optimization examples for those compiling SoftFloat.
113</P>
114
115<P>
116The previous <NOBR>Release 3d</NOBR> fixed bugs that were found in the square
117root functions for the <NOBR>64-bit</NOBR>, <NOBR>80-bit</NOBR>, and
118<NOBR>128-bit</NOBR> floating-point formats.
119(Thanks to Alexei Sibidanov at the University of Victoria for reporting an
120incorrect result.)
121The bugs affected all prior <NOBR>Release-3</NOBR> versions of SoftFloat
122<NOBR>through 3c</NOBR>.
123The flaw in the <NOBR>64-bit</NOBR> floating-point square root function was of
124very minor impact, causing a <NOBR>1-ulp</NOBR> error (<NOBR>1 unit</NOBR> in
125the last place) a few times out of a billion.
126The bugs in the <NOBR>80-bit</NOBR> and <NOBR>128-bit</NOBR> square root
127functions were more serious.
128Although incorrect results again occurred only a few times out of a billion,
129when they did occur a large portion of the less-significant bits could be
130wrong.
131</P>
132
133<P>
134Among earlier releases, 3b was notable for adding support for the
135<NOBR>16-bit</NOBR> half-precision format.
136For more about the evolution of SoftFloat releases, see
137<A HREF="SoftFloat-history.html"><NOBR><CODE>SoftFloat-history.html</CODE></NOBR></A>.
138</P>
139
140<P>
141The functional interface of SoftFloat <NOBR>Release 3</NOBR> and later differs
142in many details from the releases that came before.
143For specifics of these differences, see <NOBR>section 9</NOBR> below,
144<I>Changes from SoftFloat <NOBR>Release 2</NOBR></I>.
145</P>
146
147
148<H2>2. Limitations</H2>
149
150<P>
151SoftFloat assumes the computer has an addressable byte size of 8 or
152<NOBR>16 bits</NOBR>.
153(Nearly all computers in use today have <NOBR>8-bit</NOBR> bytes.)
154</P>
155
156<P>
157SoftFloat is written in C and is designed to work with other C code.
158The C compiler used must conform at a minimum to the 1989 ANSI standard for the
159C language (same as the 1990 ISO standard) and must in addition support basic
160arithmetic on <NOBR>64-bit</NOBR> integers.
161Earlier releases of SoftFloat included implementations of <NOBR>32-bit</NOBR>
162single-precision and <NOBR>64-bit</NOBR> double-precision floating-point that
163did not require <NOBR>64-bit</NOBR> integers, but this option is not supported
164starting with <NOBR>Release 3</NOBR>.
165Since 1999, ISO standards for C have mandated compiler support for
166<NOBR>64-bit</NOBR> integers.
167A compiler conforming to the 1999 C Standard or later is recommended but not
168strictly required.
169</P>
170
171<P>
172Most operations not required by the original 1985 version of the IEEE
173Floating-Point Standard but added in the 2008 version are not yet supported in
174SoftFloat <NOBR>Release 3e</NOBR>.
175</P>
176
177
178<H2>3. Acknowledgments and License</H2>
179
180<P>
181The SoftFloat package was written by me, <NOBR>John R.</NOBR> Hauser.
182<NOBR>Release 3</NOBR> of SoftFloat was a completely new implementation
183supplanting earlier releases.
184The project to create <NOBR>Release 3</NOBR> (now <NOBR>through 3e</NOBR>) was
185done in the employ of the University of California, Berkeley, within the
186Department of Electrical Engineering and Computer Sciences, first for the
187Parallel Computing Laboratory (Par Lab) and then for the ASPIRE Lab.
188The work was officially overseen by Prof. Krste Asanovic, with funding provided
189by these sources:
190<BLOCKQUOTE>
191<TABLE>
192<COL>
193<COL WIDTH=10>
194<COL>
195<TR>
196<TD VALIGN=TOP><NOBR>Par Lab:</NOBR></TD>
197<TD></TD>
198<TD>
199Microsoft (Award #024263), Intel (Award #024894), and U.C. Discovery
200(Award #DIG07-10227), with additional support from Par Lab affiliates Nokia,
201NVIDIA, Oracle, and Samsung.
202</TD>
203</TR>
204<TR>
205<TD VALIGN=TOP><NOBR>ASPIRE Lab:</NOBR></TD>
206<TD></TD>
207<TD>
208DARPA PERFECT program (Award #HR0011-12-2-0016), with additional support from
209ASPIRE industrial sponsor Intel and ASPIRE affiliates Google, Nokia, NVIDIA,
210Oracle, and Samsung.
211</TD>
212</TR>
213</TABLE>
214</BLOCKQUOTE>
215</P>
216
217<P>
218The following applies to the whole of SoftFloat <NOBR>Release 3e</NOBR> as well
219as to each source file individually.
220</P>
221
222<P>
223Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The Regents of the
224University of California.
225All rights reserved.
226</P>
227
228<P>
229Redistribution and use in source and binary forms, with or without
230modification, are permitted provided that the following conditions are met:
231<OL>
232
233<LI>
234<P>
235Redistributions of source code must retain the above copyright notice, this
236list of conditions, and the following disclaimer.
237</P>
238
239<LI>
240<P>
241Redistributions in binary form must reproduce the above copyright notice, this
242list of conditions, and the following disclaimer in the documentation and/or
243other materials provided with the distribution.
244</P>
245
246<LI>
247<P>
248Neither the name of the University nor the names of its contributors may be
249used to endorse or promote products derived from this software without specific
250prior written permission.
251</P>
252
253</OL>
254</P>
255
256<P>
257THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS &ldquo;AS IS&rdquo;,
258AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
259IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
260DISCLAIMED.
261IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
262INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
263BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
264DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
265LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
266OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
267ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
268</P>
269
270
271<H2>4. Types and Functions</H2>
272
273<P>
274The types and functions of SoftFloat are declared in header file
275<CODE>softfloat.h</CODE>.
276</P>
277
278<H3>4.1. Boolean and Integer Types</H3>
279
280<P>
281Header file <CODE>softfloat.h</CODE> depends on standard headers
282<CODE>&lt;stdbool.h&gt;</CODE> and <CODE>&lt;stdint.h&gt;</CODE> to define type
283<CODE>bool</CODE> and several integer types.
284These standard headers have been part of the ISO C Standard Library since 1999.
285With any recent compiler, they are likely to be supported, even if the compiler
286does not claim complete conformance to the latest ISO C Standard.
287For older or nonstandard compilers, a port of SoftFloat may have substitutes
288for these headers.
289Header <CODE>softfloat.h</CODE> depends only on the name <CODE>bool</CODE> from
290<CODE>&lt;stdbool.h&gt;</CODE> and on these type names from
291<CODE>&lt;stdint.h&gt;</CODE>:
292<BLOCKQUOTE>
293<PRE>
294uint16_t
295uint32_t
296uint64_t
297int32_t
298int64_t
299uint_fast8_t
300uint_fast32_t
301uint_fast64_t
302int_fast32_t
303int_fast64_t
304</PRE>
305</BLOCKQUOTE>
306</P>
307
308
309<H3>4.2. Floating-Point Types</H3>
310
311<P>
312The <CODE>softfloat.h</CODE> header defines five floating-point types:
313<BLOCKQUOTE>
314<TABLE CELLSPACING=0 CELLPADDING=0>
315<TR>
316<TD><CODE>float16_t</CODE></TD>
317<TD><NOBR>16-bit</NOBR> half-precision binary format</TD>
318</TR>
319<TR>
320<TD><CODE>float32_t</CODE></TD>
321<TD><NOBR>32-bit</NOBR> single-precision binary format</TD>
322</TR>
323<TR>
324<TD><CODE>float64_t</CODE></TD>
325<TD><NOBR>64-bit</NOBR> double-precision binary format</TD>
326</TR>
327<TR>
328<TD><CODE>extFloat80_t&nbsp;&nbsp;&nbsp;</CODE></TD>
329<TD><NOBR>80-bit</NOBR> double-extended-precision binary format (old Intel or
330Motorola format)</TD>
331</TR>
332<TR>
333<TD><CODE>float128_t</CODE></TD>
334<TD><NOBR>128-bit</NOBR> quadruple-precision binary format</TD>
335</TR>
336</TABLE>
337</BLOCKQUOTE>
338The non-extended types are each exactly the size specified:
339<NOBR>16 bits</NOBR> for <CODE>float16_t</CODE>, <NOBR>32 bits</NOBR> for
340<CODE>float32_t</CODE>, <NOBR>64 bits</NOBR> for <CODE>float64_t</CODE>, and
341<NOBR>128 bits</NOBR> for <CODE>float128_t</CODE>.
342Aside from these size requirements, the definitions of all these types may
343differ for different ports of SoftFloat to specific systems.
344A given port of SoftFloat may or may not define some of the floating-point
345types as aliases for the C standard types <CODE>float</CODE>,
346<CODE>double</CODE>, and <CODE>long</CODE> <CODE>double</CODE>.
347</P>
348
349<P>
350Header file <CODE>softfloat.h</CODE> also defines a structure,
351<CODE>struct</CODE> <CODE>extFloat80M</CODE>, for the representation of
352<NOBR>80-bit</NOBR> double-extended-precision floating-point values in memory.
353This structure is the same size as type <CODE>extFloat80_t</CODE> and contains
354at least these two fields (not necessarily in this order):
355<BLOCKQUOTE>
356<PRE>
357uint16_t signExp;
358uint64_t signif;
359</PRE>
360</BLOCKQUOTE>
361Field <CODE>signExp</CODE> contains the sign and exponent of the floating-point
362value, with the sign in the most significant bit (<NOBR>bit 15</NOBR>) and the
363encoded exponent in the other <NOBR>15 bits</NOBR>.
364Field <CODE>signif</CODE> is the complete <NOBR>64-bit</NOBR> significand of
365the floating-point value.
366(In the usual encoding for <NOBR>80-bit</NOBR> extended floating-point, the
367leading <NOBR>1 bit</NOBR> of normalized numbers is not implicit but is stored
368in the most significant bit of the significand.)
369</P>
370
371<H3>4.3. Supported Floating-Point Functions</H3>
372
373<P>
374SoftFloat implements these arithmetic operations for its floating-point types:
375<UL>
376<LI>
377conversions between any two floating-point formats;
378<LI>
379for each floating-point format, conversions to and from signed and unsigned
380<NOBR>32-bit</NOBR> and <NOBR>64-bit</NOBR> integers;
381<LI>
382for each format, the usual addition, subtraction, multiplication, division, and
383square root operations;
384<LI>
385for each format except <CODE>extFloat80_t</CODE>, the fused multiply-add
386operation defined by the IEEE Standard;
387<LI>
388for each format, the floating-point remainder operation defined by the IEEE
389Standard;
390<LI>
391for each format, a &ldquo;round to integer&rdquo; operation that rounds to the
392nearest integer value in the same format; and
393<LI>
394comparisons between two values in the same floating-point format.
395</UL>
396</P>
397
398<P>
399The following operations required by the 2008 IEEE Floating-Point Standard are
400not supported in SoftFloat <NOBR>Release 3e</NOBR>:
401<UL>
402<LI>
403<B>nextUp</B>, <B>nextDown</B>, <B>minNum</B>, <B>maxNum</B>, <B>minNumMag</B>,
404<B>maxNumMag</B>, <B>scaleB</B>, and <B>logB</B>;
405<LI>
406conversions between floating-point formats and decimal or hexadecimal character
407sequences;
408<LI>
409all &ldquo;quiet-computation&rdquo; operations (<B>copy</B>, <B>negate</B>,
410<B>abs</B>, and <B>copySign</B>, which all involve only simple copying and/or
411manipulation of the floating-point sign bit); and
412<LI>
413all &ldquo;non-computational&rdquo; operations other than <B>isSignaling</B>
414(which is supported).
415</UL>
416</P>
417
418<H3>4.4. Non-canonical Representations in <CODE>extFloat80_t</CODE></H3>
419
420<P>
421Because the <NOBR>80-bit</NOBR> double-extended-precision format,
422<CODE>extFloat80_t</CODE>, stores an explicit leading significand bit, many
423finite floating-point numbers are encodable in this type in multiple equivalent
424forms.
425Of these multiple encodings, there is always a unique one with the least
426encoded exponent value, and this encoding is considered the <I>canonical</I>
427representation of the floating-point number.
428Any other equivalent representations (having a higher encoded exponent value)
429are <I>non-canonical</I>.
430For a value in the subnormal range (including zero), the canonical
431representation always has an encoded exponent of zero and a leading significand
432bit <NOBR>of 0</NOBR>.
433For finite values outside the subnormal range, the canonical representation
434always has an encoded exponent that is nonzero and a leading significand bit
435<NOBR>of 1</NOBR>.
436</P>
437
438<P>
439For an infinity or NaN, the leading significand bit is similarly expected to
440<NOBR>be 1</NOBR>.
441An infinity or NaN with a leading significand bit <NOBR>of 0</NOBR> is again
442considered non-canonical.
443Hence, altogether, to be canonical, a value of type <CODE>extFloat80_t</CODE>
444must have a leading significand bit <NOBR>of 1</NOBR>, unless the value is
445subnormal or zero, in which case the leading significand bit and the encoded
446exponent must both be zero.
447</P>
448
449<P>
450SoftFloat&rsquo;s functions are not guaranteed to operate as expected when
451inputs of type <CODE>extFloat80_t</CODE> are non-canonical.
452Assuming all of a function&rsquo;s <CODE>extFloat80_t</CODE> inputs (if any)
453are canonical, function outputs of type <CODE>extFloat80_t</CODE> will always
454be canonical.
455</P>
456
457<H3>4.5. Conventions for Passing Arguments and Results</H3>
458
459<P>
460Values that are at most <NOBR>64 bits</NOBR> in size (i.e., not the
461<NOBR>80-bit</NOBR> or <NOBR>128-bit</NOBR> floating-point formats) are in all
462cases passed as function arguments by value.
463Likewise, when an output of a function is no more than <NOBR>64 bits</NOBR>, it
464is always returned directly as the function result.
465Thus, for example, the SoftFloat function for adding two <NOBR>64-bit</NOBR>
466floating-point values has this simple signature:
467<BLOCKQUOTE>
468<CODE>float64_t f64_add( float64_t, float64_t );</CODE>
469</BLOCKQUOTE>
470</P>
471
472<P>
473The story is more complex when function inputs and outputs are
474<NOBR>80-bit</NOBR> and <NOBR>128-bit</NOBR> floating-point.
475For these types, SoftFloat always provides a function that passes these larger
476values into or out of the function indirectly, via pointers.
477For example, for adding two <NOBR>128-bit</NOBR> floating-point values,
478SoftFloat supplies this function:
479<BLOCKQUOTE>
480<CODE>void f128M_add( const float128_t *, const float128_t *, float128_t * );</CODE>
481</BLOCKQUOTE>
482The first two arguments point to the values to be added, and the last argument
483points to the location where the sum will be stored.
484The <CODE>M</CODE> in the name <CODE>f128M_add</CODE> is mnemonic for the fact
485that the <NOBR>128-bit</NOBR> inputs and outputs are &ldquo;in memory&rdquo;,
486pointed to by pointer arguments.
487</P>
488
489<P>
490All ports of SoftFloat implement these <I>pass-by-pointer</I> functions for
491types <CODE>extFloat80_t</CODE> and <CODE>float128_t</CODE>.
492At the same time, SoftFloat ports may also implement alternate versions of
493these same functions that pass <CODE>extFloat80_t</CODE> and
494<CODE>float128_t</CODE> by value, like the smaller formats.
495Thus, besides the function with name <CODE>f128M_add</CODE> shown above, a
496SoftFloat port may also supply an equivalent function with this signature:
497<BLOCKQUOTE>
498<CODE>float128_t f128_add( float128_t, float128_t );</CODE>
499</BLOCKQUOTE>
500</P>
501
502<P>
503As a general rule, on computers where the machine word size is
504<NOBR>32 bits</NOBR> or smaller, only the pass-by-pointer versions of functions
505(e.g., <CODE>f128M_add</CODE>) are provided for types <CODE>extFloat80_t</CODE>
506and <CODE>float128_t</CODE>, because passing such large types directly can have
507significant extra cost.
508On computers where the word size is <NOBR>64 bits</NOBR> or larger, both
509function versions (<CODE>f128M_add</CODE> and <CODE>f128_add</CODE>) are
510provided, because the cost of passing by value is then more reasonable.
511Applications that must be portable accross both classes of computers must use
512the pointer-based functions, as these are always implemented.
513However, if it is known that SoftFloat includes the by-value functions for all
514platforms of interest, programmers can use whichever version they prefer.
515</P>
516
517
518<H2>5. Reserved Names</H2>
519
520<P>
521In addition to the variables and functions documented here, SoftFloat defines
522some symbol names for its own private use.
523These private names always begin with the prefix
524&lsquo;<CODE>softfloat_</CODE>&rsquo;.
525When a program includes header <CODE>softfloat.h</CODE> or links with the
526SoftFloat library, all names with prefix &lsquo;<CODE>softfloat_</CODE>&rsquo;
527are reserved for possible use by SoftFloat.
528Applications that use SoftFloat should not define their own names with this
529prefix, and should reference only such names as are documented.
530</P>
531
532
533<H2>6. Mode Variables</H2>
534
535<P>
536The following global variables control rounding mode, underflow detection, and
537the <NOBR>80-bit</NOBR> extended format&rsquo;s rounding precision:
538<BLOCKQUOTE>
539<CODE>softfloat_roundingMode</CODE><BR>
540<CODE>softfloat_detectTininess</CODE><BR>
541<CODE>extF80_roundingPrecision</CODE>
542</BLOCKQUOTE>
543These mode variables are covered in the next several subsections.
544For some SoftFloat ports, these variables may be <I>per-thread</I> (declared
545<CODE>thread_local</CODE>), meaning that different execution threads have their
546own separate copies of the variables.
547</P>
548
549<H3>6.1. Rounding Mode</H3>
550
551<P>
552All five rounding modes defined by the 2008 IEEE Floating-Point Standard are
553implemented for all operations that require rounding.
554Some ports of SoftFloat may also implement the <I>round-to-odd</I> mode.
555</P>
556
557<P>
558The rounding mode is selected by the global variable
559<BLOCKQUOTE>
560<CODE>uint_fast8_t softfloat_roundingMode;</CODE>
561</BLOCKQUOTE>
562This variable may be set to one of the values
563<BLOCKQUOTE>
564<TABLE CELLSPACING=0 CELLPADDING=0>
565<TR>
566<TD><CODE>softfloat_round_near_even</CODE></TD>
567<TD>round to nearest, with ties to even</TD>
568</TR>
569<TR>
570<TD><CODE>softfloat_round_near_maxMag&nbsp;&nbsp;</CODE></TD>
571<TD>round to nearest, with ties to maximum magnitude (away from zero)</TD>
572</TR>
573<TR>
574<TD><CODE>softfloat_round_minMag</CODE></TD>
575<TD>round to minimum magnitude (toward zero)</TD>
576</TR>
577<TR>
578<TD><CODE>softfloat_round_min</CODE></TD>
579<TD>round to minimum (down)</TD>
580</TR>
581<TR>
582<TD><CODE>softfloat_round_max</CODE></TD>
583<TD>round to maximum (up)</TD>
584</TR>
585<TR>
586<TD><CODE>softfloat_round_odd</CODE></TD>
587<TD>round to odd (jamming), if supported by the SoftFloat port</TD>
588</TR>
589</TABLE>
590</BLOCKQUOTE>
591Variable <CODE>softfloat_roundingMode</CODE> is initialized to
592<CODE>softfloat_round_near_even</CODE>.
593</P>
594
595<P>
596When <CODE>softfloat_round_odd</CODE> is the rounding mode for a function that
597rounds to an integer value (either conversion to an integer format or a
598&lsquo;<CODE>roundToInt</CODE>&rsquo; function), if the input is not already an
599integer, the rounded result is the closest <EM>odd</EM> integer.
600For other operations, this rounding mode acts as though the floating-point
601result is first rounded to minimum magnitude, the same as
602<CODE>softfloat_round_minMag</CODE>, and then, if the result is inexact, the
603least-significant bit of the result is set <NOBR>to 1</NOBR>.
604Rounding to odd is also known as <EM>jamming</EM>.
605</P>
606
607<H3>6.2. Underflow Detection</H3>
608
609<P>
610In the terminology of the IEEE Standard, SoftFloat can detect tininess for
611underflow either before or after rounding.
612The choice is made by the global variable
613<BLOCKQUOTE>
614<CODE>uint_fast8_t softfloat_detectTininess;</CODE>
615</BLOCKQUOTE>
616which can be set to either
617<BLOCKQUOTE>
618<CODE>softfloat_tininess_beforeRounding</CODE><BR>
619<CODE>softfloat_tininess_afterRounding</CODE>
620</BLOCKQUOTE>
621Detecting tininess after rounding is usually better because it results in fewer
622spurious underflow signals.
623The other option is provided for compatibility with some systems.
624Like most systems (and as required by the newer 2008 IEEE Standard), SoftFloat
625always detects loss of accuracy for underflow as an inexact result.
626</P>
627
628<H3>6.3. Rounding Precision for the <NOBR>80-Bit</NOBR> Extended Format</H3>
629
630<P>
631For <CODE>extFloat80_t</CODE> only, the rounding precision of the basic
632arithmetic operations is controlled by the global variable
633<BLOCKQUOTE>
634<CODE>uint_fast8_t extF80_roundingPrecision;</CODE>
635</BLOCKQUOTE>
636The operations affected are:
637<BLOCKQUOTE>
638<CODE>extF80_add</CODE><BR>
639<CODE>extF80_sub</CODE><BR>
640<CODE>extF80_mul</CODE><BR>
641<CODE>extF80_div</CODE><BR>
642<CODE>extF80_sqrt</CODE>
643</BLOCKQUOTE>
644When <CODE>extF80_roundingPrecision</CODE> is set to its default value of 80,
645these operations are rounded to the full precision of the <NOBR>80-bit</NOBR>
646double-extended-precision format, like occurs for other formats.
647Setting <CODE>extF80_roundingPrecision</CODE> to 32 or to 64 causes the
648operations listed to be rounded to <NOBR>32-bit</NOBR> precision (equivalent to
649<CODE>float32_t</CODE>) or to <NOBR>64-bit</NOBR> precision (equivalent to
650<CODE>float64_t</CODE>), respectively.
651When rounding to reduced precision, additional bits in the result significand
652beyond the rounding point are set to zero.
653The consequences of setting <CODE>extF80_roundingPrecision</CODE> to a value
654other than 32, 64, or 80 is not specified.
655Operations other than the ones listed above are not affected by
656<CODE>extF80_roundingPrecision</CODE>.
657</P>
658
659
660<H2>7. Exceptions and Exception Flags</H2>
661
662<P>
663All five exception flags required by the IEEE Floating-Point Standard are
664implemented.
665Each flag is stored as a separate bit in the global variable
666<BLOCKQUOTE>
667<CODE>uint_fast8_t softfloat_exceptionFlags;</CODE>
668</BLOCKQUOTE>
669The positions of the exception flag bits within this variable are determined by
670the bit masks
671<BLOCKQUOTE>
672<CODE>softfloat_flag_inexact</CODE><BR>
673<CODE>softfloat_flag_underflow</CODE><BR>
674<CODE>softfloat_flag_overflow</CODE><BR>
675<CODE>softfloat_flag_infinite</CODE><BR>
676<CODE>softfloat_flag_invalid</CODE>
677</BLOCKQUOTE>
678Variable <CODE>softfloat_exceptionFlags</CODE> is initialized to all zeros,
679meaning no exceptions.
680</P>
681
682<P>
683For some SoftFloat ports, <CODE>softfloat_exceptionFlags</CODE> may be
684<I>per-thread</I> (declared <CODE>thread_local</CODE>), meaning that different
685execution threads have their own separate instances of it.
686</P>
687
688<P>
689An individual exception flag can be cleared with the statement
690<BLOCKQUOTE>
691<CODE>softfloat_exceptionFlags &= ~softfloat_flag_&lt;<I>exception</I>&gt;;</CODE>
692</BLOCKQUOTE>
693where <CODE>&lt;<I>exception</I>&gt;</CODE> is the appropriate name.
694To raise a floating-point exception, function <CODE>softfloat_raiseFlags</CODE>
695should normally be used.
696</P>
697
698<P>
699When SoftFloat detects an exception other than <I>inexact</I>, it calls
700<CODE>softfloat_raiseFlags</CODE>.
701The default version of this function simply raises the corresponding exception
702flags.
703Particular ports of SoftFloat may support alternate behavior, such as exception
704traps, by modifying the default <CODE>softfloat_raiseFlags</CODE>.
705A program may also supply its own <CODE>softfloat_raiseFlags</CODE> function to
706override the one from the SoftFloat library.
707</P>
708
709<P>
710Because inexact results occur frequently under most circumstances (and thus are
711hardly exceptional), SoftFloat does not ordinarily call
712<CODE>softfloat_raiseFlags</CODE> for <I>inexact</I> exceptions.
713It does always raise the <I>inexact</I> exception flag as required.
714</P>
715
716
717<H2>8. Function Details</H2>
718
719<P>
720In this section, <CODE>&lt;<I>float</I>&gt;</CODE> appears in function names as
721a substitute for one of these abbreviations:
722<BLOCKQUOTE>
723<TABLE CELLSPACING=0 CELLPADDING=0>
724<TR>
725<TD><CODE>f16</CODE></TD>
726<TD>indicates <CODE>float16_t</CODE>, passed by value</TD>
727</TR>
728<TR>
729<TD><CODE>f32</CODE></TD>
730<TD>indicates <CODE>float32_t</CODE>, passed by value</TD>
731</TR>
732<TR>
733<TD><CODE>f64</CODE></TD>
734<TD>indicates <CODE>float64_t</CODE>, passed by value</TD>
735</TR>
736<TR>
737<TD><CODE>extF80M&nbsp;&nbsp;&nbsp;</CODE></TD>
738<TD>indicates <CODE>extFloat80_t</CODE>, passed indirectly via pointers</TD>
739</TR>
740<TR>
741<TD><CODE>extF80</CODE></TD>
742<TD>indicates <CODE>extFloat80_t</CODE>, passed by value</TD>
743</TR>
744<TR>
745<TD><CODE>f128M</CODE></TD>
746<TD>indicates <CODE>float128_t</CODE>, passed indirectly via pointers</TD>
747</TR>
748<TR>
749<TD><CODE>f128</CODE></TD>
750<TD>indicates <CODE>float128_t</CODE>, passed by value</TD>
751</TR>
752</TABLE>
753</BLOCKQUOTE>
754The circumstances under which values of floating-point types
755<CODE>extFloat80_t</CODE> and <CODE>float128_t</CODE> may be passed either by
756value or indirectly via pointers was discussed earlier in
757<NOBR>section 4.5</NOBR>, <I>Conventions for Passing Arguments and Results</I>.
758</P>
759
760<H3>8.1. Conversions from Integer to Floating-Point</H3>
761
762<P>
763All conversions from a <NOBR>32-bit</NOBR> or <NOBR>64-bit</NOBR> integer,
764signed or unsigned, to a floating-point format are supported.
765Functions performing these conversions have these names:
766<BLOCKQUOTE>
767<CODE>ui32_to_&lt;<I>float</I>&gt;</CODE><BR>
768<CODE>ui64_to_&lt;<I>float</I>&gt;</CODE><BR>
769<CODE>i32_to_&lt;<I>float</I>&gt;</CODE><BR>
770<CODE>i64_to_&lt;<I>float</I>&gt;</CODE>
771</BLOCKQUOTE>
772Conversions from <NOBR>32-bit</NOBR> integers to <NOBR>64-bit</NOBR>
773double-precision and larger formats are always exact, and likewise conversions
774from <NOBR>64-bit</NOBR> integers to <NOBR>80-bit</NOBR>
775double-extended-precision and <NOBR>128-bit</NOBR> quadruple-precision are also
776always exact.
777</P>
778
779<P>
780Each conversion function takes one input of the appropriate type and generates
781one output.
782The following illustrates the signatures of these functions in cases when the
783floating-point result is passed either by value or via pointers:
784<BLOCKQUOTE>
785<PRE>
786float64_t i32_to_f64( int32_t <I>a</I> );
787</PRE>
788<PRE>
789void i32_to_f128M( int32_t <I>a</I>, float128_t *<I>destPtr</I> );
790</PRE>
791</BLOCKQUOTE>
792</P>
793
794<H3>8.2. Conversions from Floating-Point to Integer</H3>
795
796<P>
797Conversions from a floating-point format to a <NOBR>32-bit</NOBR> or
798<NOBR>64-bit</NOBR> integer, signed or unsigned, are supported with these
799functions:
800<BLOCKQUOTE>
801<CODE>&lt;<I>float</I>&gt;_to_ui32</CODE><BR>
802<CODE>&lt;<I>float</I>&gt;_to_ui64</CODE><BR>
803<CODE>&lt;<I>float</I>&gt;_to_i32</CODE><BR>
804<CODE>&lt;<I>float</I>&gt;_to_i64</CODE>
805</BLOCKQUOTE>
806The functions have signatures as follows, depending on whether the
807floating-point input is passed by value or via pointers:
808<BLOCKQUOTE>
809<PRE>
810int_fast32_t f64_to_i32( float64_t <I>a</I>, uint_fast8_t <I>roundingMode</I>, bool <I>exact</I> );
811</PRE>
812<PRE>
813int_fast32_t
814 f128M_to_i32( const float128_t *<I>aPtr</I>, uint_fast8_t <I>roundingMode</I>, bool <I>exact</I> );
815</PRE>
816</BLOCKQUOTE>
817</P>
818
819<P>
820The <CODE><I>roundingMode</I></CODE> argument specifies the rounding mode for
821the conversion.
822The variable that usually indicates rounding mode,
823<CODE>softfloat_roundingMode</CODE>, is ignored.
824Argument <CODE><I>exact</I></CODE> determines whether the <I>inexact</I>
825exception flag is raised if the conversion is not exact.
826If <CODE><I>exact</I></CODE> is <CODE>true</CODE>, the <I>inexact</I> flag may
827be raised;
828otherwise, it will not be, even if the conversion is inexact.
829</P>
830
831<P>
832A conversion from floating-point to integer format raises the <I>invalid</I>
833exception if the source value cannot be rounded to a representable integer of
834the desired size (32 or 64 bits).
835In such circumstances, the integer result returned is determined by the
836particular port of SoftFloat, although typically this value will be either the
837maximum or minimum value of the integer format.
838The functions that convert to integer types never raise the floating-point
839<I>overflow</I> exception.
840</P>
841
842<P>
843Because languages such <NOBR>as C</NOBR> require that conversions to integers
844be rounded toward zero, the following functions are provided for improved speed
845and convenience:
846<BLOCKQUOTE>
847<CODE>&lt;<I>float</I>&gt;_to_ui32_r_minMag</CODE><BR>
848<CODE>&lt;<I>float</I>&gt;_to_ui64_r_minMag</CODE><BR>
849<CODE>&lt;<I>float</I>&gt;_to_i32_r_minMag</CODE><BR>
850<CODE>&lt;<I>float</I>&gt;_to_i64_r_minMag</CODE>
851</BLOCKQUOTE>
852These functions round only toward zero (to minimum magnitude).
853The signatures for these functions are the same as above without the redundant
854<CODE><I>roundingMode</I></CODE> argument:
855<BLOCKQUOTE>
856<PRE>
857int_fast32_t f64_to_i32_r_minMag( float64_t <I>a</I>, bool <I>exact</I> );
858</PRE>
859<PRE>
860int_fast32_t f128M_to_i32_r_minMag( const float128_t *<I>aPtr</I>, bool <I>exact</I> );
861</PRE>
862</BLOCKQUOTE>
863</P>
864
865<H3>8.3. Conversions Among Floating-Point Types</H3>
866
867<P>
868Conversions between floating-point formats are done by functions with these
869names:
870<BLOCKQUOTE>
871<CODE>&lt;<I>float</I>&gt;_to_&lt;<I>float</I>&gt;</CODE>
872</BLOCKQUOTE>
873All combinations of source and result type are supported where the source and
874result are different formats.
875There are four different styles of signature for these functions, depending on
876whether the input and the output floating-point values are passed by value or
877via pointers:
878<BLOCKQUOTE>
879<PRE>
880float32_t f64_to_f32( float64_t <I>a</I> );
881</PRE>
882<PRE>
883float32_t f128M_to_f32( const float128_t *<I>aPtr</I> );
884</PRE>
885<PRE>
886void f32_to_f128M( float32_t <I>a</I>, float128_t *<I>destPtr</I> );
887</PRE>
888<PRE>
889void extF80M_to_f128M( const extFloat80_t *<I>aPtr</I>, float128_t *<I>destPtr</I> );
890</PRE>
891</BLOCKQUOTE>
892</P>
893
894<P>
895Conversions from a smaller to a larger floating-point format are always exact
896and so require no rounding.
897</P>
898
899<H3>8.4. Basic Arithmetic Functions</H3>
900
901<P>
902The following basic arithmetic functions are provided:
903<BLOCKQUOTE>
904<CODE>&lt;<I>float</I>&gt;_add</CODE><BR>
905<CODE>&lt;<I>float</I>&gt;_sub</CODE><BR>
906<CODE>&lt;<I>float</I>&gt;_mul</CODE><BR>
907<CODE>&lt;<I>float</I>&gt;_div</CODE><BR>
908<CODE>&lt;<I>float</I>&gt;_sqrt</CODE>
909</BLOCKQUOTE>
910Each floating-point operation takes two operands, except for <CODE>sqrt</CODE>
911(square root) which takes only one.
912The operands and result are all of the same floating-point format.
913Signatures for these functions take the following forms:
914<BLOCKQUOTE>
915<PRE>
916float64_t f64_add( float64_t <I>a</I>, float64_t <I>b</I> );
917</PRE>
918<PRE>
919void
920 f128M_add(
921 const float128_t *<I>aPtr</I>, const float128_t *<I>bPtr</I>, float128_t *<I>destPtr</I> );
922</PRE>
923<PRE>
924float64_t f64_sqrt( float64_t <I>a</I> );
925</PRE>
926<PRE>
927void f128M_sqrt( const float128_t *<I>aPtr</I>, float128_t *<I>destPtr</I> );
928</PRE>
929</BLOCKQUOTE>
930When floating-point values are passed indirectly through pointers, arguments
931<CODE><I>aPtr</I></CODE> and <CODE><I>bPtr</I></CODE> point to the input
932operands, and the last argument, <CODE><I>destPtr</I></CODE>, points to the
933location where the result is stored.
934</P>
935
936<P>
937Rounding of the <NOBR>80-bit</NOBR> double-extended-precision
938(<CODE>extFloat80_t</CODE>) functions is affected by variable
939<CODE>extF80_roundingPrecision</CODE>, as explained earlier in
940<NOBR>section 6.3</NOBR>,
941<I>Rounding Precision for the <NOBR>80-Bit</NOBR> Extended Format</I>.
942</P>
943
944<H3>8.5. Fused Multiply-Add Functions</H3>
945
946<P>
947The 2008 version of the IEEE Floating-Point Standard defines a <I>fused
948multiply-add</I> operation that does a combined multiplication and addition
949with only a single rounding.
950SoftFloat implements fused multiply-add with functions
951<BLOCKQUOTE>
952<CODE>&lt;<I>float</I>&gt;_mulAdd</CODE>
953</BLOCKQUOTE>
954Unlike other operations, fused multiple-add is not supported for the
955<NOBR>80-bit</NOBR> double-extended-precision format,
956<CODE>extFloat80_t</CODE>.
957</P>
958
959<P>
960Depending on whether floating-point values are passed by value or via pointers,
961the fused multiply-add functions have signatures of these forms:
962<BLOCKQUOTE>
963<PRE>
964float64_t f64_mulAdd( float64_t <I>a</I>, float64_t <I>b</I>, float64_t <I>c</I> );
965</PRE>
966<PRE>
967void
968 f128M_mulAdd(
969 const float128_t *<I>aPtr</I>,
970 const float128_t *<I>bPtr</I>,
971 const float128_t *<I>cPtr</I>,
972 float128_t *<I>destPtr</I>
973 );
974</PRE>
975</BLOCKQUOTE>
976The functions compute
977<NOBR>(<CODE><I>a</I></CODE> &times; <CODE><I>b</I></CODE>)
978 + <CODE><I>c</I></CODE></NOBR>
979with a single rounding.
980When floating-point values are passed indirectly through pointers, arguments
981<CODE><I>aPtr</I></CODE>, <CODE><I>bPtr</I></CODE>, and
982<CODE><I>cPtr</I></CODE> point to operands <CODE><I>a</I></CODE>,
983<CODE><I>b</I></CODE>, and <CODE><I>c</I></CODE> respectively, and
984<CODE><I>destPtr</I></CODE> points to the location where the result is stored.
985</P>
986
987<P>
988If one of the multiplication operands <CODE><I>a</I></CODE> and
989<CODE><I>b</I></CODE> is infinite and the other is zero, these functions raise
990the invalid exception even if operand <CODE><I>c</I></CODE> is a quiet NaN.
991</P>
992
993<H3>8.6. Remainder Functions</H3>
994
995<P>
996For each format, SoftFloat implements the remainder operation defined by the
997IEEE Floating-Point Standard.
998The remainder functions have names
999<BLOCKQUOTE>
1000<CODE>&lt;<I>float</I>&gt;_rem</CODE>
1001</BLOCKQUOTE>
1002Each remainder operation takes two floating-point operands of the same format
1003and returns a result in the same format.
1004Depending on whether floating-point values are passed by value or via pointers,
1005the remainder functions have signatures of these forms:
1006<BLOCKQUOTE>
1007<PRE>
1008float64_t f64_rem( float64_t <I>a</I>, float64_t <I>b</I> );
1009</PRE>
1010<PRE>
1011void
1012 f128M_rem(
1013 const float128_t *<I>aPtr</I>, const float128_t *<I>bPtr</I>, float128_t *<I>destPtr</I> );
1014</PRE>
1015</BLOCKQUOTE>
1016When floating-point values are passed indirectly through pointers, arguments
1017<CODE><I>aPtr</I></CODE> and <CODE><I>bPtr</I></CODE> point to operands
1018<CODE><I>a</I></CODE> and <CODE><I>b</I></CODE> respectively, and
1019<CODE><I>destPtr</I></CODE> points to the location where the result is stored.
1020</P>
1021
1022<P>
1023The IEEE Standard remainder operation computes the value
1024<NOBR><CODE><I>a</I></CODE>
1025 &minus; <I>n</I> &times; <CODE><I>b</I></CODE></NOBR>,
1026where <I>n</I> is the integer closest to
1027<NOBR><CODE><I>a</I></CODE> &divide; <CODE><I>b</I></CODE></NOBR>.
1028If <NOBR><CODE><I>a</I></CODE> &divide; <CODE><I>b</I></CODE></NOBR> is exactly
1029halfway between two integers, <I>n</I> is the <EM>even</EM> integer closest to
1030<NOBR><CODE><I>a</I></CODE> &divide; <CODE><I>b</I></CODE></NOBR>.
1031The IEEE Standard&rsquo;s remainder operation is always exact and so requires
1032no rounding.
1033</P>
1034
1035<P>
1036Depending on the relative magnitudes of the operands, the remainder
1037functions can take considerably longer to execute than the other SoftFloat
1038functions.
1039This is an inherent characteristic of the remainder operation itself and is not
1040a flaw in the SoftFloat implementation.
1041</P>
1042
1043<H3>8.7. Round-to-Integer Functions</H3>
1044
1045<P>
1046For each format, SoftFloat implements the round-to-integer operation specified
1047by the IEEE Floating-Point Standard.
1048These functions are named
1049<BLOCKQUOTE>
1050<CODE>&lt;<I>float</I>&gt;_roundToInt</CODE>
1051</BLOCKQUOTE>
1052Each round-to-integer operation takes a single floating-point operand.
1053This operand is rounded to an integer according to a specified rounding mode,
1054and the resulting integer value is returned in the same floating-point format.
1055(Note that the result is not an integer type.)
1056</P>
1057
1058<P>
1059The signatures of the round-to-integer functions are similar to those for
1060conversions to an integer type:
1061<BLOCKQUOTE>
1062<PRE>
1063float64_t f64_roundToInt( float64_t <I>a</I>, uint_fast8_t <I>roundingMode</I>, bool <I>exact</I> );
1064</PRE>
1065<PRE>
1066void
1067 f128M_roundToInt(
1068 const float128_t *<I>aPtr</I>,
1069 uint_fast8_t <I>roundingMode</I>,
1070 bool <I>exact</I>,
1071 float128_t *<I>destPtr</I>
1072 );
1073</PRE>
1074</BLOCKQUOTE>
1075When floating-point values are passed indirectly through pointers,
1076<CODE><I>aPtr</I></CODE> points to the input operand and
1077<CODE><I>destPtr</I></CODE> points to the location where the result is stored.
1078</P>
1079
1080<P>
1081The <CODE><I>roundingMode</I></CODE> argument specifies the rounding mode to
1082apply.
1083The variable that usually indicates rounding mode,
1084<CODE>softfloat_roundingMode</CODE>, is ignored.
1085Argument <CODE><I>exact</I></CODE> determines whether the <I>inexact</I>
1086exception flag is raised if the conversion is not exact.
1087If <CODE><I>exact</I></CODE> is <CODE>true</CODE>, the <I>inexact</I> flag may
1088be raised;
1089otherwise, it will not be, even if the conversion is inexact.
1090</P>
1091
1092<H3>8.8. Comparison Functions</H3>
1093
1094<P>
1095For each format, the following floating-point comparison functions are
1096provided:
1097<BLOCKQUOTE>
1098<CODE>&lt;<I>float</I>&gt;_eq</CODE><BR>
1099<CODE>&lt;<I>float</I>&gt;_le</CODE><BR>
1100<CODE>&lt;<I>float</I>&gt;_lt</CODE>
1101</BLOCKQUOTE>
1102Each comparison takes two operands of the same type and returns a Boolean.
1103The abbreviation <CODE>eq</CODE> stands for &ldquo;equal&rdquo; (=);
1104<CODE>le</CODE> stands for &ldquo;less than or equal&rdquo; (&le;);
1105and <CODE>lt</CODE> stands for &ldquo;less than&rdquo; (&lt;).
1106Depending on whether the floating-point operands are passed by value or via
1107pointers, the comparison functions have signatures of these forms:
1108<BLOCKQUOTE>
1109<PRE>
1110bool f64_eq( float64_t <I>a</I>, float64_t <I>b</I> );
1111</PRE>
1112<PRE>
1113bool f128M_eq( const float128_t *<I>aPtr</I>, const float128_t *<I>bPtr</I> );
1114</PRE>
1115</BLOCKQUOTE>
1116</P>
1117
1118<P>
1119The usual greater-than (&gt;), greater-than-or-equal (&ge;), and not-equal
1120(&ne;) comparisons are easily obtained from the functions provided.
1121The not-equal function is just the logical complement of the equal function.
1122The greater-than-or-equal function is identical to the less-than-or-equal
1123function with the arguments in reverse order, and likewise the greater-than
1124function is identical to the less-than function with the arguments reversed.
1125</P>
1126
1127<P>
1128The IEEE Floating-Point Standard specifies that the less-than-or-equal and
1129less-than comparisons by default raise the <I>invalid</I> exception if either
1130operand is any kind of NaN.
1131Equality comparisons, on the other hand, are defined by default to raise the
1132<I>invalid</I> exception only for signaling NaNs, not quiet NaNs.
1133For completeness, SoftFloat provides these complementary functions:
1134<BLOCKQUOTE>
1135<CODE>&lt;<I>float</I>&gt;_eq_signaling</CODE><BR>
1136<CODE>&lt;<I>float</I>&gt;_le_quiet</CODE><BR>
1137<CODE>&lt;<I>float</I>&gt;_lt_quiet</CODE>
1138</BLOCKQUOTE>
1139The <CODE>signaling</CODE> equality comparisons are identical to the default
1140equality comparisons except that the <I>invalid</I> exception is raised for any
1141NaN input, not just for signaling NaNs.
1142Similarly, the <CODE>quiet</CODE> comparison functions are identical to their
1143default counterparts except that the <I>invalid</I> exception is not raised for
1144quiet NaNs.
1145</P>
1146
1147<H3>8.9. Signaling NaN Test Functions</H3>
1148
1149<P>
1150Functions for testing whether a floating-point value is a signaling NaN are
1151provided with these names:
1152<BLOCKQUOTE>
1153<CODE>&lt;<I>float</I>&gt;_isSignalingNaN</CODE>
1154</BLOCKQUOTE>
1155The functions take one floating-point operand and return a Boolean indicating
1156whether the operand is a signaling NaN.
1157Accordingly, the functions have the forms
1158<BLOCKQUOTE>
1159<PRE>
1160bool f64_isSignalingNaN( float64_t <I>a</I> );
1161</PRE>
1162<PRE>
1163bool f128M_isSignalingNaN( const float128_t *<I>aPtr</I> );
1164</PRE>
1165</BLOCKQUOTE>
1166</P>
1167
1168<H3>8.10. Raise-Exception Function</H3>
1169
1170<P>
1171SoftFloat provides a single function for raising floating-point exceptions:
1172<BLOCKQUOTE>
1173<PRE>
1174void softfloat_raiseFlags( uint_fast8_t <I>exceptions</I> );
1175</PRE>
1176</BLOCKQUOTE>
1177The <CODE><I>exceptions</I></CODE> argument is a mask indicating the set of
1178exceptions to raise.
1179(See earlier section 7, <I>Exceptions and Exception Flags</I>.)
1180In addition to setting the specified exception flags in variable
1181<CODE>softfloat_exceptionFlags</CODE>, the <CODE>softfloat_raiseFlags</CODE>
1182function may cause a trap or abort appropriate for the current system.
1183</P>
1184
1185
1186<H2>9. Changes from SoftFloat <NOBR>Release 2</NOBR></H2>
1187
1188<P>
1189Apart from a change in the legal use license, <NOBR>Release 3</NOBR> of
1190SoftFloat introduced numerous technical differences compared to earlier
1191releases.
1192</P>
1193
1194<H3>9.1. Name Changes</H3>
1195
1196<P>
1197The most obvious and pervasive difference compared to <NOBR>Release 2</NOBR>
1198is that the names of most functions and variables have changed, even when the
1199behavior has not.
1200First, the floating-point types, the mode variables, the exception flags
1201variable, the function to raise exceptions, and various associated constants
1202have been renamed as follows:
1203<BLOCKQUOTE>
1204<TABLE>
1205<TR>
1206<TD>old name, Release 2:</TD>
1207<TD>new name, Release 3:</TD>
1208</TR>
1209<TR>
1210<TD><CODE>float32</CODE></TD>
1211<TD><CODE>float32_t</CODE></TD>
1212</TR>
1213<TR>
1214<TD><CODE>float64</CODE></TD>
1215<TD><CODE>float64_t</CODE></TD>
1216</TR>
1217<TR>
1218<TD><CODE>floatx80</CODE></TD>
1219<TD><CODE>extFloat80_t</CODE></TD>
1220</TR>
1221<TR>
1222<TD><CODE>float128</CODE></TD>
1223<TD><CODE>float128_t</CODE></TD>
1224</TR>
1225<TR>
1226<TD><CODE>float_rounding_mode</CODE></TD>
1227<TD><CODE>softfloat_roundingMode</CODE></TD>
1228</TR>
1229<TR>
1230<TD><CODE>float_round_nearest_even</CODE></TD>
1231<TD><CODE>softfloat_round_near_even</CODE></TD>
1232</TR>
1233<TR>
1234<TD><CODE>float_round_to_zero</CODE></TD>
1235<TD><CODE>softfloat_round_minMag</CODE></TD>
1236</TR>
1237<TR>
1238<TD><CODE>float_round_down</CODE></TD>
1239<TD><CODE>softfloat_round_min</CODE></TD>
1240</TR>
1241<TR>
1242<TD><CODE>float_round_up</CODE></TD>
1243<TD><CODE>softfloat_round_max</CODE></TD>
1244</TR>
1245<TR>
1246<TD><CODE>float_detect_tininess</CODE></TD>
1247<TD><CODE>softfloat_detectTininess</CODE></TD>
1248</TR>
1249<TR>
1250<TD><CODE>float_tininess_before_rounding&nbsp;&nbsp;&nbsp;&nbsp;</CODE></TD>
1251<TD><CODE>softfloat_tininess_beforeRounding</CODE></TD>
1252</TR>
1253<TR>
1254<TD><CODE>float_tininess_after_rounding</CODE></TD>
1255<TD><CODE>softfloat_tininess_afterRounding</CODE></TD>
1256</TR>
1257<TR>
1258<TD><CODE>floatx80_rounding_precision</CODE></TD>
1259<TD><CODE>extF80_roundingPrecision</CODE></TD>
1260</TR>
1261<TR>
1262<TD><CODE>float_exception_flags</CODE></TD>
1263<TD><CODE>softfloat_exceptionFlags</CODE></TD>
1264</TR>
1265<TR>
1266<TD><CODE>float_flag_inexact</CODE></TD>
1267<TD><CODE>softfloat_flag_inexact</CODE></TD>
1268</TR>
1269<TR>
1270<TD><CODE>float_flag_underflow</CODE></TD>
1271<TD><CODE>softfloat_flag_underflow</CODE></TD>
1272</TR>
1273<TR>
1274<TD><CODE>float_flag_overflow</CODE></TD>
1275<TD><CODE>softfloat_flag_overflow</CODE></TD>
1276</TR>
1277<TR>
1278<TD><CODE>float_flag_divbyzero</CODE></TD>
1279<TD><CODE>softfloat_flag_infinite</CODE></TD>
1280</TR>
1281<TR>
1282<TD><CODE>float_flag_invalid</CODE></TD>
1283<TD><CODE>softfloat_flag_invalid</CODE></TD>
1284</TR>
1285<TR>
1286<TD><CODE>float_raise</CODE></TD>
1287<TD><CODE>softfloat_raiseFlags</CODE></TD>
1288</TR>
1289</TABLE>
1290</BLOCKQUOTE>
1291</P>
1292
1293<P>
1294Furthermore, <NOBR>Release 3</NOBR> adopted the following new abbreviations for
1295function names:
1296<BLOCKQUOTE>
1297<TABLE>
1298<TR>
1299<TD>used in names in Release 2:<CODE>&nbsp;&nbsp;&nbsp;&nbsp;</CODE></TD>
1300<TD>used in names in Release 3:</TD>
1301</TR>
1302<TR> <TD><CODE>int32</CODE></TD> <TD><CODE>i32</CODE></TD> </TR>
1303<TR> <TD><CODE>int64</CODE></TD> <TD><CODE>i64</CODE></TD> </TR>
1304<TR> <TD><CODE>float32</CODE></TD> <TD><CODE>f32</CODE></TD> </TR>
1305<TR> <TD><CODE>float64</CODE></TD> <TD><CODE>f64</CODE></TD> </TR>
1306<TR> <TD><CODE>floatx80</CODE></TD> <TD><CODE>extF80</CODE></TD> </TR>
1307<TR> <TD><CODE>float128</CODE></TD> <TD><CODE>f128</CODE></TD> </TR>
1308</TABLE>
1309</BLOCKQUOTE>
1310Thus, for example, the function to add two <NOBR>32-bit</NOBR> floating-point
1311numbers, previously called <CODE>float32_add</CODE> in <NOBR>Release 2</NOBR>,
1312is now <CODE>f32_add</CODE>.
1313Lastly, there have been a few other changes to function names:
1314<BLOCKQUOTE>
1315<TABLE>
1316<TR>
1317<TD>used in names in Release 2:<CODE>&nbsp;&nbsp;&nbsp;</CODE></TD>
1318<TD>used in names in Release 3:<CODE>&nbsp;&nbsp;&nbsp;</CODE></TD>
1319<TD>relevant functions:</TD>
1320</TR>
1321<TR>
1322<TD><CODE>_round_to_zero</CODE></TD>
1323<TD><CODE>_r_minMag</CODE></TD>
1324<TD>conversions from floating-point to integer (<NOBR>section 8.2</NOBR>)</TD>
1325</TR>
1326<TR>
1327<TD><CODE>round_to_int</CODE></TD>
1328<TD><CODE>roundToInt</CODE></TD>
1329<TD>round-to-integer functions (<NOBR>section 8.7</NOBR>)</TD>
1330</TR>
1331<TR>
1332<TD><CODE>is_signaling_nan&nbsp;&nbsp;&nbsp;&nbsp;</CODE></TD>
1333<TD><CODE>isSignalingNaN</CODE></TD>
1334<TD>signaling NaN test functions (<NOBR>section 8.9</NOBR>)</TD>
1335</TR>
1336</TABLE>
1337</BLOCKQUOTE>
1338</P>
1339
1340<H3>9.2. Changes to Function Arguments</H3>
1341
1342<P>
1343Besides simple name changes, some operations were given a different interface
1344in <NOBR>Release 3</NOBR> than they had in <NOBR>Release 2</NOBR>:
1345<UL>
1346
1347<LI>
1348<P>
1349Since <NOBR>Release 3</NOBR>, integer arguments and results of functions have
1350standard types from header <CODE>&lt;stdint.h&gt;</CODE>, such as
1351<CODE>uint32_t</CODE>, whereas previously their types could be defined
1352differently for each port of SoftFloat, usually using traditional C types such
1353as <CODE>unsigned</CODE> <CODE>int</CODE>.
1354Likewise, functions in <NOBR>Release 3</NOBR> and later pass Booleans as
1355standard type <CODE>bool</CODE> from <CODE>&lt;stdbool.h&gt;</CODE>, whereas
1356previously these were again passed as a port-specific type (usually
1357<CODE>int</CODE>).
1358</P>
1359
1360<LI>
1361<P>
1362As explained earlier in <NOBR>section 4.5</NOBR>, <I>Conventions for Passing
1363Arguments and Results</I>, SoftFloat functions in <NOBR>Release 3</NOBR> and
1364later may pass <NOBR>80-bit</NOBR> and <NOBR>128-bit</NOBR> floating-point
1365values through pointers, meaning that functions take pointer arguments and then
1366read or write floating-point values at the locations indicated by the pointers.
1367In <NOBR>Release 2</NOBR>, floating-point arguments and results were always
1368passed by value, regardless of their size.
1369</P>
1370
1371<LI>
1372<P>
1373Functions that round to an integer have additional
1374<CODE><I>roundingMode</I></CODE> and <CODE><I>exact</I></CODE> arguments that
1375they did not have in <NOBR>Release 2</NOBR>.
1376Refer to sections 8.2 <NOBR>and 8.7</NOBR> for descriptions of these functions
1377since <NOBR>Release 3</NOBR>.
1378For <NOBR>Release 2</NOBR>, the rounding mode, when needed, was taken from the
1379same global variable that affects the basic arithmetic operations (now called
1380<CODE>softfloat_roundingMode</CODE> but previously known as
1381<CODE>float_rounding_mode</CODE>).
1382Also, for <NOBR>Release 2</NOBR>, if the original floating-point input was not
1383an exact integer value, and if the <I>invalid</I> exception was not raised by
1384the function, the <I>inexact</I> exception was always raised.
1385<NOBR>Release 2</NOBR> had no option to suppress raising <I>inexact</I> in this
1386case.
1387Applications using SoftFloat <NOBR>Release 3</NOBR> or later can get the same
1388effect as <NOBR>Release 2</NOBR> by passing variable
1389<CODE>softfloat_roundingMode</CODE> for argument
1390<CODE><I>roundingMode</I></CODE> and <CODE>true</CODE> for argument
1391<CODE><I>exact</I></CODE>.
1392</P>
1393
1394</UL>
1395</P>
1396
1397<H3>9.3. Added Capabilities</H3>
1398
1399<P>
1400With <NOBR>Release 3</NOBR>, some new features have been added that were not
1401present in <NOBR>Release 2</NOBR>:
1402<UL>
1403
1404<LI>
1405<P>
1406A port of SoftFloat can now define any of the floating-point types
1407<CODE>float32_t</CODE>, <CODE>float64_t</CODE>, <CODE>extFloat80_t</CODE>, and
1408<CODE>float128_t</CODE> as aliases for C&rsquo;s standard floating-point types
1409<CODE>float</CODE>, <CODE>double</CODE>, and <CODE>long</CODE>
1410<CODE>double</CODE>, using either <CODE>#define</CODE> or <CODE>typedef</CODE>.
1411This potential convenience was not supported under <NOBR>Release 2</NOBR>.
1412</P>
1413
1414<P>
1415(Note, however, that there may be a performance cost to defining
1416SoftFloat&rsquo;s floating-point types this way, depending on the platform and
1417the applications using SoftFloat.
1418Ports of SoftFloat may choose to forgo the convenience in favor of better
1419speed.)
1420</P>
1421
1422<P>
1423<LI>
1424As of <NOBR>Release 3b</NOBR>, <NOBR>16-bit</NOBR> half-precision,
1425<CODE>float16_t</CODE>, is supported.
1426</P>
1427
1428<P>
1429<LI>
1430Functions have been added for converting between the floating-point types and
1431unsigned integers.
1432<NOBR>Release 2</NOBR> supported only signed integers, not unsigned.
1433</P>
1434
1435<P>
1436<LI>
1437Fused multiply-add functions have been added for all floating-point formats
1438except <NOBR>80-bit</NOBR> double-extended-precision,
1439<CODE>extFloat80_t</CODE>.
1440</P>
1441
1442<P>
1443<LI>
1444New rounding modes are supported:
1445<CODE>softfloat_round_near_maxMag</CODE> (round to nearest, with ties to
1446maximum magnitude, away from zero), and, as of <NOBR>Release 3c</NOBR>,
1447optional <CODE>softfloat_round_odd</CODE> (round to odd, also known as
1448jamming).
1449</P>
1450
1451</UL>
1452</P>
1453
1454<H3>9.4. Better Compatibility with the C Language</H3>
1455
1456<P>
1457<NOBR>Release 3</NOBR> of SoftFloat was written to conform better to the ISO C
1458Standard&rsquo;s rules for portability.
1459For example, older releases of SoftFloat employed type conversions in ways
1460that, while commonly practiced, are not fully defined by the C Standard.
1461Such problematic type conversions have generally been replaced by the use of
1462unions, the behavior around which is more strictly regulated these days.
1463</P>
1464
1465<H3>9.5. New Organization as a Library</H3>
1466
1467<P>
1468Starting with <NOBR>Release 3</NOBR>, SoftFloat now builds as a library.
1469Previously, SoftFloat compiled into a single, monolithic object file containing
1470all the SoftFloat functions, with the consequence that a program linking with
1471SoftFloat would get every SoftFloat function in its binary file even if only a
1472few functions were actually used.
1473With SoftFloat in the form of a library, a program that is linked by a standard
1474linker will include only those functions of SoftFloat that it needs and no
1475others.
1476</P>
1477
1478<H3>9.6. Optimization Gains (and Losses)</H3>
1479
1480<P>
1481Individual SoftFloat functions have been variously improved in
1482<NOBR>Release 3</NOBR> compared to earlier releases.
1483In particular, better, faster algorithms have been deployed for the operations
1484of division, square root, and remainder.
1485For functions operating on the larger <NOBR>80-bit</NOBR> and
1486<NOBR>128-bit</NOBR> formats, <CODE>extFloat80_t</CODE> and
1487<CODE>float128_t</CODE>, code size has also generally been reduced.
1488</P>
1489
1490<P>
1491However, because <NOBR>Release 2</NOBR> compiled all of SoftFloat together as a
1492single object file, compilers could make optimizations across function calls
1493when one SoftFloat function calls another.
1494Now that the functions of SoftFloat are compiled separately and only afterward
1495linked together into a program, there is not usually the same opportunity to
1496optimize across function calls.
1497Some loss of speed has been observed due to this change.
1498</P>
1499
1500
1501<H2>10. Future Directions</H2>
1502
1503<P>
1504The following improvements are anticipated for future releases of SoftFloat:
1505<UL>
1506<LI>
1507more functions from the 2008 version of the IEEE Floating-Point Standard;
1508<LI>
1509consistent, defined behavior for non-canonical representations of extended
1510format <CODE>extFloat80_t</CODE> (discussed in <NOBR>section 4.4</NOBR>,
1511<I>Non-canonical Representations in <CODE>extFloat80_t</CODE></I>).
1512
1513</UL>
1514</P>
1515
1516
1517<H2>11. Contact Information</H2>
1518
1519<P>
1520At the time of this writing, the most up-to-date information about SoftFloat
1521and the latest release can be found at the Web page
1522<A HREF="http://www.jhauser.us/arithmetic/SoftFloat.html"><NOBR><CODE>http://www.jhauser.us/arithmetic/SoftFloat.html</CODE></NOBR></A>.
1523</P>
1524
1525
1526</BODY>
1527
deps/SoftFloat-3e/source/8086-SSE/extF80M_isSignalingNaN.c created+57
......@@ -0,0 +1,57 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43*----------------------------------------------------------------------------*/
44bool extF80M_isSignalingNaN( const extFloat80_t *aPtr )
45{
46 const struct extFloat80M *aSPtr;
47 uint64_t uiA0;
48
49 aSPtr = (const struct extFloat80M *) aPtr;
50 if ( (aSPtr->signExp & 0x7FFF) != 0x7FFF ) return false;
51 uiA0 = aSPtr->signif;
52 return
53 ! (uiA0 & UINT64_C( 0x4000000000000000 ))
54 && (uiA0 & UINT64_C( 0x3FFFFFFFFFFFFFFF));
55
56}
57
deps/SoftFloat-3e/source/8086-SSE/f128M_isSignalingNaN.c created+60
......@@ -0,0 +1,60 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "primitives.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44*----------------------------------------------------------------------------*/
45bool f128M_isSignalingNaN( const float128_t *aPtr )
46{
47 const uint32_t *aWPtr;
48 uint32_t uiA96;
49
50 aWPtr = (const uint32_t *) aPtr;
51 uiA96 = aWPtr[indexWordHi( 4 )];
52 if ( (uiA96 & 0x7FFF8000) != 0x7FFF0000 ) return false;
53 return
54 ((uiA96 & 0x00007FFF) != 0)
55 || ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
56 | aWPtr[indexWord( 4, 0 )])
57 != 0);
58
59}
60
deps/SoftFloat-3e/source/8086-SSE/s_commonNaNToExtF80M.c created+56
......@@ -0,0 +1,56 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by `aPtr' into an 80-bit extended
44| floating-point NaN, and stores this NaN at the location pointed to by
45| `zSPtr'.
46*----------------------------------------------------------------------------*/
47void
48 softfloat_commonNaNToExtF80M(
49 const struct commonNaN *aPtr, struct extFloat80M *zSPtr )
50{
51
52 zSPtr->signExp = packToExtF80UI64( aPtr->sign, 0x7FFF );
53 zSPtr->signif = UINT64_C( 0xC000000000000000 ) | aPtr->v64>>1;
54
55}
56
deps/SoftFloat-3e/source/8086-SSE/s_commonNaNToExtF80UI.c created+56
......@@ -0,0 +1,56 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by `aPtr' into an 80-bit extended
44| floating-point NaN, and returns the bit pattern of this value as an unsigned
45| integer.
46*----------------------------------------------------------------------------*/
47struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr )
48{
49 struct uint128 uiZ;
50
51 uiZ.v64 = (uint_fast16_t) aPtr->sign<<15 | 0x7FFF;
52 uiZ.v0 = UINT64_C( 0xC000000000000000 ) | aPtr->v64>>1;
53 return uiZ;
54
55}
56
deps/SoftFloat-3e/source/8086-SSE/s_commonNaNToF128M.c created+56
......@@ -0,0 +1,56 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by `aPtr' into a 128-bit floating-point
44| NaN, and stores this NaN at the location pointed to by `zWPtr'. Argument
45| `zWPtr' points to an array of four 32-bit elements that concatenate in the
46| platform's normal endian order to form a 128-bit floating-point value.
47*----------------------------------------------------------------------------*/
48void
49 softfloat_commonNaNToF128M( const struct commonNaN *aPtr, uint32_t *zWPtr )
50{
51
52 softfloat_shortShiftRight128M( (const uint32_t *) &aPtr->v0, 16, zWPtr );
53 zWPtr[indexWordHi( 4 )] |= (uint32_t) aPtr->sign<<31 | 0x7FFF8000;
54
55}
56
deps/SoftFloat-3e/source/8086-SSE/s_commonNaNToF128UI.c created+55
......@@ -0,0 +1,55 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by `aPtr' into a 128-bit floating-point
44| NaN, and returns the bit pattern of this value as an unsigned integer.
45*----------------------------------------------------------------------------*/
46struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN *aPtr )
47{
48 struct uint128 uiZ;
49
50 uiZ = softfloat_shortShiftRight128( aPtr->v64, aPtr->v0, 16 );
51 uiZ.v64 |= (uint_fast64_t) aPtr->sign<<63 | UINT64_C( 0x7FFF800000000000 );
52 return uiZ;
53
54}
55
deps/SoftFloat-3e/source/8086-SSE/s_commonNaNToF16UI.c created+51
......@@ -0,0 +1,51 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40
41/*----------------------------------------------------------------------------
42| Converts the common NaN pointed to by `aPtr' into a 16-bit floating-point
43| NaN, and returns the bit pattern of this value as an unsigned integer.
44*----------------------------------------------------------------------------*/
45uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr )
46{
47
48 return (uint_fast16_t) aPtr->sign<<15 | 0x7E00 | aPtr->v64>>54;
49
50}
51
deps/SoftFloat-3e/source/8086-SSE/s_commonNaNToF32UI.c created+51
......@@ -0,0 +1,51 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40
41/*----------------------------------------------------------------------------
42| Converts the common NaN pointed to by `aPtr' into a 32-bit floating-point
43| NaN, and returns the bit pattern of this value as an unsigned integer.
44*----------------------------------------------------------------------------*/
45uint_fast32_t softfloat_commonNaNToF32UI( const struct commonNaN *aPtr )
46{
47
48 return (uint_fast32_t) aPtr->sign<<31 | 0x7FC00000 | aPtr->v64>>41;
49
50}
51
deps/SoftFloat-3e/source/8086-SSE/s_commonNaNToF64UI.c created+53
......@@ -0,0 +1,53 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40
41/*----------------------------------------------------------------------------
42| Converts the common NaN pointed to by `aPtr' into a 64-bit floating-point
43| NaN, and returns the bit pattern of this value as an unsigned integer.
44*----------------------------------------------------------------------------*/
45uint_fast64_t softfloat_commonNaNToF64UI( const struct commonNaN *aPtr )
46{
47
48 return
49 (uint_fast64_t) aPtr->sign<<63 | UINT64_C( 0x7FF8000000000000 )
50 | aPtr->v64>>12;
51
52}
53
deps/SoftFloat-3e/source/8086-SSE/s_extF80MToCommonNaN.c created+62
......@@ -0,0 +1,62 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Assuming the 80-bit extended floating-point value pointed to by `aSPtr' is
45| a NaN, converts this NaN to the common NaN form, and stores the resulting
46| common NaN at the location pointed to by `zPtr'. If the NaN is a signaling
47| NaN, the invalid exception is raised.
48*----------------------------------------------------------------------------*/
49void
50 softfloat_extF80MToCommonNaN(
51 const struct extFloat80M *aSPtr, struct commonNaN *zPtr )
52{
53
54 if ( extF80M_isSignalingNaN( (const extFloat80_t *) aSPtr ) ) {
55 softfloat_raiseFlags( softfloat_flag_invalid );
56 }
57 zPtr->sign = signExtF80UI64( aSPtr->signExp );
58 zPtr->v64 = aSPtr->signif<<1;
59 zPtr->v0 = 0;
60
61}
62
deps/SoftFloat-3e/source/8086-SSE/s_extF80UIToCommonNaN.c created+62
......@@ -0,0 +1,62 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming the unsigned integer formed from concatenating `uiA64' and `uiA0'
44| has the bit pattern of an 80-bit extended floating-point NaN, converts
45| this NaN to the common NaN form, and stores the resulting common NaN at the
46| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
47| exception is raised.
48*----------------------------------------------------------------------------*/
49void
50 softfloat_extF80UIToCommonNaN(
51 uint_fast16_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr )
52{
53
54 if ( softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ) {
55 softfloat_raiseFlags( softfloat_flag_invalid );
56 }
57 zPtr->sign = uiA64>>15;
58 zPtr->v64 = uiA0<<1;
59 zPtr->v0 = 0;
60
61}
62
deps/SoftFloat-3e/source/8086-SSE/s_f128MToCommonNaN.c created+62
......@@ -0,0 +1,62 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Assuming the 128-bit floating-point value pointed to by `aWPtr' is a NaN,
45| converts this NaN to the common NaN form, and stores the resulting common
46| NaN at the location pointed to by `zPtr'. If the NaN is a signaling NaN,
47| the invalid exception is raised. Argument `aWPtr' points to an array of
48| four 32-bit elements that concatenate in the platform's normal endian order
49| to form a 128-bit floating-point value.
50*----------------------------------------------------------------------------*/
51void
52 softfloat_f128MToCommonNaN( const uint32_t *aWPtr, struct commonNaN *zPtr )
53{
54
55 if ( f128M_isSignalingNaN( (const float128_t *) aWPtr ) ) {
56 softfloat_raiseFlags( softfloat_flag_invalid );
57 }
58 zPtr->sign = aWPtr[indexWordHi( 4 )]>>31;
59 softfloat_shortShiftLeft128M( aWPtr, 16, (uint32_t *) &zPtr->v0 );
60
61}
62
deps/SoftFloat-3e/source/8086-SSE/s_f128UIToCommonNaN.c created+65
......@@ -0,0 +1,65 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Assuming the unsigned integer formed from concatenating `uiA64' and `uiA0'
45| has the bit pattern of a 128-bit floating-point NaN, converts this NaN to
46| the common NaN form, and stores the resulting common NaN at the location
47| pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid exception
48| is raised.
49*----------------------------------------------------------------------------*/
50void
51 softfloat_f128UIToCommonNaN(
52 uint_fast64_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr )
53{
54 struct uint128 NaNSig;
55
56 if ( softfloat_isSigNaNF128UI( uiA64, uiA0 ) ) {
57 softfloat_raiseFlags( softfloat_flag_invalid );
58 }
59 NaNSig = softfloat_shortShiftLeft128( uiA64, uiA0, 16 );
60 zPtr->sign = uiA64>>63;
61 zPtr->v64 = NaNSig.v64;
62 zPtr->v0 = NaNSig.v0;
63
64}
65
deps/SoftFloat-3e/source/8086-SSE/s_f16UIToCommonNaN.c created+59
......@@ -0,0 +1,59 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming `uiA' has the bit pattern of a 16-bit floating-point NaN, converts
44| this NaN to the common NaN form, and stores the resulting common NaN at the
45| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
46| exception is raised.
47*----------------------------------------------------------------------------*/
48void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr )
49{
50
51 if ( softfloat_isSigNaNF16UI( uiA ) ) {
52 softfloat_raiseFlags( softfloat_flag_invalid );
53 }
54 zPtr->sign = uiA>>15;
55 zPtr->v64 = (uint_fast64_t) uiA<<54;
56 zPtr->v0 = 0;
57
58}
59
deps/SoftFloat-3e/source/8086-SSE/s_f32UIToCommonNaN.c created+59
......@@ -0,0 +1,59 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming `uiA' has the bit pattern of a 32-bit floating-point NaN, converts
44| this NaN to the common NaN form, and stores the resulting common NaN at the
45| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
46| exception is raised.
47*----------------------------------------------------------------------------*/
48void softfloat_f32UIToCommonNaN( uint_fast32_t uiA, struct commonNaN *zPtr )
49{
50
51 if ( softfloat_isSigNaNF32UI( uiA ) ) {
52 softfloat_raiseFlags( softfloat_flag_invalid );
53 }
54 zPtr->sign = uiA>>31;
55 zPtr->v64 = (uint_fast64_t) uiA<<41;
56 zPtr->v0 = 0;
57
58}
59
deps/SoftFloat-3e/source/8086-SSE/s_f64UIToCommonNaN.c created+59
......@@ -0,0 +1,59 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming `uiA' has the bit pattern of a 64-bit floating-point NaN, converts
44| this NaN to the common NaN form, and stores the resulting common NaN at the
45| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
46| exception is raised.
47*----------------------------------------------------------------------------*/
48void softfloat_f64UIToCommonNaN( uint_fast64_t uiA, struct commonNaN *zPtr )
49{
50
51 if ( softfloat_isSigNaNF64UI( uiA ) ) {
52 softfloat_raiseFlags( softfloat_flag_invalid );
53 }
54 zPtr->sign = uiA>>63;
55 zPtr->v64 = uiA<<12;
56 zPtr->v0 = 0;
57
58}
59
deps/SoftFloat-3e/source/8086-SSE/s_propagateNaNExtF80M.c created+107
......@@ -0,0 +1,107 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Assuming at least one of the two 80-bit extended floating-point values
46| pointed to by `aSPtr' and `bSPtr' is a NaN, stores the combined NaN result
47| at the location pointed to by `zSPtr'. If either original floating-point
48| value is a signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50void
51 softfloat_propagateNaNExtF80M(
52 const struct extFloat80M *aSPtr,
53 const struct extFloat80M *bSPtr,
54 struct extFloat80M *zSPtr
55 )
56{
57 bool isSigNaNA;
58 const struct extFloat80M *sPtr;
59 bool isSigNaNB;
60 uint_fast16_t uiB64;
61 uint64_t uiB0;
62 uint_fast16_t uiA64;
63 uint64_t uiA0;
64 uint_fast16_t uiMagA64, uiMagB64;
65
66 isSigNaNA = extF80M_isSignalingNaN( (const extFloat80_t *) aSPtr );
67 sPtr = aSPtr;
68 if ( ! bSPtr ) {
69 if ( isSigNaNA ) softfloat_raiseFlags( softfloat_flag_invalid );
70 goto copy;
71 }
72 isSigNaNB = extF80M_isSignalingNaN( (const extFloat80_t *) bSPtr );
73 if ( isSigNaNA | isSigNaNB ) {
74 softfloat_raiseFlags( softfloat_flag_invalid );
75 if ( isSigNaNA ) {
76 uiB64 = bSPtr->signExp;
77 if ( isSigNaNB ) goto returnLargerUIMag;
78 uiB0 = bSPtr->signif;
79 if ( isNaNExtF80UI( uiB64, uiB0 ) ) goto copyB;
80 goto copy;
81 } else {
82 uiA64 = aSPtr->signExp;
83 uiA0 = aSPtr->signif;
84 if ( isNaNExtF80UI( uiA64, uiA0 ) ) goto copy;
85 goto copyB;
86 }
87 }
88 uiB64 = bSPtr->signExp;
89 returnLargerUIMag:
90 uiA64 = aSPtr->signExp;
91 uiMagA64 = uiA64 & 0x7FFF;
92 uiMagB64 = uiB64 & 0x7FFF;
93 if ( uiMagA64 < uiMagB64 ) goto copyB;
94 if ( uiMagB64 < uiMagA64 ) goto copy;
95 uiA0 = aSPtr->signif;
96 uiB0 = bSPtr->signif;
97 if ( uiA0 < uiB0 ) goto copyB;
98 if ( uiB0 < uiA0 ) goto copy;
99 if ( uiA64 < uiB64 ) goto copy;
100 copyB:
101 sPtr = bSPtr;
102 copy:
103 zSPtr->signExp = sPtr->signExp;
104 zSPtr->signif = sPtr->signif | UINT64_C( 0xC000000000000000 );
105
106}
107
deps/SoftFloat-3e/source/8086-SSE/s_propagateNaNExtF80UI.c created+106
......@@ -0,0 +1,106 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2018 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting the unsigned integer formed from concatenating 'uiA64' and
46| 'uiA0' as an 80-bit extended floating-point value, and likewise interpreting
47| the unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
48| 80-bit extended floating-point value, and assuming at least on of these
49| floating-point values is a NaN, returns the bit pattern of the combined NaN
50| result. If either original floating-point value is a signaling NaN, the
51| invalid exception is raised.
52*----------------------------------------------------------------------------*/
53struct uint128
54 softfloat_propagateNaNExtF80UI(
55 uint_fast16_t uiA64,
56 uint_fast64_t uiA0,
57 uint_fast16_t uiB64,
58 uint_fast64_t uiB0
59 )
60{
61 bool isSigNaNA, isSigNaNB;
62 uint_fast64_t uiNonsigA0, uiNonsigB0;
63 uint_fast16_t uiMagA64, uiMagB64;
64 struct uint128 uiZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 isSigNaNA = softfloat_isSigNaNExtF80UI( uiA64, uiA0 );
69 isSigNaNB = softfloat_isSigNaNExtF80UI( uiB64, uiB0 );
70 /*------------------------------------------------------------------------
71 | Make NaNs non-signaling.
72 *------------------------------------------------------------------------*/
73 uiNonsigA0 = uiA0 | UINT64_C( 0xC000000000000000 );
74 uiNonsigB0 = uiB0 | UINT64_C( 0xC000000000000000 );
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( isSigNaNA | isSigNaNB ) {
78 softfloat_raiseFlags( softfloat_flag_invalid );
79 if ( isSigNaNA ) {
80 if ( isSigNaNB ) goto returnLargerMag;
81 if ( isNaNExtF80UI( uiB64, uiB0 ) ) goto returnB;
82 goto returnA;
83 } else {
84 if ( isNaNExtF80UI( uiA64, uiA0 ) ) goto returnA;
85 goto returnB;
86 }
87 }
88 returnLargerMag:
89 uiMagA64 = uiA64 & 0x7FFF;
90 uiMagB64 = uiB64 & 0x7FFF;
91 if ( uiMagA64 < uiMagB64 ) goto returnB;
92 if ( uiMagB64 < uiMagA64 ) goto returnA;
93 if ( uiA0 < uiB0 ) goto returnB;
94 if ( uiB0 < uiA0 ) goto returnA;
95 if ( uiA64 < uiB64 ) goto returnA;
96 returnB:
97 uiZ.v64 = uiB64;
98 uiZ.v0 = uiNonsigB0;
99 return uiZ;
100 returnA:
101 uiZ.v64 = uiA64;
102 uiZ.v0 = uiNonsigA0;
103 return uiZ;
104
105}
106
deps/SoftFloat-3e/source/8086-SSE/s_propagateNaNF128M.c created+76
......@@ -0,0 +1,76 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Assuming at least one of the two 128-bit floating-point values pointed to by
46| `aWPtr' and `bWPtr' is a NaN, stores the combined NaN result at the location
47| pointed to by `zWPtr'. If either original floating-point value is a
48| signaling NaN, the invalid exception is raised. Each of `aWPtr', `bWPtr',
49| and `zWPtr' points to an array of four 32-bit elements that concatenate in
50| the platform's normal endian order to form a 128-bit floating-point value.
51*----------------------------------------------------------------------------*/
52void
53 softfloat_propagateNaNF128M(
54 const uint32_t *aWPtr, const uint32_t *bWPtr, uint32_t *zWPtr )
55{
56 bool isSigNaNA;
57 const uint32_t *ptr;
58
59 ptr = aWPtr;
60 isSigNaNA = f128M_isSignalingNaN( (const float128_t *) aWPtr );
61 if (
62 isSigNaNA
63 || (bWPtr && f128M_isSignalingNaN( (const float128_t *) bWPtr ))
64 ) {
65 softfloat_raiseFlags( softfloat_flag_invalid );
66 if ( isSigNaNA ) goto copy;
67 }
68 if ( ! softfloat_isNaNF128M( aWPtr ) ) ptr = bWPtr;
69 copy:
70 zWPtr[indexWordHi( 4 )] = ptr[indexWordHi( 4 )] | 0x00008000;
71 zWPtr[indexWord( 4, 2 )] = ptr[indexWord( 4, 2 )];
72 zWPtr[indexWord( 4, 1 )] = ptr[indexWord( 4, 1 )];
73 zWPtr[indexWord( 4, 0 )] = ptr[indexWord( 4, 0 )];
74
75}
76
deps/SoftFloat-3e/source/8086-SSE/s_propagateNaNF128UI.c created+81
......@@ -0,0 +1,81 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting the unsigned integer formed from concatenating `uiA64' and
46| `uiA0' as a 128-bit floating-point value, and likewise interpreting the
47| unsigned integer formed from concatenating `uiB64' and `uiB0' as another
48| 128-bit floating-point value, and assuming at least on of these floating-
49| point values is a NaN, returns the bit pattern of the combined NaN result.
50| If either original floating-point value is a signaling NaN, the invalid
51| exception is raised.
52*----------------------------------------------------------------------------*/
53struct uint128
54 softfloat_propagateNaNF128UI(
55 uint_fast64_t uiA64,
56 uint_fast64_t uiA0,
57 uint_fast64_t uiB64,
58 uint_fast64_t uiB0
59 )
60{
61 bool isSigNaNA;
62 struct uint128 uiZ;
63
64 isSigNaNA = softfloat_isSigNaNF128UI( uiA64, uiA0 );
65 if ( isSigNaNA || softfloat_isSigNaNF128UI( uiB64, uiB0 ) ) {
66 softfloat_raiseFlags( softfloat_flag_invalid );
67 if ( isSigNaNA ) goto returnNonsigA;
68 }
69 if ( isNaNF128UI( uiA64, uiA0 ) ) {
70 returnNonsigA:
71 uiZ.v64 = uiA64;
72 uiZ.v0 = uiA0;
73 } else {
74 uiZ.v64 = uiB64;
75 uiZ.v0 = uiB0;
76 }
77 uiZ.v64 |= UINT64_C( 0x0000800000000000 );
78 return uiZ;
79
80}
81
deps/SoftFloat-3e/source/8086-SSE/s_propagateNaNF16UI.c created+63
......@@ -0,0 +1,63 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting `uiA' and `uiB' as the bit patterns of two 16-bit floating-
46| point values, at least one of which is a NaN, returns the bit pattern of
47| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
48| signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50uint_fast16_t
51 softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB )
52{
53 bool isSigNaNA;
54
55 isSigNaNA = softfloat_isSigNaNF16UI( uiA );
56 if ( isSigNaNA || softfloat_isSigNaNF16UI( uiB ) ) {
57 softfloat_raiseFlags( softfloat_flag_invalid );
58 if ( isSigNaNA ) return uiA | 0x0200;
59 }
60 return (isNaNF16UI( uiA ) ? uiA : uiB) | 0x0200;
61
62}
63
deps/SoftFloat-3e/source/8086-SSE/s_propagateNaNF32UI.c created+63
......@@ -0,0 +1,63 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting `uiA' and `uiB' as the bit patterns of two 32-bit floating-
46| point values, at least one of which is a NaN, returns the bit pattern of
47| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
48| signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50uint_fast32_t
51 softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB )
52{
53 bool isSigNaNA;
54
55 isSigNaNA = softfloat_isSigNaNF32UI( uiA );
56 if ( isSigNaNA || softfloat_isSigNaNF32UI( uiB ) ) {
57 softfloat_raiseFlags( softfloat_flag_invalid );
58 if ( isSigNaNA ) return uiA | 0x00400000;
59 }
60 return (isNaNF32UI( uiA ) ? uiA : uiB) | 0x00400000;
61
62}
63
deps/SoftFloat-3e/source/8086-SSE/s_propagateNaNF64UI.c created+63
......@@ -0,0 +1,63 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting `uiA' and `uiB' as the bit patterns of two 64-bit floating-
46| point values, at least one of which is a NaN, returns the bit pattern of
47| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
48| signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50uint_fast64_t
51 softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB )
52{
53 bool isSigNaNA;
54
55 isSigNaNA = softfloat_isSigNaNF64UI( uiA );
56 if ( isSigNaNA || softfloat_isSigNaNF64UI( uiB ) ) {
57 softfloat_raiseFlags( softfloat_flag_invalid );
58 if ( isSigNaNA ) return uiA | UINT64_C( 0x0008000000000000 );
59 }
60 return (isNaNF64UI( uiA ) ? uiA : uiB) | UINT64_C( 0x0008000000000000 );
61
62}
63
deps/SoftFloat-3e/source/8086-SSE/softfloat_raiseFlags.c created+52
......@@ -0,0 +1,52 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include "platform.h"
38#include "softfloat.h"
39
40/*----------------------------------------------------------------------------
41| Raises the exceptions specified by `flags'. Floating-point traps can be
42| defined here if desired. It is currently not possible for such a trap
43| to substitute a result value. If traps are not implemented, this routine
44| should be simply `softfloat_exceptionFlags |= flags;'.
45*----------------------------------------------------------------------------*/
46void softfloat_raiseFlags( uint_fast8_t flags )
47{
48
49 softfloat_exceptionFlags |= flags;
50
51}
52
deps/SoftFloat-3e/source/8086-SSE/specialize.h created+376
......@@ -0,0 +1,376 @@
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2018 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#ifndef specialize_h
38#define specialize_h 1
39
40#include <stdbool.h>
41#include <stdint.h>
42#include "primitiveTypes.h"
43#include "softfloat.h"
44
45/*----------------------------------------------------------------------------
46| Default value for 'softfloat_detectTininess'.
47*----------------------------------------------------------------------------*/
48#define init_detectTininess softfloat_tininess_afterRounding
49
50/*----------------------------------------------------------------------------
51| The values to return on conversions to 32-bit integer formats that raise an
52| invalid exception.
53*----------------------------------------------------------------------------*/
54#define ui32_fromPosOverflow 0xFFFFFFFF
55#define ui32_fromNegOverflow 0xFFFFFFFF
56#define ui32_fromNaN 0xFFFFFFFF
57#define i32_fromPosOverflow (-0x7FFFFFFF - 1)
58#define i32_fromNegOverflow (-0x7FFFFFFF - 1)
59#define i32_fromNaN (-0x7FFFFFFF - 1)
60
61/*----------------------------------------------------------------------------
62| The values to return on conversions to 64-bit integer formats that raise an
63| invalid exception.
64*----------------------------------------------------------------------------*/
65#define ui64_fromPosOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
66#define ui64_fromNegOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
67#define ui64_fromNaN UINT64_C( 0xFFFFFFFFFFFFFFFF )
68#define i64_fromPosOverflow (-INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
69#define i64_fromNegOverflow (-INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
70#define i64_fromNaN (-INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
71
72/*----------------------------------------------------------------------------
73| "Common NaN" structure, used to transfer NaN representations from one format
74| to another.
75*----------------------------------------------------------------------------*/
76struct commonNaN {
77 bool sign;
78#ifdef LITTLEENDIAN
79 uint64_t v0, v64;
80#else
81 uint64_t v64, v0;
82#endif
83};
84
85/*----------------------------------------------------------------------------
86| The bit pattern for a default generated 16-bit floating-point NaN.
87*----------------------------------------------------------------------------*/
88#define defaultNaNF16UI 0xFE00
89
90/*----------------------------------------------------------------------------
91| Returns true when 16-bit unsigned integer 'uiA' has the bit pattern of a
92| 16-bit floating-point signaling NaN.
93| Note: This macro evaluates its argument more than once.
94*----------------------------------------------------------------------------*/
95#define softfloat_isSigNaNF16UI( uiA ) ((((uiA) & 0x7E00) == 0x7C00) && ((uiA) & 0x01FF))
96
97/*----------------------------------------------------------------------------
98| Assuming 'uiA' has the bit pattern of a 16-bit floating-point NaN, converts
99| this NaN to the common NaN form, and stores the resulting common NaN at the
100| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
101| exception is raised.
102*----------------------------------------------------------------------------*/
103void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr );
104
105/*----------------------------------------------------------------------------
106| Converts the common NaN pointed to by 'aPtr' into a 16-bit floating-point
107| NaN, and returns the bit pattern of this value as an unsigned integer.
108*----------------------------------------------------------------------------*/
109uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr );
110
111/*----------------------------------------------------------------------------
112| Interpreting 'uiA' and 'uiB' as the bit patterns of two 16-bit floating-
113| point values, at least one of which is a NaN, returns the bit pattern of
114| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
115| signaling NaN, the invalid exception is raised.
116*----------------------------------------------------------------------------*/
117uint_fast16_t
118 softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB );
119
120/*----------------------------------------------------------------------------
121| The bit pattern for a default generated 32-bit floating-point NaN.
122*----------------------------------------------------------------------------*/
123#define defaultNaNF32UI 0xFFC00000
124
125/*----------------------------------------------------------------------------
126| Returns true when 32-bit unsigned integer 'uiA' has the bit pattern of a
127| 32-bit floating-point signaling NaN.
128| Note: This macro evaluates its argument more than once.
129*----------------------------------------------------------------------------*/
130#define softfloat_isSigNaNF32UI( uiA ) ((((uiA) & 0x7FC00000) == 0x7F800000) && ((uiA) & 0x003FFFFF))
131
132/*----------------------------------------------------------------------------
133| Assuming 'uiA' has the bit pattern of a 32-bit floating-point NaN, converts
134| this NaN to the common NaN form, and stores the resulting common NaN at the
135| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
136| exception is raised.
137*----------------------------------------------------------------------------*/
138void softfloat_f32UIToCommonNaN( uint_fast32_t uiA, struct commonNaN *zPtr );
139
140/*----------------------------------------------------------------------------
141| Converts the common NaN pointed to by 'aPtr' into a 32-bit floating-point
142| NaN, and returns the bit pattern of this value as an unsigned integer.
143*----------------------------------------------------------------------------*/
144uint_fast32_t softfloat_commonNaNToF32UI( const struct commonNaN *aPtr );
145
146/*----------------------------------------------------------------------------
147| Interpreting 'uiA' and 'uiB' as the bit patterns of two 32-bit floating-
148| point values, at least one of which is a NaN, returns the bit pattern of
149| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
150| signaling NaN, the invalid exception is raised.
151*----------------------------------------------------------------------------*/
152uint_fast32_t
153 softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB );
154
155/*----------------------------------------------------------------------------
156| The bit pattern for a default generated 64-bit floating-point NaN.
157*----------------------------------------------------------------------------*/
158#define defaultNaNF64UI UINT64_C( 0xFFF8000000000000 )
159
160/*----------------------------------------------------------------------------
161| Returns true when 64-bit unsigned integer 'uiA' has the bit pattern of a
162| 64-bit floating-point signaling NaN.
163| Note: This macro evaluates its argument more than once.
164*----------------------------------------------------------------------------*/
165#define softfloat_isSigNaNF64UI( uiA ) ((((uiA) & UINT64_C( 0x7FF8000000000000 )) == UINT64_C( 0x7FF0000000000000 )) && ((uiA) & UINT64_C( 0x0007FFFFFFFFFFFF )))
166
167/*----------------------------------------------------------------------------
168| Assuming 'uiA' has the bit pattern of a 64-bit floating-point NaN, converts
169| this NaN to the common NaN form, and stores the resulting common NaN at the
170| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
171| exception is raised.
172*----------------------------------------------------------------------------*/
173void softfloat_f64UIToCommonNaN( uint_fast64_t uiA, struct commonNaN *zPtr );
174
175/*----------------------------------------------------------------------------
176| Converts the common NaN pointed to by 'aPtr' into a 64-bit floating-point
177| NaN, and returns the bit pattern of this value as an unsigned integer.
178*----------------------------------------------------------------------------*/
179uint_fast64_t softfloat_commonNaNToF64UI( const struct commonNaN *aPtr );
180
181/*----------------------------------------------------------------------------
182| Interpreting 'uiA' and 'uiB' as the bit patterns of two 64-bit floating-
183| point values, at least one of which is a NaN, returns the bit pattern of
184| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
185| signaling NaN, the invalid exception is raised.
186*----------------------------------------------------------------------------*/
187uint_fast64_t
188 softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB );
189
190/*----------------------------------------------------------------------------
191| The bit pattern for a default generated 80-bit extended floating-point NaN.
192*----------------------------------------------------------------------------*/
193#define defaultNaNExtF80UI64 0xFFFF
194#define defaultNaNExtF80UI0 UINT64_C( 0xC000000000000000 )
195
196/*----------------------------------------------------------------------------
197| Returns true when the 80-bit unsigned integer formed from concatenating
198| 16-bit 'uiA64' and 64-bit 'uiA0' has the bit pattern of an 80-bit extended
199| floating-point signaling NaN.
200| Note: This macro evaluates its arguments more than once.
201*----------------------------------------------------------------------------*/
202#define softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ((((uiA64) & 0x7FFF) == 0x7FFF) && ! ((uiA0) & UINT64_C( 0x4000000000000000 )) && ((uiA0) & UINT64_C( 0x3FFFFFFFFFFFFFFF )))
203
204#ifdef SOFTFLOAT_FAST_INT64
205
206/*----------------------------------------------------------------------------
207| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is
208| defined.
209*----------------------------------------------------------------------------*/
210
211/*----------------------------------------------------------------------------
212| Assuming the unsigned integer formed from concatenating 'uiA64' and 'uiA0'
213| has the bit pattern of an 80-bit extended floating-point NaN, converts
214| this NaN to the common NaN form, and stores the resulting common NaN at the
215| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
216| exception is raised.
217*----------------------------------------------------------------------------*/
218void
219 softfloat_extF80UIToCommonNaN(
220 uint_fast16_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr );
221
222/*----------------------------------------------------------------------------
223| Converts the common NaN pointed to by 'aPtr' into an 80-bit extended
224| floating-point NaN, and returns the bit pattern of this value as an unsigned
225| integer.
226*----------------------------------------------------------------------------*/
227struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr );
228
229/*----------------------------------------------------------------------------
230| Interpreting the unsigned integer formed from concatenating 'uiA64' and
231| 'uiA0' as an 80-bit extended floating-point value, and likewise interpreting
232| the unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
233| 80-bit extended floating-point value, and assuming at least on of these
234| floating-point values is a NaN, returns the bit pattern of the combined NaN
235| result. If either original floating-point value is a signaling NaN, the
236| invalid exception is raised.
237*----------------------------------------------------------------------------*/
238struct uint128
239 softfloat_propagateNaNExtF80UI(
240 uint_fast16_t uiA64,
241 uint_fast64_t uiA0,
242 uint_fast16_t uiB64,
243 uint_fast64_t uiB0
244 );
245
246/*----------------------------------------------------------------------------
247| The bit pattern for a default generated 128-bit floating-point NaN.
248*----------------------------------------------------------------------------*/
249#define defaultNaNF128UI64 UINT64_C( 0xFFFF800000000000 )
250#define defaultNaNF128UI0 UINT64_C( 0 )
251
252/*----------------------------------------------------------------------------
253| Returns true when the 128-bit unsigned integer formed from concatenating
254| 64-bit 'uiA64' and 64-bit 'uiA0' has the bit pattern of a 128-bit floating-
255| point signaling NaN.
256| Note: This macro evaluates its arguments more than once.
257*----------------------------------------------------------------------------*/
258#define softfloat_isSigNaNF128UI( uiA64, uiA0 ) ((((uiA64) & UINT64_C( 0x7FFF800000000000 )) == UINT64_C( 0x7FFF000000000000 )) && ((uiA0) || ((uiA64) & UINT64_C( 0x00007FFFFFFFFFFF ))))
259
260/*----------------------------------------------------------------------------
261| Assuming the unsigned integer formed from concatenating 'uiA64' and 'uiA0'
262| has the bit pattern of a 128-bit floating-point NaN, converts this NaN to
263| the common NaN form, and stores the resulting common NaN at the location
264| pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid exception
265| is raised.
266*----------------------------------------------------------------------------*/
267void
268 softfloat_f128UIToCommonNaN(
269 uint_fast64_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr );
270
271/*----------------------------------------------------------------------------
272| Converts the common NaN pointed to by 'aPtr' into a 128-bit floating-point
273| NaN, and returns the bit pattern of this value as an unsigned integer.
274*----------------------------------------------------------------------------*/
275struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN * );
276
277/*----------------------------------------------------------------------------
278| Interpreting the unsigned integer formed from concatenating 'uiA64' and
279| 'uiA0' as a 128-bit floating-point value, and likewise interpreting the
280| unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
281| 128-bit floating-point value, and assuming at least on of these floating-
282| point values is a NaN, returns the bit pattern of the combined NaN result.
283| If either original floating-point value is a signaling NaN, the invalid
284| exception is raised.
285*----------------------------------------------------------------------------*/
286struct uint128
287 softfloat_propagateNaNF128UI(
288 uint_fast64_t uiA64,
289 uint_fast64_t uiA0,
290 uint_fast64_t uiB64,
291 uint_fast64_t uiB0
292 );
293
294#else
295
296/*----------------------------------------------------------------------------
297| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is not
298| defined.
299*----------------------------------------------------------------------------*/
300
301/*----------------------------------------------------------------------------
302| Assuming the 80-bit extended floating-point value pointed to by 'aSPtr' is
303| a NaN, converts this NaN to the common NaN form, and stores the resulting
304| common NaN at the location pointed to by 'zPtr'. If the NaN is a signaling
305| NaN, the invalid exception is raised.
306*----------------------------------------------------------------------------*/
307void
308 softfloat_extF80MToCommonNaN(
309 const struct extFloat80M *aSPtr, struct commonNaN *zPtr );
310
311/*----------------------------------------------------------------------------
312| Converts the common NaN pointed to by 'aPtr' into an 80-bit extended
313| floating-point NaN, and stores this NaN at the location pointed to by
314| 'zSPtr'.
315*----------------------------------------------------------------------------*/
316void
317 softfloat_commonNaNToExtF80M(
318 const struct commonNaN *aPtr, struct extFloat80M *zSPtr );
319
320/*----------------------------------------------------------------------------
321| Assuming at least one of the two 80-bit extended floating-point values
322| pointed to by 'aSPtr' and 'bSPtr' is a NaN, stores the combined NaN result
323| at the location pointed to by 'zSPtr'. If either original floating-point
324| value is a signaling NaN, the invalid exception is raised.
325*----------------------------------------------------------------------------*/
326void
327 softfloat_propagateNaNExtF80M(
328 const struct extFloat80M *aSPtr,
329 const struct extFloat80M *bSPtr,
330 struct extFloat80M *zSPtr
331 );
332
333/*----------------------------------------------------------------------------
334| The bit pattern for a default generated 128-bit floating-point NaN.
335*----------------------------------------------------------------------------*/
336#define defaultNaNF128UI96 0xFFFF8000
337#define defaultNaNF128UI64 0
338#define defaultNaNF128UI32 0
339#define defaultNaNF128UI0 0
340
341/*----------------------------------------------------------------------------
342| Assuming the 128-bit floating-point value pointed to by 'aWPtr' is a NaN,
343| converts this NaN to the common NaN form, and stores the resulting common
344| NaN at the location pointed to by 'zPtr'. If the NaN is a signaling NaN,
345| the invalid exception is raised. Argument 'aWPtr' points to an array of
346| four 32-bit elements that concatenate in the platform's normal endian order
347| to form a 128-bit floating-point value.
348*----------------------------------------------------------------------------*/
349void
350 softfloat_f128MToCommonNaN( const uint32_t *aWPtr, struct commonNaN *zPtr );
351
352/*----------------------------------------------------------------------------
353| Converts the common NaN pointed to by 'aPtr' into a 128-bit floating-point
354| NaN, and stores this NaN at the location pointed to by 'zWPtr'. Argument
355| 'zWPtr' points to an array of four 32-bit elements that concatenate in the
356| platform's normal endian order to form a 128-bit floating-point value.
357*----------------------------------------------------------------------------*/
358void
359 softfloat_commonNaNToF128M( const struct commonNaN *aPtr, uint32_t *zWPtr );
360
361/*----------------------------------------------------------------------------
362| Assuming at least one of the two 128-bit floating-point values pointed to by
363| 'aWPtr' and 'bWPtr' is a NaN, stores the combined NaN result at the location
364| pointed to by 'zWPtr'. If either original floating-point value is a
365| signaling NaN, the invalid exception is raised. Each of 'aWPtr', 'bWPtr',
366| and 'zWPtr' points to an array of four 32-bit elements that concatenate in
367| the platform's normal endian order to form a 128-bit floating-point value.
368*----------------------------------------------------------------------------*/
369void
370 softfloat_propagateNaNF128M(
371 const uint32_t *aWPtr, const uint32_t *bWPtr, uint32_t *zWPtr );
372
373#endif
374
375#endif
376
deps/SoftFloat-3e/source/8086/extF80M_isSignalingNaN.c created+57
......@@ -0,0 +1,57 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43*----------------------------------------------------------------------------*/
44bool extF80M_isSignalingNaN( const extFloat80_t *aPtr )
45{
46 const struct extFloat80M *aSPtr;
47 uint64_t uiA0;
48
49 aSPtr = (const struct extFloat80M *) aPtr;
50 if ( (aSPtr->signExp & 0x7FFF) != 0x7FFF ) return false;
51 uiA0 = aSPtr->signif;
52 return
53 ! (uiA0 & UINT64_C( 0x4000000000000000 ))
54 && (uiA0 & UINT64_C( 0x3FFFFFFFFFFFFFFF));
55
56}
57
deps/SoftFloat-3e/source/8086/f128M_isSignalingNaN.c created+60
......@@ -0,0 +1,60 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "primitives.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44*----------------------------------------------------------------------------*/
45bool f128M_isSignalingNaN( const float128_t *aPtr )
46{
47 const uint32_t *aWPtr;
48 uint32_t uiA96;
49
50 aWPtr = (const uint32_t *) aPtr;
51 uiA96 = aWPtr[indexWordHi( 4 )];
52 if ( (uiA96 & 0x7FFF8000) != 0x7FFF0000 ) return false;
53 return
54 ((uiA96 & 0x00007FFF) != 0)
55 || ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
56 | aWPtr[indexWord( 4, 0 )])
57 != 0);
58
59}
60
deps/SoftFloat-3e/source/8086/s_commonNaNToExtF80M.c created+56
......@@ -0,0 +1,56 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by `aPtr' into an 80-bit extended
44| floating-point NaN, and stores this NaN at the location pointed to by
45| `zSPtr'.
46*----------------------------------------------------------------------------*/
47void
48 softfloat_commonNaNToExtF80M(
49 const struct commonNaN *aPtr, struct extFloat80M *zSPtr )
50{
51
52 zSPtr->signExp = packToExtF80UI64( aPtr->sign, 0x7FFF );
53 zSPtr->signif = UINT64_C( 0xC000000000000000 ) | aPtr->v64>>1;
54
55}
56
deps/SoftFloat-3e/source/8086/s_commonNaNToExtF80UI.c created+56
......@@ -0,0 +1,56 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by `aPtr' into an 80-bit extended
44| floating-point NaN, and returns the bit pattern of this value as an unsigned
45| integer.
46*----------------------------------------------------------------------------*/
47struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr )
48{
49 struct uint128 uiZ;
50
51 uiZ.v64 = (uint_fast16_t) aPtr->sign<<15 | 0x7FFF;
52 uiZ.v0 = UINT64_C( 0xC000000000000000 ) | aPtr->v64>>1;
53 return uiZ;
54
55}
56
deps/SoftFloat-3e/source/8086/s_commonNaNToF128M.c created+56
......@@ -0,0 +1,56 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by `aPtr' into a 128-bit floating-point
44| NaN, and stores this NaN at the location pointed to by `zWPtr'. Argument
45| `zWPtr' points to an array of four 32-bit elements that concatenate in the
46| platform's normal endian order to form a 128-bit floating-point value.
47*----------------------------------------------------------------------------*/
48void
49 softfloat_commonNaNToF128M( const struct commonNaN *aPtr, uint32_t *zWPtr )
50{
51
52 softfloat_shortShiftRight128M( (const uint32_t *) &aPtr->v0, 16, zWPtr );
53 zWPtr[indexWordHi( 4 )] |= (uint32_t) aPtr->sign<<31 | 0x7FFF8000;
54
55}
56
deps/SoftFloat-3e/source/8086/s_commonNaNToF128UI.c created+55
......@@ -0,0 +1,55 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by `aPtr' into a 128-bit floating-point
44| NaN, and returns the bit pattern of this value as an unsigned integer.
45*----------------------------------------------------------------------------*/
46struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN *aPtr )
47{
48 struct uint128 uiZ;
49
50 uiZ = softfloat_shortShiftRight128( aPtr->v64, aPtr->v0, 16 );
51 uiZ.v64 |= (uint_fast64_t) aPtr->sign<<63 | UINT64_C( 0x7FFF800000000000 );
52 return uiZ;
53
54}
55
deps/SoftFloat-3e/source/8086/s_commonNaNToF16UI.c created+51
......@@ -0,0 +1,51 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40
41/*----------------------------------------------------------------------------
42| Converts the common NaN pointed to by `aPtr' into a 16-bit floating-point
43| NaN, and returns the bit pattern of this value as an unsigned integer.
44*----------------------------------------------------------------------------*/
45uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr )
46{
47
48 return (uint_fast16_t) aPtr->sign<<15 | 0x7E00 | aPtr->v64>>54;
49
50}
51
deps/SoftFloat-3e/source/8086/s_commonNaNToF32UI.c created+51
......@@ -0,0 +1,51 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40
41/*----------------------------------------------------------------------------
42| Converts the common NaN pointed to by `aPtr' into a 32-bit floating-point
43| NaN, and returns the bit pattern of this value as an unsigned integer.
44*----------------------------------------------------------------------------*/
45uint_fast32_t softfloat_commonNaNToF32UI( const struct commonNaN *aPtr )
46{
47
48 return (uint_fast32_t) aPtr->sign<<31 | 0x7FC00000 | aPtr->v64>>41;
49
50}
51
deps/SoftFloat-3e/source/8086/s_commonNaNToF64UI.c created+53
......@@ -0,0 +1,53 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40
41/*----------------------------------------------------------------------------
42| Converts the common NaN pointed to by `aPtr' into a 64-bit floating-point
43| NaN, and returns the bit pattern of this value as an unsigned integer.
44*----------------------------------------------------------------------------*/
45uint_fast64_t softfloat_commonNaNToF64UI( const struct commonNaN *aPtr )
46{
47
48 return
49 (uint_fast64_t) aPtr->sign<<63 | UINT64_C( 0x7FF8000000000000 )
50 | aPtr->v64>>12;
51
52}
53
deps/SoftFloat-3e/source/8086/s_extF80MToCommonNaN.c created+62
......@@ -0,0 +1,62 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Assuming the 80-bit extended floating-point value pointed to by `aSPtr' is
45| a NaN, converts this NaN to the common NaN form, and stores the resulting
46| common NaN at the location pointed to by `zPtr'. If the NaN is a signaling
47| NaN, the invalid exception is raised.
48*----------------------------------------------------------------------------*/
49void
50 softfloat_extF80MToCommonNaN(
51 const struct extFloat80M *aSPtr, struct commonNaN *zPtr )
52{
53
54 if ( extF80M_isSignalingNaN( (const extFloat80_t *) aSPtr ) ) {
55 softfloat_raiseFlags( softfloat_flag_invalid );
56 }
57 zPtr->sign = signExtF80UI64( aSPtr->signExp );
58 zPtr->v64 = aSPtr->signif<<1;
59 zPtr->v0 = 0;
60
61}
62
deps/SoftFloat-3e/source/8086/s_extF80UIToCommonNaN.c created+62
......@@ -0,0 +1,62 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming the unsigned integer formed from concatenating `uiA64' and `uiA0'
44| has the bit pattern of an 80-bit extended floating-point NaN, converts
45| this NaN to the common NaN form, and stores the resulting common NaN at the
46| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
47| exception is raised.
48*----------------------------------------------------------------------------*/
49void
50 softfloat_extF80UIToCommonNaN(
51 uint_fast16_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr )
52{
53
54 if ( softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ) {
55 softfloat_raiseFlags( softfloat_flag_invalid );
56 }
57 zPtr->sign = uiA64>>15;
58 zPtr->v64 = uiA0<<1;
59 zPtr->v0 = 0;
60
61}
62
deps/SoftFloat-3e/source/8086/s_f128MToCommonNaN.c created+62
......@@ -0,0 +1,62 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Assuming the 128-bit floating-point value pointed to by `aWPtr' is a NaN,
45| converts this NaN to the common NaN form, and stores the resulting common
46| NaN at the location pointed to by `zPtr'. If the NaN is a signaling NaN,
47| the invalid exception is raised. Argument `aWPtr' points to an array of
48| four 32-bit elements that concatenate in the platform's normal endian order
49| to form a 128-bit floating-point value.
50*----------------------------------------------------------------------------*/
51void
52 softfloat_f128MToCommonNaN( const uint32_t *aWPtr, struct commonNaN *zPtr )
53{
54
55 if ( f128M_isSignalingNaN( (const float128_t *) aWPtr ) ) {
56 softfloat_raiseFlags( softfloat_flag_invalid );
57 }
58 zPtr->sign = aWPtr[indexWordHi( 4 )]>>31;
59 softfloat_shortShiftLeft128M( aWPtr, 16, (uint32_t *) &zPtr->v0 );
60
61}
62
deps/SoftFloat-3e/source/8086/s_f128UIToCommonNaN.c created+65
......@@ -0,0 +1,65 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Assuming the unsigned integer formed from concatenating `uiA64' and `uiA0'
45| has the bit pattern of a 128-bit floating-point NaN, converts this NaN to
46| the common NaN form, and stores the resulting common NaN at the location
47| pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid exception
48| is raised.
49*----------------------------------------------------------------------------*/
50void
51 softfloat_f128UIToCommonNaN(
52 uint_fast64_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr )
53{
54 struct uint128 NaNSig;
55
56 if ( softfloat_isSigNaNF128UI( uiA64, uiA0 ) ) {
57 softfloat_raiseFlags( softfloat_flag_invalid );
58 }
59 NaNSig = softfloat_shortShiftLeft128( uiA64, uiA0, 16 );
60 zPtr->sign = uiA64>>63;
61 zPtr->v64 = NaNSig.v64;
62 zPtr->v0 = NaNSig.v0;
63
64}
65
deps/SoftFloat-3e/source/8086/s_f16UIToCommonNaN.c created+59
......@@ -0,0 +1,59 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming `uiA' has the bit pattern of a 16-bit floating-point NaN, converts
44| this NaN to the common NaN form, and stores the resulting common NaN at the
45| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
46| exception is raised.
47*----------------------------------------------------------------------------*/
48void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr )
49{
50
51 if ( softfloat_isSigNaNF16UI( uiA ) ) {
52 softfloat_raiseFlags( softfloat_flag_invalid );
53 }
54 zPtr->sign = uiA>>15;
55 zPtr->v64 = (uint_fast64_t) uiA<<54;
56 zPtr->v0 = 0;
57
58}
59
deps/SoftFloat-3e/source/8086/s_f32UIToCommonNaN.c created+59
......@@ -0,0 +1,59 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming `uiA' has the bit pattern of a 32-bit floating-point NaN, converts
44| this NaN to the common NaN form, and stores the resulting common NaN at the
45| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
46| exception is raised.
47*----------------------------------------------------------------------------*/
48void softfloat_f32UIToCommonNaN( uint_fast32_t uiA, struct commonNaN *zPtr )
49{
50
51 if ( softfloat_isSigNaNF32UI( uiA ) ) {
52 softfloat_raiseFlags( softfloat_flag_invalid );
53 }
54 zPtr->sign = uiA>>31;
55 zPtr->v64 = (uint_fast64_t) uiA<<41;
56 zPtr->v0 = 0;
57
58}
59
deps/SoftFloat-3e/source/8086/s_f64UIToCommonNaN.c created+59
......@@ -0,0 +1,59 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming `uiA' has the bit pattern of a 64-bit floating-point NaN, converts
44| this NaN to the common NaN form, and stores the resulting common NaN at the
45| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
46| exception is raised.
47*----------------------------------------------------------------------------*/
48void softfloat_f64UIToCommonNaN( uint_fast64_t uiA, struct commonNaN *zPtr )
49{
50
51 if ( softfloat_isSigNaNF64UI( uiA ) ) {
52 softfloat_raiseFlags( softfloat_flag_invalid );
53 }
54 zPtr->sign = uiA>>63;
55 zPtr->v64 = uiA<<12;
56 zPtr->v0 = 0;
57
58}
59
deps/SoftFloat-3e/source/8086/s_propagateNaNExtF80M.c created+107
......@@ -0,0 +1,107 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Assuming at least one of the two 80-bit extended floating-point values
46| pointed to by `aSPtr' and `bSPtr' is a NaN, stores the combined NaN result
47| at the location pointed to by `zSPtr'. If either original floating-point
48| value is a signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50void
51 softfloat_propagateNaNExtF80M(
52 const struct extFloat80M *aSPtr,
53 const struct extFloat80M *bSPtr,
54 struct extFloat80M *zSPtr
55 )
56{
57 bool isSigNaNA;
58 const struct extFloat80M *sPtr;
59 bool isSigNaNB;
60 uint_fast16_t uiB64;
61 uint64_t uiB0;
62 uint_fast16_t uiA64;
63 uint64_t uiA0;
64 uint_fast16_t uiMagA64, uiMagB64;
65
66 isSigNaNA = extF80M_isSignalingNaN( (const extFloat80_t *) aSPtr );
67 sPtr = aSPtr;
68 if ( ! bSPtr ) {
69 if ( isSigNaNA ) softfloat_raiseFlags( softfloat_flag_invalid );
70 goto copy;
71 }
72 isSigNaNB = extF80M_isSignalingNaN( (const extFloat80_t *) bSPtr );
73 if ( isSigNaNA | isSigNaNB ) {
74 softfloat_raiseFlags( softfloat_flag_invalid );
75 if ( isSigNaNA ) {
76 uiB64 = bSPtr->signExp;
77 if ( isSigNaNB ) goto returnLargerUIMag;
78 uiB0 = bSPtr->signif;
79 if ( isNaNExtF80UI( uiB64, uiB0 ) ) goto copyB;
80 goto copy;
81 } else {
82 uiA64 = aSPtr->signExp;
83 uiA0 = aSPtr->signif;
84 if ( isNaNExtF80UI( uiA64, uiA0 ) ) goto copy;
85 goto copyB;
86 }
87 }
88 uiB64 = bSPtr->signExp;
89 returnLargerUIMag:
90 uiA64 = aSPtr->signExp;
91 uiMagA64 = uiA64 & 0x7FFF;
92 uiMagB64 = uiB64 & 0x7FFF;
93 if ( uiMagA64 < uiMagB64 ) goto copyB;
94 if ( uiMagB64 < uiMagA64 ) goto copy;
95 uiA0 = aSPtr->signif;
96 uiB0 = bSPtr->signif;
97 if ( uiA0 < uiB0 ) goto copyB;
98 if ( uiB0 < uiA0 ) goto copy;
99 if ( uiA64 < uiB64 ) goto copy;
100 copyB:
101 sPtr = bSPtr;
102 copy:
103 zSPtr->signExp = sPtr->signExp;
104 zSPtr->signif = sPtr->signif | UINT64_C( 0xC000000000000000 );
105
106}
107
deps/SoftFloat-3e/source/8086/s_propagateNaNExtF80UI.c created+106
......@@ -0,0 +1,106 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2018 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting the unsigned integer formed from concatenating 'uiA64' and
46| 'uiA0' as an 80-bit extended floating-point value, and likewise interpreting
47| the unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
48| 80-bit extended floating-point value, and assuming at least on of these
49| floating-point values is a NaN, returns the bit pattern of the combined NaN
50| result. If either original floating-point value is a signaling NaN, the
51| invalid exception is raised.
52*----------------------------------------------------------------------------*/
53struct uint128
54 softfloat_propagateNaNExtF80UI(
55 uint_fast16_t uiA64,
56 uint_fast64_t uiA0,
57 uint_fast16_t uiB64,
58 uint_fast64_t uiB0
59 )
60{
61 bool isSigNaNA, isSigNaNB;
62 uint_fast64_t uiNonsigA0, uiNonsigB0;
63 uint_fast16_t uiMagA64, uiMagB64;
64 struct uint128 uiZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 isSigNaNA = softfloat_isSigNaNExtF80UI( uiA64, uiA0 );
69 isSigNaNB = softfloat_isSigNaNExtF80UI( uiB64, uiB0 );
70 /*------------------------------------------------------------------------
71 | Make NaNs non-signaling.
72 *------------------------------------------------------------------------*/
73 uiNonsigA0 = uiA0 | UINT64_C( 0xC000000000000000 );
74 uiNonsigB0 = uiB0 | UINT64_C( 0xC000000000000000 );
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( isSigNaNA | isSigNaNB ) {
78 softfloat_raiseFlags( softfloat_flag_invalid );
79 if ( isSigNaNA ) {
80 if ( isSigNaNB ) goto returnLargerMag;
81 if ( isNaNExtF80UI( uiB64, uiB0 ) ) goto returnB;
82 goto returnA;
83 } else {
84 if ( isNaNExtF80UI( uiA64, uiA0 ) ) goto returnA;
85 goto returnB;
86 }
87 }
88 returnLargerMag:
89 uiMagA64 = uiA64 & 0x7FFF;
90 uiMagB64 = uiB64 & 0x7FFF;
91 if ( uiMagA64 < uiMagB64 ) goto returnB;
92 if ( uiMagB64 < uiMagA64 ) goto returnA;
93 if ( uiA0 < uiB0 ) goto returnB;
94 if ( uiB0 < uiA0 ) goto returnA;
95 if ( uiA64 < uiB64 ) goto returnA;
96 returnB:
97 uiZ.v64 = uiB64;
98 uiZ.v0 = uiNonsigB0;
99 return uiZ;
100 returnA:
101 uiZ.v64 = uiA64;
102 uiZ.v0 = uiNonsigA0;
103 return uiZ;
104
105}
106
deps/SoftFloat-3e/source/8086/s_propagateNaNF128M.c created+108
......@@ -0,0 +1,108 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Assuming at least one of the two 128-bit floating-point values pointed to by
46| `aWPtr' and `bWPtr' is a NaN, stores the combined NaN result at the location
47| pointed to by `zWPtr'. If either original floating-point value is a
48| signaling NaN, the invalid exception is raised. Each of `aWPtr', `bWPtr',
49| and `zWPtr' points to an array of four 32-bit elements that concatenate in
50| the platform's normal endian order to form a 128-bit floating-point value.
51*----------------------------------------------------------------------------*/
52void
53 softfloat_propagateNaNF128M(
54 const uint32_t *aWPtr, const uint32_t *bWPtr, uint32_t *zWPtr )
55{
56 bool isSigNaNA;
57 const uint32_t *ptr;
58 bool isSigNaNB;
59 uint32_t uiA96, uiB96, wordMagA, wordMagB;
60
61 isSigNaNA = f128M_isSignalingNaN( (const float128_t *) aWPtr );
62 ptr = aWPtr;
63 if ( ! bWPtr ) {
64 if ( isSigNaNA ) softfloat_raiseFlags( softfloat_flag_invalid );
65 goto copy;
66 }
67 isSigNaNB = f128M_isSignalingNaN( (const float128_t *) bWPtr );
68 if ( isSigNaNA | isSigNaNB ) {
69 softfloat_raiseFlags( softfloat_flag_invalid );
70 if ( isSigNaNA ) {
71 if ( isSigNaNB ) goto returnLargerUIMag;
72 if ( softfloat_isNaNF128M( bWPtr ) ) goto copyB;
73 goto copy;
74 } else {
75 if ( softfloat_isNaNF128M( aWPtr ) ) goto copy;
76 goto copyB;
77 }
78 }
79 returnLargerUIMag:
80 uiA96 = aWPtr[indexWordHi( 4 )];
81 uiB96 = bWPtr[indexWordHi( 4 )];
82 wordMagA = uiA96 & 0x7FFFFFFF;
83 wordMagB = uiB96 & 0x7FFFFFFF;
84 if ( wordMagA < wordMagB ) goto copyB;
85 if ( wordMagB < wordMagA ) goto copy;
86 wordMagA = aWPtr[indexWord( 4, 2 )];
87 wordMagB = bWPtr[indexWord( 4, 2 )];
88 if ( wordMagA < wordMagB ) goto copyB;
89 if ( wordMagB < wordMagA ) goto copy;
90 wordMagA = aWPtr[indexWord( 4, 1 )];
91 wordMagB = bWPtr[indexWord( 4, 1 )];
92 if ( wordMagA < wordMagB ) goto copyB;
93 if ( wordMagB < wordMagA ) goto copy;
94 wordMagA = aWPtr[indexWord( 4, 0 )];
95 wordMagB = bWPtr[indexWord( 4, 0 )];
96 if ( wordMagA < wordMagB ) goto copyB;
97 if ( wordMagB < wordMagA ) goto copy;
98 if ( uiA96 < uiB96 ) goto copy;
99 copyB:
100 ptr = bWPtr;
101 copy:
102 zWPtr[indexWordHi( 4 )] = ptr[indexWordHi( 4 )] | 0x00008000;
103 zWPtr[indexWord( 4, 2 )] = ptr[indexWord( 4, 2 )];
104 zWPtr[indexWord( 4, 1 )] = ptr[indexWord( 4, 1 )];
105 zWPtr[indexWord( 4, 0 )] = ptr[indexWord( 4, 0 )];
106
107}
108
deps/SoftFloat-3e/source/8086/s_propagateNaNF128UI.c created+105
......@@ -0,0 +1,105 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2018 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting the unsigned integer formed from concatenating 'uiA64' and
46| 'uiA0' as a 128-bit floating-point value, and likewise interpreting the
47| unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
48| 128-bit floating-point value, and assuming at least on of these floating-
49| point values is a NaN, returns the bit pattern of the combined NaN result.
50| If either original floating-point value is a signaling NaN, the invalid
51| exception is raised.
52*----------------------------------------------------------------------------*/
53struct uint128
54 softfloat_propagateNaNF128UI(
55 uint_fast64_t uiA64,
56 uint_fast64_t uiA0,
57 uint_fast64_t uiB64,
58 uint_fast64_t uiB0
59 )
60{
61 bool isSigNaNA, isSigNaNB;
62 uint_fast64_t uiNonsigA64, uiNonsigB64, uiMagA64, uiMagB64;
63 struct uint128 uiZ;
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 isSigNaNA = softfloat_isSigNaNF128UI( uiA64, uiA0 );
68 isSigNaNB = softfloat_isSigNaNF128UI( uiB64, uiB0 );
69 /*------------------------------------------------------------------------
70 | Make NaNs non-signaling.
71 *------------------------------------------------------------------------*/
72 uiNonsigA64 = uiA64 | UINT64_C( 0x0000800000000000 );
73 uiNonsigB64 = uiB64 | UINT64_C( 0x0000800000000000 );
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( isSigNaNA | isSigNaNB ) {
77 softfloat_raiseFlags( softfloat_flag_invalid );
78 if ( isSigNaNA ) {
79 if ( isSigNaNB ) goto returnLargerMag;
80 if ( isNaNF128UI( uiB64, uiB0 ) ) goto returnB;
81 goto returnA;
82 } else {
83 if ( isNaNF128UI( uiA64, uiA0 ) ) goto returnA;
84 goto returnB;
85 }
86 }
87 returnLargerMag:
88 uiMagA64 = uiA64 & UINT64_C( 0x7FFFFFFFFFFFFFFF );
89 uiMagB64 = uiB64 & UINT64_C( 0x7FFFFFFFFFFFFFFF );
90 if ( uiMagA64 < uiMagB64 ) goto returnB;
91 if ( uiMagB64 < uiMagA64 ) goto returnA;
92 if ( uiA0 < uiB0 ) goto returnB;
93 if ( uiB0 < uiA0 ) goto returnA;
94 if ( uiNonsigA64 < uiNonsigB64 ) goto returnA;
95 returnB:
96 uiZ.v64 = uiNonsigB64;
97 uiZ.v0 = uiB0;
98 return uiZ;
99 returnA:
100 uiZ.v64 = uiNonsigA64;
101 uiZ.v0 = uiA0;
102 return uiZ;
103
104}
105
deps/SoftFloat-3e/source/8086/s_propagateNaNF16UI.c created+84
......@@ -0,0 +1,84 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2018 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting 'uiA' and 'uiB' as the bit patterns of two 16-bit floating-
46| point values, at least one of which is a NaN, returns the bit pattern of
47| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
48| signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50uint_fast16_t
51 softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB )
52{
53 bool isSigNaNA, isSigNaNB;
54 uint_fast16_t uiNonsigA, uiNonsigB, uiMagA, uiMagB;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 isSigNaNA = softfloat_isSigNaNF16UI( uiA );
59 isSigNaNB = softfloat_isSigNaNF16UI( uiB );
60 /*------------------------------------------------------------------------
61 | Make NaNs non-signaling.
62 *------------------------------------------------------------------------*/
63 uiNonsigA = uiA | 0x0200;
64 uiNonsigB = uiB | 0x0200;
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( isSigNaNA | isSigNaNB ) {
68 softfloat_raiseFlags( softfloat_flag_invalid );
69 if ( isSigNaNA ) {
70 if ( isSigNaNB ) goto returnLargerMag;
71 return isNaNF16UI( uiB ) ? uiNonsigB : uiNonsigA;
72 } else {
73 return isNaNF16UI( uiA ) ? uiNonsigA : uiNonsigB;
74 }
75 }
76 returnLargerMag:
77 uiMagA = uiA & 0x7FFF;
78 uiMagB = uiB & 0x7FFF;
79 if ( uiMagA < uiMagB ) return uiNonsigB;
80 if ( uiMagB < uiMagA ) return uiNonsigA;
81 return (uiNonsigA < uiNonsigB) ? uiNonsigA : uiNonsigB;
82
83}
84
deps/SoftFloat-3e/source/8086/s_propagateNaNF32UI.c created+84
......@@ -0,0 +1,84 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2018 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting 'uiA' and 'uiB' as the bit patterns of two 32-bit floating-
46| point values, at least one of which is a NaN, returns the bit pattern of
47| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
48| signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50uint_fast32_t
51 softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB )
52{
53 bool isSigNaNA, isSigNaNB;
54 uint_fast32_t uiNonsigA, uiNonsigB, uiMagA, uiMagB;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 isSigNaNA = softfloat_isSigNaNF32UI( uiA );
59 isSigNaNB = softfloat_isSigNaNF32UI( uiB );
60 /*------------------------------------------------------------------------
61 | Make NaNs non-signaling.
62 *------------------------------------------------------------------------*/
63 uiNonsigA = uiA | 0x00400000;
64 uiNonsigB = uiB | 0x00400000;
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( isSigNaNA | isSigNaNB ) {
68 softfloat_raiseFlags( softfloat_flag_invalid );
69 if ( isSigNaNA ) {
70 if ( isSigNaNB ) goto returnLargerMag;
71 return isNaNF32UI( uiB ) ? uiNonsigB : uiNonsigA;
72 } else {
73 return isNaNF32UI( uiA ) ? uiNonsigA : uiNonsigB;
74 }
75 }
76 returnLargerMag:
77 uiMagA = uiA & 0x7FFFFFFF;
78 uiMagB = uiB & 0x7FFFFFFF;
79 if ( uiMagA < uiMagB ) return uiNonsigB;
80 if ( uiMagB < uiMagA ) return uiNonsigA;
81 return (uiNonsigA < uiNonsigB) ? uiNonsigA : uiNonsigB;
82
83}
84
deps/SoftFloat-3e/source/8086/s_propagateNaNF64UI.c created+84
......@@ -0,0 +1,84 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2018 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting 'uiA' and 'uiB' as the bit patterns of two 64-bit floating-
46| point values, at least one of which is a NaN, returns the bit pattern of
47| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
48| signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50uint_fast64_t
51 softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB )
52{
53 bool isSigNaNA, isSigNaNB;
54 uint_fast64_t uiNonsigA, uiNonsigB, uiMagA, uiMagB;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 isSigNaNA = softfloat_isSigNaNF64UI( uiA );
59 isSigNaNB = softfloat_isSigNaNF64UI( uiB );
60 /*------------------------------------------------------------------------
61 | Make NaNs non-signaling.
62 *------------------------------------------------------------------------*/
63 uiNonsigA = uiA | UINT64_C( 0x0008000000000000 );
64 uiNonsigB = uiB | UINT64_C( 0x0008000000000000 );
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( isSigNaNA | isSigNaNB ) {
68 softfloat_raiseFlags( softfloat_flag_invalid );
69 if ( isSigNaNA ) {
70 if ( isSigNaNB ) goto returnLargerMag;
71 return isNaNF64UI( uiB ) ? uiNonsigB : uiNonsigA;
72 } else {
73 return isNaNF64UI( uiA ) ? uiNonsigA : uiNonsigB;
74 }
75 }
76 returnLargerMag:
77 uiMagA = uiA & UINT64_C( 0x7FFFFFFFFFFFFFFF );
78 uiMagB = uiB & UINT64_C( 0x7FFFFFFFFFFFFFFF );
79 if ( uiMagA < uiMagB ) return uiNonsigB;
80 if ( uiMagB < uiMagA ) return uiNonsigA;
81 return (uiNonsigA < uiNonsigB) ? uiNonsigA : uiNonsigB;
82
83}
84
deps/SoftFloat-3e/source/8086/softfloat_raiseFlags.c created+52
......@@ -0,0 +1,52 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include "platform.h"
38#include "softfloat.h"
39
40/*----------------------------------------------------------------------------
41| Raises the exceptions specified by `flags'. Floating-point traps can be
42| defined here if desired. It is currently not possible for such a trap
43| to substitute a result value. If traps are not implemented, this routine
44| should be simply `softfloat_exceptionFlags |= flags;'.
45*----------------------------------------------------------------------------*/
46void softfloat_raiseFlags( uint_fast8_t flags )
47{
48
49 softfloat_exceptionFlags |= flags;
50
51}
52
deps/SoftFloat-3e/source/8086/specialize.h created+376
......@@ -0,0 +1,376 @@
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2018 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#ifndef specialize_h
38#define specialize_h 1
39
40#include <stdbool.h>
41#include <stdint.h>
42#include "primitiveTypes.h"
43#include "softfloat.h"
44
45/*----------------------------------------------------------------------------
46| Default value for 'softfloat_detectTininess'.
47*----------------------------------------------------------------------------*/
48#define init_detectTininess softfloat_tininess_afterRounding
49
50/*----------------------------------------------------------------------------
51| The values to return on conversions to 32-bit integer formats that raise an
52| invalid exception.
53*----------------------------------------------------------------------------*/
54#define ui32_fromPosOverflow 0xFFFFFFFF
55#define ui32_fromNegOverflow 0xFFFFFFFF
56#define ui32_fromNaN 0xFFFFFFFF
57#define i32_fromPosOverflow (-0x7FFFFFFF - 1)
58#define i32_fromNegOverflow (-0x7FFFFFFF - 1)
59#define i32_fromNaN (-0x7FFFFFFF - 1)
60
61/*----------------------------------------------------------------------------
62| The values to return on conversions to 64-bit integer formats that raise an
63| invalid exception.
64*----------------------------------------------------------------------------*/
65#define ui64_fromPosOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
66#define ui64_fromNegOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
67#define ui64_fromNaN UINT64_C( 0xFFFFFFFFFFFFFFFF )
68#define i64_fromPosOverflow (-INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
69#define i64_fromNegOverflow (-INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
70#define i64_fromNaN (-INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
71
72/*----------------------------------------------------------------------------
73| "Common NaN" structure, used to transfer NaN representations from one format
74| to another.
75*----------------------------------------------------------------------------*/
76struct commonNaN {
77 bool sign;
78#ifdef LITTLEENDIAN
79 uint64_t v0, v64;
80#else
81 uint64_t v64, v0;
82#endif
83};
84
85/*----------------------------------------------------------------------------
86| The bit pattern for a default generated 16-bit floating-point NaN.
87*----------------------------------------------------------------------------*/
88#define defaultNaNF16UI 0xFE00
89
90/*----------------------------------------------------------------------------
91| Returns true when 16-bit unsigned integer 'uiA' has the bit pattern of a
92| 16-bit floating-point signaling NaN.
93| Note: This macro evaluates its argument more than once.
94*----------------------------------------------------------------------------*/
95#define softfloat_isSigNaNF16UI( uiA ) ((((uiA) & 0x7E00) == 0x7C00) && ((uiA) & 0x01FF))
96
97/*----------------------------------------------------------------------------
98| Assuming 'uiA' has the bit pattern of a 16-bit floating-point NaN, converts
99| this NaN to the common NaN form, and stores the resulting common NaN at the
100| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
101| exception is raised.
102*----------------------------------------------------------------------------*/
103void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr );
104
105/*----------------------------------------------------------------------------
106| Converts the common NaN pointed to by 'aPtr' into a 16-bit floating-point
107| NaN, and returns the bit pattern of this value as an unsigned integer.
108*----------------------------------------------------------------------------*/
109uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr );
110
111/*----------------------------------------------------------------------------
112| Interpreting 'uiA' and 'uiB' as the bit patterns of two 16-bit floating-
113| point values, at least one of which is a NaN, returns the bit pattern of
114| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
115| signaling NaN, the invalid exception is raised.
116*----------------------------------------------------------------------------*/
117uint_fast16_t
118 softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB );
119
120/*----------------------------------------------------------------------------
121| The bit pattern for a default generated 32-bit floating-point NaN.
122*----------------------------------------------------------------------------*/
123#define defaultNaNF32UI 0xFFC00000
124
125/*----------------------------------------------------------------------------
126| Returns true when 32-bit unsigned integer 'uiA' has the bit pattern of a
127| 32-bit floating-point signaling NaN.
128| Note: This macro evaluates its argument more than once.
129*----------------------------------------------------------------------------*/
130#define softfloat_isSigNaNF32UI( uiA ) ((((uiA) & 0x7FC00000) == 0x7F800000) && ((uiA) & 0x003FFFFF))
131
132/*----------------------------------------------------------------------------
133| Assuming 'uiA' has the bit pattern of a 32-bit floating-point NaN, converts
134| this NaN to the common NaN form, and stores the resulting common NaN at the
135| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
136| exception is raised.
137*----------------------------------------------------------------------------*/
138void softfloat_f32UIToCommonNaN( uint_fast32_t uiA, struct commonNaN *zPtr );
139
140/*----------------------------------------------------------------------------
141| Converts the common NaN pointed to by 'aPtr' into a 32-bit floating-point
142| NaN, and returns the bit pattern of this value as an unsigned integer.
143*----------------------------------------------------------------------------*/
144uint_fast32_t softfloat_commonNaNToF32UI( const struct commonNaN *aPtr );
145
146/*----------------------------------------------------------------------------
147| Interpreting 'uiA' and 'uiB' as the bit patterns of two 32-bit floating-
148| point values, at least one of which is a NaN, returns the bit pattern of
149| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
150| signaling NaN, the invalid exception is raised.
151*----------------------------------------------------------------------------*/
152uint_fast32_t
153 softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB );
154
155/*----------------------------------------------------------------------------
156| The bit pattern for a default generated 64-bit floating-point NaN.
157*----------------------------------------------------------------------------*/
158#define defaultNaNF64UI UINT64_C( 0xFFF8000000000000 )
159
160/*----------------------------------------------------------------------------
161| Returns true when 64-bit unsigned integer 'uiA' has the bit pattern of a
162| 64-bit floating-point signaling NaN.
163| Note: This macro evaluates its argument more than once.
164*----------------------------------------------------------------------------*/
165#define softfloat_isSigNaNF64UI( uiA ) ((((uiA) & UINT64_C( 0x7FF8000000000000 )) == UINT64_C( 0x7FF0000000000000 )) && ((uiA) & UINT64_C( 0x0007FFFFFFFFFFFF )))
166
167/*----------------------------------------------------------------------------
168| Assuming 'uiA' has the bit pattern of a 64-bit floating-point NaN, converts
169| this NaN to the common NaN form, and stores the resulting common NaN at the
170| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
171| exception is raised.
172*----------------------------------------------------------------------------*/
173void softfloat_f64UIToCommonNaN( uint_fast64_t uiA, struct commonNaN *zPtr );
174
175/*----------------------------------------------------------------------------
176| Converts the common NaN pointed to by 'aPtr' into a 64-bit floating-point
177| NaN, and returns the bit pattern of this value as an unsigned integer.
178*----------------------------------------------------------------------------*/
179uint_fast64_t softfloat_commonNaNToF64UI( const struct commonNaN *aPtr );
180
181/*----------------------------------------------------------------------------
182| Interpreting 'uiA' and 'uiB' as the bit patterns of two 64-bit floating-
183| point values, at least one of which is a NaN, returns the bit pattern of
184| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
185| signaling NaN, the invalid exception is raised.
186*----------------------------------------------------------------------------*/
187uint_fast64_t
188 softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB );
189
190/*----------------------------------------------------------------------------
191| The bit pattern for a default generated 80-bit extended floating-point NaN.
192*----------------------------------------------------------------------------*/
193#define defaultNaNExtF80UI64 0xFFFF
194#define defaultNaNExtF80UI0 UINT64_C( 0xC000000000000000 )
195
196/*----------------------------------------------------------------------------
197| Returns true when the 80-bit unsigned integer formed from concatenating
198| 16-bit 'uiA64' and 64-bit 'uiA0' has the bit pattern of an 80-bit extended
199| floating-point signaling NaN.
200| Note: This macro evaluates its arguments more than once.
201*----------------------------------------------------------------------------*/
202#define softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ((((uiA64) & 0x7FFF) == 0x7FFF) && ! ((uiA0) & UINT64_C( 0x4000000000000000 )) && ((uiA0) & UINT64_C( 0x3FFFFFFFFFFFFFFF )))
203
204#ifdef SOFTFLOAT_FAST_INT64
205
206/*----------------------------------------------------------------------------
207| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is
208| defined.
209*----------------------------------------------------------------------------*/
210
211/*----------------------------------------------------------------------------
212| Assuming the unsigned integer formed from concatenating 'uiA64' and 'uiA0'
213| has the bit pattern of an 80-bit extended floating-point NaN, converts
214| this NaN to the common NaN form, and stores the resulting common NaN at the
215| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
216| exception is raised.
217*----------------------------------------------------------------------------*/
218void
219 softfloat_extF80UIToCommonNaN(
220 uint_fast16_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr );
221
222/*----------------------------------------------------------------------------
223| Converts the common NaN pointed to by 'aPtr' into an 80-bit extended
224| floating-point NaN, and returns the bit pattern of this value as an unsigned
225| integer.
226*----------------------------------------------------------------------------*/
227struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr );
228
229/*----------------------------------------------------------------------------
230| Interpreting the unsigned integer formed from concatenating 'uiA64' and
231| 'uiA0' as an 80-bit extended floating-point value, and likewise interpreting
232| the unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
233| 80-bit extended floating-point value, and assuming at least on of these
234| floating-point values is a NaN, returns the bit pattern of the combined NaN
235| result. If either original floating-point value is a signaling NaN, the
236| invalid exception is raised.
237*----------------------------------------------------------------------------*/
238struct uint128
239 softfloat_propagateNaNExtF80UI(
240 uint_fast16_t uiA64,
241 uint_fast64_t uiA0,
242 uint_fast16_t uiB64,
243 uint_fast64_t uiB0
244 );
245
246/*----------------------------------------------------------------------------
247| The bit pattern for a default generated 128-bit floating-point NaN.
248*----------------------------------------------------------------------------*/
249#define defaultNaNF128UI64 UINT64_C( 0xFFFF800000000000 )
250#define defaultNaNF128UI0 UINT64_C( 0 )
251
252/*----------------------------------------------------------------------------
253| Returns true when the 128-bit unsigned integer formed from concatenating
254| 64-bit 'uiA64' and 64-bit 'uiA0' has the bit pattern of a 128-bit floating-
255| point signaling NaN.
256| Note: This macro evaluates its arguments more than once.
257*----------------------------------------------------------------------------*/
258#define softfloat_isSigNaNF128UI( uiA64, uiA0 ) ((((uiA64) & UINT64_C( 0x7FFF800000000000 )) == UINT64_C( 0x7FFF000000000000 )) && ((uiA0) || ((uiA64) & UINT64_C( 0x00007FFFFFFFFFFF ))))
259
260/*----------------------------------------------------------------------------
261| Assuming the unsigned integer formed from concatenating 'uiA64' and 'uiA0'
262| has the bit pattern of a 128-bit floating-point NaN, converts this NaN to
263| the common NaN form, and stores the resulting common NaN at the location
264| pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid exception
265| is raised.
266*----------------------------------------------------------------------------*/
267void
268 softfloat_f128UIToCommonNaN(
269 uint_fast64_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr );
270
271/*----------------------------------------------------------------------------
272| Converts the common NaN pointed to by 'aPtr' into a 128-bit floating-point
273| NaN, and returns the bit pattern of this value as an unsigned integer.
274*----------------------------------------------------------------------------*/
275struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN * );
276
277/*----------------------------------------------------------------------------
278| Interpreting the unsigned integer formed from concatenating 'uiA64' and
279| 'uiA0' as a 128-bit floating-point value, and likewise interpreting the
280| unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
281| 128-bit floating-point value, and assuming at least on of these floating-
282| point values is a NaN, returns the bit pattern of the combined NaN result.
283| If either original floating-point value is a signaling NaN, the invalid
284| exception is raised.
285*----------------------------------------------------------------------------*/
286struct uint128
287 softfloat_propagateNaNF128UI(
288 uint_fast64_t uiA64,
289 uint_fast64_t uiA0,
290 uint_fast64_t uiB64,
291 uint_fast64_t uiB0
292 );
293
294#else
295
296/*----------------------------------------------------------------------------
297| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is not
298| defined.
299*----------------------------------------------------------------------------*/
300
301/*----------------------------------------------------------------------------
302| Assuming the 80-bit extended floating-point value pointed to by 'aSPtr' is
303| a NaN, converts this NaN to the common NaN form, and stores the resulting
304| common NaN at the location pointed to by 'zPtr'. If the NaN is a signaling
305| NaN, the invalid exception is raised.
306*----------------------------------------------------------------------------*/
307void
308 softfloat_extF80MToCommonNaN(
309 const struct extFloat80M *aSPtr, struct commonNaN *zPtr );
310
311/*----------------------------------------------------------------------------
312| Converts the common NaN pointed to by 'aPtr' into an 80-bit extended
313| floating-point NaN, and stores this NaN at the location pointed to by
314| 'zSPtr'.
315*----------------------------------------------------------------------------*/
316void
317 softfloat_commonNaNToExtF80M(
318 const struct commonNaN *aPtr, struct extFloat80M *zSPtr );
319
320/*----------------------------------------------------------------------------
321| Assuming at least one of the two 80-bit extended floating-point values
322| pointed to by 'aSPtr' and 'bSPtr' is a NaN, stores the combined NaN result
323| at the location pointed to by 'zSPtr'. If either original floating-point
324| value is a signaling NaN, the invalid exception is raised.
325*----------------------------------------------------------------------------*/
326void
327 softfloat_propagateNaNExtF80M(
328 const struct extFloat80M *aSPtr,
329 const struct extFloat80M *bSPtr,
330 struct extFloat80M *zSPtr
331 );
332
333/*----------------------------------------------------------------------------
334| The bit pattern for a default generated 128-bit floating-point NaN.
335*----------------------------------------------------------------------------*/
336#define defaultNaNF128UI96 0xFFFF8000
337#define defaultNaNF128UI64 0
338#define defaultNaNF128UI32 0
339#define defaultNaNF128UI0 0
340
341/*----------------------------------------------------------------------------
342| Assuming the 128-bit floating-point value pointed to by 'aWPtr' is a NaN,
343| converts this NaN to the common NaN form, and stores the resulting common
344| NaN at the location pointed to by 'zPtr'. If the NaN is a signaling NaN,
345| the invalid exception is raised. Argument 'aWPtr' points to an array of
346| four 32-bit elements that concatenate in the platform's normal endian order
347| to form a 128-bit floating-point value.
348*----------------------------------------------------------------------------*/
349void
350 softfloat_f128MToCommonNaN( const uint32_t *aWPtr, struct commonNaN *zPtr );
351
352/*----------------------------------------------------------------------------
353| Converts the common NaN pointed to by 'aPtr' into a 128-bit floating-point
354| NaN, and stores this NaN at the location pointed to by 'zWPtr'. Argument
355| 'zWPtr' points to an array of four 32-bit elements that concatenate in the
356| platform's normal endian order to form a 128-bit floating-point value.
357*----------------------------------------------------------------------------*/
358void
359 softfloat_commonNaNToF128M( const struct commonNaN *aPtr, uint32_t *zWPtr );
360
361/*----------------------------------------------------------------------------
362| Assuming at least one of the two 128-bit floating-point values pointed to by
363| 'aWPtr' and 'bWPtr' is a NaN, stores the combined NaN result at the location
364| pointed to by 'zWPtr'. If either original floating-point value is a
365| signaling NaN, the invalid exception is raised. Each of 'aWPtr', 'bWPtr',
366| and 'zWPtr' points to an array of four 32-bit elements that concatenate in
367| the platform's normal endian order to form a 128-bit floating-point value.
368*----------------------------------------------------------------------------*/
369void
370 softfloat_propagateNaNF128M(
371 const uint32_t *aWPtr, const uint32_t *bWPtr, uint32_t *zWPtr );
372
373#endif
374
375#endif
376
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/extF80M_isSignalingNaN.c created+57
......@@ -0,0 +1,57 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43*----------------------------------------------------------------------------*/
44bool extF80M_isSignalingNaN( const extFloat80_t *aPtr )
45{
46 const struct extFloat80M *aSPtr;
47 uint64_t uiA0;
48
49 aSPtr = (const struct extFloat80M *) aPtr;
50 if ( (aSPtr->signExp & 0x7FFF) != 0x7FFF ) return false;
51 uiA0 = aSPtr->signif;
52 return
53 ! (uiA0 & UINT64_C( 0x4000000000000000 ))
54 && (uiA0 & UINT64_C( 0x3FFFFFFFFFFFFFFF));
55
56}
57
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/f128M_isSignalingNaN.c created+60
......@@ -0,0 +1,60 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "primitives.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44*----------------------------------------------------------------------------*/
45bool f128M_isSignalingNaN( const float128_t *aPtr )
46{
47 const uint32_t *aWPtr;
48 uint32_t uiA96;
49
50 aWPtr = (const uint32_t *) aPtr;
51 uiA96 = aWPtr[indexWordHi( 4 )];
52 if ( (uiA96 & 0x7FFF8000) != 0x7FFF0000 ) return false;
53 return
54 ((uiA96 & 0x00007FFF) != 0)
55 || ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
56 | aWPtr[indexWord( 4, 0 )])
57 != 0);
58
59}
60
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_commonNaNToExtF80M.c created+57
......@@ -0,0 +1,57 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include "platform.h"
38#include "softfloat_types.h"
39
40#define softfloat_commonNaNToExtF80M softfloat_commonNaNToExtF80M
41#include "specialize.h"
42
43/*----------------------------------------------------------------------------
44| Converts the common NaN pointed to by 'aPtr' into an 80-bit extended
45| floating-point NaN, and stores this NaN at the location pointed to by
46| 'zSPtr'.
47*----------------------------------------------------------------------------*/
48void
49 softfloat_commonNaNToExtF80M(
50 const struct commonNaN *aPtr, struct extFloat80M *zSPtr )
51{
52
53 zSPtr->signExp = defaultNaNExtF80UI64;
54 zSPtr->signif = defaultNaNExtF80UI0;
55
56}
57
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_commonNaNToExtF80UI.c created+57
......@@ -0,0 +1,57 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include "platform.h"
38#include "primitiveTypes.h"
39
40#define softfloat_commonNaNToExtF80UI softfloat_commonNaNToExtF80UI
41#include "specialize.h"
42
43/*----------------------------------------------------------------------------
44| Converts the common NaN pointed to by 'aPtr' into an 80-bit extended
45| floating-point NaN, and returns the bit pattern of this value as an unsigned
46| integer.
47*----------------------------------------------------------------------------*/
48struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr )
49{
50 struct uint128 uiZ;
51
52 uiZ.v64 = defaultNaNExtF80UI64;
53 uiZ.v0 = defaultNaNExtF80UI0;
54 return uiZ;
55
56}
57
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_commonNaNToF128M.c created+60
......@@ -0,0 +1,60 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#define softfloat_commonNaNToF128M softfloat_commonNaNToF128M
42#include "specialize.h"
43
44/*----------------------------------------------------------------------------
45| Converts the common NaN pointed to by 'aPtr' into a 128-bit floating-point
46| NaN, and stores this NaN at the location pointed to by 'zWPtr'. Argument
47| 'zWPtr' points to an array of four 32-bit elements that concatenate in the
48| platform's normal endian order to form a 128-bit floating-point value.
49*----------------------------------------------------------------------------*/
50void
51 softfloat_commonNaNToF128M( const struct commonNaN *aPtr, uint32_t *zWPtr )
52{
53
54 zWPtr[indexWord( 4, 3 )] = defaultNaNF128UI96;
55 zWPtr[indexWord( 4, 2 )] = defaultNaNF128UI64;
56 zWPtr[indexWord( 4, 1 )] = defaultNaNF128UI32;
57 zWPtr[indexWord( 4, 0 )] = defaultNaNF128UI0;
58
59}
60
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_commonNaNToF128UI.c created+56
......@@ -0,0 +1,56 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include "platform.h"
38#include "primitiveTypes.h"
39
40#define softfloat_commonNaNToF128UI softfloat_commonNaNToF128UI
41#include "specialize.h"
42
43/*----------------------------------------------------------------------------
44| Converts the common NaN pointed to by 'aPtr' into a 128-bit floating-point
45| NaN, and returns the bit pattern of this value as an unsigned integer.
46*----------------------------------------------------------------------------*/
47struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN *aPtr )
48{
49 struct uint128 uiZ;
50
51 uiZ.v64 = defaultNaNF128UI64;
52 uiZ.v0 = defaultNaNF128UI0;
53 return uiZ;
54
55}
56
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_commonNaNToF16UI.c created+5
......@@ -0,0 +1,5 @@
1
2/*----------------------------------------------------------------------------
3| This file intentionally contains no code.
4*----------------------------------------------------------------------------*/
5
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_commonNaNToF32UI.c created+5
......@@ -0,0 +1,5 @@
1
2/*----------------------------------------------------------------------------
3| This file intentionally contains no code.
4*----------------------------------------------------------------------------*/
5
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_commonNaNToF64UI.c created+5
......@@ -0,0 +1,5 @@
1
2/*----------------------------------------------------------------------------
3| This file intentionally contains no code.
4*----------------------------------------------------------------------------*/
5
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_extF80MToCommonNaN.c created+5
......@@ -0,0 +1,5 @@
1
2/*----------------------------------------------------------------------------
3| This file intentionally contains no code.
4*----------------------------------------------------------------------------*/
5
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_extF80UIToCommonNaN.c created+5
......@@ -0,0 +1,5 @@
1
2/*----------------------------------------------------------------------------
3| This file intentionally contains no code.
4*----------------------------------------------------------------------------*/
5
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_f128MToCommonNaN.c created+5
......@@ -0,0 +1,5 @@
1
2/*----------------------------------------------------------------------------
3| This file intentionally contains no code.
4*----------------------------------------------------------------------------*/
5
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_f128UIToCommonNaN.c created+5
......@@ -0,0 +1,5 @@
1
2/*----------------------------------------------------------------------------
3| This file intentionally contains no code.
4*----------------------------------------------------------------------------*/
5
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_f16UIToCommonNaN.c created+5
......@@ -0,0 +1,5 @@
1
2/*----------------------------------------------------------------------------
3| This file intentionally contains no code.
4*----------------------------------------------------------------------------*/
5
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_f32UIToCommonNaN.c created+5
......@@ -0,0 +1,5 @@
1
2/*----------------------------------------------------------------------------
3| This file intentionally contains no code.
4*----------------------------------------------------------------------------*/
5
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_f64UIToCommonNaN.c created+5
......@@ -0,0 +1,5 @@
1
2/*----------------------------------------------------------------------------
3| This file intentionally contains no code.
4*----------------------------------------------------------------------------*/
5
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_propagateNaNExtF80M.c created+74
......@@ -0,0 +1,74 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Assuming at least one of the two 80-bit extended floating-point values
45| pointed to by 'aSPtr' and 'bSPtr' is a NaN, stores the combined NaN result
46| at the location pointed to by 'zSPtr'. If either original floating-point
47| value is a signaling NaN, the invalid exception is raised.
48*----------------------------------------------------------------------------*/
49void
50 softfloat_propagateNaNExtF80M(
51 const struct extFloat80M *aSPtr,
52 const struct extFloat80M *bSPtr,
53 struct extFloat80M *zSPtr
54 )
55{
56 uint_fast16_t ui64;
57 uint_fast64_t ui0;
58
59 ui64 = aSPtr->signExp;
60 ui0 = aSPtr->signif;
61 if (
62 softfloat_isSigNaNExtF80UI( ui64, ui0 )
63 || (bSPtr
64 && (ui64 = bSPtr->signExp,
65 ui0 = bSPtr->signif,
66 softfloat_isSigNaNExtF80UI( ui64, ui0 )))
67 ) {
68 softfloat_raiseFlags( softfloat_flag_invalid );
69 }
70 zSPtr->signExp = defaultNaNExtF80UI64;
71 zSPtr->signif = defaultNaNExtF80UI0;
72
73}
74
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_propagateNaNExtF80UI.c created+73
......@@ -0,0 +1,73 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Interpreting the unsigned integer formed from concatenating 'uiA64' and
45| 'uiA0' as an 80-bit extended floating-point value, and likewise interpreting
46| the unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
47| 80-bit extended floating-point value, and assuming at least on of these
48| floating-point values is a NaN, returns the bit pattern of the combined NaN
49| result. If either original floating-point value is a signaling NaN, the
50| invalid exception is raised.
51*----------------------------------------------------------------------------*/
52struct uint128
53 softfloat_propagateNaNExtF80UI(
54 uint_fast16_t uiA64,
55 uint_fast64_t uiA0,
56 uint_fast16_t uiB64,
57 uint_fast64_t uiB0
58 )
59{
60 struct uint128 uiZ;
61
62 if (
63 softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
64 || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
65 ) {
66 softfloat_raiseFlags( softfloat_flag_invalid );
67 }
68 uiZ.v64 = defaultNaNExtF80UI64;
69 uiZ.v0 = defaultNaNExtF80UI0;
70 return uiZ;
71
72}
73
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_propagateNaNF128M.c created+68
......@@ -0,0 +1,68 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Assuming at least one of the two 128-bit floating-point values pointed to by
45| 'aWPtr' and 'bWPtr' is a NaN, stores the combined NaN result at the location
46| pointed to by 'zWPtr'. If either original floating-point value is a
47| signaling NaN, the invalid exception is raised. Each of 'aWPtr', 'bWPtr',
48| and 'zWPtr' points to an array of four 32-bit elements that concatenate in
49| the platform's normal endian order to form a 128-bit floating-point value.
50*----------------------------------------------------------------------------*/
51void
52 softfloat_propagateNaNF128M(
53 const uint32_t *aWPtr, const uint32_t *bWPtr, uint32_t *zWPtr )
54{
55
56 if (
57 f128M_isSignalingNaN( (const float128_t *) aWPtr );
58 || (bWPtr && f128M_isSignalingNaN( (const float128_t *) bWPtr ))
59 ) {
60 softfloat_raiseFlags( softfloat_flag_invalid );
61 }
62 zWPtr[indexWord( 4, 3 )] = defaultNaNF128UI96;
63 zWPtr[indexWord( 4, 2 )] = defaultNaNF128UI64;
64 zWPtr[indexWord( 4, 1 )] = defaultNaNF128UI32;
65 zWPtr[indexWord( 4, 0 )] = defaultNaNF128UI0;
66
67}
68
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_propagateNaNF128UI.c created+73
......@@ -0,0 +1,73 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Interpreting the unsigned integer formed from concatenating 'uiA64' and
45| 'uiA0' as a 128-bit floating-point value, and likewise interpreting the
46| unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
47| 128-bit floating-point value, and assuming at least on of these floating-
48| point values is a NaN, returns the bit pattern of the combined NaN result.
49| If either original floating-point value is a signaling NaN, the invalid
50| exception is raised.
51*----------------------------------------------------------------------------*/
52struct uint128
53 softfloat_propagateNaNF128UI(
54 uint_fast64_t uiA64,
55 uint_fast64_t uiA0,
56 uint_fast64_t uiB64,
57 uint_fast64_t uiB0
58 )
59{
60 struct uint128 uiZ;
61
62 if (
63 softfloat_isSigNaNF128UI( uiA64, uiA0 )
64 || softfloat_isSigNaNF128UI( uiB64, uiB0 )
65 ) {
66 softfloat_raiseFlags( softfloat_flag_invalid );
67 }
68 uiZ.v64 = defaultNaNF128UI64;
69 uiZ.v0 = defaultNaNF128UI0;
70 return uiZ;
71
72}
73
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_propagateNaNF16UI.c created+58
......@@ -0,0 +1,58 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Interpreting 'uiA' and 'uiB' as the bit patterns of two 16-bit floating-
44| point values, at least one of which is a NaN, returns the bit pattern of
45| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
46| signaling NaN, the invalid exception is raised.
47*----------------------------------------------------------------------------*/
48uint_fast16_t
49 softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB )
50{
51
52 if ( softfloat_isSigNaNF16UI( uiA ) || softfloat_isSigNaNF16UI( uiB ) ) {
53 softfloat_raiseFlags( softfloat_flag_invalid );
54 }
55 return defaultNaNF16UI;
56
57}
58
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_propagateNaNF32UI.c created+58
......@@ -0,0 +1,58 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Interpreting 'uiA' and 'uiB' as the bit patterns of two 32-bit floating-
44| point values, at least one of which is a NaN, returns the bit pattern of
45| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
46| signaling NaN, the invalid exception is raised.
47*----------------------------------------------------------------------------*/
48uint_fast32_t
49 softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB )
50{
51
52 if ( softfloat_isSigNaNF32UI( uiA ) || softfloat_isSigNaNF32UI( uiB ) ) {
53 softfloat_raiseFlags( softfloat_flag_invalid );
54 }
55 return defaultNaNF32UI;
56
57}
58
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/s_propagateNaNF64UI.c created+58
......@@ -0,0 +1,58 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Interpreting 'uiA' and 'uiB' as the bit patterns of two 64-bit floating-
44| point values, at least one of which is a NaN, returns the bit pattern of
45| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
46| signaling NaN, the invalid exception is raised.
47*----------------------------------------------------------------------------*/
48uint_fast64_t
49 softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB )
50{
51
52 if ( softfloat_isSigNaNF64UI( uiA ) || softfloat_isSigNaNF64UI( uiB ) ) {
53 softfloat_raiseFlags( softfloat_flag_invalid );
54 }
55 return defaultNaNF64UI;
56
57}
58
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/softfloat_raiseFlags.c created+52
......@@ -0,0 +1,52 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include "platform.h"
38#include "softfloat.h"
39
40/*----------------------------------------------------------------------------
41| Raises the exceptions specified by 'flags'. Floating-point traps can be
42| defined here if desired. It is currently not possible for such a trap
43| to substitute a result value. If traps are not implemented, this routine
44| should be simply 'softfloat_exceptionFlags |= flags;'.
45*----------------------------------------------------------------------------*/
46void softfloat_raiseFlags( uint_fast8_t flags )
47{
48
49 softfloat_exceptionFlags |= flags;
50
51}
52
deps/SoftFloat-3e/source/ARM-VFPv2-defaultNaN/specialize.h created+407
......@@ -0,0 +1,407 @@
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#ifndef specialize_h
38#define specialize_h 1
39
40#include <stdbool.h>
41#include <stdint.h>
42#include "primitiveTypes.h"
43#include "softfloat.h"
44
45/*----------------------------------------------------------------------------
46| Default value for 'softfloat_detectTininess'.
47*----------------------------------------------------------------------------*/
48#define init_detectTininess softfloat_tininess_beforeRounding
49
50/*----------------------------------------------------------------------------
51| The values to return on conversions to 32-bit integer formats that raise an
52| invalid exception.
53*----------------------------------------------------------------------------*/
54#define ui32_fromPosOverflow 0xFFFFFFFF
55#define ui32_fromNegOverflow 0
56#define ui32_fromNaN 0
57#define i32_fromPosOverflow 0x7FFFFFFF
58#define i32_fromNegOverflow (-0x7FFFFFFF - 1)
59#define i32_fromNaN 0
60
61/*----------------------------------------------------------------------------
62| The values to return on conversions to 64-bit integer formats that raise an
63| invalid exception.
64*----------------------------------------------------------------------------*/
65#define ui64_fromPosOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
66#define ui64_fromNegOverflow 0
67#define ui64_fromNaN 0
68#define i64_fromPosOverflow INT64_C( 0x7FFFFFFFFFFFFFFF )
69#define i64_fromNegOverflow (-INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
70#define i64_fromNaN 0
71
72/*----------------------------------------------------------------------------
73| "Common NaN" structure, used to transfer NaN representations from one format
74| to another.
75*----------------------------------------------------------------------------*/
76struct commonNaN { char _unused; };
77
78/*----------------------------------------------------------------------------
79| The bit pattern for a default generated 16-bit floating-point NaN.
80*----------------------------------------------------------------------------*/
81#define defaultNaNF16UI 0x7E00
82
83/*----------------------------------------------------------------------------
84| Returns true when 16-bit unsigned integer 'uiA' has the bit pattern of a
85| 16-bit floating-point signaling NaN.
86| Note: This macro evaluates its argument more than once.
87*----------------------------------------------------------------------------*/
88#define softfloat_isSigNaNF16UI( uiA ) ((((uiA) & 0x7E00) == 0x7C00) && ((uiA) & 0x01FF))
89
90/*----------------------------------------------------------------------------
91| Assuming 'uiA' has the bit pattern of a 16-bit floating-point NaN, converts
92| this NaN to the common NaN form, and stores the resulting common NaN at the
93| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
94| exception is raised.
95*----------------------------------------------------------------------------*/
96#define softfloat_f16UIToCommonNaN( uiA, zPtr ) if ( ! ((uiA) & 0x0200) ) softfloat_raiseFlags( softfloat_flag_invalid )
97
98/*----------------------------------------------------------------------------
99| Converts the common NaN pointed to by 'aPtr' into a 16-bit floating-point
100| NaN, and returns the bit pattern of this value as an unsigned integer.
101*----------------------------------------------------------------------------*/
102#define softfloat_commonNaNToF16UI( aPtr ) ((uint_fast16_t) defaultNaNF16UI)
103
104/*----------------------------------------------------------------------------
105| Interpreting 'uiA' and 'uiB' as the bit patterns of two 16-bit floating-
106| point values, at least one of which is a NaN, returns the bit pattern of
107| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
108| signaling NaN, the invalid exception is raised.
109*----------------------------------------------------------------------------*/
110uint_fast16_t
111 softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB );
112
113/*----------------------------------------------------------------------------
114| The bit pattern for a default generated 32-bit floating-point NaN.
115*----------------------------------------------------------------------------*/
116#define defaultNaNF32UI 0x7FC00000
117
118/*----------------------------------------------------------------------------
119| Returns true when 32-bit unsigned integer 'uiA' has the bit pattern of a
120| 32-bit floating-point signaling NaN.
121| Note: This macro evaluates its argument more than once.
122*----------------------------------------------------------------------------*/
123#define softfloat_isSigNaNF32UI( uiA ) ((((uiA) & 0x7FC00000) == 0x7F800000) && ((uiA) & 0x003FFFFF))
124
125/*----------------------------------------------------------------------------
126| Assuming 'uiA' has the bit pattern of a 32-bit floating-point NaN, converts
127| this NaN to the common NaN form, and stores the resulting common NaN at the
128| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
129| exception is raised.
130*----------------------------------------------------------------------------*/
131#define softfloat_f32UIToCommonNaN( uiA, zPtr ) if ( ! ((uiA) & 0x00400000) ) softfloat_raiseFlags( softfloat_flag_invalid )
132
133/*----------------------------------------------------------------------------
134| Converts the common NaN pointed to by 'aPtr' into a 32-bit floating-point
135| NaN, and returns the bit pattern of this value as an unsigned integer.
136*----------------------------------------------------------------------------*/
137#define softfloat_commonNaNToF32UI( aPtr ) ((uint_fast32_t) defaultNaNF32UI)
138
139/*----------------------------------------------------------------------------
140| Interpreting 'uiA' and 'uiB' as the bit patterns of two 32-bit floating-
141| point values, at least one of which is a NaN, returns the bit pattern of
142| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
143| signaling NaN, the invalid exception is raised.
144*----------------------------------------------------------------------------*/
145uint_fast32_t
146 softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB );
147
148/*----------------------------------------------------------------------------
149| The bit pattern for a default generated 64-bit floating-point NaN.
150*----------------------------------------------------------------------------*/
151#define defaultNaNF64UI UINT64_C( 0x7FF8000000000000 )
152
153/*----------------------------------------------------------------------------
154| Returns true when 64-bit unsigned integer 'uiA' has the bit pattern of a
155| 64-bit floating-point signaling NaN.
156| Note: This macro evaluates its argument more than once.
157*----------------------------------------------------------------------------*/
158#define softfloat_isSigNaNF64UI( uiA ) ((((uiA) & UINT64_C( 0x7FF8000000000000 )) == UINT64_C( 0x7FF0000000000000 )) && ((uiA) & UINT64_C( 0x0007FFFFFFFFFFFF )))
159
160/*----------------------------------------------------------------------------
161| Assuming 'uiA' has the bit pattern of a 64-bit floating-point NaN, converts
162| this NaN to the common NaN form, and stores the resulting common NaN at the
163| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
164| exception is raised.
165*----------------------------------------------------------------------------*/
166#define softfloat_f64UIToCommonNaN( uiA, zPtr ) if ( ! ((uiA) & UINT64_C( 0x0008000000000000 )) ) softfloat_raiseFlags( softfloat_flag_invalid )
167
168/*----------------------------------------------------------------------------
169| Converts the common NaN pointed to by 'aPtr' into a 64-bit floating-point
170| NaN, and returns the bit pattern of this value as an unsigned integer.
171*----------------------------------------------------------------------------*/
172#define softfloat_commonNaNToF64UI( aPtr ) ((uint_fast64_t) defaultNaNF64UI)
173
174/*----------------------------------------------------------------------------
175| Interpreting 'uiA' and 'uiB' as the bit patterns of two 64-bit floating-
176| point values, at least one of which is a NaN, returns the bit pattern of
177| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
178| signaling NaN, the invalid exception is raised.
179*----------------------------------------------------------------------------*/
180uint_fast64_t
181 softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB );
182
183/*----------------------------------------------------------------------------
184| The bit pattern for a default generated 80-bit extended floating-point NaN.
185*----------------------------------------------------------------------------*/
186#define defaultNaNExtF80UI64 0x7FFF
187#define defaultNaNExtF80UI0 UINT64_C( 0xC000000000000000 )
188
189/*----------------------------------------------------------------------------
190| Returns true when the 80-bit unsigned integer formed from concatenating
191| 16-bit 'uiA64' and 64-bit 'uiA0' has the bit pattern of an 80-bit extended
192| floating-point signaling NaN.
193| Note: This macro evaluates its arguments more than once.
194*----------------------------------------------------------------------------*/
195#define softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ((((uiA64) & 0x7FFF) == 0x7FFF) && ! ((uiA0) & UINT64_C( 0x4000000000000000 )) && ((uiA0) & UINT64_C( 0x3FFFFFFFFFFFFFFF )))
196
197#ifdef SOFTFLOAT_FAST_INT64
198
199/*----------------------------------------------------------------------------
200| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is
201| defined.
202*----------------------------------------------------------------------------*/
203
204/*----------------------------------------------------------------------------
205| Assuming the unsigned integer formed from concatenating 'uiA64' and 'uiA0'
206| has the bit pattern of an 80-bit extended floating-point NaN, converts
207| this NaN to the common NaN form, and stores the resulting common NaN at the
208| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
209| exception is raised.
210*----------------------------------------------------------------------------*/
211#define softfloat_extF80UIToCommonNaN( uiA64, uiA0, zPtr ) if ( ! ((uiA0) & UINT64_C( 0x4000000000000000 )) ) softfloat_raiseFlags( softfloat_flag_invalid )
212
213/*----------------------------------------------------------------------------
214| Converts the common NaN pointed to by 'aPtr' into an 80-bit extended
215| floating-point NaN, and returns the bit pattern of this value as an unsigned
216| integer.
217*----------------------------------------------------------------------------*/
218#if defined INLINE && ! defined softfloat_commonNaNToExtF80UI
219INLINE
220struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr )
221{
222 struct uint128 uiZ;
223 uiZ.v64 = defaultNaNExtF80UI64;
224 uiZ.v0 = defaultNaNExtF80UI0;
225 return uiZ;
226}
227#else
228struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr );
229#endif
230
231/*----------------------------------------------------------------------------
232| Interpreting the unsigned integer formed from concatenating 'uiA64' and
233| 'uiA0' as an 80-bit extended floating-point value, and likewise interpreting
234| the unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
235| 80-bit extended floating-point value, and assuming at least on of these
236| floating-point values is a NaN, returns the bit pattern of the combined NaN
237| result. If either original floating-point value is a signaling NaN, the
238| invalid exception is raised.
239*----------------------------------------------------------------------------*/
240struct uint128
241 softfloat_propagateNaNExtF80UI(
242 uint_fast16_t uiA64,
243 uint_fast64_t uiA0,
244 uint_fast16_t uiB64,
245 uint_fast64_t uiB0
246 );
247
248/*----------------------------------------------------------------------------
249| The bit pattern for a default generated 128-bit floating-point NaN.
250*----------------------------------------------------------------------------*/
251#define defaultNaNF128UI64 UINT64_C( 0x7FFF800000000000 )
252#define defaultNaNF128UI0 UINT64_C( 0 )
253
254/*----------------------------------------------------------------------------
255| Returns true when the 128-bit unsigned integer formed from concatenating
256| 64-bit 'uiA64' and 64-bit 'uiA0' has the bit pattern of a 128-bit floating-
257| point signaling NaN.
258| Note: This macro evaluates its arguments more than once.
259*----------------------------------------------------------------------------*/
260#define softfloat_isSigNaNF128UI( uiA64, uiA0 ) ((((uiA64) & UINT64_C( 0x7FFF800000000000 )) == UINT64_C( 0x7FFF000000000000 )) && ((uiA0) || ((uiA64) & UINT64_C( 0x00007FFFFFFFFFFF ))))
261
262/*----------------------------------------------------------------------------
263| Assuming the unsigned integer formed from concatenating 'uiA64' and 'uiA0'
264| has the bit pattern of a 128-bit floating-point NaN, converts this NaN to
265| the common NaN form, and stores the resulting common NaN at the location
266| pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid exception
267| is raised.
268*----------------------------------------------------------------------------*/
269#define softfloat_f128UIToCommonNaN( uiA64, uiA0, zPtr ) if ( ! ((uiA64) & UINT64_C( 0x0000800000000000 )) ) softfloat_raiseFlags( softfloat_flag_invalid )
270
271/*----------------------------------------------------------------------------
272| Converts the common NaN pointed to by 'aPtr' into a 128-bit floating-point
273| NaN, and returns the bit pattern of this value as an unsigned integer.
274*----------------------------------------------------------------------------*/
275#if defined INLINE && ! defined softfloat_commonNaNToF128UI
276INLINE
277struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN *aPtr )
278{
279 struct uint128 uiZ;
280 uiZ.v64 = defaultNaNF128UI64;
281 uiZ.v0 = defaultNaNF128UI0;
282 return uiZ;
283}
284#else
285struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN * );
286#endif
287
288/*----------------------------------------------------------------------------
289| Interpreting the unsigned integer formed from concatenating 'uiA64' and
290| 'uiA0' as a 128-bit floating-point value, and likewise interpreting the
291| unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
292| 128-bit floating-point value, and assuming at least on of these floating-
293| point values is a NaN, returns the bit pattern of the combined NaN result.
294| If either original floating-point value is a signaling NaN, the invalid
295| exception is raised.
296*----------------------------------------------------------------------------*/
297struct uint128
298 softfloat_propagateNaNF128UI(
299 uint_fast64_t uiA64,
300 uint_fast64_t uiA0,
301 uint_fast64_t uiB64,
302 uint_fast64_t uiB0
303 );
304
305#else
306
307/*----------------------------------------------------------------------------
308| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is not
309| defined.
310*----------------------------------------------------------------------------*/
311
312/*----------------------------------------------------------------------------
313| Assuming the 80-bit extended floating-point value pointed to by 'aSPtr' is
314| a NaN, converts this NaN to the common NaN form, and stores the resulting
315| common NaN at the location pointed to by 'zPtr'. If the NaN is a signaling
316| NaN, the invalid exception is raised.
317*----------------------------------------------------------------------------*/
318#define softfloat_extF80MToCommonNaN( aSPtr, zPtr ) if ( ! ((aSPtr)->signif & UINT64_C( 0x4000000000000000 )) ) softfloat_raiseFlags( softfloat_flag_invalid )
319
320/*----------------------------------------------------------------------------
321| Converts the common NaN pointed to by 'aPtr' into an 80-bit extended
322| floating-point NaN, and stores this NaN at the location pointed to by
323| 'zSPtr'.
324*----------------------------------------------------------------------------*/
325#if defined INLINE && ! defined softfloat_commonNaNToExtF80M
326INLINE
327void
328 softfloat_commonNaNToExtF80M(
329 const struct commonNaN *aPtr, struct extFloat80M *zSPtr )
330{
331 zSPtr->signExp = defaultNaNExtF80UI64;
332 zSPtr->signif = defaultNaNExtF80UI0;
333}
334#else
335void
336 softfloat_commonNaNToExtF80M(
337 const struct commonNaN *aPtr, struct extFloat80M *zSPtr );
338#endif
339
340/*----------------------------------------------------------------------------
341| Assuming at least one of the two 80-bit extended floating-point values
342| pointed to by 'aSPtr' and 'bSPtr' is a NaN, stores the combined NaN result
343| at the location pointed to by 'zSPtr'. If either original floating-point
344| value is a signaling NaN, the invalid exception is raised.
345*----------------------------------------------------------------------------*/
346void
347 softfloat_propagateNaNExtF80M(
348 const struct extFloat80M *aSPtr,
349 const struct extFloat80M *bSPtr,
350 struct extFloat80M *zSPtr
351 );
352
353/*----------------------------------------------------------------------------
354| The bit pattern for a default generated 128-bit floating-point NaN.
355*----------------------------------------------------------------------------*/
356#define defaultNaNF128UI96 0x7FFF8000
357#define defaultNaNF128UI64 0
358#define defaultNaNF128UI32 0
359#define defaultNaNF128UI0 0
360
361/*----------------------------------------------------------------------------
362| Assuming the 128-bit floating-point value pointed to by 'aWPtr' is a NaN,
363| converts this NaN to the common NaN form, and stores the resulting common
364| NaN at the location pointed to by 'zPtr'. If the NaN is a signaling NaN,
365| the invalid exception is raised. Argument 'aWPtr' points to an array of
366| four 32-bit elements that concatenate in the platform's normal endian order
367| to form a 128-bit floating-point value.
368*----------------------------------------------------------------------------*/
369#define softfloat_f128MToCommonNaN( aWPtr, zPtr ) if ( ! ((aWPtr)[indexWordHi( 4 )] & UINT64_C( 0x0000800000000000 )) ) softfloat_raiseFlags( softfloat_flag_invalid )
370
371/*----------------------------------------------------------------------------
372| Converts the common NaN pointed to by 'aPtr' into a 128-bit floating-point
373| NaN, and stores this NaN at the location pointed to by 'zWPtr'. Argument
374| 'zWPtr' points to an array of four 32-bit elements that concatenate in the
375| platform's normal endian order to form a 128-bit floating-point value.
376*----------------------------------------------------------------------------*/
377#if defined INLINE && ! defined softfloat_commonNaNToF128M
378INLINE
379void
380 softfloat_commonNaNToF128M( const struct commonNaN *aPtr, uint32_t *zWPtr )
381{
382 zWPtr[indexWord( 4, 3 )] = defaultNaNF128UI96;
383 zWPtr[indexWord( 4, 2 )] = defaultNaNF128UI64;
384 zWPtr[indexWord( 4, 1 )] = defaultNaNF128UI32;
385 zWPtr[indexWord( 4, 0 )] = defaultNaNF128UI0;
386}
387#else
388void
389 softfloat_commonNaNToF128M( const struct commonNaN *aPtr, uint32_t *zWPtr );
390#endif
391
392/*----------------------------------------------------------------------------
393| Assuming at least one of the two 128-bit floating-point values pointed to by
394| 'aWPtr' and 'bWPtr' is a NaN, stores the combined NaN result at the location
395| pointed to by 'zWPtr'. If either original floating-point value is a
396| signaling NaN, the invalid exception is raised. Each of 'aWPtr', 'bWPtr',
397| and 'zWPtr' points to an array of four 32-bit elements that concatenate in
398| the platform's normal endian order to form a 128-bit floating-point value.
399*----------------------------------------------------------------------------*/
400void
401 softfloat_propagateNaNF128M(
402 const uint32_t *aWPtr, const uint32_t *bWPtr, uint32_t *zWPtr );
403
404#endif
405
406#endif
407
deps/SoftFloat-3e/source/ARM-VFPv2/extF80M_isSignalingNaN.c created+57
......@@ -0,0 +1,57 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43*----------------------------------------------------------------------------*/
44bool extF80M_isSignalingNaN( const extFloat80_t *aPtr )
45{
46 const struct extFloat80M *aSPtr;
47 uint64_t uiA0;
48
49 aSPtr = (const struct extFloat80M *) aPtr;
50 if ( (aSPtr->signExp & 0x7FFF) != 0x7FFF ) return false;
51 uiA0 = aSPtr->signif;
52 return
53 ! (uiA0 & UINT64_C( 0x4000000000000000 ))
54 && (uiA0 & UINT64_C( 0x3FFFFFFFFFFFFFFF));
55
56}
57
deps/SoftFloat-3e/source/ARM-VFPv2/f128M_isSignalingNaN.c created+60
......@@ -0,0 +1,60 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "primitives.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44*----------------------------------------------------------------------------*/
45bool f128M_isSignalingNaN( const float128_t *aPtr )
46{
47 const uint32_t *aWPtr;
48 uint32_t uiA96;
49
50 aWPtr = (const uint32_t *) aPtr;
51 uiA96 = aWPtr[indexWordHi( 4 )];
52 if ( (uiA96 & 0x7FFF8000) != 0x7FFF0000 ) return false;
53 return
54 ((uiA96 & 0x00007FFF) != 0)
55 || ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
56 | aWPtr[indexWord( 4, 0 )])
57 != 0);
58
59}
60
deps/SoftFloat-3e/source/ARM-VFPv2/s_commonNaNToExtF80M.c created+56
......@@ -0,0 +1,56 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by 'aPtr' into an 80-bit extended
44| floating-point NaN, and stores this NaN at the location pointed to by
45| 'zSPtr'.
46*----------------------------------------------------------------------------*/
47void
48 softfloat_commonNaNToExtF80M(
49 const struct commonNaN *aPtr, struct extFloat80M *zSPtr )
50{
51
52 zSPtr->signExp = packToExtF80UI64( aPtr->sign, 0x7FFF );
53 zSPtr->signif = UINT64_C( 0xC000000000000000 ) | aPtr->v64>>1;
54
55}
56
deps/SoftFloat-3e/source/ARM-VFPv2/s_commonNaNToExtF80UI.c created+56
......@@ -0,0 +1,56 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by 'aPtr' into an 80-bit extended
44| floating-point NaN, and returns the bit pattern of this value as an unsigned
45| integer.
46*----------------------------------------------------------------------------*/
47struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr )
48{
49 struct uint128 uiZ;
50
51 uiZ.v64 = (uint_fast16_t) aPtr->sign<<15 | 0x7FFF;
52 uiZ.v0 = UINT64_C( 0xC000000000000000 ) | aPtr->v64>>1;
53 return uiZ;
54
55}
56
deps/SoftFloat-3e/source/ARM-VFPv2/s_commonNaNToF128M.c created+56
......@@ -0,0 +1,56 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by 'aPtr' into a 128-bit floating-point
44| NaN, and stores this NaN at the location pointed to by 'zWPtr'. Argument
45| 'zWPtr' points to an array of four 32-bit elements that concatenate in the
46| platform's normal endian order to form a 128-bit floating-point value.
47*----------------------------------------------------------------------------*/
48void
49 softfloat_commonNaNToF128M( const struct commonNaN *aPtr, uint32_t *zWPtr )
50{
51
52 softfloat_shortShiftRight128M( (const uint32_t *) &aPtr->v0, 16, zWPtr );
53 zWPtr[indexWordHi( 4 )] |= (uint32_t) aPtr->sign<<31 | 0x7FFF8000;
54
55}
56
deps/SoftFloat-3e/source/ARM-VFPv2/s_commonNaNToF128UI.c created+55
......@@ -0,0 +1,55 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41
42/*----------------------------------------------------------------------------
43| Converts the common NaN pointed to by 'aPtr' into a 128-bit floating-point
44| NaN, and returns the bit pattern of this value as an unsigned integer.
45*----------------------------------------------------------------------------*/
46struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN *aPtr )
47{
48 struct uint128 uiZ;
49
50 uiZ = softfloat_shortShiftRight128( aPtr->v64, aPtr->v0, 16 );
51 uiZ.v64 |= (uint_fast64_t) aPtr->sign<<63 | UINT64_C( 0x7FFF800000000000 );
52 return uiZ;
53
54}
55
deps/SoftFloat-3e/source/ARM-VFPv2/s_commonNaNToF16UI.c created+51
......@@ -0,0 +1,51 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40
41/*----------------------------------------------------------------------------
42| Converts the common NaN pointed to by 'aPtr' into a 16-bit floating-point
43| NaN, and returns the bit pattern of this value as an unsigned integer.
44*----------------------------------------------------------------------------*/
45uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr )
46{
47
48 return (uint_fast16_t) aPtr->sign<<15 | 0x7E00 | aPtr->v64>>54;
49
50}
51
deps/SoftFloat-3e/source/ARM-VFPv2/s_commonNaNToF32UI.c created+51
......@@ -0,0 +1,51 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40
41/*----------------------------------------------------------------------------
42| Converts the common NaN pointed to by 'aPtr' into a 32-bit floating-point
43| NaN, and returns the bit pattern of this value as an unsigned integer.
44*----------------------------------------------------------------------------*/
45uint_fast32_t softfloat_commonNaNToF32UI( const struct commonNaN *aPtr )
46{
47
48 return (uint_fast32_t) aPtr->sign<<31 | 0x7FC00000 | aPtr->v64>>41;
49
50}
51
deps/SoftFloat-3e/source/ARM-VFPv2/s_commonNaNToF64UI.c created+53
......@@ -0,0 +1,53 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40
41/*----------------------------------------------------------------------------
42| Converts the common NaN pointed to by 'aPtr' into a 64-bit floating-point
43| NaN, and returns the bit pattern of this value as an unsigned integer.
44*----------------------------------------------------------------------------*/
45uint_fast64_t softfloat_commonNaNToF64UI( const struct commonNaN *aPtr )
46{
47
48 return
49 (uint_fast64_t) aPtr->sign<<63 | UINT64_C( 0x7FF8000000000000 )
50 | aPtr->v64>>12;
51
52}
53
deps/SoftFloat-3e/source/ARM-VFPv2/s_extF80MToCommonNaN.c created+62
......@@ -0,0 +1,62 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Assuming the 80-bit extended floating-point value pointed to by 'aSPtr' is
45| a NaN, converts this NaN to the common NaN form, and stores the resulting
46| common NaN at the location pointed to by 'zPtr'. If the NaN is a signaling
47| NaN, the invalid exception is raised.
48*----------------------------------------------------------------------------*/
49void
50 softfloat_extF80MToCommonNaN(
51 const struct extFloat80M *aSPtr, struct commonNaN *zPtr )
52{
53
54 if ( extF80M_isSignalingNaN( (const extFloat80_t *) aSPtr ) ) {
55 softfloat_raiseFlags( softfloat_flag_invalid );
56 }
57 zPtr->sign = signExtF80UI64( aSPtr->signExp );
58 zPtr->v64 = aSPtr->signif<<1;
59 zPtr->v0 = 0;
60
61}
62
deps/SoftFloat-3e/source/ARM-VFPv2/s_extF80UIToCommonNaN.c created+62
......@@ -0,0 +1,62 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming the unsigned integer formed from concatenating 'uiA64' and 'uiA0'
44| has the bit pattern of an 80-bit extended floating-point NaN, converts
45| this NaN to the common NaN form, and stores the resulting common NaN at the
46| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
47| exception is raised.
48*----------------------------------------------------------------------------*/
49void
50 softfloat_extF80UIToCommonNaN(
51 uint_fast16_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr )
52{
53
54 if ( softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ) {
55 softfloat_raiseFlags( softfloat_flag_invalid );
56 }
57 zPtr->sign = uiA64>>15;
58 zPtr->v64 = uiA0<<1;
59 zPtr->v0 = 0;
60
61}
62
deps/SoftFloat-3e/source/ARM-VFPv2/s_f128MToCommonNaN.c created+62
......@@ -0,0 +1,62 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Assuming the 128-bit floating-point value pointed to by 'aWPtr' is a NaN,
45| converts this NaN to the common NaN form, and stores the resulting common
46| NaN at the location pointed to by 'zPtr'. If the NaN is a signaling NaN,
47| the invalid exception is raised. Argument 'aWPtr' points to an array of
48| four 32-bit elements that concatenate in the platform's normal endian order
49| to form a 128-bit floating-point value.
50*----------------------------------------------------------------------------*/
51void
52 softfloat_f128MToCommonNaN( const uint32_t *aWPtr, struct commonNaN *zPtr )
53{
54
55 if ( f128M_isSignalingNaN( (const float128_t *) aWPtr ) ) {
56 softfloat_raiseFlags( softfloat_flag_invalid );
57 }
58 zPtr->sign = aWPtr[indexWordHi( 4 )]>>31;
59 softfloat_shortShiftLeft128M( aWPtr, 16, (uint32_t *) &zPtr->v0 );
60
61}
62
deps/SoftFloat-3e/source/ARM-VFPv2/s_f128UIToCommonNaN.c created+65
......@@ -0,0 +1,65 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43/*----------------------------------------------------------------------------
44| Assuming the unsigned integer formed from concatenating 'uiA64' and 'uiA0'
45| has the bit pattern of a 128-bit floating-point NaN, converts this NaN to
46| the common NaN form, and stores the resulting common NaN at the location
47| pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid exception
48| is raised.
49*----------------------------------------------------------------------------*/
50void
51 softfloat_f128UIToCommonNaN(
52 uint_fast64_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr )
53{
54 struct uint128 NaNSig;
55
56 if ( softfloat_isSigNaNF128UI( uiA64, uiA0 ) ) {
57 softfloat_raiseFlags( softfloat_flag_invalid );
58 }
59 NaNSig = softfloat_shortShiftLeft128( uiA64, uiA0, 16 );
60 zPtr->sign = uiA64>>63;
61 zPtr->v64 = NaNSig.v64;
62 zPtr->v0 = NaNSig.v0;
63
64}
65
deps/SoftFloat-3e/source/ARM-VFPv2/s_f16UIToCommonNaN.c created+59
......@@ -0,0 +1,59 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming 'uiA' has the bit pattern of a 16-bit floating-point NaN, converts
44| this NaN to the common NaN form, and stores the resulting common NaN at the
45| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
46| exception is raised.
47*----------------------------------------------------------------------------*/
48void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr )
49{
50
51 if ( softfloat_isSigNaNF16UI( uiA ) ) {
52 softfloat_raiseFlags( softfloat_flag_invalid );
53 }
54 zPtr->sign = uiA>>15;
55 zPtr->v64 = (uint_fast64_t) uiA<<54;
56 zPtr->v0 = 0;
57
58}
59
deps/SoftFloat-3e/source/ARM-VFPv2/s_f32UIToCommonNaN.c created+59
......@@ -0,0 +1,59 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming 'uiA' has the bit pattern of a 32-bit floating-point NaN, converts
44| this NaN to the common NaN form, and stores the resulting common NaN at the
45| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
46| exception is raised.
47*----------------------------------------------------------------------------*/
48void softfloat_f32UIToCommonNaN( uint_fast32_t uiA, struct commonNaN *zPtr )
49{
50
51 if ( softfloat_isSigNaNF32UI( uiA ) ) {
52 softfloat_raiseFlags( softfloat_flag_invalid );
53 }
54 zPtr->sign = uiA>>31;
55 zPtr->v64 = (uint_fast64_t) uiA<<41;
56 zPtr->v0 = 0;
57
58}
59
deps/SoftFloat-3e/source/ARM-VFPv2/s_f64UIToCommonNaN.c created+59
......@@ -0,0 +1,59 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "specialize.h"
40#include "softfloat.h"
41
42/*----------------------------------------------------------------------------
43| Assuming 'uiA' has the bit pattern of a 64-bit floating-point NaN, converts
44| this NaN to the common NaN form, and stores the resulting common NaN at the
45| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
46| exception is raised.
47*----------------------------------------------------------------------------*/
48void softfloat_f64UIToCommonNaN( uint_fast64_t uiA, struct commonNaN *zPtr )
49{
50
51 if ( softfloat_isSigNaNF64UI( uiA ) ) {
52 softfloat_raiseFlags( softfloat_flag_invalid );
53 }
54 zPtr->sign = uiA>>63;
55 zPtr->v64 = uiA<<12;
56 zPtr->v0 = 0;
57
58}
59
deps/SoftFloat-3e/source/ARM-VFPv2/s_propagateNaNExtF80M.c created+86
......@@ -0,0 +1,86 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Assuming at least one of the two 80-bit extended floating-point values
46| pointed to by 'aSPtr' and 'bSPtr' is a NaN, stores the combined NaN result
47| at the location pointed to by 'zSPtr'. If either original floating-point
48| value is a signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50void
51 softfloat_propagateNaNExtF80M(
52 const struct extFloat80M *aSPtr,
53 const struct extFloat80M *bSPtr,
54 struct extFloat80M *zSPtr
55 )
56{
57 const struct extFloat80M *sPtr;
58 bool isSigNaNA;
59 uint_fast16_t uiZ64;
60 uint_fast64_t uiZ0;
61
62 sPtr = aSPtr;
63 isSigNaNA = extF80M_isSignalingNaN( (const extFloat80_t *) aSPtr );
64 if (
65 isSigNaNA
66 || (bSPtr
67 && extF80M_isSignalingNaN( (const extFloat80_t *) bSPtr ))
68 ) {
69 softfloat_raiseFlags( softfloat_flag_invalid );
70 if ( isSigNaNA ) goto copyNonsig;
71 goto copyNonsigB;
72 }
73 uiZ64 = sPtr->signExp;
74 uiZ0 = sPtr->signif;
75 if ( isNaNExtF80UI( uiZ64, uiZ0 ) ) goto returnNonsig;
76 copyNonsigB:
77 sPtr = bSPtr;
78 copyNonsig:
79 uiZ64 = sPtr->signExp;
80 uiZ0 = sPtr->signif;
81 returnNonsig:
82 zSPtr->signExp = uiZ64;
83 zSPtr->signif = uiZ0 | UINT64_C( 0xC000000000000000 );
84
85}
86
deps/SoftFloat-3e/source/ARM-VFPv2/s_propagateNaNExtF80UI.c created+83
......@@ -0,0 +1,83 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting the unsigned integer formed from concatenating 'uiA64' and
46| 'uiA0' as an 80-bit extended floating-point value, and likewise interpreting
47| the unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
48| 80-bit extended floating-point value, and assuming at least on of these
49| floating-point values is a NaN, returns the bit pattern of the combined NaN
50| result. If either original floating-point value is a signaling NaN, the
51| invalid exception is raised.
52*----------------------------------------------------------------------------*/
53struct uint128
54 softfloat_propagateNaNExtF80UI(
55 uint_fast16_t uiA64,
56 uint_fast64_t uiA0,
57 uint_fast16_t uiB64,
58 uint_fast64_t uiB0
59 )
60{
61 bool isSigNaNA;
62 struct uint128 uiZ;
63
64 isSigNaNA = softfloat_isSigNaNExtF80UI( uiA64, uiA0 );
65 if ( isSigNaNA || softfloat_isSigNaNExtF80UI( uiB64, uiB0 ) ) {
66 softfloat_raiseFlags( softfloat_flag_invalid );
67 if ( isSigNaNA ) goto returnNonsigA;
68 goto returnNonsigB;
69 }
70 if ( isNaNExtF80UI( uiA64, uiA0 ) ) {
71 returnNonsigA:
72 uiZ.v64 = uiA64;
73 uiZ.v0 = uiA0;
74 } else {
75 returnNonsigB:
76 uiZ.v64 = uiB64;
77 uiZ.v0 = uiB0;
78 }
79 uiZ.v0 | UINT64_C( 0xC000000000000000 );
80 return uiZ;
81
82}
83
deps/SoftFloat-3e/source/ARM-VFPv2/s_propagateNaNF128M.c created+77
......@@ -0,0 +1,77 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Assuming at least one of the two 128-bit floating-point values pointed to by
46| 'aWPtr' and 'bWPtr' is a NaN, stores the combined NaN result at the location
47| pointed to by 'zWPtr'. If either original floating-point value is a
48| signaling NaN, the invalid exception is raised. Each of 'aWPtr', 'bWPtr',
49| and 'zWPtr' points to an array of four 32-bit elements that concatenate in
50| the platform's normal endian order to form a 128-bit floating-point value.
51*----------------------------------------------------------------------------*/
52void
53 softfloat_propagateNaNF128M(
54 const uint32_t *aWPtr, const uint32_t *bWPtr, uint32_t *zWPtr )
55{
56 const uint32_t *ptr;
57 bool isSigNaNA;
58
59 ptr = aWPtr;
60 isSigNaNA = f128M_isSignalingNaN( (const float128_t *) aWPtr );
61 if (
62 isSigNaNA
63 || (bWPtr && f128M_isSignalingNaN( (const float128_t *) bWPtr ))
64 ) {
65 softfloat_raiseFlags( softfloat_flag_invalid );
66 if ( ! isSigNaNA ) ptr = bWPtr;
67 goto copyNonsig;
68 }
69 if ( ! softfloat_isNaNF128M( aWPtr ) ) ptr = bWPtr;
70 copyNonsig:
71 zWPtr[indexWordHi( 4 )] = ptr[indexWordHi( 4 )] | 0x00008000;
72 zWPtr[indexWord( 4, 2 )] = ptr[indexWord( 4, 2 )];
73 zWPtr[indexWord( 4, 1 )] = ptr[indexWord( 4, 1 )];
74 zWPtr[indexWord( 4, 0 )] = ptr[indexWord( 4, 0 )];
75
76}
77
deps/SoftFloat-3e/source/ARM-VFPv2/s_propagateNaNF128UI.c created+83
......@@ -0,0 +1,83 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting the unsigned integer formed from concatenating 'uiA64' and
46| 'uiA0' as a 128-bit floating-point value, and likewise interpreting the
47| unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
48| 128-bit floating-point value, and assuming at least on of these floating-
49| point values is a NaN, returns the bit pattern of the combined NaN result.
50| If either original floating-point value is a signaling NaN, the invalid
51| exception is raised.
52*----------------------------------------------------------------------------*/
53struct uint128
54 softfloat_propagateNaNF128UI(
55 uint_fast64_t uiA64,
56 uint_fast64_t uiA0,
57 uint_fast64_t uiB64,
58 uint_fast64_t uiB0
59 )
60{
61 bool isSigNaNA;
62 struct uint128 uiZ;
63
64 isSigNaNA = softfloat_isSigNaNF128UI( uiA64, uiA0 );
65 if ( isSigNaNA || softfloat_isSigNaNF128UI( uiB64, uiB0 ) ) {
66 softfloat_raiseFlags( softfloat_flag_invalid );
67 if ( isSigNaNA ) goto returnNonsigA;
68 goto returnNonsigB;
69 }
70 if ( isNaNF128UI( uiA64, uiA0 ) ) {
71 returnNonsigA:
72 uiZ.v64 = uiA64;
73 uiZ.v0 = uiA0;
74 } else {
75 returnNonsigB:
76 uiZ.v64 = uiB64;
77 uiZ.v0 = uiB0;
78 }
79 uiZ.v64 |= UINT64_C( 0x0000800000000000 );
80 return uiZ;
81
82}
83
deps/SoftFloat-3e/source/ARM-VFPv2/s_propagateNaNF16UI.c created+63
......@@ -0,0 +1,63 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting 'uiA' and 'uiB' as the bit patterns of two 16-bit floating-
46| point values, at least one of which is a NaN, returns the bit pattern of
47| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
48| signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50uint_fast16_t
51 softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB )
52{
53 bool isSigNaNA;
54
55 isSigNaNA = softfloat_isSigNaNF16UI( uiA );
56 if ( isSigNaNA || softfloat_isSigNaNF16UI( uiB ) ) {
57 softfloat_raiseFlags( softfloat_flag_invalid );
58 return (isSigNaNA ? uiA : uiB) | 0x0200;
59 }
60 return isNaNF16UI( uiA ) ? uiA : uiB;
61
62}
63
deps/SoftFloat-3e/source/ARM-VFPv2/s_propagateNaNF32UI.c created+63
......@@ -0,0 +1,63 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting 'uiA' and 'uiB' as the bit patterns of two 32-bit floating-
46| point values, at least one of which is a NaN, returns the bit pattern of
47| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
48| signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50uint_fast32_t
51 softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB )
52{
53 bool isSigNaNA;
54
55 isSigNaNA = softfloat_isSigNaNF32UI( uiA );
56 if ( isSigNaNA || softfloat_isSigNaNF32UI( uiB ) ) {
57 softfloat_raiseFlags( softfloat_flag_invalid );
58 return (isSigNaNA ? uiA : uiB) | 0x00400000;
59 }
60 return isNaNF32UI( uiA ) ? uiA : uiB;
61
62}
63
deps/SoftFloat-3e/source/ARM-VFPv2/s_propagateNaNF64UI.c created+63
......@@ -0,0 +1,63 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44/*----------------------------------------------------------------------------
45| Interpreting 'uiA' and 'uiB' as the bit patterns of two 64-bit floating-
46| point values, at least one of which is a NaN, returns the bit pattern of
47| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
48| signaling NaN, the invalid exception is raised.
49*----------------------------------------------------------------------------*/
50uint_fast64_t
51 softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB )
52{
53 bool isSigNaNA;
54
55 isSigNaNA = softfloat_isSigNaNF64UI( uiA );
56 if ( isSigNaNA || softfloat_isSigNaNF64UI( uiB ) ) {
57 softfloat_raiseFlags( softfloat_flag_invalid );
58 return (isSigNaNA ? uiA : uiB) | UINT64_C( 0x0008000000000000 );
59 }
60 return isNaNF64UI( uiA ) ? uiA : uiB;
61
62}
63
deps/SoftFloat-3e/source/ARM-VFPv2/softfloat_raiseFlags.c created+52
......@@ -0,0 +1,52 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include "platform.h"
38#include "softfloat.h"
39
40/*----------------------------------------------------------------------------
41| Raises the exceptions specified by 'flags'. Floating-point traps can be
42| defined here if desired. It is currently not possible for such a trap
43| to substitute a result value. If traps are not implemented, this routine
44| should be simply 'softfloat_exceptionFlags |= flags;'.
45*----------------------------------------------------------------------------*/
46void softfloat_raiseFlags( uint_fast8_t flags )
47{
48
49 softfloat_exceptionFlags |= flags;
50
51}
52
deps/SoftFloat-3e/source/ARM-VFPv2/specialize.h created+376
......@@ -0,0 +1,376 @@
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#ifndef specialize_h
38#define specialize_h 1
39
40#include <stdbool.h>
41#include <stdint.h>
42#include "primitiveTypes.h"
43#include "softfloat.h"
44
45/*----------------------------------------------------------------------------
46| Default value for 'softfloat_detectTininess'.
47*----------------------------------------------------------------------------*/
48#define init_detectTininess softfloat_tininess_beforeRounding
49
50/*----------------------------------------------------------------------------
51| The values to return on conversions to 32-bit integer formats that raise an
52| invalid exception.
53*----------------------------------------------------------------------------*/
54#define ui32_fromPosOverflow 0xFFFFFFFF
55#define ui32_fromNegOverflow 0
56#define ui32_fromNaN 0
57#define i32_fromPosOverflow 0x7FFFFFFF
58#define i32_fromNegOverflow (-0x7FFFFFFF - 1)
59#define i32_fromNaN 0
60
61/*----------------------------------------------------------------------------
62| The values to return on conversions to 64-bit integer formats that raise an
63| invalid exception.
64*----------------------------------------------------------------------------*/
65#define ui64_fromPosOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
66#define ui64_fromNegOverflow 0
67#define ui64_fromNaN 0
68#define i64_fromPosOverflow INT64_C( 0x7FFFFFFFFFFFFFFF )
69#define i64_fromNegOverflow (-INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
70#define i64_fromNaN 0
71
72/*----------------------------------------------------------------------------
73| "Common NaN" structure, used to transfer NaN representations from one format
74| to another.
75*----------------------------------------------------------------------------*/
76struct commonNaN {
77 bool sign;
78#ifdef LITTLEENDIAN
79 uint64_t v0, v64;
80#else
81 uint64_t v64, v0;
82#endif
83};
84
85/*----------------------------------------------------------------------------
86| The bit pattern for a default generated 16-bit floating-point NaN.
87*----------------------------------------------------------------------------*/
88#define defaultNaNF16UI 0x7E00
89
90/*----------------------------------------------------------------------------
91| Returns true when 16-bit unsigned integer 'uiA' has the bit pattern of a
92| 16-bit floating-point signaling NaN.
93| Note: This macro evaluates its argument more than once.
94*----------------------------------------------------------------------------*/
95#define softfloat_isSigNaNF16UI( uiA ) ((((uiA) & 0x7E00) == 0x7C00) && ((uiA) & 0x01FF))
96
97/*----------------------------------------------------------------------------
98| Assuming 'uiA' has the bit pattern of a 16-bit floating-point NaN, converts
99| this NaN to the common NaN form, and stores the resulting common NaN at the
100| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
101| exception is raised.
102*----------------------------------------------------------------------------*/
103void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr );
104
105/*----------------------------------------------------------------------------
106| Converts the common NaN pointed to by 'aPtr' into a 16-bit floating-point
107| NaN, and returns the bit pattern of this value as an unsigned integer.
108*----------------------------------------------------------------------------*/
109uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr );
110
111/*----------------------------------------------------------------------------
112| Interpreting 'uiA' and 'uiB' as the bit patterns of two 16-bit floating-
113| point values, at least one of which is a NaN, returns the bit pattern of
114| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
115| signaling NaN, the invalid exception is raised.
116*----------------------------------------------------------------------------*/
117uint_fast16_t
118 softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB );
119
120/*----------------------------------------------------------------------------
121| The bit pattern for a default generated 32-bit floating-point NaN.
122*----------------------------------------------------------------------------*/
123#define defaultNaNF32UI 0x7FC00000
124
125/*----------------------------------------------------------------------------
126| Returns true when 32-bit unsigned integer 'uiA' has the bit pattern of a
127| 32-bit floating-point signaling NaN.
128| Note: This macro evaluates its argument more than once.
129*----------------------------------------------------------------------------*/
130#define softfloat_isSigNaNF32UI( uiA ) ((((uiA) & 0x7FC00000) == 0x7F800000) && ((uiA) & 0x003FFFFF))
131
132/*----------------------------------------------------------------------------
133| Assuming 'uiA' has the bit pattern of a 32-bit floating-point NaN, converts
134| this NaN to the common NaN form, and stores the resulting common NaN at the
135| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
136| exception is raised.
137*----------------------------------------------------------------------------*/
138void softfloat_f32UIToCommonNaN( uint_fast32_t uiA, struct commonNaN *zPtr );
139
140/*----------------------------------------------------------------------------
141| Converts the common NaN pointed to by 'aPtr' into a 32-bit floating-point
142| NaN, and returns the bit pattern of this value as an unsigned integer.
143*----------------------------------------------------------------------------*/
144uint_fast32_t softfloat_commonNaNToF32UI( const struct commonNaN *aPtr );
145
146/*----------------------------------------------------------------------------
147| Interpreting 'uiA' and 'uiB' as the bit patterns of two 32-bit floating-
148| point values, at least one of which is a NaN, returns the bit pattern of
149| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
150| signaling NaN, the invalid exception is raised.
151*----------------------------------------------------------------------------*/
152uint_fast32_t
153 softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB );
154
155/*----------------------------------------------------------------------------
156| The bit pattern for a default generated 64-bit floating-point NaN.
157*----------------------------------------------------------------------------*/
158#define defaultNaNF64UI UINT64_C( 0x7FF8000000000000 )
159
160/*----------------------------------------------------------------------------
161| Returns true when 64-bit unsigned integer 'uiA' has the bit pattern of a
162| 64-bit floating-point signaling NaN.
163| Note: This macro evaluates its argument more than once.
164*----------------------------------------------------------------------------*/
165#define softfloat_isSigNaNF64UI( uiA ) ((((uiA) & UINT64_C( 0x7FF8000000000000 )) == UINT64_C( 0x7FF0000000000000 )) && ((uiA) & UINT64_C( 0x0007FFFFFFFFFFFF )))
166
167/*----------------------------------------------------------------------------
168| Assuming 'uiA' has the bit pattern of a 64-bit floating-point NaN, converts
169| this NaN to the common NaN form, and stores the resulting common NaN at the
170| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
171| exception is raised.
172*----------------------------------------------------------------------------*/
173void softfloat_f64UIToCommonNaN( uint_fast64_t uiA, struct commonNaN *zPtr );
174
175/*----------------------------------------------------------------------------
176| Converts the common NaN pointed to by 'aPtr' into a 64-bit floating-point
177| NaN, and returns the bit pattern of this value as an unsigned integer.
178*----------------------------------------------------------------------------*/
179uint_fast64_t softfloat_commonNaNToF64UI( const struct commonNaN *aPtr );
180
181/*----------------------------------------------------------------------------
182| Interpreting 'uiA' and 'uiB' as the bit patterns of two 64-bit floating-
183| point values, at least one of which is a NaN, returns the bit pattern of
184| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
185| signaling NaN, the invalid exception is raised.
186*----------------------------------------------------------------------------*/
187uint_fast64_t
188 softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB );
189
190/*----------------------------------------------------------------------------
191| The bit pattern for a default generated 80-bit extended floating-point NaN.
192*----------------------------------------------------------------------------*/
193#define defaultNaNExtF80UI64 0x7FFF
194#define defaultNaNExtF80UI0 UINT64_C( 0xC000000000000000 )
195
196/*----------------------------------------------------------------------------
197| Returns true when the 80-bit unsigned integer formed from concatenating
198| 16-bit 'uiA64' and 64-bit 'uiA0' has the bit pattern of an 80-bit extended
199| floating-point signaling NaN.
200| Note: This macro evaluates its arguments more than once.
201*----------------------------------------------------------------------------*/
202#define softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ((((uiA64) & 0x7FFF) == 0x7FFF) && ! ((uiA0) & UINT64_C( 0x4000000000000000 )) && ((uiA0) & UINT64_C( 0x3FFFFFFFFFFFFFFF )))
203
204#ifdef SOFTFLOAT_FAST_INT64
205
206/*----------------------------------------------------------------------------
207| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is
208| defined.
209*----------------------------------------------------------------------------*/
210
211/*----------------------------------------------------------------------------
212| Assuming the unsigned integer formed from concatenating 'uiA64' and 'uiA0'
213| has the bit pattern of an 80-bit extended floating-point NaN, converts
214| this NaN to the common NaN form, and stores the resulting common NaN at the
215| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
216| exception is raised.
217*----------------------------------------------------------------------------*/
218void
219 softfloat_extF80UIToCommonNaN(
220 uint_fast16_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr );
221
222/*----------------------------------------------------------------------------
223| Converts the common NaN pointed to by 'aPtr' into an 80-bit extended
224| floating-point NaN, and returns the bit pattern of this value as an unsigned
225| integer.
226*----------------------------------------------------------------------------*/
227struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr );
228
229/*----------------------------------------------------------------------------
230| Interpreting the unsigned integer formed from concatenating 'uiA64' and
231| 'uiA0' as an 80-bit extended floating-point value, and likewise interpreting
232| the unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
233| 80-bit extended floating-point value, and assuming at least on of these
234| floating-point values is a NaN, returns the bit pattern of the combined NaN
235| result. If either original floating-point value is a signaling NaN, the
236| invalid exception is raised.
237*----------------------------------------------------------------------------*/
238struct uint128
239 softfloat_propagateNaNExtF80UI(
240 uint_fast16_t uiA64,
241 uint_fast64_t uiA0,
242 uint_fast16_t uiB64,
243 uint_fast64_t uiB0
244 );
245
246/*----------------------------------------------------------------------------
247| The bit pattern for a default generated 128-bit floating-point NaN.
248*----------------------------------------------------------------------------*/
249#define defaultNaNF128UI64 UINT64_C( 0x7FFF800000000000 )
250#define defaultNaNF128UI0 UINT64_C( 0 )
251
252/*----------------------------------------------------------------------------
253| Returns true when the 128-bit unsigned integer formed from concatenating
254| 64-bit 'uiA64' and 64-bit 'uiA0' has the bit pattern of a 128-bit floating-
255| point signaling NaN.
256| Note: This macro evaluates its arguments more than once.
257*----------------------------------------------------------------------------*/
258#define softfloat_isSigNaNF128UI( uiA64, uiA0 ) ((((uiA64) & UINT64_C( 0x7FFF800000000000 )) == UINT64_C( 0x7FFF000000000000 )) && ((uiA0) || ((uiA64) & UINT64_C( 0x00007FFFFFFFFFFF ))))
259
260/*----------------------------------------------------------------------------
261| Assuming the unsigned integer formed from concatenating 'uiA64' and 'uiA0'
262| has the bit pattern of a 128-bit floating-point NaN, converts this NaN to
263| the common NaN form, and stores the resulting common NaN at the location
264| pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid exception
265| is raised.
266*----------------------------------------------------------------------------*/
267void
268 softfloat_f128UIToCommonNaN(
269 uint_fast64_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr );
270
271/*----------------------------------------------------------------------------
272| Converts the common NaN pointed to by 'aPtr' into a 128-bit floating-point
273| NaN, and returns the bit pattern of this value as an unsigned integer.
274*----------------------------------------------------------------------------*/
275struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN * );
276
277/*----------------------------------------------------------------------------
278| Interpreting the unsigned integer formed from concatenating 'uiA64' and
279| 'uiA0' as a 128-bit floating-point value, and likewise interpreting the
280| unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
281| 128-bit floating-point value, and assuming at least on of these floating-
282| point values is a NaN, returns the bit pattern of the combined NaN result.
283| If either original floating-point value is a signaling NaN, the invalid
284| exception is raised.
285*----------------------------------------------------------------------------*/
286struct uint128
287 softfloat_propagateNaNF128UI(
288 uint_fast64_t uiA64,
289 uint_fast64_t uiA0,
290 uint_fast64_t uiB64,
291 uint_fast64_t uiB0
292 );
293
294#else
295
296/*----------------------------------------------------------------------------
297| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is not
298| defined.
299*----------------------------------------------------------------------------*/
300
301/*----------------------------------------------------------------------------
302| Assuming the 80-bit extended floating-point value pointed to by 'aSPtr' is
303| a NaN, converts this NaN to the common NaN form, and stores the resulting
304| common NaN at the location pointed to by 'zPtr'. If the NaN is a signaling
305| NaN, the invalid exception is raised.
306*----------------------------------------------------------------------------*/
307void
308 softfloat_extF80MToCommonNaN(
309 const struct extFloat80M *aSPtr, struct commonNaN *zPtr );
310
311/*----------------------------------------------------------------------------
312| Converts the common NaN pointed to by 'aPtr' into an 80-bit extended
313| floating-point NaN, and stores this NaN at the location pointed to by
314| 'zSPtr'.
315*----------------------------------------------------------------------------*/
316void
317 softfloat_commonNaNToExtF80M(
318 const struct commonNaN *aPtr, struct extFloat80M *zSPtr );
319
320/*----------------------------------------------------------------------------
321| Assuming at least one of the two 80-bit extended floating-point values
322| pointed to by 'aSPtr' and 'bSPtr' is a NaN, stores the combined NaN result
323| at the location pointed to by 'zSPtr'. If either original floating-point
324| value is a signaling NaN, the invalid exception is raised.
325*----------------------------------------------------------------------------*/
326void
327 softfloat_propagateNaNExtF80M(
328 const struct extFloat80M *aSPtr,
329 const struct extFloat80M *bSPtr,
330 struct extFloat80M *zSPtr
331 );
332
333/*----------------------------------------------------------------------------
334| The bit pattern for a default generated 128-bit floating-point NaN.
335*----------------------------------------------------------------------------*/
336#define defaultNaNF128UI96 0x7FFF8000
337#define defaultNaNF128UI64 0
338#define defaultNaNF128UI32 0
339#define defaultNaNF128UI0 0
340
341/*----------------------------------------------------------------------------
342| Assuming the 128-bit floating-point value pointed to by 'aWPtr' is a NaN,
343| converts this NaN to the common NaN form, and stores the resulting common
344| NaN at the location pointed to by 'zPtr'. If the NaN is a signaling NaN,
345| the invalid exception is raised. Argument 'aWPtr' points to an array of
346| four 32-bit elements that concatenate in the platform's normal endian order
347| to form a 128-bit floating-point value.
348*----------------------------------------------------------------------------*/
349void
350 softfloat_f128MToCommonNaN( const uint32_t *aWPtr, struct commonNaN *zPtr );
351
352/*----------------------------------------------------------------------------
353| Converts the common NaN pointed to by 'aPtr' into a 128-bit floating-point
354| NaN, and stores this NaN at the location pointed to by 'zWPtr'. Argument
355| 'zWPtr' points to an array of four 32-bit elements that concatenate in the
356| platform's normal endian order to form a 128-bit floating-point value.
357*----------------------------------------------------------------------------*/
358void
359 softfloat_commonNaNToF128M( const struct commonNaN *aPtr, uint32_t *zWPtr );
360
361/*----------------------------------------------------------------------------
362| Assuming at least one of the two 128-bit floating-point values pointed to by
363| 'aWPtr' and 'bWPtr' is a NaN, stores the combined NaN result at the location
364| pointed to by 'zWPtr'. If either original floating-point value is a
365| signaling NaN, the invalid exception is raised. Each of 'aWPtr', 'bWPtr',
366| and 'zWPtr' points to an array of four 32-bit elements that concatenate in
367| the platform's normal endian order to form a 128-bit floating-point value.
368*----------------------------------------------------------------------------*/
369void
370 softfloat_propagateNaNF128M(
371 const uint32_t *aWPtr, const uint32_t *bWPtr, uint32_t *zWPtr );
372
373#endif
374
375#endif
376
deps/SoftFloat-3e/source/extF80M_add.c created+100
......@@ -0,0 +1,100 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void
45 extF80M_add(
46 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
47{
48 const struct extFloat80M *aSPtr, *bSPtr;
49 uint_fast16_t uiA64;
50 uint_fast64_t uiA0;
51 bool signA;
52 uint_fast16_t uiB64;
53 uint_fast64_t uiB0;
54 bool signB;
55#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
56 extFloat80_t
57 (*magsFuncPtr)(
58 uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
59#endif
60
61 aSPtr = (const struct extFloat80M *) aPtr;
62 bSPtr = (const struct extFloat80M *) bPtr;
63 uiA64 = aSPtr->signExp;
64 uiA0 = aSPtr->signif;
65 signA = signExtF80UI64( uiA64 );
66 uiB64 = bSPtr->signExp;
67 uiB0 = bSPtr->signif;
68 signB = signExtF80UI64( uiB64 );
69#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
70 if ( signA == signB ) {
71 *zPtr = softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
72 } else {
73 *zPtr = softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
74 }
75#else
76 magsFuncPtr =
77 (signA == signB) ? softfloat_addMagsExtF80 : softfloat_subMagsExtF80;
78 *zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
79#endif
80
81}
82
83#else
84
85void
86 extF80M_add(
87 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
88{
89
90 softfloat_addExtF80M(
91 (const struct extFloat80M *) aPtr,
92 (const struct extFloat80M *) bPtr,
93 (struct extFloat80M *) zPtr,
94 false
95 );
96
97}
98
99#endif
100
deps/SoftFloat-3e/source/extF80M_div.c created+194
......@@ -0,0 +1,194 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void
47 extF80M_div(
48 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
49{
50
51 *zPtr = extF80_div( *aPtr, *bPtr );
52
53}
54
55#else
56
57void
58 extF80M_div(
59 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
60{
61 const struct extFloat80M *aSPtr, *bSPtr;
62 struct extFloat80M *zSPtr;
63 uint_fast16_t uiA64;
64 int32_t expA;
65 uint_fast16_t uiB64;
66 int32_t expB;
67 bool signZ;
68 uint64_t sigA, x64;
69 int32_t expZ;
70 int shiftDist;
71 uint32_t y[3], recip32, sigB[3];
72 int ix;
73 uint32_t q, qs[2];
74 uint_fast16_t uiZ64;
75 uint64_t uiZ0;
76
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 aSPtr = (const struct extFloat80M *) aPtr;
80 bSPtr = (const struct extFloat80M *) bPtr;
81 zSPtr = (struct extFloat80M *) zPtr;
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 uiA64 = aSPtr->signExp;
85 expA = expExtF80UI64( uiA64 );
86 uiB64 = bSPtr->signExp;
87 expB = expExtF80UI64( uiB64 );
88 signZ = signExtF80UI64( uiA64 ) ^ signExtF80UI64( uiB64 );
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
92 if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
93 if ( expA == 0x7FFF ) {
94 if ( expB == 0x7FFF ) goto invalid;
95 goto infinity;
96 }
97 goto zero;
98 }
99 /*------------------------------------------------------------------------
100 *------------------------------------------------------------------------*/
101 sigA = aSPtr->signif;
102 x64 = bSPtr->signif;
103 if ( ! expB ) expB = 1;
104 if ( ! (x64 & UINT64_C( 0x8000000000000000 )) ) {
105 if ( ! x64 ) {
106 if ( ! sigA ) goto invalid;
107 softfloat_raiseFlags( softfloat_flag_infinite );
108 goto infinity;
109 }
110 expB += softfloat_normExtF80SigM( &x64 );
111 }
112 if ( ! expA ) expA = 1;
113 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
114 if ( ! sigA ) goto zero;
115 expA += softfloat_normExtF80SigM( &sigA );
116 }
117 /*------------------------------------------------------------------------
118 *------------------------------------------------------------------------*/
119 expZ = expA - expB + 0x3FFF;
120 shiftDist = 29;
121 if ( sigA < x64 ) {
122 --expZ;
123 shiftDist = 30;
124 }
125 softfloat_shortShiftLeft64To96M( sigA, shiftDist, y );
126 recip32 = softfloat_approxRecip32_1( x64>>32 );
127 sigB[indexWord( 3, 0 )] = (uint32_t) x64<<30;
128 x64 >>= 2;
129 sigB[indexWord( 3, 2 )] = x64>>32;
130 sigB[indexWord( 3, 1 )] = x64;
131 ix = 2;
132 for (;;) {
133 x64 = (uint64_t) y[indexWordHi( 3 )] * recip32;
134 q = (x64 + 0x80000000)>>32;
135 --ix;
136 if ( ix < 0 ) break;
137 softfloat_remStep96MBy32( y, 29, sigB, q, y );
138 if ( y[indexWordHi( 3 )] & 0x80000000 ) {
139 --q;
140 softfloat_add96M( y, sigB, y );
141 }
142 qs[ix] = q;
143 }
144 /*------------------------------------------------------------------------
145 *------------------------------------------------------------------------*/
146 if ( ((q + 1) & 0x3FFFFF) < 2 ) {
147 softfloat_remStep96MBy32( y, 29, sigB, q, y );
148 if ( y[indexWordHi( 3 )] & 0x80000000 ) {
149 --q;
150 softfloat_add96M( y, sigB, y );
151 } else if ( softfloat_compare96M( sigB, y ) <= 0 ) {
152 ++q;
153 softfloat_sub96M( y, sigB, y );
154 }
155 if (
156 y[indexWordLo( 3 )] || y[indexWord( 3, 1 )] || y[indexWord( 3, 2 )]
157 ) {
158 q |= 1;
159 }
160 }
161 /*------------------------------------------------------------------------
162 *------------------------------------------------------------------------*/
163 x64 = (uint64_t) q<<9;
164 y[indexWord( 3, 0 )] = x64;
165 x64 = ((uint64_t) qs[0]<<6) + (x64>>32);
166 y[indexWord( 3, 1 )] = x64;
167 y[indexWord( 3, 2 )] = (qs[1]<<3) + (x64>>32);
168 softfloat_roundPackMToExtF80M(
169 signZ, expZ, y, extF80_roundingPrecision, zSPtr );
170 return;
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 invalid:
174 softfloat_invalidExtF80M( zSPtr );
175 return;
176 /*------------------------------------------------------------------------
177 *------------------------------------------------------------------------*/
178 infinity:
179 uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
180 uiZ0 = UINT64_C( 0x8000000000000000 );
181 goto uiZ;
182 /*------------------------------------------------------------------------
183 *------------------------------------------------------------------------*/
184 zero:
185 uiZ64 = packToExtF80UI64( signZ, 0 );
186 uiZ0 = 0;
187 uiZ:
188 zSPtr->signExp = uiZ64;
189 zSPtr->signif = uiZ0;
190
191}
192
193#endif
194
deps/SoftFloat-3e/source/extF80M_eq.c created+98
......@@ -0,0 +1,98 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46bool extF80M_eq( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
47{
48
49 return extF80_eq( *aPtr, *bPtr );
50
51}
52
53#else
54
55bool extF80M_eq( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
56{
57 const struct extFloat80M *aSPtr, *bSPtr;
58 uint_fast16_t uiA64;
59 uint64_t uiA0;
60 uint_fast16_t uiB64;
61 uint64_t uiB0;
62
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 aSPtr = (const struct extFloat80M *) aPtr;
66 bSPtr = (const struct extFloat80M *) bPtr;
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 uiA64 = aSPtr->signExp;
70 uiA0 = aSPtr->signif;
71 uiB64 = bSPtr->signExp;
72 uiB0 = bSPtr->signif;
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
76 if (
77 softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
78 || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
79 ) {
80 softfloat_raiseFlags( softfloat_flag_invalid );
81 }
82 return false;
83 }
84 /*------------------------------------------------------------------------
85 *------------------------------------------------------------------------*/
86 if ( uiA0 == uiB0 ) {
87 return (uiA64 == uiB64) || ! uiA0;
88 } else {
89 if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
90 return ! softfloat_compareNonnormExtF80M( aSPtr, bSPtr );
91 }
92 return false;
93 }
94
95}
96
97#endif
98
deps/SoftFloat-3e/source/extF80M_eq_signaling.c created+92
......@@ -0,0 +1,92 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43#ifdef SOFTFLOAT_FAST_INT64
44
45bool extF80M_eq_signaling( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
46{
47
48 return extF80_eq_signaling( *aPtr, *bPtr );
49
50}
51
52#else
53
54bool extF80M_eq_signaling( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
55{
56 const struct extFloat80M *aSPtr, *bSPtr;
57 uint_fast16_t uiA64;
58 uint64_t uiA0;
59 uint_fast16_t uiB64;
60 uint64_t uiB0;
61
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 aSPtr = (const struct extFloat80M *) aPtr;
65 bSPtr = (const struct extFloat80M *) bPtr;
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 uiA64 = aSPtr->signExp;
69 uiA0 = aSPtr->signif;
70 uiB64 = bSPtr->signExp;
71 uiB0 = bSPtr->signif;
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
75 softfloat_raiseFlags( softfloat_flag_invalid );
76 return false;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 if ( uiA0 == uiB0 ) {
81 return (uiA64 == uiB64) || ! uiA0;
82 } else {
83 if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
84 return ! softfloat_compareNonnormExtF80M( aSPtr, bSPtr );
85 }
86 return false;
87 }
88
89}
90
91#endif
92
deps/SoftFloat-3e/source/extF80M_le.c created+106
......@@ -0,0 +1,106 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43#ifdef SOFTFLOAT_FAST_INT64
44
45bool extF80M_le( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
46{
47
48 return extF80_le( *aPtr, *bPtr );
49
50}
51
52#else
53
54bool extF80M_le( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
55{
56 const struct extFloat80M *aSPtr, *bSPtr;
57 uint_fast16_t uiA64;
58 uint64_t uiA0;
59 uint_fast16_t uiB64;
60 uint64_t uiB0;
61 bool signA, ltMags;
62
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 aSPtr = (const struct extFloat80M *) aPtr;
66 bSPtr = (const struct extFloat80M *) bPtr;
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 uiA64 = aSPtr->signExp;
70 uiA0 = aSPtr->signif;
71 uiB64 = bSPtr->signExp;
72 uiB0 = bSPtr->signif;
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
76 softfloat_raiseFlags( softfloat_flag_invalid );
77 return false;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 signA = signExtF80UI64( uiA64 );
82 if ( (uiA64 ^ uiB64) & 0x8000 ) {
83 /*--------------------------------------------------------------------
84 | Signs are different.
85 *--------------------------------------------------------------------*/
86 return signA || ! (uiA0 | uiB0);
87 } else {
88 /*--------------------------------------------------------------------
89 | Signs are the same.
90 *--------------------------------------------------------------------*/
91 if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
92 return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) <= 0);
93 }
94 if ( uiA64 == uiB64 ) {
95 if ( uiA0 == uiB0 ) return true;
96 ltMags = (uiA0 < uiB0);
97 } else {
98 ltMags = (uiA64 < uiB64);
99 }
100 return signA ^ ltMags;
101 }
102
103}
104
105#endif
106
deps/SoftFloat-3e/source/extF80M_le_quiet.c created+112
......@@ -0,0 +1,112 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46bool extF80M_le_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
47{
48
49 return extF80_le_quiet( *aPtr, *bPtr );
50
51}
52
53#else
54
55bool extF80M_le_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
56{
57 const struct extFloat80M *aSPtr, *bSPtr;
58 uint_fast16_t uiA64;
59 uint64_t uiA0;
60 uint_fast16_t uiB64;
61 uint64_t uiB0;
62 bool signA, ltMags;
63
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 aSPtr = (const struct extFloat80M *) aPtr;
67 bSPtr = (const struct extFloat80M *) bPtr;
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 uiA64 = aSPtr->signExp;
71 uiA0 = aSPtr->signif;
72 uiB64 = bSPtr->signExp;
73 uiB0 = bSPtr->signif;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
77 if (
78 softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
79 || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
80 ) {
81 softfloat_raiseFlags( softfloat_flag_invalid );
82 }
83 return false;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 signA = signExtF80UI64( uiA64 );
88 if ( (uiA64 ^ uiB64) & 0x8000 ) {
89 /*--------------------------------------------------------------------
90 | Signs are different.
91 *--------------------------------------------------------------------*/
92 return signA || ! (uiA0 | uiB0);
93 } else {
94 /*--------------------------------------------------------------------
95 | Signs are the same.
96 *--------------------------------------------------------------------*/
97 if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
98 return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) <= 0);
99 }
100 if ( uiA64 == uiB64 ) {
101 if ( uiA0 == uiB0 ) return true;
102 ltMags = (uiA0 < uiB0);
103 } else {
104 ltMags = (uiA64 < uiB64);
105 }
106 return signA ^ ltMags;
107 }
108
109}
110
111#endif
112
deps/SoftFloat-3e/source/extF80M_lt.c created+106
......@@ -0,0 +1,106 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43#ifdef SOFTFLOAT_FAST_INT64
44
45bool extF80M_lt( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
46{
47
48 return extF80_lt( *aPtr, *bPtr );
49
50}
51
52#else
53
54bool extF80M_lt( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
55{
56 const struct extFloat80M *aSPtr, *bSPtr;
57 uint_fast16_t uiA64;
58 uint64_t uiA0;
59 uint_fast16_t uiB64;
60 uint64_t uiB0;
61 bool signA, ltMags;
62
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 aSPtr = (const struct extFloat80M *) aPtr;
66 bSPtr = (const struct extFloat80M *) bPtr;
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 uiA64 = aSPtr->signExp;
70 uiA0 = aSPtr->signif;
71 uiB64 = bSPtr->signExp;
72 uiB0 = bSPtr->signif;
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
76 softfloat_raiseFlags( softfloat_flag_invalid );
77 return false;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 signA = signExtF80UI64( uiA64 );
82 if ( (uiA64 ^ uiB64) & 0x8000 ) {
83 /*--------------------------------------------------------------------
84 | Signs are different.
85 *--------------------------------------------------------------------*/
86 return signA && ((uiA0 | uiB0) != 0);
87 } else {
88 /*--------------------------------------------------------------------
89 | Signs are the same.
90 *--------------------------------------------------------------------*/
91 if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
92 return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) < 0);
93 }
94 if ( uiA64 == uiB64 ) {
95 if ( uiA0 == uiB0 ) return false;
96 ltMags = (uiA0 < uiB0);
97 } else {
98 ltMags = (uiA64 < uiB64);
99 }
100 return signA ^ ltMags;
101 }
102
103}
104
105#endif
106
deps/SoftFloat-3e/source/extF80M_lt_quiet.c created+112
......@@ -0,0 +1,112 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46bool extF80M_lt_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
47{
48
49 return extF80_lt_quiet( *aPtr, *bPtr );
50
51}
52
53#else
54
55bool extF80M_lt_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
56{
57 const struct extFloat80M *aSPtr, *bSPtr;
58 uint_fast16_t uiA64;
59 uint64_t uiA0;
60 uint_fast16_t uiB64;
61 uint64_t uiB0;
62 bool signA, ltMags;
63
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 aSPtr = (const struct extFloat80M *) aPtr;
67 bSPtr = (const struct extFloat80M *) bPtr;
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 uiA64 = aSPtr->signExp;
71 uiA0 = aSPtr->signif;
72 uiB64 = bSPtr->signExp;
73 uiB0 = bSPtr->signif;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
77 if (
78 softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
79 || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
80 ) {
81 softfloat_raiseFlags( softfloat_flag_invalid );
82 }
83 return false;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 signA = signExtF80UI64( uiA64 );
88 if ( (uiA64 ^ uiB64) & 0x8000 ) {
89 /*--------------------------------------------------------------------
90 | Signs are different.
91 *--------------------------------------------------------------------*/
92 return signA && ((uiA0 | uiB0) != 0);
93 } else {
94 /*--------------------------------------------------------------------
95 | Signs are the same.
96 *--------------------------------------------------------------------*/
97 if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
98 return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) < 0);
99 }
100 if ( uiA64 == uiB64 ) {
101 if ( uiA0 == uiB0 ) return false;
102 ltMags = (uiA0 < uiB0);
103 } else {
104 ltMags = (uiA64 < uiB64);
105 }
106 return signA ^ ltMags;
107 }
108
109}
110
111#endif
112
deps/SoftFloat-3e/source/extF80M_mul.c created+139
......@@ -0,0 +1,139 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void
47 extF80M_mul(
48 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
49{
50
51 *zPtr = extF80_mul( *aPtr, *bPtr );
52
53}
54
55#else
56
57void
58 extF80M_mul(
59 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
60{
61 const struct extFloat80M *aSPtr, *bSPtr;
62 struct extFloat80M *zSPtr;
63 uint_fast16_t uiA64;
64 int32_t expA;
65 uint_fast16_t uiB64;
66 int32_t expB;
67 bool signZ;
68 uint_fast16_t exp, uiZ64;
69 uint64_t uiZ0, sigA, sigB;
70 int32_t expZ;
71 uint32_t sigProd[4], *extSigZPtr;
72
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 aSPtr = (const struct extFloat80M *) aPtr;
76 bSPtr = (const struct extFloat80M *) bPtr;
77 zSPtr = (struct extFloat80M *) zPtr;
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 uiA64 = aSPtr->signExp;
81 expA = expExtF80UI64( uiA64 );
82 uiB64 = bSPtr->signExp;
83 expB = expExtF80UI64( uiB64 );
84 signZ = signExtF80UI64( uiA64 ) ^ signExtF80UI64( uiB64 );
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
88 if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
89 if (
90 (! aSPtr->signif && (expA != 0x7FFF))
91 || (! bSPtr->signif && (expB != 0x7FFF))
92 ) {
93 softfloat_invalidExtF80M( zSPtr );
94 return;
95 }
96 uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
97 uiZ0 = UINT64_C( 0x8000000000000000 );
98 goto uiZ;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 if ( ! expA ) expA = 1;
103 sigA = aSPtr->signif;
104 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
105 if ( ! sigA ) goto zero;
106 expA += softfloat_normExtF80SigM( &sigA );
107 }
108 if ( ! expB ) expB = 1;
109 sigB = bSPtr->signif;
110 if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
111 if ( ! sigB ) goto zero;
112 expB += softfloat_normExtF80SigM( &sigB );
113 }
114 /*------------------------------------------------------------------------
115 *------------------------------------------------------------------------*/
116 expZ = expA + expB - 0x3FFE;
117 softfloat_mul64To128M( sigA, sigB, sigProd );
118 if ( sigProd[indexWordLo( 4 )] ) sigProd[indexWord( 4, 1 )] |= 1;
119 extSigZPtr = &sigProd[indexMultiwordHi( 4, 3 )];
120 if ( sigProd[indexWordHi( 4 )] < 0x80000000 ) {
121 --expZ;
122 softfloat_add96M( extSigZPtr, extSigZPtr, extSigZPtr );
123 }
124 softfloat_roundPackMToExtF80M(
125 signZ, expZ, extSigZPtr, extF80_roundingPrecision, zSPtr );
126 return;
127 /*------------------------------------------------------------------------
128 *------------------------------------------------------------------------*/
129 zero:
130 uiZ64 = packToExtF80UI64( signZ, 0 );
131 uiZ0 = 0;
132 uiZ:
133 zSPtr->signExp = uiZ64;
134 zSPtr->signif = uiZ0;
135
136}
137
138#endif
139
deps/SoftFloat-3e/source/extF80M_rem.c created+204
......@@ -0,0 +1,204 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void
47 extF80M_rem(
48 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
49{
50
51 *zPtr = extF80_rem( *aPtr, *bPtr );
52
53}
54
55#else
56
57void
58 extF80M_rem(
59 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
60{
61 const struct extFloat80M *aSPtr, *bSPtr;
62 struct extFloat80M *zSPtr;
63 uint_fast16_t uiA64;
64 int32_t expA, expB;
65 uint64_t x64;
66 bool signRem;
67 uint64_t sigA;
68 int32_t expDiff;
69 uint32_t rem[3], x[3], sig32B, q, recip32, rem2[3], *remPtr, *altRemPtr;
70 uint32_t *newRemPtr, wordMeanRem;
71
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 aSPtr = (const struct extFloat80M *) aPtr;
75 bSPtr = (const struct extFloat80M *) bPtr;
76 zSPtr = (struct extFloat80M *) zPtr;
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 uiA64 = aSPtr->signExp;
80 expA = expExtF80UI64( uiA64 );
81 expB = expExtF80UI64( bSPtr->signExp );
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
85 if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
86 if ( expA == 0x7FFF ) goto invalid;
87 /*--------------------------------------------------------------------
88 | If we get here, then argument b is an infinity and `expB' is 0x7FFF;
89 | Doubling `expB' is an easy way to ensure that `expDiff' later is
90 | less than -1, which will result in returning a canonicalized version
91 | of argument a.
92 *--------------------------------------------------------------------*/
93 expB += expB;
94 }
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 if ( ! expB ) expB = 1;
98 x64 = bSPtr->signif;
99 if ( ! (x64 & UINT64_C( 0x8000000000000000 )) ) {
100 if ( ! x64 ) goto invalid;
101 expB += softfloat_normExtF80SigM( &x64 );
102 }
103 signRem = signExtF80UI64( uiA64 );
104 if ( ! expA ) expA = 1;
105 sigA = aSPtr->signif;
106 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
107 if ( ! sigA ) {
108 expA = 0;
109 goto copyA;
110 }
111 expA += softfloat_normExtF80SigM( &sigA );
112 }
113 /*------------------------------------------------------------------------
114 *------------------------------------------------------------------------*/
115 expDiff = expA - expB;
116 if ( expDiff < -1 ) goto copyA;
117 rem[indexWord( 3, 2 )] = sigA>>34;
118 rem[indexWord( 3, 1 )] = sigA>>2;
119 rem[indexWord( 3, 0 )] = (uint32_t) sigA<<30;
120 x[indexWord( 3, 0 )] = (uint32_t) x64<<30;
121 sig32B = x64>>32;
122 x64 >>= 2;
123 x[indexWord( 3, 2 )] = x64>>32;
124 x[indexWord( 3, 1 )] = x64;
125 if ( expDiff < 1 ) {
126 if ( expDiff ) {
127 --expB;
128 softfloat_add96M( x, x, x );
129 q = 0;
130 } else {
131 q = (softfloat_compare96M( x, rem ) <= 0);
132 if ( q ) softfloat_sub96M( rem, x, rem );
133 }
134 } else {
135 recip32 = softfloat_approxRecip32_1( sig32B );
136 expDiff -= 30;
137 for (;;) {
138 x64 = (uint64_t) rem[indexWordHi( 3 )] * recip32;
139 if ( expDiff < 0 ) break;
140 q = (x64 + 0x80000000)>>32;
141 softfloat_remStep96MBy32( rem, 29, x, q, rem );
142 if ( rem[indexWordHi( 3 )] & 0x80000000 ) {
143 softfloat_add96M( rem, x, rem );
144 }
145 expDiff -= 29;
146 }
147 /*--------------------------------------------------------------------
148 | (`expDiff' cannot be less than -29 here.)
149 *--------------------------------------------------------------------*/
150 q = (uint32_t) (x64>>32)>>(~expDiff & 31);
151 softfloat_remStep96MBy32( rem, expDiff + 30, x, q, rem );
152 if ( rem[indexWordHi( 3 )] & 0x80000000 ) {
153 remPtr = rem;
154 altRemPtr = rem2;
155 softfloat_add96M( remPtr, x, altRemPtr );
156 goto selectRem;
157 }
158 }
159 /*------------------------------------------------------------------------
160 *------------------------------------------------------------------------*/
161 remPtr = rem;
162 altRemPtr = rem2;
163 do {
164 ++q;
165 newRemPtr = altRemPtr;
166 softfloat_sub96M( remPtr, x, newRemPtr );
167 altRemPtr = remPtr;
168 remPtr = newRemPtr;
169 } while ( ! (remPtr[indexWordHi( 3 )] & 0x80000000) );
170 selectRem:
171 softfloat_add96M( remPtr, altRemPtr, x );
172 wordMeanRem = x[indexWordHi( 3 )];
173 if (
174 (wordMeanRem & 0x80000000)
175 || (! wordMeanRem && (q & 1) && ! x[indexWord( 3, 0 )]
176 && ! x[indexWord( 3, 1 )])
177 ) {
178 remPtr = altRemPtr;
179 }
180 if ( remPtr[indexWordHi( 3 )] & 0x80000000 ) {
181 signRem = ! signRem;
182 softfloat_negX96M( remPtr );
183 }
184 softfloat_normRoundPackMToExtF80M( signRem, expB + 2, remPtr, 80, zSPtr );
185 return;
186 /*------------------------------------------------------------------------
187 *------------------------------------------------------------------------*/
188 invalid:
189 softfloat_invalidExtF80M( zSPtr );
190 return;
191 /*------------------------------------------------------------------------
192 *------------------------------------------------------------------------*/
193 copyA:
194 if ( expA < 1 ) {
195 sigA >>= 1 - expA;
196 expA = 0;
197 }
198 zSPtr->signExp = packToExtF80UI64( signRem, expA );
199 zSPtr->signif = sigA;
200
201}
202
203#endif
204
deps/SoftFloat-3e/source/extF80M_roundToInt.c created+176
......@@ -0,0 +1,176 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void
47 extF80M_roundToInt(
48 const extFloat80_t *aPtr,
49 uint_fast8_t roundingMode,
50 bool exact,
51 extFloat80_t *zPtr
52 )
53{
54
55 *zPtr = extF80_roundToInt( *aPtr, roundingMode, exact );
56
57}
58
59#else
60
61void
62 extF80M_roundToInt(
63 const extFloat80_t *aPtr,
64 uint_fast8_t roundingMode,
65 bool exact,
66 extFloat80_t *zPtr
67 )
68{
69 const struct extFloat80M *aSPtr;
70 struct extFloat80M *zSPtr;
71 uint_fast16_t uiA64, signUI64;
72 int32_t exp;
73 uint64_t sigA;
74 uint_fast16_t uiZ64;
75 uint64_t sigZ, lastBitMask, roundBitsMask;
76
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 aSPtr = (const struct extFloat80M *) aPtr;
80 zSPtr = (struct extFloat80M *) zPtr;
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 uiA64 = aSPtr->signExp;
84 signUI64 = uiA64 & packToExtF80UI64( 1, 0 );
85 exp = expExtF80UI64( uiA64 );
86 sigA = aSPtr->signif;
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 if ( !(sigA & UINT64_C( 0x8000000000000000 )) && (exp != 0x7FFF) ) {
90 if ( !sigA ) {
91 uiZ64 = signUI64;
92 sigZ = 0;
93 goto uiZ;
94 }
95 exp += softfloat_normExtF80SigM( &sigA );
96 }
97 /*------------------------------------------------------------------------
98 *------------------------------------------------------------------------*/
99 if ( exp <= 0x3FFE ) {
100 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
101 switch ( roundingMode ) {
102 case softfloat_round_near_even:
103 if ( !(sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) break;
104 case softfloat_round_near_maxMag:
105 if ( exp == 0x3FFE ) goto mag1;
106 break;
107 case softfloat_round_min:
108 if ( signUI64 ) goto mag1;
109 break;
110 case softfloat_round_max:
111 if ( !signUI64 ) goto mag1;
112 break;
113#ifdef SOFTFLOAT_ROUND_ODD
114 case softfloat_round_odd:
115 goto mag1;
116#endif
117 }
118 uiZ64 = signUI64;
119 sigZ = 0;
120 goto uiZ;
121 mag1:
122 uiZ64 = signUI64 | 0x3FFF;
123 sigZ = UINT64_C( 0x8000000000000000 );
124 goto uiZ;
125 }
126 /*------------------------------------------------------------------------
127 *------------------------------------------------------------------------*/
128 if ( 0x403E <= exp ) {
129 if ( exp == 0x7FFF ) {
130 if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
131 softfloat_propagateNaNExtF80M( aSPtr, 0, zSPtr );
132 return;
133 }
134 sigZ = UINT64_C( 0x8000000000000000 );
135 } else {
136 sigZ = sigA;
137 }
138 uiZ64 = signUI64 | exp;
139 goto uiZ;
140 }
141 /*------------------------------------------------------------------------
142 *------------------------------------------------------------------------*/
143 uiZ64 = signUI64 | exp;
144 lastBitMask = (uint64_t) 1<<(0x403E - exp);
145 roundBitsMask = lastBitMask - 1;
146 sigZ = sigA;
147 if ( roundingMode == softfloat_round_near_maxMag ) {
148 sigZ += lastBitMask>>1;
149 } else if ( roundingMode == softfloat_round_near_even ) {
150 sigZ += lastBitMask>>1;
151 if ( !(sigZ & roundBitsMask) ) sigZ &= ~lastBitMask;
152 } else if (
153 roundingMode == (signUI64 ? softfloat_round_min : softfloat_round_max)
154 ) {
155 sigZ += roundBitsMask;
156 }
157 sigZ &= ~roundBitsMask;
158 if ( !sigZ ) {
159 ++uiZ64;
160 sigZ = UINT64_C( 0x8000000000000000 );
161 }
162 if ( sigZ != sigA ) {
163#ifdef SOFTFLOAT_ROUND_ODD
164 if ( roundingMode == softfloat_round_odd ) sigZ |= lastBitMask;
165#endif
166 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
167 }
168 uiZ:
169 zSPtr->signExp = uiZ64;
170 zSPtr->signif = sigZ;
171 return;
172
173}
174
175#endif
176
deps/SoftFloat-3e/source/extF80M_sqrt.c created+180
......@@ -0,0 +1,180 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void extF80M_sqrt( const extFloat80_t *aPtr, extFloat80_t *zPtr )
47{
48
49 *zPtr = extF80_sqrt( *aPtr );
50
51}
52
53#else
54
55void extF80M_sqrt( const extFloat80_t *aPtr, extFloat80_t *zPtr )
56{
57 const struct extFloat80M *aSPtr;
58 struct extFloat80M *zSPtr;
59 uint_fast16_t uiA64, signUI64;
60 int32_t expA;
61 uint64_t rem64;
62 int32_t expZ;
63 uint32_t rem96[3], sig32A, recipSqrt32, sig32Z, q;
64 uint64_t sig64Z, x64;
65 uint32_t rem32, term[4], rem[4], extSigZ[3];
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 aSPtr = (const struct extFloat80M *) aPtr;
70 zSPtr = (struct extFloat80M *) zPtr;
71 /*------------------------------------------------------------------------
72 *------------------------------------------------------------------------*/
73 uiA64 = aSPtr->signExp;
74 signUI64 = uiA64 & packToExtF80UI64( 1, 0 );
75 expA = expExtF80UI64( uiA64 );
76 rem64 = aSPtr->signif;
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 if ( expA == 0x7FFF ) {
80 if ( rem64 & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
81 softfloat_propagateNaNExtF80M( aSPtr, 0, zSPtr );
82 return;
83 }
84 if ( signUI64 ) goto invalid;
85 rem64 = UINT64_C( 0x8000000000000000 );
86 goto copyA;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( ! expA ) expA = 1;
91 if ( ! (rem64 & UINT64_C( 0x8000000000000000 )) ) {
92 if ( ! rem64 ) {
93 uiA64 = signUI64;
94 goto copyA;
95 }
96 expA += softfloat_normExtF80SigM( &rem64 );
97 }
98 if ( signUI64 ) goto invalid;
99 /*------------------------------------------------------------------------
100 *------------------------------------------------------------------------*/
101 expZ = ((expA - 0x3FFF)>>1) + 0x3FFF;
102 expA &= 1;
103 softfloat_shortShiftLeft64To96M( rem64, 30 - expA, rem96 );
104 sig32A = rem64>>32;
105 recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
106 sig32Z = ((uint64_t) sig32A * recipSqrt32)>>32;
107 if ( expA ) sig32Z >>= 1;
108 rem64 =
109 ((uint64_t) rem96[indexWord( 3, 2 )]<<32 | rem96[indexWord( 3, 1 )])
110 - (uint64_t) sig32Z * sig32Z;
111 rem96[indexWord( 3, 2 )] = rem64>>32;
112 rem96[indexWord( 3, 1 )] = rem64;
113 /*------------------------------------------------------------------------
114 *------------------------------------------------------------------------*/
115 q = ((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32;
116 sig64Z = ((uint64_t) sig32Z<<32) + ((uint64_t) q<<3);
117 term[indexWord( 3, 2 )] = 0;
118 /*------------------------------------------------------------------------
119 | (Repeating this loop is a rare occurrence.)
120 *------------------------------------------------------------------------*/
121 for (;;) {
122 x64 = ((uint64_t) sig32Z<<32) + sig64Z;
123 term[indexWord( 3, 1 )] = x64>>32;
124 term[indexWord( 3, 0 )] = x64;
125 softfloat_remStep96MBy32(
126 rem96, 29, term, q, &rem[indexMultiwordHi( 4, 3 )] );
127 rem32 = rem[indexWord( 4, 3 )];
128 if ( ! (rem32 & 0x80000000) ) break;
129 --q;
130 sig64Z -= 1<<3;
131 }
132 rem64 = (uint64_t) rem32<<32 | rem[indexWord( 4, 2 )];
133 /*------------------------------------------------------------------------
134 *------------------------------------------------------------------------*/
135 q = (((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32) + 2;
136 if ( rem64>>34 ) q += recipSqrt32;
137 x64 = (uint64_t) q<<7;
138 extSigZ[indexWord( 3, 0 )] = x64;
139 x64 = (sig64Z<<1) + (x64>>32);
140 extSigZ[indexWord( 3, 2 )] = x64>>32;
141 extSigZ[indexWord( 3, 1 )] = x64;
142 /*------------------------------------------------------------------------
143 *------------------------------------------------------------------------*/
144 if ( (q & 0xFFFFFF) <= 2 ) {
145 q &= ~(uint32_t) 0xFFFF;
146 extSigZ[indexWordLo( 3 )] = q<<7;
147 x64 = sig64Z + (q>>27);
148 term[indexWord( 4, 3 )] = 0;
149 term[indexWord( 4, 2 )] = x64>>32;
150 term[indexWord( 4, 1 )] = x64;
151 term[indexWord( 4, 0 )] = q<<5;
152 rem[indexWord( 4, 0 )] = 0;
153 softfloat_remStep128MBy32( rem, 28, term, q, rem );
154 q = rem[indexWordHi( 4 )];
155 if ( q & 0x80000000 ) {
156 softfloat_sub1X96M( extSigZ );
157 } else {
158 if ( q || rem[indexWord( 4, 1 )] || rem[indexWord( 4, 2 )] ) {
159 extSigZ[indexWordLo( 3 )] |= 1;
160 }
161 }
162 }
163 softfloat_roundPackMToExtF80M(
164 0, expZ, extSigZ, extF80_roundingPrecision, zSPtr );
165 return;
166 /*------------------------------------------------------------------------
167 *------------------------------------------------------------------------*/
168 invalid:
169 softfloat_invalidExtF80M( zSPtr );
170 return;
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 copyA:
174 zSPtr->signExp = uiA64;
175 zSPtr->signif = rem64;
176
177}
178
179#endif
180
deps/SoftFloat-3e/source/extF80M_sub.c created+100
......@@ -0,0 +1,100 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void
45 extF80M_sub(
46 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
47{
48 const struct extFloat80M *aSPtr, *bSPtr;
49 uint_fast16_t uiA64;
50 uint_fast64_t uiA0;
51 bool signA;
52 uint_fast16_t uiB64;
53 uint_fast64_t uiB0;
54 bool signB;
55#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
56 extFloat80_t
57 (*magsFuncPtr)(
58 uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
59#endif
60
61 aSPtr = (const struct extFloat80M *) aPtr;
62 bSPtr = (const struct extFloat80M *) bPtr;
63 uiA64 = aSPtr->signExp;
64 uiA0 = aSPtr->signif;
65 signA = signExtF80UI64( uiA64 );
66 uiB64 = bSPtr->signExp;
67 uiB0 = bSPtr->signif;
68 signB = signExtF80UI64( uiB64 );
69#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
70 if ( signA == signB ) {
71 *zPtr = softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
72 } else {
73 *zPtr = softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
74 }
75#else
76 magsFuncPtr =
77 (signA == signB) ? softfloat_subMagsExtF80 : softfloat_addMagsExtF80;
78 *zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
79#endif
80
81}
82
83#else
84
85void
86 extF80M_sub(
87 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
88{
89
90 softfloat_addExtF80M(
91 (const struct extFloat80M *) aPtr,
92 (const struct extFloat80M *) bPtr,
93 (struct extFloat80M *) zPtr,
94 true
95 );
96
97}
98
99#endif
100
deps/SoftFloat-3e/source/extF80M_to_f128M.c created+125
......@@ -0,0 +1,125 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void extF80M_to_f128M( const extFloat80_t *aPtr, float128_t *zPtr )
47{
48
49 *zPtr = extF80_to_f128( *aPtr );
50
51}
52
53#else
54
55void extF80M_to_f128M( const extFloat80_t *aPtr, float128_t *zPtr )
56{
57 const struct extFloat80M *aSPtr;
58 uint32_t *zWPtr;
59 uint_fast16_t uiA64;
60 bool sign;
61 int32_t exp;
62 uint64_t sig;
63 struct commonNaN commonNaN;
64 uint32_t uiZ96;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aSPtr = (const struct extFloat80M *) aPtr;
69 zWPtr = (uint32_t *) zPtr;
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 uiA64 = aSPtr->signExp;
73 sign = signExtF80UI64( uiA64 );
74 exp = expExtF80UI64( uiA64 );
75 sig = aSPtr->signif;
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 zWPtr[indexWord( 4, 0 )] = 0;
79 if ( exp == 0x7FFF ) {
80 if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
81 softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
82 softfloat_commonNaNToF128M( &commonNaN, zWPtr );
83 return;
84 }
85 uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
86 goto uiZ;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( exp ) --exp;
91 if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
92 if ( ! sig ) {
93 uiZ96 = packToF128UI96( sign, 0, 0 );
94 goto uiZ;
95 }
96 exp += softfloat_normExtF80SigM( &sig );
97 }
98 /*------------------------------------------------------------------------
99 *------------------------------------------------------------------------*/
100 zWPtr[indexWord( 4, 1 )] = (uint32_t) sig<<17;
101 sig >>= 15;
102 zWPtr[indexWord( 4, 2 )] = sig;
103 if ( exp < 0 ) {
104 zWPtr[indexWordHi( 4 )] = sig>>32;
105 softfloat_shiftRight96M(
106 &zWPtr[indexMultiwordHi( 4, 3 )],
107 -exp,
108 &zWPtr[indexMultiwordHi( 4, 3 )]
109 );
110 exp = 0;
111 sig = (uint64_t) zWPtr[indexWordHi( 4 )]<<32;
112 }
113 zWPtr[indexWordHi( 4 )] = packToF128UI96( sign, exp, sig>>32 );
114 return;
115 /*------------------------------------------------------------------------
116 *------------------------------------------------------------------------*/
117 uiZ:
118 zWPtr[indexWord( 4, 3 )] = uiZ96;
119 zWPtr[indexWord( 4, 2 )] = 0;
120 zWPtr[indexWord( 4, 1 )] = 0;
121
122}
123
124#endif
125
deps/SoftFloat-3e/source/extF80M_to_f16.c created+112
......@@ -0,0 +1,112 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46float16_t extF80M_to_f16( const extFloat80_t *aPtr )
47{
48
49 return extF80_to_f16( *aPtr );
50
51}
52
53#else
54
55float16_t extF80M_to_f16( const extFloat80_t *aPtr )
56{
57 const struct extFloat80M *aSPtr;
58 uint_fast16_t uiA64;
59 bool sign;
60 int32_t exp;
61 uint64_t sig;
62 struct commonNaN commonNaN;
63 uint16_t uiZ, sig16;
64 union ui16_f16 uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aSPtr = (const struct extFloat80M *) aPtr;
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 uiA64 = aSPtr->signExp;
72 sign = signExtF80UI64( uiA64 );
73 exp = expExtF80UI64( uiA64 );
74 sig = aSPtr->signif;
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp == 0x7FFF ) {
78 if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
79 softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
80 uiZ = softfloat_commonNaNToF16UI( &commonNaN );
81 } else {
82 uiZ = packToF16UI( sign, 0x1F, 0 );
83 }
84 goto uiZ;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
89 if ( ! sig ) {
90 uiZ = packToF16UI( sign, 0, 0 );
91 goto uiZ;
92 }
93 exp += softfloat_normExtF80SigM( &sig );
94 }
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 sig16 = softfloat_shortShiftRightJam64( sig, 49 );
98 exp -= 0x3FF1;
99 if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
100 if ( exp < -0x40 ) exp = -0x40;
101 }
102 return softfloat_roundPackToF16( sign, exp, sig16 );
103 /*------------------------------------------------------------------------
104 *------------------------------------------------------------------------*/
105 uiZ:
106 uZ.ui = uiZ;
107 return uZ.f;
108
109}
110
111#endif
112
deps/SoftFloat-3e/source/extF80M_to_f32.c created+112
......@@ -0,0 +1,112 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46float32_t extF80M_to_f32( const extFloat80_t *aPtr )
47{
48
49 return extF80_to_f32( *aPtr );
50
51}
52
53#else
54
55float32_t extF80M_to_f32( const extFloat80_t *aPtr )
56{
57 const struct extFloat80M *aSPtr;
58 uint_fast16_t uiA64;
59 bool sign;
60 int32_t exp;
61 uint64_t sig;
62 struct commonNaN commonNaN;
63 uint32_t uiZ, sig32;
64 union ui32_f32 uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aSPtr = (const struct extFloat80M *) aPtr;
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 uiA64 = aSPtr->signExp;
72 sign = signExtF80UI64( uiA64 );
73 exp = expExtF80UI64( uiA64 );
74 sig = aSPtr->signif;
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp == 0x7FFF ) {
78 if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
79 softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
80 uiZ = softfloat_commonNaNToF32UI( &commonNaN );
81 } else {
82 uiZ = packToF32UI( sign, 0xFF, 0 );
83 }
84 goto uiZ;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
89 if ( ! sig ) {
90 uiZ = packToF32UI( sign, 0, 0 );
91 goto uiZ;
92 }
93 exp += softfloat_normExtF80SigM( &sig );
94 }
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 sig32 = softfloat_shortShiftRightJam64( sig, 33 );
98 exp -= 0x3F81;
99 if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
100 if ( exp < -0x1000 ) exp = -0x1000;
101 }
102 return softfloat_roundPackToF32( sign, exp, sig32 );
103 /*------------------------------------------------------------------------
104 *------------------------------------------------------------------------*/
105 uiZ:
106 uZ.ui = uiZ;
107 return uZ.f;
108
109}
110
111#endif
112
deps/SoftFloat-3e/source/extF80M_to_f64.c created+112
......@@ -0,0 +1,112 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46float64_t extF80M_to_f64( const extFloat80_t *aPtr )
47{
48
49 return extF80_to_f64( *aPtr );
50
51}
52
53#else
54
55float64_t extF80M_to_f64( const extFloat80_t *aPtr )
56{
57 const struct extFloat80M *aSPtr;
58 uint_fast16_t uiA64;
59 bool sign;
60 int32_t exp;
61 uint64_t sig;
62 struct commonNaN commonNaN;
63 uint64_t uiZ;
64 union ui64_f64 uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aSPtr = (const struct extFloat80M *) aPtr;
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 uiA64 = aSPtr->signExp;
72 sign = signExtF80UI64( uiA64 );
73 exp = expExtF80UI64( uiA64 );
74 sig = aSPtr->signif;
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp == 0x7FFF ) {
78 if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
79 softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
80 uiZ = softfloat_commonNaNToF64UI( &commonNaN );
81 } else {
82 uiZ = packToF64UI( sign, 0x7FF, 0 );
83 }
84 goto uiZ;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
89 if ( ! sig ) {
90 uiZ = packToF64UI( sign, 0, 0 );
91 goto uiZ;
92 }
93 exp += softfloat_normExtF80SigM( &sig );
94 }
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 sig = softfloat_shortShiftRightJam64( sig, 1 );
98 exp -= 0x3C01;
99 if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
100 if ( exp < -0x1000 ) exp = -0x1000;
101 }
102 return softfloat_roundPackToF64( sign, exp, sig );
103 /*------------------------------------------------------------------------
104 *------------------------------------------------------------------------*/
105 uiZ:
106 uZ.ui = uiZ;
107 return uZ.f;
108
109}
110
111#endif
112
deps/SoftFloat-3e/source/extF80M_to_i32.c created+100
......@@ -0,0 +1,100 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46int_fast32_t
47 extF80M_to_i32(
48 const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
49{
50
51 return extF80_to_i32( *aPtr, roundingMode, exact );
52
53}
54
55#else
56
57int_fast32_t
58 extF80M_to_i32(
59 const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
60{
61 const struct extFloat80M *aSPtr;
62 uint_fast16_t uiA64;
63 bool sign;
64 int32_t exp;
65 uint64_t sig;
66 int32_t shiftDist;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 aSPtr = (const struct extFloat80M *) aPtr;
71 uiA64 = aSPtr->signExp;
72 sign = signExtF80UI64( uiA64 );
73 exp = expExtF80UI64( uiA64 );
74 sig = aSPtr->signif;
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 shiftDist = 0x4032 - exp;
78 if ( shiftDist <= 0 ) {
79 if ( sig>>32 ) goto invalid;
80 if ( -32 < shiftDist ) {
81 sig <<= -shiftDist;
82 } else {
83 if ( (uint32_t) sig ) goto invalid;
84 }
85 } else {
86 sig = softfloat_shiftRightJam64( sig, shiftDist );
87 }
88 return softfloat_roundToI32( sign, sig, roundingMode, exact );
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 invalid:
92 softfloat_raiseFlags( softfloat_flag_invalid );
93 return
94 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ? i32_fromNaN
95 : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
96
97}
98
99#endif
100
deps/SoftFloat-3e/source/extF80M_to_i32_r_minMag.c created+120
......@@ -0,0 +1,120 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46int_fast32_t extF80M_to_i32_r_minMag( const extFloat80_t *aPtr, bool exact )
47{
48
49 return extF80_to_i32_r_minMag( *aPtr, exact );
50
51}
52
53#else
54
55int_fast32_t extF80M_to_i32_r_minMag( const extFloat80_t *aPtr, bool exact )
56{
57 const struct extFloat80M *aSPtr;
58 uint_fast16_t uiA64;
59 int32_t exp;
60 uint64_t sig;
61 int32_t shiftDist;
62 bool sign, raiseInexact;
63 int32_t z;
64 uint64_t shiftedSig;
65 uint32_t absZ;
66 union { uint32_t ui; int32_t i; } u;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 aSPtr = (const struct extFloat80M *) aPtr;
71 uiA64 = aSPtr->signExp;
72 exp = expExtF80UI64( uiA64 );
73 sig = aSPtr->signif;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( ! sig && (exp != 0x7FFF) ) return 0;
77 shiftDist = 0x403E - exp;
78 if ( 64 <= shiftDist ) {
79 raiseInexact = exact;
80 z = 0;
81 } else {
82 sign = signExtF80UI64( uiA64 );
83 raiseInexact = false;
84 if ( shiftDist < 0 ) {
85 if ( sig>>32 || (shiftDist <= -31) ) goto invalid;
86 shiftedSig = (uint64_t) (uint32_t) sig<<-shiftDist;
87 if ( shiftedSig>>32 ) goto invalid;
88 absZ = shiftedSig;
89 } else {
90 shiftedSig = sig;
91 if ( shiftDist ) shiftedSig >>= shiftDist;
92 if ( shiftedSig>>32 ) goto invalid;
93 absZ = shiftedSig;
94 if ( exact && shiftDist ) {
95 raiseInexact = ((uint64_t) absZ<<shiftDist != sig);
96 }
97 }
98 if ( sign ) {
99 if ( 0x80000000 < absZ ) goto invalid;
100 u.ui = -absZ;
101 z = u.i;
102 } else {
103 if ( 0x80000000 <= absZ ) goto invalid;
104 z = absZ;
105 }
106 }
107 if ( raiseInexact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
108 return z;
109 /*------------------------------------------------------------------------
110 *------------------------------------------------------------------------*/
111 invalid:
112 softfloat_raiseFlags( softfloat_flag_invalid );
113 return
114 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ? i32_fromNaN
115 : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
116
117}
118
119#endif
120
deps/SoftFloat-3e/source/extF80M_to_i64.c created+97
......@@ -0,0 +1,97 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46int_fast64_t
47 extF80M_to_i64(
48 const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
49{
50
51 return extF80_to_i64( *aPtr, roundingMode, exact );
52
53}
54
55#else
56
57int_fast64_t
58 extF80M_to_i64(
59 const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
60{
61 const struct extFloat80M *aSPtr;
62 uint_fast16_t uiA64;
63 bool sign;
64 int32_t exp;
65 uint64_t sig;
66 int32_t shiftDist;
67 uint32_t extSig[3];
68
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 aSPtr = (const struct extFloat80M *) aPtr;
72 uiA64 = aSPtr->signExp;
73 sign = signExtF80UI64( uiA64 );
74 exp = expExtF80UI64( uiA64 );
75 sig = aSPtr->signif;
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 shiftDist = 0x403E - exp;
79 if ( shiftDist < 0 ) {
80 softfloat_raiseFlags( softfloat_flag_invalid );
81 return
82 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
83 ? i64_fromNaN
84 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 extSig[indexWord( 3, 2 )] = sig>>32;
89 extSig[indexWord( 3, 1 )] = sig;
90 extSig[indexWord( 3, 0 )] = 0;
91 if ( shiftDist ) softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
92 return softfloat_roundMToI64( sign, extSig, roundingMode, exact );
93
94}
95
96#endif
97
deps/SoftFloat-3e/source/extF80M_to_i64_r_minMag.c created+115
......@@ -0,0 +1,115 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46int_fast64_t extF80M_to_i64_r_minMag( const extFloat80_t *aPtr, bool exact )
47{
48
49 return extF80_to_i64_r_minMag( *aPtr, exact );
50
51}
52
53#else
54
55int_fast64_t extF80M_to_i64_r_minMag( const extFloat80_t *aPtr, bool exact )
56{
57 const struct extFloat80M *aSPtr;
58 uint_fast16_t uiA64;
59 int32_t exp;
60 uint64_t sig;
61 int32_t shiftDist;
62 bool sign, raiseInexact;
63 int64_t z;
64 uint64_t absZ;
65 union { uint64_t ui; int64_t i; } u;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 aSPtr = (const struct extFloat80M *) aPtr;
70 uiA64 = aSPtr->signExp;
71 exp = expExtF80UI64( uiA64 );
72 sig = aSPtr->signif;
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 if ( ! sig && (exp != 0x7FFF) ) return 0;
76 shiftDist = 0x403E - exp;
77 if ( 64 <= shiftDist ) {
78 raiseInexact = exact;
79 z = 0;
80 } else {
81 sign = signExtF80UI64( uiA64 );
82 raiseInexact = false;
83 if ( shiftDist < 0 ) {
84 if ( shiftDist <= -63 ) goto invalid;
85 shiftDist = -shiftDist;
86 absZ = sig<<shiftDist;
87 if ( absZ>>shiftDist != sig ) goto invalid;
88 } else {
89 absZ = sig;
90 if ( shiftDist ) absZ >>= shiftDist;
91 if ( exact && shiftDist ) raiseInexact = (absZ<<shiftDist != sig);
92 }
93 if ( sign ) {
94 if ( UINT64_C( 0x8000000000000000 ) < absZ ) goto invalid;
95 u.ui = -absZ;
96 z = u.i;
97 } else {
98 if ( UINT64_C( 0x8000000000000000 ) <= absZ ) goto invalid;
99 z = absZ;
100 }
101 }
102 if ( raiseInexact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
103 return z;
104 /*------------------------------------------------------------------------
105 *------------------------------------------------------------------------*/
106 invalid:
107 softfloat_raiseFlags( softfloat_flag_invalid );
108 return
109 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ? i64_fromNaN
110 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
111
112}
113
114#endif
115
deps/SoftFloat-3e/source/extF80M_to_ui32.c created+101
......@@ -0,0 +1,101 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46uint_fast32_t
47 extF80M_to_ui32(
48 const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
49{
50
51 return extF80_to_ui32( *aPtr, roundingMode, exact );
52
53}
54
55#else
56
57uint_fast32_t
58 extF80M_to_ui32(
59 const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
60{
61 const struct extFloat80M *aSPtr;
62 uint_fast16_t uiA64;
63 bool sign;
64 int32_t exp;
65 uint64_t sig;
66 int32_t shiftDist;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 aSPtr = (const struct extFloat80M *) aPtr;
71 uiA64 = aSPtr->signExp;
72 sign = signExtF80UI64( uiA64 );
73 exp = expExtF80UI64( uiA64 );
74 sig = aSPtr->signif;
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 shiftDist = 0x4032 - exp;
78 if ( shiftDist <= 0 ) {
79 if ( sig>>32 ) goto invalid;
80 if ( -32 < shiftDist ) {
81 sig <<= -shiftDist;
82 } else {
83 if ( (uint32_t) sig ) goto invalid;
84 }
85 } else {
86 sig = softfloat_shiftRightJam64( sig, shiftDist );
87 }
88 return softfloat_roundToUI32( sign, sig, roundingMode, exact );
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 invalid:
92 softfloat_raiseFlags( softfloat_flag_invalid );
93 return
94 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
95 ? ui32_fromNaN
96 : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
97
98}
99
100#endif
101
deps/SoftFloat-3e/source/extF80M_to_ui32_r_minMag.c created+111
......@@ -0,0 +1,111 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46uint_fast32_t extF80M_to_ui32_r_minMag( const extFloat80_t *aPtr, bool exact )
47{
48
49 return extF80_to_ui32_r_minMag( *aPtr, exact );
50
51}
52
53#else
54
55uint_fast32_t extF80M_to_ui32_r_minMag( const extFloat80_t *aPtr, bool exact )
56{
57 const struct extFloat80M *aSPtr;
58 uint_fast16_t uiA64;
59 int32_t exp;
60 uint64_t sig;
61 int32_t shiftDist;
62 bool sign;
63 uint64_t shiftedSig;
64 uint32_t z;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aSPtr = (const struct extFloat80M *) aPtr;
69 uiA64 = aSPtr->signExp;
70 exp = expExtF80UI64( uiA64 );
71 sig = aSPtr->signif;
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 if ( ! sig && (exp != 0x7FFF) ) return 0;
75 shiftDist = 0x403E - exp;
76 if ( 64 <= shiftDist ) {
77 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
78 return 0;
79 }
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 sign = signExtF80UI64( uiA64 );
83 if ( shiftDist < 0 ) {
84 if ( sign || sig>>32 || (shiftDist <= -31) ) goto invalid;
85 shiftedSig = (uint64_t) (uint32_t) sig<<-shiftDist;
86 if ( shiftedSig>>32 ) goto invalid;
87 z = shiftedSig;
88 } else {
89 shiftedSig = sig;
90 if ( shiftDist ) shiftedSig >>= shiftDist;
91 if ( shiftedSig>>32 ) goto invalid;
92 z = shiftedSig;
93 if ( sign && z ) goto invalid;
94 if ( exact && shiftDist && ((uint64_t) z<<shiftDist != sig) ) {
95 softfloat_exceptionFlags |= softfloat_flag_inexact;
96 }
97 }
98 return z;
99 /*------------------------------------------------------------------------
100 *------------------------------------------------------------------------*/
101 invalid:
102 softfloat_raiseFlags( softfloat_flag_invalid );
103 return
104 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
105 ? ui32_fromNaN
106 : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
107
108}
109
110#endif
111
deps/SoftFloat-3e/source/extF80M_to_ui64.c created+97
......@@ -0,0 +1,97 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46uint_fast64_t
47 extF80M_to_ui64(
48 const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
49{
50
51 return extF80_to_ui64( *aPtr, roundingMode, exact );
52
53}
54
55#else
56
57uint_fast64_t
58 extF80M_to_ui64(
59 const extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
60{
61 const struct extFloat80M *aSPtr;
62 uint_fast16_t uiA64;
63 bool sign;
64 int32_t exp;
65 uint64_t sig;
66 int32_t shiftDist;
67 uint32_t extSig[3];
68
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 aSPtr = (const struct extFloat80M *) aPtr;
72 uiA64 = aSPtr->signExp;
73 sign = signExtF80UI64( uiA64 );
74 exp = expExtF80UI64( uiA64 );
75 sig = aSPtr->signif;
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 shiftDist = 0x403E - exp;
79 if ( shiftDist < 0 ) {
80 softfloat_raiseFlags( softfloat_flag_invalid );
81 return
82 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
83 ? ui64_fromNaN
84 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 extSig[indexWord( 3, 2 )] = sig>>32;
89 extSig[indexWord( 3, 1 )] = sig;
90 extSig[indexWord( 3, 0 )] = 0;
91 if ( shiftDist ) softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
92 return softfloat_roundMToUI64( sign, extSig, roundingMode, exact );
93
94}
95
96#endif
97
deps/SoftFloat-3e/source/extF80M_to_ui64_r_minMag.c created+108
......@@ -0,0 +1,108 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46uint_fast64_t extF80M_to_ui64_r_minMag( const extFloat80_t *aPtr, bool exact )
47{
48
49 return extF80_to_ui64_r_minMag( *aPtr, exact );
50
51}
52
53#else
54
55uint_fast64_t extF80M_to_ui64_r_minMag( const extFloat80_t *aPtr, bool exact )
56{
57 const struct extFloat80M *aSPtr;
58 uint_fast16_t uiA64;
59 int32_t exp;
60 uint64_t sig;
61 int32_t shiftDist;
62 bool sign;
63 uint64_t z;
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 aSPtr = (const struct extFloat80M *) aPtr;
68 uiA64 = aSPtr->signExp;
69 exp = expExtF80UI64( uiA64 );
70 sig = aSPtr->signif;
71 /*------------------------------------------------------------------------
72 *------------------------------------------------------------------------*/
73 if ( ! sig && (exp != 0x7FFF) ) return 0;
74 shiftDist = 0x403E - exp;
75 if ( 64 <= shiftDist ) {
76 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
77 return 0;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 sign = signExtF80UI64( uiA64 );
82 if ( shiftDist < 0 ) {
83 if ( sign || (shiftDist <= -63) ) goto invalid;
84 shiftDist = -shiftDist;
85 z = sig<<shiftDist;
86 if ( z>>shiftDist != sig ) goto invalid;
87 } else {
88 z = sig;
89 if ( shiftDist ) z >>= shiftDist;
90 if ( sign && z ) goto invalid;
91 if ( exact && shiftDist && (z<<shiftDist != sig) ) {
92 softfloat_exceptionFlags |= softfloat_flag_inexact;
93 }
94 }
95 return z;
96 /*------------------------------------------------------------------------
97 *------------------------------------------------------------------------*/
98 invalid:
99 softfloat_raiseFlags( softfloat_flag_invalid );
100 return
101 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
102 ? ui64_fromNaN
103 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
104
105}
106
107#endif
108
deps/SoftFloat-3e/source/extF80_add.c created+80
......@@ -0,0 +1,80 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43extFloat80_t extF80_add( extFloat80_t a, extFloat80_t b )
44{
45 union { struct extFloat80M s; extFloat80_t f; } uA;
46 uint_fast16_t uiA64;
47 uint_fast64_t uiA0;
48 bool signA;
49 union { struct extFloat80M s; extFloat80_t f; } uB;
50 uint_fast16_t uiB64;
51 uint_fast64_t uiB0;
52 bool signB;
53#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
54 extFloat80_t
55 (*magsFuncPtr)(
56 uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
57#endif
58
59 uA.f = a;
60 uiA64 = uA.s.signExp;
61 uiA0 = uA.s.signif;
62 signA = signExtF80UI64( uiA64 );
63 uB.f = b;
64 uiB64 = uB.s.signExp;
65 uiB0 = uB.s.signif;
66 signB = signExtF80UI64( uiB64 );
67#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
68 if ( signA == signB ) {
69 return softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
70 } else {
71 return softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
72 }
73#else
74 magsFuncPtr =
75 (signA == signB) ? softfloat_addMagsExtF80 : softfloat_subMagsExtF80;
76 return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
77#endif
78
79}
80
deps/SoftFloat-3e/source/extF80_div.c created+203
......@@ -0,0 +1,203 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t extF80_div( extFloat80_t a, extFloat80_t b )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 bool signA;
50 int_fast32_t expA;
51 uint_fast64_t sigA;
52 union { struct extFloat80M s; extFloat80_t f; } uB;
53 uint_fast16_t uiB64;
54 uint_fast64_t uiB0;
55 bool signB;
56 int_fast32_t expB;
57 uint_fast64_t sigB;
58 bool signZ;
59 struct exp32_sig64 normExpSig;
60 int_fast32_t expZ;
61 struct uint128 rem;
62 uint_fast32_t recip32;
63 uint_fast64_t sigZ;
64 int ix;
65 uint_fast64_t q64;
66 uint_fast32_t q;
67 struct uint128 term;
68 uint_fast64_t sigZExtra;
69 struct uint128 uiZ;
70 uint_fast16_t uiZ64;
71 uint_fast64_t uiZ0;
72 union { struct extFloat80M s; extFloat80_t f; } uZ;
73
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 uA.f = a;
77 uiA64 = uA.s.signExp;
78 uiA0 = uA.s.signif;
79 signA = signExtF80UI64( uiA64 );
80 expA = expExtF80UI64( uiA64 );
81 sigA = uiA0;
82 uB.f = b;
83 uiB64 = uB.s.signExp;
84 uiB0 = uB.s.signif;
85 signB = signExtF80UI64( uiB64 );
86 expB = expExtF80UI64( uiB64 );
87 sigB = uiB0;
88 signZ = signA ^ signB;
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 if ( expA == 0x7FFF ) {
92 if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
93 if ( expB == 0x7FFF ) {
94 if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
95 goto invalid;
96 }
97 goto infinity;
98 }
99 if ( expB == 0x7FFF ) {
100 if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
101 goto zero;
102 }
103 /*------------------------------------------------------------------------
104 *------------------------------------------------------------------------*/
105 if ( ! expB ) expB = 1;
106 if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
107 if ( ! sigB ) {
108 if ( ! sigA ) goto invalid;
109 softfloat_raiseFlags( softfloat_flag_infinite );
110 goto infinity;
111 }
112 normExpSig = softfloat_normSubnormalExtF80Sig( sigB );
113 expB += normExpSig.exp;
114 sigB = normExpSig.sig;
115 }
116 if ( ! expA ) expA = 1;
117 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
118 if ( ! sigA ) goto zero;
119 normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
120 expA += normExpSig.exp;
121 sigA = normExpSig.sig;
122 }
123 /*------------------------------------------------------------------------
124 *------------------------------------------------------------------------*/
125 expZ = expA - expB + 0x3FFF;
126 if ( sigA < sigB ) {
127 --expZ;
128 rem = softfloat_shortShiftLeft128( 0, sigA, 32 );
129 } else {
130 rem = softfloat_shortShiftLeft128( 0, sigA, 31 );
131 }
132 recip32 = softfloat_approxRecip32_1( sigB>>32 );
133 sigZ = 0;
134 ix = 2;
135 for (;;) {
136 q64 = (uint_fast64_t) (uint32_t) (rem.v64>>2) * recip32;
137 q = (q64 + 0x80000000)>>32;
138 --ix;
139 if ( ix < 0 ) break;
140 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
141 term = softfloat_mul64ByShifted32To128( sigB, q );
142 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
143 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
144 --q;
145 rem = softfloat_add128( rem.v64, rem.v0, sigB>>32, sigB<<32 );
146 }
147 sigZ = (sigZ<<29) + q;
148 }
149 /*------------------------------------------------------------------------
150 *------------------------------------------------------------------------*/
151 if ( ((q + 1) & 0x3FFFFF) < 2 ) {
152 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
153 term = softfloat_mul64ByShifted32To128( sigB, q );
154 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
155 term = softfloat_shortShiftLeft128( 0, sigB, 32 );
156 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
157 --q;
158 rem = softfloat_add128( rem.v64, rem.v0, term.v64, term.v0 );
159 } else if ( softfloat_le128( term.v64, term.v0, rem.v64, rem.v0 ) ) {
160 ++q;
161 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
162 }
163 if ( rem.v64 | rem.v0 ) q |= 1;
164 }
165 /*------------------------------------------------------------------------
166 *------------------------------------------------------------------------*/
167 sigZ = (sigZ<<6) + (q>>23);
168 sigZExtra = (uint64_t) ((uint_fast64_t) q<<41);
169 return
170 softfloat_roundPackToExtF80(
171 signZ, expZ, sigZ, sigZExtra, extF80_roundingPrecision );
172 /*------------------------------------------------------------------------
173 *------------------------------------------------------------------------*/
174 propagateNaN:
175 uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
176 uiZ64 = uiZ.v64;
177 uiZ0 = uiZ.v0;
178 goto uiZ;
179 /*------------------------------------------------------------------------
180 *------------------------------------------------------------------------*/
181 invalid:
182 softfloat_raiseFlags( softfloat_flag_invalid );
183 uiZ64 = defaultNaNExtF80UI64;
184 uiZ0 = defaultNaNExtF80UI0;
185 goto uiZ;
186 /*------------------------------------------------------------------------
187 *------------------------------------------------------------------------*/
188 infinity:
189 uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
190 uiZ0 = UINT64_C( 0x8000000000000000 );
191 goto uiZ;
192 /*------------------------------------------------------------------------
193 *------------------------------------------------------------------------*/
194 zero:
195 uiZ64 = packToExtF80UI64( signZ, 0 );
196 uiZ0 = 0;
197 uiZ:
198 uZ.s.signExp = uiZ64;
199 uZ.s.signif = uiZ0;
200 return uZ.f;
201
202}
203
deps/SoftFloat-3e/source/extF80_eq.c created+73
......@@ -0,0 +1,73 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool extF80_eq( extFloat80_t a, extFloat80_t b )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 union { struct extFloat80M s; extFloat80_t f; } uB;
50 uint_fast16_t uiB64;
51 uint_fast64_t uiB0;
52
53 uA.f = a;
54 uiA64 = uA.s.signExp;
55 uiA0 = uA.s.signif;
56 uB.f = b;
57 uiB64 = uB.s.signExp;
58 uiB0 = uB.s.signif;
59 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
60 if (
61 softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
62 || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
63 ) {
64 softfloat_raiseFlags( softfloat_flag_invalid );
65 }
66 return false;
67 }
68 return
69 (uiA0 == uiB0)
70 && ((uiA64 == uiB64) || (! uiA0 && ! ((uiA64 | uiB64) & 0x7FFF)));
71
72}
73
deps/SoftFloat-3e/source/extF80_eq_signaling.c created+67
......@@ -0,0 +1,67 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool extF80_eq_signaling( extFloat80_t a, extFloat80_t b )
44{
45 union { struct extFloat80M s; extFloat80_t f; } uA;
46 uint_fast16_t uiA64;
47 uint_fast64_t uiA0;
48 union { struct extFloat80M s; extFloat80_t f; } uB;
49 uint_fast16_t uiB64;
50 uint_fast64_t uiB0;
51
52 uA.f = a;
53 uiA64 = uA.s.signExp;
54 uiA0 = uA.s.signif;
55 uB.f = b;
56 uiB64 = uB.s.signExp;
57 uiB0 = uB.s.signif;
58 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
59 softfloat_raiseFlags( softfloat_flag_invalid );
60 return false;
61 }
62 return
63 (uiA0 == uiB0)
64 && ((uiA64 == uiB64) || (! uiA0 && ! ((uiA64 | uiB64) & 0x7FFF)));
65
66}
67
deps/SoftFloat-3e/source/extF80_isSignalingNaN.c created+51
......@@ -0,0 +1,51 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43bool extF80_isSignalingNaN( extFloat80_t a )
44{
45 union { struct extFloat80M s; extFloat80_t f; } uA;
46
47 uA.f = a;
48 return softfloat_isSigNaNExtF80UI( uA.s.signExp, uA.s.signif );
49
50}
51
deps/SoftFloat-3e/source/extF80_le.c created+73
......@@ -0,0 +1,73 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool extF80_le( extFloat80_t a, extFloat80_t b )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 union { struct extFloat80M s; extFloat80_t f; } uB;
50 uint_fast16_t uiB64;
51 uint_fast64_t uiB0;
52 bool signA, signB;
53
54 uA.f = a;
55 uiA64 = uA.s.signExp;
56 uiA0 = uA.s.signif;
57 uB.f = b;
58 uiB64 = uB.s.signExp;
59 uiB0 = uB.s.signif;
60 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
61 softfloat_raiseFlags( softfloat_flag_invalid );
62 return false;
63 }
64 signA = signExtF80UI64( uiA64 );
65 signB = signExtF80UI64( uiB64 );
66 return
67 (signA != signB)
68 ? signA || ! (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
69 : ((uiA64 == uiB64) && (uiA0 == uiB0))
70 || (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
71
72}
73
deps/SoftFloat-3e/source/extF80_le_quiet.c created+78
......@@ -0,0 +1,78 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool extF80_le_quiet( extFloat80_t a, extFloat80_t b )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 union { struct extFloat80M s; extFloat80_t f; } uB;
50 uint_fast16_t uiB64;
51 uint_fast64_t uiB0;
52 bool signA, signB;
53
54 uA.f = a;
55 uiA64 = uA.s.signExp;
56 uiA0 = uA.s.signif;
57 uB.f = b;
58 uiB64 = uB.s.signExp;
59 uiB0 = uB.s.signif;
60 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
61 if (
62 softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
63 || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
64 ) {
65 softfloat_raiseFlags( softfloat_flag_invalid );
66 }
67 return false;
68 }
69 signA = signExtF80UI64( uiA64 );
70 signB = signExtF80UI64( uiB64 );
71 return
72 (signA != signB)
73 ? signA || ! (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
74 : ((uiA64 == uiB64) && (uiA0 == uiB0))
75 || (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
76
77}
78
deps/SoftFloat-3e/source/extF80_lt.c created+73
......@@ -0,0 +1,73 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool extF80_lt( extFloat80_t a, extFloat80_t b )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 union { struct extFloat80M s; extFloat80_t f; } uB;
50 uint_fast16_t uiB64;
51 uint_fast64_t uiB0;
52 bool signA, signB;
53
54 uA.f = a;
55 uiA64 = uA.s.signExp;
56 uiA0 = uA.s.signif;
57 uB.f = b;
58 uiB64 = uB.s.signExp;
59 uiB0 = uB.s.signif;
60 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
61 softfloat_raiseFlags( softfloat_flag_invalid );
62 return false;
63 }
64 signA = signExtF80UI64( uiA64 );
65 signB = signExtF80UI64( uiB64 );
66 return
67 (signA != signB)
68 ? signA && (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
69 : ((uiA64 != uiB64) || (uiA0 != uiB0))
70 && (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
71
72}
73
deps/SoftFloat-3e/source/extF80_lt_quiet.c created+78
......@@ -0,0 +1,78 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool extF80_lt_quiet( extFloat80_t a, extFloat80_t b )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 union { struct extFloat80M s; extFloat80_t f; } uB;
50 uint_fast16_t uiB64;
51 uint_fast64_t uiB0;
52 bool signA, signB;
53
54 uA.f = a;
55 uiA64 = uA.s.signExp;
56 uiA0 = uA.s.signif;
57 uB.f = b;
58 uiB64 = uB.s.signExp;
59 uiB0 = uB.s.signif;
60 if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
61 if (
62 softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
63 || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
64 ) {
65 softfloat_raiseFlags( softfloat_flag_invalid );
66 }
67 return false;
68 }
69 signA = signExtF80UI64( uiA64 );
70 signB = signExtF80UI64( uiB64 );
71 return
72 (signA != signB)
73 ? signA && (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
74 : ((uiA64 != uiB64) || (uiA0 != uiB0))
75 && (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
76
77}
78
deps/SoftFloat-3e/source/extF80_mul.c created+158
......@@ -0,0 +1,158 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t extF80_mul( extFloat80_t a, extFloat80_t b )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 bool signA;
50 int_fast32_t expA;
51 uint_fast64_t sigA;
52 union { struct extFloat80M s; extFloat80_t f; } uB;
53 uint_fast16_t uiB64;
54 uint_fast64_t uiB0;
55 bool signB;
56 int_fast32_t expB;
57 uint_fast64_t sigB;
58 bool signZ;
59 uint_fast64_t magBits;
60 struct exp32_sig64 normExpSig;
61 int_fast32_t expZ;
62 struct uint128 sig128Z, uiZ;
63 uint_fast16_t uiZ64;
64 uint_fast64_t uiZ0;
65 union { struct extFloat80M s; extFloat80_t f; } uZ;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 uA.f = a;
70 uiA64 = uA.s.signExp;
71 uiA0 = uA.s.signif;
72 signA = signExtF80UI64( uiA64 );
73 expA = expExtF80UI64( uiA64 );
74 sigA = uiA0;
75 uB.f = b;
76 uiB64 = uB.s.signExp;
77 uiB0 = uB.s.signif;
78 signB = signExtF80UI64( uiB64 );
79 expB = expExtF80UI64( uiB64 );
80 sigB = uiB0;
81 signZ = signA ^ signB;
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( expA == 0x7FFF ) {
85 if (
86 (sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
87 || ((expB == 0x7FFF) && (sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
88 ) {
89 goto propagateNaN;
90 }
91 magBits = expB | sigB;
92 goto infArg;
93 }
94 if ( expB == 0x7FFF ) {
95 if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
96 magBits = expA | sigA;
97 goto infArg;
98 }
99 /*------------------------------------------------------------------------
100 *------------------------------------------------------------------------*/
101 if ( ! expA ) expA = 1;
102 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
103 if ( ! sigA ) goto zero;
104 normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
105 expA += normExpSig.exp;
106 sigA = normExpSig.sig;
107 }
108 if ( ! expB ) expB = 1;
109 if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
110 if ( ! sigB ) goto zero;
111 normExpSig = softfloat_normSubnormalExtF80Sig( sigB );
112 expB += normExpSig.exp;
113 sigB = normExpSig.sig;
114 }
115 /*------------------------------------------------------------------------
116 *------------------------------------------------------------------------*/
117 expZ = expA + expB - 0x3FFE;
118 sig128Z = softfloat_mul64To128( sigA, sigB );
119 if ( sig128Z.v64 < UINT64_C( 0x8000000000000000 ) ) {
120 --expZ;
121 sig128Z =
122 softfloat_add128(
123 sig128Z.v64, sig128Z.v0, sig128Z.v64, sig128Z.v0 );
124 }
125 return
126 softfloat_roundPackToExtF80(
127 signZ, expZ, sig128Z.v64, sig128Z.v0, extF80_roundingPrecision );
128 /*------------------------------------------------------------------------
129 *------------------------------------------------------------------------*/
130 propagateNaN:
131 uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
132 uiZ64 = uiZ.v64;
133 uiZ0 = uiZ.v0;
134 goto uiZ;
135 /*------------------------------------------------------------------------
136 *------------------------------------------------------------------------*/
137 infArg:
138 if ( ! magBits ) {
139 softfloat_raiseFlags( softfloat_flag_invalid );
140 uiZ64 = defaultNaNExtF80UI64;
141 uiZ0 = defaultNaNExtF80UI0;
142 } else {
143 uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
144 uiZ0 = UINT64_C( 0x8000000000000000 );
145 }
146 goto uiZ;
147 /*------------------------------------------------------------------------
148 *------------------------------------------------------------------------*/
149 zero:
150 uiZ64 = packToExtF80UI64( signZ, 0 );
151 uiZ0 = 0;
152 uiZ:
153 uZ.s.signExp = uiZ64;
154 uZ.s.signif = uiZ0;
155 return uZ.f;
156
157}
158
deps/SoftFloat-3e/source/extF80_rem.c created+225
......@@ -0,0 +1,225 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t extF80_rem( extFloat80_t a, extFloat80_t b )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 bool signA;
50 int_fast32_t expA;
51 uint_fast64_t sigA;
52 union { struct extFloat80M s; extFloat80_t f; } uB;
53 uint_fast16_t uiB64;
54 uint_fast64_t uiB0;
55 int_fast32_t expB;
56 uint_fast64_t sigB;
57 struct exp32_sig64 normExpSig;
58 int_fast32_t expDiff;
59 struct uint128 rem, shiftedSigB;
60 uint_fast32_t q, recip32;
61 uint_fast64_t q64;
62 struct uint128 term, altRem, meanRem;
63 bool signRem;
64 struct uint128 uiZ;
65 uint_fast16_t uiZ64;
66 uint_fast64_t uiZ0;
67 union { struct extFloat80M s; extFloat80_t f; } uZ;
68
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 uA.f = a;
72 uiA64 = uA.s.signExp;
73 uiA0 = uA.s.signif;
74 signA = signExtF80UI64( uiA64 );
75 expA = expExtF80UI64( uiA64 );
76 sigA = uiA0;
77 uB.f = b;
78 uiB64 = uB.s.signExp;
79 uiB0 = uB.s.signif;
80 expB = expExtF80UI64( uiB64 );
81 sigB = uiB0;
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( expA == 0x7FFF ) {
85 if (
86 (sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
87 || ((expB == 0x7FFF) && (sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
88 ) {
89 goto propagateNaN;
90 }
91 goto invalid;
92 }
93 if ( expB == 0x7FFF ) {
94 if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
95 /*--------------------------------------------------------------------
96 | Argument b is an infinity. Doubling `expB' is an easy way to ensure
97 | that `expDiff' later is less than -1, which will result in returning
98 | a canonicalized version of argument a.
99 *--------------------------------------------------------------------*/
100 expB += expB;
101 }
102 /*------------------------------------------------------------------------
103 *------------------------------------------------------------------------*/
104 if ( ! expB ) expB = 1;
105 if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
106 if ( ! sigB ) goto invalid;
107 normExpSig = softfloat_normSubnormalExtF80Sig( sigB );
108 expB += normExpSig.exp;
109 sigB = normExpSig.sig;
110 }
111 if ( ! expA ) expA = 1;
112 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
113 if ( ! sigA ) {
114 expA = 0;
115 goto copyA;
116 }
117 normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
118 expA += normExpSig.exp;
119 sigA = normExpSig.sig;
120 }
121 /*------------------------------------------------------------------------
122 *------------------------------------------------------------------------*/
123 expDiff = expA - expB;
124 if ( expDiff < -1 ) goto copyA;
125 rem = softfloat_shortShiftLeft128( 0, sigA, 32 );
126 shiftedSigB = softfloat_shortShiftLeft128( 0, sigB, 32 );
127 if ( expDiff < 1 ) {
128 if ( expDiff ) {
129 --expB;
130 shiftedSigB = softfloat_shortShiftLeft128( 0, sigB, 33 );
131 q = 0;
132 } else {
133 q = (sigB <= sigA);
134 if ( q ) {
135 rem =
136 softfloat_sub128(
137 rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
138 }
139 }
140 } else {
141 recip32 = softfloat_approxRecip32_1( sigB>>32 );
142 expDiff -= 30;
143 for (;;) {
144 q64 = (uint_fast64_t) (uint32_t) (rem.v64>>2) * recip32;
145 if ( expDiff < 0 ) break;
146 q = (q64 + 0x80000000)>>32;
147 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
148 term = softfloat_mul64ByShifted32To128( sigB, q );
149 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
150 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
151 rem =
152 softfloat_add128(
153 rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
154 }
155 expDiff -= 29;
156 }
157 /*--------------------------------------------------------------------
158 | (`expDiff' cannot be less than -29 here.)
159 *--------------------------------------------------------------------*/
160 q = (uint32_t) (q64>>32)>>(~expDiff & 31);
161 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, expDiff + 30 );
162 term = softfloat_mul64ByShifted32To128( sigB, q );
163 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
164 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
165 altRem =
166 softfloat_add128(
167 rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
168 goto selectRem;
169 }
170 }
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 do {
174 altRem = rem;
175 ++q;
176 rem =
177 softfloat_sub128(
178 rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
179 } while ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) );
180 selectRem:
181 meanRem = softfloat_add128( rem.v64, rem.v0, altRem.v64, altRem.v0 );
182 if (
183 (meanRem.v64 & UINT64_C( 0x8000000000000000 ))
184 || (! (meanRem.v64 | meanRem.v0) && (q & 1))
185 ) {
186 rem = altRem;
187 }
188 signRem = signA;
189 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
190 signRem = ! signRem;
191 rem = softfloat_sub128( 0, 0, rem.v64, rem.v0 );
192 }
193 return
194 softfloat_normRoundPackToExtF80(
195 signRem, rem.v64 | rem.v0 ? expB + 32 : 0, rem.v64, rem.v0, 80 );
196 /*------------------------------------------------------------------------
197 *------------------------------------------------------------------------*/
198 propagateNaN:
199 uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
200 uiZ64 = uiZ.v64;
201 uiZ0 = uiZ.v0;
202 goto uiZ;
203 /*------------------------------------------------------------------------
204 *------------------------------------------------------------------------*/
205 invalid:
206 softfloat_raiseFlags( softfloat_flag_invalid );
207 uiZ64 = defaultNaNExtF80UI64;
208 uiZ0 = defaultNaNExtF80UI0;
209 goto uiZ;
210 /*------------------------------------------------------------------------
211 *------------------------------------------------------------------------*/
212 copyA:
213 if ( expA < 1 ) {
214 sigA >>= 1 - expA;
215 expA = 0;
216 }
217 uiZ64 = packToExtF80UI64( signA, expA );
218 uiZ0 = sigA;
219 uiZ:
220 uZ.s.signExp = uiZ64;
221 uZ.s.signif = uiZ0;
222 return uZ.f;
223
224}
225
deps/SoftFloat-3e/source/extF80_roundToInt.c created+154
......@@ -0,0 +1,154 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t
45 extF80_roundToInt( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
46{
47 union { struct extFloat80M s; extFloat80_t f; } uA;
48 uint_fast16_t uiA64, signUI64;
49 int_fast32_t exp;
50 uint_fast64_t sigA;
51 uint_fast16_t uiZ64;
52 uint_fast64_t sigZ;
53 struct exp32_sig64 normExpSig;
54 struct uint128 uiZ;
55 uint_fast64_t lastBitMask, roundBitsMask;
56 union { struct extFloat80M s; extFloat80_t f; } uZ;
57
58 /*------------------------------------------------------------------------
59 *------------------------------------------------------------------------*/
60 uA.f = a;
61 uiA64 = uA.s.signExp;
62 signUI64 = uiA64 & packToExtF80UI64( 1, 0 );
63 exp = expExtF80UI64( uiA64 );
64 sigA = uA.s.signif;
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( !(sigA & UINT64_C( 0x8000000000000000 )) && (exp != 0x7FFF) ) {
68 if ( !sigA ) {
69 uiZ64 = signUI64;
70 sigZ = 0;
71 goto uiZ;
72 }
73 normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
74 exp += normExpSig.exp;
75 sigA = normExpSig.sig;
76 }
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 if ( 0x403E <= exp ) {
80 if ( exp == 0x7FFF ) {
81 if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
82 uiZ = softfloat_propagateNaNExtF80UI( uiA64, sigA, 0, 0 );
83 uiZ64 = uiZ.v64;
84 sigZ = uiZ.v0;
85 goto uiZ;
86 }
87 sigZ = UINT64_C( 0x8000000000000000 );
88 } else {
89 sigZ = sigA;
90 }
91 uiZ64 = signUI64 | exp;
92 goto uiZ;
93 }
94 if ( exp <= 0x3FFE ) {
95 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
96 switch ( roundingMode ) {
97 case softfloat_round_near_even:
98 if ( !(sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) break;
99 case softfloat_round_near_maxMag:
100 if ( exp == 0x3FFE ) goto mag1;
101 break;
102 case softfloat_round_min:
103 if ( signUI64 ) goto mag1;
104 break;
105 case softfloat_round_max:
106 if ( !signUI64 ) goto mag1;
107 break;
108#ifdef SOFTFLOAT_ROUND_ODD
109 case softfloat_round_odd:
110 goto mag1;
111#endif
112 }
113 uiZ64 = signUI64;
114 sigZ = 0;
115 goto uiZ;
116 mag1:
117 uiZ64 = signUI64 | 0x3FFF;
118 sigZ = UINT64_C( 0x8000000000000000 );
119 goto uiZ;
120 }
121 /*------------------------------------------------------------------------
122 *------------------------------------------------------------------------*/
123 uiZ64 = signUI64 | exp;
124 lastBitMask = (uint_fast64_t) 1<<(0x403E - exp);
125 roundBitsMask = lastBitMask - 1;
126 sigZ = sigA;
127 if ( roundingMode == softfloat_round_near_maxMag ) {
128 sigZ += lastBitMask>>1;
129 } else if ( roundingMode == softfloat_round_near_even ) {
130 sigZ += lastBitMask>>1;
131 if ( !(sigZ & roundBitsMask) ) sigZ &= ~lastBitMask;
132 } else if (
133 roundingMode == (signUI64 ? softfloat_round_min : softfloat_round_max)
134 ) {
135 sigZ += roundBitsMask;
136 }
137 sigZ &= ~roundBitsMask;
138 if ( !sigZ ) {
139 ++uiZ64;
140 sigZ = UINT64_C( 0x8000000000000000 );
141 }
142 if ( sigZ != sigA ) {
143#ifdef SOFTFLOAT_ROUND_ODD
144 if ( roundingMode == softfloat_round_odd ) sigZ |= lastBitMask;
145#endif
146 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
147 }
148 uiZ:
149 uZ.s.signExp = uiZ64;
150 uZ.s.signif = sigZ;
151 return uZ.f;
152
153}
154
deps/SoftFloat-3e/source/extF80_sqrt.c created+176
......@@ -0,0 +1,176 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t extF80_sqrt( extFloat80_t a )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 bool signA;
50 int_fast32_t expA;
51 uint_fast64_t sigA;
52 struct uint128 uiZ;
53 uint_fast16_t uiZ64;
54 uint_fast64_t uiZ0;
55 struct exp32_sig64 normExpSig;
56 int_fast32_t expZ;
57 uint_fast32_t sig32A, recipSqrt32, sig32Z;
58 struct uint128 rem;
59 uint_fast64_t q, x64, sigZ;
60 struct uint128 y, term;
61 uint_fast64_t sigZExtra;
62 union { struct extFloat80M s; extFloat80_t f; } uZ;
63
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 uA.f = a;
67 uiA64 = uA.s.signExp;
68 uiA0 = uA.s.signif;
69 signA = signExtF80UI64( uiA64 );
70 expA = expExtF80UI64( uiA64 );
71 sigA = uiA0;
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 if ( expA == 0x7FFF ) {
75 if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
76 uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, 0, 0 );
77 uiZ64 = uiZ.v64;
78 uiZ0 = uiZ.v0;
79 goto uiZ;
80 }
81 if ( ! signA ) return a;
82 goto invalid;
83 }
84 /*------------------------------------------------------------------------
85 *------------------------------------------------------------------------*/
86 if ( signA ) {
87 if ( ! sigA ) goto zero;
88 goto invalid;
89 }
90 /*------------------------------------------------------------------------
91 *------------------------------------------------------------------------*/
92 if ( ! expA ) expA = 1;
93 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
94 if ( ! sigA ) goto zero;
95 normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
96 expA += normExpSig.exp;
97 sigA = normExpSig.sig;
98 }
99 /*------------------------------------------------------------------------
100 | (`sig32Z' is guaranteed to be a lower bound on the square root of
101 | `sig32A', which makes `sig32Z' also a lower bound on the square root of
102 | `sigA'.)
103 *------------------------------------------------------------------------*/
104 expZ = ((expA - 0x3FFF)>>1) + 0x3FFF;
105 expA &= 1;
106 sig32A = sigA>>32;
107 recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
108 sig32Z = ((uint_fast64_t) sig32A * recipSqrt32)>>32;
109 if ( expA ) {
110 sig32Z >>= 1;
111 rem = softfloat_shortShiftLeft128( 0, sigA, 61 );
112 } else {
113 rem = softfloat_shortShiftLeft128( 0, sigA, 62 );
114 }
115 rem.v64 -= (uint_fast64_t) sig32Z * sig32Z;
116 /*------------------------------------------------------------------------
117 *------------------------------------------------------------------------*/
118 q = ((uint32_t) (rem.v64>>2) * (uint_fast64_t) recipSqrt32)>>32;
119 x64 = (uint_fast64_t) sig32Z<<32;
120 sigZ = x64 + (q<<3);
121 y = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
122 /*------------------------------------------------------------------------
123 | (Repeating this loop is a rare occurrence.)
124 *------------------------------------------------------------------------*/
125 for (;;) {
126 term = softfloat_mul64ByShifted32To128( x64 + sigZ, q );
127 rem = softfloat_sub128( y.v64, y.v0, term.v64, term.v0 );
128 if ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) ) break;
129 --q;
130 sigZ -= 1<<3;
131 }
132 /*------------------------------------------------------------------------
133 *------------------------------------------------------------------------*/
134 q = (((rem.v64>>2) * recipSqrt32)>>32) + 2;
135 x64 = sigZ;
136 sigZ = (sigZ<<1) + (q>>25);
137 sigZExtra = (uint64_t) (q<<39);
138 /*------------------------------------------------------------------------
139 *------------------------------------------------------------------------*/
140 if ( (q & 0xFFFFFF) <= 2 ) {
141 q &= ~(uint_fast64_t) 0xFFFF;
142 sigZExtra = (uint64_t) (q<<39);
143 term = softfloat_mul64ByShifted32To128( x64 + (q>>27), q );
144 x64 = (uint32_t) (q<<5) * (uint_fast64_t) (uint32_t) q;
145 term = softfloat_add128( term.v64, term.v0, 0, x64 );
146 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 28 );
147 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
148 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
149 if ( ! sigZExtra ) --sigZ;
150 --sigZExtra;
151 } else {
152 if ( rem.v64 | rem.v0 ) sigZExtra |= 1;
153 }
154 }
155 return
156 softfloat_roundPackToExtF80(
157 0, expZ, sigZ, sigZExtra, extF80_roundingPrecision );
158 /*------------------------------------------------------------------------
159 *------------------------------------------------------------------------*/
160 invalid:
161 softfloat_raiseFlags( softfloat_flag_invalid );
162 uiZ64 = defaultNaNExtF80UI64;
163 uiZ0 = defaultNaNExtF80UI0;
164 goto uiZ;
165 /*------------------------------------------------------------------------
166 *------------------------------------------------------------------------*/
167 zero:
168 uiZ64 = packToExtF80UI64( signA, 0 );
169 uiZ0 = 0;
170 uiZ:
171 uZ.s.signExp = uiZ64;
172 uZ.s.signif = uiZ0;
173 return uZ.f;
174
175}
176
deps/SoftFloat-3e/source/extF80_sub.c created+80
......@@ -0,0 +1,80 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43extFloat80_t extF80_sub( extFloat80_t a, extFloat80_t b )
44{
45 union { struct extFloat80M s; extFloat80_t f; } uA;
46 uint_fast16_t uiA64;
47 uint_fast64_t uiA0;
48 bool signA;
49 union { struct extFloat80M s; extFloat80_t f; } uB;
50 uint_fast16_t uiB64;
51 uint_fast64_t uiB0;
52 bool signB;
53#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
54 extFloat80_t
55 (*magsFuncPtr)(
56 uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
57#endif
58
59 uA.f = a;
60 uiA64 = uA.s.signExp;
61 uiA0 = uA.s.signif;
62 signA = signExtF80UI64( uiA64 );
63 uB.f = b;
64 uiB64 = uB.s.signExp;
65 uiB0 = uB.s.signif;
66 signB = signExtF80UI64( uiB64 );
67#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
68 if ( signA == signB ) {
69 return softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
70 } else {
71 return softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
72 }
73#else
74 magsFuncPtr =
75 (signA == signB) ? softfloat_subMagsExtF80 : softfloat_addMagsExtF80;
76 return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
77#endif
78
79}
80
deps/SoftFloat-3e/source/extF80_to_f128.c created+75
......@@ -0,0 +1,75 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t extF80_to_f128( extFloat80_t a )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 uint_fast16_t exp;
50 uint_fast64_t frac;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 bool sign;
54 struct uint128 frac128;
55 union ui128_f128 uZ;
56
57 uA.f = a;
58 uiA64 = uA.s.signExp;
59 uiA0 = uA.s.signif;
60 exp = expExtF80UI64( uiA64 );
61 frac = uiA0 & UINT64_C( 0x7FFFFFFFFFFFFFFF );
62 if ( (exp == 0x7FFF) && frac ) {
63 softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
64 uiZ = softfloat_commonNaNToF128UI( &commonNaN );
65 } else {
66 sign = signExtF80UI64( uiA64 );
67 frac128 = softfloat_shortShiftLeft128( 0, frac, 49 );
68 uiZ.v64 = packToF128UI64( sign, exp, frac128.v64 );
69 uiZ.v0 = frac128.v0;
70 }
71 uZ.ui = uiZ;
72 return uZ.f;
73
74}
75
deps/SoftFloat-3e/source/extF80_to_f16.c created+96
......@@ -0,0 +1,96 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t extF80_to_f16( extFloat80_t a )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig;
52 struct commonNaN commonNaN;
53 uint_fast16_t uiZ, sig16;
54 union ui16_f16 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.s.signExp;
60 uiA0 = uA.s.signif;
61 sign = signExtF80UI64( uiA64 );
62 exp = expExtF80UI64( uiA64 );
63 sig = uiA0;
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 if ( exp == 0x7FFF ) {
67 if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
68 softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
69 uiZ = softfloat_commonNaNToF16UI( &commonNaN );
70 } else {
71 uiZ = packToF16UI( sign, 0x1F, 0 );
72 }
73 goto uiZ;
74 }
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 sig16 = softfloat_shortShiftRightJam64( sig, 49 );
78 if ( ! (exp | sig16) ) {
79 uiZ = packToF16UI( sign, 0, 0 );
80 goto uiZ;
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 exp -= 0x3FF1;
85 if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
86 if ( exp < -0x40 ) exp = -0x40;
87 }
88 return softfloat_roundPackToF16( sign, exp, sig16 );
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 uiZ:
92 uZ.ui = uiZ;
93 return uZ.f;
94
95}
96
deps/SoftFloat-3e/source/extF80_to_f32.c created+96
......@@ -0,0 +1,96 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t extF80_to_f32( extFloat80_t a )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig;
52 struct commonNaN commonNaN;
53 uint_fast32_t uiZ, sig32;
54 union ui32_f32 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.s.signExp;
60 uiA0 = uA.s.signif;
61 sign = signExtF80UI64( uiA64 );
62 exp = expExtF80UI64( uiA64 );
63 sig = uiA0;
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 if ( exp == 0x7FFF ) {
67 if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
68 softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
69 uiZ = softfloat_commonNaNToF32UI( &commonNaN );
70 } else {
71 uiZ = packToF32UI( sign, 0xFF, 0 );
72 }
73 goto uiZ;
74 }
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 sig32 = softfloat_shortShiftRightJam64( sig, 33 );
78 if ( ! (exp | sig32) ) {
79 uiZ = packToF32UI( sign, 0, 0 );
80 goto uiZ;
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 exp -= 0x3F81;
85 if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
86 if ( exp < -0x1000 ) exp = -0x1000;
87 }
88 return softfloat_roundPackToF32( sign, exp, sig32 );
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 uiZ:
92 uZ.ui = uiZ;
93 return uZ.f;
94
95}
96
deps/SoftFloat-3e/source/extF80_to_f64.c created+96
......@@ -0,0 +1,96 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t extF80_to_f64( extFloat80_t a )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 uint_fast64_t uiA0;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig;
52 struct commonNaN commonNaN;
53 uint_fast64_t uiZ;
54 union ui64_f64 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.s.signExp;
60 uiA0 = uA.s.signif;
61 sign = signExtF80UI64( uiA64 );
62 exp = expExtF80UI64( uiA64 );
63 sig = uiA0;
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 if ( ! (exp | sig) ) {
67 uiZ = packToF64UI( sign, 0, 0 );
68 goto uiZ;
69 }
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 if ( exp == 0x7FFF ) {
73 if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
74 softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
75 uiZ = softfloat_commonNaNToF64UI( &commonNaN );
76 } else {
77 uiZ = packToF64UI( sign, 0x7FF, 0 );
78 }
79 goto uiZ;
80 }
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 sig = softfloat_shortShiftRightJam64( sig, 1 );
84 exp -= 0x3C01;
85 if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
86 if ( exp < -0x1000 ) exp = -0x1000;
87 }
88 return softfloat_roundPackToF64( sign, exp, sig );
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 uiZ:
92 uZ.ui = uiZ;
93 return uZ.f;
94
95}
96
deps/SoftFloat-3e/source/extF80_to_i32.c created+83
......@@ -0,0 +1,83 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t
45 extF80_to_i32( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
46{
47 union { struct extFloat80M s; extFloat80_t f; } uA;
48 uint_fast16_t uiA64;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig;
52 int_fast32_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.s.signExp;
58 sign = signExtF80UI64( uiA64 );
59 exp = expExtF80UI64( uiA64 );
60 sig = uA.s.signif;
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
64 if ( (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) {
65#if (i32_fromNaN == i32_fromPosOverflow)
66 sign = 0;
67#elif (i32_fromNaN == i32_fromNegOverflow)
68 sign = 1;
69#else
70 softfloat_raiseFlags( softfloat_flag_invalid );
71 return i32_fromNaN;
72#endif
73 }
74#endif
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 shiftDist = 0x4032 - exp;
78 if ( shiftDist <= 0 ) shiftDist = 1;
79 sig = softfloat_shiftRightJam64( sig, shiftDist );
80 return softfloat_roundToI32( sign, sig, roundingMode, exact );
81
82}
83
deps/SoftFloat-3e/source/extF80_to_i32_r_minMag.c created+97
......@@ -0,0 +1,97 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t extF80_to_i32_r_minMag( extFloat80_t a, bool exact )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 int_fast32_t exp;
49 uint_fast64_t sig;
50 int_fast32_t shiftDist;
51 bool sign;
52 int_fast32_t absZ;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.s.signExp;
58 exp = expExtF80UI64( uiA64 );
59 sig = uA.s.signif;
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x403E - exp;
63 if ( 64 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signExtF80UI64( uiA64 );
72 if ( shiftDist < 33 ) {
73 if (
74 (uiA64 == packToExtF80UI64( 1, 0x401E ))
75 && (sig < UINT64_C( 0x8000000100000000 ))
76 ) {
77 if ( exact && (sig & UINT64_C( 0x00000000FFFFFFFF )) ) {
78 softfloat_exceptionFlags |= softfloat_flag_inexact;
79 }
80 return -0x7FFFFFFF - 1;
81 }
82 softfloat_raiseFlags( softfloat_flag_invalid );
83 return
84 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
85 ? i32_fromNaN
86 : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 absZ = sig>>shiftDist;
91 if ( exact && ((uint_fast64_t) (uint_fast32_t) absZ<<shiftDist != sig) ) {
92 softfloat_exceptionFlags |= softfloat_flag_inexact;
93 }
94 return sign ? -absZ : absZ;
95
96}
97
deps/SoftFloat-3e/source/extF80_to_i64.c created+89
......@@ -0,0 +1,89 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t
45 extF80_to_i64( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
46{
47 union { struct extFloat80M s; extFloat80_t f; } uA;
48 uint_fast16_t uiA64;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig;
52 int_fast32_t shiftDist;
53 uint_fast64_t sigExtra;
54 struct uint64_extra sig64Extra;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.s.signExp;
60 sign = signExtF80UI64( uiA64 );
61 exp = expExtF80UI64( uiA64 );
62 sig = uA.s.signif;
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 shiftDist = 0x403E - exp;
66 if ( shiftDist <= 0 ) {
67 /*--------------------------------------------------------------------
68 *--------------------------------------------------------------------*/
69 if ( shiftDist ) {
70 softfloat_raiseFlags( softfloat_flag_invalid );
71 return
72 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
73 ? i64_fromNaN
74 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
75 }
76 /*--------------------------------------------------------------------
77 *--------------------------------------------------------------------*/
78 sigExtra = 0;
79 } else {
80 /*--------------------------------------------------------------------
81 *--------------------------------------------------------------------*/
82 sig64Extra = softfloat_shiftRightJam64Extra( sig, 0, shiftDist );
83 sig = sig64Extra.v;
84 sigExtra = sig64Extra.extra;
85 }
86 return softfloat_roundToI64( sign, sig, sigExtra, roundingMode, exact );
87
88}
89
deps/SoftFloat-3e/source/extF80_to_i64_r_minMag.c created+94
......@@ -0,0 +1,94 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t extF80_to_i64_r_minMag( extFloat80_t a, bool exact )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 int_fast32_t exp;
49 uint_fast64_t sig;
50 int_fast32_t shiftDist;
51 bool sign;
52 int_fast64_t absZ;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.s.signExp;
58 exp = expExtF80UI64( uiA64 );
59 sig = uA.s.signif;
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x403E - exp;
63 if ( 64 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signExtF80UI64( uiA64 );
72 if ( shiftDist <= 0 ) {
73 if (
74 (uiA64 == packToExtF80UI64( 1, 0x403E ))
75 && (sig == UINT64_C( 0x8000000000000000 ))
76 ) {
77 return -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
78 }
79 softfloat_raiseFlags( softfloat_flag_invalid );
80 return
81 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
82 ? i64_fromNaN
83 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 absZ = sig>>shiftDist;
88 if ( exact && (uint64_t) (sig<<(-shiftDist & 63)) ) {
89 softfloat_exceptionFlags |= softfloat_flag_inexact;
90 }
91 return sign ? -absZ : absZ;
92
93}
94
deps/SoftFloat-3e/source/extF80_to_ui32.c created+83
......@@ -0,0 +1,83 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t
45 extF80_to_ui32( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
46{
47 union { struct extFloat80M s; extFloat80_t f; } uA;
48 uint_fast16_t uiA64;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig;
52 int_fast32_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.s.signExp;
58 sign = signExtF80UI64( uiA64 );
59 exp = expExtF80UI64( uiA64 );
60 sig = uA.s.signif;
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63#if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
64 if ( (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) {
65#if (ui32_fromNaN == ui32_fromPosOverflow)
66 sign = 0;
67#elif (ui32_fromNaN == ui32_fromNegOverflow)
68 sign = 1;
69#else
70 softfloat_raiseFlags( softfloat_flag_invalid );
71 return ui32_fromNaN;
72#endif
73 }
74#endif
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 shiftDist = 0x4032 - exp;
78 if ( shiftDist <= 0 ) shiftDist = 1;
79 sig = softfloat_shiftRightJam64( sig, shiftDist );
80 return softfloat_roundToUI32( sign, sig, roundingMode, exact );
81
82}
83
deps/SoftFloat-3e/source/extF80_to_ui32_r_minMag.c created+88
......@@ -0,0 +1,88 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t extF80_to_ui32_r_minMag( extFloat80_t a, bool exact )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 int_fast32_t exp;
49 uint_fast64_t sig;
50 int_fast32_t shiftDist;
51 bool sign;
52 uint_fast32_t z;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.s.signExp;
58 exp = expExtF80UI64( uiA64 );
59 sig = uA.s.signif;
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x403E - exp;
63 if ( 64 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signExtF80UI64( uiA64 );
72 if ( sign || (shiftDist < 32) ) {
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 return
75 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
76 ? ui32_fromNaN
77 : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 z = sig>>shiftDist;
82 if ( exact && ((uint_fast64_t) z<<shiftDist != sig) ) {
83 softfloat_exceptionFlags |= softfloat_flag_inexact;
84 }
85 return z;
86
87}
88
deps/SoftFloat-3e/source/extF80_to_ui64.c created+84
......@@ -0,0 +1,84 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t
45 extF80_to_ui64( extFloat80_t a, uint_fast8_t roundingMode, bool exact )
46{
47 union { struct extFloat80M s; extFloat80_t f; } uA;
48 uint_fast16_t uiA64;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig;
52 int_fast32_t shiftDist;
53 uint_fast64_t sigExtra;
54 struct uint64_extra sig64Extra;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.s.signExp;
60 sign = signExtF80UI64( uiA64 );
61 exp = expExtF80UI64( uiA64 );
62 sig = uA.s.signif;
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 shiftDist = 0x403E - exp;
66 if ( shiftDist < 0 ) {
67 softfloat_raiseFlags( softfloat_flag_invalid );
68 return
69 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
70 ? ui64_fromNaN
71 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
72 }
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 sigExtra = 0;
76 if ( shiftDist ) {
77 sig64Extra = softfloat_shiftRightJam64Extra( sig, 0, shiftDist );
78 sig = sig64Extra.v;
79 sigExtra = sig64Extra.extra;
80 }
81 return softfloat_roundToUI64( sign, sig, sigExtra, roundingMode, exact );
82
83}
84
deps/SoftFloat-3e/source/extF80_to_ui64_r_minMag.c created+88
......@@ -0,0 +1,88 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t extF80_to_ui64_r_minMag( extFloat80_t a, bool exact )
45{
46 union { struct extFloat80M s; extFloat80_t f; } uA;
47 uint_fast16_t uiA64;
48 int_fast32_t exp;
49 uint_fast64_t sig;
50 int_fast32_t shiftDist;
51 bool sign;
52 uint_fast64_t z;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.s.signExp;
58 exp = expExtF80UI64( uiA64 );
59 sig = uA.s.signif;
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x403E - exp;
63 if ( 64 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signExtF80UI64( uiA64 );
72 if ( sign || (shiftDist < 0) ) {
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 return
75 (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
76 ? ui64_fromNaN
77 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 z = sig>>shiftDist;
82 if ( exact && (z<<shiftDist != sig) ) {
83 softfloat_exceptionFlags |= softfloat_flag_inexact;
84 }
85 return z;
86
87}
88
deps/SoftFloat-3e/source/f128M_add.c created+97
......@@ -0,0 +1,97 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43#ifdef SOFTFLOAT_FAST_INT64
44
45void
46 f128M_add( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
47{
48 const uint64_t *aWPtr, *bWPtr;
49 uint_fast64_t uiA64, uiA0;
50 bool signA;
51 uint_fast64_t uiB64, uiB0;
52 bool signB;
53#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
54 float128_t
55 (*magsFuncPtr)(
56 uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
57#endif
58
59 aWPtr = (const uint64_t *) aPtr;
60 bWPtr = (const uint64_t *) bPtr;
61 uiA64 = aWPtr[indexWord( 2, 1 )];
62 uiA0 = aWPtr[indexWord( 2, 0 )];
63 signA = signF128UI64( uiA64 );
64 uiB64 = bWPtr[indexWord( 2, 1 )];
65 uiB0 = bWPtr[indexWord( 2, 0 )];
66 signB = signF128UI64( uiB64 );
67#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
68 if ( signA == signB ) {
69 *zPtr = softfloat_addMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
70 } else {
71 *zPtr = softfloat_subMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
72 }
73#else
74 magsFuncPtr =
75 (signA == signB) ? softfloat_addMagsF128 : softfloat_subMagsF128;
76 *zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
77#endif
78
79}
80
81#else
82
83void
84 f128M_add( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
85{
86
87 softfloat_addF128M(
88 (const uint32_t *) aPtr,
89 (const uint32_t *) bPtr,
90 (uint32_t *) zPtr,
91 false
92 );
93
94}
95
96#endif
97
deps/SoftFloat-3e/source/f128M_div.c created+187
......@@ -0,0 +1,187 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void
47 f128M_div( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
48{
49
50 *zPtr = f128_div( *aPtr, *bPtr );
51
52}
53
54#else
55
56void
57 f128M_div( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
58{
59 const uint32_t *aWPtr, *bWPtr;
60 uint32_t *zWPtr, uiA96;
61 bool signA;
62 int32_t expA;
63 uint32_t uiB96;
64 bool signB;
65 int32_t expB;
66 bool signZ;
67 uint32_t y[5], sigB[4];
68 int32_t expZ;
69 uint32_t recip32;
70 int ix;
71 uint64_t q64;
72 uint32_t q, qs[3], uiZ96;
73
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 aWPtr = (const uint32_t *) aPtr;
77 bWPtr = (const uint32_t *) bPtr;
78 zWPtr = (uint32_t *) zPtr;
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 uiA96 = aWPtr[indexWordHi( 4 )];
82 signA = signF128UI96( uiA96 );
83 expA = expF128UI96( uiA96 );
84 uiB96 = bWPtr[indexWordHi( 4 )];
85 signB = signF128UI96( uiB96 );
86 expB = expF128UI96( uiB96 );
87 signZ = signA ^ signB;
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
91 if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
92 if ( expA == 0x7FFF ) {
93 if ( expB == 0x7FFF ) goto invalid;
94 goto infinity;
95 }
96 goto zero;
97 }
98 /*------------------------------------------------------------------------
99 *------------------------------------------------------------------------*/
100 expA = softfloat_shiftNormSigF128M( aWPtr, 13, y );
101 expB = softfloat_shiftNormSigF128M( bWPtr, 13, sigB );
102 if ( expA == -128 ) {
103 if ( expB == -128 ) goto invalid;
104 goto zero;
105 }
106 if ( expB == -128 ) {
107 softfloat_raiseFlags( softfloat_flag_infinite );
108 goto infinity;
109 }
110 /*------------------------------------------------------------------------
111 *------------------------------------------------------------------------*/
112 expZ = expA - expB + 0x3FFE;
113 if ( softfloat_compare128M( y, sigB ) < 0 ) {
114 --expZ;
115 softfloat_add128M( y, y, y );
116 }
117 recip32 =
118 softfloat_approxRecip32_1(
119 ((uint64_t) sigB[indexWord( 4, 3 )]<<32 | sigB[indexWord( 4, 2 )])
120 >>30
121 );
122 ix = 3;
123 for (;;) {
124 q64 = (uint64_t) y[indexWordHi( 4 )] * recip32;
125 q = (q64 + 0x80000000)>>32;
126 --ix;
127 if ( ix < 0 ) break;
128 softfloat_remStep128MBy32( y, 29, sigB, q, y );
129 if ( y[indexWordHi( 4 )] & 0x80000000 ) {
130 --q;
131 softfloat_add128M( y, sigB, y );
132 }
133 qs[ix] = q;
134 }
135 /*------------------------------------------------------------------------
136 *------------------------------------------------------------------------*/
137 if ( ((q + 1) & 7) < 2 ) {
138 softfloat_remStep128MBy32( y, 29, sigB, q, y );
139 if ( y[indexWordHi( 4 )] & 0x80000000 ) {
140 --q;
141 softfloat_add128M( y, sigB, y );
142 } else if ( softfloat_compare128M( sigB, y ) <= 0 ) {
143 ++q;
144 softfloat_sub128M( y, sigB, y );
145 }
146 if (
147 y[indexWordLo( 4 )] || y[indexWord( 4, 1 )]
148 || (y[indexWord( 4, 2 )] | y[indexWord( 4, 3 )])
149 ) {
150 q |= 1;
151 }
152 }
153 /*------------------------------------------------------------------------
154 *------------------------------------------------------------------------*/
155 q64 = (uint64_t) q<<28;
156 y[indexWord( 5, 0 )] = q64;
157 q64 = ((uint64_t) qs[0]<<25) + (q64>>32);
158 y[indexWord( 5, 1 )] = q64;
159 q64 = ((uint64_t) qs[1]<<22) + (q64>>32);
160 y[indexWord( 5, 2 )] = q64;
161 q64 = ((uint64_t) qs[2]<<19) + (q64>>32);
162 y[indexWord( 5, 3 )] = q64;
163 y[indexWord( 5, 4 )] = q64>>32;
164 softfloat_roundPackMToF128M( signZ, expZ, y, zWPtr );
165 return;
166 /*------------------------------------------------------------------------
167 *------------------------------------------------------------------------*/
168 invalid:
169 softfloat_invalidF128M( zWPtr );
170 return;
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 infinity:
174 uiZ96 = packToF128UI96( signZ, 0x7FFF, 0 );
175 goto uiZ96;
176 zero:
177 uiZ96 = packToF128UI96( signZ, 0, 0 );
178 uiZ96:
179 zWPtr[indexWordHi( 4 )] = uiZ96;
180 zWPtr[indexWord( 4, 2 )] = 0;
181 zWPtr[indexWord( 4, 1 )] = 0;
182 zWPtr[indexWord( 4, 0 )] = 0;
183
184}
185
186#endif
187
deps/SoftFloat-3e/source/f128M_eq.c created+100
......@@ -0,0 +1,100 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46bool f128M_eq( const float128_t *aPtr, const float128_t *bPtr )
47{
48
49 return f128_eq( *aPtr, *bPtr );
50
51}
52
53#else
54
55bool f128M_eq( const float128_t *aPtr, const float128_t *bPtr )
56{
57 const uint32_t *aWPtr, *bWPtr;
58 uint32_t wordA, wordB, uiA96, uiB96;
59 bool possibleOppositeZeros;
60 uint32_t mashWord;
61
62 aWPtr = (const uint32_t *) aPtr;
63 bWPtr = (const uint32_t *) bPtr;
64 wordA = aWPtr[indexWord( 4, 2 )];
65 wordB = bWPtr[indexWord( 4, 2 )];
66 if ( wordA != wordB ) goto false_checkSigNaNs;
67 uiA96 = aWPtr[indexWordHi( 4 )];
68 uiB96 = bWPtr[indexWordHi( 4 )];
69 possibleOppositeZeros = false;
70 if ( uiA96 != uiB96 ) {
71 possibleOppositeZeros = (((uiA96 | uiB96) & 0x7FFFFFFF) == 0);
72 if ( ! possibleOppositeZeros ) goto false_checkSigNaNs;
73 }
74 mashWord = wordA | wordB;
75 wordA = aWPtr[indexWord( 4, 1 )];
76 wordB = bWPtr[indexWord( 4, 1 )];
77 if ( wordA != wordB ) goto false_checkSigNaNs;
78 mashWord |= wordA | wordB;
79 wordA = aWPtr[indexWord( 4, 0 )];
80 wordB = bWPtr[indexWord( 4, 0 )];
81 if ( wordA != wordB ) goto false_checkSigNaNs;
82 if ( possibleOppositeZeros && ((mashWord | wordA | wordB) != 0) ) {
83 goto false_checkSigNaNs;
84 }
85 if ( ! softfloat_isNaNF128M( aWPtr ) && ! softfloat_isNaNF128M( bWPtr ) ) {
86 return true;
87 }
88 false_checkSigNaNs:
89 if (
90 f128M_isSignalingNaN( (const float128_t *) aWPtr )
91 || f128M_isSignalingNaN( (const float128_t *) bWPtr )
92 ) {
93 softfloat_raiseFlags( softfloat_flag_invalid );
94 }
95 return false;
96
97}
98
99#endif
100
deps/SoftFloat-3e/source/f128M_eq_signaling.c created+92
......@@ -0,0 +1,92 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46bool f128M_eq_signaling( const float128_t *aPtr, const float128_t *bPtr )
47{
48
49 return f128_eq_signaling( *aPtr, *bPtr );
50
51}
52
53#else
54
55bool f128M_eq_signaling( const float128_t *aPtr, const float128_t *bPtr )
56{
57 const uint32_t *aWPtr, *bWPtr;
58 uint32_t wordA, wordB, uiA96, uiB96;
59 bool possibleOppositeZeros;
60 uint32_t mashWord;
61
62 aWPtr = (const uint32_t *) aPtr;
63 bWPtr = (const uint32_t *) bPtr;
64 if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
65 softfloat_raiseFlags( softfloat_flag_invalid );
66 return false;
67 }
68 wordA = aWPtr[indexWord( 4, 2 )];
69 wordB = bWPtr[indexWord( 4, 2 )];
70 if ( wordA != wordB ) return false;
71 uiA96 = aWPtr[indexWordHi( 4 )];
72 uiB96 = bWPtr[indexWordHi( 4 )];
73 possibleOppositeZeros = false;
74 if ( uiA96 != uiB96 ) {
75 possibleOppositeZeros = (((uiA96 | uiB96) & 0x7FFFFFFF) == 0);
76 if ( ! possibleOppositeZeros ) return false;
77 }
78 mashWord = wordA | wordB;
79 wordA = aWPtr[indexWord( 4, 1 )];
80 wordB = bWPtr[indexWord( 4, 1 )];
81 if ( wordA != wordB ) return false;
82 mashWord |= wordA | wordB;
83 wordA = aWPtr[indexWord( 4, 0 )];
84 wordB = bWPtr[indexWord( 4, 0 )];
85 return
86 (wordA == wordB)
87 && (! possibleOppositeZeros || ((mashWord | wordA | wordB) == 0));
88
89}
90
91#endif
92
deps/SoftFloat-3e/source/f128M_le.c created+93
......@@ -0,0 +1,93 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43#ifdef SOFTFLOAT_FAST_INT64
44
45bool f128M_le( const float128_t *aPtr, const float128_t *bPtr )
46{
47
48 return f128_le( *aPtr, *bPtr );
49
50}
51
52#else
53
54bool f128M_le( const float128_t *aPtr, const float128_t *bPtr )
55{
56 const uint32_t *aWPtr, *bWPtr;
57 uint32_t uiA96, uiB96;
58 bool signA, signB;
59 uint32_t wordA, wordB;
60
61 aWPtr = (const uint32_t *) aPtr;
62 bWPtr = (const uint32_t *) bPtr;
63 if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
64 softfloat_raiseFlags( softfloat_flag_invalid );
65 return false;
66 }
67 uiA96 = aWPtr[indexWordHi( 4 )];
68 uiB96 = bWPtr[indexWordHi( 4 )];
69 signA = signF128UI96( uiA96 );
70 signB = signF128UI96( uiB96 );
71 if ( signA != signB ) {
72 if ( signA ) return true;
73 if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return false;
74 wordA = aWPtr[indexWord( 4, 2 )];
75 wordB = bWPtr[indexWord( 4, 2 )];
76 if ( wordA | wordB ) return false;
77 wordA = aWPtr[indexWord( 4, 1 )];
78 wordB = bWPtr[indexWord( 4, 1 )];
79 if ( wordA | wordB ) return false;
80 wordA = aWPtr[indexWord( 4, 0 )];
81 wordB = bWPtr[indexWord( 4, 0 )];
82 return ((wordA | wordB) == 0);
83 }
84 if ( signA ) {
85 aWPtr = (const uint32_t *) bPtr;
86 bWPtr = (const uint32_t *) aPtr;
87 }
88 return (softfloat_compare128M( aWPtr, bWPtr ) <= 0);
89
90}
91
92#endif
93
deps/SoftFloat-3e/source/f128M_le_quiet.c created+96
......@@ -0,0 +1,96 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46bool f128M_le_quiet( const float128_t *aPtr, const float128_t *bPtr )
47{
48
49 return f128_le_quiet( *aPtr, *bPtr );
50
51}
52
53#else
54
55bool f128M_le_quiet( const float128_t *aPtr, const float128_t *bPtr )
56{
57 const uint32_t *aWPtr, *bWPtr;
58 uint32_t uiA96, uiB96;
59 bool signA, signB;
60 uint32_t wordA, wordB;
61
62 aWPtr = (const uint32_t *) aPtr;
63 bWPtr = (const uint32_t *) bPtr;
64 if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
65 if ( f128M_isSignalingNaN( aPtr ) || f128M_isSignalingNaN( bPtr ) ) {
66 softfloat_raiseFlags( softfloat_flag_invalid );
67 }
68 return false;
69 }
70 uiA96 = aWPtr[indexWordHi( 4 )];
71 uiB96 = bWPtr[indexWordHi( 4 )];
72 signA = signF128UI96( uiA96 );
73 signB = signF128UI96( uiB96 );
74 if ( signA != signB ) {
75 if ( signA ) return true;
76 if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return false;
77 wordA = aWPtr[indexWord( 4, 2 )];
78 wordB = bWPtr[indexWord( 4, 2 )];
79 if ( wordA | wordB ) return false;
80 wordA = aWPtr[indexWord( 4, 1 )];
81 wordB = bWPtr[indexWord( 4, 1 )];
82 if ( wordA | wordB ) return false;
83 wordA = aWPtr[indexWord( 4, 0 )];
84 wordB = bWPtr[indexWord( 4, 0 )];
85 return ((wordA | wordB) == 0);
86 }
87 if ( signA ) {
88 aWPtr = (const uint32_t *) bPtr;
89 bWPtr = (const uint32_t *) aPtr;
90 }
91 return (softfloat_compare128M( aWPtr, bWPtr ) <= 0);
92
93}
94
95#endif
96
deps/SoftFloat-3e/source/f128M_lt.c created+93
......@@ -0,0 +1,93 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43#ifdef SOFTFLOAT_FAST_INT64
44
45bool f128M_lt( const float128_t *aPtr, const float128_t *bPtr )
46{
47
48 return f128_lt( *aPtr, *bPtr );
49
50}
51
52#else
53
54bool f128M_lt( const float128_t *aPtr, const float128_t *bPtr )
55{
56 const uint32_t *aWPtr, *bWPtr;
57 uint32_t uiA96, uiB96;
58 bool signA, signB;
59 uint32_t wordA, wordB;
60
61 aWPtr = (const uint32_t *) aPtr;
62 bWPtr = (const uint32_t *) bPtr;
63 if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
64 softfloat_raiseFlags( softfloat_flag_invalid );
65 return false;
66 }
67 uiA96 = aWPtr[indexWordHi( 4 )];
68 uiB96 = bWPtr[indexWordHi( 4 )];
69 signA = signF128UI96( uiA96 );
70 signB = signF128UI96( uiB96 );
71 if ( signA != signB ) {
72 if ( signB ) return false;
73 if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return true;
74 wordA = aWPtr[indexWord( 4, 2 )];
75 wordB = bWPtr[indexWord( 4, 2 )];
76 if ( wordA | wordB ) return true;
77 wordA = aWPtr[indexWord( 4, 1 )];
78 wordB = bWPtr[indexWord( 4, 1 )];
79 if ( wordA | wordB ) return true;
80 wordA = aWPtr[indexWord( 4, 0 )];
81 wordB = bWPtr[indexWord( 4, 0 )];
82 return ((wordA | wordB) != 0);
83 }
84 if ( signA ) {
85 aWPtr = (const uint32_t *) bPtr;
86 bWPtr = (const uint32_t *) aPtr;
87 }
88 return (softfloat_compare128M( aWPtr, bWPtr ) < 0);
89
90}
91
92#endif
93
deps/SoftFloat-3e/source/f128M_lt_quiet.c created+96
......@@ -0,0 +1,96 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46bool f128M_lt_quiet( const float128_t *aPtr, const float128_t *bPtr )
47{
48
49 return f128_lt_quiet( *aPtr, *bPtr );
50
51}
52
53#else
54
55bool f128M_lt_quiet( const float128_t *aPtr, const float128_t *bPtr )
56{
57 const uint32_t *aWPtr, *bWPtr;
58 uint32_t uiA96, uiB96;
59 bool signA, signB;
60 uint32_t wordA, wordB;
61
62 aWPtr = (const uint32_t *) aPtr;
63 bWPtr = (const uint32_t *) bPtr;
64 if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
65 if ( f128M_isSignalingNaN( aPtr ) || f128M_isSignalingNaN( bPtr ) ) {
66 softfloat_raiseFlags( softfloat_flag_invalid );
67 }
68 return false;
69 }
70 uiA96 = aWPtr[indexWordHi( 4 )];
71 uiB96 = bWPtr[indexWordHi( 4 )];
72 signA = signF128UI96( uiA96 );
73 signB = signF128UI96( uiB96 );
74 if ( signA != signB ) {
75 if ( signB ) return false;
76 if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return true;
77 wordA = aWPtr[indexWord( 4, 2 )];
78 wordB = bWPtr[indexWord( 4, 2 )];
79 if ( wordA | wordB ) return true;
80 wordA = aWPtr[indexWord( 4, 1 )];
81 wordB = bWPtr[indexWord( 4, 1 )];
82 if ( wordA | wordB ) return true;
83 wordA = aWPtr[indexWord( 4, 0 )];
84 wordB = bWPtr[indexWord( 4, 0 )];
85 return ((wordA | wordB) != 0);
86 }
87 if ( signA ) {
88 aWPtr = (const uint32_t *) bPtr;
89 bWPtr = (const uint32_t *) aPtr;
90 }
91 return (softfloat_compare128M( aWPtr, bWPtr ) < 0);
92
93}
94
95#endif
96
deps/SoftFloat-3e/source/f128M_mul.c created+158
......@@ -0,0 +1,158 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void
47 f128M_mul( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
48{
49
50 *zPtr = f128_mul( *aPtr, *bPtr );
51
52}
53
54#else
55
56void
57 f128M_mul( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
58{
59 const uint32_t *aWPtr, *bWPtr;
60 uint32_t *zWPtr;
61 uint32_t uiA96;
62 int32_t expA;
63 uint32_t uiB96;
64 int32_t expB;
65 bool signZ;
66 const uint32_t *ptr;
67 uint32_t uiZ96, sigA[4];
68 uint_fast8_t shiftDist;
69 uint32_t sigB[4];
70 int32_t expZ;
71 uint32_t sigProd[8], *extSigZPtr;
72
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 aWPtr = (const uint32_t *) aPtr;
76 bWPtr = (const uint32_t *) bPtr;
77 zWPtr = (uint32_t *) zPtr;
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 uiA96 = aWPtr[indexWordHi( 4 )];
81 expA = expF128UI96( uiA96 );
82 uiB96 = bWPtr[indexWordHi( 4 )];
83 expB = expF128UI96( uiB96 );
84 signZ = signF128UI96( uiA96 ) ^ signF128UI96( uiB96 );
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
88 if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
89 ptr = aWPtr;
90 if ( ! expA ) goto possiblyInvalid;
91 if ( ! expB ) {
92 ptr = bWPtr;
93 possiblyInvalid:
94 if (
95 ! fracF128UI96( ptr[indexWordHi( 4 )] )
96 && ! (ptr[indexWord( 4, 2 )] | ptr[indexWord( 4, 1 )]
97 | ptr[indexWord( 4, 0 )])
98 ) {
99 softfloat_invalidF128M( zWPtr );
100 return;
101 }
102 }
103 uiZ96 = packToF128UI96( signZ, 0x7FFF, 0 );
104 goto uiZ96;
105 }
106 /*------------------------------------------------------------------------
107 *------------------------------------------------------------------------*/
108 if ( expA ) {
109 sigA[indexWordHi( 4 )] = fracF128UI96( uiA96 ) | 0x00010000;
110 sigA[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
111 sigA[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
112 sigA[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
113 } else {
114 expA = softfloat_shiftNormSigF128M( aWPtr, 0, sigA );
115 if ( expA == -128 ) goto zero;
116 }
117 if ( expB ) {
118 sigB[indexWordHi( 4 )] = fracF128UI96( uiB96 ) | 0x00010000;
119 sigB[indexWord( 4, 2 )] = bWPtr[indexWord( 4, 2 )];
120 sigB[indexWord( 4, 1 )] = bWPtr[indexWord( 4, 1 )];
121 sigB[indexWord( 4, 0 )] = bWPtr[indexWord( 4, 0 )];
122 } else {
123 expB = softfloat_shiftNormSigF128M( bWPtr, 0, sigB );
124 if ( expB == -128 ) goto zero;
125 }
126 /*------------------------------------------------------------------------
127 *------------------------------------------------------------------------*/
128 expZ = expA + expB - 0x4000;
129 softfloat_mul128MTo256M( sigA, sigB, sigProd );
130 if (
131 sigProd[indexWord( 8, 2 )]
132 || (sigProd[indexWord( 8, 1 )] | sigProd[indexWord( 8, 0 )])
133 ) {
134 sigProd[indexWord( 8, 3 )] |= 1;
135 }
136 extSigZPtr = &sigProd[indexMultiwordHi( 8, 5 )];
137 shiftDist = 16;
138 if ( extSigZPtr[indexWordHi( 5 )] & 2 ) {
139 ++expZ;
140 shiftDist = 15;
141 }
142 softfloat_shortShiftLeft160M( extSigZPtr, shiftDist, extSigZPtr );
143 softfloat_roundPackMToF128M( signZ, expZ, extSigZPtr, zWPtr );
144 return;
145 /*------------------------------------------------------------------------
146 *------------------------------------------------------------------------*/
147 zero:
148 uiZ96 = packToF128UI96( signZ, 0, 0 );
149 uiZ96:
150 zWPtr[indexWordHi( 4 )] = uiZ96;
151 zWPtr[indexWord( 4, 2 )] = 0;
152 zWPtr[indexWord( 4, 1 )] = 0;
153 zWPtr[indexWord( 4, 0 )] = 0;
154
155}
156
157#endif
158
deps/SoftFloat-3e/source/f128M_mulAdd.c created+92
......@@ -0,0 +1,92 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void
45 f128M_mulAdd(
46 const float128_t *aPtr,
47 const float128_t *bPtr,
48 const float128_t *cPtr,
49 float128_t *zPtr
50 )
51{
52 const uint64_t *aWPtr, *bWPtr, *cWPtr;
53 uint_fast64_t uiA64, uiA0;
54 uint_fast64_t uiB64, uiB0;
55 uint_fast64_t uiC64, uiC0;
56
57 aWPtr = (const uint64_t *) aPtr;
58 bWPtr = (const uint64_t *) bPtr;
59 cWPtr = (const uint64_t *) cPtr;
60 uiA64 = aWPtr[indexWord( 2, 1 )];
61 uiA0 = aWPtr[indexWord( 2, 0 )];
62 uiB64 = bWPtr[indexWord( 2, 1 )];
63 uiB0 = bWPtr[indexWord( 2, 0 )];
64 uiC64 = cWPtr[indexWord( 2, 1 )];
65 uiC0 = cWPtr[indexWord( 2, 0 )];
66 *zPtr = softfloat_mulAddF128( uiA64, uiA0, uiB64, uiB0, uiC64, uiC0, 0 );
67
68}
69
70#else
71
72void
73 f128M_mulAdd(
74 const float128_t *aPtr,
75 const float128_t *bPtr,
76 const float128_t *cPtr,
77 float128_t *zPtr
78 )
79{
80
81 softfloat_mulAddF128M(
82 (const uint32_t *) aPtr,
83 (const uint32_t *) bPtr,
84 (const uint32_t *) cPtr,
85 (uint32_t *) zPtr,
86 0
87 );
88
89}
90
91#endif
92
deps/SoftFloat-3e/source/f128M_rem.c created+182
......@@ -0,0 +1,182 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void
47 f128M_rem( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
48{
49
50 *zPtr = f128_rem( *aPtr, *bPtr );
51
52}
53
54#else
55
56void
57 f128M_rem( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
58{
59 const uint32_t *aWPtr, *bWPtr;
60 uint32_t *zWPtr, uiA96;
61 int32_t expA, expB;
62 uint32_t x[4], rem1[5], *remPtr;
63 bool signRem;
64 int32_t expDiff;
65 uint32_t q, recip32;
66 uint64_t q64;
67 uint32_t rem2[5], *altRemPtr, *newRemPtr, wordMeanRem;
68
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 aWPtr = (const uint32_t *) aPtr;
72 bWPtr = (const uint32_t *) bPtr;
73 zWPtr = (uint32_t *) zPtr;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 uiA96 = aWPtr[indexWordHi( 4 )];
77 expA = expF128UI96( uiA96 );
78 expB = expF128UI96( bWPtr[indexWordHi( 4 )] );
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
82 if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
83 if ( expA == 0x7FFF ) goto invalid;
84 goto copyA;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 if ( expA < expB - 1 ) goto copyA;
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 expB = softfloat_shiftNormSigF128M( bWPtr, 13, x );
92 if ( expB == -128 ) goto invalid;
93 remPtr = &rem1[indexMultiwordLo( 5, 4 )];
94 expA = softfloat_shiftNormSigF128M( aWPtr, 13, remPtr );
95 if ( expA == -128 ) goto copyA;
96 signRem = signF128UI96( uiA96 );
97 /*------------------------------------------------------------------------
98 *------------------------------------------------------------------------*/
99 expDiff = expA - expB;
100 if ( expDiff < 1 ) {
101 if ( expDiff < -1 ) goto copyA;
102 if ( expDiff ) {
103 --expB;
104 softfloat_add128M( x, x, x );
105 q = 0;
106 } else {
107 q = (softfloat_compare128M( x, remPtr ) <= 0);
108 if ( q ) softfloat_sub128M( remPtr, x, remPtr );
109 }
110 } else {
111 recip32 =
112 softfloat_approxRecip32_1(
113 ((uint64_t) x[indexWord( 4, 3 )]<<32 | x[indexWord( 4, 2 )])
114 >>30
115 );
116 expDiff -= 30;
117 for (;;) {
118 q64 = (uint64_t) remPtr[indexWordHi( 4 )] * recip32;
119 if ( expDiff < 0 ) break;
120 q = (q64 + 0x80000000)>>32;
121 softfloat_remStep128MBy32( remPtr, 29, x, q, remPtr );
122 if ( remPtr[indexWordHi( 4 )] & 0x80000000 ) {
123 softfloat_add128M( remPtr, x, remPtr );
124 }
125 expDiff -= 29;
126 }
127 /*--------------------------------------------------------------------
128 | (`expDiff' cannot be less than -29 here.)
129 *--------------------------------------------------------------------*/
130 q = (uint32_t) (q64>>32)>>(~expDiff & 31);
131 softfloat_remStep128MBy32( remPtr, expDiff + 30, x, q, remPtr );
132 if ( remPtr[indexWordHi( 4 )] & 0x80000000 ) {
133 altRemPtr = &rem2[indexMultiwordLo( 5, 4 )];
134 softfloat_add128M( remPtr, x, altRemPtr );
135 goto selectRem;
136 }
137 }
138 /*------------------------------------------------------------------------
139 *------------------------------------------------------------------------*/
140 altRemPtr = &rem2[indexMultiwordLo( 5, 4 )];
141 do {
142 ++q;
143 newRemPtr = altRemPtr;
144 softfloat_sub128M( remPtr, x, newRemPtr );
145 altRemPtr = remPtr;
146 remPtr = newRemPtr;
147 } while ( ! (remPtr[indexWordHi( 4 )] & 0x80000000) );
148 selectRem:
149 softfloat_add128M( remPtr, altRemPtr, x );
150 wordMeanRem = x[indexWordHi( 4 )];
151 if (
152 (wordMeanRem & 0x80000000)
153 || (! wordMeanRem && (q & 1) && ! x[indexWord( 4, 0 )]
154 && ! (x[indexWord( 4, 2 )] | x[indexWord( 4, 1 )]))
155 ) {
156 remPtr = altRemPtr;
157 }
158 if ( remPtr[indexWordHi( 4 )] & 0x80000000 ) {
159 signRem = ! signRem;
160 softfloat_negX128M( remPtr );
161 }
162 remPtr -= indexMultiwordLo( 5, 4 );
163 remPtr[indexWordHi( 5 )] = 0;
164 softfloat_normRoundPackMToF128M( signRem, expB + 18, remPtr, zWPtr );
165 return;
166 /*------------------------------------------------------------------------
167 *------------------------------------------------------------------------*/
168 invalid:
169 softfloat_invalidF128M( zWPtr );
170 return;
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 copyA:
174 zWPtr[indexWordHi( 4 )] = uiA96;
175 zWPtr[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
176 zWPtr[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
177 zWPtr[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
178
179}
180
181#endif
182
deps/SoftFloat-3e/source/f128M_roundToInt.c created+223
......@@ -0,0 +1,223 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void
47 f128M_roundToInt(
48 const float128_t *aPtr,
49 uint_fast8_t roundingMode,
50 bool exact,
51 float128_t *zPtr
52 )
53{
54
55 *zPtr = f128_roundToInt( *aPtr, roundingMode, exact );
56
57}
58
59#else
60
61void
62 f128M_roundToInt(
63 const float128_t *aPtr,
64 uint_fast8_t roundingMode,
65 bool exact,
66 float128_t *zPtr
67 )
68{
69 const uint32_t *aWPtr;
70 uint32_t *zWPtr;
71 uint32_t ui96;
72 int32_t exp;
73 uint32_t sigExtra;
74 bool sign;
75 uint_fast8_t bitPos;
76 bool roundNear;
77 unsigned int index, lastIndex;
78 bool extra;
79 uint32_t wordA, bit, wordZ;
80 uint_fast8_t carry;
81 uint32_t extrasMask;
82
83 /*------------------------------------------------------------------------
84 *------------------------------------------------------------------------*/
85 aWPtr = (const uint32_t *) aPtr;
86 zWPtr = (uint32_t *) zPtr;
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 ui96 = aWPtr[indexWordHi( 4 )];
90 exp = expF128UI96( ui96 );
91 /*------------------------------------------------------------------------
92 *------------------------------------------------------------------------*/
93 if ( exp < 0x3FFF ) {
94 zWPtr[indexWord( 4, 2 )] = 0;
95 zWPtr[indexWord( 4, 1 )] = 0;
96 zWPtr[indexWord( 4, 0 )] = 0;
97 sigExtra = aWPtr[indexWord( 4, 2 )];
98 if ( !sigExtra ) {
99 sigExtra = aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )];
100 }
101 if ( !sigExtra && !(ui96 & 0x7FFFFFFF) ) goto ui96;
102 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
103 sign = signF128UI96( ui96 );
104 switch ( roundingMode ) {
105 case softfloat_round_near_even:
106 if ( !fracF128UI96( ui96 ) && !sigExtra ) break;
107 case softfloat_round_near_maxMag:
108 if ( exp == 0x3FFE ) goto mag1;
109 break;
110 case softfloat_round_min:
111 if ( sign ) goto mag1;
112 break;
113 case softfloat_round_max:
114 if ( !sign ) goto mag1;
115 break;
116#ifdef SOFTFLOAT_ROUND_ODD
117 case softfloat_round_odd:
118 goto mag1;
119#endif
120 }
121 ui96 = packToF128UI96( sign, 0, 0 );
122 goto ui96;
123 mag1:
124 ui96 = packToF128UI96( sign, 0x3FFF, 0 );
125 goto ui96;
126 }
127 /*------------------------------------------------------------------------
128 *------------------------------------------------------------------------*/
129 if ( 0x406F <= exp ) {
130 if (
131 (exp == 0x7FFF)
132 && (fracF128UI96( ui96 )
133 || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
134 | aWPtr[indexWord( 4, 0 )]))
135 ) {
136 softfloat_propagateNaNF128M( aWPtr, 0, zWPtr );
137 return;
138 }
139 zWPtr[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
140 zWPtr[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
141 zWPtr[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
142 goto ui96;
143 }
144 /*------------------------------------------------------------------------
145 *------------------------------------------------------------------------*/
146 bitPos = 0x406F - exp;
147 roundNear =
148 (roundingMode == softfloat_round_near_maxMag)
149 || (roundingMode == softfloat_round_near_even);
150 bitPos -= roundNear;
151 index = indexWordLo( 4 );
152 lastIndex = indexWordHi( 4 );
153 extra = 0;
154 for (;;) {
155 wordA = aWPtr[index];
156 if ( bitPos < 32 ) break;
157 if ( wordA ) extra = 1;
158 zWPtr[index] = 0;
159 index += wordIncr;
160 bitPos -= 32;
161 }
162 bit = (uint32_t) 1<<bitPos;
163 if ( roundNear ) {
164 wordZ = wordA + bit;
165 carry = (wordZ < wordA);
166 bit <<= 1;
167 extrasMask = bit - 1;
168 if ( exact && (extra || (wordA & extrasMask)) ) {
169 softfloat_exceptionFlags |= softfloat_flag_inexact;
170 }
171 if (
172 (roundingMode == softfloat_round_near_even)
173 && !extra && !(wordZ & extrasMask)
174 ) {
175 if ( !bit ) {
176 zWPtr[index] = wordZ;
177 index += wordIncr;
178 wordZ = aWPtr[index] + carry;
179 carry &= !wordZ;
180 zWPtr[index] = wordZ & ~1;
181 goto propagateCarry;
182 }
183 wordZ &= ~bit;
184 }
185 } else {
186 wordZ = wordA;
187 carry = 0;
188 extrasMask = bit - 1;
189 if ( extra || (wordA & extrasMask) ) {
190 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
191 if (
192 roundingMode
193 == (signF128UI96( ui96 ) ? softfloat_round_min
194 : softfloat_round_max)
195 ) {
196 wordZ += bit;
197 carry = (wordZ < wordA);
198#ifdef SOFTFLOAT_ROUND_ODD
199 } else if ( roundingMode == softfloat_round_odd ) {
200 wordZ |= bit;
201#endif
202 }
203 }
204 }
205 wordZ &= ~extrasMask;
206 zWPtr[index] = wordZ;
207 propagateCarry:
208 while ( index != lastIndex ) {
209 index += wordIncr;
210 wordZ = aWPtr[index] + carry;
211 zWPtr[index] = wordZ;
212 carry &= !wordZ;
213 }
214 return;
215 /*------------------------------------------------------------------------
216 *------------------------------------------------------------------------*/
217 ui96:
218 zWPtr[indexWordHi( 4 )] = ui96;
219
220}
221
222#endif
223
deps/SoftFloat-3e/source/f128M_sqrt.c created+228
......@@ -0,0 +1,228 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void f128M_sqrt( const float128_t *aPtr, float128_t *zPtr )
47{
48
49 *zPtr = f128_sqrt( *aPtr );
50
51}
52
53#else
54
55void f128M_sqrt( const float128_t *aPtr, float128_t *zPtr )
56{
57 const uint32_t *aWPtr;
58 uint32_t *zWPtr;
59 uint32_t uiA96;
60 bool signA;
61 int32_t rawExpA;
62 uint32_t rem[6];
63 int32_t expA, expZ;
64 uint64_t rem64;
65 uint32_t sig32A, recipSqrt32, sig32Z, qs[3], q;
66 uint64_t sig64Z;
67 uint32_t term[5];
68 uint64_t x64;
69 uint32_t y[5], rem32;
70
71 /*------------------------------------------------------------------------
72 *------------------------------------------------------------------------*/
73 aWPtr = (const uint32_t *) aPtr;
74 zWPtr = (uint32_t *) zPtr;
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 uiA96 = aWPtr[indexWordHi( 4 )];
78 signA = signF128UI96( uiA96 );
79 rawExpA = expF128UI96( uiA96 );
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 if ( rawExpA == 0x7FFF ) {
83 if (
84 fracF128UI96( uiA96 )
85 || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
86 | aWPtr[indexWord( 4, 0 )])
87 ) {
88 softfloat_propagateNaNF128M( aWPtr, 0, zWPtr );
89 return;
90 }
91 if ( ! signA ) goto copyA;
92 goto invalid;
93 }
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 expA = softfloat_shiftNormSigF128M( aWPtr, 13 - (rawExpA & 1), rem );
97 if ( expA == -128 ) goto copyA;
98 if ( signA ) goto invalid;
99 /*------------------------------------------------------------------------
100 | (`sig32Z' is guaranteed to be a lower bound on the square root of
101 | `sig32A', which makes `sig32Z' also a lower bound on the square root of
102 | `sigA'.)
103 *------------------------------------------------------------------------*/
104 expZ = ((expA - 0x3FFF)>>1) + 0x3FFE;
105 expA &= 1;
106 rem64 = (uint64_t) rem[indexWord( 4, 3 )]<<32 | rem[indexWord( 4, 2 )];
107 if ( expA ) {
108 if ( ! rawExpA ) {
109 softfloat_shortShiftRight128M( rem, 1, rem );
110 rem64 >>= 1;
111 }
112 sig32A = rem64>>29;
113 } else {
114 sig32A = rem64>>30;
115 }
116 recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
117 sig32Z = ((uint64_t) sig32A * recipSqrt32)>>32;
118 if ( expA ) sig32Z >>= 1;
119 qs[2] = sig32Z;
120 rem64 -= (uint64_t) sig32Z * sig32Z;
121 rem[indexWord( 4, 3 )] = rem64>>32;
122 rem[indexWord( 4, 2 )] = rem64;
123 /*------------------------------------------------------------------------
124 *------------------------------------------------------------------------*/
125 q = ((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32;
126 sig64Z = ((uint64_t) sig32Z<<32) + ((uint64_t) q<<3);
127 term[indexWord( 4, 3 )] = 0;
128 term[indexWord( 4, 0 )] = 0;
129 /*------------------------------------------------------------------------
130 | (Repeating this loop is a rare occurrence.)
131 *------------------------------------------------------------------------*/
132 for (;;) {
133 x64 = ((uint64_t) sig32Z<<32) + sig64Z;
134 term[indexWord( 4, 2 )] = x64>>32;
135 term[indexWord( 4, 1 )] = x64;
136 softfloat_remStep128MBy32( rem, 29, term, q, y );
137 rem32 = y[indexWord( 4, 3 )];
138 if ( ! (rem32 & 0x80000000) ) break;
139 --q;
140 sig64Z -= 1<<3;
141 }
142 qs[1] = q;
143 rem64 = (uint64_t) rem32<<32 | y[indexWord( 4, 2 )];
144 /*------------------------------------------------------------------------
145 *------------------------------------------------------------------------*/
146 q = ((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32;
147 if ( rem64>>34 ) q += recipSqrt32;
148 sig64Z <<= 1;
149 /*------------------------------------------------------------------------
150 | (Repeating this loop is a rare occurrence.)
151 *------------------------------------------------------------------------*/
152 for (;;) {
153 x64 = sig64Z + (q>>26);
154 term[indexWord( 4, 2 )] = x64>>32;
155 term[indexWord( 4, 1 )] = x64;
156 term[indexWord( 4, 0 )] = q<<6;
157 softfloat_remStep128MBy32(
158 y, 29, term, q, &rem[indexMultiwordHi( 6, 4 )] );
159 rem32 = rem[indexWordHi( 6 )];
160 if ( ! (rem32 & 0x80000000) ) break;
161 --q;
162 }
163 qs[0] = q;
164 rem64 = (uint64_t) rem32<<32 | rem[indexWord( 6, 4 )];
165 /*------------------------------------------------------------------------
166 *------------------------------------------------------------------------*/
167 q = (((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32) + 2;
168 if ( rem64>>34 ) q += recipSqrt32;
169 x64 = (uint64_t) q<<27;
170 y[indexWord( 5, 0 )] = x64;
171 x64 = ((uint64_t) qs[0]<<24) + (x64>>32);
172 y[indexWord( 5, 1 )] = x64;
173 x64 = ((uint64_t) qs[1]<<21) + (x64>>32);
174 y[indexWord( 5, 2 )] = x64;
175 x64 = ((uint64_t) qs[2]<<18) + (x64>>32);
176 y[indexWord( 5, 3 )] = x64;
177 y[indexWord( 5, 4 )] = x64>>32;
178 /*------------------------------------------------------------------------
179 *------------------------------------------------------------------------*/
180 if ( (q & 0xF) <= 2 ) {
181 q &= ~3;
182 y[indexWordLo( 5 )] = q<<27;
183 term[indexWord( 5, 4 )] = 0;
184 term[indexWord( 5, 3 )] = 0;
185 term[indexWord( 5, 2 )] = 0;
186 term[indexWord( 5, 1 )] = q>>6;
187 term[indexWord( 5, 0 )] = q<<26;
188 softfloat_sub160M( y, term, term );
189 rem[indexWord( 6, 1 )] = 0;
190 rem[indexWord( 6, 0 )] = 0;
191 softfloat_remStep160MBy32(
192 &rem[indexMultiwordLo( 6, 5 )],
193 14,
194 term,
195 q,
196 &rem[indexMultiwordLo( 6, 5 )]
197 );
198 rem32 = rem[indexWord( 6, 4 )];
199 if ( rem32 & 0x80000000 ) {
200 softfloat_sub1X160M( y );
201 } else {
202 if (
203 rem32 || rem[indexWord( 6, 0 )] || rem[indexWord( 6, 1 )]
204 || (rem[indexWord( 6, 3 )] | rem[indexWord( 6, 2 )])
205 ) {
206 y[indexWordLo( 5 )] |= 1;
207 }
208 }
209 }
210 softfloat_roundPackMToF128M( 0, expZ, y, zWPtr );
211 return;
212 /*------------------------------------------------------------------------
213 *------------------------------------------------------------------------*/
214 invalid:
215 softfloat_invalidF128M( zWPtr );
216 return;
217 /*------------------------------------------------------------------------
218 *------------------------------------------------------------------------*/
219 copyA:
220 zWPtr[indexWordHi( 4 )] = uiA96;
221 zWPtr[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
222 zWPtr[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
223 zWPtr[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
224
225}
226
227#endif
228
deps/SoftFloat-3e/source/f128M_sub.c created+97
......@@ -0,0 +1,97 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43#ifdef SOFTFLOAT_FAST_INT64
44
45void
46 f128M_sub( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
47{
48 const uint64_t *aWPtr, *bWPtr;
49 uint_fast64_t uiA64, uiA0;
50 bool signA;
51 uint_fast64_t uiB64, uiB0;
52 bool signB;
53#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
54 float128_t
55 (*magsFuncPtr)(
56 uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
57#endif
58
59 aWPtr = (const uint64_t *) aPtr;
60 bWPtr = (const uint64_t *) bPtr;
61 uiA64 = aWPtr[indexWord( 2, 1 )];
62 uiA0 = aWPtr[indexWord( 2, 0 )];
63 signA = signF128UI64( uiA64 );
64 uiB64 = bWPtr[indexWord( 2, 1 )];
65 uiB0 = bWPtr[indexWord( 2, 0 )];
66 signB = signF128UI64( uiB64 );
67#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
68 if ( signA == signB ) {
69 *zPtr = softfloat_subMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
70 } else {
71 *zPtr = softfloat_addMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
72 }
73#else
74 magsFuncPtr =
75 (signA == signB) ? softfloat_subMagsF128 : softfloat_addMagsF128;
76 *zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
77#endif
78
79}
80
81#else
82
83void
84 f128M_sub( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
85{
86
87 softfloat_addF128M(
88 (const uint32_t *) aPtr,
89 (const uint32_t *) bPtr,
90 (uint32_t *) zPtr,
91 true
92 );
93
94}
95
96#endif
97
deps/SoftFloat-3e/source/f128M_to_extF80M.c created+101
......@@ -0,0 +1,101 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void f128M_to_extF80M( const float128_t *aPtr, extFloat80_t *zPtr )
47{
48
49 *zPtr = f128_to_extF80( *aPtr );
50
51}
52
53#else
54
55void f128M_to_extF80M( const float128_t *aPtr, extFloat80_t *zPtr )
56{
57 const uint32_t *aWPtr;
58 struct extFloat80M *zSPtr;
59 uint32_t uiA96;
60 bool sign;
61 int32_t exp;
62 struct commonNaN commonNaN;
63 uint32_t sig[4];
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 aWPtr = (const uint32_t *) aPtr;
68 zSPtr = (struct extFloat80M *) zPtr;
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 uiA96 = aWPtr[indexWordHi( 4 )];
72 sign = signF128UI96( uiA96 );
73 exp = expF128UI96( uiA96 );
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( exp == 0x7FFF ) {
77 if ( softfloat_isNaNF128M( aWPtr ) ) {
78 softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
79 softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
80 return;
81 }
82 zSPtr->signExp = packToExtF80UI64( sign, 0x7FFF );
83 zSPtr->signif = UINT64_C( 0x8000000000000000 );
84 return;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 exp = softfloat_shiftNormSigF128M( aWPtr, 15, sig );
89 if ( exp == -128 ) {
90 zSPtr->signExp = packToExtF80UI64( sign, 0 );
91 zSPtr->signif = 0;
92 return;
93 }
94 if ( sig[indexWord( 4, 0 )] ) sig[indexWord( 4, 1 )] |= 1;
95 softfloat_roundPackMToExtF80M(
96 sign, exp, &sig[indexMultiwordHi( 4, 3 )], 80, zSPtr );
97
98}
99
100#endif
101
deps/SoftFloat-3e/source/f128M_to_f16.c created+113
......@@ -0,0 +1,113 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46float16_t f128M_to_f16( const float128_t *aPtr )
47{
48
49 return f128_to_f16( *aPtr );
50
51}
52
53#else
54
55float16_t f128M_to_f16( const float128_t *aPtr )
56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 bool sign;
60 int32_t exp;
61 uint32_t frac32;
62 struct commonNaN commonNaN;
63 uint16_t uiZ, frac16;
64 union ui16_f16 uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 uiA96 = aWPtr[indexWordHi( 4 )];
72 sign = signF128UI96( uiA96 );
73 exp = expF128UI96( uiA96 );
74 frac32 =
75 fracF128UI96( uiA96 )
76 | ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
77 | aWPtr[indexWord( 4, 0 )])
78 != 0);
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 if ( exp == 0x7FFF ) {
82 if ( frac32 ) {
83 softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
84 uiZ = softfloat_commonNaNToF16UI( &commonNaN );
85 } else {
86 uiZ = packToF16UI( sign, 0x1F, 0 );
87 }
88 goto uiZ;
89 }
90 /*------------------------------------------------------------------------
91 *------------------------------------------------------------------------*/
92 frac16 = frac32>>2 | (frac32 & 3);
93 if ( ! (exp | frac16) ) {
94 uiZ = packToF16UI( sign, 0, 0 );
95 goto uiZ;
96 }
97 /*------------------------------------------------------------------------
98 *------------------------------------------------------------------------*/
99 exp -= 0x3FF1;
100 if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
101 if ( exp < -0x40 ) exp = -0x40;
102 }
103 return softfloat_roundPackToF16( sign, exp, frac16 | 0x4000 );
104 /*------------------------------------------------------------------------
105 *------------------------------------------------------------------------*/
106 uiZ:
107 uZ.ui = uiZ;
108 return uZ.f;
109
110}
111
112#endif
113
deps/SoftFloat-3e/source/f128M_to_f32.c created+109
......@@ -0,0 +1,109 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46float32_t f128M_to_f32( const float128_t *aPtr )
47{
48
49 return f128_to_f32( *aPtr );
50
51}
52
53#else
54
55float32_t f128M_to_f32( const float128_t *aPtr )
56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 bool sign;
60 int32_t exp;
61 uint64_t frac64;
62 struct commonNaN commonNaN;
63 uint32_t uiZ, frac32;
64 union ui32_f32 uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 uiA96 = aWPtr[indexWordHi( 4 )];
70 sign = signF128UI96( uiA96 );
71 exp = expF128UI96( uiA96 );
72 frac64 =
73 (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )]
74 | ((aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )]) != 0);
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp == 0x7FFF ) {
78 if ( frac64 ) {
79 softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
80 uiZ = softfloat_commonNaNToF32UI( &commonNaN );
81 } else {
82 uiZ = packToF32UI( sign, 0xFF, 0 );
83 }
84 goto uiZ;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 frac32 = softfloat_shortShiftRightJam64( frac64, 18 );
89 if ( ! (exp | frac32) ) {
90 uiZ = packToF32UI( sign, 0, 0 );
91 goto uiZ;
92 }
93 /*------------------------------------------------------------------------
94 *------------------------------------------------------------------------*/
95 exp -= 0x3F81;
96 if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
97 if ( exp < -0x1000 ) exp = -0x1000;
98 }
99 return softfloat_roundPackToF32( sign, exp, frac32 | 0x40000000 );
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 uiZ:
103 uZ.ui = uiZ;
104 return uZ.f;
105
106}
107
108#endif
109
deps/SoftFloat-3e/source/f128M_to_f64.c created+112
......@@ -0,0 +1,112 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46float64_t f128M_to_f64( const float128_t *aPtr )
47{
48
49 return f128_to_f64( *aPtr );
50
51}
52
53#else
54
55float64_t f128M_to_f64( const float128_t *aPtr )
56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 bool sign;
60 int32_t exp;
61 uint64_t frac64;
62 struct commonNaN commonNaN;
63 uint64_t uiZ;
64 uint32_t frac32;
65 union ui64_f64 uZ;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 aWPtr = (const uint32_t *) aPtr;
70 uiA96 = aWPtr[indexWordHi( 4 )];
71 sign = signF128UI96( uiA96 );
72 exp = expF128UI96( uiA96 );
73 frac64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( exp == 0x7FFF ) {
77 if ( frac64 || aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) {
78 softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
79 uiZ = softfloat_commonNaNToF64UI( &commonNaN );
80 } else {
81 uiZ = packToF64UI( sign, 0x7FF, 0 );
82 }
83 goto uiZ;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 frac32 = aWPtr[indexWord( 4, 1 )];
88 frac64 = frac64<<14 | frac32>>18;
89 if ( (frac32 & 0x0003FFFF) || aWPtr[indexWord( 4, 0 )] ) frac64 |= 1;
90 if ( ! (exp | frac64) ) {
91 uiZ = packToF64UI( sign, 0, 0 );
92 goto uiZ;
93 }
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 exp -= 0x3C01;
97 if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
98 if ( exp < -0x1000 ) exp = -0x1000;
99 }
100 return
101 softfloat_roundPackToF64(
102 sign, exp, frac64 | UINT64_C( 0x4000000000000000 ) );
103 /*------------------------------------------------------------------------
104 *------------------------------------------------------------------------*/
105 uiZ:
106 uZ.ui = uiZ;
107 return uZ.f;
108
109}
110
111#endif
112
deps/SoftFloat-3e/source/f128M_to_i32.c created+98
......@@ -0,0 +1,98 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46int_fast32_t
47 f128M_to_i32( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
48{
49
50 return f128_to_i32( *aPtr, roundingMode, exact );
51
52}
53
54#else
55
56int_fast32_t
57 f128M_to_i32( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
58{
59 const uint32_t *aWPtr;
60 uint32_t uiA96;
61 bool sign;
62 int32_t exp;
63 uint64_t sig64;
64 int32_t shiftDist;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 uiA96 = aWPtr[indexWordHi( 4 )];
70 sign = signF128UI96( uiA96 );
71 exp = expF128UI96( uiA96 );
72 sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
73 if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
77 if ( (exp == 0x7FFF) && sig64 ) {
78#if (i32_fromNaN == i32_fromPosOverflow)
79 sign = 0;
80#elif (i32_fromNaN == i32_fromNegOverflow)
81 sign = 1;
82#else
83 softfloat_raiseFlags( softfloat_flag_invalid );
84 return i32_fromNaN;
85#endif
86 }
87#endif
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
91 shiftDist = 0x4023 - exp;
92 if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
93 return softfloat_roundToI32( sign, sig64, roundingMode, exact );
94
95}
96
97#endif
98
deps/SoftFloat-3e/source/f128M_to_i32_r_minMag.c created+106
......@@ -0,0 +1,106 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46int_fast32_t f128M_to_i32_r_minMag( const float128_t *aPtr, bool exact )
47{
48
49 return f128_to_i32_r_minMag( *aPtr, exact );
50
51}
52
53#else
54
55int_fast32_t f128M_to_i32_r_minMag( const float128_t *aPtr, bool exact )
56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 bool sign;
60 int32_t exp;
61 uint64_t sig64;
62 int32_t shiftDist;
63 uint32_t absZ, uiZ;
64 union { uint32_t ui; int32_t i; } uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 uiA96 = aWPtr[indexWordHi( 4 )];
70 sign = signF128UI96( uiA96 );
71 exp = expF128UI96( uiA96 );
72 sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
73 if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( exp < 0x3FFF ) {
77 if ( exact && (exp | sig64) ) {
78 softfloat_exceptionFlags |= softfloat_flag_inexact;
79 }
80 return 0;
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( 0x401F <= exp ) goto invalid;
85 shiftDist = 0x402F - exp;
86 sig64 |= UINT64_C( 0x0001000000000000 );
87 absZ = sig64>>shiftDist;
88 uiZ = sign ? -absZ : absZ;
89 if ( uiZ>>31 != sign ) goto invalid;
90 if ( exact && ((uint64_t) absZ<<shiftDist != sig64) ) {
91 softfloat_exceptionFlags |= softfloat_flag_inexact;
92 }
93 uZ.ui = uiZ;
94 return uZ.i;
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 invalid:
98 softfloat_raiseFlags( softfloat_flag_invalid );
99 return
100 (exp == 0x7FFF) && sig64 ? i32_fromNaN
101 : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
102
103}
104
105#endif
106
deps/SoftFloat-3e/source/f128M_to_i64.c created+102
......@@ -0,0 +1,102 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46int_fast64_t
47 f128M_to_i64( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
48{
49
50 return f128_to_i64( *aPtr, roundingMode, exact );
51
52}
53
54#else
55
56int_fast64_t
57 f128M_to_i64( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
58{
59 const uint32_t *aWPtr;
60 uint32_t uiA96;
61 bool sign;
62 int32_t exp;
63 uint32_t sig96;
64 int32_t shiftDist;
65 uint32_t sig[4];
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 aWPtr = (const uint32_t *) aPtr;
70 uiA96 = aWPtr[indexWordHi( 4 )];
71 sign = signF128UI96( uiA96 );
72 exp = expF128UI96( uiA96 );
73 sig96 = fracF128UI96( uiA96 );
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 shiftDist = 0x404F - exp;
77 if ( shiftDist < 17 ) {
78 softfloat_raiseFlags( softfloat_flag_invalid );
79 return
80 (exp == 0x7FFF)
81 && (sig96
82 || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
83 | aWPtr[indexWord( 4, 0 )]))
84 ? i64_fromNaN
85 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
86 }
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 if ( exp ) sig96 |= 0x00010000;
90 sig[indexWord( 4, 3 )] = sig96;
91 sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
92 sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
93 sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
94 softfloat_shiftRightJam128M( sig, shiftDist, sig );
95 return
96 softfloat_roundMToI64(
97 sign, sig + indexMultiwordLo( 4, 3 ), roundingMode, exact );
98
99}
100
101#endif
102
deps/SoftFloat-3e/source/f128M_to_i64_r_minMag.c created+124
......@@ -0,0 +1,124 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46int_fast64_t f128M_to_i64_r_minMag( const float128_t *aPtr, bool exact )
47{
48
49 return f128_to_i64_r_minMag( *aPtr, exact );
50
51}
52
53#else
54
55int_fast64_t f128M_to_i64_r_minMag( const float128_t *aPtr, bool exact )
56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 bool sign;
60 int32_t exp;
61 uint32_t sig96;
62 int32_t shiftDist;
63 uint32_t sig[4];
64 uint64_t uiZ;
65 union { uint64_t ui; int64_t i; } uZ;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 aWPtr = (const uint32_t *) aPtr;
70 uiA96 = aWPtr[indexWordHi( 4 )];
71 sign = signF128UI96( uiA96 );
72 exp = expF128UI96( uiA96 );
73 sig96 = fracF128UI96( uiA96 );
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 shiftDist = 0x403E - exp;
77 if ( shiftDist < 0 ) goto invalid;
78 if ( exact ) {
79 if ( exp ) sig96 |= 0x00010000;
80 sig[indexWord( 4, 3 )] = sig96;
81 sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
82 sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
83 sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
84 softfloat_shiftRightJam128M( sig, shiftDist + 17, sig );
85 uiZ = (uint64_t) sig[indexWord( 4, 2 )]<<32 | sig[indexWord( 4, 1 )];
86 if ( uiZ>>63 && (! sign || (uiZ != UINT64_C( 0x8000000000000000 ))) ) {
87 goto invalid;
88 }
89 if ( sig[indexWordLo( 4 )] ) {
90 softfloat_exceptionFlags |= softfloat_flag_inexact;
91 }
92 } else {
93 if ( 64 <= shiftDist ) return 0;
94 uiZ =
95 (uint64_t) sig96<<47
96 | (uint64_t) aWPtr[indexWord( 4, 2 )]<<15
97 | aWPtr[indexWord( 4, 1 )]>>17;
98 if ( shiftDist ) {
99 uiZ |= UINT64_C( 0x8000000000000000 );
100 uiZ >>= shiftDist;
101 } else {
102 if ( uiZ || ! sign ) goto invalid;
103 uiZ |= UINT64_C( 0x8000000000000000 );
104 }
105 }
106 if ( sign ) uiZ = -uiZ;
107 uZ.ui = uiZ;
108 return uZ.i;
109 /*------------------------------------------------------------------------
110 *------------------------------------------------------------------------*/
111 invalid:
112 softfloat_raiseFlags( softfloat_flag_invalid );
113 return
114 (exp == 0x7FFF)
115 && (sig96
116 || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
117 | aWPtr[indexWord( 4, 0 )]))
118 ? i64_fromNaN
119 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
120
121}
122
123#endif
124
deps/SoftFloat-3e/source/f128M_to_ui32.c created+98
......@@ -0,0 +1,98 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46uint_fast32_t
47 f128M_to_ui32( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
48{
49
50 return f128_to_ui32( *aPtr, roundingMode, exact );
51
52}
53
54#else
55
56uint_fast32_t
57 f128M_to_ui32( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
58{
59 const uint32_t *aWPtr;
60 uint32_t uiA96;
61 bool sign;
62 int32_t exp;
63 uint64_t sig64;
64 int32_t shiftDist;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 uiA96 = aWPtr[indexWordHi( 4 )];
70 sign = signF128UI96( uiA96 );
71 exp = expF128UI96( uiA96 );
72 sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
73 if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76#if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
77 if ( (exp == 0x7FFF) && sig64 ) {
78#if (ui32_fromNaN == ui32_fromPosOverflow)
79 sign = 0;
80#elif (ui32_fromNaN == ui32_fromNegOverflow)
81 sign = 1;
82#else
83 softfloat_raiseFlags( softfloat_flag_invalid );
84 return ui32_fromNaN;
85#endif
86 }
87#endif
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
91 shiftDist = 0x4023 - exp;
92 if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
93 return softfloat_roundToUI32( sign, sig64, roundingMode, exact );
94
95}
96
97#endif
98
deps/SoftFloat-3e/source/f128M_to_ui32_r_minMag.c created+102
......@@ -0,0 +1,102 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46uint_fast32_t f128M_to_ui32_r_minMag( const float128_t *aPtr, bool exact )
47{
48
49 return f128_to_ui32_r_minMag( *aPtr, exact );
50
51}
52
53#else
54
55uint_fast32_t f128M_to_ui32_r_minMag( const float128_t *aPtr, bool exact )
56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 int32_t exp;
60 uint64_t sig64;
61 int32_t shiftDist;
62 bool sign;
63 uint32_t z;
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 aWPtr = (const uint32_t *) aPtr;
68 uiA96 = aWPtr[indexWordHi( 4 )];
69 exp = expF128UI96( uiA96 );
70 sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
71 if ( aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 shiftDist = 0x402F - exp;
75 if ( 49 <= shiftDist ) {
76 if ( exact && (exp | sig64) ) {
77 softfloat_exceptionFlags |= softfloat_flag_inexact;
78 }
79 return 0;
80 }
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 sign = signF128UI96( uiA96 );
84 if ( sign || (shiftDist < 17) ) {
85 softfloat_raiseFlags( softfloat_flag_invalid );
86 return
87 (exp == 0x7FFF) && sig64 ? ui32_fromNaN
88 : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
89 }
90 /*------------------------------------------------------------------------
91 *------------------------------------------------------------------------*/
92 sig64 |= UINT64_C( 0x0001000000000000 );
93 z = sig64>>shiftDist;
94 if ( exact && ((uint64_t) z<<shiftDist != sig64) ) {
95 softfloat_exceptionFlags |= softfloat_flag_inexact;
96 }
97 return z;
98
99}
100
101#endif
102
deps/SoftFloat-3e/source/f128M_to_ui64.c created+102
......@@ -0,0 +1,102 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46uint_fast64_t
47 f128M_to_ui64( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
48{
49
50 return f128_to_ui64( *aPtr, roundingMode, exact );
51
52}
53
54#else
55
56uint_fast64_t
57 f128M_to_ui64( const float128_t *aPtr, uint_fast8_t roundingMode, bool exact )
58{
59 const uint32_t *aWPtr;
60 uint32_t uiA96;
61 bool sign;
62 int32_t exp;
63 uint32_t sig96;
64 int32_t shiftDist;
65 uint32_t sig[4];
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 aWPtr = (const uint32_t *) aPtr;
70 uiA96 = aWPtr[indexWordHi( 4 )];
71 sign = signF128UI96( uiA96 );
72 exp = expF128UI96( uiA96 );
73 sig96 = fracF128UI96( uiA96 );
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 shiftDist = 0x404F - exp;
77 if ( shiftDist < 17 ) {
78 softfloat_raiseFlags( softfloat_flag_invalid );
79 return
80 (exp == 0x7FFF)
81 && (sig96
82 || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
83 | aWPtr[indexWord( 4, 0 )]))
84 ? ui64_fromNaN
85 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
86 }
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 if ( exp ) sig96 |= 0x00010000;
90 sig[indexWord( 4, 3 )] = sig96;
91 sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
92 sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
93 sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
94 softfloat_shiftRightJam128M( sig, shiftDist, sig );
95 return
96 softfloat_roundMToUI64(
97 sign, sig + indexMultiwordLo( 4, 3 ), roundingMode, exact );
98
99}
100
101#endif
102
deps/SoftFloat-3e/source/f128M_to_ui64_r_minMag.c created+114
......@@ -0,0 +1,114 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46uint_fast64_t f128M_to_ui64_r_minMag( const float128_t *aPtr, bool exact )
47{
48
49 return f128_to_ui64_r_minMag( *aPtr, exact );
50
51}
52
53#else
54
55uint_fast64_t f128M_to_ui64_r_minMag( const float128_t *aPtr, bool exact )
56{
57 const uint32_t *aWPtr;
58 uint32_t uiA96;
59 bool sign;
60 int32_t exp;
61 uint32_t sig96;
62 int32_t shiftDist;
63 uint32_t sig[4];
64 uint64_t z;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 aWPtr = (const uint32_t *) aPtr;
69 uiA96 = aWPtr[indexWordHi( 4 )];
70 sign = signF128UI96( uiA96 );
71 exp = expF128UI96( uiA96 );
72 sig96 = fracF128UI96( uiA96 );
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 shiftDist = 0x403E - exp;
76 if ( shiftDist < 0 ) goto invalid;
77 if ( exact ) {
78 if ( exp ) sig96 |= 0x00010000;
79 sig[indexWord( 4, 3 )] = sig96;
80 sig[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
81 sig[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
82 sig[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
83 softfloat_shiftRightJam128M( sig, shiftDist + 17, sig );
84 z = (uint64_t) sig[indexWord( 4, 2 )]<<32 | sig[indexWord( 4, 1 )];
85 if ( sign && z ) goto invalid;
86 if ( sig[indexWordLo( 4 )] ) {
87 softfloat_exceptionFlags |= softfloat_flag_inexact;
88 }
89 } else {
90 if ( 64 <= shiftDist ) return 0;
91 if ( sign ) goto invalid;
92 z = UINT64_C( 0x8000000000000000 )
93 | (uint64_t) sig96<<47
94 | (uint64_t) aWPtr[indexWord( 4, 2 )]<<15
95 | aWPtr[indexWord( 4, 1 )]>>17;
96 z >>= shiftDist;
97 }
98 return z;
99 /*------------------------------------------------------------------------
100 *------------------------------------------------------------------------*/
101 invalid:
102 softfloat_raiseFlags( softfloat_flag_invalid );
103 return
104 (exp == 0x7FFF)
105 && (sig96
106 || (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
107 | aWPtr[indexWord( 4, 0 )]))
108 ? ui64_fromNaN
109 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
110
111}
112
113#endif
114
deps/SoftFloat-3e/source/f128_add.c created+78
......@@ -0,0 +1,78 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float128_t f128_add( float128_t a, float128_t b )
44{
45 union ui128_f128 uA;
46 uint_fast64_t uiA64, uiA0;
47 bool signA;
48 union ui128_f128 uB;
49 uint_fast64_t uiB64, uiB0;
50 bool signB;
51#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
52 float128_t
53 (*magsFuncPtr)(
54 uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
55#endif
56
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 signA = signF128UI64( uiA64 );
61 uB.f = b;
62 uiB64 = uB.ui.v64;
63 uiB0 = uB.ui.v0;
64 signB = signF128UI64( uiB64 );
65#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
66 if ( signA == signB ) {
67 return softfloat_addMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
68 } else {
69 return softfloat_subMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
70 }
71#else
72 magsFuncPtr =
73 (signA == signB) ? softfloat_addMagsF128 : softfloat_subMagsF128;
74 return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
75#endif
76
77}
78
deps/SoftFloat-3e/source/f128_div.c created+199
......@@ -0,0 +1,199 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t f128_div( float128_t a, float128_t b )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool signA;
49 int_fast32_t expA;
50 struct uint128 sigA;
51 union ui128_f128 uB;
52 uint_fast64_t uiB64, uiB0;
53 bool signB;
54 int_fast32_t expB;
55 struct uint128 sigB;
56 bool signZ;
57 struct exp32_sig128 normExpSig;
58 int_fast32_t expZ;
59 struct uint128 rem;
60 uint_fast32_t recip32;
61 int ix;
62 uint_fast64_t q64;
63 uint_fast32_t q;
64 struct uint128 term;
65 uint_fast32_t qs[3];
66 uint_fast64_t sigZExtra;
67 struct uint128 sigZ, uiZ;
68 union ui128_f128 uZ;
69
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 uA.f = a;
73 uiA64 = uA.ui.v64;
74 uiA0 = uA.ui.v0;
75 signA = signF128UI64( uiA64 );
76 expA = expF128UI64( uiA64 );
77 sigA.v64 = fracF128UI64( uiA64 );
78 sigA.v0 = uiA0;
79 uB.f = b;
80 uiB64 = uB.ui.v64;
81 uiB0 = uB.ui.v0;
82 signB = signF128UI64( uiB64 );
83 expB = expF128UI64( uiB64 );
84 sigB.v64 = fracF128UI64( uiB64 );
85 sigB.v0 = uiB0;
86 signZ = signA ^ signB;
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 if ( expA == 0x7FFF ) {
90 if ( sigA.v64 | sigA.v0 ) goto propagateNaN;
91 if ( expB == 0x7FFF ) {
92 if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
93 goto invalid;
94 }
95 goto infinity;
96 }
97 if ( expB == 0x7FFF ) {
98 if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
99 goto zero;
100 }
101 /*------------------------------------------------------------------------
102 *------------------------------------------------------------------------*/
103 if ( ! expB ) {
104 if ( ! (sigB.v64 | sigB.v0) ) {
105 if ( ! (expA | sigA.v64 | sigA.v0) ) goto invalid;
106 softfloat_raiseFlags( softfloat_flag_infinite );
107 goto infinity;
108 }
109 normExpSig = softfloat_normSubnormalF128Sig( sigB.v64, sigB.v0 );
110 expB = normExpSig.exp;
111 sigB = normExpSig.sig;
112 }
113 if ( ! expA ) {
114 if ( ! (sigA.v64 | sigA.v0) ) goto zero;
115 normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
116 expA = normExpSig.exp;
117 sigA = normExpSig.sig;
118 }
119 /*------------------------------------------------------------------------
120 *------------------------------------------------------------------------*/
121 expZ = expA - expB + 0x3FFE;
122 sigA.v64 |= UINT64_C( 0x0001000000000000 );
123 sigB.v64 |= UINT64_C( 0x0001000000000000 );
124 rem = sigA;
125 if ( softfloat_lt128( sigA.v64, sigA.v0, sigB.v64, sigB.v0 ) ) {
126 --expZ;
127 rem = softfloat_add128( sigA.v64, sigA.v0, sigA.v64, sigA.v0 );
128 }
129 recip32 = softfloat_approxRecip32_1( sigB.v64>>17 );
130 ix = 3;
131 for (;;) {
132 q64 = (uint_fast64_t) (uint32_t) (rem.v64>>19) * recip32;
133 q = (q64 + 0x80000000)>>32;
134 --ix;
135 if ( ix < 0 ) break;
136 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
137 term = softfloat_mul128By32( sigB.v64, sigB.v0, q );
138 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
139 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
140 --q;
141 rem = softfloat_add128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
142 }
143 qs[ix] = q;
144 }
145 /*------------------------------------------------------------------------
146 *------------------------------------------------------------------------*/
147 if ( ((q + 1) & 7) < 2 ) {
148 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
149 term = softfloat_mul128By32( sigB.v64, sigB.v0, q );
150 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
151 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
152 --q;
153 rem = softfloat_add128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
154 } else if ( softfloat_le128( sigB.v64, sigB.v0, rem.v64, rem.v0 ) ) {
155 ++q;
156 rem = softfloat_sub128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
157 }
158 if ( rem.v64 | rem.v0 ) q |= 1;
159 }
160 /*------------------------------------------------------------------------
161 *------------------------------------------------------------------------*/
162 sigZExtra = (uint64_t) ((uint_fast64_t) q<<60);
163 term = softfloat_shortShiftLeft128( 0, qs[1], 54 );
164 sigZ =
165 softfloat_add128(
166 (uint_fast64_t) qs[2]<<19, ((uint_fast64_t) qs[0]<<25) + (q>>4),
167 term.v64, term.v0
168 );
169 return
170 softfloat_roundPackToF128( signZ, expZ, sigZ.v64, sigZ.v0, sigZExtra );
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 propagateNaN:
174 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
175 goto uiZ;
176 /*------------------------------------------------------------------------
177 *------------------------------------------------------------------------*/
178 invalid:
179 softfloat_raiseFlags( softfloat_flag_invalid );
180 uiZ.v64 = defaultNaNF128UI64;
181 uiZ.v0 = defaultNaNF128UI0;
182 goto uiZ;
183 /*------------------------------------------------------------------------
184 *------------------------------------------------------------------------*/
185 infinity:
186 uiZ.v64 = packToF128UI64( signZ, 0x7FFF, 0 );
187 goto uiZ0;
188 /*------------------------------------------------------------------------
189 *------------------------------------------------------------------------*/
190 zero:
191 uiZ.v64 = packToF128UI64( signZ, 0, 0 );
192 uiZ0:
193 uiZ.v0 = 0;
194 uiZ:
195 uZ.ui = uiZ;
196 return uZ.f;
197
198}
199
deps/SoftFloat-3e/source/f128_eq.c created+73
......@@ -0,0 +1,73 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f128_eq( float128_t a, float128_t b )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 union ui128_f128 uB;
49 uint_fast64_t uiB64, uiB0;
50
51 uA.f = a;
52 uiA64 = uA.ui.v64;
53 uiA0 = uA.ui.v0;
54 uB.f = b;
55 uiB64 = uB.ui.v64;
56 uiB0 = uB.ui.v0;
57 if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
58 if (
59 softfloat_isSigNaNF128UI( uiA64, uiA0 )
60 || softfloat_isSigNaNF128UI( uiB64, uiB0 )
61 ) {
62 softfloat_raiseFlags( softfloat_flag_invalid );
63 }
64 return false;
65 }
66 return
67 (uiA0 == uiB0)
68 && ( (uiA64 == uiB64)
69 || (! uiA0 && ! ((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
70 );
71
72}
73
deps/SoftFloat-3e/source/f128_eq_signaling.c created+67
......@@ -0,0 +1,67 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f128_eq_signaling( float128_t a, float128_t b )
44{
45 union ui128_f128 uA;
46 uint_fast64_t uiA64, uiA0;
47 union ui128_f128 uB;
48 uint_fast64_t uiB64, uiB0;
49
50 uA.f = a;
51 uiA64 = uA.ui.v64;
52 uiA0 = uA.ui.v0;
53 uB.f = b;
54 uiB64 = uB.ui.v64;
55 uiB0 = uB.ui.v0;
56 if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
57 softfloat_raiseFlags( softfloat_flag_invalid );
58 return false;
59 }
60 return
61 (uiA0 == uiB0)
62 && ( (uiA64 == uiB64)
63 || (! uiA0 && ! ((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
64 );
65
66}
67
deps/SoftFloat-3e/source/f128_isSignalingNaN.c created+51
......@@ -0,0 +1,51 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43bool f128_isSignalingNaN( float128_t a )
44{
45 union ui128_f128 uA;
46
47 uA.f = a;
48 return softfloat_isSigNaNF128UI( uA.ui.v64, uA.ui.v0 );
49
50}
51
deps/SoftFloat-3e/source/f128_le.c created+72
......@@ -0,0 +1,72 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f128_le( float128_t a, float128_t b )
44{
45 union ui128_f128 uA;
46 uint_fast64_t uiA64, uiA0;
47 union ui128_f128 uB;
48 uint_fast64_t uiB64, uiB0;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA64 = uA.ui.v64;
53 uiA0 = uA.ui.v0;
54 uB.f = b;
55 uiB64 = uB.ui.v64;
56 uiB0 = uB.ui.v0;
57 if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
58 softfloat_raiseFlags( softfloat_flag_invalid );
59 return false;
60 }
61 signA = signF128UI64( uiA64 );
62 signB = signF128UI64( uiB64 );
63 return
64 (signA != signB)
65 ? signA
66 || ! (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
67 | uiA0 | uiB0)
68 : ((uiA64 == uiB64) && (uiA0 == uiB0))
69 || (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
70
71}
72
deps/SoftFloat-3e/source/f128_le_quiet.c created+78
......@@ -0,0 +1,78 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f128_le_quiet( float128_t a, float128_t b )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 union ui128_f128 uB;
49 uint_fast64_t uiB64, uiB0;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA64 = uA.ui.v64;
54 uiA0 = uA.ui.v0;
55 uB.f = b;
56 uiB64 = uB.ui.v64;
57 uiB0 = uB.ui.v0;
58 if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
59 if (
60 softfloat_isSigNaNF128UI( uiA64, uiA0 )
61 || softfloat_isSigNaNF128UI( uiB64, uiB0 )
62 ) {
63 softfloat_raiseFlags( softfloat_flag_invalid );
64 }
65 return false;
66 }
67 signA = signF128UI64( uiA64 );
68 signB = signF128UI64( uiB64 );
69 return
70 (signA != signB)
71 ? signA
72 || ! (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
73 | uiA0 | uiB0)
74 : ((uiA64 == uiB64) && (uiA0 == uiB0))
75 || (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
76
77}
78
deps/SoftFloat-3e/source/f128_lt.c created+72
......@@ -0,0 +1,72 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f128_lt( float128_t a, float128_t b )
44{
45 union ui128_f128 uA;
46 uint_fast64_t uiA64, uiA0;
47 union ui128_f128 uB;
48 uint_fast64_t uiB64, uiB0;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA64 = uA.ui.v64;
53 uiA0 = uA.ui.v0;
54 uB.f = b;
55 uiB64 = uB.ui.v64;
56 uiB0 = uB.ui.v0;
57 if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
58 softfloat_raiseFlags( softfloat_flag_invalid );
59 return false;
60 }
61 signA = signF128UI64( uiA64 );
62 signB = signF128UI64( uiB64 );
63 return
64 (signA != signB)
65 ? signA
66 && (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
67 | uiA0 | uiB0)
68 : ((uiA64 != uiB64) || (uiA0 != uiB0))
69 && (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
70
71}
72
deps/SoftFloat-3e/source/f128_lt_quiet.c created+78
......@@ -0,0 +1,78 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f128_lt_quiet( float128_t a, float128_t b )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 union ui128_f128 uB;
49 uint_fast64_t uiB64, uiB0;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA64 = uA.ui.v64;
54 uiA0 = uA.ui.v0;
55 uB.f = b;
56 uiB64 = uB.ui.v64;
57 uiB0 = uB.ui.v0;
58 if ( isNaNF128UI( uiA64, uiA0 ) || isNaNF128UI( uiB64, uiB0 ) ) {
59 if (
60 softfloat_isSigNaNF128UI( uiA64, uiA0 )
61 || softfloat_isSigNaNF128UI( uiB64, uiB0 )
62 ) {
63 softfloat_raiseFlags( softfloat_flag_invalid );
64 }
65 return false;
66 }
67 signA = signF128UI64( uiA64 );
68 signB = signF128UI64( uiB64 );
69 return
70 (signA != signB)
71 ? signA
72 && (((uiA64 | uiB64) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
73 | uiA0 | uiB0)
74 : ((uiA64 != uiB64) || (uiA0 != uiB0))
75 && (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
76
77}
78
deps/SoftFloat-3e/source/f128_mul.c created+163
......@@ -0,0 +1,163 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t f128_mul( float128_t a, float128_t b )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool signA;
49 int_fast32_t expA;
50 struct uint128 sigA;
51 union ui128_f128 uB;
52 uint_fast64_t uiB64, uiB0;
53 bool signB;
54 int_fast32_t expB;
55 struct uint128 sigB;
56 bool signZ;
57 uint_fast64_t magBits;
58 struct exp32_sig128 normExpSig;
59 int_fast32_t expZ;
60 uint64_t sig256Z[4];
61 uint_fast64_t sigZExtra;
62 struct uint128 sigZ;
63 struct uint128_extra sig128Extra;
64 struct uint128 uiZ;
65 union ui128_f128 uZ;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 uA.f = a;
70 uiA64 = uA.ui.v64;
71 uiA0 = uA.ui.v0;
72 signA = signF128UI64( uiA64 );
73 expA = expF128UI64( uiA64 );
74 sigA.v64 = fracF128UI64( uiA64 );
75 sigA.v0 = uiA0;
76 uB.f = b;
77 uiB64 = uB.ui.v64;
78 uiB0 = uB.ui.v0;
79 signB = signF128UI64( uiB64 );
80 expB = expF128UI64( uiB64 );
81 sigB.v64 = fracF128UI64( uiB64 );
82 sigB.v0 = uiB0;
83 signZ = signA ^ signB;
84 /*------------------------------------------------------------------------
85 *------------------------------------------------------------------------*/
86 if ( expA == 0x7FFF ) {
87 if (
88 (sigA.v64 | sigA.v0) || ((expB == 0x7FFF) && (sigB.v64 | sigB.v0))
89 ) {
90 goto propagateNaN;
91 }
92 magBits = expB | sigB.v64 | sigB.v0;
93 goto infArg;
94 }
95 if ( expB == 0x7FFF ) {
96 if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
97 magBits = expA | sigA.v64 | sigA.v0;
98 goto infArg;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 if ( ! expA ) {
103 if ( ! (sigA.v64 | sigA.v0) ) goto zero;
104 normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
105 expA = normExpSig.exp;
106 sigA = normExpSig.sig;
107 }
108 if ( ! expB ) {
109 if ( ! (sigB.v64 | sigB.v0) ) goto zero;
110 normExpSig = softfloat_normSubnormalF128Sig( sigB.v64, sigB.v0 );
111 expB = normExpSig.exp;
112 sigB = normExpSig.sig;
113 }
114 /*------------------------------------------------------------------------
115 *------------------------------------------------------------------------*/
116 expZ = expA + expB - 0x4000;
117 sigA.v64 |= UINT64_C( 0x0001000000000000 );
118 sigB = softfloat_shortShiftLeft128( sigB.v64, sigB.v0, 16 );
119 softfloat_mul128To256M( sigA.v64, sigA.v0, sigB.v64, sigB.v0, sig256Z );
120 sigZExtra = sig256Z[indexWord( 4, 1 )] | (sig256Z[indexWord( 4, 0 )] != 0);
121 sigZ =
122 softfloat_add128(
123 sig256Z[indexWord( 4, 3 )], sig256Z[indexWord( 4, 2 )],
124 sigA.v64, sigA.v0
125 );
126 if ( UINT64_C( 0x0002000000000000 ) <= sigZ.v64 ) {
127 ++expZ;
128 sig128Extra =
129 softfloat_shortShiftRightJam128Extra(
130 sigZ.v64, sigZ.v0, sigZExtra, 1 );
131 sigZ = sig128Extra.v;
132 sigZExtra = sig128Extra.extra;
133 }
134 return
135 softfloat_roundPackToF128( signZ, expZ, sigZ.v64, sigZ.v0, sigZExtra );
136 /*------------------------------------------------------------------------
137 *------------------------------------------------------------------------*/
138 propagateNaN:
139 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
140 goto uiZ;
141 /*------------------------------------------------------------------------
142 *------------------------------------------------------------------------*/
143 infArg:
144 if ( ! magBits ) {
145 softfloat_raiseFlags( softfloat_flag_invalid );
146 uiZ.v64 = defaultNaNF128UI64;
147 uiZ.v0 = defaultNaNF128UI0;
148 goto uiZ;
149 }
150 uiZ.v64 = packToF128UI64( signZ, 0x7FFF, 0 );
151 goto uiZ0;
152 /*------------------------------------------------------------------------
153 *------------------------------------------------------------------------*/
154 zero:
155 uiZ.v64 = packToF128UI64( signZ, 0, 0 );
156 uiZ0:
157 uiZ.v0 = 0;
158 uiZ:
159 uZ.ui = uiZ;
160 return uZ.f;
161
162}
163
deps/SoftFloat-3e/source/f128_mulAdd.c created+63
......@@ -0,0 +1,63 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float128_t f128_mulAdd( float128_t a, float128_t b, float128_t c )
43{
44 union ui128_f128 uA;
45 uint_fast64_t uiA64, uiA0;
46 union ui128_f128 uB;
47 uint_fast64_t uiB64, uiB0;
48 union ui128_f128 uC;
49 uint_fast64_t uiC64, uiC0;
50
51 uA.f = a;
52 uiA64 = uA.ui.v64;
53 uiA0 = uA.ui.v0;
54 uB.f = b;
55 uiB64 = uB.ui.v64;
56 uiB0 = uB.ui.v0;
57 uC.f = c;
58 uiC64 = uC.ui.v64;
59 uiC0 = uC.ui.v0;
60 return softfloat_mulAddF128( uiA64, uiA0, uiB64, uiB0, uiC64, uiC0, 0 );
61
62}
63
deps/SoftFloat-3e/source/f128_rem.c created+190
......@@ -0,0 +1,190 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t f128_rem( float128_t a, float128_t b )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool signA;
49 int_fast32_t expA;
50 struct uint128 sigA;
51 union ui128_f128 uB;
52 uint_fast64_t uiB64, uiB0;
53 int_fast32_t expB;
54 struct uint128 sigB;
55 struct exp32_sig128 normExpSig;
56 struct uint128 rem;
57 int_fast32_t expDiff;
58 uint_fast32_t q, recip32;
59 uint_fast64_t q64;
60 struct uint128 term, altRem, meanRem;
61 bool signRem;
62 struct uint128 uiZ;
63 union ui128_f128 uZ;
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 uA.f = a;
68 uiA64 = uA.ui.v64;
69 uiA0 = uA.ui.v0;
70 signA = signF128UI64( uiA64 );
71 expA = expF128UI64( uiA64 );
72 sigA.v64 = fracF128UI64( uiA64 );
73 sigA.v0 = uiA0;
74 uB.f = b;
75 uiB64 = uB.ui.v64;
76 uiB0 = uB.ui.v0;
77 expB = expF128UI64( uiB64 );
78 sigB.v64 = fracF128UI64( uiB64 );
79 sigB.v0 = uiB0;
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 if ( expA == 0x7FFF ) {
83 if (
84 (sigA.v64 | sigA.v0) || ((expB == 0x7FFF) && (sigB.v64 | sigB.v0))
85 ) {
86 goto propagateNaN;
87 }
88 goto invalid;
89 }
90 if ( expB == 0x7FFF ) {
91 if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
92 return a;
93 }
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 if ( ! expB ) {
97 if ( ! (sigB.v64 | sigB.v0) ) goto invalid;
98 normExpSig = softfloat_normSubnormalF128Sig( sigB.v64, sigB.v0 );
99 expB = normExpSig.exp;
100 sigB = normExpSig.sig;
101 }
102 if ( ! expA ) {
103 if ( ! (sigA.v64 | sigA.v0) ) return a;
104 normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
105 expA = normExpSig.exp;
106 sigA = normExpSig.sig;
107 }
108 /*------------------------------------------------------------------------
109 *------------------------------------------------------------------------*/
110 sigA.v64 |= UINT64_C( 0x0001000000000000 );
111 sigB.v64 |= UINT64_C( 0x0001000000000000 );
112 rem = sigA;
113 expDiff = expA - expB;
114 if ( expDiff < 1 ) {
115 if ( expDiff < -1 ) return a;
116 if ( expDiff ) {
117 --expB;
118 sigB = softfloat_add128( sigB.v64, sigB.v0, sigB.v64, sigB.v0 );
119 q = 0;
120 } else {
121 q = softfloat_le128( sigB.v64, sigB.v0, rem.v64, rem.v0 );
122 if ( q ) {
123 rem = softfloat_sub128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
124 }
125 }
126 } else {
127 recip32 = softfloat_approxRecip32_1( sigB.v64>>17 );
128 expDiff -= 30;
129 for (;;) {
130 q64 = (uint_fast64_t) (uint32_t) (rem.v64>>19) * recip32;
131 if ( expDiff < 0 ) break;
132 q = (q64 + 0x80000000)>>32;
133 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
134 term = softfloat_mul128By32( sigB.v64, sigB.v0, q );
135 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
136 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
137 rem = softfloat_add128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
138 }
139 expDiff -= 29;
140 }
141 /*--------------------------------------------------------------------
142 | (`expDiff' cannot be less than -29 here.)
143 *--------------------------------------------------------------------*/
144 q = (uint32_t) (q64>>32)>>(~expDiff & 31);
145 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, expDiff + 30 );
146 term = softfloat_mul128By32( sigB.v64, sigB.v0, q );
147 rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
148 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
149 altRem = softfloat_add128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
150 goto selectRem;
151 }
152 }
153 /*------------------------------------------------------------------------
154 *------------------------------------------------------------------------*/
155 do {
156 altRem = rem;
157 ++q;
158 rem = softfloat_sub128( rem.v64, rem.v0, sigB.v64, sigB.v0 );
159 } while ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) );
160 selectRem:
161 meanRem = softfloat_add128( rem.v64, rem.v0, altRem.v64, altRem.v0 );
162 if (
163 (meanRem.v64 & UINT64_C( 0x8000000000000000 ))
164 || (! (meanRem.v64 | meanRem.v0) && (q & 1))
165 ) {
166 rem = altRem;
167 }
168 signRem = signA;
169 if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
170 signRem = ! signRem;
171 rem = softfloat_sub128( 0, 0, rem.v64, rem.v0 );
172 }
173 return softfloat_normRoundPackToF128( signRem, expB - 1, rem.v64, rem.v0 );
174 /*------------------------------------------------------------------------
175 *------------------------------------------------------------------------*/
176 propagateNaN:
177 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
178 goto uiZ;
179 /*------------------------------------------------------------------------
180 *------------------------------------------------------------------------*/
181 invalid:
182 softfloat_raiseFlags( softfloat_flag_invalid );
183 uiZ.v64 = defaultNaNF128UI64;
184 uiZ.v0 = defaultNaNF128UI0;
185 uiZ:
186 uZ.ui = uiZ;
187 return uZ.f;
188
189}
190
deps/SoftFloat-3e/source/f128_roundToInt.c created+172
......@@ -0,0 +1,172 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t
45 f128_roundToInt( float128_t a, uint_fast8_t roundingMode, bool exact )
46{
47 union ui128_f128 uA;
48 uint_fast64_t uiA64, uiA0;
49 int_fast32_t exp;
50 struct uint128 uiZ;
51 uint_fast64_t lastBitMask0, roundBitsMask;
52 bool roundNearEven;
53 uint_fast64_t lastBitMask64;
54 union ui128_f128 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.ui.v64;
60 uiA0 = uA.ui.v0;
61 exp = expF128UI64( uiA64 );
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 if ( 0x402F <= exp ) {
65 /*--------------------------------------------------------------------
66 *--------------------------------------------------------------------*/
67 if ( 0x406F <= exp ) {
68 if ( (exp == 0x7FFF) && (fracF128UI64( uiA64 ) | uiA0) ) {
69 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, 0, 0 );
70 goto uiZ;
71 }
72 return a;
73 }
74 /*--------------------------------------------------------------------
75 *--------------------------------------------------------------------*/
76 lastBitMask0 = (uint_fast64_t) 2<<(0x406E - exp);
77 roundBitsMask = lastBitMask0 - 1;
78 uiZ.v64 = uiA64;
79 uiZ.v0 = uiA0;
80 roundNearEven = (roundingMode == softfloat_round_near_even);
81 if ( roundNearEven || (roundingMode == softfloat_round_near_maxMag) ) {
82 if ( exp == 0x402F ) {
83 if ( UINT64_C( 0x8000000000000000 ) <= uiZ.v0 ) {
84 ++uiZ.v64;
85 if (
86 roundNearEven
87 && (uiZ.v0 == UINT64_C( 0x8000000000000000 ))
88 ) {
89 uiZ.v64 &= ~1;
90 }
91 }
92 } else {
93 uiZ = softfloat_add128( uiZ.v64, uiZ.v0, 0, lastBitMask0>>1 );
94 if ( roundNearEven && !(uiZ.v0 & roundBitsMask) ) {
95 uiZ.v0 &= ~lastBitMask0;
96 }
97 }
98 } else if (
99 roundingMode
100 == (signF128UI64( uiZ.v64 ) ? softfloat_round_min
101 : softfloat_round_max)
102 ) {
103 uiZ = softfloat_add128( uiZ.v64, uiZ.v0, 0, roundBitsMask );
104 }
105 uiZ.v0 &= ~roundBitsMask;
106 lastBitMask64 = !lastBitMask0;
107 } else {
108 /*--------------------------------------------------------------------
109 *--------------------------------------------------------------------*/
110 if ( exp < 0x3FFF ) {
111 if ( !((uiA64 & UINT64_C( 0x7FFFFFFFFFFFFFFF )) | uiA0) ) return a;
112 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
113 uiZ.v64 = uiA64 & packToF128UI64( 1, 0, 0 );
114 uiZ.v0 = 0;
115 switch ( roundingMode ) {
116 case softfloat_round_near_even:
117 if ( !(fracF128UI64( uiA64 ) | uiA0) ) break;
118 case softfloat_round_near_maxMag:
119 if ( exp == 0x3FFE ) uiZ.v64 |= packToF128UI64( 0, 0x3FFF, 0 );
120 break;
121 case softfloat_round_min:
122 if ( uiZ.v64 ) uiZ.v64 = packToF128UI64( 1, 0x3FFF, 0 );
123 break;
124 case softfloat_round_max:
125 if ( !uiZ.v64 ) uiZ.v64 = packToF128UI64( 0, 0x3FFF, 0 );
126 break;
127#ifdef SOFTFLOAT_ROUND_ODD
128 case softfloat_round_odd:
129 uiZ.v64 |= packToF128UI64( 0, 0x3FFF, 0 );
130 break;
131#endif
132 }
133 goto uiZ;
134 }
135 /*--------------------------------------------------------------------
136 *--------------------------------------------------------------------*/
137 uiZ.v64 = uiA64;
138 uiZ.v0 = 0;
139 lastBitMask64 = (uint_fast64_t) 1<<(0x402F - exp);
140 roundBitsMask = lastBitMask64 - 1;
141 if ( roundingMode == softfloat_round_near_maxMag ) {
142 uiZ.v64 += lastBitMask64>>1;
143 } else if ( roundingMode == softfloat_round_near_even ) {
144 uiZ.v64 += lastBitMask64>>1;
145 if ( !((uiZ.v64 & roundBitsMask) | uiA0) ) {
146 uiZ.v64 &= ~lastBitMask64;
147 }
148 } else if (
149 roundingMode
150 == (signF128UI64( uiZ.v64 ) ? softfloat_round_min
151 : softfloat_round_max)
152 ) {
153 uiZ.v64 = (uiZ.v64 | (uiA0 != 0)) + roundBitsMask;
154 }
155 uiZ.v64 &= ~roundBitsMask;
156 lastBitMask0 = 0;
157 }
158 if ( (uiZ.v64 != uiA64) || (uiZ.v0 != uiA0) ) {
159#ifdef SOFTFLOAT_ROUND_ODD
160 if ( roundingMode == softfloat_round_odd ) {
161 uiZ.v64 |= lastBitMask64;
162 uiZ.v0 |= lastBitMask0;
163 }
164#endif
165 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
166 }
167 uiZ:
168 uZ.ui = uiZ;
169 return uZ.f;
170
171}
172
deps/SoftFloat-3e/source/f128_sqrt.c created+201
......@@ -0,0 +1,201 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t f128_sqrt( float128_t a )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool signA;
49 int_fast32_t expA;
50 struct uint128 sigA, uiZ;
51 struct exp32_sig128 normExpSig;
52 int_fast32_t expZ;
53 uint_fast32_t sig32A, recipSqrt32, sig32Z;
54 struct uint128 rem;
55 uint32_t qs[3];
56 uint_fast32_t q;
57 uint_fast64_t x64, sig64Z;
58 struct uint128 y, term;
59 uint_fast64_t sigZExtra;
60 struct uint128 sigZ;
61 union ui128_f128 uZ;
62
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 uA.f = a;
66 uiA64 = uA.ui.v64;
67 uiA0 = uA.ui.v0;
68 signA = signF128UI64( uiA64 );
69 expA = expF128UI64( uiA64 );
70 sigA.v64 = fracF128UI64( uiA64 );
71 sigA.v0 = uiA0;
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 if ( expA == 0x7FFF ) {
75 if ( sigA.v64 | sigA.v0 ) {
76 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, 0, 0 );
77 goto uiZ;
78 }
79 if ( ! signA ) return a;
80 goto invalid;
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( signA ) {
85 if ( ! (expA | sigA.v64 | sigA.v0) ) return a;
86 goto invalid;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( ! expA ) {
91 if ( ! (sigA.v64 | sigA.v0) ) return a;
92 normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
93 expA = normExpSig.exp;
94 sigA = normExpSig.sig;
95 }
96 /*------------------------------------------------------------------------
97 | (`sig32Z' is guaranteed to be a lower bound on the square root of
98 | `sig32A', which makes `sig32Z' also a lower bound on the square root of
99 | `sigA'.)
100 *------------------------------------------------------------------------*/
101 expZ = ((expA - 0x3FFF)>>1) + 0x3FFE;
102 expA &= 1;
103 sigA.v64 |= UINT64_C( 0x0001000000000000 );
104 sig32A = sigA.v64>>17;
105 recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
106 sig32Z = ((uint_fast64_t) sig32A * recipSqrt32)>>32;
107 if ( expA ) {
108 sig32Z >>= 1;
109 rem = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 12 );
110 } else {
111 rem = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 13 );
112 }
113 qs[2] = sig32Z;
114 rem.v64 -= (uint_fast64_t) sig32Z * sig32Z;
115 /*------------------------------------------------------------------------
116 *------------------------------------------------------------------------*/
117 q = ((uint32_t) (rem.v64>>2) * (uint_fast64_t) recipSqrt32)>>32;
118 x64 = (uint_fast64_t) sig32Z<<32;
119 sig64Z = x64 + ((uint_fast64_t) q<<3);
120 y = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
121 /*------------------------------------------------------------------------
122 | (Repeating this loop is a rare occurrence.)
123 *------------------------------------------------------------------------*/
124 for (;;) {
125 term = softfloat_mul64ByShifted32To128( x64 + sig64Z, q );
126 rem = softfloat_sub128( y.v64, y.v0, term.v64, term.v0 );
127 if ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) ) break;
128 --q;
129 sig64Z -= 1<<3;
130 }
131 qs[1] = q;
132 /*------------------------------------------------------------------------
133 *------------------------------------------------------------------------*/
134 q = ((rem.v64>>2) * recipSqrt32)>>32;
135 y = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
136 sig64Z <<= 1;
137 /*------------------------------------------------------------------------
138 | (Repeating this loop is a rare occurrence.)
139 *------------------------------------------------------------------------*/
140 for (;;) {
141 term = softfloat_shortShiftLeft128( 0, sig64Z, 32 );
142 term = softfloat_add128( term.v64, term.v0, 0, (uint_fast64_t) q<<6 );
143 term = softfloat_mul128By32( term.v64, term.v0, q );
144 rem = softfloat_sub128( y.v64, y.v0, term.v64, term.v0 );
145 if ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) ) break;
146 --q;
147 }
148 qs[0] = q;
149 /*------------------------------------------------------------------------
150 *------------------------------------------------------------------------*/
151 q = (((rem.v64>>2) * recipSqrt32)>>32) + 2;
152 sigZExtra = (uint64_t) ((uint_fast64_t) q<<59);
153 term = softfloat_shortShiftLeft128( 0, qs[1], 53 );
154 sigZ =
155 softfloat_add128(
156 (uint_fast64_t) qs[2]<<18, ((uint_fast64_t) qs[0]<<24) + (q>>5),
157 term.v64, term.v0
158 );
159 /*------------------------------------------------------------------------
160 *------------------------------------------------------------------------*/
161 if ( (q & 0xF) <= 2 ) {
162 q &= ~3;
163 sigZExtra = (uint64_t) ((uint_fast64_t) q<<59);
164 y = softfloat_shortShiftLeft128( sigZ.v64, sigZ.v0, 6 );
165 y.v0 |= sigZExtra>>58;
166 term = softfloat_sub128( y.v64, y.v0, 0, q );
167 y = softfloat_mul64ByShifted32To128( term.v0, q );
168 term = softfloat_mul64ByShifted32To128( term.v64, q );
169 term = softfloat_add128( term.v64, term.v0, 0, y.v64 );
170 rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 20 );
171 term = softfloat_sub128( term.v64, term.v0, rem.v64, rem.v0 );
172 /*--------------------------------------------------------------------
173 | The concatenation of `term' and `y.v0' is now the negative remainder
174 | (3 words altogether).
175 *--------------------------------------------------------------------*/
176 if ( term.v64 & UINT64_C( 0x8000000000000000 ) ) {
177 sigZExtra |= 1;
178 } else {
179 if ( term.v64 | term.v0 | y.v0 ) {
180 if ( sigZExtra ) {
181 --sigZExtra;
182 } else {
183 sigZ = softfloat_sub128( sigZ.v64, sigZ.v0, 0, 1 );
184 sigZExtra = ~0;
185 }
186 }
187 }
188 }
189 return softfloat_roundPackToF128( 0, expZ, sigZ.v64, sigZ.v0, sigZExtra );
190 /*------------------------------------------------------------------------
191 *------------------------------------------------------------------------*/
192 invalid:
193 softfloat_raiseFlags( softfloat_flag_invalid );
194 uiZ.v64 = defaultNaNF128UI64;
195 uiZ.v0 = defaultNaNF128UI0;
196 uiZ:
197 uZ.ui = uiZ;
198 return uZ.f;
199
200}
201
deps/SoftFloat-3e/source/f128_sub.c created+78
......@@ -0,0 +1,78 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float128_t f128_sub( float128_t a, float128_t b )
44{
45 union ui128_f128 uA;
46 uint_fast64_t uiA64, uiA0;
47 bool signA;
48 union ui128_f128 uB;
49 uint_fast64_t uiB64, uiB0;
50 bool signB;
51#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
52 float128_t
53 (*magsFuncPtr)(
54 uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
55#endif
56
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 signA = signF128UI64( uiA64 );
61 uB.f = b;
62 uiB64 = uB.ui.v64;
63 uiB0 = uB.ui.v0;
64 signB = signF128UI64( uiB64 );
65#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
66 if ( signA == signB ) {
67 return softfloat_subMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
68 } else {
69 return softfloat_addMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
70 }
71#else
72 magsFuncPtr =
73 (signA == signB) ? softfloat_subMagsF128 : softfloat_addMagsF128;
74 return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
75#endif
76
77}
78
deps/SoftFloat-3e/source/f128_to_extF80.c created+109
......@@ -0,0 +1,109 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t f128_to_extF80( float128_t a )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t frac64, frac0;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 uint_fast16_t uiZ64;
54 uint_fast64_t uiZ0;
55 struct exp32_sig128 normExpSig;
56 struct uint128 sig128;
57 union { struct extFloat80M s; extFloat80_t f; } uZ;
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 uA.f = a;
62 uiA64 = uA.ui.v64;
63 uiA0 = uA.ui.v0;
64 sign = signF128UI64( uiA64 );
65 exp = expF128UI64( uiA64 );
66 frac64 = fracF128UI64( uiA64 );
67 frac0 = uiA0;
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 if ( exp == 0x7FFF ) {
71 if ( frac64 | frac0 ) {
72 softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
73 uiZ = softfloat_commonNaNToExtF80UI( &commonNaN );
74 uiZ64 = uiZ.v64;
75 uiZ0 = uiZ.v0;
76 } else {
77 uiZ64 = packToExtF80UI64( sign, 0x7FFF );
78 uiZ0 = UINT64_C( 0x8000000000000000 );
79 }
80 goto uiZ;
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( ! exp ) {
85 if ( ! (frac64 | frac0) ) {
86 uiZ64 = packToExtF80UI64( sign, 0 );
87 uiZ0 = 0;
88 goto uiZ;
89 }
90 normExpSig = softfloat_normSubnormalF128Sig( frac64, frac0 );
91 exp = normExpSig.exp;
92 frac64 = normExpSig.sig.v64;
93 frac0 = normExpSig.sig.v0;
94 }
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 sig128 =
98 softfloat_shortShiftLeft128(
99 frac64 | UINT64_C( 0x0001000000000000 ), frac0, 15 );
100 return softfloat_roundPackToExtF80( sign, exp, sig128.v64, sig128.v0, 80 );
101 /*------------------------------------------------------------------------
102 *------------------------------------------------------------------------*/
103 uiZ:
104 uZ.s.signExp = uiZ64;
105 uZ.s.signif = uiZ0;
106 return uZ.f;
107
108}
109
deps/SoftFloat-3e/source/f128_to_f16.c created+95
......@@ -0,0 +1,95 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t f128_to_f16( float128_t a )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t frac64;
51 struct commonNaN commonNaN;
52 uint_fast16_t uiZ, frac16;
53 union ui16_f16 uZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 sign = signF128UI64( uiA64 );
61 exp = expF128UI64( uiA64 );
62 frac64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0x7FFF ) {
66 if ( frac64 ) {
67 softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
68 uiZ = softfloat_commonNaNToF16UI( &commonNaN );
69 } else {
70 uiZ = packToF16UI( sign, 0x1F, 0 );
71 }
72 goto uiZ;
73 }
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 frac16 = softfloat_shortShiftRightJam64( frac64, 34 );
77 if ( ! (exp | frac16) ) {
78 uiZ = packToF16UI( sign, 0, 0 );
79 goto uiZ;
80 }
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 exp -= 0x3FF1;
84 if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
85 if ( exp < -0x40 ) exp = -0x40;
86 }
87 return softfloat_roundPackToF16( sign, exp, frac16 | 0x4000 );
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 uiZ:
91 uZ.ui = uiZ;
92 return uZ.f;
93
94}
95
deps/SoftFloat-3e/source/f128_to_f32.c created+95
......@@ -0,0 +1,95 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t f128_to_f32( float128_t a )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t frac64;
51 struct commonNaN commonNaN;
52 uint_fast32_t uiZ, frac32;
53 union ui32_f32 uZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 sign = signF128UI64( uiA64 );
61 exp = expF128UI64( uiA64 );
62 frac64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0x7FFF ) {
66 if ( frac64 ) {
67 softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
68 uiZ = softfloat_commonNaNToF32UI( &commonNaN );
69 } else {
70 uiZ = packToF32UI( sign, 0xFF, 0 );
71 }
72 goto uiZ;
73 }
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 frac32 = softfloat_shortShiftRightJam64( frac64, 18 );
77 if ( ! (exp | frac32) ) {
78 uiZ = packToF32UI( sign, 0, 0 );
79 goto uiZ;
80 }
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 exp -= 0x3F81;
84 if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
85 if ( exp < -0x1000 ) exp = -0x1000;
86 }
87 return softfloat_roundPackToF32( sign, exp, frac32 | 0x40000000 );
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 uiZ:
91 uZ.ui = uiZ;
92 return uZ.f;
93
94}
95
deps/SoftFloat-3e/source/f128_to_f64.c created+100
......@@ -0,0 +1,100 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t f128_to_f64( float128_t a )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t frac64, frac0;
51 struct commonNaN commonNaN;
52 uint_fast64_t uiZ;
53 struct uint128 frac128;
54 union ui64_f64 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.ui.v64;
60 uiA0 = uA.ui.v0;
61 sign = signF128UI64( uiA64 );
62 exp = expF128UI64( uiA64 );
63 frac64 = fracF128UI64( uiA64 );
64 frac0 = uiA0;
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( exp == 0x7FFF ) {
68 if ( frac64 | frac0 ) {
69 softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
70 uiZ = softfloat_commonNaNToF64UI( &commonNaN );
71 } else {
72 uiZ = packToF64UI( sign, 0x7FF, 0 );
73 }
74 goto uiZ;
75 }
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 frac128 = softfloat_shortShiftLeft128( frac64, frac0, 14 );
79 frac64 = frac128.v64 | (frac128.v0 != 0);
80 if ( ! (exp | frac64) ) {
81 uiZ = packToF64UI( sign, 0, 0 );
82 goto uiZ;
83 }
84 /*------------------------------------------------------------------------
85 *------------------------------------------------------------------------*/
86 exp -= 0x3C01;
87 if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
88 if ( exp < -0x1000 ) exp = -0x1000;
89 }
90 return
91 softfloat_roundPackToF64(
92 sign, exp, frac64 | UINT64_C( 0x4000000000000000 ) );
93 /*------------------------------------------------------------------------
94 *------------------------------------------------------------------------*/
95 uiZ:
96 uZ.ui = uiZ;
97 return uZ.f;
98
99}
100
deps/SoftFloat-3e/source/f128_to_i32.c created+85
......@@ -0,0 +1,85 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t f128_to_i32( float128_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t sig64, sig0;
51 int_fast32_t shiftDist;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 uA.f = a;
56 uiA64 = uA.ui.v64;
57 uiA0 = uA.ui.v0;
58 sign = signF128UI64( uiA64 );
59 exp = expF128UI64( uiA64 );
60 sig64 = fracF128UI64( uiA64 );
61 sig0 = uiA0;
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
65 if ( (exp == 0x7FFF) && (sig64 | sig0) ) {
66#if (i32_fromNaN == i32_fromPosOverflow)
67 sign = 0;
68#elif (i32_fromNaN == i32_fromNegOverflow)
69 sign = 1;
70#else
71 softfloat_raiseFlags( softfloat_flag_invalid );
72 return i32_fromNaN;
73#endif
74 }
75#endif
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
79 sig64 |= (sig0 != 0);
80 shiftDist = 0x4023 - exp;
81 if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
82 return softfloat_roundToI32( sign, sig64, roundingMode, exact );
83
84}
85
deps/SoftFloat-3e/source/f128_to_i32_r_minMag.c created+100
......@@ -0,0 +1,100 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t f128_to_i32_r_minMag( float128_t a, bool exact )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 int_fast32_t exp;
49 uint_fast64_t sig64;
50 int_fast32_t shiftDist;
51 bool sign;
52 int_fast32_t absZ;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.ui.v64;
58 uiA0 = uA.ui.v0;
59 exp = expF128UI64( uiA64 );
60 sig64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 shiftDist = 0x402F - exp;
64 if ( 49 <= shiftDist ) {
65 if ( exact && (exp | sig64) ) {
66 softfloat_exceptionFlags |= softfloat_flag_inexact;
67 }
68 return 0;
69 }
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 sign = signF128UI64( uiA64 );
73 if ( shiftDist < 18 ) {
74 if (
75 sign && (shiftDist == 17)
76 && (sig64 < UINT64_C( 0x0000000000020000 ))
77 ) {
78 if ( exact && sig64 ) {
79 softfloat_exceptionFlags |= softfloat_flag_inexact;
80 }
81 return -0x7FFFFFFF - 1;
82 }
83 softfloat_raiseFlags( softfloat_flag_invalid );
84 return
85 (exp == 0x7FFF) && sig64 ? i32_fromNaN
86 : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 sig64 |= UINT64_C( 0x0001000000000000 );
91 absZ = sig64>>shiftDist;
92 if (
93 exact && ((uint_fast64_t) (uint_fast32_t) absZ<<shiftDist != sig64)
94 ) {
95 softfloat_exceptionFlags |= softfloat_flag_inexact;
96 }
97 return sign ? -absZ : absZ;
98
99}
100
deps/SoftFloat-3e/source/f128_to_i64.c created+95
......@@ -0,0 +1,95 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t f128_to_i64( float128_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t sig64, sig0;
51 int_fast32_t shiftDist;
52 struct uint128 sig128;
53 struct uint64_extra sigExtra;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 sign = signF128UI64( uiA64 );
61 exp = expF128UI64( uiA64 );
62 sig64 = fracF128UI64( uiA64 );
63 sig0 = uiA0;
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 shiftDist = 0x402F - exp;
67 if ( shiftDist <= 0 ) {
68 /*--------------------------------------------------------------------
69 *--------------------------------------------------------------------*/
70 if ( shiftDist < -15 ) {
71 softfloat_raiseFlags( softfloat_flag_invalid );
72 return
73 (exp == 0x7FFF) && (sig64 | sig0) ? i64_fromNaN
74 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
75 }
76 /*--------------------------------------------------------------------
77 *--------------------------------------------------------------------*/
78 sig64 |= UINT64_C( 0x0001000000000000 );
79 if ( shiftDist ) {
80 sig128 = softfloat_shortShiftLeft128( sig64, sig0, -shiftDist );
81 sig64 = sig128.v64;
82 sig0 = sig128.v0;
83 }
84 } else {
85 /*--------------------------------------------------------------------
86 *--------------------------------------------------------------------*/
87 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
88 sigExtra = softfloat_shiftRightJam64Extra( sig64, sig0, shiftDist );
89 sig64 = sigExtra.v;
90 sig0 = sigExtra.extra;
91 }
92 return softfloat_roundToI64( sign, sig64, sig0, roundingMode, exact );
93
94}
95
deps/SoftFloat-3e/source/f128_to_i64_r_minMag.c created+113
......@@ -0,0 +1,113 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t f128_to_i64_r_minMag( float128_t a, bool exact )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t sig64, sig0;
51 int_fast32_t shiftDist;
52 int_fast8_t negShiftDist;
53 int_fast64_t absZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 sign = signF128UI64( uiA64 );
61 exp = expF128UI64( uiA64 );
62 sig64 = fracF128UI64( uiA64 );
63 sig0 = uiA0;
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 shiftDist = 0x402F - exp;
67 if ( shiftDist < 0 ) {
68 /*--------------------------------------------------------------------
69 *--------------------------------------------------------------------*/
70 if ( shiftDist < -14 ) {
71 if (
72 (uiA64 == UINT64_C( 0xC03E000000000000 ))
73 && (sig0 < UINT64_C( 0x0002000000000000 ))
74 ) {
75 if ( exact && sig0 ) {
76 softfloat_exceptionFlags |= softfloat_flag_inexact;
77 }
78 return -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
79 }
80 softfloat_raiseFlags( softfloat_flag_invalid );
81 return
82 (exp == 0x7FFF) && (sig64 | sig0) ? i64_fromNaN
83 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
84 }
85 /*--------------------------------------------------------------------
86 *--------------------------------------------------------------------*/
87 sig64 |= UINT64_C( 0x0001000000000000 );
88 negShiftDist = -shiftDist;
89 absZ = sig64<<negShiftDist | sig0>>(shiftDist & 63);
90 if ( exact && (uint64_t) (sig0<<negShiftDist) ) {
91 softfloat_exceptionFlags |= softfloat_flag_inexact;
92 }
93 } else {
94 /*--------------------------------------------------------------------
95 *--------------------------------------------------------------------*/
96 if ( 49 <= shiftDist ) {
97 if ( exact && (exp | sig64 | sig0) ) {
98 softfloat_exceptionFlags |= softfloat_flag_inexact;
99 }
100 return 0;
101 }
102 /*--------------------------------------------------------------------
103 *--------------------------------------------------------------------*/
104 sig64 |= UINT64_C( 0x0001000000000000 );
105 absZ = sig64>>shiftDist;
106 if ( exact && (sig0 || (absZ<<shiftDist != sig64)) ) {
107 softfloat_exceptionFlags |= softfloat_flag_inexact;
108 }
109 }
110 return sign ? -absZ : absZ;
111
112}
113
deps/SoftFloat-3e/source/f128_to_ui32.c created+86
......@@ -0,0 +1,86 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t
45 f128_to_ui32( float128_t a, uint_fast8_t roundingMode, bool exact )
46{
47 union ui128_f128 uA;
48 uint_fast64_t uiA64, uiA0;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig64;
52 int_fast32_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.ui.v64;
58 uiA0 = uA.ui.v0;
59 sign = signF128UI64( uiA64 );
60 exp = expF128UI64( uiA64 );
61 sig64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64#if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
65 if ( (exp == 0x7FFF) && sig64 ) {
66#if (ui32_fromNaN == ui32_fromPosOverflow)
67 sign = 0;
68#elif (ui32_fromNaN == ui32_fromNegOverflow)
69 sign = 1;
70#else
71 softfloat_raiseFlags( softfloat_flag_invalid );
72 return ui32_fromNaN;
73#endif
74 }
75#endif
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
79 shiftDist = 0x4023 - exp;
80 if ( 0 < shiftDist ) {
81 sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
82 }
83 return softfloat_roundToUI32( sign, sig64, roundingMode, exact );
84
85}
86
deps/SoftFloat-3e/source/f128_to_ui32_r_minMag.c created+89
......@@ -0,0 +1,89 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t f128_to_ui32_r_minMag( float128_t a, bool exact )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 int_fast32_t exp;
49 uint_fast64_t sig64;
50 int_fast32_t shiftDist;
51 bool sign;
52 uint_fast32_t z;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA64 = uA.ui.v64;
58 uiA0 = uA.ui.v0;
59 exp = expF128UI64( uiA64 );
60 sig64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 shiftDist = 0x402F - exp;
64 if ( 49 <= shiftDist ) {
65 if ( exact && (exp | sig64) ) {
66 softfloat_exceptionFlags |= softfloat_flag_inexact;
67 }
68 return 0;
69 }
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 sign = signF128UI64( uiA64 );
73 if ( sign || (shiftDist < 17) ) {
74 softfloat_raiseFlags( softfloat_flag_invalid );
75 return
76 (exp == 0x7FFF) && sig64 ? ui32_fromNaN
77 : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 sig64 |= UINT64_C( 0x0001000000000000 );
82 z = sig64>>shiftDist;
83 if ( exact && ((uint_fast64_t) z<<shiftDist != sig64) ) {
84 softfloat_exceptionFlags |= softfloat_flag_inexact;
85 }
86 return z;
87
88}
89
deps/SoftFloat-3e/source/f128_to_ui64.c created+96
......@@ -0,0 +1,96 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t
45 f128_to_ui64( float128_t a, uint_fast8_t roundingMode, bool exact )
46{
47 union ui128_f128 uA;
48 uint_fast64_t uiA64, uiA0;
49 bool sign;
50 int_fast32_t exp;
51 uint_fast64_t sig64, sig0;
52 int_fast32_t shiftDist;
53 struct uint128 sig128;
54 struct uint64_extra sigExtra;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA64 = uA.ui.v64;
60 uiA0 = uA.ui.v0;
61 sign = signF128UI64( uiA64 );
62 exp = expF128UI64( uiA64 );
63 sig64 = fracF128UI64( uiA64 );
64 sig0 = uiA0;
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 shiftDist = 0x402F - exp;
68 if ( shiftDist <= 0 ) {
69 /*--------------------------------------------------------------------
70 *--------------------------------------------------------------------*/
71 if ( shiftDist < -15 ) {
72 softfloat_raiseFlags( softfloat_flag_invalid );
73 return
74 (exp == 0x7FFF) && (sig64 | sig0) ? ui64_fromNaN
75 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
76 }
77 /*--------------------------------------------------------------------
78 *--------------------------------------------------------------------*/
79 sig64 |= UINT64_C( 0x0001000000000000 );
80 if ( shiftDist ) {
81 sig128 = softfloat_shortShiftLeft128( sig64, sig0, -shiftDist );
82 sig64 = sig128.v64;
83 sig0 = sig128.v0;
84 }
85 } else {
86 /*--------------------------------------------------------------------
87 *--------------------------------------------------------------------*/
88 if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
89 sigExtra = softfloat_shiftRightJam64Extra( sig64, sig0, shiftDist );
90 sig64 = sigExtra.v;
91 sig0 = sigExtra.extra;
92 }
93 return softfloat_roundToUI64( sign, sig64, sig0, roundingMode, exact );
94
95}
96
deps/SoftFloat-3e/source/f128_to_ui64_r_minMag.c created+105
......@@ -0,0 +1,105 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t f128_to_ui64_r_minMag( float128_t a, bool exact )
45{
46 union ui128_f128 uA;
47 uint_fast64_t uiA64, uiA0;
48 bool sign;
49 int_fast32_t exp;
50 uint_fast64_t sig64, sig0;
51 int_fast32_t shiftDist;
52 int_fast8_t negShiftDist;
53 uint_fast64_t z;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA64 = uA.ui.v64;
59 uiA0 = uA.ui.v0;
60 sign = signF128UI64( uiA64 );
61 exp = expF128UI64( uiA64 );
62 sig64 = fracF128UI64( uiA64 );
63 sig0 = uiA0;
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 shiftDist = 0x402F - exp;
67 if ( shiftDist < 0 ) {
68 /*--------------------------------------------------------------------
69 *--------------------------------------------------------------------*/
70 if ( sign || (shiftDist < -15) ) goto invalid;
71 sig64 |= UINT64_C( 0x0001000000000000 );
72 negShiftDist = -shiftDist;
73 z = sig64<<negShiftDist | sig0>>(shiftDist & 63);
74 if ( exact && (uint64_t) (sig0<<negShiftDist) ) {
75 softfloat_exceptionFlags |= softfloat_flag_inexact;
76 }
77 } else {
78 /*--------------------------------------------------------------------
79 *--------------------------------------------------------------------*/
80 if ( 49 <= shiftDist ) {
81 if ( exact && (exp | sig64 | sig0) ) {
82 softfloat_exceptionFlags |= softfloat_flag_inexact;
83 }
84 return 0;
85 }
86 /*--------------------------------------------------------------------
87 *--------------------------------------------------------------------*/
88 if ( sign ) goto invalid;
89 sig64 |= UINT64_C( 0x0001000000000000 );
90 z = sig64>>shiftDist;
91 if ( exact && (sig0 || (z<<shiftDist != sig64)) ) {
92 softfloat_exceptionFlags |= softfloat_flag_inexact;
93 }
94 }
95 return z;
96 /*------------------------------------------------------------------------
97 *------------------------------------------------------------------------*/
98 invalid:
99 softfloat_raiseFlags( softfloat_flag_invalid );
100 return
101 (exp == 0x7FFF) && (sig64 | sig0) ? ui64_fromNaN
102 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
103
104}
105
deps/SoftFloat-3e/source/f16_add.c created+70
......@@ -0,0 +1,70 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float16_t f16_add( float16_t a, float16_t b )
44{
45 union ui16_f16 uA;
46 uint_fast16_t uiA;
47 union ui16_f16 uB;
48 uint_fast16_t uiB;
49#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
50 float16_t (*magsFuncPtr)( uint_fast16_t, uint_fast16_t );
51#endif
52
53 uA.f = a;
54 uiA = uA.ui;
55 uB.f = b;
56 uiB = uB.ui;
57#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
58 if ( signF16UI( uiA ^ uiB ) ) {
59 return softfloat_subMagsF16( uiA, uiB );
60 } else {
61 return softfloat_addMagsF16( uiA, uiB );
62 }
63#else
64 magsFuncPtr =
65 signF16UI( uiA ^ uiB ) ? softfloat_subMagsF16 : softfloat_addMagsF16;
66 return (*magsFuncPtr)( uiA, uiB );
67#endif
68
69}
70
deps/SoftFloat-3e/source/f16_div.c created+186
......@@ -0,0 +1,186 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extern const uint16_t softfloat_approxRecip_1k0s[];
45extern const uint16_t softfloat_approxRecip_1k1s[];
46
47float16_t f16_div( float16_t a, float16_t b )
48{
49 union ui16_f16 uA;
50 uint_fast16_t uiA;
51 bool signA;
52 int_fast8_t expA;
53 uint_fast16_t sigA;
54 union ui16_f16 uB;
55 uint_fast16_t uiB;
56 bool signB;
57 int_fast8_t expB;
58 uint_fast16_t sigB;
59 bool signZ;
60 struct exp8_sig16 normExpSig;
61 int_fast8_t expZ;
62#ifdef SOFTFLOAT_FAST_DIV32TO16
63 uint_fast32_t sig32A;
64 uint_fast16_t sigZ;
65#else
66 int index;
67 uint16_t r0;
68 uint_fast16_t sigZ, rem;
69#endif
70 uint_fast16_t uiZ;
71 union ui16_f16 uZ;
72
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 uA.f = a;
76 uiA = uA.ui;
77 signA = signF16UI( uiA );
78 expA = expF16UI( uiA );
79 sigA = fracF16UI( uiA );
80 uB.f = b;
81 uiB = uB.ui;
82 signB = signF16UI( uiB );
83 expB = expF16UI( uiB );
84 sigB = fracF16UI( uiB );
85 signZ = signA ^ signB;
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 if ( expA == 0x1F ) {
89 if ( sigA ) goto propagateNaN;
90 if ( expB == 0x1F ) {
91 if ( sigB ) goto propagateNaN;
92 goto invalid;
93 }
94 goto infinity;
95 }
96 if ( expB == 0x1F ) {
97 if ( sigB ) goto propagateNaN;
98 goto zero;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 if ( ! expB ) {
103 if ( ! sigB ) {
104 if ( ! (expA | sigA) ) goto invalid;
105 softfloat_raiseFlags( softfloat_flag_infinite );
106 goto infinity;
107 }
108 normExpSig = softfloat_normSubnormalF16Sig( sigB );
109 expB = normExpSig.exp;
110 sigB = normExpSig.sig;
111 }
112 if ( ! expA ) {
113 if ( ! sigA ) goto zero;
114 normExpSig = softfloat_normSubnormalF16Sig( sigA );
115 expA = normExpSig.exp;
116 sigA = normExpSig.sig;
117 }
118 /*------------------------------------------------------------------------
119 *------------------------------------------------------------------------*/
120 expZ = expA - expB + 0xE;
121 sigA |= 0x0400;
122 sigB |= 0x0400;
123#ifdef SOFTFLOAT_FAST_DIV32TO16
124 if ( sigA < sigB ) {
125 --expZ;
126 sig32A = (uint_fast32_t) sigA<<15;
127 } else {
128 sig32A = (uint_fast32_t) sigA<<14;
129 }
130 sigZ = sig32A / sigB;
131 if ( ! (sigZ & 7) ) sigZ |= ((uint_fast32_t) sigB * sigZ != sig32A);
132#else
133 if ( sigA < sigB ) {
134 --expZ;
135 sigA <<= 5;
136 } else {
137 sigA <<= 4;
138 }
139 index = sigB>>6 & 0xF;
140 r0 = softfloat_approxRecip_1k0s[index]
141 - (((uint_fast32_t) softfloat_approxRecip_1k1s[index]
142 * (sigB & 0x3F))
143 >>10);
144 sigZ = ((uint_fast32_t) sigA * r0)>>16;
145 rem = (sigA<<10) - sigZ * sigB;
146 sigZ += (rem * (uint_fast32_t) r0)>>26;
147 /*------------------------------------------------------------------------
148 *------------------------------------------------------------------------*/
149 ++sigZ;
150 if ( ! (sigZ & 7) ) {
151 sigZ &= ~1;
152 rem = (sigA<<10) - sigZ * sigB;
153 if ( rem & 0x8000 ) {
154 sigZ -= 2;
155 } else {
156 if ( rem ) sigZ |= 1;
157 }
158 }
159#endif
160 return softfloat_roundPackToF16( signZ, expZ, sigZ );
161 /*------------------------------------------------------------------------
162 *------------------------------------------------------------------------*/
163 propagateNaN:
164 uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
165 goto uiZ;
166 /*------------------------------------------------------------------------
167 *------------------------------------------------------------------------*/
168 invalid:
169 softfloat_raiseFlags( softfloat_flag_invalid );
170 uiZ = defaultNaNF16UI;
171 goto uiZ;
172 /*------------------------------------------------------------------------
173 *------------------------------------------------------------------------*/
174 infinity:
175 uiZ = packToF16UI( signZ, 0x1F, 0 );
176 goto uiZ;
177 /*------------------------------------------------------------------------
178 *------------------------------------------------------------------------*/
179 zero:
180 uiZ = packToF16UI( signZ, 0, 0 );
181 uiZ:
182 uZ.ui = uiZ;
183 return uZ.f;
184
185}
186
deps/SoftFloat-3e/source/f16_eq.c created+66
......@@ -0,0 +1,66 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f16_eq( float16_t a, float16_t b )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 union ui16_f16 uB;
49 uint_fast16_t uiB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
56 if (
57 softfloat_isSigNaNF16UI( uiA ) || softfloat_isSigNaNF16UI( uiB )
58 ) {
59 softfloat_raiseFlags( softfloat_flag_invalid );
60 }
61 return false;
62 }
63 return (uiA == uiB) || ! (uint16_t) ((uiA | uiB)<<1);
64
65}
66
deps/SoftFloat-3e/source/f16_eq_signaling.c created+61
......@@ -0,0 +1,61 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f16_eq_signaling( float16_t a, float16_t b )
44{
45 union ui16_f16 uA;
46 uint_fast16_t uiA;
47 union ui16_f16 uB;
48 uint_fast16_t uiB;
49
50 uA.f = a;
51 uiA = uA.ui;
52 uB.f = b;
53 uiB = uB.ui;
54 if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
55 softfloat_raiseFlags( softfloat_flag_invalid );
56 return false;
57 }
58 return (uiA == uiB) || ! (uint16_t) ((uiA | uiB)<<1);
59
60}
61
deps/SoftFloat-3e/source/f16_isSignalingNaN.c created+51
......@@ -0,0 +1,51 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43bool f16_isSignalingNaN( float16_t a )
44{
45 union ui16_f16 uA;
46
47 uA.f = a;
48 return softfloat_isSigNaNF16UI( uA.ui );
49
50}
51
deps/SoftFloat-3e/source/f16_le.c created+66
......@@ -0,0 +1,66 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f16_le( float16_t a, float16_t b )
44{
45 union ui16_f16 uA;
46 uint_fast16_t uiA;
47 union ui16_f16 uB;
48 uint_fast16_t uiB;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
56 softfloat_raiseFlags( softfloat_flag_invalid );
57 return false;
58 }
59 signA = signF16UI( uiA );
60 signB = signF16UI( uiB );
61 return
62 (signA != signB) ? signA || ! (uint16_t) ((uiA | uiB)<<1)
63 : (uiA == uiB) || (signA ^ (uiA < uiB));
64
65}
66
deps/SoftFloat-3e/source/f16_le_quiet.c created+71
......@@ -0,0 +1,71 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f16_le_quiet( float16_t a, float16_t b )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 union ui16_f16 uB;
49 uint_fast16_t uiB;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA = uA.ui;
54 uB.f = b;
55 uiB = uB.ui;
56 if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
57 if (
58 softfloat_isSigNaNF16UI( uiA ) || softfloat_isSigNaNF16UI( uiB )
59 ) {
60 softfloat_raiseFlags( softfloat_flag_invalid );
61 }
62 return false;
63 }
64 signA = signF16UI( uiA );
65 signB = signF16UI( uiB );
66 return
67 (signA != signB) ? signA || ! (uint16_t) ((uiA | uiB)<<1)
68 : (uiA == uiB) || (signA ^ (uiA < uiB));
69
70}
71
deps/SoftFloat-3e/source/f16_lt.c created+66
......@@ -0,0 +1,66 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f16_lt( float16_t a, float16_t b )
44{
45 union ui16_f16 uA;
46 uint_fast16_t uiA;
47 union ui16_f16 uB;
48 uint_fast16_t uiB;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
56 softfloat_raiseFlags( softfloat_flag_invalid );
57 return false;
58 }
59 signA = signF16UI( uiA );
60 signB = signF16UI( uiB );
61 return
62 (signA != signB) ? signA && ((uint16_t) ((uiA | uiB)<<1) != 0)
63 : (uiA != uiB) && (signA ^ (uiA < uiB));
64
65}
66
deps/SoftFloat-3e/source/f16_lt_quiet.c created+71
......@@ -0,0 +1,71 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f16_lt_quiet( float16_t a, float16_t b )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 union ui16_f16 uB;
49 uint_fast16_t uiB;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA = uA.ui;
54 uB.f = b;
55 uiB = uB.ui;
56 if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
57 if (
58 softfloat_isSigNaNF16UI( uiA ) || softfloat_isSigNaNF16UI( uiB )
59 ) {
60 softfloat_raiseFlags( softfloat_flag_invalid );
61 }
62 return false;
63 }
64 signA = signF16UI( uiA );
65 signB = signF16UI( uiB );
66 return
67 (signA != signB) ? signA && ((uint16_t) ((uiA | uiB)<<1) != 0)
68 : (uiA != uiB) && (signA ^ (uiA < uiB));
69
70}
71
deps/SoftFloat-3e/source/f16_mul.c created+140
......@@ -0,0 +1,140 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t f16_mul( float16_t a, float16_t b )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool signA;
49 int_fast8_t expA;
50 uint_fast16_t sigA;
51 union ui16_f16 uB;
52 uint_fast16_t uiB;
53 bool signB;
54 int_fast8_t expB;
55 uint_fast16_t sigB;
56 bool signZ;
57 uint_fast16_t magBits;
58 struct exp8_sig16 normExpSig;
59 int_fast8_t expZ;
60 uint_fast32_t sig32Z;
61 uint_fast16_t sigZ, uiZ;
62 union ui16_f16 uZ;
63
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 uA.f = a;
67 uiA = uA.ui;
68 signA = signF16UI( uiA );
69 expA = expF16UI( uiA );
70 sigA = fracF16UI( uiA );
71 uB.f = b;
72 uiB = uB.ui;
73 signB = signF16UI( uiB );
74 expB = expF16UI( uiB );
75 sigB = fracF16UI( uiB );
76 signZ = signA ^ signB;
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 if ( expA == 0x1F ) {
80 if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN;
81 magBits = expB | sigB;
82 goto infArg;
83 }
84 if ( expB == 0x1F ) {
85 if ( sigB ) goto propagateNaN;
86 magBits = expA | sigA;
87 goto infArg;
88 }
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 if ( ! expA ) {
92 if ( ! sigA ) goto zero;
93 normExpSig = softfloat_normSubnormalF16Sig( sigA );
94 expA = normExpSig.exp;
95 sigA = normExpSig.sig;
96 }
97 if ( ! expB ) {
98 if ( ! sigB ) goto zero;
99 normExpSig = softfloat_normSubnormalF16Sig( sigB );
100 expB = normExpSig.exp;
101 sigB = normExpSig.sig;
102 }
103 /*------------------------------------------------------------------------
104 *------------------------------------------------------------------------*/
105 expZ = expA + expB - 0xF;
106 sigA = (sigA | 0x0400)<<4;
107 sigB = (sigB | 0x0400)<<5;
108 sig32Z = (uint_fast32_t) sigA * sigB;
109 sigZ = sig32Z>>16;
110 if ( sig32Z & 0xFFFF ) sigZ |= 1;
111 if ( sigZ < 0x4000 ) {
112 --expZ;
113 sigZ <<= 1;
114 }
115 return softfloat_roundPackToF16( signZ, expZ, sigZ );
116 /*------------------------------------------------------------------------
117 *------------------------------------------------------------------------*/
118 propagateNaN:
119 uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
120 goto uiZ;
121 /*------------------------------------------------------------------------
122 *------------------------------------------------------------------------*/
123 infArg:
124 if ( ! magBits ) {
125 softfloat_raiseFlags( softfloat_flag_invalid );
126 uiZ = defaultNaNF16UI;
127 } else {
128 uiZ = packToF16UI( signZ, 0x1F, 0 );
129 }
130 goto uiZ;
131 /*------------------------------------------------------------------------
132 *------------------------------------------------------------------------*/
133 zero:
134 uiZ = packToF16UI( signZ, 0, 0 );
135 uiZ:
136 uZ.ui = uiZ;
137 return uZ.f;
138
139}
140
deps/SoftFloat-3e/source/f16_mulAdd.c created+60
......@@ -0,0 +1,60 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float16_t f16_mulAdd( float16_t a, float16_t b, float16_t c )
43{
44 union ui16_f16 uA;
45 uint_fast16_t uiA;
46 union ui16_f16 uB;
47 uint_fast16_t uiB;
48 union ui16_f16 uC;
49 uint_fast16_t uiC;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 uC.f = c;
56 uiC = uC.ui;
57 return softfloat_mulAddF16( uiA, uiB, uiC, 0 );
58
59}
60
deps/SoftFloat-3e/source/f16_rem.c created+171
......@@ -0,0 +1,171 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t f16_rem( float16_t a, float16_t b )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool signA;
49 int_fast8_t expA;
50 uint_fast16_t sigA;
51 union ui16_f16 uB;
52 uint_fast16_t uiB;
53 int_fast8_t expB;
54 uint_fast16_t sigB;
55 struct exp8_sig16 normExpSig;
56 uint16_t rem;
57 int_fast8_t expDiff;
58 uint_fast16_t q;
59 uint32_t recip32, q32;
60 uint16_t altRem, meanRem;
61 bool signRem;
62 uint_fast16_t uiZ;
63 union ui16_f16 uZ;
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 uA.f = a;
68 uiA = uA.ui;
69 signA = signF16UI( uiA );
70 expA = expF16UI( uiA );
71 sigA = fracF16UI( uiA );
72 uB.f = b;
73 uiB = uB.ui;
74 expB = expF16UI( uiB );
75 sigB = fracF16UI( uiB );
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( expA == 0x1F ) {
79 if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN;
80 goto invalid;
81 }
82 if ( expB == 0x1F ) {
83 if ( sigB ) goto propagateNaN;
84 return a;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 if ( ! expB ) {
89 if ( ! sigB ) goto invalid;
90 normExpSig = softfloat_normSubnormalF16Sig( sigB );
91 expB = normExpSig.exp;
92 sigB = normExpSig.sig;
93 }
94 if ( ! expA ) {
95 if ( ! sigA ) return a;
96 normExpSig = softfloat_normSubnormalF16Sig( sigA );
97 expA = normExpSig.exp;
98 sigA = normExpSig.sig;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 rem = sigA | 0x0400;
103 sigB |= 0x0400;
104 expDiff = expA - expB;
105 if ( expDiff < 1 ) {
106 if ( expDiff < -1 ) return a;
107 sigB <<= 3;
108 if ( expDiff ) {
109 rem <<= 2;
110 q = 0;
111 } else {
112 rem <<= 3;
113 q = (sigB <= rem);
114 if ( q ) rem -= sigB;
115 }
116 } else {
117 recip32 = softfloat_approxRecip32_1( (uint_fast32_t) sigB<<21 );
118 /*--------------------------------------------------------------------
119 | Changing the shift of `rem' here requires also changing the initial
120 | subtraction from `expDiff'.
121 *--------------------------------------------------------------------*/
122 rem <<= 4;
123 expDiff -= 31;
124 /*--------------------------------------------------------------------
125 | The scale of `sigB' affects how many bits are obtained during each
126 | cycle of the loop. Currently this is 29 bits per loop iteration,
127 | which is believed to be the maximum possible.
128 *--------------------------------------------------------------------*/
129 sigB <<= 3;
130 for (;;) {
131 q32 = (rem * (uint_fast64_t) recip32)>>16;
132 if ( expDiff < 0 ) break;
133 rem = -((uint_fast16_t) q32 * sigB);
134 expDiff -= 29;
135 }
136 /*--------------------------------------------------------------------
137 | (`expDiff' cannot be less than -30 here.)
138 *--------------------------------------------------------------------*/
139 q32 >>= ~expDiff & 31;
140 q = q32;
141 rem = (rem<<(expDiff + 30)) - q * sigB;
142 }
143 /*------------------------------------------------------------------------
144 *------------------------------------------------------------------------*/
145 do {
146 altRem = rem;
147 ++q;
148 rem -= sigB;
149 } while ( ! (rem & 0x8000) );
150 meanRem = rem + altRem;
151 if ( (meanRem & 0x8000) || (! meanRem && (q & 1)) ) rem = altRem;
152 signRem = signA;
153 if ( 0x8000 <= rem ) {
154 signRem = ! signRem;
155 rem = -rem;
156 }
157 return softfloat_normRoundPackToF16( signRem, expB, rem );
158 /*------------------------------------------------------------------------
159 *------------------------------------------------------------------------*/
160 propagateNaN:
161 uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
162 goto uiZ;
163 invalid:
164 softfloat_raiseFlags( softfloat_flag_invalid );
165 uiZ = defaultNaNF16UI;
166 uiZ:
167 uZ.ui = uiZ;
168 return uZ.f;
169
170}
171
deps/SoftFloat-3e/source/f16_roundToInt.c created+120
......@@ -0,0 +1,120 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t f16_roundToInt( float16_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 int_fast8_t exp;
49 uint_fast16_t uiZ, lastBitMask, roundBitsMask;
50 union ui16_f16 uZ;
51
52 /*------------------------------------------------------------------------
53 *------------------------------------------------------------------------*/
54 uA.f = a;
55 uiA = uA.ui;
56 exp = expF16UI( uiA );
57 /*------------------------------------------------------------------------
58 *------------------------------------------------------------------------*/
59 if ( exp <= 0xE ) {
60 if ( !(uint16_t) (uiA<<1) ) return a;
61 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
62 uiZ = uiA & packToF16UI( 1, 0, 0 );
63 switch ( roundingMode ) {
64 case softfloat_round_near_even:
65 if ( !fracF16UI( uiA ) ) break;
66 case softfloat_round_near_maxMag:
67 if ( exp == 0xE ) uiZ |= packToF16UI( 0, 0xF, 0 );
68 break;
69 case softfloat_round_min:
70 if ( uiZ ) uiZ = packToF16UI( 1, 0xF, 0 );
71 break;
72 case softfloat_round_max:
73 if ( !uiZ ) uiZ = packToF16UI( 0, 0xF, 0 );
74 break;
75#ifdef SOFTFLOAT_ROUND_ODD
76 case softfloat_round_odd:
77 uiZ |= packToF16UI( 0, 0xF, 0 );
78 break;
79#endif
80 }
81 goto uiZ;
82 }
83 /*------------------------------------------------------------------------
84 *------------------------------------------------------------------------*/
85 if ( 0x19 <= exp ) {
86 if ( (exp == 0x1F) && fracF16UI( uiA ) ) {
87 uiZ = softfloat_propagateNaNF16UI( uiA, 0 );
88 goto uiZ;
89 }
90 return a;
91 }
92 /*------------------------------------------------------------------------
93 *------------------------------------------------------------------------*/
94 uiZ = uiA;
95 lastBitMask = (uint_fast16_t) 1<<(0x19 - exp);
96 roundBitsMask = lastBitMask - 1;
97 if ( roundingMode == softfloat_round_near_maxMag ) {
98 uiZ += lastBitMask>>1;
99 } else if ( roundingMode == softfloat_round_near_even ) {
100 uiZ += lastBitMask>>1;
101 if ( !(uiZ & roundBitsMask) ) uiZ &= ~lastBitMask;
102 } else if (
103 roundingMode
104 == (signF16UI( uiZ ) ? softfloat_round_min : softfloat_round_max)
105 ) {
106 uiZ += roundBitsMask;
107 }
108 uiZ &= ~roundBitsMask;
109 if ( uiZ != uiA ) {
110#ifdef SOFTFLOAT_ROUND_ODD
111 if ( roundingMode == softfloat_round_odd ) uiZ |= lastBitMask;
112#endif
113 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
114 }
115 uiZ:
116 uZ.ui = uiZ;
117 return uZ.f;
118
119}
120
deps/SoftFloat-3e/source/f16_sqrt.c created+136
......@@ -0,0 +1,136 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extern const uint16_t softfloat_approxRecipSqrt_1k0s[];
45extern const uint16_t softfloat_approxRecipSqrt_1k1s[];
46
47float16_t f16_sqrt( float16_t a )
48{
49 union ui16_f16 uA;
50 uint_fast16_t uiA;
51 bool signA;
52 int_fast8_t expA;
53 uint_fast16_t sigA, uiZ;
54 struct exp8_sig16 normExpSig;
55 int_fast8_t expZ;
56 int index;
57 uint_fast16_t r0;
58 uint_fast32_t ESqrR0;
59 uint16_t sigma0;
60 uint_fast16_t recipSqrt16, sigZ, shiftedSigZ;
61 uint16_t negRem;
62 union ui16_f16 uZ;
63
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 uA.f = a;
67 uiA = uA.ui;
68 signA = signF16UI( uiA );
69 expA = expF16UI( uiA );
70 sigA = fracF16UI( uiA );
71 /*------------------------------------------------------------------------
72 *------------------------------------------------------------------------*/
73 if ( expA == 0x1F ) {
74 if ( sigA ) {
75 uiZ = softfloat_propagateNaNF16UI( uiA, 0 );
76 goto uiZ;
77 }
78 if ( ! signA ) return a;
79 goto invalid;
80 }
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 if ( signA ) {
84 if ( ! (expA | sigA) ) return a;
85 goto invalid;
86 }
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 if ( ! expA ) {
90 if ( ! sigA ) return a;
91 normExpSig = softfloat_normSubnormalF16Sig( sigA );
92 expA = normExpSig.exp;
93 sigA = normExpSig.sig;
94 }
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 expZ = ((expA - 0xF)>>1) + 0xE;
98 expA &= 1;
99 sigA |= 0x0400;
100 index = (sigA>>6 & 0xE) + expA;
101 r0 = softfloat_approxRecipSqrt_1k0s[index]
102 - (((uint_fast32_t) softfloat_approxRecipSqrt_1k1s[index]
103 * (sigA & 0x7F))
104 >>11);
105 ESqrR0 = ((uint_fast32_t) r0 * r0)>>1;
106 if ( expA ) ESqrR0 >>= 1;
107 sigma0 = ~(uint_fast16_t) ((ESqrR0 * sigA)>>16);
108 recipSqrt16 = r0 + (((uint_fast32_t) r0 * sigma0)>>25);
109 if ( ! (recipSqrt16 & 0x8000) ) recipSqrt16 = 0x8000;
110 sigZ = ((uint_fast32_t) (sigA<<5) * recipSqrt16)>>16;
111 if ( expA ) sigZ >>= 1;
112 /*------------------------------------------------------------------------
113 *------------------------------------------------------------------------*/
114 ++sigZ;
115 if ( ! (sigZ & 7) ) {
116 shiftedSigZ = sigZ>>1;
117 negRem = shiftedSigZ * shiftedSigZ;
118 sigZ &= ~1;
119 if ( negRem & 0x8000 ) {
120 sigZ |= 1;
121 } else {
122 if ( negRem ) --sigZ;
123 }
124 }
125 return softfloat_roundPackToF16( 0, expZ, sigZ );
126 /*------------------------------------------------------------------------
127 *------------------------------------------------------------------------*/
128 invalid:
129 softfloat_raiseFlags( softfloat_flag_invalid );
130 uiZ = defaultNaNF16UI;
131 uiZ:
132 uZ.ui = uiZ;
133 return uZ.f;
134
135}
136
deps/SoftFloat-3e/source/f16_sub.c created+70
......@@ -0,0 +1,70 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float16_t f16_sub( float16_t a, float16_t b )
44{
45 union ui16_f16 uA;
46 uint_fast16_t uiA;
47 union ui16_f16 uB;
48 uint_fast16_t uiB;
49#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
50 float16_t (*magsFuncPtr)( uint_fast16_t, uint_fast16_t );
51#endif
52
53 uA.f = a;
54 uiA = uA.ui;
55 uB.f = b;
56 uiB = uB.ui;
57#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
58 if ( signF16UI( uiA ^ uiB ) ) {
59 return softfloat_addMagsF16( uiA, uiB );
60 } else {
61 return softfloat_subMagsF16( uiA, uiB );
62 }
63#else
64 magsFuncPtr =
65 signF16UI( uiA ^ uiB ) ? softfloat_addMagsF16 : softfloat_subMagsF16;
66 return (*magsFuncPtr)( uiA, uiB );
67#endif
68
69}
70
deps/SoftFloat-3e/source/f16_to_extF80.c created+101
......@@ -0,0 +1,101 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t f16_to_extF80( float16_t a )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 uint_fast16_t uiZ64;
54 uint_fast64_t uiZ0;
55 struct exp8_sig16 normExpSig;
56 union { struct extFloat80M s; extFloat80_t f; } uZ;
57
58 /*------------------------------------------------------------------------
59 *------------------------------------------------------------------------*/
60 uA.f = a;
61 uiA = uA.ui;
62 sign = signF16UI( uiA );
63 exp = expF16UI( uiA );
64 frac = fracF16UI( uiA );
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( exp == 0x1F ) {
68 if ( frac ) {
69 softfloat_f16UIToCommonNaN( uiA, &commonNaN );
70 uiZ = softfloat_commonNaNToExtF80UI( &commonNaN );
71 uiZ64 = uiZ.v64;
72 uiZ0 = uiZ.v0;
73 } else {
74 uiZ64 = packToExtF80UI64( sign, 0x7FFF );
75 uiZ0 = UINT64_C( 0x8000000000000000 );
76 }
77 goto uiZ;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 if ( ! exp ) {
82 if ( ! frac ) {
83 uiZ64 = packToExtF80UI64( sign, 0 );
84 uiZ0 = 0;
85 goto uiZ;
86 }
87 normExpSig = softfloat_normSubnormalF16Sig( frac );
88 exp = normExpSig.exp;
89 frac = normExpSig.sig;
90 }
91 /*------------------------------------------------------------------------
92 *------------------------------------------------------------------------*/
93 uiZ64 = packToExtF80UI64( sign, exp + 0x3FF0 );
94 uiZ0 = (uint_fast64_t) (frac | 0x0400)<<53;
95 uiZ:
96 uZ.s.signExp = uiZ64;
97 uZ.s.signif = uiZ0;
98 return uZ.f;
99
100}
101
deps/SoftFloat-3e/source/f16_to_extF80M.c created+111
......@@ -0,0 +1,111 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void f16_to_extF80M( float16_t a, extFloat80_t *zPtr )
47{
48
49 *zPtr = f16_to_extF80( a );
50
51}
52
53#else
54
55void f16_to_extF80M( float16_t a, extFloat80_t *zPtr )
56{
57 struct extFloat80M *zSPtr;
58 union ui16_f16 uA;
59 uint16_t uiA;
60 bool sign;
61 int_fast8_t exp;
62 uint16_t frac;
63 struct commonNaN commonNaN;
64 uint_fast16_t uiZ64;
65 uint32_t uiZ32;
66 struct exp8_sig16 normExpSig;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 zSPtr = (struct extFloat80M *) zPtr;
71 uA.f = a;
72 uiA = uA.ui;
73 sign = signF16UI( uiA );
74 exp = expF16UI( uiA );
75 frac = fracF16UI( uiA );
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( exp == 0x1F ) {
79 if ( frac ) {
80 softfloat_f16UIToCommonNaN( uiA, &commonNaN );
81 softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
82 return;
83 }
84 uiZ64 = packToExtF80UI64( sign, 0x7FFF );
85 uiZ32 = 0x80000000;
86 goto uiZ;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( ! exp ) {
91 if ( ! frac ) {
92 uiZ64 = packToExtF80UI64( sign, 0 );
93 uiZ32 = 0;
94 goto uiZ;
95 }
96 normExpSig = softfloat_normSubnormalF16Sig( frac );
97 exp = normExpSig.exp;
98 frac = normExpSig.sig;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 uiZ64 = packToExtF80UI64( sign, exp + 0x3FF0 );
103 uiZ32 = 0x80000000 | (uint32_t) frac<<21;
104 uiZ:
105 zSPtr->signExp = uiZ64;
106 zSPtr->signif = (uint64_t) uiZ32<<32;
107
108}
109
110#endif
111
deps/SoftFloat-3e/source/f16_to_f128.c created+96
......@@ -0,0 +1,96 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t f16_to_f128( float16_t a )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 struct exp8_sig16 normExpSig;
54 union ui128_f128 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA = uA.ui;
60 sign = signF16UI( uiA );
61 exp = expF16UI( uiA );
62 frac = fracF16UI( uiA );
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0x1F ) {
66 if ( frac ) {
67 softfloat_f16UIToCommonNaN( uiA, &commonNaN );
68 uiZ = softfloat_commonNaNToF128UI( &commonNaN );
69 } else {
70 uiZ.v64 = packToF128UI64( sign, 0x7FFF, 0 );
71 uiZ.v0 = 0;
72 }
73 goto uiZ;
74 }
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( ! exp ) {
78 if ( ! frac ) {
79 uiZ.v64 = packToF128UI64( sign, 0, 0 );
80 uiZ.v0 = 0;
81 goto uiZ;
82 }
83 normExpSig = softfloat_normSubnormalF16Sig( frac );
84 exp = normExpSig.exp - 1;
85 frac = normExpSig.sig;
86 }
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 uiZ.v64 = packToF128UI64( sign, exp + 0x3FF0, (uint_fast64_t) frac<<38 );
90 uiZ.v0 = 0;
91 uiZ:
92 uZ.ui = uiZ;
93 return uZ.f;
94
95}
96
deps/SoftFloat-3e/source/f16_to_f128M.c created+111
......@@ -0,0 +1,111 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void f16_to_f128M( float16_t a, float128_t *zPtr )
47{
48
49 *zPtr = f16_to_f128( a );
50
51}
52
53#else
54
55void f16_to_f128M( float16_t a, float128_t *zPtr )
56{
57 uint32_t *zWPtr;
58 union ui16_f16 uA;
59 uint16_t uiA;
60 bool sign;
61 int_fast8_t exp;
62 uint16_t frac;
63 struct commonNaN commonNaN;
64 uint32_t uiZ96;
65 struct exp8_sig16 normExpSig;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 zWPtr = (uint32_t *) zPtr;
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 uA.f = a;
73 uiA = uA.ui;
74 sign = signF16UI( uiA );
75 exp = expF16UI( uiA );
76 frac = fracF16UI( uiA );
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 if ( exp == 0x1F ) {
80 if ( frac ) {
81 softfloat_f16UIToCommonNaN( uiA, &commonNaN );
82 softfloat_commonNaNToF128M( &commonNaN, zWPtr );
83 return;
84 }
85 uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
86 goto uiZ;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( ! exp ) {
91 if ( ! frac ) {
92 uiZ96 = packToF128UI96( sign, 0, 0 );
93 goto uiZ;
94 }
95 normExpSig = softfloat_normSubnormalF16Sig( frac );
96 exp = normExpSig.exp - 1;
97 frac = normExpSig.sig;
98 }
99 /*------------------------------------------------------------------------
100 *------------------------------------------------------------------------*/
101 uiZ96 = packToF128UI96( sign, exp + 0x3FF0, (uint32_t) frac<<6 );
102 uiZ:
103 zWPtr[indexWord( 4, 3 )] = uiZ96;
104 zWPtr[indexWord( 4, 2 )] = 0;
105 zWPtr[indexWord( 4, 1 )] = 0;
106 zWPtr[indexWord( 4, 0 )] = 0;
107
108}
109
110#endif
111
deps/SoftFloat-3e/source/f16_to_f32.c created+93
......@@ -0,0 +1,93 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t f16_to_f32( float16_t a )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 struct commonNaN commonNaN;
52 uint_fast32_t uiZ;
53 struct exp8_sig16 normExpSig;
54 union ui32_f32 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA = uA.ui;
60 sign = signF16UI( uiA );
61 exp = expF16UI( uiA );
62 frac = fracF16UI( uiA );
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0x1F ) {
66 if ( frac ) {
67 softfloat_f16UIToCommonNaN( uiA, &commonNaN );
68 uiZ = softfloat_commonNaNToF32UI( &commonNaN );
69 } else {
70 uiZ = packToF32UI( sign, 0xFF, 0 );
71 }
72 goto uiZ;
73 }
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( ! exp ) {
77 if ( ! frac ) {
78 uiZ = packToF32UI( sign, 0, 0 );
79 goto uiZ;
80 }
81 normExpSig = softfloat_normSubnormalF16Sig( frac );
82 exp = normExpSig.exp - 1;
83 frac = normExpSig.sig;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 uiZ = packToF32UI( sign, exp + 0x70, (uint_fast32_t) frac<<13 );
88 uiZ:
89 uZ.ui = uiZ;
90 return uZ.f;
91
92}
93
deps/SoftFloat-3e/source/f16_to_f64.c created+93
......@@ -0,0 +1,93 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t f16_to_f64( float16_t a )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 struct commonNaN commonNaN;
52 uint_fast64_t uiZ;
53 struct exp8_sig16 normExpSig;
54 union ui64_f64 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA = uA.ui;
60 sign = signF16UI( uiA );
61 exp = expF16UI( uiA );
62 frac = fracF16UI( uiA );
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0x1F ) {
66 if ( frac ) {
67 softfloat_f16UIToCommonNaN( uiA, &commonNaN );
68 uiZ = softfloat_commonNaNToF64UI( &commonNaN );
69 } else {
70 uiZ = packToF64UI( sign, 0x7FF, 0 );
71 }
72 goto uiZ;
73 }
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( ! exp ) {
77 if ( ! frac ) {
78 uiZ = packToF64UI( sign, 0, 0 );
79 goto uiZ;
80 }
81 normExpSig = softfloat_normSubnormalF16Sig( frac );
82 exp = normExpSig.exp - 1;
83 frac = normExpSig.sig;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 uiZ = packToF64UI( sign, exp + 0x3F0, (uint_fast64_t) frac<<42 );
88 uiZ:
89 uZ.ui = uiZ;
90 return uZ.f;
91
92}
93
deps/SoftFloat-3e/source/f16_to_i32.c created+87
......@@ -0,0 +1,87 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t f16_to_i32( float16_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 int_fast32_t sig32;
52 int_fast8_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF16UI( uiA );
59 exp = expF16UI( uiA );
60 frac = fracF16UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 if ( exp == 0x1F ) {
64 softfloat_raiseFlags( softfloat_flag_invalid );
65 return
66 frac ? i32_fromNaN
67 : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sig32 = frac;
72 if ( exp ) {
73 sig32 |= 0x0400;
74 shiftDist = exp - 0x19;
75 if ( 0 <= shiftDist ) {
76 sig32 <<= shiftDist;
77 return sign ? -sig32 : sig32;
78 }
79 shiftDist = exp - 0x0D;
80 if ( 0 < shiftDist ) sig32 <<= shiftDist;
81 }
82 return
83 softfloat_roundToI32(
84 sign, (uint_fast32_t) sig32, roundingMode, exact );
85
86}
87
deps/SoftFloat-3e/source/f16_to_i32_r_minMag.c created+88
......@@ -0,0 +1,88 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t f16_to_i32_r_minMag( float16_t a, bool exact )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 int_fast8_t exp;
49 uint_fast16_t frac;
50 int_fast8_t shiftDist;
51 bool sign;
52 int_fast32_t alignedSig;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF16UI( uiA );
59 frac = fracF16UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = exp - 0x0F;
63 if ( shiftDist < 0 ) {
64 if ( exact && (exp | frac) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF16UI( uiA );
72 if ( exp == 0x1F ) {
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 return
75 (exp == 0x1F) && frac ? i32_fromNaN
76 : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 alignedSig = (int_fast32_t) (frac | 0x0400)<<shiftDist;
81 if ( exact && (alignedSig & 0x3FF) ) {
82 softfloat_exceptionFlags |= softfloat_flag_inexact;
83 }
84 alignedSig >>= 10;
85 return sign ? -alignedSig : alignedSig;
86
87}
88
deps/SoftFloat-3e/source/f16_to_i64.c created+87
......@@ -0,0 +1,87 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t f16_to_i64( float16_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 int_fast32_t sig32;
52 int_fast8_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF16UI( uiA );
59 exp = expF16UI( uiA );
60 frac = fracF16UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 if ( exp == 0x1F ) {
64 softfloat_raiseFlags( softfloat_flag_invalid );
65 return
66 frac ? i64_fromNaN
67 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sig32 = frac;
72 if ( exp ) {
73 sig32 |= 0x0400;
74 shiftDist = exp - 0x19;
75 if ( 0 <= shiftDist ) {
76 sig32 <<= shiftDist;
77 return sign ? -sig32 : sig32;
78 }
79 shiftDist = exp - 0x0D;
80 if ( 0 < shiftDist ) sig32 <<= shiftDist;
81 }
82 return
83 softfloat_roundToI32(
84 sign, (uint_fast32_t) sig32, roundingMode, exact );
85
86}
87
deps/SoftFloat-3e/source/f16_to_i64_r_minMag.c created+88
......@@ -0,0 +1,88 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t f16_to_i64_r_minMag( float16_t a, bool exact )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 int_fast8_t exp;
49 uint_fast16_t frac;
50 int_fast8_t shiftDist;
51 bool sign;
52 int_fast32_t alignedSig;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF16UI( uiA );
59 frac = fracF16UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = exp - 0x0F;
63 if ( shiftDist < 0 ) {
64 if ( exact && (exp | frac) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF16UI( uiA );
72 if ( exp == 0x1F ) {
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 return
75 (exp == 0x1F) && frac ? i64_fromNaN
76 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 alignedSig = (int_fast32_t) (frac | 0x0400)<<shiftDist;
81 if ( exact && (alignedSig & 0x3FF) ) {
82 softfloat_exceptionFlags |= softfloat_flag_inexact;
83 }
84 alignedSig >>= 10;
85 return sign ? -alignedSig : alignedSig;
86
87}
88
deps/SoftFloat-3e/source/f16_to_ui32.c created+84
......@@ -0,0 +1,84 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t f16_to_ui32( float16_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 uint_fast32_t sig32;
52 int_fast8_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF16UI( uiA );
59 exp = expF16UI( uiA );
60 frac = fracF16UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 if ( exp == 0x1F ) {
64 softfloat_raiseFlags( softfloat_flag_invalid );
65 return
66 frac ? ui32_fromNaN
67 : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sig32 = frac;
72 if ( exp ) {
73 sig32 |= 0x0400;
74 shiftDist = exp - 0x19;
75 if ( (0 <= shiftDist) && ! sign ) {
76 return sig32<<shiftDist;
77 }
78 shiftDist = exp - 0x0D;
79 if ( 0 < shiftDist ) sig32 <<= shiftDist;
80 }
81 return softfloat_roundToUI32( sign, sig32, roundingMode, exact );
82
83}
84
deps/SoftFloat-3e/source/f16_to_ui32_r_minMag.c created+87
......@@ -0,0 +1,87 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t f16_to_ui32_r_minMag( float16_t a, bool exact )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 int_fast8_t exp;
49 uint_fast16_t frac;
50 int_fast8_t shiftDist;
51 bool sign;
52 uint_fast32_t alignedSig;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF16UI( uiA );
59 frac = fracF16UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = exp - 0x0F;
63 if ( shiftDist < 0 ) {
64 if ( exact && (exp | frac) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF16UI( uiA );
72 if ( sign || (exp == 0x1F) ) {
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 return
75 (exp == 0x1F) && frac ? ui32_fromNaN
76 : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 alignedSig = (uint_fast32_t) (frac | 0x0400)<<shiftDist;
81 if ( exact && (alignedSig & 0x3FF) ) {
82 softfloat_exceptionFlags |= softfloat_flag_inexact;
83 }
84 return alignedSig>>10;
85
86}
87
deps/SoftFloat-3e/source/f16_to_ui64.c created+96
......@@ -0,0 +1,96 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t f16_to_ui64( float16_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 bool sign;
49 int_fast8_t exp;
50 uint_fast16_t frac;
51 uint_fast32_t sig32;
52 int_fast8_t shiftDist;
53#ifndef SOFTFLOAT_FAST_INT64
54 uint32_t extSig[3];
55#endif
56
57 /*------------------------------------------------------------------------
58 *------------------------------------------------------------------------*/
59 uA.f = a;
60 uiA = uA.ui;
61 sign = signF16UI( uiA );
62 exp = expF16UI( uiA );
63 frac = fracF16UI( uiA );
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 if ( exp == 0x1F ) {
67 softfloat_raiseFlags( softfloat_flag_invalid );
68 return
69 frac ? ui64_fromNaN
70 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
71 }
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 sig32 = frac;
75 if ( exp ) {
76 sig32 |= 0x0400;
77 shiftDist = exp - 0x19;
78 if ( (0 <= shiftDist) && ! sign ) {
79 return sig32<<shiftDist;
80 }
81 shiftDist = exp - 0x0D;
82 if ( 0 < shiftDist ) sig32 <<= shiftDist;
83 }
84#ifdef SOFTFLOAT_FAST_INT64
85 return
86 softfloat_roundToUI64(
87 sign, sig32>>12, (uint_fast64_t) sig32<<52, roundingMode, exact );
88#else
89 extSig[indexWord( 3, 2 )] = 0;
90 extSig[indexWord( 3, 1 )] = sig32>>12;
91 extSig[indexWord( 3, 0 )] = sig32<<20;
92 return softfloat_roundMToUI64( sign, extSig, roundingMode, exact );
93#endif
94
95}
96
deps/SoftFloat-3e/source/f16_to_ui64_r_minMag.c created+87
......@@ -0,0 +1,87 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t f16_to_ui64_r_minMag( float16_t a, bool exact )
45{
46 union ui16_f16 uA;
47 uint_fast16_t uiA;
48 int_fast8_t exp;
49 uint_fast16_t frac;
50 int_fast8_t shiftDist;
51 bool sign;
52 uint_fast32_t alignedSig;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF16UI( uiA );
59 frac = fracF16UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = exp - 0x0F;
63 if ( shiftDist < 0 ) {
64 if ( exact && (exp | frac) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF16UI( uiA );
72 if ( sign || (exp == 0x1F) ) {
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 return
75 (exp == 0x1F) && frac ? ui64_fromNaN
76 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 alignedSig = (uint_fast32_t) (frac | 0x0400)<<shiftDist;
81 if ( exact && (alignedSig & 0x3FF) ) {
82 softfloat_exceptionFlags |= softfloat_flag_inexact;
83 }
84 return alignedSig>>10;
85
86}
87
deps/SoftFloat-3e/source/f32_add.c created+70
......@@ -0,0 +1,70 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float32_t f32_add( float32_t a, float32_t b )
44{
45 union ui32_f32 uA;
46 uint_fast32_t uiA;
47 union ui32_f32 uB;
48 uint_fast32_t uiB;
49#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
50 float32_t (*magsFuncPtr)( uint_fast32_t, uint_fast32_t );
51#endif
52
53 uA.f = a;
54 uiA = uA.ui;
55 uB.f = b;
56 uiB = uB.ui;
57#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
58 if ( signF32UI( uiA ^ uiB ) ) {
59 return softfloat_subMagsF32( uiA, uiB );
60 } else {
61 return softfloat_addMagsF32( uiA, uiB );
62 }
63#else
64 magsFuncPtr =
65 signF32UI( uiA ^ uiB ) ? softfloat_subMagsF32 : softfloat_addMagsF32;
66 return (*magsFuncPtr)( uiA, uiB );
67#endif
68
69}
70
deps/SoftFloat-3e/source/f32_div.c created+180
......@@ -0,0 +1,180 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t f32_div( float32_t a, float32_t b )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast32_t sigA;
51 union ui32_f32 uB;
52 uint_fast32_t uiB;
53 bool signB;
54 int_fast16_t expB;
55 uint_fast32_t sigB;
56 bool signZ;
57 struct exp16_sig32 normExpSig;
58 int_fast16_t expZ;
59#ifdef SOFTFLOAT_FAST_DIV64TO32
60 uint_fast64_t sig64A;
61 uint_fast32_t sigZ;
62#else
63 uint_fast32_t sigZ;
64 uint_fast64_t rem;
65#endif
66 uint_fast32_t uiZ;
67 union ui32_f32 uZ;
68
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 uA.f = a;
72 uiA = uA.ui;
73 signA = signF32UI( uiA );
74 expA = expF32UI( uiA );
75 sigA = fracF32UI( uiA );
76 uB.f = b;
77 uiB = uB.ui;
78 signB = signF32UI( uiB );
79 expB = expF32UI( uiB );
80 sigB = fracF32UI( uiB );
81 signZ = signA ^ signB;
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( expA == 0xFF ) {
85 if ( sigA ) goto propagateNaN;
86 if ( expB == 0xFF ) {
87 if ( sigB ) goto propagateNaN;
88 goto invalid;
89 }
90 goto infinity;
91 }
92 if ( expB == 0xFF ) {
93 if ( sigB ) goto propagateNaN;
94 goto zero;
95 }
96 /*------------------------------------------------------------------------
97 *------------------------------------------------------------------------*/
98 if ( ! expB ) {
99 if ( ! sigB ) {
100 if ( ! (expA | sigA) ) goto invalid;
101 softfloat_raiseFlags( softfloat_flag_infinite );
102 goto infinity;
103 }
104 normExpSig = softfloat_normSubnormalF32Sig( sigB );
105 expB = normExpSig.exp;
106 sigB = normExpSig.sig;
107 }
108 if ( ! expA ) {
109 if ( ! sigA ) goto zero;
110 normExpSig = softfloat_normSubnormalF32Sig( sigA );
111 expA = normExpSig.exp;
112 sigA = normExpSig.sig;
113 }
114 /*------------------------------------------------------------------------
115 *------------------------------------------------------------------------*/
116 expZ = expA - expB + 0x7E;
117 sigA |= 0x00800000;
118 sigB |= 0x00800000;
119#ifdef SOFTFLOAT_FAST_DIV64TO32
120 if ( sigA < sigB ) {
121 --expZ;
122 sig64A = (uint_fast64_t) sigA<<31;
123 } else {
124 sig64A = (uint_fast64_t) sigA<<30;
125 }
126 sigZ = sig64A / sigB;
127 if ( ! (sigZ & 0x3F) ) sigZ |= ((uint_fast64_t) sigB * sigZ != sig64A);
128#else
129 if ( sigA < sigB ) {
130 --expZ;
131 sigA <<= 8;
132 } else {
133 sigA <<= 7;
134 }
135 sigB <<= 8;
136 sigZ = ((uint_fast64_t) sigA * softfloat_approxRecip32_1( sigB ))>>32;
137 /*------------------------------------------------------------------------
138 *------------------------------------------------------------------------*/
139 sigZ += 2;
140 if ( (sigZ & 0x3F) < 2 ) {
141 sigZ &= ~3;
142#ifdef SOFTFLOAT_FAST_INT64
143 rem = ((uint_fast64_t) sigA<<31) - (uint_fast64_t) sigZ * sigB;
144#else
145 rem = ((uint_fast64_t) sigA<<32) - (uint_fast64_t) (sigZ<<1) * sigB;
146#endif
147 if ( rem & UINT64_C( 0x8000000000000000 ) ) {
148 sigZ -= 4;
149 } else {
150 if ( rem ) sigZ |= 1;
151 }
152 }
153#endif
154 return softfloat_roundPackToF32( signZ, expZ, sigZ );
155 /*------------------------------------------------------------------------
156 *------------------------------------------------------------------------*/
157 propagateNaN:
158 uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
159 goto uiZ;
160 /*------------------------------------------------------------------------
161 *------------------------------------------------------------------------*/
162 invalid:
163 softfloat_raiseFlags( softfloat_flag_invalid );
164 uiZ = defaultNaNF32UI;
165 goto uiZ;
166 /*------------------------------------------------------------------------
167 *------------------------------------------------------------------------*/
168 infinity:
169 uiZ = packToF32UI( signZ, 0xFF, 0 );
170 goto uiZ;
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 zero:
174 uiZ = packToF32UI( signZ, 0, 0 );
175 uiZ:
176 uZ.ui = uiZ;
177 return uZ.f;
178
179}
180
deps/SoftFloat-3e/source/f32_eq.c created+66
......@@ -0,0 +1,66 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f32_eq( float32_t a, float32_t b )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 union ui32_f32 uB;
49 uint_fast32_t uiB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
56 if (
57 softfloat_isSigNaNF32UI( uiA ) || softfloat_isSigNaNF32UI( uiB )
58 ) {
59 softfloat_raiseFlags( softfloat_flag_invalid );
60 }
61 return false;
62 }
63 return (uiA == uiB) || ! (uint32_t) ((uiA | uiB)<<1);
64
65}
66
deps/SoftFloat-3e/source/f32_eq_signaling.c created+61
......@@ -0,0 +1,61 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f32_eq_signaling( float32_t a, float32_t b )
44{
45 union ui32_f32 uA;
46 uint_fast32_t uiA;
47 union ui32_f32 uB;
48 uint_fast32_t uiB;
49
50 uA.f = a;
51 uiA = uA.ui;
52 uB.f = b;
53 uiB = uB.ui;
54 if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
55 softfloat_raiseFlags( softfloat_flag_invalid );
56 return false;
57 }
58 return (uiA == uiB) || ! (uint32_t) ((uiA | uiB)<<1);
59
60}
61
deps/SoftFloat-3e/source/f32_isSignalingNaN.c created+51
......@@ -0,0 +1,51 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43bool f32_isSignalingNaN( float32_t a )
44{
45 union ui32_f32 uA;
46
47 uA.f = a;
48 return softfloat_isSigNaNF32UI( uA.ui );
49
50}
51
deps/SoftFloat-3e/source/f32_le.c created+66
......@@ -0,0 +1,66 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f32_le( float32_t a, float32_t b )
44{
45 union ui32_f32 uA;
46 uint_fast32_t uiA;
47 union ui32_f32 uB;
48 uint_fast32_t uiB;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
56 softfloat_raiseFlags( softfloat_flag_invalid );
57 return false;
58 }
59 signA = signF32UI( uiA );
60 signB = signF32UI( uiB );
61 return
62 (signA != signB) ? signA || ! (uint32_t) ((uiA | uiB)<<1)
63 : (uiA == uiB) || (signA ^ (uiA < uiB));
64
65}
66
deps/SoftFloat-3e/source/f32_le_quiet.c created+71
......@@ -0,0 +1,71 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f32_le_quiet( float32_t a, float32_t b )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 union ui32_f32 uB;
49 uint_fast32_t uiB;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA = uA.ui;
54 uB.f = b;
55 uiB = uB.ui;
56 if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
57 if (
58 softfloat_isSigNaNF32UI( uiA ) || softfloat_isSigNaNF32UI( uiB )
59 ) {
60 softfloat_raiseFlags( softfloat_flag_invalid );
61 }
62 return false;
63 }
64 signA = signF32UI( uiA );
65 signB = signF32UI( uiB );
66 return
67 (signA != signB) ? signA || ! (uint32_t) ((uiA | uiB)<<1)
68 : (uiA == uiB) || (signA ^ (uiA < uiB));
69
70}
71
deps/SoftFloat-3e/source/f32_lt.c created+66
......@@ -0,0 +1,66 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f32_lt( float32_t a, float32_t b )
44{
45 union ui32_f32 uA;
46 uint_fast32_t uiA;
47 union ui32_f32 uB;
48 uint_fast32_t uiB;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
56 softfloat_raiseFlags( softfloat_flag_invalid );
57 return false;
58 }
59 signA = signF32UI( uiA );
60 signB = signF32UI( uiB );
61 return
62 (signA != signB) ? signA && ((uint32_t) ((uiA | uiB)<<1) != 0)
63 : (uiA != uiB) && (signA ^ (uiA < uiB));
64
65}
66
deps/SoftFloat-3e/source/f32_lt_quiet.c created+71
......@@ -0,0 +1,71 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f32_lt_quiet( float32_t a, float32_t b )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 union ui32_f32 uB;
49 uint_fast32_t uiB;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA = uA.ui;
54 uB.f = b;
55 uiB = uB.ui;
56 if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
57 if (
58 softfloat_isSigNaNF32UI( uiA ) || softfloat_isSigNaNF32UI( uiB )
59 ) {
60 softfloat_raiseFlags( softfloat_flag_invalid );
61 }
62 return false;
63 }
64 signA = signF32UI( uiA );
65 signB = signF32UI( uiB );
66 return
67 (signA != signB) ? signA && ((uint32_t) ((uiA | uiB)<<1) != 0)
68 : (uiA != uiB) && (signA ^ (uiA < uiB));
69
70}
71
deps/SoftFloat-3e/source/f32_mul.c created+137
......@@ -0,0 +1,137 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t f32_mul( float32_t a, float32_t b )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast32_t sigA;
51 union ui32_f32 uB;
52 uint_fast32_t uiB;
53 bool signB;
54 int_fast16_t expB;
55 uint_fast32_t sigB;
56 bool signZ;
57 uint_fast32_t magBits;
58 struct exp16_sig32 normExpSig;
59 int_fast16_t expZ;
60 uint_fast32_t sigZ, uiZ;
61 union ui32_f32 uZ;
62
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 uA.f = a;
66 uiA = uA.ui;
67 signA = signF32UI( uiA );
68 expA = expF32UI( uiA );
69 sigA = fracF32UI( uiA );
70 uB.f = b;
71 uiB = uB.ui;
72 signB = signF32UI( uiB );
73 expB = expF32UI( uiB );
74 sigB = fracF32UI( uiB );
75 signZ = signA ^ signB;
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( expA == 0xFF ) {
79 if ( sigA || ((expB == 0xFF) && sigB) ) goto propagateNaN;
80 magBits = expB | sigB;
81 goto infArg;
82 }
83 if ( expB == 0xFF ) {
84 if ( sigB ) goto propagateNaN;
85 magBits = expA | sigA;
86 goto infArg;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( ! expA ) {
91 if ( ! sigA ) goto zero;
92 normExpSig = softfloat_normSubnormalF32Sig( sigA );
93 expA = normExpSig.exp;
94 sigA = normExpSig.sig;
95 }
96 if ( ! expB ) {
97 if ( ! sigB ) goto zero;
98 normExpSig = softfloat_normSubnormalF32Sig( sigB );
99 expB = normExpSig.exp;
100 sigB = normExpSig.sig;
101 }
102 /*------------------------------------------------------------------------
103 *------------------------------------------------------------------------*/
104 expZ = expA + expB - 0x7F;
105 sigA = (sigA | 0x00800000)<<7;
106 sigB = (sigB | 0x00800000)<<8;
107 sigZ = softfloat_shortShiftRightJam64( (uint_fast64_t) sigA * sigB, 32 );
108 if ( sigZ < 0x40000000 ) {
109 --expZ;
110 sigZ <<= 1;
111 }
112 return softfloat_roundPackToF32( signZ, expZ, sigZ );
113 /*------------------------------------------------------------------------
114 *------------------------------------------------------------------------*/
115 propagateNaN:
116 uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
117 goto uiZ;
118 /*------------------------------------------------------------------------
119 *------------------------------------------------------------------------*/
120 infArg:
121 if ( ! magBits ) {
122 softfloat_raiseFlags( softfloat_flag_invalid );
123 uiZ = defaultNaNF32UI;
124 } else {
125 uiZ = packToF32UI( signZ, 0xFF, 0 );
126 }
127 goto uiZ;
128 /*------------------------------------------------------------------------
129 *------------------------------------------------------------------------*/
130 zero:
131 uiZ = packToF32UI( signZ, 0, 0 );
132 uiZ:
133 uZ.ui = uiZ;
134 return uZ.f;
135
136}
137
deps/SoftFloat-3e/source/f32_mulAdd.c created+60
......@@ -0,0 +1,60 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float32_t f32_mulAdd( float32_t a, float32_t b, float32_t c )
43{
44 union ui32_f32 uA;
45 uint_fast32_t uiA;
46 union ui32_f32 uB;
47 uint_fast32_t uiB;
48 union ui32_f32 uC;
49 uint_fast32_t uiC;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 uC.f = c;
56 uiC = uC.ui;
57 return softfloat_mulAddF32( uiA, uiB, uiC, 0 );
58
59}
60
deps/SoftFloat-3e/source/f32_rem.c created+168
......@@ -0,0 +1,168 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t f32_rem( float32_t a, float32_t b )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast32_t sigA;
51 union ui32_f32 uB;
52 uint_fast32_t uiB;
53 int_fast16_t expB;
54 uint_fast32_t sigB;
55 struct exp16_sig32 normExpSig;
56 uint32_t rem;
57 int_fast16_t expDiff;
58 uint32_t q, recip32, altRem, meanRem;
59 bool signRem;
60 uint_fast32_t uiZ;
61 union ui32_f32 uZ;
62
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 uA.f = a;
66 uiA = uA.ui;
67 signA = signF32UI( uiA );
68 expA = expF32UI( uiA );
69 sigA = fracF32UI( uiA );
70 uB.f = b;
71 uiB = uB.ui;
72 expB = expF32UI( uiB );
73 sigB = fracF32UI( uiB );
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( expA == 0xFF ) {
77 if ( sigA || ((expB == 0xFF) && sigB) ) goto propagateNaN;
78 goto invalid;
79 }
80 if ( expB == 0xFF ) {
81 if ( sigB ) goto propagateNaN;
82 return a;
83 }
84 /*------------------------------------------------------------------------
85 *------------------------------------------------------------------------*/
86 if ( ! expB ) {
87 if ( ! sigB ) goto invalid;
88 normExpSig = softfloat_normSubnormalF32Sig( sigB );
89 expB = normExpSig.exp;
90 sigB = normExpSig.sig;
91 }
92 if ( ! expA ) {
93 if ( ! sigA ) return a;
94 normExpSig = softfloat_normSubnormalF32Sig( sigA );
95 expA = normExpSig.exp;
96 sigA = normExpSig.sig;
97 }
98 /*------------------------------------------------------------------------
99 *------------------------------------------------------------------------*/
100 rem = sigA | 0x00800000;
101 sigB |= 0x00800000;
102 expDiff = expA - expB;
103 if ( expDiff < 1 ) {
104 if ( expDiff < -1 ) return a;
105 sigB <<= 6;
106 if ( expDiff ) {
107 rem <<= 5;
108 q = 0;
109 } else {
110 rem <<= 6;
111 q = (sigB <= rem);
112 if ( q ) rem -= sigB;
113 }
114 } else {
115 recip32 = softfloat_approxRecip32_1( sigB<<8 );
116 /*--------------------------------------------------------------------
117 | Changing the shift of `rem' here requires also changing the initial
118 | subtraction from `expDiff'.
119 *--------------------------------------------------------------------*/
120 rem <<= 7;
121 expDiff -= 31;
122 /*--------------------------------------------------------------------
123 | The scale of `sigB' affects how many bits are obtained during each
124 | cycle of the loop. Currently this is 29 bits per loop iteration,
125 | which is believed to be the maximum possible.
126 *--------------------------------------------------------------------*/
127 sigB <<= 6;
128 for (;;) {
129 q = (rem * (uint_fast64_t) recip32)>>32;
130 if ( expDiff < 0 ) break;
131 rem = -(q * (uint32_t) sigB);
132 expDiff -= 29;
133 }
134 /*--------------------------------------------------------------------
135 | (`expDiff' cannot be less than -30 here.)
136 *--------------------------------------------------------------------*/
137 q >>= ~expDiff & 31;
138 rem = (rem<<(expDiff + 30)) - q * (uint32_t) sigB;
139 }
140 /*------------------------------------------------------------------------
141 *------------------------------------------------------------------------*/
142 do {
143 altRem = rem;
144 ++q;
145 rem -= sigB;
146 } while ( ! (rem & 0x80000000) );
147 meanRem = rem + altRem;
148 if ( (meanRem & 0x80000000) || (! meanRem && (q & 1)) ) rem = altRem;
149 signRem = signA;
150 if ( 0x80000000 <= rem ) {
151 signRem = ! signRem;
152 rem = -rem;
153 }
154 return softfloat_normRoundPackToF32( signRem, expB, rem );
155 /*------------------------------------------------------------------------
156 *------------------------------------------------------------------------*/
157 propagateNaN:
158 uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
159 goto uiZ;
160 invalid:
161 softfloat_raiseFlags( softfloat_flag_invalid );
162 uiZ = defaultNaNF32UI;
163 uiZ:
164 uZ.ui = uiZ;
165 return uZ.f;
166
167}
168
deps/SoftFloat-3e/source/f32_roundToInt.c created+120
......@@ -0,0 +1,120 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t f32_roundToInt( float32_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 int_fast16_t exp;
49 uint_fast32_t uiZ, lastBitMask, roundBitsMask;
50 union ui32_f32 uZ;
51
52 /*------------------------------------------------------------------------
53 *------------------------------------------------------------------------*/
54 uA.f = a;
55 uiA = uA.ui;
56 exp = expF32UI( uiA );
57 /*------------------------------------------------------------------------
58 *------------------------------------------------------------------------*/
59 if ( exp <= 0x7E ) {
60 if ( !(uint32_t) (uiA<<1) ) return a;
61 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
62 uiZ = uiA & packToF32UI( 1, 0, 0 );
63 switch ( roundingMode ) {
64 case softfloat_round_near_even:
65 if ( !fracF32UI( uiA ) ) break;
66 case softfloat_round_near_maxMag:
67 if ( exp == 0x7E ) uiZ |= packToF32UI( 0, 0x7F, 0 );
68 break;
69 case softfloat_round_min:
70 if ( uiZ ) uiZ = packToF32UI( 1, 0x7F, 0 );
71 break;
72 case softfloat_round_max:
73 if ( !uiZ ) uiZ = packToF32UI( 0, 0x7F, 0 );
74 break;
75#ifdef SOFTFLOAT_ROUND_ODD
76 case softfloat_round_odd:
77 uiZ |= packToF32UI( 0, 0x7F, 0 );
78 break;
79#endif
80 }
81 goto uiZ;
82 }
83 /*------------------------------------------------------------------------
84 *------------------------------------------------------------------------*/
85 if ( 0x96 <= exp ) {
86 if ( (exp == 0xFF) && fracF32UI( uiA ) ) {
87 uiZ = softfloat_propagateNaNF32UI( uiA, 0 );
88 goto uiZ;
89 }
90 return a;
91 }
92 /*------------------------------------------------------------------------
93 *------------------------------------------------------------------------*/
94 uiZ = uiA;
95 lastBitMask = (uint_fast32_t) 1<<(0x96 - exp);
96 roundBitsMask = lastBitMask - 1;
97 if ( roundingMode == softfloat_round_near_maxMag ) {
98 uiZ += lastBitMask>>1;
99 } else if ( roundingMode == softfloat_round_near_even ) {
100 uiZ += lastBitMask>>1;
101 if ( !(uiZ & roundBitsMask) ) uiZ &= ~lastBitMask;
102 } else if (
103 roundingMode
104 == (signF32UI( uiZ ) ? softfloat_round_min : softfloat_round_max)
105 ) {
106 uiZ += roundBitsMask;
107 }
108 uiZ &= ~roundBitsMask;
109 if ( uiZ != uiA ) {
110#ifdef SOFTFLOAT_ROUND_ODD
111 if ( roundingMode == softfloat_round_odd ) uiZ |= lastBitMask;
112#endif
113 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
114 }
115 uiZ:
116 uZ.ui = uiZ;
117 return uZ.f;
118
119}
120
deps/SoftFloat-3e/source/f32_sqrt.c created+121
......@@ -0,0 +1,121 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t f32_sqrt( float32_t a )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast32_t sigA, uiZ;
51 struct exp16_sig32 normExpSig;
52 int_fast16_t expZ;
53 uint_fast32_t sigZ, shiftedSigZ;
54 uint32_t negRem;
55 union ui32_f32 uZ;
56
57 /*------------------------------------------------------------------------
58 *------------------------------------------------------------------------*/
59 uA.f = a;
60 uiA = uA.ui;
61 signA = signF32UI( uiA );
62 expA = expF32UI( uiA );
63 sigA = fracF32UI( uiA );
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 if ( expA == 0xFF ) {
67 if ( sigA ) {
68 uiZ = softfloat_propagateNaNF32UI( uiA, 0 );
69 goto uiZ;
70 }
71 if ( ! signA ) return a;
72 goto invalid;
73 }
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( signA ) {
77 if ( ! (expA | sigA) ) return a;
78 goto invalid;
79 }
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 if ( ! expA ) {
83 if ( ! sigA ) return a;
84 normExpSig = softfloat_normSubnormalF32Sig( sigA );
85 expA = normExpSig.exp;
86 sigA = normExpSig.sig;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 expZ = ((expA - 0x7F)>>1) + 0x7E;
91 expA &= 1;
92 sigA = (sigA | 0x00800000)<<8;
93 sigZ =
94 ((uint_fast64_t) sigA * softfloat_approxRecipSqrt32_1( expA, sigA ))
95 >>32;
96 if ( expA ) sigZ >>= 1;
97 /*------------------------------------------------------------------------
98 *------------------------------------------------------------------------*/
99 sigZ += 2;
100 if ( (sigZ & 0x3F) < 2 ) {
101 shiftedSigZ = sigZ>>2;
102 negRem = shiftedSigZ * shiftedSigZ;
103 sigZ &= ~3;
104 if ( negRem & 0x80000000 ) {
105 sigZ |= 1;
106 } else {
107 if ( negRem ) --sigZ;
108 }
109 }
110 return softfloat_roundPackToF32( 0, expZ, sigZ );
111 /*------------------------------------------------------------------------
112 *------------------------------------------------------------------------*/
113 invalid:
114 softfloat_raiseFlags( softfloat_flag_invalid );
115 uiZ = defaultNaNF32UI;
116 uiZ:
117 uZ.ui = uiZ;
118 return uZ.f;
119
120}
121
deps/SoftFloat-3e/source/f32_sub.c created+70
......@@ -0,0 +1,70 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float32_t f32_sub( float32_t a, float32_t b )
44{
45 union ui32_f32 uA;
46 uint_fast32_t uiA;
47 union ui32_f32 uB;
48 uint_fast32_t uiB;
49#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
50 float32_t (*magsFuncPtr)( uint_fast32_t, uint_fast32_t );
51#endif
52
53 uA.f = a;
54 uiA = uA.ui;
55 uB.f = b;
56 uiB = uB.ui;
57#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
58 if ( signF32UI( uiA ^ uiB ) ) {
59 return softfloat_addMagsF32( uiA, uiB );
60 } else {
61 return softfloat_subMagsF32( uiA, uiB );
62 }
63#else
64 magsFuncPtr =
65 signF32UI( uiA ^ uiB ) ? softfloat_addMagsF32 : softfloat_subMagsF32;
66 return (*magsFuncPtr)( uiA, uiB );
67#endif
68
69}
70
deps/SoftFloat-3e/source/f32_to_extF80.c created+101
......@@ -0,0 +1,101 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t f32_to_extF80( float32_t a )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t frac;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 uint_fast16_t uiZ64;
54 uint_fast64_t uiZ0;
55 struct exp16_sig32 normExpSig;
56 union { struct extFloat80M s; extFloat80_t f; } uZ;
57
58 /*------------------------------------------------------------------------
59 *------------------------------------------------------------------------*/
60 uA.f = a;
61 uiA = uA.ui;
62 sign = signF32UI( uiA );
63 exp = expF32UI( uiA );
64 frac = fracF32UI( uiA );
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( exp == 0xFF ) {
68 if ( frac ) {
69 softfloat_f32UIToCommonNaN( uiA, &commonNaN );
70 uiZ = softfloat_commonNaNToExtF80UI( &commonNaN );
71 uiZ64 = uiZ.v64;
72 uiZ0 = uiZ.v0;
73 } else {
74 uiZ64 = packToExtF80UI64( sign, 0x7FFF );
75 uiZ0 = UINT64_C( 0x8000000000000000 );
76 }
77 goto uiZ;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 if ( ! exp ) {
82 if ( ! frac ) {
83 uiZ64 = packToExtF80UI64( sign, 0 );
84 uiZ0 = 0;
85 goto uiZ;
86 }
87 normExpSig = softfloat_normSubnormalF32Sig( frac );
88 exp = normExpSig.exp;
89 frac = normExpSig.sig;
90 }
91 /*------------------------------------------------------------------------
92 *------------------------------------------------------------------------*/
93 uiZ64 = packToExtF80UI64( sign, exp + 0x3F80 );
94 uiZ0 = (uint_fast64_t) (frac | 0x00800000)<<40;
95 uiZ:
96 uZ.s.signExp = uiZ64;
97 uZ.s.signif = uiZ0;
98 return uZ.f;
99
100}
101
deps/SoftFloat-3e/source/f32_to_extF80M.c created+111
......@@ -0,0 +1,111 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void f32_to_extF80M( float32_t a, extFloat80_t *zPtr )
47{
48
49 *zPtr = f32_to_extF80( a );
50
51}
52
53#else
54
55void f32_to_extF80M( float32_t a, extFloat80_t *zPtr )
56{
57 struct extFloat80M *zSPtr;
58 union ui32_f32 uA;
59 uint32_t uiA;
60 bool sign;
61 int_fast16_t exp;
62 uint32_t frac;
63 struct commonNaN commonNaN;
64 uint_fast16_t uiZ64;
65 uint32_t uiZ32;
66 struct exp16_sig32 normExpSig;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 zSPtr = (struct extFloat80M *) zPtr;
71 uA.f = a;
72 uiA = uA.ui;
73 sign = signF32UI( uiA );
74 exp = expF32UI( uiA );
75 frac = fracF32UI( uiA );
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( exp == 0xFF ) {
79 if ( frac ) {
80 softfloat_f32UIToCommonNaN( uiA, &commonNaN );
81 softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
82 return;
83 }
84 uiZ64 = packToExtF80UI64( sign, 0x7FFF );
85 uiZ32 = 0x80000000;
86 goto uiZ;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( ! exp ) {
91 if ( ! frac ) {
92 uiZ64 = packToExtF80UI64( sign, 0 );
93 uiZ32 = 0;
94 goto uiZ;
95 }
96 normExpSig = softfloat_normSubnormalF32Sig( frac );
97 exp = normExpSig.exp;
98 frac = normExpSig.sig;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 uiZ64 = packToExtF80UI64( sign, exp + 0x3F80 );
103 uiZ32 = 0x80000000 | (uint32_t) frac<<8;
104 uiZ:
105 zSPtr->signExp = uiZ64;
106 zSPtr->signif = (uint64_t) uiZ32<<32;
107
108}
109
110#endif
111
deps/SoftFloat-3e/source/f32_to_f128.c created+96
......@@ -0,0 +1,96 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t f32_to_f128( float32_t a )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t frac;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 struct exp16_sig32 normExpSig;
54 union ui128_f128 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA = uA.ui;
60 sign = signF32UI( uiA );
61 exp = expF32UI( uiA );
62 frac = fracF32UI( uiA );
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0xFF ) {
66 if ( frac ) {
67 softfloat_f32UIToCommonNaN( uiA, &commonNaN );
68 uiZ = softfloat_commonNaNToF128UI( &commonNaN );
69 } else {
70 uiZ.v64 = packToF128UI64( sign, 0x7FFF, 0 );
71 uiZ.v0 = 0;
72 }
73 goto uiZ;
74 }
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( ! exp ) {
78 if ( ! frac ) {
79 uiZ.v64 = packToF128UI64( sign, 0, 0 );
80 uiZ.v0 = 0;
81 goto uiZ;
82 }
83 normExpSig = softfloat_normSubnormalF32Sig( frac );
84 exp = normExpSig.exp - 1;
85 frac = normExpSig.sig;
86 }
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 uiZ.v64 = packToF128UI64( sign, exp + 0x3F80, (uint_fast64_t) frac<<25 );
90 uiZ.v0 = 0;
91 uiZ:
92 uZ.ui = uiZ;
93 return uZ.f;
94
95}
96
deps/SoftFloat-3e/source/f32_to_f128M.c created+115
......@@ -0,0 +1,115 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void f32_to_f128M( float32_t a, float128_t *zPtr )
47{
48
49 *zPtr = f32_to_f128( a );
50
51}
52
53#else
54
55void f32_to_f128M( float32_t a, float128_t *zPtr )
56{
57 uint32_t *zWPtr;
58 union ui32_f32 uA;
59 uint32_t uiA;
60 bool sign;
61 int_fast16_t exp;
62 uint32_t frac, uiZ64;
63 struct commonNaN commonNaN;
64 uint32_t uiZ96;
65 struct exp16_sig32 normExpSig;
66 uint64_t frac64;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 zWPtr = (uint32_t *) zPtr;
71 /*------------------------------------------------------------------------
72 *------------------------------------------------------------------------*/
73 uA.f = a;
74 uiA = uA.ui;
75 sign = signF32UI( uiA );
76 exp = expF32UI( uiA );
77 frac = fracF32UI( uiA );
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 uiZ64 = 0;
81 if ( exp == 0xFF ) {
82 if ( frac ) {
83 softfloat_f32UIToCommonNaN( uiA, &commonNaN );
84 softfloat_commonNaNToF128M( &commonNaN, zWPtr );
85 return;
86 }
87 uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
88 goto uiZ;
89 }
90 /*------------------------------------------------------------------------
91 *------------------------------------------------------------------------*/
92 if ( ! exp ) {
93 if ( ! frac ) {
94 uiZ96 = packToF128UI96( sign, 0, 0 );
95 goto uiZ;
96 }
97 normExpSig = softfloat_normSubnormalF32Sig( frac );
98 exp = normExpSig.exp - 1;
99 frac = normExpSig.sig;
100 }
101 /*------------------------------------------------------------------------
102 *------------------------------------------------------------------------*/
103 frac64 = (uint64_t) frac<<25;
104 uiZ96 = packToF128UI96( sign, exp + 0x3F80, frac64>>32 );
105 uiZ64 = frac64;
106 uiZ:
107 zWPtr[indexWord( 4, 3 )] = uiZ96;
108 zWPtr[indexWord( 4, 2 )] = uiZ64;
109 zWPtr[indexWord( 4, 1 )] = 0;
110 zWPtr[indexWord( 4, 0 )] = 0;
111
112}
113
114#endif
115
deps/SoftFloat-3e/source/f32_to_f16.c created+88
......@@ -0,0 +1,88 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t f32_to_f16( float32_t a )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t frac;
51 struct commonNaN commonNaN;
52 uint_fast16_t uiZ, frac16;
53 union ui16_f16 uZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA = uA.ui;
59 sign = signF32UI( uiA );
60 exp = expF32UI( uiA );
61 frac = fracF32UI( uiA );
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 if ( exp == 0xFF ) {
65 if ( frac ) {
66 softfloat_f32UIToCommonNaN( uiA, &commonNaN );
67 uiZ = softfloat_commonNaNToF16UI( &commonNaN );
68 } else {
69 uiZ = packToF16UI( sign, 0x1F, 0 );
70 }
71 goto uiZ;
72 }
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 frac16 = frac>>9 | ((frac & 0x1FF) != 0);
76 if ( ! (exp | frac16) ) {
77 uiZ = packToF16UI( sign, 0, 0 );
78 goto uiZ;
79 }
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 return softfloat_roundPackToF16( sign, exp - 0x71, frac16 | 0x4000 );
83 uiZ:
84 uZ.ui = uiZ;
85 return uZ.f;
86
87}
88
deps/SoftFloat-3e/source/f32_to_f64.c created+93
......@@ -0,0 +1,93 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t f32_to_f64( float32_t a )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t frac;
51 struct commonNaN commonNaN;
52 uint_fast64_t uiZ;
53 struct exp16_sig32 normExpSig;
54 union ui64_f64 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 uA.f = a;
59 uiA = uA.ui;
60 sign = signF32UI( uiA );
61 exp = expF32UI( uiA );
62 frac = fracF32UI( uiA );
63 /*------------------------------------------------------------------------
64 *------------------------------------------------------------------------*/
65 if ( exp == 0xFF ) {
66 if ( frac ) {
67 softfloat_f32UIToCommonNaN( uiA, &commonNaN );
68 uiZ = softfloat_commonNaNToF64UI( &commonNaN );
69 } else {
70 uiZ = packToF64UI( sign, 0x7FF, 0 );
71 }
72 goto uiZ;
73 }
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( ! exp ) {
77 if ( ! frac ) {
78 uiZ = packToF64UI( sign, 0, 0 );
79 goto uiZ;
80 }
81 normExpSig = softfloat_normSubnormalF32Sig( frac );
82 exp = normExpSig.exp - 1;
83 frac = normExpSig.sig;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 uiZ = packToF64UI( sign, exp + 0x380, (uint_fast64_t) frac<<29 );
88 uiZ:
89 uZ.ui = uiZ;
90 return uZ.f;
91
92}
93
deps/SoftFloat-3e/source/f32_to_i32.c created+84
......@@ -0,0 +1,84 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t f32_to_i32( float32_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t sig;
51 uint_fast64_t sig64;
52 int_fast16_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF32UI( uiA );
59 exp = expF32UI( uiA );
60 sig = fracF32UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
64 if ( (exp == 0xFF) && sig ) {
65#if (i32_fromNaN == i32_fromPosOverflow)
66 sign = 0;
67#elif (i32_fromNaN == i32_fromNegOverflow)
68 sign = 1;
69#else
70 softfloat_raiseFlags( softfloat_flag_invalid );
71 return i32_fromNaN;
72#endif
73 }
74#endif
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp ) sig |= 0x00800000;
78 sig64 = (uint_fast64_t) sig<<32;
79 shiftDist = 0xAA - exp;
80 if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
81 return softfloat_roundToI32( sign, sig64, roundingMode, exact );
82
83}
84
deps/SoftFloat-3e/source/f32_to_i32_r_minMag.c created+89
......@@ -0,0 +1,89 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t f32_to_i32_r_minMag( float32_t a, bool exact )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 int_fast16_t exp;
49 uint_fast32_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
52 int_fast32_t absZ;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF32UI( uiA );
59 sig = fracF32UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x9E - exp;
63 if ( 32 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF32UI( uiA );
72 if ( shiftDist <= 0 ) {
73 if ( uiA == packToF32UI( 1, 0x9E, 0 ) ) return -0x7FFFFFFF - 1;
74 softfloat_raiseFlags( softfloat_flag_invalid );
75 return
76 (exp == 0xFF) && sig ? i32_fromNaN
77 : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 sig = (sig | 0x00800000)<<8;
82 absZ = sig>>shiftDist;
83 if ( exact && ((uint_fast32_t) absZ<<shiftDist != sig) ) {
84 softfloat_exceptionFlags |= softfloat_flag_inexact;
85 }
86 return sign ? -absZ : absZ;
87
88}
89
deps/SoftFloat-3e/source/f32_to_i64.c created+96
......@@ -0,0 +1,96 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t f32_to_i64( float32_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t sig;
51 int_fast16_t shiftDist;
52#ifdef SOFTFLOAT_FAST_INT64
53 uint_fast64_t sig64, extra;
54 struct uint64_extra sig64Extra;
55#else
56 uint32_t extSig[3];
57#endif
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 uA.f = a;
62 uiA = uA.ui;
63 sign = signF32UI( uiA );
64 exp = expF32UI( uiA );
65 sig = fracF32UI( uiA );
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 shiftDist = 0xBE - exp;
69 if ( shiftDist < 0 ) {
70 softfloat_raiseFlags( softfloat_flag_invalid );
71 return
72 (exp == 0xFF) && sig ? i64_fromNaN
73 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
74 }
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp ) sig |= 0x00800000;
78#ifdef SOFTFLOAT_FAST_INT64
79 sig64 = (uint_fast64_t) sig<<40;
80 extra = 0;
81 if ( shiftDist ) {
82 sig64Extra = softfloat_shiftRightJam64Extra( sig64, 0, shiftDist );
83 sig64 = sig64Extra.v;
84 extra = sig64Extra.extra;
85 }
86 return softfloat_roundToI64( sign, sig64, extra, roundingMode, exact );
87#else
88 extSig[indexWord( 3, 2 )] = sig<<8;
89 extSig[indexWord( 3, 1 )] = 0;
90 extSig[indexWord( 3, 0 )] = 0;
91 if ( shiftDist ) softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
92 return softfloat_roundMToI64( sign, extSig, roundingMode, exact );
93#endif
94
95}
96
deps/SoftFloat-3e/source/f32_to_i64_r_minMag.c created+94
......@@ -0,0 +1,94 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t f32_to_i64_r_minMag( float32_t a, bool exact )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 int_fast16_t exp;
49 uint_fast32_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
52 uint_fast64_t sig64;
53 int_fast64_t absZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA = uA.ui;
59 exp = expF32UI( uiA );
60 sig = fracF32UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 shiftDist = 0xBE - exp;
64 if ( 64 <= shiftDist ) {
65 if ( exact && (exp | sig) ) {
66 softfloat_exceptionFlags |= softfloat_flag_inexact;
67 }
68 return 0;
69 }
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 sign = signF32UI( uiA );
73 if ( shiftDist <= 0 ) {
74 if ( uiA == packToF32UI( 1, 0xBE, 0 ) ) {
75 return -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
76 }
77 softfloat_raiseFlags( softfloat_flag_invalid );
78 return
79 (exp == 0xFF) && sig ? i64_fromNaN
80 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 sig |= 0x00800000;
85 sig64 = (uint_fast64_t) sig<<40;
86 absZ = sig64>>shiftDist;
87 shiftDist = 40 - shiftDist;
88 if ( exact && (shiftDist < 0) && (uint32_t) (sig<<(shiftDist & 31)) ) {
89 softfloat_exceptionFlags |= softfloat_flag_inexact;
90 }
91 return sign ? -absZ : absZ;
92
93}
94
deps/SoftFloat-3e/source/f32_to_ui32.c created+84
......@@ -0,0 +1,84 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t f32_to_ui32( float32_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t sig;
51 uint_fast64_t sig64;
52 int_fast16_t shiftDist;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF32UI( uiA );
59 exp = expF32UI( uiA );
60 sig = fracF32UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63#if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
64 if ( (exp == 0xFF) && sig ) {
65#if (ui32_fromNaN == ui32_fromPosOverflow)
66 sign = 0;
67#elif (ui32_fromNaN == ui32_fromNegOverflow)
68 sign = 1;
69#else
70 softfloat_raiseFlags( softfloat_flag_invalid );
71 return ui32_fromNaN;
72#endif
73 }
74#endif
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp ) sig |= 0x00800000;
78 sig64 = (uint_fast64_t) sig<<32;
79 shiftDist = 0xAA - exp;
80 if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
81 return softfloat_roundToUI32( sign, sig64, roundingMode, exact );
82
83}
84
deps/SoftFloat-3e/source/f32_to_ui32_r_minMag.c created+88
......@@ -0,0 +1,88 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t f32_to_ui32_r_minMag( float32_t a, bool exact )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 int_fast16_t exp;
49 uint_fast32_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
52 uint_fast32_t z;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF32UI( uiA );
59 sig = fracF32UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x9E - exp;
63 if ( 32 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF32UI( uiA );
72 if ( sign || (shiftDist < 0) ) {
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 return
75 (exp == 0xFF) && sig ? ui32_fromNaN
76 : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 sig = (sig | 0x00800000)<<8;
81 z = sig>>shiftDist;
82 if ( exact && (z<<shiftDist != sig) ) {
83 softfloat_exceptionFlags |= softfloat_flag_inexact;
84 }
85 return z;
86
87}
88
deps/SoftFloat-3e/source/f32_to_ui64.c created+96
......@@ -0,0 +1,96 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t f32_to_ui64( float32_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast32_t sig;
51 int_fast16_t shiftDist;
52#ifdef SOFTFLOAT_FAST_INT64
53 uint_fast64_t sig64, extra;
54 struct uint64_extra sig64Extra;
55#else
56 uint32_t extSig[3];
57#endif
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 uA.f = a;
62 uiA = uA.ui;
63 sign = signF32UI( uiA );
64 exp = expF32UI( uiA );
65 sig = fracF32UI( uiA );
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 shiftDist = 0xBE - exp;
69 if ( shiftDist < 0 ) {
70 softfloat_raiseFlags( softfloat_flag_invalid );
71 return
72 (exp == 0xFF) && sig ? ui64_fromNaN
73 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
74 }
75 /*------------------------------------------------------------------------
76 *------------------------------------------------------------------------*/
77 if ( exp ) sig |= 0x00800000;
78#ifdef SOFTFLOAT_FAST_INT64
79 sig64 = (uint_fast64_t) sig<<40;
80 extra = 0;
81 if ( shiftDist ) {
82 sig64Extra = softfloat_shiftRightJam64Extra( sig64, 0, shiftDist );
83 sig64 = sig64Extra.v;
84 extra = sig64Extra.extra;
85 }
86 return softfloat_roundToUI64( sign, sig64, extra, roundingMode, exact );
87#else
88 extSig[indexWord( 3, 2 )] = sig<<8;
89 extSig[indexWord( 3, 1 )] = 0;
90 extSig[indexWord( 3, 0 )] = 0;
91 if ( shiftDist ) softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
92 return softfloat_roundMToUI64( sign, extSig, roundingMode, exact );
93#endif
94
95}
96
deps/SoftFloat-3e/source/f32_to_ui64_r_minMag.c created+90
......@@ -0,0 +1,90 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t f32_to_ui64_r_minMag( float32_t a, bool exact )
45{
46 union ui32_f32 uA;
47 uint_fast32_t uiA;
48 int_fast16_t exp;
49 uint_fast32_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
52 uint_fast64_t sig64, z;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF32UI( uiA );
59 sig = fracF32UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0xBE - exp;
63 if ( 64 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF32UI( uiA );
72 if ( sign || (shiftDist < 0) ) {
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 return
75 (exp == 0xFF) && sig ? ui64_fromNaN
76 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 sig |= 0x00800000;
81 sig64 = (uint_fast64_t) sig<<40;
82 z = sig64>>shiftDist;
83 shiftDist = 40 - shiftDist;
84 if ( exact && (shiftDist < 0) && (uint32_t) (sig<<(shiftDist & 31)) ) {
85 softfloat_exceptionFlags |= softfloat_flag_inexact;
86 }
87 return z;
88
89}
90
deps/SoftFloat-3e/source/f64_add.c created+74
......@@ -0,0 +1,74 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float64_t f64_add( float64_t a, float64_t b )
44{
45 union ui64_f64 uA;
46 uint_fast64_t uiA;
47 bool signA;
48 union ui64_f64 uB;
49 uint_fast64_t uiB;
50 bool signB;
51#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
52 float64_t (*magsFuncPtr)( uint_fast64_t, uint_fast64_t, bool );
53#endif
54
55 uA.f = a;
56 uiA = uA.ui;
57 signA = signF64UI( uiA );
58 uB.f = b;
59 uiB = uB.ui;
60 signB = signF64UI( uiB );
61#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
62 if ( signA == signB ) {
63 return softfloat_addMagsF64( uiA, uiB, signA );
64 } else {
65 return softfloat_subMagsF64( uiA, uiB, signA );
66 }
67#else
68 magsFuncPtr =
69 (signA == signB) ? softfloat_addMagsF64 : softfloat_subMagsF64;
70 return (*magsFuncPtr)( uiA, uiB, signA );
71#endif
72
73}
74
deps/SoftFloat-3e/source/f64_div.c created+172
......@@ -0,0 +1,172 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t f64_div( float64_t a, float64_t b )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast64_t sigA;
51 union ui64_f64 uB;
52 uint_fast64_t uiB;
53 bool signB;
54 int_fast16_t expB;
55 uint_fast64_t sigB;
56 bool signZ;
57 struct exp16_sig64 normExpSig;
58 int_fast16_t expZ;
59 uint32_t recip32, sig32Z, doubleTerm;
60 uint_fast64_t rem;
61 uint32_t q;
62 uint_fast64_t sigZ;
63 uint_fast64_t uiZ;
64 union ui64_f64 uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 uA.f = a;
69 uiA = uA.ui;
70 signA = signF64UI( uiA );
71 expA = expF64UI( uiA );
72 sigA = fracF64UI( uiA );
73 uB.f = b;
74 uiB = uB.ui;
75 signB = signF64UI( uiB );
76 expB = expF64UI( uiB );
77 sigB = fracF64UI( uiB );
78 signZ = signA ^ signB;
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 if ( expA == 0x7FF ) {
82 if ( sigA ) goto propagateNaN;
83 if ( expB == 0x7FF ) {
84 if ( sigB ) goto propagateNaN;
85 goto invalid;
86 }
87 goto infinity;
88 }
89 if ( expB == 0x7FF ) {
90 if ( sigB ) goto propagateNaN;
91 goto zero;
92 }
93 /*------------------------------------------------------------------------
94 *------------------------------------------------------------------------*/
95 if ( ! expB ) {
96 if ( ! sigB ) {
97 if ( ! (expA | sigA) ) goto invalid;
98 softfloat_raiseFlags( softfloat_flag_infinite );
99 goto infinity;
100 }
101 normExpSig = softfloat_normSubnormalF64Sig( sigB );
102 expB = normExpSig.exp;
103 sigB = normExpSig.sig;
104 }
105 if ( ! expA ) {
106 if ( ! sigA ) goto zero;
107 normExpSig = softfloat_normSubnormalF64Sig( sigA );
108 expA = normExpSig.exp;
109 sigA = normExpSig.sig;
110 }
111 /*------------------------------------------------------------------------
112 *------------------------------------------------------------------------*/
113 expZ = expA - expB + 0x3FE;
114 sigA |= UINT64_C( 0x0010000000000000 );
115 sigB |= UINT64_C( 0x0010000000000000 );
116 if ( sigA < sigB ) {
117 --expZ;
118 sigA <<= 11;
119 } else {
120 sigA <<= 10;
121 }
122 sigB <<= 11;
123 recip32 = softfloat_approxRecip32_1( sigB>>32 ) - 2;
124 sig32Z = ((uint32_t) (sigA>>32) * (uint_fast64_t) recip32)>>32;
125 doubleTerm = sig32Z<<1;
126 rem =
127 ((sigA - (uint_fast64_t) doubleTerm * (uint32_t) (sigB>>32))<<28)
128 - (uint_fast64_t) doubleTerm * ((uint32_t) sigB>>4);
129 q = (((uint32_t) (rem>>32) * (uint_fast64_t) recip32)>>32) + 4;
130 sigZ = ((uint_fast64_t) sig32Z<<32) + ((uint_fast64_t) q<<4);
131 /*------------------------------------------------------------------------
132 *------------------------------------------------------------------------*/
133 if ( (sigZ & 0x1FF) < 4<<4 ) {
134 q &= ~7;
135 sigZ &= ~(uint_fast64_t) 0x7F;
136 doubleTerm = q<<1;
137 rem =
138 ((rem - (uint_fast64_t) doubleTerm * (uint32_t) (sigB>>32))<<28)
139 - (uint_fast64_t) doubleTerm * ((uint32_t) sigB>>4);
140 if ( rem & UINT64_C( 0x8000000000000000 ) ) {
141 sigZ -= 1<<7;
142 } else {
143 if ( rem ) sigZ |= 1;
144 }
145 }
146 return softfloat_roundPackToF64( signZ, expZ, sigZ );
147 /*------------------------------------------------------------------------
148 *------------------------------------------------------------------------*/
149 propagateNaN:
150 uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
151 goto uiZ;
152 /*------------------------------------------------------------------------
153 *------------------------------------------------------------------------*/
154 invalid:
155 softfloat_raiseFlags( softfloat_flag_invalid );
156 uiZ = defaultNaNF64UI;
157 goto uiZ;
158 /*------------------------------------------------------------------------
159 *------------------------------------------------------------------------*/
160 infinity:
161 uiZ = packToF64UI( signZ, 0x7FF, 0 );
162 goto uiZ;
163 /*------------------------------------------------------------------------
164 *------------------------------------------------------------------------*/
165 zero:
166 uiZ = packToF64UI( signZ, 0, 0 );
167 uiZ:
168 uZ.ui = uiZ;
169 return uZ.f;
170
171}
172
deps/SoftFloat-3e/source/f64_eq.c created+66
......@@ -0,0 +1,66 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f64_eq( float64_t a, float64_t b )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 union ui64_f64 uB;
49 uint_fast64_t uiB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
56 if (
57 softfloat_isSigNaNF64UI( uiA ) || softfloat_isSigNaNF64UI( uiB )
58 ) {
59 softfloat_raiseFlags( softfloat_flag_invalid );
60 }
61 return false;
62 }
63 return (uiA == uiB) || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ));
64
65}
66
deps/SoftFloat-3e/source/f64_eq_signaling.c created+61
......@@ -0,0 +1,61 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f64_eq_signaling( float64_t a, float64_t b )
44{
45 union ui64_f64 uA;
46 uint_fast64_t uiA;
47 union ui64_f64 uB;
48 uint_fast64_t uiB;
49
50 uA.f = a;
51 uiA = uA.ui;
52 uB.f = b;
53 uiB = uB.ui;
54 if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
55 softfloat_raiseFlags( softfloat_flag_invalid );
56 return false;
57 }
58 return (uiA == uiB) || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ));
59
60}
61
deps/SoftFloat-3e/source/f64_isSignalingNaN.c created+51
......@@ -0,0 +1,51 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43bool f64_isSignalingNaN( float64_t a )
44{
45 union ui64_f64 uA;
46
47 uA.f = a;
48 return softfloat_isSigNaNF64UI( uA.ui );
49
50}
51
deps/SoftFloat-3e/source/f64_le.c created+67
......@@ -0,0 +1,67 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f64_le( float64_t a, float64_t b )
44{
45 union ui64_f64 uA;
46 uint_fast64_t uiA;
47 union ui64_f64 uB;
48 uint_fast64_t uiB;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
56 softfloat_raiseFlags( softfloat_flag_invalid );
57 return false;
58 }
59 signA = signF64UI( uiA );
60 signB = signF64UI( uiB );
61 return
62 (signA != signB)
63 ? signA || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
64 : (uiA == uiB) || (signA ^ (uiA < uiB));
65
66}
67
deps/SoftFloat-3e/source/f64_le_quiet.c created+72
......@@ -0,0 +1,72 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f64_le_quiet( float64_t a, float64_t b )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 union ui64_f64 uB;
49 uint_fast64_t uiB;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA = uA.ui;
54 uB.f = b;
55 uiB = uB.ui;
56 if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
57 if (
58 softfloat_isSigNaNF64UI( uiA ) || softfloat_isSigNaNF64UI( uiB )
59 ) {
60 softfloat_raiseFlags( softfloat_flag_invalid );
61 }
62 return false;
63 }
64 signA = signF64UI( uiA );
65 signB = signF64UI( uiB );
66 return
67 (signA != signB)
68 ? signA || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
69 : (uiA == uiB) || (signA ^ (uiA < uiB));
70
71}
72
deps/SoftFloat-3e/source/f64_lt.c created+67
......@@ -0,0 +1,67 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43bool f64_lt( float64_t a, float64_t b )
44{
45 union ui64_f64 uA;
46 uint_fast64_t uiA;
47 union ui64_f64 uB;
48 uint_fast64_t uiB;
49 bool signA, signB;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
56 softfloat_raiseFlags( softfloat_flag_invalid );
57 return false;
58 }
59 signA = signF64UI( uiA );
60 signB = signF64UI( uiB );
61 return
62 (signA != signB)
63 ? signA && ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
64 : (uiA != uiB) && (signA ^ (uiA < uiB));
65
66}
67
deps/SoftFloat-3e/source/f64_lt_quiet.c created+72
......@@ -0,0 +1,72 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44bool f64_lt_quiet( float64_t a, float64_t b )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 union ui64_f64 uB;
49 uint_fast64_t uiB;
50 bool signA, signB;
51
52 uA.f = a;
53 uiA = uA.ui;
54 uB.f = b;
55 uiB = uB.ui;
56 if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
57 if (
58 softfloat_isSigNaNF64UI( uiA ) || softfloat_isSigNaNF64UI( uiB )
59 ) {
60 softfloat_raiseFlags( softfloat_flag_invalid );
61 }
62 return false;
63 }
64 signA = signF64UI( uiA );
65 signB = signF64UI( uiB );
66 return
67 (signA != signB)
68 ? signA && ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
69 : (uiA != uiB) && (signA ^ (uiA < uiB));
70
71}
72
deps/SoftFloat-3e/source/f64_mul.c created+150
......@@ -0,0 +1,150 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t f64_mul( float64_t a, float64_t b )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast64_t sigA;
51 union ui64_f64 uB;
52 uint_fast64_t uiB;
53 bool signB;
54 int_fast16_t expB;
55 uint_fast64_t sigB;
56 bool signZ;
57 uint_fast64_t magBits;
58 struct exp16_sig64 normExpSig;
59 int_fast16_t expZ;
60#ifdef SOFTFLOAT_FAST_INT64
61 struct uint128 sig128Z;
62#else
63 uint32_t sig128Z[4];
64#endif
65 uint_fast64_t sigZ, uiZ;
66 union ui64_f64 uZ;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 uA.f = a;
71 uiA = uA.ui;
72 signA = signF64UI( uiA );
73 expA = expF64UI( uiA );
74 sigA = fracF64UI( uiA );
75 uB.f = b;
76 uiB = uB.ui;
77 signB = signF64UI( uiB );
78 expB = expF64UI( uiB );
79 sigB = fracF64UI( uiB );
80 signZ = signA ^ signB;
81 /*------------------------------------------------------------------------
82 *------------------------------------------------------------------------*/
83 if ( expA == 0x7FF ) {
84 if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN;
85 magBits = expB | sigB;
86 goto infArg;
87 }
88 if ( expB == 0x7FF ) {
89 if ( sigB ) goto propagateNaN;
90 magBits = expA | sigA;
91 goto infArg;
92 }
93 /*------------------------------------------------------------------------
94 *------------------------------------------------------------------------*/
95 if ( ! expA ) {
96 if ( ! sigA ) goto zero;
97 normExpSig = softfloat_normSubnormalF64Sig( sigA );
98 expA = normExpSig.exp;
99 sigA = normExpSig.sig;
100 }
101 if ( ! expB ) {
102 if ( ! sigB ) goto zero;
103 normExpSig = softfloat_normSubnormalF64Sig( sigB );
104 expB = normExpSig.exp;
105 sigB = normExpSig.sig;
106 }
107 /*------------------------------------------------------------------------
108 *------------------------------------------------------------------------*/
109 expZ = expA + expB - 0x3FF;
110 sigA = (sigA | UINT64_C( 0x0010000000000000 ))<<10;
111 sigB = (sigB | UINT64_C( 0x0010000000000000 ))<<11;
112#ifdef SOFTFLOAT_FAST_INT64
113 sig128Z = softfloat_mul64To128( sigA, sigB );
114 sigZ = sig128Z.v64 | (sig128Z.v0 != 0);
115#else
116 softfloat_mul64To128M( sigA, sigB, sig128Z );
117 sigZ =
118 (uint64_t) sig128Z[indexWord( 4, 3 )]<<32 | sig128Z[indexWord( 4, 2 )];
119 if ( sig128Z[indexWord( 4, 1 )] || sig128Z[indexWord( 4, 0 )] ) sigZ |= 1;
120#endif
121 if ( sigZ < UINT64_C( 0x4000000000000000 ) ) {
122 --expZ;
123 sigZ <<= 1;
124 }
125 return softfloat_roundPackToF64( signZ, expZ, sigZ );
126 /*------------------------------------------------------------------------
127 *------------------------------------------------------------------------*/
128 propagateNaN:
129 uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
130 goto uiZ;
131 /*------------------------------------------------------------------------
132 *------------------------------------------------------------------------*/
133 infArg:
134 if ( ! magBits ) {
135 softfloat_raiseFlags( softfloat_flag_invalid );
136 uiZ = defaultNaNF64UI;
137 } else {
138 uiZ = packToF64UI( signZ, 0x7FF, 0 );
139 }
140 goto uiZ;
141 /*------------------------------------------------------------------------
142 *------------------------------------------------------------------------*/
143 zero:
144 uiZ = packToF64UI( signZ, 0, 0 );
145 uiZ:
146 uZ.ui = uiZ;
147 return uZ.f;
148
149}
150
deps/SoftFloat-3e/source/f64_mulAdd.c created+60
......@@ -0,0 +1,60 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float64_t f64_mulAdd( float64_t a, float64_t b, float64_t c )
43{
44 union ui64_f64 uA;
45 uint_fast64_t uiA;
46 union ui64_f64 uB;
47 uint_fast64_t uiB;
48 union ui64_f64 uC;
49 uint_fast64_t uiC;
50
51 uA.f = a;
52 uiA = uA.ui;
53 uB.f = b;
54 uiB = uB.ui;
55 uC.f = c;
56 uiC = uC.ui;
57 return softfloat_mulAddF64( uiA, uiB, uiC, 0 );
58
59}
60
deps/SoftFloat-3e/source/f64_rem.c created+189
......@@ -0,0 +1,189 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t f64_rem( float64_t a, float64_t b )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast64_t sigA;
51 union ui64_f64 uB;
52 uint_fast64_t uiB;
53 int_fast16_t expB;
54 uint_fast64_t sigB;
55 struct exp16_sig64 normExpSig;
56 uint64_t rem;
57 int_fast16_t expDiff;
58 uint32_t q, recip32;
59 uint_fast64_t q64;
60 uint64_t altRem, meanRem;
61 bool signRem;
62 uint_fast64_t uiZ;
63 union ui64_f64 uZ;
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 uA.f = a;
68 uiA = uA.ui;
69 signA = signF64UI( uiA );
70 expA = expF64UI( uiA );
71 sigA = fracF64UI( uiA );
72 uB.f = b;
73 uiB = uB.ui;
74 expB = expF64UI( uiB );
75 sigB = fracF64UI( uiB );
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( expA == 0x7FF ) {
79 if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN;
80 goto invalid;
81 }
82 if ( expB == 0x7FF ) {
83 if ( sigB ) goto propagateNaN;
84 return a;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 if ( expA < expB - 1 ) return a;
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 if ( ! expB ) {
92 if ( ! sigB ) goto invalid;
93 normExpSig = softfloat_normSubnormalF64Sig( sigB );
94 expB = normExpSig.exp;
95 sigB = normExpSig.sig;
96 }
97 if ( ! expA ) {
98 if ( ! sigA ) return a;
99 normExpSig = softfloat_normSubnormalF64Sig( sigA );
100 expA = normExpSig.exp;
101 sigA = normExpSig.sig;
102 }
103 /*------------------------------------------------------------------------
104 *------------------------------------------------------------------------*/
105 rem = sigA | UINT64_C( 0x0010000000000000 );
106 sigB |= UINT64_C( 0x0010000000000000 );
107 expDiff = expA - expB;
108 if ( expDiff < 1 ) {
109 if ( expDiff < -1 ) return a;
110 sigB <<= 9;
111 if ( expDiff ) {
112 rem <<= 8;
113 q = 0;
114 } else {
115 rem <<= 9;
116 q = (sigB <= rem);
117 if ( q ) rem -= sigB;
118 }
119 } else {
120 recip32 = softfloat_approxRecip32_1( sigB>>21 );
121 /*--------------------------------------------------------------------
122 | Changing the shift of `rem' here requires also changing the initial
123 | subtraction from `expDiff'.
124 *--------------------------------------------------------------------*/
125 rem <<= 9;
126 expDiff -= 30;
127 /*--------------------------------------------------------------------
128 | The scale of `sigB' affects how many bits are obtained during each
129 | cycle of the loop. Currently this is 29 bits per loop iteration,
130 | the maximum possible.
131 *--------------------------------------------------------------------*/
132 sigB <<= 9;
133 for (;;) {
134 q64 = (uint32_t) (rem>>32) * (uint_fast64_t) recip32;
135 if ( expDiff < 0 ) break;
136 q = (q64 + 0x80000000)>>32;
137#ifdef SOFTFLOAT_FAST_INT64
138 rem <<= 29;
139#else
140 rem = (uint_fast64_t) (uint32_t) (rem>>3)<<32;
141#endif
142 rem -= q * (uint64_t) sigB;
143 if ( rem & UINT64_C( 0x8000000000000000 ) ) rem += sigB;
144 expDiff -= 29;
145 }
146 /*--------------------------------------------------------------------
147 | (`expDiff' cannot be less than -29 here.)
148 *--------------------------------------------------------------------*/
149 q = (uint32_t) (q64>>32)>>(~expDiff & 31);
150 rem = (rem<<(expDiff + 30)) - q * (uint64_t) sigB;
151 if ( rem & UINT64_C( 0x8000000000000000 ) ) {
152 altRem = rem + sigB;
153 goto selectRem;
154 }
155 }
156 /*------------------------------------------------------------------------
157 *------------------------------------------------------------------------*/
158 do {
159 altRem = rem;
160 ++q;
161 rem -= sigB;
162 } while ( ! (rem & UINT64_C( 0x8000000000000000 )) );
163 selectRem:
164 meanRem = rem + altRem;
165 if (
166 (meanRem & UINT64_C( 0x8000000000000000 )) || (! meanRem && (q & 1))
167 ) {
168 rem = altRem;
169 }
170 signRem = signA;
171 if ( rem & UINT64_C( 0x8000000000000000 ) ) {
172 signRem = ! signRem;
173 rem = -rem;
174 }
175 return softfloat_normRoundPackToF64( signRem, expB, rem );
176 /*------------------------------------------------------------------------
177 *------------------------------------------------------------------------*/
178 propagateNaN:
179 uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
180 goto uiZ;
181 invalid:
182 softfloat_raiseFlags( softfloat_flag_invalid );
183 uiZ = defaultNaNF64UI;
184 uiZ:
185 uZ.ui = uiZ;
186 return uZ.f;
187
188}
189
deps/SoftFloat-3e/source/f64_roundToInt.c created+120
......@@ -0,0 +1,120 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t f64_roundToInt( float64_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 int_fast16_t exp;
49 uint_fast64_t uiZ, lastBitMask, roundBitsMask;
50 union ui64_f64 uZ;
51
52 /*------------------------------------------------------------------------
53 *------------------------------------------------------------------------*/
54 uA.f = a;
55 uiA = uA.ui;
56 exp = expF64UI( uiA );
57 /*------------------------------------------------------------------------
58 *------------------------------------------------------------------------*/
59 if ( exp <= 0x3FE ) {
60 if ( !(uiA & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) return a;
61 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
62 uiZ = uiA & packToF64UI( 1, 0, 0 );
63 switch ( roundingMode ) {
64 case softfloat_round_near_even:
65 if ( !fracF64UI( uiA ) ) break;
66 case softfloat_round_near_maxMag:
67 if ( exp == 0x3FE ) uiZ |= packToF64UI( 0, 0x3FF, 0 );
68 break;
69 case softfloat_round_min:
70 if ( uiZ ) uiZ = packToF64UI( 1, 0x3FF, 0 );
71 break;
72 case softfloat_round_max:
73 if ( !uiZ ) uiZ = packToF64UI( 0, 0x3FF, 0 );
74 break;
75#ifdef SOFTFLOAT_ROUND_ODD
76 case softfloat_round_odd:
77 uiZ |= packToF64UI( 0, 0x3FF, 0 );
78 break;
79#endif
80 }
81 goto uiZ;
82 }
83 /*------------------------------------------------------------------------
84 *------------------------------------------------------------------------*/
85 if ( 0x433 <= exp ) {
86 if ( (exp == 0x7FF) && fracF64UI( uiA ) ) {
87 uiZ = softfloat_propagateNaNF64UI( uiA, 0 );
88 goto uiZ;
89 }
90 return a;
91 }
92 /*------------------------------------------------------------------------
93 *------------------------------------------------------------------------*/
94 uiZ = uiA;
95 lastBitMask = (uint_fast64_t) 1<<(0x433 - exp);
96 roundBitsMask = lastBitMask - 1;
97 if ( roundingMode == softfloat_round_near_maxMag ) {
98 uiZ += lastBitMask>>1;
99 } else if ( roundingMode == softfloat_round_near_even ) {
100 uiZ += lastBitMask>>1;
101 if ( !(uiZ & roundBitsMask) ) uiZ &= ~lastBitMask;
102 } else if (
103 roundingMode
104 == (signF64UI( uiZ ) ? softfloat_round_min : softfloat_round_max)
105 ) {
106 uiZ += roundBitsMask;
107 }
108 uiZ &= ~roundBitsMask;
109 if ( uiZ != uiA ) {
110#ifdef SOFTFLOAT_ROUND_ODD
111 if ( roundingMode == softfloat_round_odd ) uiZ |= lastBitMask;
112#endif
113 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
114 }
115 uiZ:
116 uZ.ui = uiZ;
117 return uZ.f;
118
119}
120
deps/SoftFloat-3e/source/f64_sqrt.c created+133
......@@ -0,0 +1,133 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t f64_sqrt( float64_t a )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool signA;
49 int_fast16_t expA;
50 uint_fast64_t sigA, uiZ;
51 struct exp16_sig64 normExpSig;
52 int_fast16_t expZ;
53 uint32_t sig32A, recipSqrt32, sig32Z;
54 uint_fast64_t rem;
55 uint32_t q;
56 uint_fast64_t sigZ, shiftedSigZ;
57 union ui64_f64 uZ;
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 uA.f = a;
62 uiA = uA.ui;
63 signA = signF64UI( uiA );
64 expA = expF64UI( uiA );
65 sigA = fracF64UI( uiA );
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 if ( expA == 0x7FF ) {
69 if ( sigA ) {
70 uiZ = softfloat_propagateNaNF64UI( uiA, 0 );
71 goto uiZ;
72 }
73 if ( ! signA ) return a;
74 goto invalid;
75 }
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( signA ) {
79 if ( ! (expA | sigA) ) return a;
80 goto invalid;
81 }
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( ! expA ) {
85 if ( ! sigA ) return a;
86 normExpSig = softfloat_normSubnormalF64Sig( sigA );
87 expA = normExpSig.exp;
88 sigA = normExpSig.sig;
89 }
90 /*------------------------------------------------------------------------
91 | (`sig32Z' is guaranteed to be a lower bound on the square root of
92 | `sig32A', which makes `sig32Z' also a lower bound on the square root of
93 | `sigA'.)
94 *------------------------------------------------------------------------*/
95 expZ = ((expA - 0x3FF)>>1) + 0x3FE;
96 expA &= 1;
97 sigA |= UINT64_C( 0x0010000000000000 );
98 sig32A = sigA>>21;
99 recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
100 sig32Z = ((uint_fast64_t) sig32A * recipSqrt32)>>32;
101 if ( expA ) {
102 sigA <<= 8;
103 sig32Z >>= 1;
104 } else {
105 sigA <<= 9;
106 }
107 rem = sigA - (uint_fast64_t) sig32Z * sig32Z;
108 q = ((uint32_t) (rem>>2) * (uint_fast64_t) recipSqrt32)>>32;
109 sigZ = ((uint_fast64_t) sig32Z<<32 | 1<<5) + ((uint_fast64_t) q<<3);
110 /*------------------------------------------------------------------------
111 *------------------------------------------------------------------------*/
112 if ( (sigZ & 0x1FF) < 0x22 ) {
113 sigZ &= ~(uint_fast64_t) 0x3F;
114 shiftedSigZ = sigZ>>6;
115 rem = (sigA<<52) - shiftedSigZ * shiftedSigZ;
116 if ( rem & UINT64_C( 0x8000000000000000 ) ) {
117 --sigZ;
118 } else {
119 if ( rem ) sigZ |= 1;
120 }
121 }
122 return softfloat_roundPackToF64( 0, expZ, sigZ );
123 /*------------------------------------------------------------------------
124 *------------------------------------------------------------------------*/
125 invalid:
126 softfloat_raiseFlags( softfloat_flag_invalid );
127 uiZ = defaultNaNF64UI;
128 uiZ:
129 uZ.ui = uiZ;
130 return uZ.f;
131
132}
133
deps/SoftFloat-3e/source/f64_sub.c created+74
......@@ -0,0 +1,74 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float64_t f64_sub( float64_t a, float64_t b )
44{
45 union ui64_f64 uA;
46 uint_fast64_t uiA;
47 bool signA;
48 union ui64_f64 uB;
49 uint_fast64_t uiB;
50 bool signB;
51#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
52 float64_t (*magsFuncPtr)( uint_fast64_t, uint_fast64_t, bool );
53#endif
54
55 uA.f = a;
56 uiA = uA.ui;
57 signA = signF64UI( uiA );
58 uB.f = b;
59 uiB = uB.ui;
60 signB = signF64UI( uiB );
61#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
62 if ( signA == signB ) {
63 return softfloat_subMagsF64( uiA, uiB, signA );
64 } else {
65 return softfloat_addMagsF64( uiA, uiB, signA );
66 }
67#else
68 magsFuncPtr =
69 (signA == signB) ? softfloat_subMagsF64 : softfloat_addMagsF64;
70 return (*magsFuncPtr)( uiA, uiB, signA );
71#endif
72
73}
74
deps/SoftFloat-3e/source/f64_to_extF80.c created+101
......@@ -0,0 +1,101 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t f64_to_extF80( float64_t a )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t frac;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 uint_fast16_t uiZ64;
54 uint_fast64_t uiZ0;
55 struct exp16_sig64 normExpSig;
56 union { struct extFloat80M s; extFloat80_t f; } uZ;
57
58 /*------------------------------------------------------------------------
59 *------------------------------------------------------------------------*/
60 uA.f = a;
61 uiA = uA.ui;
62 sign = signF64UI( uiA );
63 exp = expF64UI( uiA );
64 frac = fracF64UI( uiA );
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( exp == 0x7FF ) {
68 if ( frac ) {
69 softfloat_f64UIToCommonNaN( uiA, &commonNaN );
70 uiZ = softfloat_commonNaNToExtF80UI( &commonNaN );
71 uiZ64 = uiZ.v64;
72 uiZ0 = uiZ.v0;
73 } else {
74 uiZ64 = packToExtF80UI64( sign, 0x7FFF );
75 uiZ0 = UINT64_C( 0x8000000000000000 );
76 }
77 goto uiZ;
78 }
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 if ( ! exp ) {
82 if ( ! frac ) {
83 uiZ64 = packToExtF80UI64( sign, 0 );
84 uiZ0 = 0;
85 goto uiZ;
86 }
87 normExpSig = softfloat_normSubnormalF64Sig( frac );
88 exp = normExpSig.exp;
89 frac = normExpSig.sig;
90 }
91 /*------------------------------------------------------------------------
92 *------------------------------------------------------------------------*/
93 uiZ64 = packToExtF80UI64( sign, exp + 0x3C00 );
94 uiZ0 = (frac | UINT64_C( 0x0010000000000000 ))<<11;
95 uiZ:
96 uZ.s.signExp = uiZ64;
97 uZ.s.signif = uiZ0;
98 return uZ.f;
99
100}
101
deps/SoftFloat-3e/source/f64_to_extF80M.c created+111
......@@ -0,0 +1,111 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void f64_to_extF80M( float64_t a, extFloat80_t *zPtr )
47{
48
49 *zPtr = f64_to_extF80( a );
50
51}
52
53#else
54
55void f64_to_extF80M( float64_t a, extFloat80_t *zPtr )
56{
57 struct extFloat80M *zSPtr;
58 union ui64_f64 uA;
59 uint64_t uiA;
60 bool sign;
61 int_fast16_t exp;
62 uint64_t frac;
63 struct commonNaN commonNaN;
64 uint_fast16_t uiZ64;
65 uint64_t uiZ0;
66 struct exp16_sig64 normExpSig;
67
68 /*------------------------------------------------------------------------
69 *------------------------------------------------------------------------*/
70 zSPtr = (struct extFloat80M *) zPtr;
71 uA.f = a;
72 uiA = uA.ui;
73 sign = signF64UI( uiA );
74 exp = expF64UI( uiA );
75 frac = fracF64UI( uiA );
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( exp == 0x7FF ) {
79 if ( frac ) {
80 softfloat_f64UIToCommonNaN( uiA, &commonNaN );
81 softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
82 return;
83 }
84 uiZ64 = packToExtF80UI64( sign, 0x7FFF );
85 uiZ0 = UINT64_C( 0x8000000000000000 );
86 goto uiZ;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( ! exp ) {
91 if ( ! frac ) {
92 uiZ64 = packToExtF80UI64( sign, 0 );
93 uiZ0 = 0;
94 goto uiZ;
95 }
96 normExpSig = softfloat_normSubnormalF64Sig( frac );
97 exp = normExpSig.exp;
98 frac = normExpSig.sig;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 uiZ64 = packToExtF80UI64( sign, exp + 0x3C00 );
103 uiZ0 = UINT64_C( 0x8000000000000000 ) | frac<<11;
104 uiZ:
105 zSPtr->signExp = uiZ64;
106 zSPtr->signif = uiZ0;
107
108}
109
110#endif
111
deps/SoftFloat-3e/source/f64_to_f128.c created+98
......@@ -0,0 +1,98 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t f64_to_f128( float64_t a )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t frac;
51 struct commonNaN commonNaN;
52 struct uint128 uiZ;
53 struct exp16_sig64 normExpSig;
54 struct uint128 frac128;
55 union ui128_f128 uZ;
56
57 /*------------------------------------------------------------------------
58 *------------------------------------------------------------------------*/
59 uA.f = a;
60 uiA = uA.ui;
61 sign = signF64UI( uiA );
62 exp = expF64UI( uiA );
63 frac = fracF64UI( uiA );
64 /*------------------------------------------------------------------------
65 *------------------------------------------------------------------------*/
66 if ( exp == 0x7FF ) {
67 if ( frac ) {
68 softfloat_f64UIToCommonNaN( uiA, &commonNaN );
69 uiZ = softfloat_commonNaNToF128UI( &commonNaN );
70 } else {
71 uiZ.v64 = packToF128UI64( sign, 0x7FFF, 0 );
72 uiZ.v0 = 0;
73 }
74 goto uiZ;
75 }
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( ! exp ) {
79 if ( ! frac ) {
80 uiZ.v64 = packToF128UI64( sign, 0, 0 );
81 uiZ.v0 = 0;
82 goto uiZ;
83 }
84 normExpSig = softfloat_normSubnormalF64Sig( frac );
85 exp = normExpSig.exp - 1;
86 frac = normExpSig.sig;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 frac128 = softfloat_shortShiftLeft128( 0, frac, 60 );
91 uiZ.v64 = packToF128UI64( sign, exp + 0x3C00, frac128.v64 );
92 uiZ.v0 = frac128.v0;
93 uiZ:
94 uZ.ui = uiZ;
95 return uZ.f;
96
97}
98
deps/SoftFloat-3e/source/f64_to_f128M.c created+117
......@@ -0,0 +1,117 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void f64_to_f128M( float64_t a, float128_t *zPtr )
47{
48
49 *zPtr = f64_to_f128( a );
50
51}
52
53#else
54
55void f64_to_f128M( float64_t a, float128_t *zPtr )
56{
57 uint32_t *zWPtr;
58 union ui64_f64 uA;
59 uint64_t uiA;
60 bool sign;
61 int_fast16_t exp;
62 uint64_t frac;
63 struct commonNaN commonNaN;
64 uint32_t uiZ96;
65 struct exp16_sig64 normExpSig;
66
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 zWPtr = (uint32_t *) zPtr;
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 uA.f = a;
73 uiA = uA.ui;
74 sign = signF64UI( uiA );
75 exp = expF64UI( uiA );
76 frac = fracF64UI( uiA );
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 zWPtr[indexWord( 4, 0 )] = 0;
80 if ( exp == 0x7FF ) {
81 if ( frac ) {
82 softfloat_f64UIToCommonNaN( uiA, &commonNaN );
83 softfloat_commonNaNToF128M( &commonNaN, zWPtr );
84 return;
85 }
86 uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
87 goto uiZ;
88 }
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 if ( ! exp ) {
92 if ( ! frac ) {
93 uiZ96 = packToF128UI96( sign, 0, 0 );
94 goto uiZ;
95 }
96 normExpSig = softfloat_normSubnormalF64Sig( frac );
97 exp = normExpSig.exp - 1;
98 frac = normExpSig.sig;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 zWPtr[indexWord( 4, 1 )] = (uint32_t) frac<<28;
103 frac >>= 4;
104 zWPtr[indexWordHi( 4 )] = packToF128UI96( sign, exp + 0x3C00, frac>>32 );
105 zWPtr[indexWord( 4, 2 )] = frac;
106 return;
107 /*------------------------------------------------------------------------
108 *------------------------------------------------------------------------*/
109 uiZ:
110 zWPtr[indexWord( 4, 3 )] = uiZ96;
111 zWPtr[indexWord( 4, 2 )] = 0;
112 zWPtr[indexWord( 4, 1 )] = 0;
113
114}
115
116#endif
117
deps/SoftFloat-3e/source/f64_to_f16.c created+88
......@@ -0,0 +1,88 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t f64_to_f16( float64_t a )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t frac;
51 struct commonNaN commonNaN;
52 uint_fast16_t uiZ, frac16;
53 union ui16_f16 uZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA = uA.ui;
59 sign = signF64UI( uiA );
60 exp = expF64UI( uiA );
61 frac = fracF64UI( uiA );
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 if ( exp == 0x7FF ) {
65 if ( frac ) {
66 softfloat_f64UIToCommonNaN( uiA, &commonNaN );
67 uiZ = softfloat_commonNaNToF16UI( &commonNaN );
68 } else {
69 uiZ = packToF16UI( sign, 0x1F, 0 );
70 }
71 goto uiZ;
72 }
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 frac16 = softfloat_shortShiftRightJam64( frac, 38 );
76 if ( ! (exp | frac16) ) {
77 uiZ = packToF16UI( sign, 0, 0 );
78 goto uiZ;
79 }
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 return softfloat_roundPackToF16( sign, exp - 0x3F1, frac16 | 0x4000 );
83 uiZ:
84 uZ.ui = uiZ;
85 return uZ.f;
86
87}
88
deps/SoftFloat-3e/source/f64_to_f32.c created+88
......@@ -0,0 +1,88 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t f64_to_f32( float64_t a )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t frac;
51 struct commonNaN commonNaN;
52 uint_fast32_t uiZ, frac32;
53 union ui32_f32 uZ;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 uA.f = a;
58 uiA = uA.ui;
59 sign = signF64UI( uiA );
60 exp = expF64UI( uiA );
61 frac = fracF64UI( uiA );
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 if ( exp == 0x7FF ) {
65 if ( frac ) {
66 softfloat_f64UIToCommonNaN( uiA, &commonNaN );
67 uiZ = softfloat_commonNaNToF32UI( &commonNaN );
68 } else {
69 uiZ = packToF32UI( sign, 0xFF, 0 );
70 }
71 goto uiZ;
72 }
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 frac32 = softfloat_shortShiftRightJam64( frac, 22 );
76 if ( ! (exp | frac32) ) {
77 uiZ = packToF32UI( sign, 0, 0 );
78 goto uiZ;
79 }
80 /*------------------------------------------------------------------------
81 *------------------------------------------------------------------------*/
82 return softfloat_roundPackToF32( sign, exp - 0x381, frac32 | 0x40000000 );
83 uiZ:
84 uZ.ui = uiZ;
85 return uZ.f;
86
87}
88
deps/SoftFloat-3e/source/f64_to_i32.c created+82
......@@ -0,0 +1,82 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t f64_to_i32( float64_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t sig;
51 int_fast16_t shiftDist;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 uA.f = a;
56 uiA = uA.ui;
57 sign = signF64UI( uiA );
58 exp = expF64UI( uiA );
59 sig = fracF64UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
63 if ( (exp == 0x7FF) && sig ) {
64#if (i32_fromNaN == i32_fromPosOverflow)
65 sign = 0;
66#elif (i32_fromNaN == i32_fromNegOverflow)
67 sign = 1;
68#else
69 softfloat_raiseFlags( softfloat_flag_invalid );
70 return i32_fromNaN;
71#endif
72 }
73#endif
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
77 shiftDist = 0x427 - exp;
78 if ( 0 < shiftDist ) sig = softfloat_shiftRightJam64( sig, shiftDist );
79 return softfloat_roundToI32( sign, sig, roundingMode, exact );
80
81}
82
deps/SoftFloat-3e/source/f64_to_i32_r_minMag.c created+96
......@@ -0,0 +1,96 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t f64_to_i32_r_minMag( float64_t a, bool exact )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 int_fast16_t exp;
49 uint_fast64_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
52 int_fast32_t absZ;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF64UI( uiA );
59 sig = fracF64UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x433 - exp;
63 if ( 53 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF64UI( uiA );
72 if ( shiftDist < 22 ) {
73 if (
74 sign && (exp == 0x41E) && (sig < UINT64_C( 0x0000000000200000 ))
75 ) {
76 if ( exact && sig ) {
77 softfloat_exceptionFlags |= softfloat_flag_inexact;
78 }
79 return -0x7FFFFFFF - 1;
80 }
81 softfloat_raiseFlags( softfloat_flag_invalid );
82 return
83 (exp == 0x7FF) && sig ? i32_fromNaN
84 : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
85 }
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 sig |= UINT64_C( 0x0010000000000000 );
89 absZ = sig>>shiftDist;
90 if ( exact && ((uint_fast64_t) (uint_fast32_t) absZ<<shiftDist != sig) ) {
91 softfloat_exceptionFlags |= softfloat_flag_inexact;
92 }
93 return sign ? -absZ : absZ;
94
95}
96
deps/SoftFloat-3e/source/f64_to_i64.c created+103
......@@ -0,0 +1,103 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t f64_to_i64( float64_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t sig;
51 int_fast16_t shiftDist;
52#ifdef SOFTFLOAT_FAST_INT64
53 struct uint64_extra sigExtra;
54#else
55 uint32_t extSig[3];
56#endif
57
58 /*------------------------------------------------------------------------
59 *------------------------------------------------------------------------*/
60 uA.f = a;
61 uiA = uA.ui;
62 sign = signF64UI( uiA );
63 exp = expF64UI( uiA );
64 sig = fracF64UI( uiA );
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
68 shiftDist = 0x433 - exp;
69#ifdef SOFTFLOAT_FAST_INT64
70 if ( shiftDist <= 0 ) {
71 if ( shiftDist < -11 ) goto invalid;
72 sigExtra.v = sig<<-shiftDist;
73 sigExtra.extra = 0;
74 } else {
75 sigExtra = softfloat_shiftRightJam64Extra( sig, 0, shiftDist );
76 }
77 return
78 softfloat_roundToI64(
79 sign, sigExtra.v, sigExtra.extra, roundingMode, exact );
80#else
81 extSig[indexWord( 3, 0 )] = 0;
82 if ( shiftDist <= 0 ) {
83 if ( shiftDist < -11 ) goto invalid;
84 sig <<= -shiftDist;
85 extSig[indexWord( 3, 2 )] = sig>>32;
86 extSig[indexWord( 3, 1 )] = sig;
87 } else {
88 extSig[indexWord( 3, 2 )] = sig>>32;
89 extSig[indexWord( 3, 1 )] = sig;
90 softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
91 }
92 return softfloat_roundMToI64( sign, extSig, roundingMode, exact );
93#endif
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 invalid:
97 softfloat_raiseFlags( softfloat_flag_invalid );
98 return
99 (exp == 0x7FF) && fracF64UI( uiA ) ? i64_fromNaN
100 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
101
102}
103
deps/SoftFloat-3e/source/f64_to_i64_r_minMag.c created+100
......@@ -0,0 +1,100 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t f64_to_i64_r_minMag( float64_t a, bool exact )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t sig;
51 int_fast16_t shiftDist;
52 int_fast64_t absZ;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 sign = signF64UI( uiA );
59 exp = expF64UI( uiA );
60 sig = fracF64UI( uiA );
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 shiftDist = 0x433 - exp;
64 if ( shiftDist <= 0 ) {
65 /*--------------------------------------------------------------------
66 *--------------------------------------------------------------------*/
67 if ( shiftDist < -10 ) {
68 if ( uiA == packToF64UI( 1, 0x43E, 0 ) ) {
69 return -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
70 }
71 softfloat_raiseFlags( softfloat_flag_invalid );
72 return
73 (exp == 0x7FF) && sig ? i64_fromNaN
74 : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
75 }
76 /*--------------------------------------------------------------------
77 *--------------------------------------------------------------------*/
78 sig |= UINT64_C( 0x0010000000000000 );
79 absZ = sig<<-shiftDist;
80 } else {
81 /*--------------------------------------------------------------------
82 *--------------------------------------------------------------------*/
83 if ( 53 <= shiftDist ) {
84 if ( exact && (exp | sig) ) {
85 softfloat_exceptionFlags |= softfloat_flag_inexact;
86 }
87 return 0;
88 }
89 /*--------------------------------------------------------------------
90 *--------------------------------------------------------------------*/
91 sig |= UINT64_C( 0x0010000000000000 );
92 absZ = sig>>shiftDist;
93 if ( exact && (absZ<<shiftDist != sig) ) {
94 softfloat_exceptionFlags |= softfloat_flag_inexact;
95 }
96 }
97 return sign ? -absZ : absZ;
98
99}
100
deps/SoftFloat-3e/source/f64_to_ui32.c created+82
......@@ -0,0 +1,82 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t f64_to_ui32( float64_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t sig;
51 int_fast16_t shiftDist;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 uA.f = a;
56 uiA = uA.ui;
57 sign = signF64UI( uiA );
58 exp = expF64UI( uiA );
59 sig = fracF64UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62#if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
63 if ( (exp == 0x7FF) && sig ) {
64#if (ui32_fromNaN == ui32_fromPosOverflow)
65 sign = 0;
66#elif (ui32_fromNaN == ui32_fromNegOverflow)
67 sign = 1;
68#else
69 softfloat_raiseFlags( softfloat_flag_invalid );
70 return ui32_fromNaN;
71#endif
72 }
73#endif
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
77 shiftDist = 0x427 - exp;
78 if ( 0 < shiftDist ) sig = softfloat_shiftRightJam64( sig, shiftDist );
79 return softfloat_roundToUI32( sign, sig, roundingMode, exact );
80
81}
82
deps/SoftFloat-3e/source/f64_to_ui32_r_minMag.c created+88
......@@ -0,0 +1,88 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t f64_to_ui32_r_minMag( float64_t a, bool exact )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 int_fast16_t exp;
49 uint_fast64_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
52 uint_fast32_t z;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF64UI( uiA );
59 sig = fracF64UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x433 - exp;
63 if ( 53 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF64UI( uiA );
72 if ( sign || (shiftDist < 21) ) {
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 return
75 (exp == 0x7FF) && sig ? ui32_fromNaN
76 : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
77 }
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 sig |= UINT64_C( 0x0010000000000000 );
81 z = sig>>shiftDist;
82 if ( exact && ((uint_fast64_t) z<<shiftDist != sig) ) {
83 softfloat_exceptionFlags |= softfloat_flag_inexact;
84 }
85 return z;
86
87}
88
deps/SoftFloat-3e/source/f64_to_ui64.c created+103
......@@ -0,0 +1,103 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t f64_to_ui64( float64_t a, uint_fast8_t roundingMode, bool exact )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 bool sign;
49 int_fast16_t exp;
50 uint_fast64_t sig;
51 int_fast16_t shiftDist;
52#ifdef SOFTFLOAT_FAST_INT64
53 struct uint64_extra sigExtra;
54#else
55 uint32_t extSig[3];
56#endif
57
58 /*------------------------------------------------------------------------
59 *------------------------------------------------------------------------*/
60 uA.f = a;
61 uiA = uA.ui;
62 sign = signF64UI( uiA );
63 exp = expF64UI( uiA );
64 sig = fracF64UI( uiA );
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
68 shiftDist = 0x433 - exp;
69#ifdef SOFTFLOAT_FAST_INT64
70 if ( shiftDist <= 0 ) {
71 if ( shiftDist < -11 ) goto invalid;
72 sigExtra.v = sig<<-shiftDist;
73 sigExtra.extra = 0;
74 } else {
75 sigExtra = softfloat_shiftRightJam64Extra( sig, 0, shiftDist );
76 }
77 return
78 softfloat_roundToUI64(
79 sign, sigExtra.v, sigExtra.extra, roundingMode, exact );
80#else
81 extSig[indexWord( 3, 0 )] = 0;
82 if ( shiftDist <= 0 ) {
83 if ( shiftDist < -11 ) goto invalid;
84 sig <<= -shiftDist;
85 extSig[indexWord( 3, 2 )] = sig>>32;
86 extSig[indexWord( 3, 1 )] = sig;
87 } else {
88 extSig[indexWord( 3, 2 )] = sig>>32;
89 extSig[indexWord( 3, 1 )] = sig;
90 softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
91 }
92 return softfloat_roundMToUI64( sign, extSig, roundingMode, exact );
93#endif
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 invalid:
97 softfloat_raiseFlags( softfloat_flag_invalid );
98 return
99 (exp == 0x7FF) && fracF64UI( uiA ) ? ui64_fromNaN
100 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
101
102}
103
deps/SoftFloat-3e/source/f64_to_ui64_r_minMag.c created+93
......@@ -0,0 +1,93 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t f64_to_ui64_r_minMag( float64_t a, bool exact )
45{
46 union ui64_f64 uA;
47 uint_fast64_t uiA;
48 int_fast16_t exp;
49 uint_fast64_t sig;
50 int_fast16_t shiftDist;
51 bool sign;
52 uint_fast64_t z;
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 uA.f = a;
57 uiA = uA.ui;
58 exp = expF64UI( uiA );
59 sig = fracF64UI( uiA );
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 shiftDist = 0x433 - exp;
63 if ( 53 <= shiftDist ) {
64 if ( exact && (exp | sig) ) {
65 softfloat_exceptionFlags |= softfloat_flag_inexact;
66 }
67 return 0;
68 }
69 /*------------------------------------------------------------------------
70 *------------------------------------------------------------------------*/
71 sign = signF64UI( uiA );
72 if ( sign ) goto invalid;
73 if ( shiftDist <= 0 ) {
74 if ( shiftDist < -11 ) goto invalid;
75 z = (sig | UINT64_C( 0x0010000000000000 ))<<-shiftDist;
76 } else {
77 sig |= UINT64_C( 0x0010000000000000 );
78 z = sig>>shiftDist;
79 if ( exact && (uint64_t) (sig<<(-shiftDist & 63)) ) {
80 softfloat_exceptionFlags |= softfloat_flag_inexact;
81 }
82 }
83 return z;
84 /*------------------------------------------------------------------------
85 *------------------------------------------------------------------------*/
86 invalid:
87 softfloat_raiseFlags( softfloat_flag_invalid );
88 return
89 (exp == 0x7FF) && sig ? ui64_fromNaN
90 : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
91
92}
93
deps/SoftFloat-3e/source/i32_to_extF80.c created+65
......@@ -0,0 +1,65 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43extFloat80_t i32_to_extF80( int32_t a )
44{
45 uint_fast16_t uiZ64;
46 uint_fast32_t absA;
47 bool sign;
48 int_fast8_t shiftDist;
49 union { struct extFloat80M s; extFloat80_t f; } uZ;
50
51 uiZ64 = 0;
52 absA = 0;
53 if ( a ) {
54 sign = (a < 0);
55 absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
56 shiftDist = softfloat_countLeadingZeros32( absA );
57 uiZ64 = packToExtF80UI64( sign, 0x401E - shiftDist );
58 absA <<= shiftDist;
59 }
60 uZ.s.signExp = uiZ64;
61 uZ.s.signif = (uint_fast64_t) absA<<32;
62 return uZ.f;
63
64}
65
deps/SoftFloat-3e/source/i32_to_extF80M.c created+78
......@@ -0,0 +1,78 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void i32_to_extF80M( int32_t a, extFloat80_t *zPtr )
45{
46
47 *zPtr = i32_to_extF80( a );
48
49}
50
51#else
52
53void i32_to_extF80M( int32_t a, extFloat80_t *zPtr )
54{
55 struct extFloat80M *zSPtr;
56 uint_fast16_t uiZ64;
57 uint64_t sigZ;
58 bool sign;
59 uint32_t absA;
60 int_fast8_t shiftDist;
61
62 zSPtr = (struct extFloat80M *) zPtr;
63 uiZ64 = 0;
64 sigZ = 0;
65 if ( a ) {
66 sign = (a < 0);
67 absA = sign ? -(uint32_t) a : (uint32_t) a;
68 shiftDist = softfloat_countLeadingZeros32( absA );
69 uiZ64 = packToExtF80UI64( sign, 0x401E - shiftDist );
70 sigZ = (uint64_t) (absA<<shiftDist)<<32;
71 }
72 zSPtr->signExp = uiZ64;
73 zSPtr->signif = sigZ;
74
75}
76
77#endif
78
deps/SoftFloat-3e/source/i32_to_f128.c created+64
......@@ -0,0 +1,64 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float128_t i32_to_f128( int32_t a )
43{
44 uint_fast64_t uiZ64;
45 bool sign;
46 uint_fast32_t absA;
47 int_fast8_t shiftDist;
48 union ui128_f128 uZ;
49
50 uiZ64 = 0;
51 if ( a ) {
52 sign = (a < 0);
53 absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
54 shiftDist = softfloat_countLeadingZeros32( absA ) + 17;
55 uiZ64 =
56 packToF128UI64(
57 sign, 0x402E - shiftDist, (uint_fast64_t) absA<<shiftDist );
58 }
59 uZ.ui.v64 = uiZ64;
60 uZ.ui.v0 = 0;
61 return uZ.f;
62
63}
64
deps/SoftFloat-3e/source/i32_to_f128M.c created+81
......@@ -0,0 +1,81 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void i32_to_f128M( int32_t a, float128_t *zPtr )
45{
46
47 *zPtr = i32_to_f128( a );
48
49}
50
51#else
52
53void i32_to_f128M( int32_t a, float128_t *zPtr )
54{
55 uint32_t *zWPtr;
56 uint32_t uiZ96, uiZ64;
57 bool sign;
58 uint32_t absA;
59 int_fast8_t shiftDist;
60 uint64_t normAbsA;
61
62 zWPtr = (uint32_t *) zPtr;
63 uiZ96 = 0;
64 uiZ64 = 0;
65 if ( a ) {
66 sign = (a < 0);
67 absA = sign ? -(uint32_t) a : (uint32_t) a;
68 shiftDist = softfloat_countLeadingZeros32( absA ) + 17;
69 normAbsA = (uint64_t) absA<<shiftDist;
70 uiZ96 = packToF128UI96( sign, 0x402E - shiftDist, normAbsA>>32 );
71 uiZ64 = normAbsA;
72 }
73 zWPtr[indexWord( 4, 3 )] = uiZ96;
74 zWPtr[indexWord( 4, 2 )] = uiZ64;
75 zWPtr[indexWord( 4, 1 )] = 0;
76 zWPtr[indexWord( 4, 0 )] = 0;
77
78}
79
80#endif
81
deps/SoftFloat-3e/source/i32_to_f16.c created+71
......@@ -0,0 +1,71 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float16_t i32_to_f16( int32_t a )
44{
45 bool sign;
46 uint_fast32_t absA;
47 int_fast8_t shiftDist;
48 union ui16_f16 u;
49 uint_fast16_t sig;
50
51 sign = (a < 0);
52 absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
53 shiftDist = softfloat_countLeadingZeros32( absA ) - 21;
54 if ( 0 <= shiftDist ) {
55 u.ui =
56 a ? packToF16UI(
57 sign, 0x18 - shiftDist, (uint_fast16_t) absA<<shiftDist )
58 : 0;
59 return u.f;
60 } else {
61 shiftDist += 4;
62 sig =
63 (shiftDist < 0)
64 ? absA>>(-shiftDist)
65 | ((uint32_t) (absA<<(shiftDist & 31)) != 0)
66 : (uint_fast16_t) absA<<shiftDist;
67 return softfloat_roundPackToF16( sign, 0x1C - shiftDist, sig );
68 }
69
70}
71
deps/SoftFloat-3e/source/i32_to_f32.c created+58
......@@ -0,0 +1,58 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float32_t i32_to_f32( int32_t a )
44{
45 bool sign;
46 union ui32_f32 uZ;
47 uint_fast32_t absA;
48
49 sign = (a < 0);
50 if ( ! (a & 0x7FFFFFFF) ) {
51 uZ.ui = sign ? packToF32UI( 1, 0x9E, 0 ) : 0;
52 return uZ.f;
53 }
54 absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
55 return softfloat_normRoundPackToF32( sign, 0x9C, absA );
56
57}
58
deps/SoftFloat-3e/source/i32_to_f64.c created+65
......@@ -0,0 +1,65 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float64_t i32_to_f64( int32_t a )
44{
45 uint_fast64_t uiZ;
46 bool sign;
47 uint_fast32_t absA;
48 int_fast8_t shiftDist;
49 union ui64_f64 uZ;
50
51 if ( ! a ) {
52 uiZ = 0;
53 } else {
54 sign = (a < 0);
55 absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
56 shiftDist = softfloat_countLeadingZeros32( absA ) + 21;
57 uiZ =
58 packToF64UI(
59 sign, 0x432 - shiftDist, (uint_fast64_t) absA<<shiftDist );
60 }
61 uZ.ui = uiZ;
62 return uZ.f;
63
64}
65
deps/SoftFloat-3e/source/i64_to_extF80.c created+65
......@@ -0,0 +1,65 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43extFloat80_t i64_to_extF80( int64_t a )
44{
45 uint_fast16_t uiZ64;
46 uint_fast64_t absA;
47 bool sign;
48 int_fast8_t shiftDist;
49 union { struct extFloat80M s; extFloat80_t f; } uZ;
50
51 uiZ64 = 0;
52 absA = 0;
53 if ( a ) {
54 sign = (a < 0);
55 absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
56 shiftDist = softfloat_countLeadingZeros64( absA );
57 uiZ64 = packToExtF80UI64( sign, 0x403E - shiftDist );
58 absA <<= shiftDist;
59 }
60 uZ.s.signExp = uiZ64;
61 uZ.s.signif = absA;
62 return uZ.f;
63
64}
65
deps/SoftFloat-3e/source/i64_to_extF80M.c created+78
......@@ -0,0 +1,78 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void i64_to_extF80M( int64_t a, extFloat80_t *zPtr )
45{
46
47 *zPtr = i64_to_extF80( a );
48
49}
50
51#else
52
53void i64_to_extF80M( int64_t a, extFloat80_t *zPtr )
54{
55 struct extFloat80M *zSPtr;
56 uint_fast16_t uiZ64;
57 uint64_t sigZ;
58 bool sign;
59 uint64_t absA;
60 int_fast8_t shiftDist;
61
62 zSPtr = (struct extFloat80M *) zPtr;
63 uiZ64 = 0;
64 sigZ = 0;
65 if ( a ) {
66 sign = (a < 0);
67 absA = sign ? -(uint64_t) a : (uint64_t) a;
68 shiftDist = softfloat_countLeadingZeros64( absA );
69 uiZ64 = packToExtF80UI64( sign, 0x403E - shiftDist );
70 sigZ = absA<<shiftDist;
71 }
72 zSPtr->signExp = uiZ64;
73 zSPtr->signif = sigZ;
74
75}
76
77#endif
78
deps/SoftFloat-3e/source/i64_to_f128.c created+72
......@@ -0,0 +1,72 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float128_t i64_to_f128( int64_t a )
43{
44 uint_fast64_t uiZ64, uiZ0;
45 bool sign;
46 uint_fast64_t absA;
47 int_fast8_t shiftDist;
48 struct uint128 zSig;
49 union ui128_f128 uZ;
50
51 if ( ! a ) {
52 uiZ64 = 0;
53 uiZ0 = 0;
54 } else {
55 sign = (a < 0);
56 absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
57 shiftDist = softfloat_countLeadingZeros64( absA ) + 49;
58 if ( 64 <= shiftDist ) {
59 zSig.v64 = absA<<(shiftDist - 64);
60 zSig.v0 = 0;
61 } else {
62 zSig = softfloat_shortShiftLeft128( 0, absA, shiftDist );
63 }
64 uiZ64 = packToF128UI64( sign, 0x406E - shiftDist, zSig.v64 );
65 uiZ0 = zSig.v0;
66 }
67 uZ.ui.v64 = uiZ64;
68 uZ.ui.v0 = uiZ0;
69 return uZ.f;
70
71}
72
deps/SoftFloat-3e/source/i64_to_f128M.c created+92
......@@ -0,0 +1,92 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void i64_to_f128M( int64_t a, float128_t *zPtr )
45{
46
47 *zPtr = i64_to_f128( a );
48
49}
50
51#else
52
53void i64_to_f128M( int64_t a, float128_t *zPtr )
54{
55 uint32_t *zWPtr;
56 uint32_t uiZ96, uiZ64;
57 bool sign;
58 uint64_t absA;
59 uint_fast8_t shiftDist;
60 uint32_t *ptr;
61
62 zWPtr = (uint32_t *) zPtr;
63 uiZ96 = 0;
64 uiZ64 = 0;
65 zWPtr[indexWord( 4, 1 )] = 0;
66 zWPtr[indexWord( 4, 0 )] = 0;
67 if ( a ) {
68 sign = (a < 0);
69 absA = sign ? -(uint64_t) a : (uint64_t) a;
70 shiftDist = softfloat_countLeadingZeros64( absA ) + 17;
71 if ( shiftDist < 32 ) {
72 ptr = zWPtr + indexMultiwordHi( 4, 3 );
73 ptr[indexWord( 3, 2 )] = 0;
74 ptr[indexWord( 3, 1 )] = absA>>32;
75 ptr[indexWord( 3, 0 )] = absA;
76 softfloat_shortShiftLeft96M( ptr, shiftDist, ptr );
77 ptr[indexWordHi( 3 )] =
78 packToF128UI96(
79 sign, 0x404E - shiftDist, ptr[indexWordHi( 3 )] );
80 return;
81 }
82 absA <<= shiftDist - 32;
83 uiZ96 = packToF128UI96( sign, 0x404E - shiftDist, absA>>32 );
84 uiZ64 = absA;
85 }
86 zWPtr[indexWord( 4, 3 )] = uiZ96;
87 zWPtr[indexWord( 4, 2 )] = uiZ64;
88
89}
90
91#endif
92
deps/SoftFloat-3e/source/i64_to_f16.c created+70
......@@ -0,0 +1,70 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float16_t i64_to_f16( int64_t a )
44{
45 bool sign;
46 uint_fast64_t absA;
47 int_fast8_t shiftDist;
48 union ui16_f16 u;
49 uint_fast16_t sig;
50
51 sign = (a < 0);
52 absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
53 shiftDist = softfloat_countLeadingZeros64( absA ) - 53;
54 if ( 0 <= shiftDist ) {
55 u.ui =
56 a ? packToF16UI(
57 sign, 0x18 - shiftDist, (uint_fast16_t) absA<<shiftDist )
58 : 0;
59 return u.f;
60 } else {
61 shiftDist += 4;
62 sig =
63 (shiftDist < 0)
64 ? softfloat_shortShiftRightJam64( absA, -shiftDist )
65 : (uint_fast16_t) absA<<shiftDist;
66 return softfloat_roundPackToF16( sign, 0x1C - shiftDist, sig );
67 }
68
69}
70
deps/SoftFloat-3e/source/i64_to_f32.c created+70
......@@ -0,0 +1,70 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float32_t i64_to_f32( int64_t a )
44{
45 bool sign;
46 uint_fast64_t absA;
47 int_fast8_t shiftDist;
48 union ui32_f32 u;
49 uint_fast32_t sig;
50
51 sign = (a < 0);
52 absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
53 shiftDist = softfloat_countLeadingZeros64( absA ) - 40;
54 if ( 0 <= shiftDist ) {
55 u.ui =
56 a ? packToF32UI(
57 sign, 0x95 - shiftDist, (uint_fast32_t) absA<<shiftDist )
58 : 0;
59 return u.f;
60 } else {
61 shiftDist += 7;
62 sig =
63 (shiftDist < 0)
64 ? softfloat_shortShiftRightJam64( absA, -shiftDist )
65 : (uint_fast32_t) absA<<shiftDist;
66 return softfloat_roundPackToF32( sign, 0x9C - shiftDist, sig );
67 }
68
69}
70
deps/SoftFloat-3e/source/i64_to_f64.c created+58
......@@ -0,0 +1,58 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float64_t i64_to_f64( int64_t a )
44{
45 bool sign;
46 union ui64_f64 uZ;
47 uint_fast64_t absA;
48
49 sign = (a < 0);
50 if ( ! (a & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) {
51 uZ.ui = sign ? packToF64UI( 1, 0x43E, 0 ) : 0;
52 return uZ.f;
53 }
54 absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
55 return softfloat_normRoundPackToF64( sign, 0x43C, absA );
56
57}
58
deps/SoftFloat-3e/source/include/internals.h created+278
......@@ -0,0 +1,278 @@
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#ifndef internals_h
38#define internals_h 1
39
40#include <stdbool.h>
41#include <stdint.h>
42#include "primitives.h"
43#include "softfloat_types.h"
44
45union ui16_f16 { uint16_t ui; float16_t f; };
46union ui32_f32 { uint32_t ui; float32_t f; };
47union ui64_f64 { uint64_t ui; float64_t f; };
48
49#ifdef SOFTFLOAT_FAST_INT64
50union extF80M_extF80 { struct extFloat80M fM; extFloat80_t f; };
51union ui128_f128 { struct uint128 ui; float128_t f; };
52#endif
53
54enum {
55 softfloat_mulAdd_subC = 1,
56 softfloat_mulAdd_subProd = 2
57};
58
59/*----------------------------------------------------------------------------
60*----------------------------------------------------------------------------*/
61uint_fast32_t softfloat_roundToUI32( bool, uint_fast64_t, uint_fast8_t, bool );
62
63#ifdef SOFTFLOAT_FAST_INT64
64uint_fast64_t
65 softfloat_roundToUI64(
66 bool, uint_fast64_t, uint_fast64_t, uint_fast8_t, bool );
67#else
68uint_fast64_t softfloat_roundMToUI64( bool, uint32_t *, uint_fast8_t, bool );
69#endif
70
71int_fast32_t softfloat_roundToI32( bool, uint_fast64_t, uint_fast8_t, bool );
72
73#ifdef SOFTFLOAT_FAST_INT64
74int_fast64_t
75 softfloat_roundToI64(
76 bool, uint_fast64_t, uint_fast64_t, uint_fast8_t, bool );
77#else
78int_fast64_t softfloat_roundMToI64( bool, uint32_t *, uint_fast8_t, bool );
79#endif
80
81/*----------------------------------------------------------------------------
82*----------------------------------------------------------------------------*/
83#define signF16UI( a ) ((bool) ((uint16_t) (a)>>15))
84#define expF16UI( a ) ((int_fast8_t) ((a)>>10) & 0x1F)
85#define fracF16UI( a ) ((a) & 0x03FF)
86#define packToF16UI( sign, exp, sig ) (((uint16_t) (sign)<<15) + ((uint16_t) (exp)<<10) + (sig))
87
88#define isNaNF16UI( a ) (((~(a) & 0x7C00) == 0) && ((a) & 0x03FF))
89
90struct exp8_sig16 { int_fast8_t exp; uint_fast16_t sig; };
91struct exp8_sig16 softfloat_normSubnormalF16Sig( uint_fast16_t );
92
93float16_t softfloat_roundPackToF16( bool, int_fast16_t, uint_fast16_t );
94float16_t softfloat_normRoundPackToF16( bool, int_fast16_t, uint_fast16_t );
95
96float16_t softfloat_addMagsF16( uint_fast16_t, uint_fast16_t );
97float16_t softfloat_subMagsF16( uint_fast16_t, uint_fast16_t );
98float16_t
99 softfloat_mulAddF16(
100 uint_fast16_t, uint_fast16_t, uint_fast16_t, uint_fast8_t );
101
102/*----------------------------------------------------------------------------
103*----------------------------------------------------------------------------*/
104#define signF32UI( a ) ((bool) ((uint32_t) (a)>>31))
105#define expF32UI( a ) ((int_fast16_t) ((a)>>23) & 0xFF)
106#define fracF32UI( a ) ((a) & 0x007FFFFF)
107#define packToF32UI( sign, exp, sig ) (((uint32_t) (sign)<<31) + ((uint32_t) (exp)<<23) + (sig))
108
109#define isNaNF32UI( a ) (((~(a) & 0x7F800000) == 0) && ((a) & 0x007FFFFF))
110
111struct exp16_sig32 { int_fast16_t exp; uint_fast32_t sig; };
112struct exp16_sig32 softfloat_normSubnormalF32Sig( uint_fast32_t );
113
114float32_t softfloat_roundPackToF32( bool, int_fast16_t, uint_fast32_t );
115float32_t softfloat_normRoundPackToF32( bool, int_fast16_t, uint_fast32_t );
116
117float32_t softfloat_addMagsF32( uint_fast32_t, uint_fast32_t );
118float32_t softfloat_subMagsF32( uint_fast32_t, uint_fast32_t );
119float32_t
120 softfloat_mulAddF32(
121 uint_fast32_t, uint_fast32_t, uint_fast32_t, uint_fast8_t );
122
123/*----------------------------------------------------------------------------
124*----------------------------------------------------------------------------*/
125#define signF64UI( a ) ((bool) ((uint64_t) (a)>>63))
126#define expF64UI( a ) ((int_fast16_t) ((a)>>52) & 0x7FF)
127#define fracF64UI( a ) ((a) & UINT64_C( 0x000FFFFFFFFFFFFF ))
128#define packToF64UI( sign, exp, sig ) ((uint64_t) (((uint_fast64_t) (sign)<<63) + ((uint_fast64_t) (exp)<<52) + (sig)))
129
130#define isNaNF64UI( a ) (((~(a) & UINT64_C( 0x7FF0000000000000 )) == 0) && ((a) & UINT64_C( 0x000FFFFFFFFFFFFF )))
131
132struct exp16_sig64 { int_fast16_t exp; uint_fast64_t sig; };
133struct exp16_sig64 softfloat_normSubnormalF64Sig( uint_fast64_t );
134
135float64_t softfloat_roundPackToF64( bool, int_fast16_t, uint_fast64_t );
136float64_t softfloat_normRoundPackToF64( bool, int_fast16_t, uint_fast64_t );
137
138float64_t softfloat_addMagsF64( uint_fast64_t, uint_fast64_t, bool );
139float64_t softfloat_subMagsF64( uint_fast64_t, uint_fast64_t, bool );
140float64_t
141 softfloat_mulAddF64(
142 uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast8_t );
143
144/*----------------------------------------------------------------------------
145*----------------------------------------------------------------------------*/
146#define signExtF80UI64( a64 ) ((bool) ((uint16_t) (a64)>>15))
147#define expExtF80UI64( a64 ) ((a64) & 0x7FFF)
148#define packToExtF80UI64( sign, exp ) ((uint_fast16_t) (sign)<<15 | (exp))
149
150#define isNaNExtF80UI( a64, a0 ) ((((a64) & 0x7FFF) == 0x7FFF) && ((a0) & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
151
152#ifdef SOFTFLOAT_FAST_INT64
153
154/*----------------------------------------------------------------------------
155*----------------------------------------------------------------------------*/
156
157struct exp32_sig64 { int_fast32_t exp; uint64_t sig; };
158struct exp32_sig64 softfloat_normSubnormalExtF80Sig( uint_fast64_t );
159
160extFloat80_t
161 softfloat_roundPackToExtF80(
162 bool, int_fast32_t, uint_fast64_t, uint_fast64_t, uint_fast8_t );
163extFloat80_t
164 softfloat_normRoundPackToExtF80(
165 bool, int_fast32_t, uint_fast64_t, uint_fast64_t, uint_fast8_t );
166
167extFloat80_t
168 softfloat_addMagsExtF80(
169 uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
170extFloat80_t
171 softfloat_subMagsExtF80(
172 uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
173
174/*----------------------------------------------------------------------------
175*----------------------------------------------------------------------------*/
176#define signF128UI64( a64 ) ((bool) ((uint64_t) (a64)>>63))
177#define expF128UI64( a64 ) ((int_fast32_t) ((a64)>>48) & 0x7FFF)
178#define fracF128UI64( a64 ) ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))
179#define packToF128UI64( sign, exp, sig64 ) (((uint_fast64_t) (sign)<<63) + ((uint_fast64_t) (exp)<<48) + (sig64))
180
181#define isNaNF128UI( a64, a0 ) (((~(a64) & UINT64_C( 0x7FFF000000000000 )) == 0) && (a0 || ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))))
182
183struct exp32_sig128 { int_fast32_t exp; struct uint128 sig; };
184struct exp32_sig128
185 softfloat_normSubnormalF128Sig( uint_fast64_t, uint_fast64_t );
186
187float128_t
188 softfloat_roundPackToF128(
189 bool, int_fast32_t, uint_fast64_t, uint_fast64_t, uint_fast64_t );
190float128_t
191 softfloat_normRoundPackToF128(
192 bool, int_fast32_t, uint_fast64_t, uint_fast64_t );
193
194float128_t
195 softfloat_addMagsF128(
196 uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
197float128_t
198 softfloat_subMagsF128(
199 uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
200float128_t
201 softfloat_mulAddF128(
202 uint_fast64_t,
203 uint_fast64_t,
204 uint_fast64_t,
205 uint_fast64_t,
206 uint_fast64_t,
207 uint_fast64_t,
208 uint_fast8_t
209 );
210
211#else
212
213/*----------------------------------------------------------------------------
214*----------------------------------------------------------------------------*/
215
216bool
217 softfloat_tryPropagateNaNExtF80M(
218 const struct extFloat80M *,
219 const struct extFloat80M *,
220 struct extFloat80M *
221 );
222void softfloat_invalidExtF80M( struct extFloat80M * );
223
224int softfloat_normExtF80SigM( uint64_t * );
225
226void
227 softfloat_roundPackMToExtF80M(
228 bool, int32_t, uint32_t *, uint_fast8_t, struct extFloat80M * );
229void
230 softfloat_normRoundPackMToExtF80M(
231 bool, int32_t, uint32_t *, uint_fast8_t, struct extFloat80M * );
232
233void
234 softfloat_addExtF80M(
235 const struct extFloat80M *,
236 const struct extFloat80M *,
237 struct extFloat80M *,
238 bool
239 );
240
241int
242 softfloat_compareNonnormExtF80M(
243 const struct extFloat80M *, const struct extFloat80M * );
244
245/*----------------------------------------------------------------------------
246*----------------------------------------------------------------------------*/
247#define signF128UI96( a96 ) ((bool) ((uint32_t) (a96)>>31))
248#define expF128UI96( a96 ) ((int32_t) ((a96)>>16) & 0x7FFF)
249#define fracF128UI96( a96 ) ((a96) & 0x0000FFFF)
250#define packToF128UI96( sign, exp, sig96 ) (((uint32_t) (sign)<<31) + ((uint32_t) (exp)<<16) + (sig96))
251
252bool softfloat_isNaNF128M( const uint32_t * );
253
254bool
255 softfloat_tryPropagateNaNF128M(
256 const uint32_t *, const uint32_t *, uint32_t * );
257void softfloat_invalidF128M( uint32_t * );
258
259int softfloat_shiftNormSigF128M( const uint32_t *, uint_fast8_t, uint32_t * );
260
261void softfloat_roundPackMToF128M( bool, int32_t, uint32_t *, uint32_t * );
262void softfloat_normRoundPackMToF128M( bool, int32_t, uint32_t *, uint32_t * );
263
264void
265 softfloat_addF128M( const uint32_t *, const uint32_t *, uint32_t *, bool );
266void
267 softfloat_mulAddF128M(
268 const uint32_t *,
269 const uint32_t *,
270 const uint32_t *,
271 uint32_t *,
272 uint_fast8_t
273 );
274
275#endif
276
277#endif
278
deps/SoftFloat-3e/source/include/opts-GCC.h created+114
......@@ -0,0 +1,114 @@
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2017 The Regents of the University of California. All rights
8reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#ifndef opts_GCC_h
38#define opts_GCC_h 1
39
40#ifdef INLINE
41
42#include <stdint.h>
43#include "primitiveTypes.h"
44
45#ifdef SOFTFLOAT_BUILTIN_CLZ
46
47INLINE uint_fast8_t softfloat_countLeadingZeros16( uint16_t a )
48 { return a ? __builtin_clz( a ) - 16 : 16; }
49#define softfloat_countLeadingZeros16 softfloat_countLeadingZeros16
50
51INLINE uint_fast8_t softfloat_countLeadingZeros32( uint32_t a )
52 { return a ? __builtin_clz( a ) : 32; }
53#define softfloat_countLeadingZeros32 softfloat_countLeadingZeros32
54
55INLINE uint_fast8_t softfloat_countLeadingZeros64( uint64_t a )
56 { return a ? __builtin_clzll( a ) : 64; }
57#define softfloat_countLeadingZeros64 softfloat_countLeadingZeros64
58
59#endif
60
61#ifdef SOFTFLOAT_INTRINSIC_INT128
62
63INLINE struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b )
64{
65 union { unsigned __int128 ui; struct uint128 s; } uZ;
66 uZ.ui = (unsigned __int128) a * ((uint_fast64_t) b<<32);
67 return uZ.s;
68}
69#define softfloat_mul64ByShifted32To128 softfloat_mul64ByShifted32To128
70
71INLINE struct uint128 softfloat_mul64To128( uint64_t a, uint64_t b )
72{
73 union { unsigned __int128 ui; struct uint128 s; } uZ;
74 uZ.ui = (unsigned __int128) a * b;
75 return uZ.s;
76}
77#define softfloat_mul64To128 softfloat_mul64To128
78
79INLINE
80struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b )
81{
82 union { unsigned __int128 ui; struct uint128 s; } uZ;
83 uZ.ui = ((unsigned __int128) a64<<64 | a0) * b;
84 return uZ.s;
85}
86#define softfloat_mul128By32 softfloat_mul128By32
87
88INLINE
89void
90 softfloat_mul128To256M(
91 uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0, uint64_t *zPtr )
92{
93 unsigned __int128 z0, mid1, mid, z128;
94 z0 = (unsigned __int128) a0 * b0;
95 mid1 = (unsigned __int128) a64 * b0;
96 mid = mid1 + (unsigned __int128) a0 * b64;
97 z128 = (unsigned __int128) a64 * b64;
98 z128 += (unsigned __int128) (mid < mid1)<<64 | mid>>64;
99 mid <<= 64;
100 z0 += mid;
101 z128 += (z0 < mid);
102 zPtr[indexWord( 4, 0 )] = z0;
103 zPtr[indexWord( 4, 1 )] = z0>>64;
104 zPtr[indexWord( 4, 2 )] = z128;
105 zPtr[indexWord( 4, 3 )] = z128>>64;
106}
107#define softfloat_mul128To256M softfloat_mul128To256M
108
109#endif
110
111#endif
112
113#endif
114
deps/SoftFloat-3e/source/include/primitiveTypes.h created+85
......@@ -0,0 +1,85 @@
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#ifndef primitiveTypes_h
38#define primitiveTypes_h 1
39
40#include <stdint.h>
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44#ifdef LITTLEENDIAN
45struct uint128 { uint64_t v0, v64; };
46struct uint64_extra { uint64_t extra, v; };
47struct uint128_extra { uint64_t extra; struct uint128 v; };
48#else
49struct uint128 { uint64_t v64, v0; };
50struct uint64_extra { uint64_t v, extra; };
51struct uint128_extra { struct uint128 v; uint64_t extra; };
52#endif
53
54#endif
55
56/*----------------------------------------------------------------------------
57| These macros are used to isolate the differences in word order between big-
58| endian and little-endian platforms.
59*----------------------------------------------------------------------------*/
60#ifdef LITTLEENDIAN
61#define wordIncr 1
62#define indexWord( total, n ) (n)
63#define indexWordHi( total ) ((total) - 1)
64#define indexWordLo( total ) 0
65#define indexMultiword( total, m, n ) (n)
66#define indexMultiwordHi( total, n ) ((total) - (n))
67#define indexMultiwordLo( total, n ) 0
68#define indexMultiwordHiBut( total, n ) (n)
69#define indexMultiwordLoBut( total, n ) 0
70#define INIT_UINTM4( v3, v2, v1, v0 ) { v0, v1, v2, v3 }
71#else
72#define wordIncr -1
73#define indexWord( total, n ) ((total) - 1 - (n))
74#define indexWordHi( total ) 0
75#define indexWordLo( total ) ((total) - 1)
76#define indexMultiword( total, m, n ) ((total) - 1 - (m))
77#define indexMultiwordHi( total, n ) 0
78#define indexMultiwordLo( total, n ) ((total) - (n))
79#define indexMultiwordHiBut( total, n ) 0
80#define indexMultiwordLoBut( total, n ) (n)
81#define INIT_UINTM4( v3, v2, v1, v0 ) { v3, v2, v1, v0 }
82#endif
83
84#endif
85
deps/SoftFloat-3e/source/include/primitives.h created+1160
......@@ -0,0 +1,1160 @@
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#ifndef primitives_h
38#define primitives_h 1
39
40#include <stdbool.h>
41#include <stdint.h>
42#include "primitiveTypes.h"
43
44#ifndef softfloat_shortShiftRightJam64
45/*----------------------------------------------------------------------------
46| Shifts 'a' right by the number of bits given in 'dist', which must be in
47| the range 1 to 63. If any nonzero bits are shifted off, they are "jammed"
48| into the least-significant bit of the shifted value by setting the least-
49| significant bit to 1. This shifted-and-jammed value is returned.
50*----------------------------------------------------------------------------*/
51#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
52INLINE
53uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist )
54 { return a>>dist | ((a & (((uint_fast64_t) 1<<dist) - 1)) != 0); }
55#else
56uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist );
57#endif
58#endif
59
60#ifndef softfloat_shiftRightJam32
61/*----------------------------------------------------------------------------
62| Shifts 'a' right by the number of bits given in 'dist', which must not
63| be zero. If any nonzero bits are shifted off, they are "jammed" into the
64| least-significant bit of the shifted value by setting the least-significant
65| bit to 1. This shifted-and-jammed value is returned.
66| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
67| greater than 32, the result will be either 0 or 1, depending on whether 'a'
68| is zero or nonzero.
69*----------------------------------------------------------------------------*/
70#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
71INLINE uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist )
72{
73 return
74 (dist < 31) ? a>>dist | ((uint32_t) (a<<(-dist & 31)) != 0) : (a != 0);
75}
76#else
77uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist );
78#endif
79#endif
80
81#ifndef softfloat_shiftRightJam64
82/*----------------------------------------------------------------------------
83| Shifts 'a' right by the number of bits given in 'dist', which must not
84| be zero. If any nonzero bits are shifted off, they are "jammed" into the
85| least-significant bit of the shifted value by setting the least-significant
86| bit to 1. This shifted-and-jammed value is returned.
87| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
88| greater than 64, the result will be either 0 or 1, depending on whether 'a'
89| is zero or nonzero.
90*----------------------------------------------------------------------------*/
91#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
92INLINE uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist )
93{
94 return
95 (dist < 63) ? a>>dist | ((uint64_t) (a<<(-dist & 63)) != 0) : (a != 0);
96}
97#else
98uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist );
99#endif
100#endif
101
102/*----------------------------------------------------------------------------
103| A constant table that translates an 8-bit unsigned integer (the array index)
104| into the number of leading 0 bits before the most-significant 1 of that
105| integer. For integer zero (index 0), the corresponding table element is 8.
106*----------------------------------------------------------------------------*/
107extern const uint_least8_t softfloat_countLeadingZeros8[256];
108
109#ifndef softfloat_countLeadingZeros16
110/*----------------------------------------------------------------------------
111| Returns the number of leading 0 bits before the most-significant 1 bit of
112| 'a'. If 'a' is zero, 16 is returned.
113*----------------------------------------------------------------------------*/
114#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
115INLINE uint_fast8_t softfloat_countLeadingZeros16( uint16_t a )
116{
117 uint_fast8_t count = 8;
118 if ( 0x100 <= a ) {
119 count = 0;
120 a >>= 8;
121 }
122 count += softfloat_countLeadingZeros8[a];
123 return count;
124}
125#else
126uint_fast8_t softfloat_countLeadingZeros16( uint16_t a );
127#endif
128#endif
129
130#ifndef softfloat_countLeadingZeros32
131/*----------------------------------------------------------------------------
132| Returns the number of leading 0 bits before the most-significant 1 bit of
133| 'a'. If 'a' is zero, 32 is returned.
134*----------------------------------------------------------------------------*/
135#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
136INLINE uint_fast8_t softfloat_countLeadingZeros32( uint32_t a )
137{
138 uint_fast8_t count = 0;
139 if ( a < 0x10000 ) {
140 count = 16;
141 a <<= 16;
142 }
143 if ( a < 0x1000000 ) {
144 count += 8;
145 a <<= 8;
146 }
147 count += softfloat_countLeadingZeros8[a>>24];
148 return count;
149}
150#else
151uint_fast8_t softfloat_countLeadingZeros32( uint32_t a );
152#endif
153#endif
154
155#ifndef softfloat_countLeadingZeros64
156/*----------------------------------------------------------------------------
157| Returns the number of leading 0 bits before the most-significant 1 bit of
158| 'a'. If 'a' is zero, 64 is returned.
159*----------------------------------------------------------------------------*/
160uint_fast8_t softfloat_countLeadingZeros64( uint64_t a );
161#endif
162
163extern const uint16_t softfloat_approxRecip_1k0s[16];
164extern const uint16_t softfloat_approxRecip_1k1s[16];
165
166#ifndef softfloat_approxRecip32_1
167/*----------------------------------------------------------------------------
168| Returns an approximation to the reciprocal of the number represented by 'a',
169| where 'a' is interpreted as an unsigned fixed-point number with one integer
170| bit and 31 fraction bits. The 'a' input must be "normalized", meaning that
171| its most-significant bit (bit 31) must be 1. Thus, if A is the value of
172| the fixed-point interpretation of 'a', then 1 <= A < 2. The returned value
173| is interpreted as a pure unsigned fraction, having no integer bits and 32
174| fraction bits. The approximation returned is never greater than the true
175| reciprocal 1/A, and it differs from the true reciprocal by at most 2.006 ulp
176| (units in the last place).
177*----------------------------------------------------------------------------*/
178#ifdef SOFTFLOAT_FAST_DIV64TO32
179#define softfloat_approxRecip32_1( a ) ((uint32_t) (UINT64_C( 0x7FFFFFFFFFFFFFFF ) / (uint32_t) (a)))
180#else
181uint32_t softfloat_approxRecip32_1( uint32_t a );
182#endif
183#endif
184
185extern const uint16_t softfloat_approxRecipSqrt_1k0s[16];
186extern const uint16_t softfloat_approxRecipSqrt_1k1s[16];
187
188#ifndef softfloat_approxRecipSqrt32_1
189/*----------------------------------------------------------------------------
190| Returns an approximation to the reciprocal of the square root of the number
191| represented by 'a', where 'a' is interpreted as an unsigned fixed-point
192| number either with one integer bit and 31 fraction bits or with two integer
193| bits and 30 fraction bits. The format of 'a' is determined by 'oddExpA',
194| which must be either 0 or 1. If 'oddExpA' is 1, 'a' is interpreted as
195| having one integer bit, and if 'oddExpA' is 0, 'a' is interpreted as having
196| two integer bits. The 'a' input must be "normalized", meaning that its
197| most-significant bit (bit 31) must be 1. Thus, if A is the value of the
198| fixed-point interpretation of 'a', it follows that 1 <= A < 2 when 'oddExpA'
199| is 1, and 2 <= A < 4 when 'oddExpA' is 0.
200| The returned value is interpreted as a pure unsigned fraction, having
201| no integer bits and 32 fraction bits. The approximation returned is never
202| greater than the true reciprocal 1/sqrt(A), and it differs from the true
203| reciprocal by at most 2.06 ulp (units in the last place). The approximation
204| returned is also always within the range 0.5 to 1; thus, the most-
205| significant bit of the result is always set.
206*----------------------------------------------------------------------------*/
207uint32_t softfloat_approxRecipSqrt32_1( unsigned int oddExpA, uint32_t a );
208#endif
209
210#ifdef SOFTFLOAT_FAST_INT64
211
212/*----------------------------------------------------------------------------
213| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is
214| defined.
215*----------------------------------------------------------------------------*/
216
217#ifndef softfloat_eq128
218/*----------------------------------------------------------------------------
219| Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
220| and 'a0' is equal to the 128-bit unsigned integer formed by concatenating
221| 'b64' and 'b0'.
222*----------------------------------------------------------------------------*/
223#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
224INLINE
225bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
226 { return (a64 == b64) && (a0 == b0); }
227#else
228bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
229#endif
230#endif
231
232#ifndef softfloat_le128
233/*----------------------------------------------------------------------------
234| Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
235| and 'a0' is less than or equal to the 128-bit unsigned integer formed by
236| concatenating 'b64' and 'b0'.
237*----------------------------------------------------------------------------*/
238#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
239INLINE
240bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
241 { return (a64 < b64) || ((a64 == b64) && (a0 <= b0)); }
242#else
243bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
244#endif
245#endif
246
247#ifndef softfloat_lt128
248/*----------------------------------------------------------------------------
249| Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
250| and 'a0' is less than the 128-bit unsigned integer formed by concatenating
251| 'b64' and 'b0'.
252*----------------------------------------------------------------------------*/
253#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
254INLINE
255bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
256 { return (a64 < b64) || ((a64 == b64) && (a0 < b0)); }
257#else
258bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
259#endif
260#endif
261
262#ifndef softfloat_shortShiftLeft128
263/*----------------------------------------------------------------------------
264| Shifts the 128 bits formed by concatenating 'a64' and 'a0' left by the
265| number of bits given in 'dist', which must be in the range 1 to 63.
266*----------------------------------------------------------------------------*/
267#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
268INLINE
269struct uint128
270 softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
271{
272 struct uint128 z;
273 z.v64 = a64<<dist | a0>>(-dist & 63);
274 z.v0 = a0<<dist;
275 return z;
276}
277#else
278struct uint128
279 softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist );
280#endif
281#endif
282
283#ifndef softfloat_shortShiftRight128
284/*----------------------------------------------------------------------------
285| Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
286| number of bits given in 'dist', which must be in the range 1 to 63.
287*----------------------------------------------------------------------------*/
288#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
289INLINE
290struct uint128
291 softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
292{
293 struct uint128 z;
294 z.v64 = a64>>dist;
295 z.v0 = a64<<(-dist & 63) | a0>>dist;
296 return z;
297}
298#else
299struct uint128
300 softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t dist );
301#endif
302#endif
303
304#ifndef softfloat_shortShiftRightJam64Extra
305/*----------------------------------------------------------------------------
306| This function is the same as 'softfloat_shiftRightJam64Extra' (below),
307| except that 'dist' must be in the range 1 to 63.
308*----------------------------------------------------------------------------*/
309#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
310INLINE
311struct uint64_extra
312 softfloat_shortShiftRightJam64Extra(
313 uint64_t a, uint64_t extra, uint_fast8_t dist )
314{
315 struct uint64_extra z;
316 z.v = a>>dist;
317 z.extra = a<<(-dist & 63) | (extra != 0);
318 return z;
319}
320#else
321struct uint64_extra
322 softfloat_shortShiftRightJam64Extra(
323 uint64_t a, uint64_t extra, uint_fast8_t dist );
324#endif
325#endif
326
327#ifndef softfloat_shortShiftRightJam128
328/*----------------------------------------------------------------------------
329| Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
330| number of bits given in 'dist', which must be in the range 1 to 63. If any
331| nonzero bits are shifted off, they are "jammed" into the least-significant
332| bit of the shifted value by setting the least-significant bit to 1. This
333| shifted-and-jammed value is returned.
334*----------------------------------------------------------------------------*/
335#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
336INLINE
337struct uint128
338 softfloat_shortShiftRightJam128(
339 uint64_t a64, uint64_t a0, uint_fast8_t dist )
340{
341 uint_fast8_t negDist = -dist;
342 struct uint128 z;
343 z.v64 = a64>>dist;
344 z.v0 =
345 a64<<(negDist & 63) | a0>>dist
346 | ((uint64_t) (a0<<(negDist & 63)) != 0);
347 return z;
348}
349#else
350struct uint128
351 softfloat_shortShiftRightJam128(
352 uint64_t a64, uint64_t a0, uint_fast8_t dist );
353#endif
354#endif
355
356#ifndef softfloat_shortShiftRightJam128Extra
357/*----------------------------------------------------------------------------
358| This function is the same as 'softfloat_shiftRightJam128Extra' (below),
359| except that 'dist' must be in the range 1 to 63.
360*----------------------------------------------------------------------------*/
361#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
362INLINE
363struct uint128_extra
364 softfloat_shortShiftRightJam128Extra(
365 uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist )
366{
367 uint_fast8_t negDist = -dist;
368 struct uint128_extra z;
369 z.v.v64 = a64>>dist;
370 z.v.v0 = a64<<(negDist & 63) | a0>>dist;
371 z.extra = a0<<(negDist & 63) | (extra != 0);
372 return z;
373}
374#else
375struct uint128_extra
376 softfloat_shortShiftRightJam128Extra(
377 uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist );
378#endif
379#endif
380
381#ifndef softfloat_shiftRightJam64Extra
382/*----------------------------------------------------------------------------
383| Shifts the 128 bits formed by concatenating 'a' and 'extra' right by 64
384| _plus_ the number of bits given in 'dist', which must not be zero. This
385| shifted value is at most 64 nonzero bits and is returned in the 'v' field
386| of the 'struct uint64_extra' result. The 64-bit 'extra' field of the result
387| contains a value formed as follows from the bits that were shifted off: The
388| _last_ bit shifted off is the most-significant bit of the 'extra' field, and
389| the other 63 bits of the 'extra' field are all zero if and only if _all_but_
390| _the_last_ bits shifted off were all zero.
391| (This function makes more sense if 'a' and 'extra' are considered to form
392| an unsigned fixed-point number with binary point between 'a' and 'extra'.
393| This fixed-point value is shifted right by the number of bits given in
394| 'dist', and the integer part of this shifted value is returned in the 'v'
395| field of the result. The fractional part of the shifted value is modified
396| as described above and returned in the 'extra' field of the result.)
397*----------------------------------------------------------------------------*/
398#if defined INLINE_LEVEL && (4 <= INLINE_LEVEL)
399INLINE
400struct uint64_extra
401 softfloat_shiftRightJam64Extra(
402 uint64_t a, uint64_t extra, uint_fast32_t dist )
403{
404 struct uint64_extra z;
405 if ( dist < 64 ) {
406 z.v = a>>dist;
407 z.extra = a<<(-dist & 63);
408 } else {
409 z.v = 0;
410 z.extra = (dist == 64) ? a : (a != 0);
411 }
412 z.extra |= (extra != 0);
413 return z;
414}
415#else
416struct uint64_extra
417 softfloat_shiftRightJam64Extra(
418 uint64_t a, uint64_t extra, uint_fast32_t dist );
419#endif
420#endif
421
422#ifndef softfloat_shiftRightJam128
423/*----------------------------------------------------------------------------
424| Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
425| number of bits given in 'dist', which must not be zero. If any nonzero bits
426| are shifted off, they are "jammed" into the least-significant bit of the
427| shifted value by setting the least-significant bit to 1. This shifted-and-
428| jammed value is returned.
429| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
430| greater than 128, the result will be either 0 or 1, depending on whether the
431| original 128 bits are all zeros.
432*----------------------------------------------------------------------------*/
433struct uint128
434 softfloat_shiftRightJam128( uint64_t a64, uint64_t a0, uint_fast32_t dist );
435#endif
436
437#ifndef softfloat_shiftRightJam128Extra
438/*----------------------------------------------------------------------------
439| Shifts the 192 bits formed by concatenating 'a64', 'a0', and 'extra' right
440| by 64 _plus_ the number of bits given in 'dist', which must not be zero.
441| This shifted value is at most 128 nonzero bits and is returned in the 'v'
442| field of the 'struct uint128_extra' result. The 64-bit 'extra' field of the
443| result contains a value formed as follows from the bits that were shifted
444| off: The _last_ bit shifted off is the most-significant bit of the 'extra'
445| field, and the other 63 bits of the 'extra' field are all zero if and only
446| if _all_but_the_last_ bits shifted off were all zero.
447| (This function makes more sense if 'a64', 'a0', and 'extra' are considered
448| to form an unsigned fixed-point number with binary point between 'a0' and
449| 'extra'. This fixed-point value is shifted right by the number of bits
450| given in 'dist', and the integer part of this shifted value is returned
451| in the 'v' field of the result. The fractional part of the shifted value
452| is modified as described above and returned in the 'extra' field of the
453| result.)
454*----------------------------------------------------------------------------*/
455struct uint128_extra
456 softfloat_shiftRightJam128Extra(
457 uint64_t a64, uint64_t a0, uint64_t extra, uint_fast32_t dist );
458#endif
459
460#ifndef softfloat_shiftRightJam256M
461/*----------------------------------------------------------------------------
462| Shifts the 256-bit unsigned integer pointed to by 'aPtr' right by the number
463| of bits given in 'dist', which must not be zero. If any nonzero bits are
464| shifted off, they are "jammed" into the least-significant bit of the shifted
465| value by setting the least-significant bit to 1. This shifted-and-jammed
466| value is stored at the location pointed to by 'zPtr'. Each of 'aPtr' and
467| 'zPtr' points to an array of four 64-bit elements that concatenate in the
468| platform's normal endian order to form a 256-bit integer.
469| The value of 'dist' can be arbitrarily large. In particular, if 'dist'
470| is greater than 256, the stored result will be either 0 or 1, depending on
471| whether the original 256 bits are all zeros.
472*----------------------------------------------------------------------------*/
473void
474 softfloat_shiftRightJam256M(
475 const uint64_t *aPtr, uint_fast32_t dist, uint64_t *zPtr );
476#endif
477
478#ifndef softfloat_add128
479/*----------------------------------------------------------------------------
480| Returns the sum of the 128-bit integer formed by concatenating 'a64' and
481| 'a0' and the 128-bit integer formed by concatenating 'b64' and 'b0'. The
482| addition is modulo 2^128, so any carry out is lost.
483*----------------------------------------------------------------------------*/
484#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
485INLINE
486struct uint128
487 softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
488{
489 struct uint128 z;
490 z.v0 = a0 + b0;
491 z.v64 = a64 + b64 + (z.v0 < a0);
492 return z;
493}
494#else
495struct uint128
496 softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
497#endif
498#endif
499
500#ifndef softfloat_add256M
501/*----------------------------------------------------------------------------
502| Adds the two 256-bit integers pointed to by 'aPtr' and 'bPtr'. The addition
503| is modulo 2^256, so any carry out is lost. The sum is stored at the
504| location pointed to by 'zPtr'. Each of 'aPtr', 'bPtr', and 'zPtr' points to
505| an array of four 64-bit elements that concatenate in the platform's normal
506| endian order to form a 256-bit integer.
507*----------------------------------------------------------------------------*/
508void
509 softfloat_add256M(
510 const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr );
511#endif
512
513#ifndef softfloat_sub128
514/*----------------------------------------------------------------------------
515| Returns the difference of the 128-bit integer formed by concatenating 'a64'
516| and 'a0' and the 128-bit integer formed by concatenating 'b64' and 'b0'.
517| The subtraction is modulo 2^128, so any borrow out (carry out) is lost.
518*----------------------------------------------------------------------------*/
519#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
520INLINE
521struct uint128
522 softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
523{
524 struct uint128 z;
525 z.v0 = a0 - b0;
526 z.v64 = a64 - b64;
527 z.v64 -= (a0 < b0);
528 return z;
529}
530#else
531struct uint128
532 softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
533#endif
534#endif
535
536#ifndef softfloat_sub256M
537/*----------------------------------------------------------------------------
538| Subtracts the 256-bit integer pointed to by 'bPtr' from the 256-bit integer
539| pointed to by 'aPtr'. The addition is modulo 2^256, so any borrow out
540| (carry out) is lost. The difference is stored at the location pointed to
541| by 'zPtr'. Each of 'aPtr', 'bPtr', and 'zPtr' points to an array of four
542| 64-bit elements that concatenate in the platform's normal endian order to
543| form a 256-bit integer.
544*----------------------------------------------------------------------------*/
545void
546 softfloat_sub256M(
547 const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr );
548#endif
549
550#ifndef softfloat_mul64ByShifted32To128
551/*----------------------------------------------------------------------------
552| Returns the 128-bit product of 'a', 'b', and 2^32.
553*----------------------------------------------------------------------------*/
554#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
555INLINE struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b )
556{
557 uint_fast64_t mid;
558 struct uint128 z;
559 mid = (uint_fast64_t) (uint32_t) a * b;
560 z.v0 = mid<<32;
561 z.v64 = (uint_fast64_t) (uint32_t) (a>>32) * b + (mid>>32);
562 return z;
563}
564#else
565struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b );
566#endif
567#endif
568
569#ifndef softfloat_mul64To128
570/*----------------------------------------------------------------------------
571| Returns the 128-bit product of 'a' and 'b'.
572*----------------------------------------------------------------------------*/
573struct uint128 softfloat_mul64To128( uint64_t a, uint64_t b );
574#endif
575
576#ifndef softfloat_mul128By32
577/*----------------------------------------------------------------------------
578| Returns the product of the 128-bit integer formed by concatenating 'a64' and
579| 'a0', multiplied by 'b'. The multiplication is modulo 2^128; any overflow
580| bits are discarded.
581*----------------------------------------------------------------------------*/
582#if defined INLINE_LEVEL && (4 <= INLINE_LEVEL)
583INLINE
584struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b )
585{
586 struct uint128 z;
587 uint_fast64_t mid;
588 uint_fast32_t carry;
589 z.v0 = a0 * b;
590 mid = (uint_fast64_t) (uint32_t) (a0>>32) * b;
591 carry = (uint32_t) ((uint_fast32_t) (z.v0>>32) - (uint_fast32_t) mid);
592 z.v64 = a64 * b + (uint_fast32_t) ((mid + carry)>>32);
593 return z;
594}
595#else
596struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b );
597#endif
598#endif
599
600#ifndef softfloat_mul128To256M
601/*----------------------------------------------------------------------------
602| Multiplies the 128-bit unsigned integer formed by concatenating 'a64' and
603| 'a0' by the 128-bit unsigned integer formed by concatenating 'b64' and
604| 'b0'. The 256-bit product is stored at the location pointed to by 'zPtr'.
605| Argument 'zPtr' points to an array of four 64-bit elements that concatenate
606| in the platform's normal endian order to form a 256-bit integer.
607*----------------------------------------------------------------------------*/
608void
609 softfloat_mul128To256M(
610 uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0, uint64_t *zPtr );
611#endif
612
613#else
614
615/*----------------------------------------------------------------------------
616| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is not
617| defined.
618*----------------------------------------------------------------------------*/
619
620#ifndef softfloat_compare96M
621/*----------------------------------------------------------------------------
622| Compares the two 96-bit unsigned integers pointed to by 'aPtr' and 'bPtr'.
623| Returns -1 if the first integer (A) is less than the second (B); returns 0
624| if the two integers are equal; and returns +1 if the first integer (A)
625| is greater than the second (B). (The result is thus the signum of A - B.)
626| Each of 'aPtr' and 'bPtr' points to an array of three 32-bit elements that
627| concatenate in the platform's normal endian order to form a 96-bit integer.
628*----------------------------------------------------------------------------*/
629int_fast8_t softfloat_compare96M( const uint32_t *aPtr, const uint32_t *bPtr );
630#endif
631
632#ifndef softfloat_compare128M
633/*----------------------------------------------------------------------------
634| Compares the two 128-bit unsigned integers pointed to by 'aPtr' and 'bPtr'.
635| Returns -1 if the first integer (A) is less than the second (B); returns 0
636| if the two integers are equal; and returns +1 if the first integer (A)
637| is greater than the second (B). (The result is thus the signum of A - B.)
638| Each of 'aPtr' and 'bPtr' points to an array of four 32-bit elements that
639| concatenate in the platform's normal endian order to form a 128-bit integer.
640*----------------------------------------------------------------------------*/
641int_fast8_t
642 softfloat_compare128M( const uint32_t *aPtr, const uint32_t *bPtr );
643#endif
644
645#ifndef softfloat_shortShiftLeft64To96M
646/*----------------------------------------------------------------------------
647| Extends 'a' to 96 bits and shifts the value left by the number of bits given
648| in 'dist', which must be in the range 1 to 31. The result is stored at the
649| location pointed to by 'zPtr'. Argument 'zPtr' points to an array of three
650| 32-bit elements that concatenate in the platform's normal endian order to
651| form a 96-bit integer.
652*----------------------------------------------------------------------------*/
653#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
654INLINE
655void
656 softfloat_shortShiftLeft64To96M(
657 uint64_t a, uint_fast8_t dist, uint32_t *zPtr )
658{
659 zPtr[indexWord( 3, 0 )] = (uint32_t) a<<dist;
660 a >>= 32 - dist;
661 zPtr[indexWord( 3, 2 )] = a>>32;
662 zPtr[indexWord( 3, 1 )] = a;
663}
664#else
665void
666 softfloat_shortShiftLeft64To96M(
667 uint64_t a, uint_fast8_t dist, uint32_t *zPtr );
668#endif
669#endif
670
671#ifndef softfloat_shortShiftLeftM
672/*----------------------------------------------------------------------------
673| Shifts the N-bit unsigned integer pointed to by 'aPtr' left by the number
674| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
675| must be in the range 1 to 31. Any nonzero bits shifted off are lost. The
676| shifted N-bit result is stored at the location pointed to by 'zPtr'. Each
677| of 'aPtr' and 'zPtr' points to a 'size_words'-long array of 32-bit elements
678| that concatenate in the platform's normal endian order to form an N-bit
679| integer.
680*----------------------------------------------------------------------------*/
681void
682 softfloat_shortShiftLeftM(
683 uint_fast8_t size_words,
684 const uint32_t *aPtr,
685 uint_fast8_t dist,
686 uint32_t *zPtr
687 );
688#endif
689
690#ifndef softfloat_shortShiftLeft96M
691/*----------------------------------------------------------------------------
692| This function or macro is the same as 'softfloat_shortShiftLeftM' with
693| 'size_words' = 3 (N = 96).
694*----------------------------------------------------------------------------*/
695#define softfloat_shortShiftLeft96M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 3, aPtr, dist, zPtr )
696#endif
697
698#ifndef softfloat_shortShiftLeft128M
699/*----------------------------------------------------------------------------
700| This function or macro is the same as 'softfloat_shortShiftLeftM' with
701| 'size_words' = 4 (N = 128).
702*----------------------------------------------------------------------------*/
703#define softfloat_shortShiftLeft128M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 4, aPtr, dist, zPtr )
704#endif
705
706#ifndef softfloat_shortShiftLeft160M
707/*----------------------------------------------------------------------------
708| This function or macro is the same as 'softfloat_shortShiftLeftM' with
709| 'size_words' = 5 (N = 160).
710*----------------------------------------------------------------------------*/
711#define softfloat_shortShiftLeft160M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 5, aPtr, dist, zPtr )
712#endif
713
714#ifndef softfloat_shiftLeftM
715/*----------------------------------------------------------------------------
716| Shifts the N-bit unsigned integer pointed to by 'aPtr' left by the number
717| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
718| must not be zero. Any nonzero bits shifted off are lost. The shifted
719| N-bit result is stored at the location pointed to by 'zPtr'. Each of 'aPtr'
720| and 'zPtr' points to a 'size_words'-long array of 32-bit elements that
721| concatenate in the platform's normal endian order to form an N-bit integer.
722| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
723| greater than N, the stored result will be 0.
724*----------------------------------------------------------------------------*/
725void
726 softfloat_shiftLeftM(
727 uint_fast8_t size_words,
728 const uint32_t *aPtr,
729 uint32_t dist,
730 uint32_t *zPtr
731 );
732#endif
733
734#ifndef softfloat_shiftLeft96M
735/*----------------------------------------------------------------------------
736| This function or macro is the same as 'softfloat_shiftLeftM' with
737| 'size_words' = 3 (N = 96).
738*----------------------------------------------------------------------------*/
739#define softfloat_shiftLeft96M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 3, aPtr, dist, zPtr )
740#endif
741
742#ifndef softfloat_shiftLeft128M
743/*----------------------------------------------------------------------------
744| This function or macro is the same as 'softfloat_shiftLeftM' with
745| 'size_words' = 4 (N = 128).
746*----------------------------------------------------------------------------*/
747#define softfloat_shiftLeft128M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 4, aPtr, dist, zPtr )
748#endif
749
750#ifndef softfloat_shiftLeft160M
751/*----------------------------------------------------------------------------
752| This function or macro is the same as 'softfloat_shiftLeftM' with
753| 'size_words' = 5 (N = 160).
754*----------------------------------------------------------------------------*/
755#define softfloat_shiftLeft160M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 5, aPtr, dist, zPtr )
756#endif
757
758#ifndef softfloat_shortShiftRightM
759/*----------------------------------------------------------------------------
760| Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
761| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
762| must be in the range 1 to 31. Any nonzero bits shifted off are lost. The
763| shifted N-bit result is stored at the location pointed to by 'zPtr'. Each
764| of 'aPtr' and 'zPtr' points to a 'size_words'-long array of 32-bit elements
765| that concatenate in the platform's normal endian order to form an N-bit
766| integer.
767*----------------------------------------------------------------------------*/
768void
769 softfloat_shortShiftRightM(
770 uint_fast8_t size_words,
771 const uint32_t *aPtr,
772 uint_fast8_t dist,
773 uint32_t *zPtr
774 );
775#endif
776
777#ifndef softfloat_shortShiftRight128M
778/*----------------------------------------------------------------------------
779| This function or macro is the same as 'softfloat_shortShiftRightM' with
780| 'size_words' = 4 (N = 128).
781*----------------------------------------------------------------------------*/
782#define softfloat_shortShiftRight128M( aPtr, dist, zPtr ) softfloat_shortShiftRightM( 4, aPtr, dist, zPtr )
783#endif
784
785#ifndef softfloat_shortShiftRight160M
786/*----------------------------------------------------------------------------
787| This function or macro is the same as 'softfloat_shortShiftRightM' with
788| 'size_words' = 5 (N = 160).
789*----------------------------------------------------------------------------*/
790#define softfloat_shortShiftRight160M( aPtr, dist, zPtr ) softfloat_shortShiftRightM( 5, aPtr, dist, zPtr )
791#endif
792
793#ifndef softfloat_shortShiftRightJamM
794/*----------------------------------------------------------------------------
795| Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
796| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
797| must be in the range 1 to 31. If any nonzero bits are shifted off, they are
798| "jammed" into the least-significant bit of the shifted value by setting the
799| least-significant bit to 1. This shifted-and-jammed N-bit result is stored
800| at the location pointed to by 'zPtr'. Each of 'aPtr' and 'zPtr' points
801| to a 'size_words'-long array of 32-bit elements that concatenate in the
802| platform's normal endian order to form an N-bit integer.
803*----------------------------------------------------------------------------*/
804void
805 softfloat_shortShiftRightJamM(
806 uint_fast8_t, const uint32_t *, uint_fast8_t, uint32_t * );
807#endif
808
809#ifndef softfloat_shortShiftRightJam160M
810/*----------------------------------------------------------------------------
811| This function or macro is the same as 'softfloat_shortShiftRightJamM' with
812| 'size_words' = 5 (N = 160).
813*----------------------------------------------------------------------------*/
814#define softfloat_shortShiftRightJam160M( aPtr, dist, zPtr ) softfloat_shortShiftRightJamM( 5, aPtr, dist, zPtr )
815#endif
816
817#ifndef softfloat_shiftRightM
818/*----------------------------------------------------------------------------
819| Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
820| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
821| must not be zero. Any nonzero bits shifted off are lost. The shifted
822| N-bit result is stored at the location pointed to by 'zPtr'. Each of 'aPtr'
823| and 'zPtr' points to a 'size_words'-long array of 32-bit elements that
824| concatenate in the platform's normal endian order to form an N-bit integer.
825| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
826| greater than N, the stored result will be 0.
827*----------------------------------------------------------------------------*/
828void
829 softfloat_shiftRightM(
830 uint_fast8_t size_words,
831 const uint32_t *aPtr,
832 uint32_t dist,
833 uint32_t *zPtr
834 );
835#endif
836
837#ifndef softfloat_shiftRight96M
838/*----------------------------------------------------------------------------
839| This function or macro is the same as 'softfloat_shiftRightM' with
840| 'size_words' = 3 (N = 96).
841*----------------------------------------------------------------------------*/
842#define softfloat_shiftRight96M( aPtr, dist, zPtr ) softfloat_shiftRightM( 3, aPtr, dist, zPtr )
843#endif
844
845#ifndef softfloat_shiftRightJamM
846/*----------------------------------------------------------------------------
847| Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
848| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
849| must not be zero. If any nonzero bits are shifted off, they are "jammed"
850| into the least-significant bit of the shifted value by setting the least-
851| significant bit to 1. This shifted-and-jammed N-bit result is stored
852| at the location pointed to by 'zPtr'. Each of 'aPtr' and 'zPtr' points
853| to a 'size_words'-long array of 32-bit elements that concatenate in the
854| platform's normal endian order to form an N-bit integer.
855| The value of 'dist' can be arbitrarily large. In particular, if 'dist'
856| is greater than N, the stored result will be either 0 or 1, depending on
857| whether the original N bits are all zeros.
858*----------------------------------------------------------------------------*/
859void
860 softfloat_shiftRightJamM(
861 uint_fast8_t size_words,
862 const uint32_t *aPtr,
863 uint32_t dist,
864 uint32_t *zPtr
865 );
866#endif
867
868#ifndef softfloat_shiftRightJam96M
869/*----------------------------------------------------------------------------
870| This function or macro is the same as 'softfloat_shiftRightJamM' with
871| 'size_words' = 3 (N = 96).
872*----------------------------------------------------------------------------*/
873#define softfloat_shiftRightJam96M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 3, aPtr, dist, zPtr )
874#endif
875
876#ifndef softfloat_shiftRightJam128M
877/*----------------------------------------------------------------------------
878| This function or macro is the same as 'softfloat_shiftRightJamM' with
879| 'size_words' = 4 (N = 128).
880*----------------------------------------------------------------------------*/
881#define softfloat_shiftRightJam128M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 4, aPtr, dist, zPtr )
882#endif
883
884#ifndef softfloat_shiftRightJam160M
885/*----------------------------------------------------------------------------
886| This function or macro is the same as 'softfloat_shiftRightJamM' with
887| 'size_words' = 5 (N = 160).
888*----------------------------------------------------------------------------*/
889#define softfloat_shiftRightJam160M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 5, aPtr, dist, zPtr )
890#endif
891
892#ifndef softfloat_addM
893/*----------------------------------------------------------------------------
894| Adds the two N-bit integers pointed to by 'aPtr' and 'bPtr', where N =
895| 'size_words' * 32. The addition is modulo 2^N, so any carry out is lost.
896| The N-bit sum is stored at the location pointed to by 'zPtr'. Each of
897| 'aPtr', 'bPtr', and 'zPtr' points to a 'size_words'-long array of 32-bit
898| elements that concatenate in the platform's normal endian order to form an
899| N-bit integer.
900*----------------------------------------------------------------------------*/
901void
902 softfloat_addM(
903 uint_fast8_t size_words,
904 const uint32_t *aPtr,
905 const uint32_t *bPtr,
906 uint32_t *zPtr
907 );
908#endif
909
910#ifndef softfloat_add96M
911/*----------------------------------------------------------------------------
912| This function or macro is the same as 'softfloat_addM' with 'size_words'
913| = 3 (N = 96).
914*----------------------------------------------------------------------------*/
915#define softfloat_add96M( aPtr, bPtr, zPtr ) softfloat_addM( 3, aPtr, bPtr, zPtr )
916#endif
917
918#ifndef softfloat_add128M
919/*----------------------------------------------------------------------------
920| This function or macro is the same as 'softfloat_addM' with 'size_words'
921| = 4 (N = 128).
922*----------------------------------------------------------------------------*/
923#define softfloat_add128M( aPtr, bPtr, zPtr ) softfloat_addM( 4, aPtr, bPtr, zPtr )
924#endif
925
926#ifndef softfloat_add160M
927/*----------------------------------------------------------------------------
928| This function or macro is the same as 'softfloat_addM' with 'size_words'
929| = 5 (N = 160).
930*----------------------------------------------------------------------------*/
931#define softfloat_add160M( aPtr, bPtr, zPtr ) softfloat_addM( 5, aPtr, bPtr, zPtr )
932#endif
933
934#ifndef softfloat_addCarryM
935/*----------------------------------------------------------------------------
936| Adds the two N-bit unsigned integers pointed to by 'aPtr' and 'bPtr', where
937| N = 'size_words' * 32, plus 'carry', which must be either 0 or 1. The N-bit
938| sum (modulo 2^N) is stored at the location pointed to by 'zPtr', and any
939| carry out is returned as the result. Each of 'aPtr', 'bPtr', and 'zPtr'
940| points to a 'size_words'-long array of 32-bit elements that concatenate in
941| the platform's normal endian order to form an N-bit integer.
942*----------------------------------------------------------------------------*/
943uint_fast8_t
944 softfloat_addCarryM(
945 uint_fast8_t size_words,
946 const uint32_t *aPtr,
947 const uint32_t *bPtr,
948 uint_fast8_t carry,
949 uint32_t *zPtr
950 );
951#endif
952
953#ifndef softfloat_addComplCarryM
954/*----------------------------------------------------------------------------
955| This function or macro is the same as 'softfloat_addCarryM', except that
956| the value of the unsigned integer pointed to by 'bPtr' is bit-wise completed
957| before the addition.
958*----------------------------------------------------------------------------*/
959uint_fast8_t
960 softfloat_addComplCarryM(
961 uint_fast8_t size_words,
962 const uint32_t *aPtr,
963 const uint32_t *bPtr,
964 uint_fast8_t carry,
965 uint32_t *zPtr
966 );
967#endif
968
969#ifndef softfloat_addComplCarry96M
970/*----------------------------------------------------------------------------
971| This function or macro is the same as 'softfloat_addComplCarryM' with
972| 'size_words' = 3 (N = 96).
973*----------------------------------------------------------------------------*/
974#define softfloat_addComplCarry96M( aPtr, bPtr, carry, zPtr ) softfloat_addComplCarryM( 3, aPtr, bPtr, carry, zPtr )
975#endif
976
977#ifndef softfloat_negXM
978/*----------------------------------------------------------------------------
979| Replaces the N-bit unsigned integer pointed to by 'zPtr' by the
980| 2s-complement of itself, where N = 'size_words' * 32. Argument 'zPtr'
981| points to a 'size_words'-long array of 32-bit elements that concatenate in
982| the platform's normal endian order to form an N-bit integer.
983*----------------------------------------------------------------------------*/
984void softfloat_negXM( uint_fast8_t size_words, uint32_t *zPtr );
985#endif
986
987#ifndef softfloat_negX96M
988/*----------------------------------------------------------------------------
989| This function or macro is the same as 'softfloat_negXM' with 'size_words'
990| = 3 (N = 96).
991*----------------------------------------------------------------------------*/
992#define softfloat_negX96M( zPtr ) softfloat_negXM( 3, zPtr )
993#endif
994
995#ifndef softfloat_negX128M
996/*----------------------------------------------------------------------------
997| This function or macro is the same as 'softfloat_negXM' with 'size_words'
998| = 4 (N = 128).
999*----------------------------------------------------------------------------*/
1000#define softfloat_negX128M( zPtr ) softfloat_negXM( 4, zPtr )
1001#endif
1002
1003#ifndef softfloat_negX160M
1004/*----------------------------------------------------------------------------
1005| This function or macro is the same as 'softfloat_negXM' with 'size_words'
1006| = 5 (N = 160).
1007*----------------------------------------------------------------------------*/
1008#define softfloat_negX160M( zPtr ) softfloat_negXM( 5, zPtr )
1009#endif
1010
1011#ifndef softfloat_negX256M
1012/*----------------------------------------------------------------------------
1013| This function or macro is the same as 'softfloat_negXM' with 'size_words'
1014| = 8 (N = 256).
1015*----------------------------------------------------------------------------*/
1016#define softfloat_negX256M( zPtr ) softfloat_negXM( 8, zPtr )
1017#endif
1018
1019#ifndef softfloat_sub1XM
1020/*----------------------------------------------------------------------------
1021| Subtracts 1 from the N-bit integer pointed to by 'zPtr', where N =
1022| 'size_words' * 32. The subtraction is modulo 2^N, so any borrow out (carry
1023| out) is lost. Argument 'zPtr' points to a 'size_words'-long array of 32-bit
1024| elements that concatenate in the platform's normal endian order to form an
1025| N-bit integer.
1026*----------------------------------------------------------------------------*/
1027void softfloat_sub1XM( uint_fast8_t size_words, uint32_t *zPtr );
1028#endif
1029
1030#ifndef softfloat_sub1X96M
1031/*----------------------------------------------------------------------------
1032| This function or macro is the same as 'softfloat_sub1XM' with 'size_words'
1033| = 3 (N = 96).
1034*----------------------------------------------------------------------------*/
1035#define softfloat_sub1X96M( zPtr ) softfloat_sub1XM( 3, zPtr )
1036#endif
1037
1038#ifndef softfloat_sub1X160M
1039/*----------------------------------------------------------------------------
1040| This function or macro is the same as 'softfloat_sub1XM' with 'size_words'
1041| = 5 (N = 160).
1042*----------------------------------------------------------------------------*/
1043#define softfloat_sub1X160M( zPtr ) softfloat_sub1XM( 5, zPtr )
1044#endif
1045
1046#ifndef softfloat_subM
1047/*----------------------------------------------------------------------------
1048| Subtracts the two N-bit integers pointed to by 'aPtr' and 'bPtr', where N =
1049| 'size_words' * 32. The subtraction is modulo 2^N, so any borrow out (carry
1050| out) is lost. The N-bit difference is stored at the location pointed to by
1051| 'zPtr'. Each of 'aPtr', 'bPtr', and 'zPtr' points to a 'size_words'-long
1052| array of 32-bit elements that concatenate in the platform's normal endian
1053| order to form an N-bit integer.
1054*----------------------------------------------------------------------------*/
1055void
1056 softfloat_subM(
1057 uint_fast8_t size_words,
1058 const uint32_t *aPtr,
1059 const uint32_t *bPtr,
1060 uint32_t *zPtr
1061 );
1062#endif
1063
1064#ifndef softfloat_sub96M
1065/*----------------------------------------------------------------------------
1066| This function or macro is the same as 'softfloat_subM' with 'size_words'
1067| = 3 (N = 96).
1068*----------------------------------------------------------------------------*/
1069#define softfloat_sub96M( aPtr, bPtr, zPtr ) softfloat_subM( 3, aPtr, bPtr, zPtr )
1070#endif
1071
1072#ifndef softfloat_sub128M
1073/*----------------------------------------------------------------------------
1074| This function or macro is the same as 'softfloat_subM' with 'size_words'
1075| = 4 (N = 128).
1076*----------------------------------------------------------------------------*/
1077#define softfloat_sub128M( aPtr, bPtr, zPtr ) softfloat_subM( 4, aPtr, bPtr, zPtr )
1078#endif
1079
1080#ifndef softfloat_sub160M
1081/*----------------------------------------------------------------------------
1082| This function or macro is the same as 'softfloat_subM' with 'size_words'
1083| = 5 (N = 160).
1084*----------------------------------------------------------------------------*/
1085#define softfloat_sub160M( aPtr, bPtr, zPtr ) softfloat_subM( 5, aPtr, bPtr, zPtr )
1086#endif
1087
1088#ifndef softfloat_mul64To128M
1089/*----------------------------------------------------------------------------
1090| Multiplies 'a' and 'b' and stores the 128-bit product at the location
1091| pointed to by 'zPtr'. Argument 'zPtr' points to an array of four 32-bit
1092| elements that concatenate in the platform's normal endian order to form a
1093| 128-bit integer.
1094*----------------------------------------------------------------------------*/
1095void softfloat_mul64To128M( uint64_t a, uint64_t b, uint32_t *zPtr );
1096#endif
1097
1098#ifndef softfloat_mul128MTo256M
1099/*----------------------------------------------------------------------------
1100| Multiplies the two 128-bit unsigned integers pointed to by 'aPtr' and
1101| 'bPtr', and stores the 256-bit product at the location pointed to by 'zPtr'.
1102| Each of 'aPtr' and 'bPtr' points to an array of four 32-bit elements that
1103| concatenate in the platform's normal endian order to form a 128-bit integer.
1104| Argument 'zPtr' points to an array of eight 32-bit elements that concatenate
1105| to form a 256-bit integer.
1106*----------------------------------------------------------------------------*/
1107void
1108 softfloat_mul128MTo256M(
1109 const uint32_t *aPtr, const uint32_t *bPtr, uint32_t *zPtr );
1110#endif
1111
1112#ifndef softfloat_remStepMBy32
1113/*----------------------------------------------------------------------------
1114| Performs a "remainder reduction step" as follows: Arguments 'remPtr' and
1115| 'bPtr' both point to N-bit unsigned integers, where N = 'size_words' * 32.
1116| Defining R and B as the values of those integers, the expression (R<<'dist')
1117| - B * q is computed modulo 2^N, and the N-bit result is stored at the
1118| location pointed to by 'zPtr'. Each of 'remPtr', 'bPtr', and 'zPtr' points
1119| to a 'size_words'-long array of 32-bit elements that concatenate in the
1120| platform's normal endian order to form an N-bit integer.
1121*----------------------------------------------------------------------------*/
1122void
1123 softfloat_remStepMBy32(
1124 uint_fast8_t size_words,
1125 const uint32_t *remPtr,
1126 uint_fast8_t dist,
1127 const uint32_t *bPtr,
1128 uint32_t q,
1129 uint32_t *zPtr
1130 );
1131#endif
1132
1133#ifndef softfloat_remStep96MBy32
1134/*----------------------------------------------------------------------------
1135| This function or macro is the same as 'softfloat_remStepMBy32' with
1136| 'size_words' = 3 (N = 96).
1137*----------------------------------------------------------------------------*/
1138#define softfloat_remStep96MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 3, remPtr, dist, bPtr, q, zPtr )
1139#endif
1140
1141#ifndef softfloat_remStep128MBy32
1142/*----------------------------------------------------------------------------
1143| This function or macro is the same as 'softfloat_remStepMBy32' with
1144| 'size_words' = 4 (N = 128).
1145*----------------------------------------------------------------------------*/
1146#define softfloat_remStep128MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 4, remPtr, dist, bPtr, q, zPtr )
1147#endif
1148
1149#ifndef softfloat_remStep160MBy32
1150/*----------------------------------------------------------------------------
1151| This function or macro is the same as 'softfloat_remStepMBy32' with
1152| 'size_words' = 5 (N = 160).
1153*----------------------------------------------------------------------------*/
1154#define softfloat_remStep160MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 5, remPtr, dist, bPtr, q, zPtr )
1155#endif
1156
1157#endif
1158
1159#endif
1160
deps/SoftFloat-3e/source/include/softfloat.h created+372
......@@ -0,0 +1,372 @@
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37
38/*============================================================================
39| Note: If SoftFloat is made available as a general library for programs to
40| use, it is strongly recommended that a platform-specific version of this
41| header, "softfloat.h", be created that folds in "softfloat_types.h" and that
42| eliminates all dependencies on compile-time macros.
43*============================================================================*/
44
45
46#ifndef softfloat_h
47#define softfloat_h 1
48
49#include <stdbool.h>
50#include <stdint.h>
51#include "softfloat_types.h"
52
53#ifndef THREAD_LOCAL
54#define THREAD_LOCAL
55#endif
56
57/*----------------------------------------------------------------------------
58| Software floating-point underflow tininess-detection mode.
59*----------------------------------------------------------------------------*/
60extern THREAD_LOCAL uint_fast8_t softfloat_detectTininess;
61enum {
62 softfloat_tininess_beforeRounding = 0,
63 softfloat_tininess_afterRounding = 1
64};
65
66/*----------------------------------------------------------------------------
67| Software floating-point rounding mode. (Mode "odd" is supported only if
68| SoftFloat is compiled with macro 'SOFTFLOAT_ROUND_ODD' defined.)
69*----------------------------------------------------------------------------*/
70extern THREAD_LOCAL uint_fast8_t softfloat_roundingMode;
71enum {
72 softfloat_round_near_even = 0,
73 softfloat_round_minMag = 1,
74 softfloat_round_min = 2,
75 softfloat_round_max = 3,
76 softfloat_round_near_maxMag = 4,
77 softfloat_round_odd = 6
78};
79
80/*----------------------------------------------------------------------------
81| Software floating-point exception flags.
82*----------------------------------------------------------------------------*/
83extern THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags;
84enum {
85 softfloat_flag_inexact = 1,
86 softfloat_flag_underflow = 2,
87 softfloat_flag_overflow = 4,
88 softfloat_flag_infinite = 8,
89 softfloat_flag_invalid = 16
90};
91
92/*----------------------------------------------------------------------------
93| Routine to raise any or all of the software floating-point exception flags.
94*----------------------------------------------------------------------------*/
95void softfloat_raiseFlags( uint_fast8_t );
96
97/*----------------------------------------------------------------------------
98| Integer-to-floating-point conversion routines.
99*----------------------------------------------------------------------------*/
100float16_t ui32_to_f16( uint32_t );
101float32_t ui32_to_f32( uint32_t );
102float64_t ui32_to_f64( uint32_t );
103#ifdef SOFTFLOAT_FAST_INT64
104extFloat80_t ui32_to_extF80( uint32_t );
105float128_t ui32_to_f128( uint32_t );
106#endif
107void ui32_to_extF80M( uint32_t, extFloat80_t * );
108void ui32_to_f128M( uint32_t, float128_t * );
109float16_t ui64_to_f16( uint64_t );
110float32_t ui64_to_f32( uint64_t );
111float64_t ui64_to_f64( uint64_t );
112#ifdef SOFTFLOAT_FAST_INT64
113extFloat80_t ui64_to_extF80( uint64_t );
114float128_t ui64_to_f128( uint64_t );
115#endif
116void ui64_to_extF80M( uint64_t, extFloat80_t * );
117void ui64_to_f128M( uint64_t, float128_t * );
118float16_t i32_to_f16( int32_t );
119float32_t i32_to_f32( int32_t );
120float64_t i32_to_f64( int32_t );
121#ifdef SOFTFLOAT_FAST_INT64
122extFloat80_t i32_to_extF80( int32_t );
123float128_t i32_to_f128( int32_t );
124#endif
125void i32_to_extF80M( int32_t, extFloat80_t * );
126void i32_to_f128M( int32_t, float128_t * );
127float16_t i64_to_f16( int64_t );
128float32_t i64_to_f32( int64_t );
129float64_t i64_to_f64( int64_t );
130#ifdef SOFTFLOAT_FAST_INT64
131extFloat80_t i64_to_extF80( int64_t );
132float128_t i64_to_f128( int64_t );
133#endif
134void i64_to_extF80M( int64_t, extFloat80_t * );
135void i64_to_f128M( int64_t, float128_t * );
136
137/*----------------------------------------------------------------------------
138| 16-bit (half-precision) floating-point operations.
139*----------------------------------------------------------------------------*/
140uint_fast32_t f16_to_ui32( float16_t, uint_fast8_t, bool );
141uint_fast64_t f16_to_ui64( float16_t, uint_fast8_t, bool );
142int_fast32_t f16_to_i32( float16_t, uint_fast8_t, bool );
143int_fast64_t f16_to_i64( float16_t, uint_fast8_t, bool );
144uint_fast32_t f16_to_ui32_r_minMag( float16_t, bool );
145uint_fast64_t f16_to_ui64_r_minMag( float16_t, bool );
146int_fast32_t f16_to_i32_r_minMag( float16_t, bool );
147int_fast64_t f16_to_i64_r_minMag( float16_t, bool );
148float32_t f16_to_f32( float16_t );
149float64_t f16_to_f64( float16_t );
150#ifdef SOFTFLOAT_FAST_INT64
151extFloat80_t f16_to_extF80( float16_t );
152float128_t f16_to_f128( float16_t );
153#endif
154void f16_to_extF80M( float16_t, extFloat80_t * );
155void f16_to_f128M( float16_t, float128_t * );
156float16_t f16_roundToInt( float16_t, uint_fast8_t, bool );
157float16_t f16_add( float16_t, float16_t );
158float16_t f16_sub( float16_t, float16_t );
159float16_t f16_mul( float16_t, float16_t );
160float16_t f16_mulAdd( float16_t, float16_t, float16_t );
161float16_t f16_div( float16_t, float16_t );
162float16_t f16_rem( float16_t, float16_t );
163float16_t f16_sqrt( float16_t );
164bool f16_eq( float16_t, float16_t );
165bool f16_le( float16_t, float16_t );
166bool f16_lt( float16_t, float16_t );
167bool f16_eq_signaling( float16_t, float16_t );
168bool f16_le_quiet( float16_t, float16_t );
169bool f16_lt_quiet( float16_t, float16_t );
170bool f16_isSignalingNaN( float16_t );
171
172/*----------------------------------------------------------------------------
173| 32-bit (single-precision) floating-point operations.
174*----------------------------------------------------------------------------*/
175uint_fast32_t f32_to_ui32( float32_t, uint_fast8_t, bool );
176uint_fast64_t f32_to_ui64( float32_t, uint_fast8_t, bool );
177int_fast32_t f32_to_i32( float32_t, uint_fast8_t, bool );
178int_fast64_t f32_to_i64( float32_t, uint_fast8_t, bool );
179uint_fast32_t f32_to_ui32_r_minMag( float32_t, bool );
180uint_fast64_t f32_to_ui64_r_minMag( float32_t, bool );
181int_fast32_t f32_to_i32_r_minMag( float32_t, bool );
182int_fast64_t f32_to_i64_r_minMag( float32_t, bool );
183float16_t f32_to_f16( float32_t );
184float64_t f32_to_f64( float32_t );
185#ifdef SOFTFLOAT_FAST_INT64
186extFloat80_t f32_to_extF80( float32_t );
187float128_t f32_to_f128( float32_t );
188#endif
189void f32_to_extF80M( float32_t, extFloat80_t * );
190void f32_to_f128M( float32_t, float128_t * );
191float32_t f32_roundToInt( float32_t, uint_fast8_t, bool );
192float32_t f32_add( float32_t, float32_t );
193float32_t f32_sub( float32_t, float32_t );
194float32_t f32_mul( float32_t, float32_t );
195float32_t f32_mulAdd( float32_t, float32_t, float32_t );
196float32_t f32_div( float32_t, float32_t );
197float32_t f32_rem( float32_t, float32_t );
198float32_t f32_sqrt( float32_t );
199bool f32_eq( float32_t, float32_t );
200bool f32_le( float32_t, float32_t );
201bool f32_lt( float32_t, float32_t );
202bool f32_eq_signaling( float32_t, float32_t );
203bool f32_le_quiet( float32_t, float32_t );
204bool f32_lt_quiet( float32_t, float32_t );
205bool f32_isSignalingNaN( float32_t );
206
207/*----------------------------------------------------------------------------
208| 64-bit (double-precision) floating-point operations.
209*----------------------------------------------------------------------------*/
210uint_fast32_t f64_to_ui32( float64_t, uint_fast8_t, bool );
211uint_fast64_t f64_to_ui64( float64_t, uint_fast8_t, bool );
212int_fast32_t f64_to_i32( float64_t, uint_fast8_t, bool );
213int_fast64_t f64_to_i64( float64_t, uint_fast8_t, bool );
214uint_fast32_t f64_to_ui32_r_minMag( float64_t, bool );
215uint_fast64_t f64_to_ui64_r_minMag( float64_t, bool );
216int_fast32_t f64_to_i32_r_minMag( float64_t, bool );
217int_fast64_t f64_to_i64_r_minMag( float64_t, bool );
218float16_t f64_to_f16( float64_t );
219float32_t f64_to_f32( float64_t );
220#ifdef SOFTFLOAT_FAST_INT64
221extFloat80_t f64_to_extF80( float64_t );
222float128_t f64_to_f128( float64_t );
223#endif
224void f64_to_extF80M( float64_t, extFloat80_t * );
225void f64_to_f128M( float64_t, float128_t * );
226float64_t f64_roundToInt( float64_t, uint_fast8_t, bool );
227float64_t f64_add( float64_t, float64_t );
228float64_t f64_sub( float64_t, float64_t );
229float64_t f64_mul( float64_t, float64_t );
230float64_t f64_mulAdd( float64_t, float64_t, float64_t );
231float64_t f64_div( float64_t, float64_t );
232float64_t f64_rem( float64_t, float64_t );
233float64_t f64_sqrt( float64_t );
234bool f64_eq( float64_t, float64_t );
235bool f64_le( float64_t, float64_t );
236bool f64_lt( float64_t, float64_t );
237bool f64_eq_signaling( float64_t, float64_t );
238bool f64_le_quiet( float64_t, float64_t );
239bool f64_lt_quiet( float64_t, float64_t );
240bool f64_isSignalingNaN( float64_t );
241
242/*----------------------------------------------------------------------------
243| Rounding precision for 80-bit extended double-precision floating-point.
244| Valid values are 32, 64, and 80.
245*----------------------------------------------------------------------------*/
246extern THREAD_LOCAL uint_fast8_t extF80_roundingPrecision;
247
248/*----------------------------------------------------------------------------
249| 80-bit extended double-precision floating-point operations.
250*----------------------------------------------------------------------------*/
251#ifdef SOFTFLOAT_FAST_INT64
252uint_fast32_t extF80_to_ui32( extFloat80_t, uint_fast8_t, bool );
253uint_fast64_t extF80_to_ui64( extFloat80_t, uint_fast8_t, bool );
254int_fast32_t extF80_to_i32( extFloat80_t, uint_fast8_t, bool );
255int_fast64_t extF80_to_i64( extFloat80_t, uint_fast8_t, bool );
256uint_fast32_t extF80_to_ui32_r_minMag( extFloat80_t, bool );
257uint_fast64_t extF80_to_ui64_r_minMag( extFloat80_t, bool );
258int_fast32_t extF80_to_i32_r_minMag( extFloat80_t, bool );
259int_fast64_t extF80_to_i64_r_minMag( extFloat80_t, bool );
260float16_t extF80_to_f16( extFloat80_t );
261float32_t extF80_to_f32( extFloat80_t );
262float64_t extF80_to_f64( extFloat80_t );
263float128_t extF80_to_f128( extFloat80_t );
264extFloat80_t extF80_roundToInt( extFloat80_t, uint_fast8_t, bool );
265extFloat80_t extF80_add( extFloat80_t, extFloat80_t );
266extFloat80_t extF80_sub( extFloat80_t, extFloat80_t );
267extFloat80_t extF80_mul( extFloat80_t, extFloat80_t );
268extFloat80_t extF80_div( extFloat80_t, extFloat80_t );
269extFloat80_t extF80_rem( extFloat80_t, extFloat80_t );
270extFloat80_t extF80_sqrt( extFloat80_t );
271bool extF80_eq( extFloat80_t, extFloat80_t );
272bool extF80_le( extFloat80_t, extFloat80_t );
273bool extF80_lt( extFloat80_t, extFloat80_t );
274bool extF80_eq_signaling( extFloat80_t, extFloat80_t );
275bool extF80_le_quiet( extFloat80_t, extFloat80_t );
276bool extF80_lt_quiet( extFloat80_t, extFloat80_t );
277bool extF80_isSignalingNaN( extFloat80_t );
278#endif
279uint_fast32_t extF80M_to_ui32( const extFloat80_t *, uint_fast8_t, bool );
280uint_fast64_t extF80M_to_ui64( const extFloat80_t *, uint_fast8_t, bool );
281int_fast32_t extF80M_to_i32( const extFloat80_t *, uint_fast8_t, bool );
282int_fast64_t extF80M_to_i64( const extFloat80_t *, uint_fast8_t, bool );
283uint_fast32_t extF80M_to_ui32_r_minMag( const extFloat80_t *, bool );
284uint_fast64_t extF80M_to_ui64_r_minMag( const extFloat80_t *, bool );
285int_fast32_t extF80M_to_i32_r_minMag( const extFloat80_t *, bool );
286int_fast64_t extF80M_to_i64_r_minMag( const extFloat80_t *, bool );
287float16_t extF80M_to_f16( const extFloat80_t * );
288float32_t extF80M_to_f32( const extFloat80_t * );
289float64_t extF80M_to_f64( const extFloat80_t * );
290void extF80M_to_f128M( const extFloat80_t *, float128_t * );
291void
292 extF80M_roundToInt(
293 const extFloat80_t *, uint_fast8_t, bool, extFloat80_t * );
294void extF80M_add( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
295void extF80M_sub( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
296void extF80M_mul( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
297void extF80M_div( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
298void extF80M_rem( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
299void extF80M_sqrt( const extFloat80_t *, extFloat80_t * );
300bool extF80M_eq( const extFloat80_t *, const extFloat80_t * );
301bool extF80M_le( const extFloat80_t *, const extFloat80_t * );
302bool extF80M_lt( const extFloat80_t *, const extFloat80_t * );
303bool extF80M_eq_signaling( const extFloat80_t *, const extFloat80_t * );
304bool extF80M_le_quiet( const extFloat80_t *, const extFloat80_t * );
305bool extF80M_lt_quiet( const extFloat80_t *, const extFloat80_t * );
306bool extF80M_isSignalingNaN( const extFloat80_t * );
307
308/*----------------------------------------------------------------------------
309| 128-bit (quadruple-precision) floating-point operations.
310*----------------------------------------------------------------------------*/
311#ifdef SOFTFLOAT_FAST_INT64
312uint_fast32_t f128_to_ui32( float128_t, uint_fast8_t, bool );
313uint_fast64_t f128_to_ui64( float128_t, uint_fast8_t, bool );
314int_fast32_t f128_to_i32( float128_t, uint_fast8_t, bool );
315int_fast64_t f128_to_i64( float128_t, uint_fast8_t, bool );
316uint_fast32_t f128_to_ui32_r_minMag( float128_t, bool );
317uint_fast64_t f128_to_ui64_r_minMag( float128_t, bool );
318int_fast32_t f128_to_i32_r_minMag( float128_t, bool );
319int_fast64_t f128_to_i64_r_minMag( float128_t, bool );
320float16_t f128_to_f16( float128_t );
321float32_t f128_to_f32( float128_t );
322float64_t f128_to_f64( float128_t );
323extFloat80_t f128_to_extF80( float128_t );
324float128_t f128_roundToInt( float128_t, uint_fast8_t, bool );
325float128_t f128_add( float128_t, float128_t );
326float128_t f128_sub( float128_t, float128_t );
327float128_t f128_mul( float128_t, float128_t );
328float128_t f128_mulAdd( float128_t, float128_t, float128_t );
329float128_t f128_div( float128_t, float128_t );
330float128_t f128_rem( float128_t, float128_t );
331float128_t f128_sqrt( float128_t );
332bool f128_eq( float128_t, float128_t );
333bool f128_le( float128_t, float128_t );
334bool f128_lt( float128_t, float128_t );
335bool f128_eq_signaling( float128_t, float128_t );
336bool f128_le_quiet( float128_t, float128_t );
337bool f128_lt_quiet( float128_t, float128_t );
338bool f128_isSignalingNaN( float128_t );
339#endif
340uint_fast32_t f128M_to_ui32( const float128_t *, uint_fast8_t, bool );
341uint_fast64_t f128M_to_ui64( const float128_t *, uint_fast8_t, bool );
342int_fast32_t f128M_to_i32( const float128_t *, uint_fast8_t, bool );
343int_fast64_t f128M_to_i64( const float128_t *, uint_fast8_t, bool );
344uint_fast32_t f128M_to_ui32_r_minMag( const float128_t *, bool );
345uint_fast64_t f128M_to_ui64_r_minMag( const float128_t *, bool );
346int_fast32_t f128M_to_i32_r_minMag( const float128_t *, bool );
347int_fast64_t f128M_to_i64_r_minMag( const float128_t *, bool );
348float16_t f128M_to_f16( const float128_t * );
349float32_t f128M_to_f32( const float128_t * );
350float64_t f128M_to_f64( const float128_t * );
351void f128M_to_extF80M( const float128_t *, extFloat80_t * );
352void f128M_roundToInt( const float128_t *, uint_fast8_t, bool, float128_t * );
353void f128M_add( const float128_t *, const float128_t *, float128_t * );
354void f128M_sub( const float128_t *, const float128_t *, float128_t * );
355void f128M_mul( const float128_t *, const float128_t *, float128_t * );
356void
357 f128M_mulAdd(
358 const float128_t *, const float128_t *, const float128_t *, float128_t *
359 );
360void f128M_div( const float128_t *, const float128_t *, float128_t * );
361void f128M_rem( const float128_t *, const float128_t *, float128_t * );
362void f128M_sqrt( const float128_t *, float128_t * );
363bool f128M_eq( const float128_t *, const float128_t * );
364bool f128M_le( const float128_t *, const float128_t * );
365bool f128M_lt( const float128_t *, const float128_t * );
366bool f128M_eq_signaling( const float128_t *, const float128_t * );
367bool f128M_le_quiet( const float128_t *, const float128_t * );
368bool f128M_lt_quiet( const float128_t *, const float128_t * );
369bool f128M_isSignalingNaN( const float128_t * );
370
371#endif
372
deps/SoftFloat-3e/source/include/softfloat_types.h created+81
......@@ -0,0 +1,81 @@
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#ifndef softfloat_types_h
38#define softfloat_types_h 1
39
40#include <stdint.h>
41
42/*----------------------------------------------------------------------------
43| Types used to pass 16-bit, 32-bit, 64-bit, and 128-bit floating-point
44| arguments and results to/from functions. These types must be exactly
45| 16 bits, 32 bits, 64 bits, and 128 bits in size, respectively. Where a
46| platform has "native" support for IEEE-Standard floating-point formats,
47| the types below may, if desired, be defined as aliases for the native types
48| (typically 'float' and 'double', and possibly 'long double').
49*----------------------------------------------------------------------------*/
50typedef struct { uint16_t v; } float16_t;
51typedef struct { uint32_t v; } float32_t;
52typedef struct { uint64_t v; } float64_t;
53typedef struct { uint64_t v[2]; } float128_t;
54
55/*----------------------------------------------------------------------------
56| The format of an 80-bit extended floating-point number in memory. This
57| structure must contain a 16-bit field named 'signExp' and a 64-bit field
58| named 'signif'.
59*----------------------------------------------------------------------------*/
60#ifdef LITTLEENDIAN
61struct extFloat80M { uint64_t signif; uint16_t signExp; };
62#else
63struct extFloat80M { uint16_t signExp; uint64_t signif; };
64#endif
65
66/*----------------------------------------------------------------------------
67| The type used to pass 80-bit extended floating-point arguments and
68| results to/from functions. This type must have size identical to
69| 'struct extFloat80M'. Type 'extFloat80_t' can be defined as an alias for
70| 'struct extFloat80M'. Alternatively, if a platform has "native" support
71| for IEEE-Standard 80-bit extended floating-point, it may be possible,
72| if desired, to define 'extFloat80_t' as an alias for the native type
73| (presumably either 'long double' or a nonstandard compiler-intrinsic type).
74| In that case, the 'signif' and 'signExp' fields of 'struct extFloat80M'
75| must align exactly with the locations in memory of the sign, exponent, and
76| significand of the native type.
77*----------------------------------------------------------------------------*/
78typedef struct extFloat80M extFloat80_t;
79
80#endif
81
deps/SoftFloat-3e/source/s_add128.c created+55
......@@ -0,0 +1,55 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_add128
42
43struct uint128
44 softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
45{
46 struct uint128 z;
47
48 z.v0 = a0 + b0;
49 z.v64 = a64 + b64 + (z.v0 < a0);
50 return z;
51
52}
53
54#endif
55
deps/SoftFloat-3e/source/s_add256M.c created+65
......@@ -0,0 +1,65 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_add256M
42
43void
44 softfloat_add256M(
45 const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr )
46{
47 unsigned int index;
48 uint_fast8_t carry;
49 uint64_t wordA, wordZ;
50
51 index = indexWordLo( 4 );
52 carry = 0;
53 for (;;) {
54 wordA = aPtr[index];
55 wordZ = wordA + bPtr[index] + carry;
56 zPtr[index] = wordZ;
57 if ( index == indexWordHi( 4 ) ) break;
58 if ( wordZ != wordA ) carry = (wordZ < wordA);
59 index += wordIncr;
60 }
61
62}
63
64#endif
65
deps/SoftFloat-3e/source/s_addCarryM.c created+70
......@@ -0,0 +1,70 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_addCarryM
42
43uint_fast8_t
44 softfloat_addCarryM(
45 uint_fast8_t size_words,
46 const uint32_t *aPtr,
47 const uint32_t *bPtr,
48 uint_fast8_t carry,
49 uint32_t *zPtr
50 )
51{
52 unsigned int index, lastIndex;
53 uint32_t wordA, wordZ;
54
55 index = indexWordLo( size_words );
56 lastIndex = indexWordHi( size_words );
57 for (;;) {
58 wordA = aPtr[index];
59 wordZ = wordA + bPtr[index] + carry;
60 zPtr[index] = wordZ;
61 if ( wordZ != wordA ) carry = (wordZ < wordA);
62 if ( index == lastIndex ) break;
63 index += wordIncr;
64 }
65 return carry;
66
67}
68
69#endif
70
deps/SoftFloat-3e/source/s_addComplCarryM.c created+70
......@@ -0,0 +1,70 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_addComplCarryM
42
43uint_fast8_t
44 softfloat_addComplCarryM(
45 uint_fast8_t size_words,
46 const uint32_t *aPtr,
47 const uint32_t *bPtr,
48 uint_fast8_t carry,
49 uint32_t *zPtr
50 )
51{
52 unsigned int index, lastIndex;
53 uint32_t wordA, wordZ;
54
55 index = indexWordLo( size_words );
56 lastIndex = indexWordHi( size_words );
57 for (;;) {
58 wordA = aPtr[index];
59 wordZ = wordA + ~bPtr[index] + carry;
60 zPtr[index] = wordZ;
61 if ( wordZ != wordA ) carry = (wordZ < wordA);
62 if ( index == lastIndex ) break;
63 index += wordIncr;
64 }
65 return carry;
66
67}
68
69#endif
70
deps/SoftFloat-3e/source/s_addExtF80M.c created+186
......@@ -0,0 +1,186 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44void
45 softfloat_addExtF80M(
46 const struct extFloat80M *aSPtr,
47 const struct extFloat80M *bSPtr,
48 struct extFloat80M *zSPtr,
49 bool negateB
50 )
51{
52 uint32_t uiA64;
53 int32_t expA;
54 uint32_t uiB64;
55 int32_t expB;
56 uint32_t uiZ64;
57 bool signZ, signB;
58 const struct extFloat80M *tempSPtr;
59 uint64_t sigZ, sigB;
60 void
61 (*roundPackRoutinePtr)(
62 bool, int32_t, uint32_t *, uint_fast8_t, struct extFloat80M * );
63 int32_t expDiff;
64 uint32_t extSigX[3], sigZExtra;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 uiA64 = aSPtr->signExp;
69 expA = expExtF80UI64( uiA64 );
70 uiB64 = bSPtr->signExp;
71 expB = expExtF80UI64( uiB64 );
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
75 if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
76 uiZ64 = uiA64;
77 if ( expB == 0x7FFF ) {
78 uiZ64 = uiB64 ^ packToExtF80UI64( negateB, 0 );
79 if ( (expA == 0x7FFF) && (uiZ64 != uiA64) ) {
80 softfloat_invalidExtF80M( zSPtr );
81 return;
82 }
83 }
84 zSPtr->signExp = uiZ64;
85 zSPtr->signif = UINT64_C( 0x8000000000000000 );
86 return;
87 }
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 signZ = signExtF80UI64( uiA64 );
91 signB = signExtF80UI64( uiB64 ) ^ negateB;
92 negateB = (signZ != signB);
93 if ( expA < expB ) {
94 signZ = signB;
95 expA = expB;
96 expB = expExtF80UI64( uiA64 );
97 tempSPtr = aSPtr;
98 aSPtr = bSPtr;
99 bSPtr = tempSPtr;
100 }
101 if ( ! expB ) {
102 expB = 1;
103 if ( ! expA ) expA = 1;
104 }
105 sigZ = aSPtr->signif;
106 sigB = bSPtr->signif;
107 /*------------------------------------------------------------------------
108 *------------------------------------------------------------------------*/
109 roundPackRoutinePtr = softfloat_roundPackMToExtF80M;
110 expDiff = expA - expB;
111 if ( expDiff ) {
112 /*--------------------------------------------------------------------
113 *--------------------------------------------------------------------*/
114 extSigX[indexWord( 3, 2 )] = sigB>>32;
115 extSigX[indexWord( 3, 1 )] = sigB;
116 extSigX[indexWord( 3, 0 )] = 0;
117 softfloat_shiftRightJam96M( extSigX, expDiff, extSigX );
118 sigB =
119 (uint64_t) extSigX[indexWord( 3, 2 )]<<32
120 | extSigX[indexWord( 3, 1 )];
121 if ( negateB ) {
122 sigZ -= sigB;
123 sigZExtra = extSigX[indexWordLo( 3 )];
124 if ( sigZExtra ) {
125 --sigZ;
126 sigZExtra = -sigZExtra;
127 }
128 if ( ! (sigZ & UINT64_C( 0x8000000000000000 )) ) {
129 if ( sigZ & UINT64_C( 0x4000000000000000 ) ) {
130 --expA;
131 sigZ = sigZ<<1 | sigZExtra>>31;
132 sigZExtra <<= 1;
133 } else {
134 roundPackRoutinePtr = softfloat_normRoundPackMToExtF80M;
135 }
136 }
137 } else {
138 sigZ += sigB;
139 if ( sigZ & UINT64_C( 0x8000000000000000 ) ) goto sigZ;
140 sigZExtra = (uint32_t) sigZ<<31 | (extSigX[indexWordLo( 3 )] != 0);
141 goto completeNormAfterAdd;
142 }
143 } else {
144 /*--------------------------------------------------------------------
145 *--------------------------------------------------------------------*/
146 sigZExtra = 0;
147 if ( negateB ) {
148 if ( sigZ < sigB ) {
149 signZ = ! signZ;
150 sigZ = sigB - sigZ;
151 } else {
152 sigZ -= sigB;
153 if ( ! sigZ ) {
154 signZ = (softfloat_roundingMode == softfloat_round_min);
155 zSPtr->signExp = packToExtF80UI64( signZ, 0 );
156 zSPtr->signif = 0;
157 return;
158 }
159 }
160 roundPackRoutinePtr = softfloat_normRoundPackMToExtF80M;
161 } else {
162 sigZ += sigB;
163 if ( sigZ < sigB ) {
164 sigZExtra = (uint32_t) sigZ<<31;
165 completeNormAfterAdd:
166 ++expA;
167 sigZ = UINT64_C( 0x8000000000000000 ) | sigZ>>1;
168 } else {
169 if ( ! (sigZ & UINT64_C( 0x8000000000000000 )) ) {
170 roundPackRoutinePtr = softfloat_normRoundPackMToExtF80M;
171 }
172 }
173 }
174 }
175 extSigX[indexWord( 3, 0 )] = sigZExtra;
176 sigZ:
177 extSigX[indexWord( 3, 2 )] = sigZ>>32;
178 extSigX[indexWord( 3, 1 )] = sigZ;
179 /*------------------------------------------------------------------------
180 *------------------------------------------------------------------------*/
181 roundPack:
182 (*roundPackRoutinePtr)(
183 signZ, expA, extSigX, extF80_roundingPrecision, zSPtr );
184
185}
186
deps/SoftFloat-3e/source/s_addF128M.c created+211
......@@ -0,0 +1,211 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44void
45 softfloat_addF128M(
46 const uint32_t *aWPtr,
47 const uint32_t *bWPtr,
48 uint32_t *zWPtr,
49 bool negateB
50 )
51{
52 uint32_t uiA96;
53 int32_t expA;
54 uint32_t uiB96;
55 int32_t expB;
56 uint32_t uiZ96;
57 bool signZ, signB;
58 const uint32_t *tempPtr;
59 uint32_t sig96A, sig96B;
60 int32_t expDiff;
61 uint_fast8_t
62 (*addCarryMRoutinePtr)(
63 uint_fast8_t,
64 const uint32_t *,
65 const uint32_t *,
66 uint_fast8_t,
67 uint32_t *
68 );
69 uint32_t extSigZ[5], wordSigZ;
70 uint_fast8_t carry;
71 void (*roundPackRoutinePtr)( bool, int32_t, uint32_t *, uint32_t * );
72
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 uiA96 = aWPtr[indexWordHi( 4 )];
76 expA = expF128UI96( uiA96 );
77 uiB96 = bWPtr[indexWordHi( 4 )];
78 expB = expF128UI96( uiB96 );
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
82 if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
83 uiZ96 = uiA96;
84 if ( expB == 0x7FFF ) {
85 uiZ96 = uiB96 ^ packToF128UI96( negateB, 0, 0 );
86 if ( (expA == 0x7FFF) && (uiZ96 != uiA96) ) {
87 softfloat_invalidF128M( zWPtr );
88 return;
89 }
90 }
91 zWPtr[indexWordHi( 4 )] = uiZ96;
92 zWPtr[indexWord( 4, 2 )] = 0;
93 zWPtr[indexWord( 4, 1 )] = 0;
94 zWPtr[indexWord( 4, 0 )] = 0;
95 return;
96 }
97 /*------------------------------------------------------------------------
98 *------------------------------------------------------------------------*/
99 signZ = signF128UI96( uiA96 );
100 signB = signF128UI96( uiB96 ) ^ negateB;
101 negateB = (signZ != signB);
102 if ( (uint32_t) (uiA96<<1) < (uint32_t) (uiB96<<1) ) {
103 signZ = signB;
104 expA = expB;
105 expB = expF128UI96( uiA96 );
106 tempPtr = aWPtr;
107 aWPtr = bWPtr;
108 bWPtr = tempPtr;
109 uiA96 = uiB96;
110 uiB96 = bWPtr[indexWordHi( 4 )];
111 }
112 sig96A = fracF128UI96( uiA96 );
113 sig96B = fracF128UI96( uiB96 );
114 if ( expA ) {
115 --expA;
116 sig96A |= 0x00010000;
117 if ( expB ) {
118 --expB;
119 sig96B |= 0x00010000;
120 }
121 }
122 /*------------------------------------------------------------------------
123 *------------------------------------------------------------------------*/
124 addCarryMRoutinePtr =
125 negateB ? softfloat_addComplCarryM : softfloat_addCarryM;
126 expDiff = expA - expB;
127 if ( expDiff ) {
128 /*--------------------------------------------------------------------
129 *--------------------------------------------------------------------*/
130 extSigZ[indexWordHi( 5 )] = sig96B;
131 extSigZ[indexWord( 5, 3 )] = bWPtr[indexWord( 4, 2 )];
132 extSigZ[indexWord( 5, 2 )] = bWPtr[indexWord( 4, 1 )];
133 extSigZ[indexWord( 5, 1 )] = bWPtr[indexWord( 4, 0 )];
134 extSigZ[indexWord( 5, 0 )] = 0;
135 softfloat_shiftRightJam160M( extSigZ, expDiff, extSigZ );
136 sig96B = extSigZ[indexWordHi( 5 )];
137 carry = 0;
138 if ( negateB ) {
139 sig96B = ~sig96B;
140 wordSigZ = extSigZ[indexWordLo( 5 )];
141 extSigZ[indexWordLo( 5 )] = -wordSigZ;
142 carry = ! wordSigZ;
143 }
144 carry =
145 (*addCarryMRoutinePtr)(
146 3,
147 &aWPtr[indexMultiwordLo( 4, 3 )],
148 &extSigZ[indexMultiword( 5, 3, 1 )],
149 carry,
150 &extSigZ[indexMultiword( 5, 3, 1 )]
151 );
152 wordSigZ = sig96A + sig96B + carry;
153 } else {
154 /*--------------------------------------------------------------------
155 *--------------------------------------------------------------------*/
156 extSigZ[indexWordLo( 5 )] = 0;
157 carry =
158 (*addCarryMRoutinePtr)(
159 3,
160 &aWPtr[indexMultiwordLo( 4, 3 )],
161 &bWPtr[indexMultiwordLo( 4, 3 )],
162 negateB,
163 &extSigZ[indexMultiword( 5, 3, 1 )]
164 );
165 if ( negateB ) {
166 wordSigZ = sig96A + ~sig96B + carry;
167 if ( wordSigZ & 0x80000000 ) {
168 signZ = ! signZ;
169 carry =
170 softfloat_addComplCarry96M(
171 &bWPtr[indexMultiwordLo( 4, 3 )],
172 &aWPtr[indexMultiwordLo( 4, 3 )],
173 1,
174 &extSigZ[indexMultiword( 5, 3, 1 )]
175 );
176 wordSigZ = sig96B + ~sig96A + carry;
177 } else {
178 if (
179 ! wordSigZ && ! extSigZ[indexWord( 5, 3 )]
180 && ! ( extSigZ[indexWord( 5, 2 )]
181 | extSigZ[indexWord( 5, 1 )]
182 | extSigZ[indexWord( 5, 0 )]
183 )
184 ) {
185 signZ = (softfloat_roundingMode == softfloat_round_min);
186 zWPtr[indexWordHi( 4 )] = packToF128UI96( signZ, 0, 0 );
187 zWPtr[indexWord( 4, 2 )] = 0;
188 zWPtr[indexWord( 4, 1 )] = 0;
189 zWPtr[indexWord( 4, 0 )] = 0;
190 return;
191 }
192 }
193 } else {
194 wordSigZ = sig96A + sig96B + carry;
195 }
196 }
197 extSigZ[indexWordHi( 5 )] = wordSigZ;
198 /*------------------------------------------------------------------------
199 *------------------------------------------------------------------------*/
200 roundPackRoutinePtr = softfloat_normRoundPackMToF128M;
201 if ( 0x00010000 <= wordSigZ ) {
202 if ( 0x00020000 <= wordSigZ ) {
203 ++expA;
204 softfloat_shortShiftRightJam160M( extSigZ, 1, extSigZ );
205 }
206 roundPackRoutinePtr = softfloat_roundPackMToF128M;
207 }
208 (*roundPackRoutinePtr)( signZ, expA, extSigZ, zWPtr );
209
210}
211
deps/SoftFloat-3e/source/s_addM.c created+70
......@@ -0,0 +1,70 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_addM
42
43void
44 softfloat_addM(
45 uint_fast8_t size_words,
46 const uint32_t *aPtr,
47 const uint32_t *bPtr,
48 uint32_t *zPtr
49 )
50{
51 unsigned int index, lastIndex;
52 uint_fast8_t carry;
53 uint32_t wordA, wordZ;
54
55 index = indexWordLo( size_words );
56 lastIndex = indexWordHi( size_words );
57 carry = 0;
58 for (;;) {
59 wordA = aPtr[index];
60 wordZ = wordA + bPtr[index] + carry;
61 zPtr[index] = wordZ;
62 if ( index == lastIndex ) break;
63 if ( wordZ != wordA ) carry = (wordZ < wordA);
64 index += wordIncr;
65 }
66
67}
68
69#endif
70
deps/SoftFloat-3e/source/s_addMagsExtF80.c created+156
......@@ -0,0 +1,156 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t
45 softfloat_addMagsExtF80(
46 uint_fast16_t uiA64,
47 uint_fast64_t uiA0,
48 uint_fast16_t uiB64,
49 uint_fast64_t uiB0,
50 bool signZ
51 )
52{
53 int_fast32_t expA;
54 uint_fast64_t sigA;
55 int_fast32_t expB;
56 uint_fast64_t sigB;
57 int_fast32_t expDiff;
58 uint_fast16_t uiZ64;
59 uint_fast64_t uiZ0, sigZ, sigZExtra;
60 struct exp32_sig64 normExpSig;
61 int_fast32_t expZ;
62 struct uint64_extra sig64Extra;
63 struct uint128 uiZ;
64 union { struct extFloat80M s; extFloat80_t f; } uZ;
65
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 expA = expExtF80UI64( uiA64 );
69 sigA = uiA0;
70 expB = expExtF80UI64( uiB64 );
71 sigB = uiB0;
72 /*------------------------------------------------------------------------
73 *------------------------------------------------------------------------*/
74 expDiff = expA - expB;
75 if ( ! expDiff ) {
76 if ( expA == 0x7FFF ) {
77 if ( (sigA | sigB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
78 goto propagateNaN;
79 }
80 uiZ64 = uiA64;
81 uiZ0 = uiA0;
82 goto uiZ;
83 }
84 sigZ = sigA + sigB;
85 sigZExtra = 0;
86 if ( ! expA ) {
87 normExpSig = softfloat_normSubnormalExtF80Sig( sigZ );
88 expZ = normExpSig.exp + 1;
89 sigZ = normExpSig.sig;
90 goto roundAndPack;
91 }
92 expZ = expA;
93 goto shiftRight1;
94 }
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 if ( expDiff < 0 ) {
98 if ( expB == 0x7FFF ) {
99 if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
100 uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
101 uiZ0 = uiB0;
102 goto uiZ;
103 }
104 expZ = expB;
105 if ( ! expA ) {
106 ++expDiff;
107 sigZExtra = 0;
108 if ( ! expDiff ) goto newlyAligned;
109 }
110 sig64Extra = softfloat_shiftRightJam64Extra( sigA, 0, -expDiff );
111 sigA = sig64Extra.v;
112 sigZExtra = sig64Extra.extra;
113 } else {
114 if ( expA == 0x7FFF ) {
115 if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
116 uiZ64 = uiA64;
117 uiZ0 = uiA0;
118 goto uiZ;
119 }
120 expZ = expA;
121 if ( ! expB ) {
122 --expDiff;
123 sigZExtra = 0;
124 if ( ! expDiff ) goto newlyAligned;
125 }
126 sig64Extra = softfloat_shiftRightJam64Extra( sigB, 0, expDiff );
127 sigB = sig64Extra.v;
128 sigZExtra = sig64Extra.extra;
129 }
130 newlyAligned:
131 sigZ = sigA + sigB;
132 if ( sigZ & UINT64_C( 0x8000000000000000 ) ) goto roundAndPack;
133 /*------------------------------------------------------------------------
134 *------------------------------------------------------------------------*/
135 shiftRight1:
136 sig64Extra = softfloat_shortShiftRightJam64Extra( sigZ, sigZExtra, 1 );
137 sigZ = sig64Extra.v | UINT64_C( 0x8000000000000000 );
138 sigZExtra = sig64Extra.extra;
139 ++expZ;
140 roundAndPack:
141 return
142 softfloat_roundPackToExtF80(
143 signZ, expZ, sigZ, sigZExtra, extF80_roundingPrecision );
144 /*------------------------------------------------------------------------
145 *------------------------------------------------------------------------*/
146 propagateNaN:
147 uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
148 uiZ64 = uiZ.v64;
149 uiZ0 = uiZ.v0;
150 uiZ:
151 uZ.s.signExp = uiZ64;
152 uZ.s.signif = uiZ0;
153 return uZ.f;
154
155}
156
deps/SoftFloat-3e/source/s_addMagsF128.c created+154
......@@ -0,0 +1,154 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42
43float128_t
44 softfloat_addMagsF128(
45 uint_fast64_t uiA64,
46 uint_fast64_t uiA0,
47 uint_fast64_t uiB64,
48 uint_fast64_t uiB0,
49 bool signZ
50 )
51{
52 int_fast32_t expA;
53 struct uint128 sigA;
54 int_fast32_t expB;
55 struct uint128 sigB;
56 int_fast32_t expDiff;
57 struct uint128 uiZ, sigZ;
58 int_fast32_t expZ;
59 uint_fast64_t sigZExtra;
60 struct uint128_extra sig128Extra;
61 union ui128_f128 uZ;
62
63 expA = expF128UI64( uiA64 );
64 sigA.v64 = fracF128UI64( uiA64 );
65 sigA.v0 = uiA0;
66 expB = expF128UI64( uiB64 );
67 sigB.v64 = fracF128UI64( uiB64 );
68 sigB.v0 = uiB0;
69 expDiff = expA - expB;
70 if ( ! expDiff ) {
71 if ( expA == 0x7FFF ) {
72 if ( sigA.v64 | sigA.v0 | sigB.v64 | sigB.v0 ) goto propagateNaN;
73 uiZ.v64 = uiA64;
74 uiZ.v0 = uiA0;
75 goto uiZ;
76 }
77 sigZ = softfloat_add128( sigA.v64, sigA.v0, sigB.v64, sigB.v0 );
78 if ( ! expA ) {
79 uiZ.v64 = packToF128UI64( signZ, 0, sigZ.v64 );
80 uiZ.v0 = sigZ.v0;
81 goto uiZ;
82 }
83 expZ = expA;
84 sigZ.v64 |= UINT64_C( 0x0002000000000000 );
85 sigZExtra = 0;
86 goto shiftRight1;
87 }
88 if ( expDiff < 0 ) {
89 if ( expB == 0x7FFF ) {
90 if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
91 uiZ.v64 = packToF128UI64( signZ, 0x7FFF, 0 );
92 uiZ.v0 = 0;
93 goto uiZ;
94 }
95 expZ = expB;
96 if ( expA ) {
97 sigA.v64 |= UINT64_C( 0x0001000000000000 );
98 } else {
99 ++expDiff;
100 sigZExtra = 0;
101 if ( ! expDiff ) goto newlyAligned;
102 }
103 sig128Extra =
104 softfloat_shiftRightJam128Extra( sigA.v64, sigA.v0, 0, -expDiff );
105 sigA = sig128Extra.v;
106 sigZExtra = sig128Extra.extra;
107 } else {
108 if ( expA == 0x7FFF ) {
109 if ( sigA.v64 | sigA.v0 ) goto propagateNaN;
110 uiZ.v64 = uiA64;
111 uiZ.v0 = uiA0;
112 goto uiZ;
113 }
114 expZ = expA;
115 if ( expB ) {
116 sigB.v64 |= UINT64_C( 0x0001000000000000 );
117 } else {
118 --expDiff;
119 sigZExtra = 0;
120 if ( ! expDiff ) goto newlyAligned;
121 }
122 sig128Extra =
123 softfloat_shiftRightJam128Extra( sigB.v64, sigB.v0, 0, expDiff );
124 sigB = sig128Extra.v;
125 sigZExtra = sig128Extra.extra;
126 }
127 newlyAligned:
128 sigZ =
129 softfloat_add128(
130 sigA.v64 | UINT64_C( 0x0001000000000000 ),
131 sigA.v0,
132 sigB.v64,
133 sigB.v0
134 );
135 --expZ;
136 if ( sigZ.v64 < UINT64_C( 0x0002000000000000 ) ) goto roundAndPack;
137 ++expZ;
138 shiftRight1:
139 sig128Extra =
140 softfloat_shortShiftRightJam128Extra(
141 sigZ.v64, sigZ.v0, sigZExtra, 1 );
142 sigZ = sig128Extra.v;
143 sigZExtra = sig128Extra.extra;
144 roundAndPack:
145 return
146 softfloat_roundPackToF128( signZ, expZ, sigZ.v64, sigZ.v0, sigZExtra );
147 propagateNaN:
148 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
149 uiZ:
150 uZ.ui = uiZ;
151 return uZ.f;
152
153}
154
deps/SoftFloat-3e/source/s_addMagsF16.c created+183
......@@ -0,0 +1,183 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t softfloat_addMagsF16( uint_fast16_t uiA, uint_fast16_t uiB )
45{
46 int_fast8_t expA;
47 uint_fast16_t sigA;
48 int_fast8_t expB;
49 uint_fast16_t sigB;
50 int_fast8_t expDiff;
51 uint_fast16_t uiZ;
52 bool signZ;
53 int_fast8_t expZ;
54 uint_fast16_t sigZ;
55 uint_fast16_t sigX, sigY;
56 int_fast8_t shiftDist;
57 uint_fast32_t sig32Z;
58 int_fast8_t roundingMode;
59 union ui16_f16 uZ;
60
61 /*------------------------------------------------------------------------
62 *------------------------------------------------------------------------*/
63 expA = expF16UI( uiA );
64 sigA = fracF16UI( uiA );
65 expB = expF16UI( uiB );
66 sigB = fracF16UI( uiB );
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 expDiff = expA - expB;
70 if ( ! expDiff ) {
71 /*--------------------------------------------------------------------
72 *--------------------------------------------------------------------*/
73 if ( ! expA ) {
74 uiZ = uiA + sigB;
75 goto uiZ;
76 }
77 if ( expA == 0x1F ) {
78 if ( sigA | sigB ) goto propagateNaN;
79 uiZ = uiA;
80 goto uiZ;
81 }
82 signZ = signF16UI( uiA );
83 expZ = expA;
84 sigZ = 0x0800 + sigA + sigB;
85 if ( ! (sigZ & 1) && (expZ < 0x1E) ) {
86 sigZ >>= 1;
87 goto pack;
88 }
89 sigZ <<= 3;
90 } else {
91 /*--------------------------------------------------------------------
92 *--------------------------------------------------------------------*/
93 signZ = signF16UI( uiA );
94 if ( expDiff < 0 ) {
95 /*----------------------------------------------------------------
96 *----------------------------------------------------------------*/
97 if ( expB == 0x1F ) {
98 if ( sigB ) goto propagateNaN;
99 uiZ = packToF16UI( signZ, 0x1F, 0 );
100 goto uiZ;
101 }
102 if ( expDiff <= -13 ) {
103 uiZ = packToF16UI( signZ, expB, sigB );
104 if ( expA | sigA ) goto addEpsilon;
105 goto uiZ;
106 }
107 expZ = expB;
108 sigX = sigB | 0x0400;
109 sigY = sigA + (expA ? 0x0400 : sigA);
110 shiftDist = 19 + expDiff;
111 } else {
112 /*----------------------------------------------------------------
113 *----------------------------------------------------------------*/
114 uiZ = uiA;
115 if ( expA == 0x1F ) {
116 if ( sigA ) goto propagateNaN;
117 goto uiZ;
118 }
119 if ( 13 <= expDiff ) {
120 if ( expB | sigB ) goto addEpsilon;
121 goto uiZ;
122 }
123 expZ = expA;
124 sigX = sigA | 0x0400;
125 sigY = sigB + (expB ? 0x0400 : sigB);
126 shiftDist = 19 - expDiff;
127 }
128 sig32Z =
129 ((uint_fast32_t) sigX<<19) + ((uint_fast32_t) sigY<<shiftDist);
130 if ( sig32Z < 0x40000000 ) {
131 --expZ;
132 sig32Z <<= 1;
133 }
134 sigZ = sig32Z>>16;
135 if ( sig32Z & 0xFFFF ) {
136 sigZ |= 1;
137 } else {
138 if ( ! (sigZ & 0xF) && (expZ < 0x1E) ) {
139 sigZ >>= 4;
140 goto pack;
141 }
142 }
143 }
144 return softfloat_roundPackToF16( signZ, expZ, sigZ );
145 /*------------------------------------------------------------------------
146 *------------------------------------------------------------------------*/
147 propagateNaN:
148 uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
149 goto uiZ;
150 /*------------------------------------------------------------------------
151 *------------------------------------------------------------------------*/
152 addEpsilon:
153 roundingMode = softfloat_roundingMode;
154 if ( roundingMode != softfloat_round_near_even ) {
155 if (
156 roundingMode
157 == (signF16UI( uiZ ) ? softfloat_round_min
158 : softfloat_round_max)
159 ) {
160 ++uiZ;
161 if ( (uint16_t) (uiZ<<1) == 0xF800 ) {
162 softfloat_raiseFlags(
163 softfloat_flag_overflow | softfloat_flag_inexact );
164 }
165 }
166#ifdef SOFTFLOAT_ROUND_ODD
167 else if ( roundingMode == softfloat_round_odd ) {
168 uiZ |= 1;
169 }
170#endif
171 }
172 softfloat_exceptionFlags |= softfloat_flag_inexact;
173 goto uiZ;
174 /*------------------------------------------------------------------------
175 *------------------------------------------------------------------------*/
176 pack:
177 uiZ = packToF16UI( signZ, expZ, sigZ );
178 uiZ:
179 uZ.ui = uiZ;
180 return uZ.f;
181
182}
183
deps/SoftFloat-3e/source/s_addMagsF32.c created+126
......@@ -0,0 +1,126 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42
43float32_t softfloat_addMagsF32( uint_fast32_t uiA, uint_fast32_t uiB )
44{
45 int_fast16_t expA;
46 uint_fast32_t sigA;
47 int_fast16_t expB;
48 uint_fast32_t sigB;
49 int_fast16_t expDiff;
50 uint_fast32_t uiZ;
51 bool signZ;
52 int_fast16_t expZ;
53 uint_fast32_t sigZ;
54 union ui32_f32 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 expA = expF32UI( uiA );
59 sigA = fracF32UI( uiA );
60 expB = expF32UI( uiB );
61 sigB = fracF32UI( uiB );
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 expDiff = expA - expB;
65 if ( ! expDiff ) {
66 /*--------------------------------------------------------------------
67 *--------------------------------------------------------------------*/
68 if ( ! expA ) {
69 uiZ = uiA + sigB;
70 goto uiZ;
71 }
72 if ( expA == 0xFF ) {
73 if ( sigA | sigB ) goto propagateNaN;
74 uiZ = uiA;
75 goto uiZ;
76 }
77 signZ = signF32UI( uiA );
78 expZ = expA;
79 sigZ = 0x01000000 + sigA + sigB;
80 if ( ! (sigZ & 1) && (expZ < 0xFE) ) {
81 uiZ = packToF32UI( signZ, expZ, sigZ>>1 );
82 goto uiZ;
83 }
84 sigZ <<= 6;
85 } else {
86 /*--------------------------------------------------------------------
87 *--------------------------------------------------------------------*/
88 signZ = signF32UI( uiA );
89 sigA <<= 6;
90 sigB <<= 6;
91 if ( expDiff < 0 ) {
92 if ( expB == 0xFF ) {
93 if ( sigB ) goto propagateNaN;
94 uiZ = packToF32UI( signZ, 0xFF, 0 );
95 goto uiZ;
96 }
97 expZ = expB;
98 sigA += expA ? 0x20000000 : sigA;
99 sigA = softfloat_shiftRightJam32( sigA, -expDiff );
100 } else {
101 if ( expA == 0xFF ) {
102 if ( sigA ) goto propagateNaN;
103 uiZ = uiA;
104 goto uiZ;
105 }
106 expZ = expA;
107 sigB += expB ? 0x20000000 : sigB;
108 sigB = softfloat_shiftRightJam32( sigB, expDiff );
109 }
110 sigZ = 0x20000000 + sigA + sigB;
111 if ( sigZ < 0x40000000 ) {
112 --expZ;
113 sigZ <<= 1;
114 }
115 }
116 return softfloat_roundPackToF32( signZ, expZ, sigZ );
117 /*------------------------------------------------------------------------
118 *------------------------------------------------------------------------*/
119 propagateNaN:
120 uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
121 uiZ:
122 uZ.ui = uiZ;
123 return uZ.f;
124
125}
126
deps/SoftFloat-3e/source/s_addMagsF64.c created+128
......@@ -0,0 +1,128 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42
43float64_t
44 softfloat_addMagsF64( uint_fast64_t uiA, uint_fast64_t uiB, bool signZ )
45{
46 int_fast16_t expA;
47 uint_fast64_t sigA;
48 int_fast16_t expB;
49 uint_fast64_t sigB;
50 int_fast16_t expDiff;
51 uint_fast64_t uiZ;
52 int_fast16_t expZ;
53 uint_fast64_t sigZ;
54 union ui64_f64 uZ;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 expA = expF64UI( uiA );
59 sigA = fracF64UI( uiA );
60 expB = expF64UI( uiB );
61 sigB = fracF64UI( uiB );
62 /*------------------------------------------------------------------------
63 *------------------------------------------------------------------------*/
64 expDiff = expA - expB;
65 if ( ! expDiff ) {
66 /*--------------------------------------------------------------------
67 *--------------------------------------------------------------------*/
68 if ( ! expA ) {
69 uiZ = uiA + sigB;
70 goto uiZ;
71 }
72 if ( expA == 0x7FF ) {
73 if ( sigA | sigB ) goto propagateNaN;
74 uiZ = uiA;
75 goto uiZ;
76 }
77 expZ = expA;
78 sigZ = UINT64_C( 0x0020000000000000 ) + sigA + sigB;
79 sigZ <<= 9;
80 } else {
81 /*--------------------------------------------------------------------
82 *--------------------------------------------------------------------*/
83 sigA <<= 9;
84 sigB <<= 9;
85 if ( expDiff < 0 ) {
86 if ( expB == 0x7FF ) {
87 if ( sigB ) goto propagateNaN;
88 uiZ = packToF64UI( signZ, 0x7FF, 0 );
89 goto uiZ;
90 }
91 expZ = expB;
92 if ( expA ) {
93 sigA += UINT64_C( 0x2000000000000000 );
94 } else {
95 sigA <<= 1;
96 }
97 sigA = softfloat_shiftRightJam64( sigA, -expDiff );
98 } else {
99 if ( expA == 0x7FF ) {
100 if ( sigA ) goto propagateNaN;
101 uiZ = uiA;
102 goto uiZ;
103 }
104 expZ = expA;
105 if ( expB ) {
106 sigB += UINT64_C( 0x2000000000000000 );
107 } else {
108 sigB <<= 1;
109 }
110 sigB = softfloat_shiftRightJam64( sigB, expDiff );
111 }
112 sigZ = UINT64_C( 0x2000000000000000 ) + sigA + sigB;
113 if ( sigZ < UINT64_C( 0x4000000000000000 ) ) {
114 --expZ;
115 sigZ <<= 1;
116 }
117 }
118 return softfloat_roundPackToF64( signZ, expZ, sigZ );
119 /*------------------------------------------------------------------------
120 *------------------------------------------------------------------------*/
121 propagateNaN:
122 uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
123 uiZ:
124 uZ.ui = uiZ;
125 return uZ.f;
126
127}
128
deps/SoftFloat-3e/source/s_approxRecip32_1.c created+66
......@@ -0,0 +1,66 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_approxRecip32_1
41
42extern const uint16_t softfloat_approxRecip_1k0s[16];
43extern const uint16_t softfloat_approxRecip_1k1s[16];
44
45uint32_t softfloat_approxRecip32_1( uint32_t a )
46{
47 int index;
48 uint16_t eps, r0;
49 uint32_t sigma0;
50 uint_fast32_t r;
51 uint32_t sqrSigma0;
52
53 index = a>>27 & 0xF;
54 eps = (uint16_t) (a>>11);
55 r0 = softfloat_approxRecip_1k0s[index]
56 - ((softfloat_approxRecip_1k1s[index] * (uint_fast32_t) eps)>>20);
57 sigma0 = ~(uint_fast32_t) ((r0 * (uint_fast64_t) a)>>7);
58 r = ((uint_fast32_t) r0<<16) + ((r0 * (uint_fast64_t) sigma0)>>24);
59 sqrSigma0 = ((uint_fast64_t) sigma0 * sigma0)>>32;
60 r += ((uint32_t) r * (uint_fast64_t) sqrSigma0)>>48;
61 return r;
62
63}
64
65#endif
66
deps/SoftFloat-3e/source/s_approxRecipSqrt32_1.c created+73
......@@ -0,0 +1,73 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_approxRecipSqrt32_1
41
42extern const uint16_t softfloat_approxRecipSqrt_1k0s[];
43extern const uint16_t softfloat_approxRecipSqrt_1k1s[];
44
45uint32_t softfloat_approxRecipSqrt32_1( unsigned int oddExpA, uint32_t a )
46{
47 int index;
48 uint16_t eps, r0;
49 uint_fast32_t ESqrR0;
50 uint32_t sigma0;
51 uint_fast32_t r;
52 uint32_t sqrSigma0;
53
54 index = (a>>27 & 0xE) + oddExpA;
55 eps = (uint16_t) (a>>12);
56 r0 = softfloat_approxRecipSqrt_1k0s[index]
57 - ((softfloat_approxRecipSqrt_1k1s[index] * (uint_fast32_t) eps)
58 >>20);
59 ESqrR0 = (uint_fast32_t) r0 * r0;
60 if ( ! oddExpA ) ESqrR0 <<= 1;
61 sigma0 = ~(uint_fast32_t) (((uint32_t) ESqrR0 * (uint_fast64_t) a)>>23);
62 r = ((uint_fast32_t) r0<<16) + ((r0 * (uint_fast64_t) sigma0)>>25);
63 sqrSigma0 = ((uint_fast64_t) sigma0 * sigma0)>>32;
64 r += ((uint32_t) ((r>>1) + (r>>3) - ((uint_fast32_t) r0<<14))
65 * (uint_fast64_t) sqrSigma0)
66 >>48;
67 if ( ! (r & 0x80000000) ) r = 0x80000000;
68 return r;
69
70}
71
72#endif
73
deps/SoftFloat-3e/source/s_approxRecipSqrt_1Ks.c created+49
......@@ -0,0 +1,49 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40
41const uint16_t softfloat_approxRecipSqrt_1k0s[16] = {
42 0xB4C9, 0xFFAB, 0xAA7D, 0xF11C, 0xA1C5, 0xE4C7, 0x9A43, 0xDA29,
43 0x93B5, 0xD0E5, 0x8DED, 0xC8B7, 0x88C6, 0xC16D, 0x8424, 0xBAE1
44};
45const uint16_t softfloat_approxRecipSqrt_1k1s[16] = {
46 0xA5A5, 0xEA42, 0x8C21, 0xC62D, 0x788F, 0xAA7F, 0x6928, 0x94B6,
47 0x5CC7, 0x8335, 0x52A6, 0x74E2, 0x4A3E, 0x68FE, 0x432B, 0x5EFD
48};
49
deps/SoftFloat-3e/source/s_approxRecip_1Ks.c created+49
......@@ -0,0 +1,49 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40
41const uint16_t softfloat_approxRecip_1k0s[16] = {
42 0xFFC4, 0xF0BE, 0xE363, 0xD76F, 0xCCAD, 0xC2F0, 0xBA16, 0xB201,
43 0xAA97, 0xA3C6, 0x9D7A, 0x97A6, 0x923C, 0x8D32, 0x887E, 0x8417
44};
45const uint16_t softfloat_approxRecip_1k1s[16] = {
46 0xF0F1, 0xD62C, 0xBFA1, 0xAC77, 0x9C0A, 0x8DDB, 0x8185, 0x76BA,
47 0x6D3B, 0x64D4, 0x5D5C, 0x56B1, 0x50B6, 0x4B55, 0x4679, 0x4211
48};
49
deps/SoftFloat-3e/source/s_compare128M.c created+62
......@@ -0,0 +1,62 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_compare128M
42
43int_fast8_t softfloat_compare128M( const uint32_t *aPtr, const uint32_t *bPtr )
44{
45 unsigned int index, lastIndex;
46 uint32_t wordA, wordB;
47
48 index = indexWordHi( 4 );
49 lastIndex = indexWordLo( 4 );
50 for (;;) {
51 wordA = aPtr[index];
52 wordB = bPtr[index];
53 if ( wordA != wordB ) return (wordA < wordB) ? -1 : 1;
54 if ( index == lastIndex ) break;
55 index -= wordIncr;
56 }
57 return 0;
58
59}
60
61#endif
62
deps/SoftFloat-3e/source/s_compare96M.c created+62
......@@ -0,0 +1,62 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_compare96M
42
43int_fast8_t softfloat_compare96M( const uint32_t *aPtr, const uint32_t *bPtr )
44{
45 unsigned int index, lastIndex;
46 uint32_t wordA, wordB;
47
48 index = indexWordHi( 3 );
49 lastIndex = indexWordLo( 3 );
50 for (;;) {
51 wordA = aPtr[index];
52 wordB = bPtr[index];
53 if ( wordA != wordB ) return (wordA < wordB) ? -1 : 1;
54 if ( index == lastIndex ) break;
55 index -= wordIncr;
56 }
57 return 0;
58
59}
60
61#endif
62
deps/SoftFloat-3e/source/s_compareNonnormExtF80M.c created+111
......@@ -0,0 +1,111 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat_types.h"
41
42int
43 softfloat_compareNonnormExtF80M(
44 const struct extFloat80M *aSPtr, const struct extFloat80M *bSPtr )
45{
46 uint_fast16_t uiA64, uiB64;
47 uint64_t sigA;
48 bool signB;
49 uint64_t sigB;
50 int32_t expA, expB;
51
52 /*------------------------------------------------------------------------
53 *------------------------------------------------------------------------*/
54 uiA64 = aSPtr->signExp;
55 uiB64 = bSPtr->signExp;
56 sigA = aSPtr->signif;
57 signB = signExtF80UI64( uiB64 );
58 sigB = bSPtr->signif;
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 if ( (uiA64 ^ uiB64) & 0x8000 ) {
62 if ( ! (sigA | sigB) ) return 0;
63 goto resultFromSignB;
64 }
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 expA = expExtF80UI64( uiA64 );
68 expB = expExtF80UI64( uiB64 );
69 if ( expA == 0x7FFF ) {
70 if (expB == 0x7FFF) return 0;
71 signB = ! signB;
72 goto resultFromSignB;
73 }
74 if ( expB == 0x7FFF ) {
75 goto resultFromSignB;
76 }
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 if ( ! expA ) expA = 1;
80 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
81 if ( sigA ) {
82 expA += softfloat_normExtF80SigM( &sigA );
83 } else {
84 expA = -128;
85 }
86 }
87 if ( ! expB ) expB = 1;
88 if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
89 if ( sigB ) {
90 expB += softfloat_normExtF80SigM( &sigB );
91 } else {
92 expB = -128;
93 }
94 }
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 if ( signB ) {
98 if ( expA < expB ) return 1;
99 if ( (expB < expA) || (sigB < sigA) ) return -1;
100 } else {
101 if ( expB < expA ) return 1;
102 if ( (expA < expB) || (sigA < sigB) ) return -1;
103 }
104 return (sigA != sigB);
105 /*------------------------------------------------------------------------
106 *------------------------------------------------------------------------*/
107 resultFromSignB:
108 return signB ? 1 : -1;
109
110}
111
deps/SoftFloat-3e/source/s_countLeadingZeros16.c created+60
......@@ -0,0 +1,60 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_countLeadingZeros16
41
42#define softfloat_countLeadingZeros16 softfloat_countLeadingZeros16
43#include "primitives.h"
44
45uint_fast8_t softfloat_countLeadingZeros16( uint16_t a )
46{
47 uint_fast8_t count;
48
49 count = 8;
50 if ( 0x100 <= a ) {
51 count = 0;
52 a >>= 8;
53 }
54 count += softfloat_countLeadingZeros8[a];
55 return count;
56
57}
58
59#endif
60
deps/SoftFloat-3e/source/s_countLeadingZeros32.c created+64
......@@ -0,0 +1,64 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_countLeadingZeros32
41
42#define softfloat_countLeadingZeros32 softfloat_countLeadingZeros32
43#include "primitives.h"
44
45uint_fast8_t softfloat_countLeadingZeros32( uint32_t a )
46{
47 uint_fast8_t count;
48
49 count = 0;
50 if ( a < 0x10000 ) {
51 count = 16;
52 a <<= 16;
53 }
54 if ( a < 0x1000000 ) {
55 count += 8;
56 a <<= 8;
57 }
58 count += softfloat_countLeadingZeros8[a>>24];
59 return count;
60
61}
62
63#endif
64
deps/SoftFloat-3e/source/s_countLeadingZeros64.c created+73
......@@ -0,0 +1,73 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_countLeadingZeros64
41
42#define softfloat_countLeadingZeros64 softfloat_countLeadingZeros64
43#include "primitives.h"
44
45uint_fast8_t softfloat_countLeadingZeros64( uint64_t a )
46{
47 uint_fast8_t count;
48 uint32_t a32;
49
50 count = 0;
51 a32 = a>>32;
52 if ( ! a32 ) {
53 count = 32;
54 a32 = a;
55 }
56 /*------------------------------------------------------------------------
57 | From here, result is current count + count leading zeros of `a32'.
58 *------------------------------------------------------------------------*/
59 if ( a32 < 0x10000 ) {
60 count += 16;
61 a32 <<= 16;
62 }
63 if ( a32 < 0x1000000 ) {
64 count += 8;
65 a32 <<= 8;
66 }
67 count += softfloat_countLeadingZeros8[a32>>24];
68 return count;
69
70}
71
72#endif
73
deps/SoftFloat-3e/source/s_countLeadingZeros8.c created+59
......@@ -0,0 +1,59 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40
41const uint_least8_t softfloat_countLeadingZeros8[256] = {
42 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
43 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
44 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
45 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
46 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
47 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
48 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
49 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
50 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
51 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
52 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
53 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
54 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
55 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
56 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
58};
59
deps/SoftFloat-3e/source/s_eq128.c created+51
......@@ -0,0 +1,51 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40
41#ifndef softfloat_eq128
42
43bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
44{
45
46 return (a64 == b64) && (a0 == b0);
47
48}
49
50#endif
51
deps/SoftFloat-3e/source/s_invalidExtF80M.c created+49
......@@ -0,0 +1,49 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include "platform.h"
38#include "specialize.h"
39#include "softfloat.h"
40
41void softfloat_invalidExtF80M( struct extFloat80M *zSPtr )
42{
43
44 softfloat_raiseFlags( softfloat_flag_invalid );
45 zSPtr->signExp = defaultNaNExtF80UI64;
46 zSPtr->signif = defaultNaNExtF80UI0;
47
48}
49
deps/SoftFloat-3e/source/s_invalidF128M.c created+53
......@@ -0,0 +1,53 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitives.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43void softfloat_invalidF128M( uint32_t *zWPtr )
44{
45
46 softfloat_raiseFlags( softfloat_flag_invalid );
47 zWPtr[indexWord( 4, 3 )] = defaultNaNF128UI96;
48 zWPtr[indexWord( 4, 2 )] = defaultNaNF128UI64;
49 zWPtr[indexWord( 4, 1 )] = defaultNaNF128UI32;
50 zWPtr[indexWord( 4, 0 )] = defaultNaNF128UI0;
51
52}
53
deps/SoftFloat-3e/source/s_isNaNF128M.c created+57
......@@ -0,0 +1,57 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "primitives.h"
41
42/*----------------------------------------------------------------------------
43*----------------------------------------------------------------------------*/
44bool softfloat_isNaNF128M( const uint32_t *aWPtr )
45{
46 uint32_t uiA96;
47
48 uiA96 = aWPtr[indexWordHi( 4 )];
49 if ( (~uiA96 & 0x7FFF0000) != 0 ) return false;
50 return
51 ((uiA96 & 0x0000FFFF) != 0)
52 || ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
53 | aWPtr[indexWord( 4, 0 )])
54 != 0);
55
56}
57
deps/SoftFloat-3e/source/s_le128.c created+51
......@@ -0,0 +1,51 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40
41#ifndef softfloat_le128
42
43bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
44{
45
46 return (a64 < b64) || ((a64 == b64) && (a0 <= b0));
47
48}
49
50#endif
51
deps/SoftFloat-3e/source/s_lt128.c created+51
......@@ -0,0 +1,51 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40
41#ifndef softfloat_lt128
42
43bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
44{
45
46 return (a64 < b64) || ((a64 == b64) && (a0 < b0));
47
48}
49
50#endif
51
deps/SoftFloat-3e/source/s_mul128By32.c created+58
......@@ -0,0 +1,58 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_mul128By32
42
43struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b )
44{
45 struct uint128 z;
46 uint_fast64_t mid;
47 uint_fast32_t carry;
48
49 z.v0 = a0 * b;
50 mid = (uint_fast64_t) (uint32_t) (a0>>32) * b;
51 carry = (uint32_t) ((uint_fast32_t) (z.v0>>32) - (uint_fast32_t) mid);
52 z.v64 = a64 * b + (uint_fast32_t) ((mid + carry)>>32);
53 return z;
54
55}
56
57#endif
58
deps/SoftFloat-3e/source/s_mul128MTo256M.c created+100
......@@ -0,0 +1,100 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_mul128MTo256M
42
43void
44 softfloat_mul128MTo256M(
45 const uint32_t *aPtr, const uint32_t *bPtr, uint32_t *zPtr )
46{
47 uint32_t *lastZPtr, wordB;
48 uint64_t dwordProd;
49 uint32_t wordZ;
50 uint_fast8_t carry;
51
52 bPtr += indexWordLo( 4 );
53 lastZPtr = zPtr + indexMultiwordHi( 8, 5 );
54 zPtr += indexMultiwordLo( 8, 5 );
55 wordB = *bPtr;
56 dwordProd = (uint64_t) aPtr[indexWord( 4, 0 )] * wordB;
57 zPtr[indexWord( 5, 0 )] = dwordProd;
58 dwordProd = (uint64_t) aPtr[indexWord( 4, 1 )] * wordB + (dwordProd>>32);
59 zPtr[indexWord( 5, 1 )] = dwordProd;
60 dwordProd = (uint64_t) aPtr[indexWord( 4, 2 )] * wordB + (dwordProd>>32);
61 zPtr[indexWord( 5, 2 )] = dwordProd;
62 dwordProd = (uint64_t) aPtr[indexWord( 4, 3 )] * wordB + (dwordProd>>32);
63 zPtr[indexWord( 5, 3 )] = dwordProd;
64 zPtr[indexWord( 5, 4 )] = dwordProd>>32;
65 do {
66 bPtr += wordIncr;
67 zPtr += wordIncr;
68 wordB = *bPtr;
69 dwordProd = (uint64_t) aPtr[indexWord( 4, 0 )] * wordB;
70 wordZ = zPtr[indexWord( 5, 0 )] + (uint32_t) dwordProd;
71 zPtr[indexWord( 5, 0 )] = wordZ;
72 carry = (wordZ < (uint32_t) dwordProd);
73 dwordProd =
74 (uint64_t) aPtr[indexWord( 4, 1 )] * wordB + (dwordProd>>32);
75 wordZ = zPtr[indexWord( 5, 1 )] + (uint32_t) dwordProd + carry;
76 zPtr[indexWord( 5, 1 )] = wordZ;
77 if ( wordZ != (uint32_t) dwordProd ) {
78 carry = (wordZ < (uint32_t) dwordProd);
79 }
80 dwordProd =
81 (uint64_t) aPtr[indexWord( 4, 2 )] * wordB + (dwordProd>>32);
82 wordZ = zPtr[indexWord( 5, 2 )] + (uint32_t) dwordProd + carry;
83 zPtr[indexWord( 5, 2 )] = wordZ;
84 if ( wordZ != (uint32_t) dwordProd ) {
85 carry = (wordZ < (uint32_t) dwordProd);
86 }
87 dwordProd =
88 (uint64_t) aPtr[indexWord( 4, 3 )] * wordB + (dwordProd>>32);
89 wordZ = zPtr[indexWord( 5, 3 )] + (uint32_t) dwordProd + carry;
90 zPtr[indexWord( 5, 3 )] = wordZ;
91 if ( wordZ != (uint32_t) dwordProd ) {
92 carry = (wordZ < (uint32_t) dwordProd);
93 }
94 zPtr[indexWord( 5, 4 )] = (dwordProd>>32) + carry;
95 } while ( zPtr != lastZPtr );
96
97}
98
99#endif
100
deps/SoftFloat-3e/source/s_mul128To256M.c created+71
......@@ -0,0 +1,71 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_mul128To256M
41
42#define softfloat_mul128To256M softfloat_mul128To256M
43#include "primitives.h"
44
45void
46 softfloat_mul128To256M(
47 uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0, uint64_t *zPtr )
48{
49 struct uint128 p0, p64, p128;
50 uint_fast64_t z64, z128, z192;
51
52 p0 = softfloat_mul64To128( a0, b0 );
53 zPtr[indexWord( 4, 0 )] = p0.v0;
54 p64 = softfloat_mul64To128( a64, b0 );
55 z64 = p64.v0 + p0.v64;
56 z128 = p64.v64 + (z64 < p64.v0);
57 p128 = softfloat_mul64To128( a64, b64 );
58 z128 += p128.v0;
59 z192 = p128.v64 + (z128 < p128.v0);
60 p64 = softfloat_mul64To128( a0, b64 );
61 z64 += p64.v0;
62 zPtr[indexWord( 4, 1 )] = z64;
63 p64.v64 += (z64 < p64.v0);
64 z128 += p64.v64;
65 zPtr[indexWord( 4, 2 )] = z128;
66 zPtr[indexWord( 4, 3 )] = z192 + (z128 < p64.v64);
67
68}
69
70#endif
71
deps/SoftFloat-3e/source/s_mul64ByShifted32To128.c created+56
......@@ -0,0 +1,56 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_mul64ByShifted32To128
42
43struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b )
44{
45 uint_fast64_t mid;
46 struct uint128 z;
47
48 mid = (uint_fast64_t) (uint32_t) a * b;
49 z.v0 = mid<<32;
50 z.v64 = (uint_fast64_t) (uint32_t) (a>>32) * b + (mid>>32);
51 return z;
52
53}
54
55#endif
56
deps/SoftFloat-3e/source/s_mul64To128.c created+66
......@@ -0,0 +1,66 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_mul64To128
42
43struct uint128 softfloat_mul64To128( uint64_t a, uint64_t b )
44{
45 uint32_t a32, a0, b32, b0;
46 struct uint128 z;
47 uint64_t mid1, mid;
48
49 a32 = a>>32;
50 a0 = a;
51 b32 = b>>32;
52 b0 = b;
53 z.v0 = (uint_fast64_t) a0 * b0;
54 mid1 = (uint_fast64_t) a32 * b0;
55 mid = mid1 + (uint_fast64_t) a0 * b32;
56 z.v64 = (uint_fast64_t) a32 * b32;
57 z.v64 += (uint_fast64_t) (mid < mid1)<<32 | mid>>32;
58 mid <<= 32;
59 z.v0 += mid;
60 z.v64 += (z.v0 < mid);
61 return z;
62
63}
64
65#endif
66
deps/SoftFloat-3e/source/s_mul64To128M.c created+68
......@@ -0,0 +1,68 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_mul64To128M
42
43void softfloat_mul64To128M( uint64_t a, uint64_t b, uint32_t *zPtr )
44{
45 uint32_t a32, a0, b32, b0;
46 uint64_t z0, mid1, z64, mid;
47
48 a32 = a>>32;
49 a0 = a;
50 b32 = b>>32;
51 b0 = b;
52 z0 = (uint64_t) a0 * b0;
53 mid1 = (uint64_t) a32 * b0;
54 mid = mid1 + (uint64_t) a0 * b32;
55 z64 = (uint64_t) a32 * b32;
56 z64 += (uint64_t) (mid < mid1)<<32 | mid>>32;
57 mid <<= 32;
58 z0 += mid;
59 zPtr[indexWord( 4, 1 )] = z0>>32;
60 zPtr[indexWord( 4, 0 )] = z0;
61 z64 += (z0 < mid);
62 zPtr[indexWord( 4, 3 )] = z64>>32;
63 zPtr[indexWord( 4, 2 )] = z64;
64
65}
66
67#endif
68
deps/SoftFloat-3e/source/s_mulAddF128.c created+350
......@@ -0,0 +1,350 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t
45 softfloat_mulAddF128(
46 uint_fast64_t uiA64,
47 uint_fast64_t uiA0,
48 uint_fast64_t uiB64,
49 uint_fast64_t uiB0,
50 uint_fast64_t uiC64,
51 uint_fast64_t uiC0,
52 uint_fast8_t op
53 )
54{
55 bool signA;
56 int_fast32_t expA;
57 struct uint128 sigA;
58 bool signB;
59 int_fast32_t expB;
60 struct uint128 sigB;
61 bool signC;
62 int_fast32_t expC;
63 struct uint128 sigC;
64 bool signZ;
65 uint_fast64_t magBits;
66 struct uint128 uiZ;
67 struct exp32_sig128 normExpSig;
68 int_fast32_t expZ;
69 uint64_t sig256Z[4];
70 struct uint128 sigZ;
71 int_fast32_t shiftDist, expDiff;
72 struct uint128 x128;
73 uint64_t sig256C[4];
74 static uint64_t zero256[4] = INIT_UINTM4( 0, 0, 0, 0 );
75 uint_fast64_t sigZExtra, sig256Z0;
76 union ui128_f128 uZ;
77
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 signA = signF128UI64( uiA64 );
81 expA = expF128UI64( uiA64 );
82 sigA.v64 = fracF128UI64( uiA64 );
83 sigA.v0 = uiA0;
84 signB = signF128UI64( uiB64 );
85 expB = expF128UI64( uiB64 );
86 sigB.v64 = fracF128UI64( uiB64 );
87 sigB.v0 = uiB0;
88 signC = signF128UI64( uiC64 ) ^ (op == softfloat_mulAdd_subC);
89 expC = expF128UI64( uiC64 );
90 sigC.v64 = fracF128UI64( uiC64 );
91 sigC.v0 = uiC0;
92 signZ = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
93 /*------------------------------------------------------------------------
94 *------------------------------------------------------------------------*/
95 if ( expA == 0x7FFF ) {
96 if (
97 (sigA.v64 | sigA.v0) || ((expB == 0x7FFF) && (sigB.v64 | sigB.v0))
98 ) {
99 goto propagateNaN_ABC;
100 }
101 magBits = expB | sigB.v64 | sigB.v0;
102 goto infProdArg;
103 }
104 if ( expB == 0x7FFF ) {
105 if ( sigB.v64 | sigB.v0 ) goto propagateNaN_ABC;
106 magBits = expA | sigA.v64 | sigA.v0;
107 goto infProdArg;
108 }
109 if ( expC == 0x7FFF ) {
110 if ( sigC.v64 | sigC.v0 ) {
111 uiZ.v64 = 0;
112 uiZ.v0 = 0;
113 goto propagateNaN_ZC;
114 }
115 uiZ.v64 = uiC64;
116 uiZ.v0 = uiC0;
117 goto uiZ;
118 }
119 /*------------------------------------------------------------------------
120 *------------------------------------------------------------------------*/
121 if ( ! expA ) {
122 if ( ! (sigA.v64 | sigA.v0) ) goto zeroProd;
123 normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
124 expA = normExpSig.exp;
125 sigA = normExpSig.sig;
126 }
127 if ( ! expB ) {
128 if ( ! (sigB.v64 | sigB.v0) ) goto zeroProd;
129 normExpSig = softfloat_normSubnormalF128Sig( sigB.v64, sigB.v0 );
130 expB = normExpSig.exp;
131 sigB = normExpSig.sig;
132 }
133 /*------------------------------------------------------------------------
134 *------------------------------------------------------------------------*/
135 expZ = expA + expB - 0x3FFE;
136 sigA.v64 |= UINT64_C( 0x0001000000000000 );
137 sigB.v64 |= UINT64_C( 0x0001000000000000 );
138 sigA = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 8 );
139 sigB = softfloat_shortShiftLeft128( sigB.v64, sigB.v0, 15 );
140 softfloat_mul128To256M( sigA.v64, sigA.v0, sigB.v64, sigB.v0, sig256Z );
141 sigZ.v64 = sig256Z[indexWord( 4, 3 )];
142 sigZ.v0 = sig256Z[indexWord( 4, 2 )];
143 shiftDist = 0;
144 if ( ! (sigZ.v64 & UINT64_C( 0x0100000000000000 )) ) {
145 --expZ;
146 shiftDist = -1;
147 }
148 if ( ! expC ) {
149 if ( ! (sigC.v64 | sigC.v0) ) {
150 shiftDist += 8;
151 goto sigZ;
152 }
153 normExpSig = softfloat_normSubnormalF128Sig( sigC.v64, sigC.v0 );
154 expC = normExpSig.exp;
155 sigC = normExpSig.sig;
156 }
157 sigC.v64 |= UINT64_C( 0x0001000000000000 );
158 sigC = softfloat_shortShiftLeft128( sigC.v64, sigC.v0, 8 );
159 /*------------------------------------------------------------------------
160 *------------------------------------------------------------------------*/
161 expDiff = expZ - expC;
162 if ( expDiff < 0 ) {
163 expZ = expC;
164 if ( (signZ == signC) || (expDiff < -1) ) {
165 shiftDist -= expDiff;
166 if ( shiftDist ) {
167 sigZ =
168 softfloat_shiftRightJam128( sigZ.v64, sigZ.v0, shiftDist );
169 }
170 } else {
171 if ( ! shiftDist ) {
172 x128 =
173 softfloat_shortShiftRight128(
174 sig256Z[indexWord( 4, 1 )], sig256Z[indexWord( 4, 0 )],
175 1
176 );
177 sig256Z[indexWord( 4, 1 )] = (sigZ.v0<<63) | x128.v64;
178 sig256Z[indexWord( 4, 0 )] = x128.v0;
179 sigZ = softfloat_shortShiftRight128( sigZ.v64, sigZ.v0, 1 );
180 sig256Z[indexWord( 4, 3 )] = sigZ.v64;
181 sig256Z[indexWord( 4, 2 )] = sigZ.v0;
182 }
183 }
184 } else {
185 if ( shiftDist ) softfloat_add256M( sig256Z, sig256Z, sig256Z );
186 if ( ! expDiff ) {
187 sigZ.v64 = sig256Z[indexWord( 4, 3 )];
188 sigZ.v0 = sig256Z[indexWord( 4, 2 )];
189 } else {
190 sig256C[indexWord( 4, 3 )] = sigC.v64;
191 sig256C[indexWord( 4, 2 )] = sigC.v0;
192 sig256C[indexWord( 4, 1 )] = 0;
193 sig256C[indexWord( 4, 0 )] = 0;
194 softfloat_shiftRightJam256M( sig256C, expDiff, sig256C );
195 }
196 }
197 /*------------------------------------------------------------------------
198 *------------------------------------------------------------------------*/
199 shiftDist = 8;
200 if ( signZ == signC ) {
201 /*--------------------------------------------------------------------
202 *--------------------------------------------------------------------*/
203 if ( expDiff <= 0 ) {
204 sigZ = softfloat_add128( sigC.v64, sigC.v0, sigZ.v64, sigZ.v0 );
205 } else {
206 softfloat_add256M( sig256Z, sig256C, sig256Z );
207 sigZ.v64 = sig256Z[indexWord( 4, 3 )];
208 sigZ.v0 = sig256Z[indexWord( 4, 2 )];
209 }
210 if ( sigZ.v64 & UINT64_C( 0x0200000000000000 ) ) {
211 ++expZ;
212 shiftDist = 9;
213 }
214 } else {
215 /*--------------------------------------------------------------------
216 *--------------------------------------------------------------------*/
217 if ( expDiff < 0 ) {
218 signZ = signC;
219 if ( expDiff < -1 ) {
220 sigZ =
221 softfloat_sub128( sigC.v64, sigC.v0, sigZ.v64, sigZ.v0 );
222 sigZExtra =
223 sig256Z[indexWord( 4, 1 )] | sig256Z[indexWord( 4, 0 )];
224 if ( sigZExtra ) {
225 sigZ = softfloat_sub128( sigZ.v64, sigZ.v0, 0, 1 );
226 }
227 if ( ! (sigZ.v64 & UINT64_C( 0x0100000000000000 )) ) {
228 --expZ;
229 shiftDist = 7;
230 }
231 goto shiftRightRoundPack;
232 } else {
233 sig256C[indexWord( 4, 3 )] = sigC.v64;
234 sig256C[indexWord( 4, 2 )] = sigC.v0;
235 sig256C[indexWord( 4, 1 )] = 0;
236 sig256C[indexWord( 4, 0 )] = 0;
237 softfloat_sub256M( sig256C, sig256Z, sig256Z );
238 }
239 } else if ( ! expDiff ) {
240 sigZ = softfloat_sub128( sigZ.v64, sigZ.v0, sigC.v64, sigC.v0 );
241 if (
242 ! (sigZ.v64 | sigZ.v0) && ! sig256Z[indexWord( 4, 1 )]
243 && ! sig256Z[indexWord( 4, 0 )]
244 ) {
245 goto completeCancellation;
246 }
247 sig256Z[indexWord( 4, 3 )] = sigZ.v64;
248 sig256Z[indexWord( 4, 2 )] = sigZ.v0;
249 if ( sigZ.v64 & UINT64_C( 0x8000000000000000 ) ) {
250 signZ = ! signZ;
251 softfloat_sub256M( zero256, sig256Z, sig256Z );
252 }
253 } else {
254 softfloat_sub256M( sig256Z, sig256C, sig256Z );
255 if ( 1 < expDiff ) {
256 sigZ.v64 = sig256Z[indexWord( 4, 3 )];
257 sigZ.v0 = sig256Z[indexWord( 4, 2 )];
258 if ( ! (sigZ.v64 & UINT64_C( 0x0100000000000000 )) ) {
259 --expZ;
260 shiftDist = 7;
261 }
262 goto sigZ;
263 }
264 }
265 /*--------------------------------------------------------------------
266 *--------------------------------------------------------------------*/
267 sigZ.v64 = sig256Z[indexWord( 4, 3 )];
268 sigZ.v0 = sig256Z[indexWord( 4, 2 )];
269 sigZExtra = sig256Z[indexWord( 4, 1 )];
270 sig256Z0 = sig256Z[indexWord( 4, 0 )];
271 if ( sigZ.v64 ) {
272 if ( sig256Z0 ) sigZExtra |= 1;
273 } else {
274 expZ -= 64;
275 sigZ.v64 = sigZ.v0;
276 sigZ.v0 = sigZExtra;
277 sigZExtra = sig256Z0;
278 if ( ! sigZ.v64 ) {
279 expZ -= 64;
280 sigZ.v64 = sigZ.v0;
281 sigZ.v0 = sigZExtra;
282 sigZExtra = 0;
283 if ( ! sigZ.v64 ) {
284 expZ -= 64;
285 sigZ.v64 = sigZ.v0;
286 sigZ.v0 = 0;
287 }
288 }
289 }
290 shiftDist = softfloat_countLeadingZeros64( sigZ.v64 );
291 expZ += 7 - shiftDist;
292 shiftDist = 15 - shiftDist;
293 if ( 0 < shiftDist ) goto shiftRightRoundPack;
294 if ( shiftDist ) {
295 shiftDist = -shiftDist;
296 sigZ = softfloat_shortShiftLeft128( sigZ.v64, sigZ.v0, shiftDist );
297 x128 = softfloat_shortShiftLeft128( 0, sigZExtra, shiftDist );
298 sigZ.v0 |= x128.v64;
299 sigZExtra = x128.v0;
300 }
301 goto roundPack;
302 }
303 sigZ:
304 sigZExtra = sig256Z[indexWord( 4, 1 )] | sig256Z[indexWord( 4, 0 )];
305 shiftRightRoundPack:
306 sigZExtra = (uint64_t) (sigZ.v0<<(64 - shiftDist)) | (sigZExtra != 0);
307 sigZ = softfloat_shortShiftRight128( sigZ.v64, sigZ.v0, shiftDist );
308 roundPack:
309 return
310 softfloat_roundPackToF128(
311 signZ, expZ - 1, sigZ.v64, sigZ.v0, sigZExtra );
312 /*------------------------------------------------------------------------
313 *------------------------------------------------------------------------*/
314 propagateNaN_ABC:
315 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
316 goto propagateNaN_ZC;
317 /*------------------------------------------------------------------------
318 *------------------------------------------------------------------------*/
319 infProdArg:
320 if ( magBits ) {
321 uiZ.v64 = packToF128UI64( signZ, 0x7FFF, 0 );
322 uiZ.v0 = 0;
323 if ( expC != 0x7FFF ) goto uiZ;
324 if ( sigC.v64 | sigC.v0 ) goto propagateNaN_ZC;
325 if ( signZ == signC ) goto uiZ;
326 }
327 softfloat_raiseFlags( softfloat_flag_invalid );
328 uiZ.v64 = defaultNaNF128UI64;
329 uiZ.v0 = defaultNaNF128UI0;
330 propagateNaN_ZC:
331 uiZ = softfloat_propagateNaNF128UI( uiZ.v64, uiZ.v0, uiC64, uiC0 );
332 goto uiZ;
333 /*------------------------------------------------------------------------
334 *------------------------------------------------------------------------*/
335 zeroProd:
336 uiZ.v64 = uiC64;
337 uiZ.v0 = uiC0;
338 if ( ! (expC | sigC.v64 | sigC.v0) && (signZ != signC) ) {
339 completeCancellation:
340 uiZ.v64 =
341 packToF128UI64(
342 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
343 uiZ.v0 = 0;
344 }
345 uiZ:
346 uZ.ui = uiZ;
347 return uZ.f;
348
349}
350
deps/SoftFloat-3e/source/s_mulAddF128M.c created+382
......@@ -0,0 +1,382 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44void
45 softfloat_mulAddF128M(
46 const uint32_t *aWPtr,
47 const uint32_t *bWPtr,
48 const uint32_t *cWPtr,
49 uint32_t *zWPtr,
50 uint_fast8_t op
51 )
52{
53 uint32_t uiA96;
54 int32_t expA;
55 uint32_t uiB96;
56 int32_t expB;
57 uint32_t uiC96;
58 bool signC;
59 int32_t expC;
60 bool signProd, prodIsInfinite;
61 uint32_t *ptr, uiZ96, sigA[4];
62 uint_fast8_t shiftDist;
63 uint32_t sigX[5];
64 int32_t expProd;
65 uint32_t sigProd[8], wordSig;
66 bool doSub;
67 uint_fast8_t
68 (*addCarryMRoutinePtr)(
69 uint_fast8_t,
70 const uint32_t *,
71 const uint32_t *,
72 uint_fast8_t,
73 uint32_t *
74 );
75 int32_t expDiff;
76 bool signZ;
77 int32_t expZ;
78 uint32_t *extSigPtr;
79 uint_fast8_t carry;
80 void (*roundPackRoutinePtr)( bool, int32_t, uint32_t *, uint32_t * );
81
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 uiA96 = aWPtr[indexWordHi( 4 )];
85 expA = expF128UI96( uiA96 );
86 uiB96 = bWPtr[indexWordHi( 4 )];
87 expB = expF128UI96( uiB96 );
88 uiC96 = cWPtr[indexWordHi( 4 )];
89 signC = signF128UI96( uiC96 ) ^ (op == softfloat_mulAdd_subC);
90 expC = expF128UI96( uiC96 );
91 signProd =
92 signF128UI96( uiA96 ) ^ signF128UI96( uiB96 )
93 ^ (op == softfloat_mulAdd_subProd);
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 prodIsInfinite = false;
97 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
98 if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) {
99 goto propagateNaN_ZC;
100 }
101 ptr = (uint32_t *) aWPtr;
102 if ( ! (uint32_t) (uiA96<<1) ) goto possibleInvalidProd;
103 if ( ! (uint32_t) (uiB96<<1) ) {
104 ptr = (uint32_t *) bWPtr;
105 possibleInvalidProd:
106 if (
107 ! (ptr[indexWord( 4, 2 )] | ptr[indexWord( 4, 1 )]
108 | ptr[indexWord( 4, 0 )])
109 ) {
110 goto invalid;
111 }
112 }
113 prodIsInfinite = true;
114 }
115 if ( expC == 0x7FFF ) {
116 if (
117 fracF128UI96( uiC96 )
118 || (cWPtr[indexWord( 4, 2 )] | cWPtr[indexWord( 4, 1 )]
119 | cWPtr[indexWord( 4, 0 )])
120 ) {
121 zWPtr[indexWordHi( 4 )] = 0;
122 goto propagateNaN_ZC;
123 }
124 if ( prodIsInfinite && (signProd != signC) ) goto invalid;
125 goto copyC;
126 }
127 if ( prodIsInfinite ) {
128 uiZ96 = packToF128UI96( signProd, 0x7FFF, 0 );
129 goto uiZ;
130 }
131 /*------------------------------------------------------------------------
132 *------------------------------------------------------------------------*/
133 if ( expA ) {
134 sigA[indexWordHi( 4 )] = fracF128UI96( uiA96 ) | 0x00010000;
135 sigA[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
136 sigA[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
137 sigA[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
138 } else {
139 expA = softfloat_shiftNormSigF128M( aWPtr, 0, sigA );
140 if ( expA == -128 ) goto zeroProd;
141 }
142 if ( expB ) {
143 sigX[indexWordHi( 4 )] = fracF128UI96( uiB96 ) | 0x00010000;
144 sigX[indexWord( 4, 2 )] = bWPtr[indexWord( 4, 2 )];
145 sigX[indexWord( 4, 1 )] = bWPtr[indexWord( 4, 1 )];
146 sigX[indexWord( 4, 0 )] = bWPtr[indexWord( 4, 0 )];
147 } else {
148 expB = softfloat_shiftNormSigF128M( bWPtr, 0, sigX );
149 if ( expB == -128 ) goto zeroProd;
150 }
151 /*------------------------------------------------------------------------
152 *------------------------------------------------------------------------*/
153 expProd = expA + expB - 0x3FF0;
154 softfloat_mul128MTo256M( sigA, sigX, sigProd );
155 /*------------------------------------------------------------------------
156 *------------------------------------------------------------------------*/
157 wordSig = fracF128UI96( uiC96 );
158 if ( expC ) {
159 --expC;
160 wordSig |= 0x00010000;
161 }
162 sigX[indexWordHi( 5 )] = wordSig;
163 sigX[indexWord( 5, 3 )] = cWPtr[indexWord( 4, 2 )];
164 sigX[indexWord( 5, 2 )] = cWPtr[indexWord( 4, 1 )];
165 sigX[indexWord( 5, 1 )] = cWPtr[indexWord( 4, 0 )];
166 /*------------------------------------------------------------------------
167 *------------------------------------------------------------------------*/
168 doSub = (signProd != signC);
169 addCarryMRoutinePtr =
170 doSub ? softfloat_addComplCarryM : softfloat_addCarryM;
171 expDiff = expProd - expC;
172 if ( expDiff <= 0 ) {
173 /*--------------------------------------------------------------------
174 *--------------------------------------------------------------------*/
175 signZ = signC;
176 expZ = expC;
177 if (
178 sigProd[indexWord( 8, 2 )]
179 || (sigProd[indexWord( 8, 1 )] | sigProd[indexWord( 8, 0 )])
180 ) {
181 sigProd[indexWord( 8, 3 )] |= 1;
182 }
183 extSigPtr = &sigProd[indexMultiwordHi( 8, 5 )];
184 if ( expDiff ) {
185 softfloat_shiftRightJam160M( extSigPtr, -expDiff, extSigPtr );
186 }
187 carry = 0;
188 if ( doSub ) {
189 wordSig = extSigPtr[indexWordLo( 5 )];
190 extSigPtr[indexWordLo( 5 )] = -wordSig;
191 carry = ! wordSig;
192 }
193 (*addCarryMRoutinePtr)(
194 4,
195 &sigX[indexMultiwordHi( 5, 4 )],
196 extSigPtr + indexMultiwordHi( 5, 4 ),
197 carry,
198 extSigPtr + indexMultiwordHi( 5, 4 )
199 );
200 wordSig = extSigPtr[indexWordHi( 5 )];
201 if ( ! expZ ) {
202 if ( wordSig & 0x80000000 ) {
203 signZ = ! signZ;
204 softfloat_negX160M( extSigPtr );
205 wordSig = extSigPtr[indexWordHi( 5 )];
206 }
207 goto checkCancellation;
208 }
209 if ( wordSig < 0x00010000 ) {
210 --expZ;
211 softfloat_add160M( extSigPtr, extSigPtr, extSigPtr );
212 goto roundPack;
213 }
214 goto extSigReady_noCancellation;
215 } else {
216 /*--------------------------------------------------------------------
217 *--------------------------------------------------------------------*/
218 signZ = signProd;
219 expZ = expProd;
220 sigX[indexWordLo( 5 )] = 0;
221 expDiff -= 128;
222 if ( 0 <= expDiff ) {
223 /*----------------------------------------------------------------
224 *----------------------------------------------------------------*/
225 if ( expDiff ) softfloat_shiftRightJam160M( sigX, expDiff, sigX );
226 wordSig = sigX[indexWordLo( 5 )];
227 carry = 0;
228 if ( doSub ) {
229 carry = ! wordSig;
230 wordSig = -wordSig;
231 }
232 carry =
233 (*addCarryMRoutinePtr)(
234 4,
235 &sigProd[indexMultiwordLo( 8, 4 )],
236 &sigX[indexMultiwordHi( 5, 4 )],
237 carry,
238 &sigProd[indexMultiwordLo( 8, 4 )]
239 );
240 sigProd[indexWord( 8, 2 )] |= wordSig;
241 ptr = &sigProd[indexWord( 8, 4 )];
242 } else {
243 /*----------------------------------------------------------------
244 *----------------------------------------------------------------*/
245 shiftDist = expDiff & 31;
246 if ( shiftDist ) {
247 softfloat_shortShiftRight160M( sigX, shiftDist, sigX );
248 }
249 expDiff >>= 5;
250 extSigPtr =
251 &sigProd[indexMultiwordLo( 8, 5 )] - wordIncr
252 + expDiff * -wordIncr;
253 carry =
254 (*addCarryMRoutinePtr)( 5, extSigPtr, sigX, doSub, extSigPtr );
255 if ( expDiff == -4 ) {
256 /*------------------------------------------------------------
257 *------------------------------------------------------------*/
258 wordSig = sigProd[indexWordHi( 8 )];
259 if ( wordSig & 0x80000000 ) {
260 signZ = ! signZ;
261 softfloat_negX256M( sigProd );
262 wordSig = sigProd[indexWordHi( 8 )];
263 }
264 /*------------------------------------------------------------
265 *------------------------------------------------------------*/
266 if ( wordSig ) goto expProdBigger_noWordShift;
267 wordSig = sigProd[indexWord( 8, 6 )];
268 if ( 0x00040000 <= wordSig ) goto expProdBigger_noWordShift;
269 expZ -= 32;
270 extSigPtr = &sigProd[indexMultiwordHi( 8, 5 )] - wordIncr;
271 for (;;) {
272 if ( wordSig ) break;
273 wordSig = extSigPtr[indexWord( 5, 3 )];
274 if ( 0x00040000 <= wordSig ) break;
275 expZ -= 32;
276 extSigPtr -= wordIncr;
277 if ( extSigPtr == &sigProd[indexMultiwordLo( 8, 5 )] ) {
278 goto checkCancellation;
279 }
280 }
281 /*------------------------------------------------------------
282 *------------------------------------------------------------*/
283 ptr = extSigPtr + indexWordLo( 5 );
284 do {
285 ptr -= wordIncr;
286 if ( *ptr ) {
287 extSigPtr[indexWordLo( 5 )] |= 1;
288 break;
289 }
290 } while ( ptr != &sigProd[indexWordLo( 8 )] );
291 wordSig = extSigPtr[indexWordHi( 5 )];
292 goto extSigReady;
293 }
294 ptr = extSigPtr + indexWordHi( 5 ) + wordIncr;
295 }
296 /*--------------------------------------------------------------------
297 *--------------------------------------------------------------------*/
298 if ( carry != doSub ) {
299 if ( doSub ) {
300 do {
301 wordSig = *ptr;
302 *ptr = wordSig - 1;
303 ptr += wordIncr;
304 } while ( ! wordSig );
305 } else {
306 do {
307 wordSig = *ptr + 1;
308 *ptr = wordSig;
309 ptr += wordIncr;
310 } while ( ! wordSig );
311 }
312 }
313 /*--------------------------------------------------------------------
314 *--------------------------------------------------------------------*/
315 expProdBigger_noWordShift:
316 if (
317 sigProd[indexWord( 8, 2 )]
318 || (sigProd[indexWord( 8, 1 )] | sigProd[indexWord( 8, 0 )])
319 ) {
320 sigProd[indexWord( 8, 3 )] |= 1;
321 }
322 extSigPtr = &sigProd[indexMultiwordHi( 8, 5 )];
323 wordSig = extSigPtr[indexWordHi( 5 )];
324 }
325 extSigReady:
326 roundPackRoutinePtr = softfloat_normRoundPackMToF128M;
327 if ( wordSig < 0x00010000 ) goto doRoundPack;
328 extSigReady_noCancellation:
329 if ( 0x00020000 <= wordSig ) {
330 ++expZ;
331 softfloat_shortShiftRightJam160M( extSigPtr, 1, extSigPtr );
332 }
333 roundPack:
334 roundPackRoutinePtr = softfloat_roundPackMToF128M;
335 doRoundPack:
336 (*roundPackRoutinePtr)( signZ, expZ, extSigPtr, zWPtr );
337 return;
338 /*------------------------------------------------------------------------
339 *------------------------------------------------------------------------*/
340 invalid:
341 softfloat_invalidF128M( zWPtr );
342 propagateNaN_ZC:
343 softfloat_propagateNaNF128M( zWPtr, cWPtr, zWPtr );
344 return;
345 /*------------------------------------------------------------------------
346 *------------------------------------------------------------------------*/
347 zeroProd:
348 if (
349 ! (uint32_t) (uiC96<<1) && (signProd != signC)
350 && ! cWPtr[indexWord( 4, 2 )]
351 && ! (cWPtr[indexWord( 4, 1 )] | cWPtr[indexWord( 4, 0 )])
352 ) {
353 goto completeCancellation;
354 }
355 copyC:
356 zWPtr[indexWordHi( 4 )] = uiC96;
357 zWPtr[indexWord( 4, 2 )] = cWPtr[indexWord( 4, 2 )];
358 zWPtr[indexWord( 4, 1 )] = cWPtr[indexWord( 4, 1 )];
359 zWPtr[indexWord( 4, 0 )] = cWPtr[indexWord( 4, 0 )];
360 return;
361 /*------------------------------------------------------------------------
362 *------------------------------------------------------------------------*/
363 checkCancellation:
364 if (
365 wordSig
366 || (extSigPtr[indexWord( 5, 3 )] | extSigPtr[indexWord( 5, 2 )])
367 || (extSigPtr[indexWord( 5, 1 )] | extSigPtr[indexWord( 5, 0 )])
368 ) {
369 goto extSigReady;
370 }
371 completeCancellation:
372 uiZ96 =
373 packToF128UI96(
374 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
375 uiZ:
376 zWPtr[indexWordHi( 4 )] = uiZ96;
377 zWPtr[indexWord( 4, 2 )] = 0;
378 zWPtr[indexWord( 4, 1 )] = 0;
379 zWPtr[indexWord( 4, 0 )] = 0;
380
381}
382
deps/SoftFloat-3e/source/s_mulAddF16.c created+226
......@@ -0,0 +1,226 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t
45 softfloat_mulAddF16(
46 uint_fast16_t uiA, uint_fast16_t uiB, uint_fast16_t uiC, uint_fast8_t op )
47{
48 bool signA;
49 int_fast8_t expA;
50 uint_fast16_t sigA;
51 bool signB;
52 int_fast8_t expB;
53 uint_fast16_t sigB;
54 bool signC;
55 int_fast8_t expC;
56 uint_fast16_t sigC;
57 bool signProd;
58 uint_fast16_t magBits, uiZ;
59 struct exp8_sig16 normExpSig;
60 int_fast8_t expProd;
61 uint_fast32_t sigProd;
62 bool signZ;
63 int_fast8_t expZ;
64 uint_fast16_t sigZ;
65 int_fast8_t expDiff;
66 uint_fast32_t sig32Z, sig32C;
67 int_fast8_t shiftDist;
68 union ui16_f16 uZ;
69
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 signA = signF16UI( uiA );
73 expA = expF16UI( uiA );
74 sigA = fracF16UI( uiA );
75 signB = signF16UI( uiB );
76 expB = expF16UI( uiB );
77 sigB = fracF16UI( uiB );
78 signC = signF16UI( uiC ) ^ (op == softfloat_mulAdd_subC);
79 expC = expF16UI( uiC );
80 sigC = fracF16UI( uiC );
81 signProd = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( expA == 0x1F ) {
85 if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN_ABC;
86 magBits = expB | sigB;
87 goto infProdArg;
88 }
89 if ( expB == 0x1F ) {
90 if ( sigB ) goto propagateNaN_ABC;
91 magBits = expA | sigA;
92 goto infProdArg;
93 }
94 if ( expC == 0x1F ) {
95 if ( sigC ) {
96 uiZ = 0;
97 goto propagateNaN_ZC;
98 }
99 uiZ = uiC;
100 goto uiZ;
101 }
102 /*------------------------------------------------------------------------
103 *------------------------------------------------------------------------*/
104 if ( ! expA ) {
105 if ( ! sigA ) goto zeroProd;
106 normExpSig = softfloat_normSubnormalF16Sig( sigA );
107 expA = normExpSig.exp;
108 sigA = normExpSig.sig;
109 }
110 if ( ! expB ) {
111 if ( ! sigB ) goto zeroProd;
112 normExpSig = softfloat_normSubnormalF16Sig( sigB );
113 expB = normExpSig.exp;
114 sigB = normExpSig.sig;
115 }
116 /*------------------------------------------------------------------------
117 *------------------------------------------------------------------------*/
118 expProd = expA + expB - 0xE;
119 sigA = (sigA | 0x0400)<<4;
120 sigB = (sigB | 0x0400)<<4;
121 sigProd = (uint_fast32_t) sigA * sigB;
122 if ( sigProd < 0x20000000 ) {
123 --expProd;
124 sigProd <<= 1;
125 }
126 signZ = signProd;
127 if ( ! expC ) {
128 if ( ! sigC ) {
129 expZ = expProd - 1;
130 sigZ = sigProd>>15 | ((sigProd & 0x7FFF) != 0);
131 goto roundPack;
132 }
133 normExpSig = softfloat_normSubnormalF16Sig( sigC );
134 expC = normExpSig.exp;
135 sigC = normExpSig.sig;
136 }
137 sigC = (sigC | 0x0400)<<3;
138 /*------------------------------------------------------------------------
139 *------------------------------------------------------------------------*/
140 expDiff = expProd - expC;
141 if ( signProd == signC ) {
142 /*--------------------------------------------------------------------
143 *--------------------------------------------------------------------*/
144 if ( expDiff <= 0 ) {
145 expZ = expC;
146 sigZ = sigC + softfloat_shiftRightJam32( sigProd, 16 - expDiff );
147 } else {
148 expZ = expProd;
149 sig32Z =
150 sigProd
151 + softfloat_shiftRightJam32(
152 (uint_fast32_t) sigC<<16, expDiff );
153 sigZ = sig32Z>>16 | ((sig32Z & 0xFFFF) != 0 );
154 }
155 if ( sigZ < 0x4000 ) {
156 --expZ;
157 sigZ <<= 1;
158 }
159 } else {
160 /*--------------------------------------------------------------------
161 *--------------------------------------------------------------------*/
162 sig32C = (uint_fast32_t) sigC<<16;
163 if ( expDiff < 0 ) {
164 signZ = signC;
165 expZ = expC;
166 sig32Z = sig32C - softfloat_shiftRightJam32( sigProd, -expDiff );
167 } else if ( ! expDiff ) {
168 expZ = expProd;
169 sig32Z = sigProd - sig32C;
170 if ( ! sig32Z ) goto completeCancellation;
171 if ( sig32Z & 0x80000000 ) {
172 signZ = ! signZ;
173 sig32Z = -sig32Z;
174 }
175 } else {
176 expZ = expProd;
177 sig32Z = sigProd - softfloat_shiftRightJam32( sig32C, expDiff );
178 }
179 shiftDist = softfloat_countLeadingZeros32( sig32Z ) - 1;
180 expZ -= shiftDist;
181 shiftDist -= 16;
182 if ( shiftDist < 0 ) {
183 sigZ =
184 sig32Z>>(-shiftDist)
185 | ((uint32_t) (sig32Z<<(shiftDist & 31)) != 0);
186 } else {
187 sigZ = (uint_fast16_t) sig32Z<<shiftDist;
188 }
189 }
190 roundPack:
191 return softfloat_roundPackToF16( signZ, expZ, sigZ );
192 /*------------------------------------------------------------------------
193 *------------------------------------------------------------------------*/
194 propagateNaN_ABC:
195 uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
196 goto propagateNaN_ZC;
197 /*------------------------------------------------------------------------
198 *------------------------------------------------------------------------*/
199 infProdArg:
200 if ( magBits ) {
201 uiZ = packToF16UI( signProd, 0x1F, 0 );
202 if ( expC != 0x1F ) goto uiZ;
203 if ( sigC ) goto propagateNaN_ZC;
204 if ( signProd == signC ) goto uiZ;
205 }
206 softfloat_raiseFlags( softfloat_flag_invalid );
207 uiZ = defaultNaNF16UI;
208 propagateNaN_ZC:
209 uiZ = softfloat_propagateNaNF16UI( uiZ, uiC );
210 goto uiZ;
211 /*------------------------------------------------------------------------
212 *------------------------------------------------------------------------*/
213 zeroProd:
214 uiZ = uiC;
215 if ( ! (expC | sigC) && (signProd != signC) ) {
216 completeCancellation:
217 uiZ =
218 packToF16UI(
219 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
220 }
221 uiZ:
222 uZ.ui = uiZ;
223 return uZ.f;
224
225}
226
deps/SoftFloat-3e/source/s_mulAddF32.c created+224
......@@ -0,0 +1,224 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t
45 softfloat_mulAddF32(
46 uint_fast32_t uiA, uint_fast32_t uiB, uint_fast32_t uiC, uint_fast8_t op )
47{
48 bool signA;
49 int_fast16_t expA;
50 uint_fast32_t sigA;
51 bool signB;
52 int_fast16_t expB;
53 uint_fast32_t sigB;
54 bool signC;
55 int_fast16_t expC;
56 uint_fast32_t sigC;
57 bool signProd;
58 uint_fast32_t magBits, uiZ;
59 struct exp16_sig32 normExpSig;
60 int_fast16_t expProd;
61 uint_fast64_t sigProd;
62 bool signZ;
63 int_fast16_t expZ;
64 uint_fast32_t sigZ;
65 int_fast16_t expDiff;
66 uint_fast64_t sig64Z, sig64C;
67 int_fast8_t shiftDist;
68 union ui32_f32 uZ;
69
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 signA = signF32UI( uiA );
73 expA = expF32UI( uiA );
74 sigA = fracF32UI( uiA );
75 signB = signF32UI( uiB );
76 expB = expF32UI( uiB );
77 sigB = fracF32UI( uiB );
78 signC = signF32UI( uiC ) ^ (op == softfloat_mulAdd_subC);
79 expC = expF32UI( uiC );
80 sigC = fracF32UI( uiC );
81 signProd = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( expA == 0xFF ) {
85 if ( sigA || ((expB == 0xFF) && sigB) ) goto propagateNaN_ABC;
86 magBits = expB | sigB;
87 goto infProdArg;
88 }
89 if ( expB == 0xFF ) {
90 if ( sigB ) goto propagateNaN_ABC;
91 magBits = expA | sigA;
92 goto infProdArg;
93 }
94 if ( expC == 0xFF ) {
95 if ( sigC ) {
96 uiZ = 0;
97 goto propagateNaN_ZC;
98 }
99 uiZ = uiC;
100 goto uiZ;
101 }
102 /*------------------------------------------------------------------------
103 *------------------------------------------------------------------------*/
104 if ( ! expA ) {
105 if ( ! sigA ) goto zeroProd;
106 normExpSig = softfloat_normSubnormalF32Sig( sigA );
107 expA = normExpSig.exp;
108 sigA = normExpSig.sig;
109 }
110 if ( ! expB ) {
111 if ( ! sigB ) goto zeroProd;
112 normExpSig = softfloat_normSubnormalF32Sig( sigB );
113 expB = normExpSig.exp;
114 sigB = normExpSig.sig;
115 }
116 /*------------------------------------------------------------------------
117 *------------------------------------------------------------------------*/
118 expProd = expA + expB - 0x7E;
119 sigA = (sigA | 0x00800000)<<7;
120 sigB = (sigB | 0x00800000)<<7;
121 sigProd = (uint_fast64_t) sigA * sigB;
122 if ( sigProd < UINT64_C( 0x2000000000000000 ) ) {
123 --expProd;
124 sigProd <<= 1;
125 }
126 signZ = signProd;
127 if ( ! expC ) {
128 if ( ! sigC ) {
129 expZ = expProd - 1;
130 sigZ = softfloat_shortShiftRightJam64( sigProd, 31 );
131 goto roundPack;
132 }
133 normExpSig = softfloat_normSubnormalF32Sig( sigC );
134 expC = normExpSig.exp;
135 sigC = normExpSig.sig;
136 }
137 sigC = (sigC | 0x00800000)<<6;
138 /*------------------------------------------------------------------------
139 *------------------------------------------------------------------------*/
140 expDiff = expProd - expC;
141 if ( signProd == signC ) {
142 /*--------------------------------------------------------------------
143 *--------------------------------------------------------------------*/
144 if ( expDiff <= 0 ) {
145 expZ = expC;
146 sigZ = sigC + softfloat_shiftRightJam64( sigProd, 32 - expDiff );
147 } else {
148 expZ = expProd;
149 sig64Z =
150 sigProd
151 + softfloat_shiftRightJam64(
152 (uint_fast64_t) sigC<<32, expDiff );
153 sigZ = softfloat_shortShiftRightJam64( sig64Z, 32 );
154 }
155 if ( sigZ < 0x40000000 ) {
156 --expZ;
157 sigZ <<= 1;
158 }
159 } else {
160 /*--------------------------------------------------------------------
161 *--------------------------------------------------------------------*/
162 sig64C = (uint_fast64_t) sigC<<32;
163 if ( expDiff < 0 ) {
164 signZ = signC;
165 expZ = expC;
166 sig64Z = sig64C - softfloat_shiftRightJam64( sigProd, -expDiff );
167 } else if ( ! expDiff ) {
168 expZ = expProd;
169 sig64Z = sigProd - sig64C;
170 if ( ! sig64Z ) goto completeCancellation;
171 if ( sig64Z & UINT64_C( 0x8000000000000000 ) ) {
172 signZ = ! signZ;
173 sig64Z = -sig64Z;
174 }
175 } else {
176 expZ = expProd;
177 sig64Z = sigProd - softfloat_shiftRightJam64( sig64C, expDiff );
178 }
179 shiftDist = softfloat_countLeadingZeros64( sig64Z ) - 1;
180 expZ -= shiftDist;
181 shiftDist -= 32;
182 if ( shiftDist < 0 ) {
183 sigZ = softfloat_shortShiftRightJam64( sig64Z, -shiftDist );
184 } else {
185 sigZ = (uint_fast32_t) sig64Z<<shiftDist;
186 }
187 }
188 roundPack:
189 return softfloat_roundPackToF32( signZ, expZ, sigZ );
190 /*------------------------------------------------------------------------
191 *------------------------------------------------------------------------*/
192 propagateNaN_ABC:
193 uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
194 goto propagateNaN_ZC;
195 /*------------------------------------------------------------------------
196 *------------------------------------------------------------------------*/
197 infProdArg:
198 if ( magBits ) {
199 uiZ = packToF32UI( signProd, 0xFF, 0 );
200 if ( expC != 0xFF ) goto uiZ;
201 if ( sigC ) goto propagateNaN_ZC;
202 if ( signProd == signC ) goto uiZ;
203 }
204 softfloat_raiseFlags( softfloat_flag_invalid );
205 uiZ = defaultNaNF32UI;
206 propagateNaN_ZC:
207 uiZ = softfloat_propagateNaNF32UI( uiZ, uiC );
208 goto uiZ;
209 /*------------------------------------------------------------------------
210 *------------------------------------------------------------------------*/
211 zeroProd:
212 uiZ = uiC;
213 if ( ! (expC | sigC) && (signProd != signC) ) {
214 completeCancellation:
215 uiZ =
216 packToF32UI(
217 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
218 }
219 uiZ:
220 uZ.ui = uiZ;
221 return uZ.f;
222
223}
224
deps/SoftFloat-3e/source/s_mulAddF64.c created+496
......@@ -0,0 +1,496 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46float64_t
47 softfloat_mulAddF64(
48 uint_fast64_t uiA, uint_fast64_t uiB, uint_fast64_t uiC, uint_fast8_t op )
49{
50 bool signA;
51 int_fast16_t expA;
52 uint_fast64_t sigA;
53 bool signB;
54 int_fast16_t expB;
55 uint_fast64_t sigB;
56 bool signC;
57 int_fast16_t expC;
58 uint_fast64_t sigC;
59 bool signZ;
60 uint_fast64_t magBits, uiZ;
61 struct exp16_sig64 normExpSig;
62 int_fast16_t expZ;
63 struct uint128 sig128Z;
64 uint_fast64_t sigZ;
65 int_fast16_t expDiff;
66 struct uint128 sig128C;
67 int_fast8_t shiftDist;
68 union ui64_f64 uZ;
69
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 signA = signF64UI( uiA );
73 expA = expF64UI( uiA );
74 sigA = fracF64UI( uiA );
75 signB = signF64UI( uiB );
76 expB = expF64UI( uiB );
77 sigB = fracF64UI( uiB );
78 signC = signF64UI( uiC ) ^ (op == softfloat_mulAdd_subC);
79 expC = expF64UI( uiC );
80 sigC = fracF64UI( uiC );
81 signZ = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( expA == 0x7FF ) {
85 if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN_ABC;
86 magBits = expB | sigB;
87 goto infProdArg;
88 }
89 if ( expB == 0x7FF ) {
90 if ( sigB ) goto propagateNaN_ABC;
91 magBits = expA | sigA;
92 goto infProdArg;
93 }
94 if ( expC == 0x7FF ) {
95 if ( sigC ) {
96 uiZ = 0;
97 goto propagateNaN_ZC;
98 }
99 uiZ = uiC;
100 goto uiZ;
101 }
102 /*------------------------------------------------------------------------
103 *------------------------------------------------------------------------*/
104 if ( ! expA ) {
105 if ( ! sigA ) goto zeroProd;
106 normExpSig = softfloat_normSubnormalF64Sig( sigA );
107 expA = normExpSig.exp;
108 sigA = normExpSig.sig;
109 }
110 if ( ! expB ) {
111 if ( ! sigB ) goto zeroProd;
112 normExpSig = softfloat_normSubnormalF64Sig( sigB );
113 expB = normExpSig.exp;
114 sigB = normExpSig.sig;
115 }
116 /*------------------------------------------------------------------------
117 *------------------------------------------------------------------------*/
118 expZ = expA + expB - 0x3FE;
119 sigA = (sigA | UINT64_C( 0x0010000000000000 ))<<10;
120 sigB = (sigB | UINT64_C( 0x0010000000000000 ))<<10;
121 sig128Z = softfloat_mul64To128( sigA, sigB );
122 if ( sig128Z.v64 < UINT64_C( 0x2000000000000000 ) ) {
123 --expZ;
124 sig128Z =
125 softfloat_add128(
126 sig128Z.v64, sig128Z.v0, sig128Z.v64, sig128Z.v0 );
127 }
128 if ( ! expC ) {
129 if ( ! sigC ) {
130 --expZ;
131 sigZ = sig128Z.v64<<1 | (sig128Z.v0 != 0);
132 goto roundPack;
133 }
134 normExpSig = softfloat_normSubnormalF64Sig( sigC );
135 expC = normExpSig.exp;
136 sigC = normExpSig.sig;
137 }
138 sigC = (sigC | UINT64_C( 0x0010000000000000 ))<<9;
139 /*------------------------------------------------------------------------
140 *------------------------------------------------------------------------*/
141 expDiff = expZ - expC;
142 if ( expDiff < 0 ) {
143 expZ = expC;
144 if ( (signZ == signC) || (expDiff < -1) ) {
145 sig128Z.v64 = softfloat_shiftRightJam64( sig128Z.v64, -expDiff );
146 } else {
147 sig128Z =
148 softfloat_shortShiftRightJam128( sig128Z.v64, sig128Z.v0, 1 );
149 }
150 } else if ( expDiff ) {
151 sig128C = softfloat_shiftRightJam128( sigC, 0, expDiff );
152 }
153 /*------------------------------------------------------------------------
154 *------------------------------------------------------------------------*/
155 if ( signZ == signC ) {
156 /*--------------------------------------------------------------------
157 *--------------------------------------------------------------------*/
158 if ( expDiff <= 0 ) {
159 sigZ = (sigC + sig128Z.v64) | (sig128Z.v0 != 0);
160 } else {
161 sig128Z =
162 softfloat_add128(
163 sig128Z.v64, sig128Z.v0, sig128C.v64, sig128C.v0 );
164 sigZ = sig128Z.v64 | (sig128Z.v0 != 0);
165 }
166 if ( sigZ < UINT64_C( 0x4000000000000000 ) ) {
167 --expZ;
168 sigZ <<= 1;
169 }
170 } else {
171 /*--------------------------------------------------------------------
172 *--------------------------------------------------------------------*/
173 if ( expDiff < 0 ) {
174 signZ = signC;
175 sig128Z = softfloat_sub128( sigC, 0, sig128Z.v64, sig128Z.v0 );
176 } else if ( ! expDiff ) {
177 sig128Z.v64 = sig128Z.v64 - sigC;
178 if ( ! (sig128Z.v64 | sig128Z.v0) ) goto completeCancellation;
179 if ( sig128Z.v64 & UINT64_C( 0x8000000000000000 ) ) {
180 signZ = ! signZ;
181 sig128Z = softfloat_sub128( 0, 0, sig128Z.v64, sig128Z.v0 );
182 }
183 } else {
184 sig128Z =
185 softfloat_sub128(
186 sig128Z.v64, sig128Z.v0, sig128C.v64, sig128C.v0 );
187 }
188 /*--------------------------------------------------------------------
189 *--------------------------------------------------------------------*/
190 if ( ! sig128Z.v64 ) {
191 expZ -= 64;
192 sig128Z.v64 = sig128Z.v0;
193 sig128Z.v0 = 0;
194 }
195 shiftDist = softfloat_countLeadingZeros64( sig128Z.v64 ) - 1;
196 expZ -= shiftDist;
197 if ( shiftDist < 0 ) {
198 sigZ = softfloat_shortShiftRightJam64( sig128Z.v64, -shiftDist );
199 } else {
200 sig128Z =
201 softfloat_shortShiftLeft128(
202 sig128Z.v64, sig128Z.v0, shiftDist );
203 sigZ = sig128Z.v64;
204 }
205 sigZ |= (sig128Z.v0 != 0);
206 }
207 roundPack:
208 return softfloat_roundPackToF64( signZ, expZ, sigZ );
209 /*------------------------------------------------------------------------
210 *------------------------------------------------------------------------*/
211 propagateNaN_ABC:
212 uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
213 goto propagateNaN_ZC;
214 /*------------------------------------------------------------------------
215 *------------------------------------------------------------------------*/
216 infProdArg:
217 if ( magBits ) {
218 uiZ = packToF64UI( signZ, 0x7FF, 0 );
219 if ( expC != 0x7FF ) goto uiZ;
220 if ( sigC ) goto propagateNaN_ZC;
221 if ( signZ == signC ) goto uiZ;
222 }
223 softfloat_raiseFlags( softfloat_flag_invalid );
224 uiZ = defaultNaNF64UI;
225 propagateNaN_ZC:
226 uiZ = softfloat_propagateNaNF64UI( uiZ, uiC );
227 goto uiZ;
228 /*------------------------------------------------------------------------
229 *------------------------------------------------------------------------*/
230 zeroProd:
231 uiZ = uiC;
232 if ( ! (expC | sigC) && (signZ != signC) ) {
233 completeCancellation:
234 uiZ =
235 packToF64UI(
236 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
237 }
238 uiZ:
239 uZ.ui = uiZ;
240 return uZ.f;
241
242}
243
244#else
245
246float64_t
247 softfloat_mulAddF64(
248 uint_fast64_t uiA, uint_fast64_t uiB, uint_fast64_t uiC, uint_fast8_t op )
249{
250 bool signA;
251 int_fast16_t expA;
252 uint64_t sigA;
253 bool signB;
254 int_fast16_t expB;
255 uint64_t sigB;
256 bool signC;
257 int_fast16_t expC;
258 uint64_t sigC;
259 bool signZ;
260 uint64_t magBits, uiZ;
261 struct exp16_sig64 normExpSig;
262 int_fast16_t expZ;
263 uint32_t sig128Z[4];
264 uint64_t sigZ;
265 int_fast16_t shiftDist, expDiff;
266 uint32_t sig128C[4];
267 union ui64_f64 uZ;
268
269 /*------------------------------------------------------------------------
270 *------------------------------------------------------------------------*/
271 signA = signF64UI( uiA );
272 expA = expF64UI( uiA );
273 sigA = fracF64UI( uiA );
274 signB = signF64UI( uiB );
275 expB = expF64UI( uiB );
276 sigB = fracF64UI( uiB );
277 signC = signF64UI( uiC ) ^ (op == softfloat_mulAdd_subC);
278 expC = expF64UI( uiC );
279 sigC = fracF64UI( uiC );
280 signZ = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
281 /*------------------------------------------------------------------------
282 *------------------------------------------------------------------------*/
283 if ( expA == 0x7FF ) {
284 if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN_ABC;
285 magBits = expB | sigB;
286 goto infProdArg;
287 }
288 if ( expB == 0x7FF ) {
289 if ( sigB ) goto propagateNaN_ABC;
290 magBits = expA | sigA;
291 goto infProdArg;
292 }
293 if ( expC == 0x7FF ) {
294 if ( sigC ) {
295 uiZ = 0;
296 goto propagateNaN_ZC;
297 }
298 uiZ = uiC;
299 goto uiZ;
300 }
301 /*------------------------------------------------------------------------
302 *------------------------------------------------------------------------*/
303 if ( ! expA ) {
304 if ( ! sigA ) goto zeroProd;
305 normExpSig = softfloat_normSubnormalF64Sig( sigA );
306 expA = normExpSig.exp;
307 sigA = normExpSig.sig;
308 }
309 if ( ! expB ) {
310 if ( ! sigB ) goto zeroProd;
311 normExpSig = softfloat_normSubnormalF64Sig( sigB );
312 expB = normExpSig.exp;
313 sigB = normExpSig.sig;
314 }
315 /*------------------------------------------------------------------------
316 *------------------------------------------------------------------------*/
317 expZ = expA + expB - 0x3FE;
318 sigA = (sigA | UINT64_C( 0x0010000000000000 ))<<10;
319 sigB = (sigB | UINT64_C( 0x0010000000000000 ))<<11;
320 softfloat_mul64To128M( sigA, sigB, sig128Z );
321 sigZ =
322 (uint64_t) sig128Z[indexWord( 4, 3 )]<<32 | sig128Z[indexWord( 4, 2 )];
323 shiftDist = 0;
324 if ( ! (sigZ & UINT64_C( 0x4000000000000000 )) ) {
325 --expZ;
326 shiftDist = -1;
327 }
328 if ( ! expC ) {
329 if ( ! sigC ) {
330 if ( shiftDist ) sigZ <<= 1;
331 goto sigZ;
332 }
333 normExpSig = softfloat_normSubnormalF64Sig( sigC );
334 expC = normExpSig.exp;
335 sigC = normExpSig.sig;
336 }
337 sigC = (sigC | UINT64_C( 0x0010000000000000 ))<<10;
338 /*------------------------------------------------------------------------
339 *------------------------------------------------------------------------*/
340 expDiff = expZ - expC;
341 if ( expDiff < 0 ) {
342 expZ = expC;
343 if ( (signZ == signC) || (expDiff < -1) ) {
344 shiftDist -= expDiff;
345 if ( shiftDist) {
346 sigZ = softfloat_shiftRightJam64( sigZ, shiftDist );
347 }
348 } else {
349 if ( ! shiftDist ) {
350 softfloat_shortShiftRight128M( sig128Z, 1, sig128Z );
351 }
352 }
353 } else {
354 if ( shiftDist ) softfloat_add128M( sig128Z, sig128Z, sig128Z );
355 if ( ! expDiff ) {
356 sigZ =
357 (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
358 | sig128Z[indexWord( 4, 2 )];
359 } else {
360 sig128C[indexWord( 4, 3 )] = sigC>>32;
361 sig128C[indexWord( 4, 2 )] = sigC;
362 sig128C[indexWord( 4, 1 )] = 0;
363 sig128C[indexWord( 4, 0 )] = 0;
364 softfloat_shiftRightJam128M( sig128C, expDiff, sig128C );
365 }
366 }
367 /*------------------------------------------------------------------------
368 *------------------------------------------------------------------------*/
369 if ( signZ == signC ) {
370 /*--------------------------------------------------------------------
371 *--------------------------------------------------------------------*/
372 if ( expDiff <= 0 ) {
373 sigZ += sigC;
374 } else {
375 softfloat_add128M( sig128Z, sig128C, sig128Z );
376 sigZ =
377 (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
378 | sig128Z[indexWord( 4, 2 )];
379 }
380 if ( sigZ & UINT64_C( 0x8000000000000000 ) ) {
381 ++expZ;
382 sigZ = softfloat_shortShiftRightJam64( sigZ, 1 );
383 }
384 } else {
385 /*--------------------------------------------------------------------
386 *--------------------------------------------------------------------*/
387 if ( expDiff < 0 ) {
388 signZ = signC;
389 if ( expDiff < -1 ) {
390 sigZ = sigC - sigZ;
391 if (
392 sig128Z[indexWord( 4, 1 )] || sig128Z[indexWord( 4, 0 )]
393 ) {
394 sigZ = (sigZ - 1) | 1;
395 }
396 if ( ! (sigZ & UINT64_C( 0x4000000000000000 )) ) {
397 --expZ;
398 sigZ <<= 1;
399 }
400 goto roundPack;
401 } else {
402 sig128C[indexWord( 4, 3 )] = sigC>>32;
403 sig128C[indexWord( 4, 2 )] = sigC;
404 sig128C[indexWord( 4, 1 )] = 0;
405 sig128C[indexWord( 4, 0 )] = 0;
406 softfloat_sub128M( sig128C, sig128Z, sig128Z );
407 }
408 } else if ( ! expDiff ) {
409 sigZ -= sigC;
410 if (
411 ! sigZ && ! sig128Z[indexWord( 4, 1 )]
412 && ! sig128Z[indexWord( 4, 0 )]
413 ) {
414 goto completeCancellation;
415 }
416 sig128Z[indexWord( 4, 3 )] = sigZ>>32;
417 sig128Z[indexWord( 4, 2 )] = sigZ;
418 if ( sigZ & UINT64_C( 0x8000000000000000 ) ) {
419 signZ = ! signZ;
420 softfloat_negX128M( sig128Z );
421 }
422 } else {
423 softfloat_sub128M( sig128Z, sig128C, sig128Z );
424 if ( 1 < expDiff ) {
425 sigZ =
426 (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
427 | sig128Z[indexWord( 4, 2 )];
428 if ( ! (sigZ & UINT64_C( 0x4000000000000000 )) ) {
429 --expZ;
430 sigZ <<= 1;
431 }
432 goto sigZ;
433 }
434 }
435 /*--------------------------------------------------------------------
436 *--------------------------------------------------------------------*/
437 shiftDist = 0;
438 sigZ =
439 (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
440 | sig128Z[indexWord( 4, 2 )];
441 if ( ! sigZ ) {
442 shiftDist = 64;
443 sigZ =
444 (uint64_t) sig128Z[indexWord( 4, 1 )]<<32
445 | sig128Z[indexWord( 4, 0 )];
446 }
447 shiftDist += softfloat_countLeadingZeros64( sigZ ) - 1;
448 if ( shiftDist ) {
449 expZ -= shiftDist;
450 softfloat_shiftLeft128M( sig128Z, shiftDist, sig128Z );
451 sigZ =
452 (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
453 | sig128Z[indexWord( 4, 2 )];
454 }
455 }
456 sigZ:
457 if ( sig128Z[indexWord( 4, 1 )] || sig128Z[indexWord( 4, 0 )] ) sigZ |= 1;
458 roundPack:
459 return softfloat_roundPackToF64( signZ, expZ - 1, sigZ );
460 /*------------------------------------------------------------------------
461 *------------------------------------------------------------------------*/
462 propagateNaN_ABC:
463 uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
464 goto propagateNaN_ZC;
465 /*------------------------------------------------------------------------
466 *------------------------------------------------------------------------*/
467 infProdArg:
468 if ( magBits ) {
469 uiZ = packToF64UI( signZ, 0x7FF, 0 );
470 if ( expC != 0x7FF ) goto uiZ;
471 if ( sigC ) goto propagateNaN_ZC;
472 if ( signZ == signC ) goto uiZ;
473 }
474 softfloat_raiseFlags( softfloat_flag_invalid );
475 uiZ = defaultNaNF64UI;
476 propagateNaN_ZC:
477 uiZ = softfloat_propagateNaNF64UI( uiZ, uiC );
478 goto uiZ;
479 /*------------------------------------------------------------------------
480 *------------------------------------------------------------------------*/
481 zeroProd:
482 uiZ = uiC;
483 if ( ! (expC | sigC) && (signZ != signC) ) {
484 completeCancellation:
485 uiZ =
486 packToF64UI(
487 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
488 }
489 uiZ:
490 uZ.ui = uiZ;
491 return uZ.f;
492
493}
494
495#endif
496
deps/SoftFloat-3e/source/s_negXM.c created+63
......@@ -0,0 +1,63 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_negXM
42
43void softfloat_negXM( uint_fast8_t size_words, uint32_t *zPtr )
44{
45 unsigned int index, lastIndex;
46 uint_fast8_t carry;
47 uint32_t word;
48
49 index = indexWordLo( size_words );
50 lastIndex = indexWordHi( size_words );
51 carry = 1;
52 for (;;) {
53 word = ~zPtr[index] + carry;
54 zPtr[index] = word;
55 if ( index == lastIndex ) break;
56 index += wordIncr;
57 if ( word ) carry = 0;
58 }
59
60}
61
62#endif
63
deps/SoftFloat-3e/source/s_normExtF80SigM.c created+52
......@@ -0,0 +1,52 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40
41int softfloat_normExtF80SigM( uint64_t *sigPtr )
42{
43 uint64_t sig;
44 int_fast8_t shiftDist;
45
46 sig = *sigPtr;
47 shiftDist = softfloat_countLeadingZeros64( sig );
48 *sigPtr = sig<<shiftDist;
49 return -shiftDist;
50
51}
52
deps/SoftFloat-3e/source/s_normRoundPackMToExtF80M.c created+78
......@@ -0,0 +1,78 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41
42void
43 softfloat_normRoundPackMToExtF80M(
44 bool sign,
45 int32_t exp,
46 uint32_t *extSigPtr,
47 uint_fast8_t roundingPrecision,
48 struct extFloat80M *zSPtr
49 )
50{
51 int_fast16_t shiftDist;
52 uint32_t wordSig;
53
54 shiftDist = 0;
55 wordSig = extSigPtr[indexWord( 3, 2 )];
56 if ( ! wordSig ) {
57 shiftDist = 32;
58 wordSig = extSigPtr[indexWord( 3, 1 )];
59 if ( ! wordSig ) {
60 shiftDist = 64;
61 wordSig = extSigPtr[indexWord( 3, 0 )];
62 if ( ! wordSig ) {
63 zSPtr->signExp = packToExtF80UI64( sign, 0 );
64 zSPtr->signif = 0;
65 return;
66 }
67 }
68 }
69 shiftDist += softfloat_countLeadingZeros32( wordSig );
70 if ( shiftDist ) {
71 exp -= shiftDist;
72 softfloat_shiftLeft96M( extSigPtr, shiftDist, extSigPtr );
73 }
74 softfloat_roundPackMToExtF80M(
75 sign, exp, extSigPtr, roundingPrecision, zSPtr );
76
77}
78
deps/SoftFloat-3e/source/s_normRoundPackMToF128M.c created+73
......@@ -0,0 +1,73 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41
42void
43 softfloat_normRoundPackMToF128M(
44 bool sign, int32_t exp, uint32_t *extSigPtr, uint32_t *zWPtr )
45{
46 const uint32_t *ptr;
47 int_fast16_t shiftDist;
48 uint32_t wordSig;
49
50 ptr = extSigPtr + indexWordHi( 5 );
51 shiftDist = 0;
52 for (;;) {
53 wordSig = *ptr;
54 if ( wordSig ) break;
55 shiftDist += 32;
56 if ( 160 <= shiftDist ) {
57 zWPtr[indexWordHi( 4 )] = packToF128UI96( sign, 0, 0 );
58 zWPtr[indexWord( 4, 2 )] = 0;
59 zWPtr[indexWord( 4, 1 )] = 0;
60 zWPtr[indexWord( 4, 0 )] = 0;
61 return;
62 }
63 ptr -= wordIncr;
64 }
65 shiftDist += softfloat_countLeadingZeros32( wordSig ) - 15;
66 if ( shiftDist ) {
67 exp -= shiftDist;
68 softfloat_shiftLeft160M( extSigPtr, shiftDist, extSigPtr );
69 }
70 softfloat_roundPackMToF128M( sign, exp, extSigPtr, zWPtr );
71
72}
73
deps/SoftFloat-3e/source/s_normRoundPackToExtF80.c created+71
......@@ -0,0 +1,71 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41
42extFloat80_t
43 softfloat_normRoundPackToExtF80(
44 bool sign,
45 int_fast32_t exp,
46 uint_fast64_t sig,
47 uint_fast64_t sigExtra,
48 uint_fast8_t roundingPrecision
49 )
50{
51 int_fast8_t shiftDist;
52 struct uint128 sig128;
53
54 if ( ! sig ) {
55 exp -= 64;
56 sig = sigExtra;
57 sigExtra = 0;
58 }
59 shiftDist = softfloat_countLeadingZeros64( sig );
60 exp -= shiftDist;
61 if ( shiftDist ) {
62 sig128 = softfloat_shortShiftLeft128( sig, sigExtra, shiftDist );
63 sig = sig128.v64;
64 sigExtra = sig128.v0;
65 }
66 return
67 softfloat_roundPackToExtF80(
68 sign, exp, sig, sigExtra, roundingPrecision );
69
70}
71
deps/SoftFloat-3e/source/s_normRoundPackToF128.c created+81
......@@ -0,0 +1,81 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41
42float128_t
43 softfloat_normRoundPackToF128(
44 bool sign, int_fast32_t exp, uint_fast64_t sig64, uint_fast64_t sig0 )
45{
46 int_fast8_t shiftDist;
47 struct uint128 sig128;
48 union ui128_f128 uZ;
49 uint_fast64_t sigExtra;
50 struct uint128_extra sig128Extra;
51
52 if ( ! sig64 ) {
53 exp -= 64;
54 sig64 = sig0;
55 sig0 = 0;
56 }
57 shiftDist = softfloat_countLeadingZeros64( sig64 ) - 15;
58 exp -= shiftDist;
59 if ( 0 <= shiftDist ) {
60 if ( shiftDist ) {
61 sig128 = softfloat_shortShiftLeft128( sig64, sig0, shiftDist );
62 sig64 = sig128.v64;
63 sig0 = sig128.v0;
64 }
65 if ( (uint32_t) exp < 0x7FFD ) {
66 uZ.ui.v64 = packToF128UI64( sign, sig64 | sig0 ? exp : 0, sig64 );
67 uZ.ui.v0 = sig0;
68 return uZ.f;
69 }
70 sigExtra = 0;
71 } else {
72 sig128Extra =
73 softfloat_shortShiftRightJam128Extra( sig64, sig0, 0, -shiftDist );
74 sig64 = sig128Extra.v.v64;
75 sig0 = sig128Extra.v.v0;
76 sigExtra = sig128Extra.extra;
77 }
78 return softfloat_roundPackToF128( sign, exp, sig64, sig0, sigExtra );
79
80}
81
deps/SoftFloat-3e/source/s_normRoundPackToF16.c created+58
......@@ -0,0 +1,58 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41
42float16_t
43 softfloat_normRoundPackToF16( bool sign, int_fast16_t exp, uint_fast16_t sig )
44{
45 int_fast8_t shiftDist;
46 union ui16_f16 uZ;
47
48 shiftDist = softfloat_countLeadingZeros16( sig ) - 1;
49 exp -= shiftDist;
50 if ( (4 <= shiftDist) && ((unsigned int) exp < 0x1D) ) {
51 uZ.ui = packToF16UI( sign, sig ? exp : 0, sig<<(shiftDist - 4) );
52 return uZ.f;
53 } else {
54 return softfloat_roundPackToF16( sign, exp, sig<<shiftDist );
55 }
56
57}
58
deps/SoftFloat-3e/source/s_normRoundPackToF32.c created+58
......@@ -0,0 +1,58 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41
42float32_t
43 softfloat_normRoundPackToF32( bool sign, int_fast16_t exp, uint_fast32_t sig )
44{
45 int_fast8_t shiftDist;
46 union ui32_f32 uZ;
47
48 shiftDist = softfloat_countLeadingZeros32( sig ) - 1;
49 exp -= shiftDist;
50 if ( (7 <= shiftDist) && ((unsigned int) exp < 0xFD) ) {
51 uZ.ui = packToF32UI( sign, sig ? exp : 0, sig<<(shiftDist - 7) );
52 return uZ.f;
53 } else {
54 return softfloat_roundPackToF32( sign, exp, sig<<shiftDist );
55 }
56
57}
58
deps/SoftFloat-3e/source/s_normRoundPackToF64.c created+58
......@@ -0,0 +1,58 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41
42float64_t
43 softfloat_normRoundPackToF64( bool sign, int_fast16_t exp, uint_fast64_t sig )
44{
45 int_fast8_t shiftDist;
46 union ui64_f64 uZ;
47
48 shiftDist = softfloat_countLeadingZeros64( sig ) - 1;
49 exp -= shiftDist;
50 if ( (10 <= shiftDist) && ((unsigned int) exp < 0x7FD) ) {
51 uZ.ui = packToF64UI( sign, sig ? exp : 0, sig<<(shiftDist - 10) );
52 return uZ.f;
53 } else {
54 return softfloat_roundPackToF64( sign, exp, sig<<shiftDist );
55 }
56
57}
58
deps/SoftFloat-3e/source/s_normSubnormalExtF80Sig.c created+52
......@@ -0,0 +1,52 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40
41struct exp32_sig64 softfloat_normSubnormalExtF80Sig( uint_fast64_t sig )
42{
43 int_fast8_t shiftDist;
44 struct exp32_sig64 z;
45
46 shiftDist = softfloat_countLeadingZeros64( sig );
47 z.exp = -shiftDist;
48 z.sig = sig<<shiftDist;
49 return z;
50
51}
52
deps/SoftFloat-3e/source/s_normSubnormalF128Sig.c created+65
......@@ -0,0 +1,65 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40
41struct exp32_sig128
42 softfloat_normSubnormalF128Sig( uint_fast64_t sig64, uint_fast64_t sig0 )
43{
44 int_fast8_t shiftDist;
45 struct exp32_sig128 z;
46
47 if ( ! sig64 ) {
48 shiftDist = softfloat_countLeadingZeros64( sig0 ) - 15;
49 z.exp = -63 - shiftDist;
50 if ( shiftDist < 0 ) {
51 z.sig.v64 = sig0>>-shiftDist;
52 z.sig.v0 = sig0<<(shiftDist & 63);
53 } else {
54 z.sig.v64 = sig0<<shiftDist;
55 z.sig.v0 = 0;
56 }
57 } else {
58 shiftDist = softfloat_countLeadingZeros64( sig64 ) - 15;
59 z.exp = 1 - shiftDist;
60 z.sig = softfloat_shortShiftLeft128( sig64, sig0, shiftDist );
61 }
62 return z;
63
64}
65
deps/SoftFloat-3e/source/s_normSubnormalF128SigM.c created+61
......@@ -0,0 +1,61 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40
41int softfloat_normSubnormalF128SigM( uint32_t *sigPtr )
42{
43 const uint32_t *ptr;
44 int_fast16_t shiftDist;
45 uint32_t wordSig;
46
47 ptr = sigPtr + indexWordHi( 4 );
48 shiftDist = 0;
49 for (;;) {
50 wordSig = *ptr;
51 if ( wordSig ) break;
52 shiftDist += 32;
53 if ( 128 <= shiftDist ) return 1;
54 ptr -= wordIncr;
55 }
56 shiftDist += softfloat_countLeadingZeros32( wordSig ) - 15;
57 if ( shiftDist ) softfloat_shiftLeft128M( sigPtr, shiftDist, sigPtr );
58 return 1 - shiftDist;
59
60}
61
deps/SoftFloat-3e/source/s_normSubnormalF16Sig.c created+52
......@@ -0,0 +1,52 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40
41struct exp8_sig16 softfloat_normSubnormalF16Sig( uint_fast16_t sig )
42{
43 int_fast8_t shiftDist;
44 struct exp8_sig16 z;
45
46 shiftDist = softfloat_countLeadingZeros16( sig ) - 5;
47 z.exp = 1 - shiftDist;
48 z.sig = sig<<shiftDist;
49 return z;
50
51}
52
deps/SoftFloat-3e/source/s_normSubnormalF32Sig.c created+52
......@@ -0,0 +1,52 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40
41struct exp16_sig32 softfloat_normSubnormalF32Sig( uint_fast32_t sig )
42{
43 int_fast8_t shiftDist;
44 struct exp16_sig32 z;
45
46 shiftDist = softfloat_countLeadingZeros32( sig ) - 8;
47 z.exp = 1 - shiftDist;
48 z.sig = sig<<shiftDist;
49 return z;
50
51}
52
deps/SoftFloat-3e/source/s_normSubnormalF64Sig.c created+52
......@@ -0,0 +1,52 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40
41struct exp16_sig64 softfloat_normSubnormalF64Sig( uint_fast64_t sig )
42{
43 int_fast8_t shiftDist;
44 struct exp16_sig64 z;
45
46 shiftDist = softfloat_countLeadingZeros64( sig ) - 11;
47 z.exp = 1 - shiftDist;
48 z.sig = sig<<shiftDist;
49 return z;
50
51}
52
deps/SoftFloat-3e/source/s_remStepMBy32.c created+86
......@@ -0,0 +1,86 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_remStepMBy32
42
43void
44 softfloat_remStepMBy32(
45 uint_fast8_t size_words,
46 const uint32_t *remPtr,
47 uint_fast8_t dist,
48 const uint32_t *bPtr,
49 uint32_t q,
50 uint32_t *zPtr
51 )
52{
53 unsigned int index, lastIndex;
54 uint64_t dwordProd;
55 uint32_t wordRem, wordShiftedRem, wordProd;
56 uint_fast8_t uNegDist, borrow;
57
58 index = indexWordLo( size_words );
59 lastIndex = indexWordHi( size_words );
60 dwordProd = (uint64_t) bPtr[index] * q;
61 wordRem = remPtr[index];
62 wordShiftedRem = wordRem<<dist;
63 wordProd = dwordProd;
64 zPtr[index] = wordShiftedRem - wordProd;
65 if ( index != lastIndex ) {
66 uNegDist = -dist;
67 borrow = (wordShiftedRem < wordProd);
68 for (;;) {
69 wordShiftedRem = wordRem>>(uNegDist & 31);
70 index += wordIncr;
71 dwordProd = (uint64_t) bPtr[index] * q + (dwordProd>>32);
72 wordRem = remPtr[index];
73 wordShiftedRem |= wordRem<<dist;
74 wordProd = dwordProd;
75 zPtr[index] = wordShiftedRem - wordProd - borrow;
76 if ( index == lastIndex ) break;
77 borrow =
78 borrow ? (wordShiftedRem <= wordProd)
79 : (wordShiftedRem < wordProd);
80 }
81 }
82
83}
84
85#endif
86
deps/SoftFloat-3e/source/s_roundMToI64.c created+102
......@@ -0,0 +1,102 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t
45 softfloat_roundMToI64(
46 bool sign, uint32_t *extSigPtr, uint_fast8_t roundingMode, bool exact )
47{
48 uint64_t sig;
49 uint32_t sigExtra;
50 union { uint64_t ui; int64_t i; } uZ;
51 int64_t z;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 sig =
56 (uint64_t) extSigPtr[indexWord( 3, 2 )]<<32
57 | extSigPtr[indexWord( 3, 1 )];
58 sigExtra = extSigPtr[indexWordLo( 3 )];
59 if (
60 (roundingMode == softfloat_round_near_maxMag)
61 || (roundingMode == softfloat_round_near_even)
62 ) {
63 if ( 0x80000000 <= sigExtra ) goto increment;
64 } else {
65 if (
66 sigExtra
67 && (sign
68 ? (roundingMode == softfloat_round_min)
69#ifdef SOFTFLOAT_ROUND_ODD
70 || (roundingMode == softfloat_round_odd)
71#endif
72 : (roundingMode == softfloat_round_max))
73 ) {
74 increment:
75 ++sig;
76 if ( !sig ) goto invalid;
77 if (
78 (sigExtra == 0x80000000)
79 && (roundingMode == softfloat_round_near_even)
80 ) {
81 sig &= ~(uint_fast64_t) 1;
82 }
83 }
84 }
85 uZ.ui = sign ? -sig : sig;
86 z = uZ.i;
87 if ( z && ((z < 0) ^ sign) ) goto invalid;
88 if ( sigExtra ) {
89#ifdef SOFTFLOAT_ROUND_ODD
90 if ( roundingMode == softfloat_round_odd ) z |= 1;
91#endif
92 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
93 }
94 return z;
95 /*------------------------------------------------------------------------
96 *------------------------------------------------------------------------*/
97 invalid:
98 softfloat_raiseFlags( softfloat_flag_invalid );
99 return sign ? i64_fromNegOverflow : i64_fromPosOverflow;
100
101}
102
deps/SoftFloat-3e/source/s_roundMToUI64.c created+98
......@@ -0,0 +1,98 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t
45 softfloat_roundMToUI64(
46 bool sign, uint32_t *extSigPtr, uint_fast8_t roundingMode, bool exact )
47{
48 uint64_t sig;
49 uint32_t sigExtra;
50
51 /*------------------------------------------------------------------------
52 *------------------------------------------------------------------------*/
53 sig =
54 (uint64_t) extSigPtr[indexWord( 3, 2 )]<<32
55 | extSigPtr[indexWord( 3, 1 )];
56 sigExtra = extSigPtr[indexWordLo( 3 )];
57 if (
58 (roundingMode == softfloat_round_near_maxMag)
59 || (roundingMode == softfloat_round_near_even)
60 ) {
61 if ( 0x80000000 <= sigExtra ) goto increment;
62 } else {
63 if ( sign ) {
64 if ( !(sig | sigExtra) ) return 0;
65 if ( roundingMode == softfloat_round_min ) goto invalid;
66#ifdef SOFTFLOAT_ROUND_ODD
67 if ( roundingMode == softfloat_round_odd ) goto invalid;
68#endif
69 } else {
70 if ( (roundingMode == softfloat_round_max) && sigExtra ) {
71 increment:
72 ++sig;
73 if ( !sig ) goto invalid;
74 if (
75 (sigExtra == 0x80000000)
76 && (roundingMode == softfloat_round_near_even)
77 ) {
78 sig &= ~(uint_fast64_t) 1;
79 }
80 }
81 }
82 }
83 if ( sign && sig ) goto invalid;
84 if ( sigExtra ) {
85#ifdef SOFTFLOAT_ROUND_ODD
86 if ( roundingMode == softfloat_round_odd ) sig |= 1;
87#endif
88 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
89 }
90 return sig;
91 /*------------------------------------------------------------------------
92 *------------------------------------------------------------------------*/
93 invalid:
94 softfloat_raiseFlags( softfloat_flag_invalid );
95 return sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
96
97}
98
deps/SoftFloat-3e/source/s_roundPackMToExtF80M.c created+256
......@@ -0,0 +1,256 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43void
44 softfloat_roundPackMToExtF80M(
45 bool sign,
46 int32_t exp,
47 uint32_t *extSigPtr,
48 uint_fast8_t roundingPrecision,
49 struct extFloat80M *zSPtr
50 )
51{
52 uint_fast8_t roundingMode;
53 bool roundNearEven;
54 uint64_t sig, roundIncrement, roundMask, roundBits;
55 bool isTiny;
56 uint32_t sigExtra;
57 bool doIncrement;
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 roundingMode = softfloat_roundingMode;
62 roundNearEven = (roundingMode == softfloat_round_near_even);
63 sig =
64 (uint64_t) extSigPtr[indexWord( 3, 2 )]<<32
65 | extSigPtr[indexWord( 3, 1 )];
66 if ( roundingPrecision == 80 ) goto precision80;
67 if ( roundingPrecision == 64 ) {
68 roundIncrement = UINT64_C( 0x0000000000000400 );
69 roundMask = UINT64_C( 0x00000000000007FF );
70 } else if ( roundingPrecision == 32 ) {
71 roundIncrement = UINT64_C( 0x0000008000000000 );
72 roundMask = UINT64_C( 0x000000FFFFFFFFFF );
73 } else {
74 goto precision80;
75 }
76 /*------------------------------------------------------------------------
77 *------------------------------------------------------------------------*/
78 if ( extSigPtr[indexWordLo( 3 )] ) sig |= 1;
79 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
80 roundIncrement =
81 (roundingMode
82 == (sign ? softfloat_round_min : softfloat_round_max))
83 ? roundMask
84 : 0;
85 }
86 roundBits = sig & roundMask;
87 /*------------------------------------------------------------------------
88 *------------------------------------------------------------------------*/
89 if ( 0x7FFD <= (uint32_t) (exp - 1) ) {
90 if ( exp <= 0 ) {
91 /*----------------------------------------------------------------
92 *----------------------------------------------------------------*/
93 isTiny =
94 (softfloat_detectTininess
95 == softfloat_tininess_beforeRounding)
96 || (exp < 0)
97 || (sig <= (uint64_t) (sig + roundIncrement));
98 sig = softfloat_shiftRightJam64( sig, 1 - exp );
99 roundBits = sig & roundMask;
100 if ( roundBits ) {
101 if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );
102 softfloat_exceptionFlags |= softfloat_flag_inexact;
103#ifdef SOFTFLOAT_ROUND_ODD
104 if ( roundingMode == softfloat_round_odd ) {
105 sig |= roundMask + 1;
106 }
107#endif
108 }
109 sig += roundIncrement;
110 exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);
111 roundIncrement = roundMask + 1;
112 if ( roundNearEven && (roundBits<<1 == roundIncrement) ) {
113 roundMask |= roundIncrement;
114 }
115 sig &= ~roundMask;
116 goto packReturn;
117 }
118 if (
119 (0x7FFE < exp)
120 || ((exp == 0x7FFE) && ((uint64_t) (sig + roundIncrement) < sig))
121 ) {
122 goto overflow;
123 }
124 }
125 /*------------------------------------------------------------------------
126 *------------------------------------------------------------------------*/
127 if ( roundBits ) {
128 softfloat_exceptionFlags |= softfloat_flag_inexact;
129#ifdef SOFTFLOAT_ROUND_ODD
130 if ( roundingMode == softfloat_round_odd ) {
131 sig = (sig & ~roundMask) | (roundMask + 1);
132 goto packReturn;
133 }
134#endif
135 }
136 sig += roundIncrement;
137 if ( sig < roundIncrement ) {
138 ++exp;
139 sig = UINT64_C( 0x8000000000000000 );
140 }
141 roundIncrement = roundMask + 1;
142 if ( roundNearEven && (roundBits<<1 == roundIncrement) ) {
143 roundMask |= roundIncrement;
144 }
145 sig &= ~roundMask;
146 goto packReturn;
147 /*------------------------------------------------------------------------
148 *------------------------------------------------------------------------*/
149 precision80:
150 sigExtra = extSigPtr[indexWordLo( 3 )];
151 doIncrement = (0x80000000 <= sigExtra);
152 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
153 doIncrement =
154 (roundingMode
155 == (sign ? softfloat_round_min : softfloat_round_max))
156 && sigExtra;
157 }
158 /*------------------------------------------------------------------------
159 *------------------------------------------------------------------------*/
160 if ( 0x7FFD <= (uint32_t) (exp - 1) ) {
161 if ( exp <= 0 ) {
162 /*----------------------------------------------------------------
163 *----------------------------------------------------------------*/
164 isTiny =
165 (softfloat_detectTininess
166 == softfloat_tininess_beforeRounding)
167 || (exp < 0)
168 || ! doIncrement
169 || (sig < UINT64_C( 0xFFFFFFFFFFFFFFFF ));
170 softfloat_shiftRightJam96M( extSigPtr, 1 - exp, extSigPtr );
171 exp = 0;
172 sig =
173 (uint64_t) extSigPtr[indexWord( 3, 2 )]<<32
174 | extSigPtr[indexWord( 3, 1 )];
175 sigExtra = extSigPtr[indexWordLo( 3 )];
176 if ( sigExtra ) {
177 if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );
178 softfloat_exceptionFlags |= softfloat_flag_inexact;
179#ifdef SOFTFLOAT_ROUND_ODD
180 if ( roundingMode == softfloat_round_odd ) {
181 sig |= 1;
182 goto packReturn;
183 }
184#endif
185 }
186 doIncrement = (0x80000000 <= sigExtra);
187 if (
188 ! roundNearEven
189 && (roundingMode != softfloat_round_near_maxMag)
190 ) {
191 doIncrement =
192 (roundingMode
193 == (sign ? softfloat_round_min : softfloat_round_max))
194 && sigExtra;
195 }
196 if ( doIncrement ) {
197 ++sig;
198 sig &= ~(uint64_t) (! (sigExtra & 0x7FFFFFFF) & roundNearEven);
199 exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);
200 }
201 goto packReturn;
202 }
203 if (
204 (0x7FFE < exp)
205 || ((exp == 0x7FFE) && (sig == UINT64_C( 0xFFFFFFFFFFFFFFFF ))
206 && doIncrement)
207 ) {
208 /*----------------------------------------------------------------
209 *----------------------------------------------------------------*/
210 roundMask = 0;
211 overflow:
212 softfloat_raiseFlags(
213 softfloat_flag_overflow | softfloat_flag_inexact );
214 if (
215 roundNearEven
216 || (roundingMode == softfloat_round_near_maxMag)
217 || (roundingMode
218 == (sign ? softfloat_round_min : softfloat_round_max))
219 ) {
220 exp = 0x7FFF;
221 sig = UINT64_C( 0x8000000000000000 );
222 } else {
223 exp = 0x7FFE;
224 sig = ~roundMask;
225 }
226 goto packReturn;
227 }
228 }
229 /*------------------------------------------------------------------------
230 *------------------------------------------------------------------------*/
231 if ( sigExtra ) {
232 softfloat_exceptionFlags |= softfloat_flag_inexact;
233#ifdef SOFTFLOAT_ROUND_ODD
234 if ( roundingMode == softfloat_round_odd ) {
235 sig |= 1;
236 goto packReturn;
237 }
238#endif
239 }
240 if ( doIncrement ) {
241 ++sig;
242 if ( ! sig ) {
243 ++exp;
244 sig = UINT64_C( 0x8000000000000000 );
245 } else {
246 sig &= ~(uint64_t) (! (sigExtra & 0x7FFFFFFF) & roundNearEven);
247 }
248 }
249 /*------------------------------------------------------------------------
250 *------------------------------------------------------------------------*/
251 packReturn:
252 zSPtr->signExp = packToExtF80UI64( sign, exp );
253 zSPtr->signif = sig;
254
255}
256
deps/SoftFloat-3e/source/s_roundPackMToF128M.c created+178
......@@ -0,0 +1,178 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43void
44 softfloat_roundPackMToF128M(
45 bool sign, int32_t exp, uint32_t *extSigPtr, uint32_t *zWPtr )
46{
47 uint_fast8_t roundingMode;
48 bool roundNearEven;
49 uint32_t sigExtra;
50 bool doIncrement, isTiny;
51 static const uint32_t maxSig[4] =
52 INIT_UINTM4( 0x0001FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF );
53 uint32_t ui, uj;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 roundingMode = softfloat_roundingMode;
58 roundNearEven = (roundingMode == softfloat_round_near_even);
59 sigExtra = extSigPtr[indexWordLo( 5 )];
60 doIncrement = (0x80000000 <= sigExtra);
61 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
62 doIncrement =
63 (roundingMode
64 == (sign ? softfloat_round_min : softfloat_round_max))
65 && sigExtra;
66 }
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 if ( 0x7FFD <= (uint32_t) exp ) {
70 if ( exp < 0 ) {
71 /*----------------------------------------------------------------
72 *----------------------------------------------------------------*/
73 isTiny =
74 (softfloat_detectTininess
75 == softfloat_tininess_beforeRounding)
76 || (exp < -1)
77 || ! doIncrement
78 || (softfloat_compare128M(
79 extSigPtr + indexMultiwordHi( 5, 4 ), maxSig )
80 < 0);
81 softfloat_shiftRightJam160M( extSigPtr, -exp, extSigPtr );
82 exp = 0;
83 sigExtra = extSigPtr[indexWordLo( 5 )];
84 if ( isTiny && sigExtra ) {
85 softfloat_raiseFlags( softfloat_flag_underflow );
86 }
87 doIncrement = (0x80000000 <= sigExtra);
88 if (
89 ! roundNearEven
90 && (roundingMode != softfloat_round_near_maxMag)
91 ) {
92 doIncrement =
93 (roundingMode
94 == (sign ? softfloat_round_min : softfloat_round_max))
95 && sigExtra;
96 }
97 } else if (
98 (0x7FFD < exp)
99 || ((exp == 0x7FFD) && doIncrement
100 && (softfloat_compare128M(
101 extSigPtr + indexMultiwordHi( 5, 4 ), maxSig )
102 == 0))
103 ) {
104 /*----------------------------------------------------------------
105 *----------------------------------------------------------------*/
106 softfloat_raiseFlags(
107 softfloat_flag_overflow | softfloat_flag_inexact );
108 if (
109 roundNearEven
110 || (roundingMode == softfloat_round_near_maxMag)
111 || (roundingMode
112 == (sign ? softfloat_round_min : softfloat_round_max))
113 ) {
114 ui = packToF128UI96( sign, 0x7FFF, 0 );
115 uj = 0;
116 } else {
117 ui = packToF128UI96( sign, 0x7FFE, 0x0000FFFF );
118 uj = 0xFFFFFFFF;
119 }
120 zWPtr[indexWordHi( 4 )] = ui;
121 zWPtr[indexWord( 4, 2 )] = uj;
122 zWPtr[indexWord( 4, 1 )] = uj;
123 zWPtr[indexWord( 4, 0 )] = uj;
124 return;
125 }
126 }
127 /*------------------------------------------------------------------------
128 *------------------------------------------------------------------------*/
129 uj = extSigPtr[indexWord( 5, 1 )];
130 if ( sigExtra ) {
131 softfloat_exceptionFlags |= softfloat_flag_inexact;
132#ifdef SOFTFLOAT_ROUND_ODD
133 if ( roundingMode == softfloat_round_odd ) {
134 uj |= 1;
135 goto noIncrementPackReturn;
136 }
137#endif
138 }
139 if ( doIncrement ) {
140 ++uj;
141 if ( uj ) {
142 if ( ! (sigExtra & 0x7FFFFFFF) && roundNearEven ) uj &= ~1;
143 zWPtr[indexWord( 4, 2 )] = extSigPtr[indexWord( 5, 3 )];
144 zWPtr[indexWord( 4, 1 )] = extSigPtr[indexWord( 5, 2 )];
145 zWPtr[indexWord( 4, 0 )] = uj;
146 ui = extSigPtr[indexWordHi( 5 )];
147 } else {
148 zWPtr[indexWord( 4, 0 )] = uj;
149 ui = extSigPtr[indexWord( 5, 2 )] + 1;
150 zWPtr[indexWord( 4, 1 )] = ui;
151 uj = extSigPtr[indexWord( 5, 3 )];
152 if ( ui ) {
153 zWPtr[indexWord( 4, 2 )] = uj;
154 ui = extSigPtr[indexWordHi( 5 )];
155 } else {
156 ++uj;
157 zWPtr[indexWord( 4, 2 )] = uj;
158 ui = extSigPtr[indexWordHi( 5 )];
159 if ( ! uj ) ++ui;
160 }
161 }
162 } else {
163 noIncrementPackReturn:
164 zWPtr[indexWord( 4, 0 )] = uj;
165 ui = extSigPtr[indexWord( 5, 2 )];
166 zWPtr[indexWord( 4, 1 )] = ui;
167 uj |= ui;
168 ui = extSigPtr[indexWord( 5, 3 )];
169 zWPtr[indexWord( 4, 2 )] = ui;
170 uj |= ui;
171 ui = extSigPtr[indexWordHi( 5 )];
172 uj |= ui;
173 if ( ! uj ) exp = 0;
174 }
175 zWPtr[indexWordHi( 4 )] = packToF128UI96( sign, exp, ui );
176
177}
178
deps/SoftFloat-3e/source/s_roundPackToExtF80.c created+256
......@@ -0,0 +1,256 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43extFloat80_t
44 softfloat_roundPackToExtF80(
45 bool sign,
46 int_fast32_t exp,
47 uint_fast64_t sig,
48 uint_fast64_t sigExtra,
49 uint_fast8_t roundingPrecision
50 )
51{
52 uint_fast8_t roundingMode;
53 bool roundNearEven;
54 uint_fast64_t roundIncrement, roundMask, roundBits;
55 bool isTiny, doIncrement;
56 struct uint64_extra sig64Extra;
57 union { struct extFloat80M s; extFloat80_t f; } uZ;
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 roundingMode = softfloat_roundingMode;
62 roundNearEven = (roundingMode == softfloat_round_near_even);
63 if ( roundingPrecision == 80 ) goto precision80;
64 if ( roundingPrecision == 64 ) {
65 roundIncrement = UINT64_C( 0x0000000000000400 );
66 roundMask = UINT64_C( 0x00000000000007FF );
67 } else if ( roundingPrecision == 32 ) {
68 roundIncrement = UINT64_C( 0x0000008000000000 );
69 roundMask = UINT64_C( 0x000000FFFFFFFFFF );
70 } else {
71 goto precision80;
72 }
73 sig |= (sigExtra != 0);
74 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
75 roundIncrement =
76 (roundingMode
77 == (sign ? softfloat_round_min : softfloat_round_max))
78 ? roundMask
79 : 0;
80 }
81 roundBits = sig & roundMask;
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 if ( 0x7FFD <= (uint32_t) (exp - 1) ) {
85 if ( exp <= 0 ) {
86 /*----------------------------------------------------------------
87 *----------------------------------------------------------------*/
88 isTiny =
89 (softfloat_detectTininess
90 == softfloat_tininess_beforeRounding)
91 || (exp < 0)
92 || (sig <= (uint64_t) (sig + roundIncrement));
93 sig = softfloat_shiftRightJam64( sig, 1 - exp );
94 roundBits = sig & roundMask;
95 if ( roundBits ) {
96 if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );
97 softfloat_exceptionFlags |= softfloat_flag_inexact;
98#ifdef SOFTFLOAT_ROUND_ODD
99 if ( roundingMode == softfloat_round_odd ) {
100 sig |= roundMask + 1;
101 }
102#endif
103 }
104 sig += roundIncrement;
105 exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);
106 roundIncrement = roundMask + 1;
107 if ( roundNearEven && (roundBits<<1 == roundIncrement) ) {
108 roundMask |= roundIncrement;
109 }
110 sig &= ~roundMask;
111 goto packReturn;
112 }
113 if (
114 (0x7FFE < exp)
115 || ((exp == 0x7FFE) && ((uint64_t) (sig + roundIncrement) < sig))
116 ) {
117 goto overflow;
118 }
119 }
120 /*------------------------------------------------------------------------
121 *------------------------------------------------------------------------*/
122 if ( roundBits ) {
123 softfloat_exceptionFlags |= softfloat_flag_inexact;
124#ifdef SOFTFLOAT_ROUND_ODD
125 if ( roundingMode == softfloat_round_odd ) {
126 sig = (sig & ~roundMask) | (roundMask + 1);
127 goto packReturn;
128 }
129#endif
130 }
131 sig = (uint64_t) (sig + roundIncrement);
132 if ( sig < roundIncrement ) {
133 ++exp;
134 sig = UINT64_C( 0x8000000000000000 );
135 }
136 roundIncrement = roundMask + 1;
137 if ( roundNearEven && (roundBits<<1 == roundIncrement) ) {
138 roundMask |= roundIncrement;
139 }
140 sig &= ~roundMask;
141 goto packReturn;
142 /*------------------------------------------------------------------------
143 *------------------------------------------------------------------------*/
144 precision80:
145 doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
146 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
147 doIncrement =
148 (roundingMode
149 == (sign ? softfloat_round_min : softfloat_round_max))
150 && sigExtra;
151 }
152 /*------------------------------------------------------------------------
153 *------------------------------------------------------------------------*/
154 if ( 0x7FFD <= (uint32_t) (exp - 1) ) {
155 if ( exp <= 0 ) {
156 /*----------------------------------------------------------------
157 *----------------------------------------------------------------*/
158 isTiny =
159 (softfloat_detectTininess
160 == softfloat_tininess_beforeRounding)
161 || (exp < 0)
162 || ! doIncrement
163 || (sig < UINT64_C( 0xFFFFFFFFFFFFFFFF ));
164 sig64Extra =
165 softfloat_shiftRightJam64Extra( sig, sigExtra, 1 - exp );
166 exp = 0;
167 sig = sig64Extra.v;
168 sigExtra = sig64Extra.extra;
169 if ( sigExtra ) {
170 if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );
171 softfloat_exceptionFlags |= softfloat_flag_inexact;
172#ifdef SOFTFLOAT_ROUND_ODD
173 if ( roundingMode == softfloat_round_odd ) {
174 sig |= 1;
175 goto packReturn;
176 }
177#endif
178 }
179 doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
180 if (
181 ! roundNearEven
182 && (roundingMode != softfloat_round_near_maxMag)
183 ) {
184 doIncrement =
185 (roundingMode
186 == (sign ? softfloat_round_min : softfloat_round_max))
187 && sigExtra;
188 }
189 if ( doIncrement ) {
190 ++sig;
191 sig &=
192 ~(uint_fast64_t)
193 (! (sigExtra & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
194 & roundNearEven);
195 exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);
196 }
197 goto packReturn;
198 }
199 if (
200 (0x7FFE < exp)
201 || ((exp == 0x7FFE) && (sig == UINT64_C( 0xFFFFFFFFFFFFFFFF ))
202 && doIncrement)
203 ) {
204 /*----------------------------------------------------------------
205 *----------------------------------------------------------------*/
206 roundMask = 0;
207 overflow:
208 softfloat_raiseFlags(
209 softfloat_flag_overflow | softfloat_flag_inexact );
210 if (
211 roundNearEven
212 || (roundingMode == softfloat_round_near_maxMag)
213 || (roundingMode
214 == (sign ? softfloat_round_min : softfloat_round_max))
215 ) {
216 exp = 0x7FFF;
217 sig = UINT64_C( 0x8000000000000000 );
218 } else {
219 exp = 0x7FFE;
220 sig = ~roundMask;
221 }
222 goto packReturn;
223 }
224 }
225 /*------------------------------------------------------------------------
226 *------------------------------------------------------------------------*/
227 if ( sigExtra ) {
228 softfloat_exceptionFlags |= softfloat_flag_inexact;
229#ifdef SOFTFLOAT_ROUND_ODD
230 if ( roundingMode == softfloat_round_odd ) {
231 sig |= 1;
232 goto packReturn;
233 }
234#endif
235 }
236 if ( doIncrement ) {
237 ++sig;
238 if ( ! sig ) {
239 ++exp;
240 sig = UINT64_C( 0x8000000000000000 );
241 } else {
242 sig &=
243 ~(uint_fast64_t)
244 (! (sigExtra & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
245 & roundNearEven);
246 }
247 }
248 /*------------------------------------------------------------------------
249 *------------------------------------------------------------------------*/
250 packReturn:
251 uZ.s.signExp = packToExtF80UI64( sign, exp );
252 uZ.s.signif = sig;
253 return uZ.f;
254
255}
256
deps/SoftFloat-3e/source/s_roundPackToF128.c created+171
......@@ -0,0 +1,171 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float128_t
44 softfloat_roundPackToF128(
45 bool sign,
46 int_fast32_t exp,
47 uint_fast64_t sig64,
48 uint_fast64_t sig0,
49 uint_fast64_t sigExtra
50 )
51{
52 uint_fast8_t roundingMode;
53 bool roundNearEven, doIncrement, isTiny;
54 struct uint128_extra sig128Extra;
55 uint_fast64_t uiZ64, uiZ0;
56 struct uint128 sig128;
57 union ui128_f128 uZ;
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 roundingMode = softfloat_roundingMode;
62 roundNearEven = (roundingMode == softfloat_round_near_even);
63 doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
64 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
65 doIncrement =
66 (roundingMode
67 == (sign ? softfloat_round_min : softfloat_round_max))
68 && sigExtra;
69 }
70 /*------------------------------------------------------------------------
71 *------------------------------------------------------------------------*/
72 if ( 0x7FFD <= (uint32_t) exp ) {
73 if ( exp < 0 ) {
74 /*----------------------------------------------------------------
75 *----------------------------------------------------------------*/
76 isTiny =
77 (softfloat_detectTininess
78 == softfloat_tininess_beforeRounding)
79 || (exp < -1)
80 || ! doIncrement
81 || softfloat_lt128(
82 sig64,
83 sig0,
84 UINT64_C( 0x0001FFFFFFFFFFFF ),
85 UINT64_C( 0xFFFFFFFFFFFFFFFF )
86 );
87 sig128Extra =
88 softfloat_shiftRightJam128Extra( sig64, sig0, sigExtra, -exp );
89 sig64 = sig128Extra.v.v64;
90 sig0 = sig128Extra.v.v0;
91 sigExtra = sig128Extra.extra;
92 exp = 0;
93 if ( isTiny && sigExtra ) {
94 softfloat_raiseFlags( softfloat_flag_underflow );
95 }
96 doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
97 if (
98 ! roundNearEven
99 && (roundingMode != softfloat_round_near_maxMag)
100 ) {
101 doIncrement =
102 (roundingMode
103 == (sign ? softfloat_round_min : softfloat_round_max))
104 && sigExtra;
105 }
106 } else if (
107 (0x7FFD < exp)
108 || ((exp == 0x7FFD)
109 && softfloat_eq128(
110 sig64,
111 sig0,
112 UINT64_C( 0x0001FFFFFFFFFFFF ),
113 UINT64_C( 0xFFFFFFFFFFFFFFFF )
114 )
115 && doIncrement)
116 ) {
117 /*----------------------------------------------------------------
118 *----------------------------------------------------------------*/
119 softfloat_raiseFlags(
120 softfloat_flag_overflow | softfloat_flag_inexact );
121 if (
122 roundNearEven
123 || (roundingMode == softfloat_round_near_maxMag)
124 || (roundingMode
125 == (sign ? softfloat_round_min : softfloat_round_max))
126 ) {
127 uiZ64 = packToF128UI64( sign, 0x7FFF, 0 );
128 uiZ0 = 0;
129 } else {
130 uiZ64 =
131 packToF128UI64(
132 sign, 0x7FFE, UINT64_C( 0x0000FFFFFFFFFFFF ) );
133 uiZ0 = UINT64_C( 0xFFFFFFFFFFFFFFFF );
134 }
135 goto uiZ;
136 }
137 }
138 /*------------------------------------------------------------------------
139 *------------------------------------------------------------------------*/
140 if ( sigExtra ) {
141 softfloat_exceptionFlags |= softfloat_flag_inexact;
142#ifdef SOFTFLOAT_ROUND_ODD
143 if ( roundingMode == softfloat_round_odd ) {
144 sig0 |= 1;
145 goto packReturn;
146 }
147#endif
148 }
149 if ( doIncrement ) {
150 sig128 = softfloat_add128( sig64, sig0, 0, 1 );
151 sig64 = sig128.v64;
152 sig0 =
153 sig128.v0
154 & ~(uint64_t)
155 (! (sigExtra & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
156 & roundNearEven);
157 } else {
158 if ( ! (sig64 | sig0) ) exp = 0;
159 }
160 /*------------------------------------------------------------------------
161 *------------------------------------------------------------------------*/
162 packReturn:
163 uiZ64 = packToF128UI64( sign, exp, sig64 );
164 uiZ0 = sig0;
165 uiZ:
166 uZ.ui.v64 = uiZ64;
167 uZ.ui.v0 = uiZ0;
168 return uZ.f;
169
170}
171
deps/SoftFloat-3e/source/s_roundPackToF16.c created+113
......@@ -0,0 +1,113 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float16_t
44 softfloat_roundPackToF16( bool sign, int_fast16_t exp, uint_fast16_t sig )
45{
46 uint_fast8_t roundingMode;
47 bool roundNearEven;
48 uint_fast8_t roundIncrement, roundBits;
49 bool isTiny;
50 uint_fast16_t uiZ;
51 union ui16_f16 uZ;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 roundingMode = softfloat_roundingMode;
56 roundNearEven = (roundingMode == softfloat_round_near_even);
57 roundIncrement = 0x8;
58 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
59 roundIncrement =
60 (roundingMode
61 == (sign ? softfloat_round_min : softfloat_round_max))
62 ? 0xF
63 : 0;
64 }
65 roundBits = sig & 0xF;
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 if ( 0x1D <= (unsigned int) exp ) {
69 if ( exp < 0 ) {
70 /*----------------------------------------------------------------
71 *----------------------------------------------------------------*/
72 isTiny =
73 (softfloat_detectTininess == softfloat_tininess_beforeRounding)
74 || (exp < -1) || (sig + roundIncrement < 0x8000);
75 sig = softfloat_shiftRightJam32( sig, -exp );
76 exp = 0;
77 roundBits = sig & 0xF;
78 if ( isTiny && roundBits ) {
79 softfloat_raiseFlags( softfloat_flag_underflow );
80 }
81 } else if ( (0x1D < exp) || (0x8000 <= sig + roundIncrement) ) {
82 /*----------------------------------------------------------------
83 *----------------------------------------------------------------*/
84 softfloat_raiseFlags(
85 softfloat_flag_overflow | softfloat_flag_inexact );
86 uiZ = packToF16UI( sign, 0x1F, 0 ) - ! roundIncrement;
87 goto uiZ;
88 }
89 }
90 /*------------------------------------------------------------------------
91 *------------------------------------------------------------------------*/
92 sig = (sig + roundIncrement)>>4;
93 if ( roundBits ) {
94 softfloat_exceptionFlags |= softfloat_flag_inexact;
95#ifdef SOFTFLOAT_ROUND_ODD
96 if ( roundingMode == softfloat_round_odd ) {
97 sig |= 1;
98 goto packReturn;
99 }
100#endif
101 }
102 sig &= ~(uint_fast16_t) (! (roundBits ^ 8) & roundNearEven);
103 if ( ! sig ) exp = 0;
104 /*------------------------------------------------------------------------
105 *------------------------------------------------------------------------*/
106 packReturn:
107 uiZ = packToF16UI( sign, exp, sig );
108 uiZ:
109 uZ.ui = uiZ;
110 return uZ.f;
111
112}
113
deps/SoftFloat-3e/source/s_roundPackToF32.c created+113
......@@ -0,0 +1,113 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float32_t
44 softfloat_roundPackToF32( bool sign, int_fast16_t exp, uint_fast32_t sig )
45{
46 uint_fast8_t roundingMode;
47 bool roundNearEven;
48 uint_fast8_t roundIncrement, roundBits;
49 bool isTiny;
50 uint_fast32_t uiZ;
51 union ui32_f32 uZ;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 roundingMode = softfloat_roundingMode;
56 roundNearEven = (roundingMode == softfloat_round_near_even);
57 roundIncrement = 0x40;
58 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
59 roundIncrement =
60 (roundingMode
61 == (sign ? softfloat_round_min : softfloat_round_max))
62 ? 0x7F
63 : 0;
64 }
65 roundBits = sig & 0x7F;
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 if ( 0xFD <= (unsigned int) exp ) {
69 if ( exp < 0 ) {
70 /*----------------------------------------------------------------
71 *----------------------------------------------------------------*/
72 isTiny =
73 (softfloat_detectTininess == softfloat_tininess_beforeRounding)
74 || (exp < -1) || (sig + roundIncrement < 0x80000000);
75 sig = softfloat_shiftRightJam32( sig, -exp );
76 exp = 0;
77 roundBits = sig & 0x7F;
78 if ( isTiny && roundBits ) {
79 softfloat_raiseFlags( softfloat_flag_underflow );
80 }
81 } else if ( (0xFD < exp) || (0x80000000 <= sig + roundIncrement) ) {
82 /*----------------------------------------------------------------
83 *----------------------------------------------------------------*/
84 softfloat_raiseFlags(
85 softfloat_flag_overflow | softfloat_flag_inexact );
86 uiZ = packToF32UI( sign, 0xFF, 0 ) - ! roundIncrement;
87 goto uiZ;
88 }
89 }
90 /*------------------------------------------------------------------------
91 *------------------------------------------------------------------------*/
92 sig = (sig + roundIncrement)>>7;
93 if ( roundBits ) {
94 softfloat_exceptionFlags |= softfloat_flag_inexact;
95#ifdef SOFTFLOAT_ROUND_ODD
96 if ( roundingMode == softfloat_round_odd ) {
97 sig |= 1;
98 goto packReturn;
99 }
100#endif
101 }
102 sig &= ~(uint_fast32_t) (! (roundBits ^ 0x40) & roundNearEven);
103 if ( ! sig ) exp = 0;
104 /*------------------------------------------------------------------------
105 *------------------------------------------------------------------------*/
106 packReturn:
107 uiZ = packToF32UI( sign, exp, sig );
108 uiZ:
109 uZ.ui = uiZ;
110 return uZ.f;
111
112}
113
deps/SoftFloat-3e/source/s_roundPackToF64.c created+117
......@@ -0,0 +1,117 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "softfloat.h"
42
43float64_t
44 softfloat_roundPackToF64( bool sign, int_fast16_t exp, uint_fast64_t sig )
45{
46 uint_fast8_t roundingMode;
47 bool roundNearEven;
48 uint_fast16_t roundIncrement, roundBits;
49 bool isTiny;
50 uint_fast64_t uiZ;
51 union ui64_f64 uZ;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 roundingMode = softfloat_roundingMode;
56 roundNearEven = (roundingMode == softfloat_round_near_even);
57 roundIncrement = 0x200;
58 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
59 roundIncrement =
60 (roundingMode
61 == (sign ? softfloat_round_min : softfloat_round_max))
62 ? 0x3FF
63 : 0;
64 }
65 roundBits = sig & 0x3FF;
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 if ( 0x7FD <= (uint16_t) exp ) {
69 if ( exp < 0 ) {
70 /*----------------------------------------------------------------
71 *----------------------------------------------------------------*/
72 isTiny =
73 (softfloat_detectTininess == softfloat_tininess_beforeRounding)
74 || (exp < -1)
75 || (sig + roundIncrement < UINT64_C( 0x8000000000000000 ));
76 sig = softfloat_shiftRightJam64( sig, -exp );
77 exp = 0;
78 roundBits = sig & 0x3FF;
79 if ( isTiny && roundBits ) {
80 softfloat_raiseFlags( softfloat_flag_underflow );
81 }
82 } else if (
83 (0x7FD < exp)
84 || (UINT64_C( 0x8000000000000000 ) <= sig + roundIncrement)
85 ) {
86 /*----------------------------------------------------------------
87 *----------------------------------------------------------------*/
88 softfloat_raiseFlags(
89 softfloat_flag_overflow | softfloat_flag_inexact );
90 uiZ = packToF64UI( sign, 0x7FF, 0 ) - ! roundIncrement;
91 goto uiZ;
92 }
93 }
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 sig = (sig + roundIncrement)>>10;
97 if ( roundBits ) {
98 softfloat_exceptionFlags |= softfloat_flag_inexact;
99#ifdef SOFTFLOAT_ROUND_ODD
100 if ( roundingMode == softfloat_round_odd ) {
101 sig |= 1;
102 goto packReturn;
103 }
104#endif
105 }
106 sig &= ~(uint_fast64_t) (! (roundBits ^ 0x200) & roundNearEven);
107 if ( ! sig ) exp = 0;
108 /*------------------------------------------------------------------------
109 *------------------------------------------------------------------------*/
110 packReturn:
111 uiZ = packToF64UI( sign, exp, sig );
112 uiZ:
113 uZ.ui = uiZ;
114 return uZ.f;
115
116}
117
deps/SoftFloat-3e/source/s_roundToI32.c created+98
......@@ -0,0 +1,98 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast32_t
45 softfloat_roundToI32(
46 bool sign, uint_fast64_t sig, uint_fast8_t roundingMode, bool exact )
47{
48 uint_fast16_t roundIncrement, roundBits;
49 uint_fast32_t sig32;
50 union { uint32_t ui; int32_t i; } uZ;
51 int_fast32_t z;
52
53 /*------------------------------------------------------------------------
54 *------------------------------------------------------------------------*/
55 roundIncrement = 0x800;
56 if (
57 (roundingMode != softfloat_round_near_maxMag)
58 && (roundingMode != softfloat_round_near_even)
59 ) {
60 roundIncrement = 0;
61 if (
62 sign
63 ? (roundingMode == softfloat_round_min)
64#ifdef SOFTFLOAT_ROUND_ODD
65 || (roundingMode == softfloat_round_odd)
66#endif
67 : (roundingMode == softfloat_round_max)
68 ) {
69 roundIncrement = 0xFFF;
70 }
71 }
72 roundBits = sig & 0xFFF;
73 sig += roundIncrement;
74 if ( sig & UINT64_C( 0xFFFFF00000000000 ) ) goto invalid;
75 sig32 = sig>>12;
76 if (
77 (roundBits == 0x800) && (roundingMode == softfloat_round_near_even)
78 ) {
79 sig32 &= ~(uint_fast32_t) 1;
80 }
81 uZ.ui = sign ? -sig32 : sig32;
82 z = uZ.i;
83 if ( z && ((z < 0) ^ sign) ) goto invalid;
84 if ( roundBits ) {
85#ifdef SOFTFLOAT_ROUND_ODD
86 if ( roundingMode == softfloat_round_odd ) z |= 1;
87#endif
88 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
89 }
90 return z;
91 /*------------------------------------------------------------------------
92 *------------------------------------------------------------------------*/
93 invalid:
94 softfloat_raiseFlags( softfloat_flag_invalid );
95 return sign ? i32_fromNegOverflow : i32_fromPosOverflow;
96
97}
98
deps/SoftFloat-3e/source/s_roundToI64.c created+101
......@@ -0,0 +1,101 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44int_fast64_t
45 softfloat_roundToI64(
46 bool sign,
47 uint_fast64_t sig,
48 uint_fast64_t sigExtra,
49 uint_fast8_t roundingMode,
50 bool exact
51 )
52{
53 union { uint64_t ui; int64_t i; } uZ;
54 int_fast64_t z;
55
56 /*------------------------------------------------------------------------
57 *------------------------------------------------------------------------*/
58 if (
59 (roundingMode == softfloat_round_near_maxMag)
60 || (roundingMode == softfloat_round_near_even)
61 ) {
62 if ( UINT64_C( 0x8000000000000000 ) <= sigExtra ) goto increment;
63 } else {
64 if (
65 sigExtra
66 && (sign
67 ? (roundingMode == softfloat_round_min)
68#ifdef SOFTFLOAT_ROUND_ODD
69 || (roundingMode == softfloat_round_odd)
70#endif
71 : (roundingMode == softfloat_round_max))
72 ) {
73 increment:
74 ++sig;
75 if ( !sig ) goto invalid;
76 if (
77 (sigExtra == UINT64_C( 0x8000000000000000 ))
78 && (roundingMode == softfloat_round_near_even)
79 ) {
80 sig &= ~(uint_fast64_t) 1;
81 }
82 }
83 }
84 uZ.ui = sign ? -sig : sig;
85 z = uZ.i;
86 if ( z && ((z < 0) ^ sign) ) goto invalid;
87 if ( sigExtra ) {
88#ifdef SOFTFLOAT_ROUND_ODD
89 if ( roundingMode == softfloat_round_odd ) z |= 1;
90#endif
91 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
92 }
93 return z;
94 /*------------------------------------------------------------------------
95 *------------------------------------------------------------------------*/
96 invalid:
97 softfloat_raiseFlags( softfloat_flag_invalid );
98 return sign ? i64_fromNegOverflow : i64_fromPosOverflow;
99
100}
101
deps/SoftFloat-3e/source/s_roundToUI32.c created+93
......@@ -0,0 +1,93 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast32_t
45 softfloat_roundToUI32(
46 bool sign, uint_fast64_t sig, uint_fast8_t roundingMode, bool exact )
47{
48 uint_fast16_t roundIncrement, roundBits;
49 uint_fast32_t z;
50
51 /*------------------------------------------------------------------------
52 *------------------------------------------------------------------------*/
53 roundIncrement = 0x800;
54 if (
55 (roundingMode != softfloat_round_near_maxMag)
56 && (roundingMode != softfloat_round_near_even)
57 ) {
58 roundIncrement = 0;
59 if ( sign ) {
60 if ( !sig ) return 0;
61 if ( roundingMode == softfloat_round_min ) goto invalid;
62#ifdef SOFTFLOAT_ROUND_ODD
63 if ( roundingMode == softfloat_round_odd ) goto invalid;
64#endif
65 } else {
66 if ( roundingMode == softfloat_round_max ) roundIncrement = 0xFFF;
67 }
68 }
69 roundBits = sig & 0xFFF;
70 sig += roundIncrement;
71 if ( sig & UINT64_C( 0xFFFFF00000000000 ) ) goto invalid;
72 z = sig>>12;
73 if (
74 (roundBits == 0x800) && (roundingMode == softfloat_round_near_even)
75 ) {
76 z &= ~(uint_fast32_t) 1;
77 }
78 if ( sign && z ) goto invalid;
79 if ( roundBits ) {
80#ifdef SOFTFLOAT_ROUND_ODD
81 if ( roundingMode == softfloat_round_odd ) z |= 1;
82#endif
83 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
84 }
85 return z;
86 /*------------------------------------------------------------------------
87 *------------------------------------------------------------------------*/
88 invalid:
89 softfloat_raiseFlags( softfloat_flag_invalid );
90 return sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
91
92}
93
deps/SoftFloat-3e/source/s_roundToUI64.c created+97
......@@ -0,0 +1,97 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44uint_fast64_t
45 softfloat_roundToUI64(
46 bool sign,
47 uint_fast64_t sig,
48 uint_fast64_t sigExtra,
49 uint_fast8_t roundingMode,
50 bool exact
51 )
52{
53
54 /*------------------------------------------------------------------------
55 *------------------------------------------------------------------------*/
56 if (
57 (roundingMode == softfloat_round_near_maxMag)
58 || (roundingMode == softfloat_round_near_even)
59 ) {
60 if ( UINT64_C( 0x8000000000000000 ) <= sigExtra ) goto increment;
61 } else {
62 if ( sign ) {
63 if ( !(sig | sigExtra) ) return 0;
64 if ( roundingMode == softfloat_round_min ) goto invalid;
65#ifdef SOFTFLOAT_ROUND_ODD
66 if ( roundingMode == softfloat_round_odd ) goto invalid;
67#endif
68 } else {
69 if ( (roundingMode == softfloat_round_max) && sigExtra ) {
70 increment:
71 ++sig;
72 if ( !sig ) goto invalid;
73 if (
74 (sigExtra == UINT64_C( 0x8000000000000000 ))
75 && (roundingMode == softfloat_round_near_even)
76 ) {
77 sig &= ~(uint_fast64_t) 1;
78 }
79 }
80 }
81 }
82 if ( sign && sig ) goto invalid;
83 if ( sigExtra ) {
84#ifdef SOFTFLOAT_ROUND_ODD
85 if ( roundingMode == softfloat_round_odd ) sig |= 1;
86#endif
87 if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
88 }
89 return sig;
90 /*------------------------------------------------------------------------
91 *------------------------------------------------------------------------*/
92 invalid:
93 softfloat_raiseFlags( softfloat_flag_invalid );
94 return sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
95
96}
97
deps/SoftFloat-3e/source/s_shiftLeftM.c created+91
......@@ -0,0 +1,91 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_shiftLeftM
41
42#define softfloat_shiftLeftM softfloat_shiftLeftM
43#include "primitives.h"
44
45void
46 softfloat_shiftLeftM(
47 uint_fast8_t size_words,
48 const uint32_t *aPtr,
49 uint32_t dist,
50 uint32_t *zPtr
51 )
52{
53 uint32_t wordDist;
54 uint_fast8_t innerDist;
55 uint32_t *destPtr;
56 uint_fast8_t i;
57
58 wordDist = dist>>5;
59 if ( wordDist < size_words ) {
60 aPtr += indexMultiwordLoBut( size_words, wordDist );
61 innerDist = dist & 31;
62 if ( innerDist ) {
63 softfloat_shortShiftLeftM(
64 size_words - wordDist,
65 aPtr,
66 innerDist,
67 zPtr + indexMultiwordHiBut( size_words, wordDist )
68 );
69 if ( ! wordDist ) return;
70 } else {
71 aPtr += indexWordHi( size_words - wordDist );
72 destPtr = zPtr + indexWordHi( size_words );
73 for ( i = size_words - wordDist; i; --i ) {
74 *destPtr = *aPtr;
75 aPtr -= wordIncr;
76 destPtr -= wordIncr;
77 }
78 }
79 zPtr += indexMultiwordLo( size_words, wordDist );
80 } else {
81 wordDist = size_words;
82 }
83 do {
84 *zPtr++ = 0;
85 --wordDist;
86 } while ( wordDist );
87
88}
89
90#endif
91
deps/SoftFloat-3e/source/s_shiftNormSigF128M.c created+78
......@@ -0,0 +1,78 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40
41int
42 softfloat_shiftNormSigF128M(
43 const uint32_t *wPtr, uint_fast8_t shiftDist, uint32_t *sigPtr )
44{
45 uint32_t wordSig;
46 int32_t exp;
47 uint32_t leadingBit;
48
49 wordSig = wPtr[indexWordHi( 4 )];
50 exp = expF128UI96( wordSig );
51 if ( exp ) {
52 softfloat_shortShiftLeft128M( wPtr, shiftDist, sigPtr );
53 leadingBit = 0x00010000<<shiftDist;
54 sigPtr[indexWordHi( 4 )] =
55 (sigPtr[indexWordHi( 4 )] & (leadingBit - 1)) | leadingBit;
56 } else {
57 exp = 16;
58 wordSig &= 0x7FFFFFFF;
59 if ( ! wordSig ) {
60 exp = -16;
61 wordSig = wPtr[indexWord( 4, 2 )];
62 if ( ! wordSig ) {
63 exp = -48;
64 wordSig = wPtr[indexWord( 4, 1 )];
65 if ( ! wordSig ) {
66 wordSig = wPtr[indexWord( 4, 0 )];
67 if ( ! wordSig ) return -128;
68 exp = -80;
69 }
70 }
71 }
72 exp -= softfloat_countLeadingZeros32( wordSig );
73 softfloat_shiftLeft128M( wPtr, 1 - exp + shiftDist, sigPtr );
74 }
75 return exp;
76
77}
78
deps/SoftFloat-3e/source/s_shiftRightJam128.c created+69
......@@ -0,0 +1,69 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shiftRightJam128
42
43struct uint128
44 softfloat_shiftRightJam128( uint64_t a64, uint64_t a0, uint_fast32_t dist )
45{
46 uint_fast8_t u8NegDist;
47 struct uint128 z;
48
49 if ( dist < 64 ) {
50 u8NegDist = -dist;
51 z.v64 = a64>>dist;
52 z.v0 =
53 a64<<(u8NegDist & 63) | a0>>dist
54 | ((uint64_t) (a0<<(u8NegDist & 63)) != 0);
55 } else {
56 z.v64 = 0;
57 z.v0 =
58 (dist < 127)
59 ? a64>>(dist & 63)
60 | (((a64 & (((uint_fast64_t) 1<<(dist & 63)) - 1)) | a0)
61 != 0)
62 : ((a64 | a0) != 0);
63 }
64 return z;
65
66}
67
68#endif
69
deps/SoftFloat-3e/source/s_shiftRightJam128Extra.c created+77
......@@ -0,0 +1,77 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shiftRightJam128Extra
42
43struct uint128_extra
44 softfloat_shiftRightJam128Extra(
45 uint64_t a64, uint64_t a0, uint64_t extra, uint_fast32_t dist )
46{
47 uint_fast8_t u8NegDist;
48 struct uint128_extra z;
49
50 u8NegDist = -dist;
51 if ( dist < 64 ) {
52 z.v.v64 = a64>>dist;
53 z.v.v0 = a64<<(u8NegDist & 63) | a0>>dist;
54 z.extra = a0<<(u8NegDist & 63);
55 } else {
56 z.v.v64 = 0;
57 if ( dist == 64 ) {
58 z.v.v0 = a64;
59 z.extra = a0;
60 } else {
61 extra |= a0;
62 if ( dist < 128 ) {
63 z.v.v0 = a64>>(dist & 63);
64 z.extra = a64<<(u8NegDist & 63);
65 } else {
66 z.v.v0 = 0;
67 z.extra = (dist == 128) ? a64 : (a64 != 0);
68 }
69 }
70 }
71 z.extra |= (extra != 0);
72 return z;
73
74}
75
76#endif
77
deps/SoftFloat-3e/source/s_shiftRightJam256M.c created+126
......@@ -0,0 +1,126 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shiftRightJam256M
42
43static
44 void
45 softfloat_shortShiftRightJamM(
46 uint_fast8_t size_words,
47 const uint64_t *aPtr,
48 uint_fast8_t dist,
49 uint64_t *zPtr
50 )
51{
52 uint_fast8_t uNegDist;
53 unsigned int index, lastIndex;
54 uint64_t partWordZ, wordA;
55
56 uNegDist = -dist;
57 index = indexWordLo( size_words );
58 lastIndex = indexWordHi( size_words );
59 wordA = aPtr[index];
60 partWordZ = wordA>>dist;
61 if ( partWordZ<<dist != wordA ) partWordZ |= 1;
62 while ( index != lastIndex ) {
63 wordA = aPtr[index + wordIncr];
64 zPtr[index] = wordA<<(uNegDist & 63) | partWordZ;
65 index += wordIncr;
66 partWordZ = wordA>>dist;
67 }
68 zPtr[index] = partWordZ;
69
70}
71
72void
73 softfloat_shiftRightJam256M(
74 const uint64_t *aPtr, uint_fast32_t dist, uint64_t *zPtr )
75{
76 uint64_t wordJam;
77 uint_fast32_t wordDist;
78 uint64_t *ptr;
79 uint_fast8_t i, innerDist;
80
81 wordJam = 0;
82 wordDist = dist>>6;
83 if ( wordDist ) {
84 if ( 4 < wordDist ) wordDist = 4;
85 ptr = (uint64_t *) (aPtr + indexMultiwordLo( 4, wordDist ));
86 i = wordDist;
87 do {
88 wordJam = *ptr++;
89 if ( wordJam ) break;
90 --i;
91 } while ( i );
92 ptr = zPtr;
93 }
94 if ( wordDist < 4 ) {
95 aPtr += indexMultiwordHiBut( 4, wordDist );
96 innerDist = dist & 63;
97 if ( innerDist ) {
98 softfloat_shortShiftRightJamM(
99 4 - wordDist,
100 aPtr,
101 innerDist,
102 zPtr + indexMultiwordLoBut( 4, wordDist )
103 );
104 if ( ! wordDist ) goto wordJam;
105 } else {
106 aPtr += indexWordLo( 4 - wordDist );
107 ptr = zPtr + indexWordLo( 4 );
108 for ( i = 4 - wordDist; i; --i ) {
109 *ptr = *aPtr;
110 aPtr += wordIncr;
111 ptr += wordIncr;
112 }
113 }
114 ptr = zPtr + indexMultiwordHi( 4, wordDist );
115 }
116 do {
117 *ptr++ = 0;
118 --wordDist;
119 } while ( wordDist );
120 wordJam:
121 if ( wordJam ) zPtr[indexWordLo( 4 )] |= 1;
122
123}
124
125#endif
126
deps/SoftFloat-3e/source/s_shiftRightJam32.c created+51
......@@ -0,0 +1,51 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_shiftRightJam32
41
42uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist )
43{
44
45 return
46 (dist < 31) ? a>>dist | ((uint32_t) (a<<(-dist & 31)) != 0) : (a != 0);
47
48}
49
50#endif
51
deps/SoftFloat-3e/source/s_shiftRightJam64.c created+51
......@@ -0,0 +1,51 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_shiftRightJam64
41
42uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist )
43{
44
45 return
46 (dist < 63) ? a>>dist | ((uint64_t) (a<<(-dist & 63)) != 0) : (a != 0);
47
48}
49
50#endif
51
deps/SoftFloat-3e/source/s_shiftRightJam64Extra.c created+62
......@@ -0,0 +1,62 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shiftRightJam64Extra
42
43struct uint64_extra
44 softfloat_shiftRightJam64Extra(
45 uint64_t a, uint64_t extra, uint_fast32_t dist )
46{
47 struct uint64_extra z;
48
49 if ( dist < 64 ) {
50 z.v = a>>dist;
51 z.extra = a<<(-dist & 63);
52 } else {
53 z.v = 0;
54 z.extra = (dist == 64) ? a : (a != 0);
55 }
56 z.extra |= (extra != 0);
57 return z;
58
59}
60
61#endif
62
deps/SoftFloat-3e/source/s_shiftRightJamM.c created+101
......@@ -0,0 +1,101 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_shiftRightJamM
41
42#define softfloat_shiftRightJamM softfloat_shiftRightJamM
43#include "primitives.h"
44
45void
46 softfloat_shiftRightJamM(
47 uint_fast8_t size_words,
48 const uint32_t *aPtr,
49 uint32_t dist,
50 uint32_t *zPtr
51 )
52{
53 uint32_t wordJam, wordDist, *ptr;
54 uint_fast8_t i, innerDist;
55
56 wordJam = 0;
57 wordDist = dist>>5;
58 if ( wordDist ) {
59 if ( size_words < wordDist ) wordDist = size_words;
60 ptr = (uint32_t *) (aPtr + indexMultiwordLo( size_words, wordDist ));
61 i = wordDist;
62 do {
63 wordJam = *ptr++;
64 if ( wordJam ) break;
65 --i;
66 } while ( i );
67 ptr = zPtr;
68 }
69 if ( wordDist < size_words ) {
70 aPtr += indexMultiwordHiBut( size_words, wordDist );
71 innerDist = dist & 31;
72 if ( innerDist ) {
73 softfloat_shortShiftRightJamM(
74 size_words - wordDist,
75 aPtr,
76 innerDist,
77 zPtr + indexMultiwordLoBut( size_words, wordDist )
78 );
79 if ( ! wordDist ) goto wordJam;
80 } else {
81 aPtr += indexWordLo( size_words - wordDist );
82 ptr = zPtr + indexWordLo( size_words );
83 for ( i = size_words - wordDist; i; --i ) {
84 *ptr = *aPtr;
85 aPtr += wordIncr;
86 ptr += wordIncr;
87 }
88 }
89 ptr = zPtr + indexMultiwordHi( size_words, wordDist );
90 }
91 do {
92 *ptr++ = 0;
93 --wordDist;
94 } while ( wordDist );
95 wordJam:
96 if ( wordJam ) zPtr[indexWordLo( size_words )] |= 1;
97
98}
99
100#endif
101
deps/SoftFloat-3e/source/s_shiftRightM.c created+91
......@@ -0,0 +1,91 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_shiftRightM
41
42#define softfloat_shiftRightM softfloat_shiftRightM
43#include "primitives.h"
44
45void
46 softfloat_shiftRightM(
47 uint_fast8_t size_words,
48 const uint32_t *aPtr,
49 uint32_t dist,
50 uint32_t *zPtr
51 )
52{
53 uint32_t wordDist;
54 uint_fast8_t innerDist;
55 uint32_t *destPtr;
56 uint_fast8_t i;
57
58 wordDist = dist>>5;
59 if ( wordDist < size_words ) {
60 aPtr += indexMultiwordHiBut( size_words, wordDist );
61 innerDist = dist & 31;
62 if ( innerDist ) {
63 softfloat_shortShiftRightM(
64 size_words - wordDist,
65 aPtr,
66 innerDist,
67 zPtr + indexMultiwordLoBut( size_words, wordDist )
68 );
69 if ( ! wordDist ) return;
70 } else {
71 aPtr += indexWordLo( size_words - wordDist );
72 destPtr = zPtr + indexWordLo( size_words );
73 for ( i = size_words - wordDist; i; --i ) {
74 *destPtr = *aPtr;
75 aPtr += wordIncr;
76 destPtr += wordIncr;
77 }
78 }
79 zPtr += indexMultiwordHi( size_words, wordDist );
80 } else {
81 wordDist = size_words;
82 }
83 do {
84 *zPtr++ = 0;
85 --wordDist;
86 } while ( wordDist );
87
88}
89
90#endif
91
deps/SoftFloat-3e/source/s_shortShiftLeft128.c created+55
......@@ -0,0 +1,55 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftLeft128
42
43struct uint128
44 softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
45{
46 struct uint128 z;
47
48 z.v64 = a64<<dist | a0>>(-dist & 63);
49 z.v0 = a0<<dist;
50 return z;
51
52}
53
54#endif
55
deps/SoftFloat-3e/source/s_shortShiftLeft64To96M.c created+56
......@@ -0,0 +1,56 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftLeft64To96M
42
43void
44 softfloat_shortShiftLeft64To96M(
45 uint64_t a, uint_fast8_t dist, uint32_t *zPtr )
46{
47
48 zPtr[indexWord( 3, 0 )] = (uint32_t) a<<dist;
49 a >>= 32 - dist;
50 zPtr[indexWord( 3, 2 )] = a>>32;
51 zPtr[indexWord( 3, 1 )] = a;
52
53}
54
55#endif
56
deps/SoftFloat-3e/source/s_shortShiftLeftM.c created+70
......@@ -0,0 +1,70 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftLeftM
42
43void
44 softfloat_shortShiftLeftM(
45 uint_fast8_t size_words,
46 const uint32_t *aPtr,
47 uint_fast8_t dist,
48 uint32_t *zPtr
49 )
50{
51 uint_fast8_t uNegDist;
52 unsigned int index, lastIndex;
53 uint32_t partWordZ, wordA;
54
55 uNegDist = -dist;
56 index = indexWordHi( size_words );
57 lastIndex = indexWordLo( size_words );
58 partWordZ = aPtr[index]<<dist;
59 while ( index != lastIndex ) {
60 wordA = aPtr[index - wordIncr];
61 zPtr[index] = partWordZ | wordA>>(uNegDist & 31);
62 index -= wordIncr;
63 partWordZ = wordA<<dist;
64 }
65 zPtr[index] = partWordZ;
66
67}
68
69#endif
70
deps/SoftFloat-3e/source/s_shortShiftRight128.c created+55
......@@ -0,0 +1,55 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftRight128
42
43struct uint128
44 softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
45{
46 struct uint128 z;
47
48 z.v64 = a64>>dist;
49 z.v0 = a64<<(-dist & 63) | a0>>dist;
50 return z;
51
52}
53
54#endif
55
deps/SoftFloat-3e/source/s_shortShiftRightExtendM.c created+73
......@@ -0,0 +1,73 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftRightExtendM
42
43void
44 softfloat_shortShiftRightExtendM(
45 uint_fast8_t size_words,
46 const uint32_t *aPtr,
47 uint_fast8_t dist,
48 uint32_t *zPtr
49 )
50{
51 uint_fast8_t uNegDist;
52 unsigned int indexA, lastIndexA;
53 uint32_t partWordZ, wordA;
54
55 uNegDist = -dist;
56 indexA = indexWordLo( size_words );
57 lastIndexA = indexWordHi( size_words );
58 zPtr += indexWordLo( size_words + 1 );
59 partWordZ = 0;
60 for (;;) {
61 wordA = aPtr[indexA];
62 *zPtr = wordA<<(uNegDist & 31) | partWordZ;
63 zPtr += wordIncr;
64 partWordZ = wordA>>dist;
65 if ( indexA == lastIndexA ) break;
66 indexA += wordIncr;
67 }
68 *zPtr = partWordZ;
69
70}
71
72#endif
73
deps/SoftFloat-3e/source/s_shortShiftRightJam128.c created+60
......@@ -0,0 +1,60 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftRightJam128
42
43struct uint128
44 softfloat_shortShiftRightJam128(
45 uint64_t a64, uint64_t a0, uint_fast8_t dist )
46{
47 uint_fast8_t uNegDist;
48 struct uint128 z;
49
50 uNegDist = -dist;
51 z.v64 = a64>>dist;
52 z.v0 =
53 a64<<(uNegDist & 63) | a0>>dist
54 | ((uint64_t) (a0<<(uNegDist & 63)) != 0);
55 return z;
56
57}
58
59#endif
60
deps/SoftFloat-3e/source/s_shortShiftRightJam128Extra.c created+59
......@@ -0,0 +1,59 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftRightJam128Extra
42
43struct uint128_extra
44 softfloat_shortShiftRightJam128Extra(
45 uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist )
46{
47 uint_fast8_t uNegDist;
48 struct uint128_extra z;
49
50 uNegDist = -dist;
51 z.v.v64 = a64>>dist;
52 z.v.v0 = a64<<(uNegDist & 63) | a0>>dist;
53 z.extra = a0<<(uNegDist & 63) | (extra != 0);
54 return z;
55
56}
57
58#endif
59
deps/SoftFloat-3e/source/s_shortShiftRightJam64.c created+50
......@@ -0,0 +1,50 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39
40#ifndef softfloat_shortShiftRightJam64
41
42uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist )
43{
44
45 return a>>dist | ((a & (((uint_fast64_t) 1<<dist) - 1)) != 0);
46
47}
48
49#endif
50
deps/SoftFloat-3e/source/s_shortShiftRightJam64Extra.c created+56
......@@ -0,0 +1,56 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftRightJam64Extra
42
43struct uint64_extra
44 softfloat_shortShiftRightJam64Extra(
45 uint64_t a, uint64_t extra, uint_fast8_t dist )
46{
47 struct uint64_extra z;
48
49 z.v = a>>dist;
50 z.extra = a<<(-dist & 63) | (extra != 0);
51 return z;
52
53}
54
55#endif
56
deps/SoftFloat-3e/source/s_shortShiftRightJamM.c created+72
......@@ -0,0 +1,72 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftRightJamM
42
43void
44 softfloat_shortShiftRightJamM(
45 uint_fast8_t size_words,
46 const uint32_t *aPtr,
47 uint_fast8_t dist,
48 uint32_t *zPtr
49 )
50{
51 uint_fast8_t uNegDist;
52 unsigned int index, lastIndex;
53 uint32_t partWordZ, wordA;
54
55 uNegDist = -dist;
56 index = indexWordLo( size_words );
57 lastIndex = indexWordHi( size_words );
58 wordA = aPtr[index];
59 partWordZ = wordA>>dist;
60 if ( partWordZ<<dist != wordA ) partWordZ |= 1;
61 while ( index != lastIndex ) {
62 wordA = aPtr[index + wordIncr];
63 zPtr[index] = wordA<<(uNegDist & 31) | partWordZ;
64 index += wordIncr;
65 partWordZ = wordA>>dist;
66 }
67 zPtr[index] = partWordZ;
68
69}
70
71#endif
72
deps/SoftFloat-3e/source/s_shortShiftRightM.c created+70
......@@ -0,0 +1,70 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_shortShiftRightM
42
43void
44 softfloat_shortShiftRightM(
45 uint_fast8_t size_words,
46 const uint32_t *aPtr,
47 uint_fast8_t dist,
48 uint32_t *zPtr
49 )
50{
51 uint_fast8_t uNegDist;
52 unsigned int index, lastIndex;
53 uint32_t partWordZ, wordA;
54
55 uNegDist = -dist;
56 index = indexWordLo( size_words );
57 lastIndex = indexWordHi( size_words );
58 partWordZ = aPtr[index]>>dist;
59 while ( index != lastIndex ) {
60 wordA = aPtr[index + wordIncr];
61 zPtr[index] = wordA<<(uNegDist & 31) | partWordZ;
62 index += wordIncr;
63 partWordZ = wordA>>dist;
64 }
65 zPtr[index] = partWordZ;
66
67}
68
69#endif
70
deps/SoftFloat-3e/source/s_sub128.c created+55
......@@ -0,0 +1,55 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_sub128
42
43struct uint128
44 softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
45{
46 struct uint128 z;
47
48 z.v0 = a0 - b0;
49 z.v64 = a64 - b64 - (a0 < b0);
50 return z;
51
52}
53
54#endif
55
deps/SoftFloat-3e/source/s_sub1XM.c created+60
......@@ -0,0 +1,60 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_sub1XM
42
43void softfloat_sub1XM( uint_fast8_t size_words, uint32_t *zPtr )
44{
45 unsigned int index, lastIndex;
46 uint32_t wordA;
47
48 index = indexWordLo( size_words );
49 lastIndex = indexWordHi( size_words );
50 for (;;) {
51 wordA = zPtr[index];
52 zPtr[index] = wordA - 1;
53 if ( wordA || (index == lastIndex) ) break;
54 index += wordIncr;
55 }
56
57}
58
59#endif
60
deps/SoftFloat-3e/source/s_sub256M.c created+65
......@@ -0,0 +1,65 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_sub256M
42
43void
44 softfloat_sub256M(
45 const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr )
46{
47 unsigned int index;
48 uint_fast8_t borrow;
49 uint64_t wordA, wordB;
50
51 index = indexWordLo( 4 );
52 borrow = 0;
53 for (;;) {
54 wordA = aPtr[index];
55 wordB = bPtr[index];
56 zPtr[index] = wordA - wordB - borrow;
57 if ( index == indexWordHi( 4 ) ) break;
58 borrow = borrow ? (wordA <= wordB) : (wordA < wordB);
59 index += wordIncr;
60 }
61
62}
63
64#endif
65
deps/SoftFloat-3e/source/s_subM.c created+70
......@@ -0,0 +1,70 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "primitiveTypes.h"
40
41#ifndef softfloat_subM
42
43void
44 softfloat_subM(
45 uint_fast8_t size_words,
46 const uint32_t *aPtr,
47 const uint32_t *bPtr,
48 uint32_t *zPtr
49 )
50{
51 unsigned int index, lastIndex;
52 uint_fast8_t borrow;
53 uint32_t wordA, wordB;
54
55 index = indexWordLo( size_words );
56 lastIndex = indexWordHi( size_words );
57 borrow = 0;
58 for (;;) {
59 wordA = aPtr[index];
60 wordB = bPtr[index];
61 zPtr[index] = wordA - wordB - borrow;
62 if ( index == lastIndex ) break;
63 borrow = borrow ? (wordA <= wordB) : (wordA < wordB);
64 index += wordIncr;
65 }
66
67}
68
69#endif
70
deps/SoftFloat-3e/source/s_subMagsExtF80.c created+158
......@@ -0,0 +1,158 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44extFloat80_t
45 softfloat_subMagsExtF80(
46 uint_fast16_t uiA64,
47 uint_fast64_t uiA0,
48 uint_fast16_t uiB64,
49 uint_fast64_t uiB0,
50 bool signZ
51 )
52{
53 int_fast32_t expA;
54 uint_fast64_t sigA;
55 int_fast32_t expB;
56 uint_fast64_t sigB;
57 int_fast32_t expDiff;
58 uint_fast16_t uiZ64;
59 uint_fast64_t uiZ0;
60 int_fast32_t expZ;
61 uint_fast64_t sigExtra;
62 struct uint128 sig128, uiZ;
63 union { struct extFloat80M s; extFloat80_t f; } uZ;
64
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 expA = expExtF80UI64( uiA64 );
68 sigA = uiA0;
69 expB = expExtF80UI64( uiB64 );
70 sigB = uiB0;
71 /*------------------------------------------------------------------------
72 *------------------------------------------------------------------------*/
73 expDiff = expA - expB;
74 if ( 0 < expDiff ) goto expABigger;
75 if ( expDiff < 0 ) goto expBBigger;
76 if ( expA == 0x7FFF ) {
77 if ( (sigA | sigB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
78 goto propagateNaN;
79 }
80 softfloat_raiseFlags( softfloat_flag_invalid );
81 uiZ64 = defaultNaNExtF80UI64;
82 uiZ0 = defaultNaNExtF80UI0;
83 goto uiZ;
84 }
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 expZ = expA;
88 if ( ! expZ ) expZ = 1;
89 sigExtra = 0;
90 if ( sigB < sigA ) goto aBigger;
91 if ( sigA < sigB ) goto bBigger;
92 uiZ64 =
93 packToExtF80UI64( (softfloat_roundingMode == softfloat_round_min), 0 );
94 uiZ0 = 0;
95 goto uiZ;
96 /*------------------------------------------------------------------------
97 *------------------------------------------------------------------------*/
98 expBBigger:
99 if ( expB == 0x7FFF ) {
100 if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
101 uiZ64 = packToExtF80UI64( signZ ^ 1, 0x7FFF );
102 uiZ0 = UINT64_C( 0x8000000000000000 );
103 goto uiZ;
104 }
105 if ( ! expA ) {
106 ++expDiff;
107 sigExtra = 0;
108 if ( ! expDiff ) goto newlyAlignedBBigger;
109 }
110 sig128 = softfloat_shiftRightJam128( sigA, 0, -expDiff );
111 sigA = sig128.v64;
112 sigExtra = sig128.v0;
113 newlyAlignedBBigger:
114 expZ = expB;
115 bBigger:
116 signZ = ! signZ;
117 sig128 = softfloat_sub128( sigB, 0, sigA, sigExtra );
118 goto normRoundPack;
119 /*------------------------------------------------------------------------
120 *------------------------------------------------------------------------*/
121 expABigger:
122 if ( expA == 0x7FFF ) {
123 if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
124 uiZ64 = uiA64;
125 uiZ0 = uiA0;
126 goto uiZ;
127 }
128 if ( ! expB ) {
129 --expDiff;
130 sigExtra = 0;
131 if ( ! expDiff ) goto newlyAlignedABigger;
132 }
133 sig128 = softfloat_shiftRightJam128( sigB, 0, expDiff );
134 sigB = sig128.v64;
135 sigExtra = sig128.v0;
136 newlyAlignedABigger:
137 expZ = expA;
138 aBigger:
139 sig128 = softfloat_sub128( sigA, 0, sigB, sigExtra );
140 /*------------------------------------------------------------------------
141 *------------------------------------------------------------------------*/
142 normRoundPack:
143 return
144 softfloat_normRoundPackToExtF80(
145 signZ, expZ, sig128.v64, sig128.v0, extF80_roundingPrecision );
146 /*------------------------------------------------------------------------
147 *------------------------------------------------------------------------*/
148 propagateNaN:
149 uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
150 uiZ64 = uiZ.v64;
151 uiZ0 = uiZ.v0;
152 uiZ:
153 uZ.s.signExp = uiZ64;
154 uZ.s.signif = uiZ0;
155 return uZ.f;
156
157}
158
deps/SoftFloat-3e/source/s_subMagsF128.c created+139
......@@ -0,0 +1,139 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float128_t
45 softfloat_subMagsF128(
46 uint_fast64_t uiA64,
47 uint_fast64_t uiA0,
48 uint_fast64_t uiB64,
49 uint_fast64_t uiB0,
50 bool signZ
51 )
52{
53 int_fast32_t expA;
54 struct uint128 sigA;
55 int_fast32_t expB;
56 struct uint128 sigB, sigZ;
57 int_fast32_t expDiff, expZ;
58 struct uint128 uiZ;
59 union ui128_f128 uZ;
60
61 expA = expF128UI64( uiA64 );
62 sigA.v64 = fracF128UI64( uiA64 );
63 sigA.v0 = uiA0;
64 expB = expF128UI64( uiB64 );
65 sigB.v64 = fracF128UI64( uiB64 );
66 sigB.v0 = uiB0;
67 sigA = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 4 );
68 sigB = softfloat_shortShiftLeft128( sigB.v64, sigB.v0, 4 );
69 expDiff = expA - expB;
70 if ( 0 < expDiff ) goto expABigger;
71 if ( expDiff < 0 ) goto expBBigger;
72 if ( expA == 0x7FFF ) {
73 if ( sigA.v64 | sigA.v0 | sigB.v64 | sigB.v0 ) goto propagateNaN;
74 softfloat_raiseFlags( softfloat_flag_invalid );
75 uiZ.v64 = defaultNaNF128UI64;
76 uiZ.v0 = defaultNaNF128UI0;
77 goto uiZ;
78 }
79 expZ = expA;
80 if ( ! expZ ) expZ = 1;
81 if ( sigB.v64 < sigA.v64 ) goto aBigger;
82 if ( sigA.v64 < sigB.v64 ) goto bBigger;
83 if ( sigB.v0 < sigA.v0 ) goto aBigger;
84 if ( sigA.v0 < sigB.v0 ) goto bBigger;
85 uiZ.v64 =
86 packToF128UI64(
87 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
88 uiZ.v0 = 0;
89 goto uiZ;
90 expBBigger:
91 if ( expB == 0x7FFF ) {
92 if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
93 uiZ.v64 = packToF128UI64( signZ ^ 1, 0x7FFF, 0 );
94 uiZ.v0 = 0;
95 goto uiZ;
96 }
97 if ( expA ) {
98 sigA.v64 |= UINT64_C( 0x0010000000000000 );
99 } else {
100 ++expDiff;
101 if ( ! expDiff ) goto newlyAlignedBBigger;
102 }
103 sigA = softfloat_shiftRightJam128( sigA.v64, sigA.v0, -expDiff );
104 newlyAlignedBBigger:
105 expZ = expB;
106 sigB.v64 |= UINT64_C( 0x0010000000000000 );
107 bBigger:
108 signZ = ! signZ;
109 sigZ = softfloat_sub128( sigB.v64, sigB.v0, sigA.v64, sigA.v0 );
110 goto normRoundPack;
111 expABigger:
112 if ( expA == 0x7FFF ) {
113 if ( sigA.v64 | sigA.v0 ) goto propagateNaN;
114 uiZ.v64 = uiA64;
115 uiZ.v0 = uiA0;
116 goto uiZ;
117 }
118 if ( expB ) {
119 sigB.v64 |= UINT64_C( 0x0010000000000000 );
120 } else {
121 --expDiff;
122 if ( ! expDiff ) goto newlyAlignedABigger;
123 }
124 sigB = softfloat_shiftRightJam128( sigB.v64, sigB.v0, expDiff );
125 newlyAlignedABigger:
126 expZ = expA;
127 sigA.v64 |= UINT64_C( 0x0010000000000000 );
128 aBigger:
129 sigZ = softfloat_sub128( sigA.v64, sigA.v0, sigB.v64, sigB.v0 );
130 normRoundPack:
131 return softfloat_normRoundPackToF128( signZ, expZ - 5, sigZ.v64, sigZ.v0 );
132 propagateNaN:
133 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
134 uiZ:
135 uZ.ui = uiZ;
136 return uZ.f;
137
138}
139
deps/SoftFloat-3e/source/s_subMagsF16.c created+187
......@@ -0,0 +1,187 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float16_t softfloat_subMagsF16( uint_fast16_t uiA, uint_fast16_t uiB )
45{
46 int_fast8_t expA;
47 uint_fast16_t sigA;
48 int_fast8_t expB;
49 uint_fast16_t sigB;
50 int_fast8_t expDiff;
51 uint_fast16_t uiZ;
52 int_fast16_t sigDiff;
53 bool signZ;
54 int_fast8_t shiftDist, expZ;
55 uint_fast16_t sigZ, sigX, sigY;
56 uint_fast32_t sig32Z;
57 int_fast8_t roundingMode;
58 union ui16_f16 uZ;
59
60 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
62 expA = expF16UI( uiA );
63 sigA = fracF16UI( uiA );
64 expB = expF16UI( uiB );
65 sigB = fracF16UI( uiB );
66 /*------------------------------------------------------------------------
67 *------------------------------------------------------------------------*/
68 expDiff = expA - expB;
69 if ( ! expDiff ) {
70 /*--------------------------------------------------------------------
71 *--------------------------------------------------------------------*/
72 if ( expA == 0x1F ) {
73 if ( sigA | sigB ) goto propagateNaN;
74 softfloat_raiseFlags( softfloat_flag_invalid );
75 uiZ = defaultNaNF16UI;
76 goto uiZ;
77 }
78 sigDiff = sigA - sigB;
79 if ( ! sigDiff ) {
80 uiZ =
81 packToF16UI(
82 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
83 goto uiZ;
84 }
85 if ( expA ) --expA;
86 signZ = signF16UI( uiA );
87 if ( sigDiff < 0 ) {
88 signZ = ! signZ;
89 sigDiff = -sigDiff;
90 }
91 shiftDist = softfloat_countLeadingZeros16( sigDiff ) - 5;
92 expZ = expA - shiftDist;
93 if ( expZ < 0 ) {
94 shiftDist = expA;
95 expZ = 0;
96 }
97 sigZ = sigDiff<<shiftDist;
98 goto pack;
99 } else {
100 /*--------------------------------------------------------------------
101 *--------------------------------------------------------------------*/
102 signZ = signF16UI( uiA );
103 if ( expDiff < 0 ) {
104 /*----------------------------------------------------------------
105 *----------------------------------------------------------------*/
106 signZ = ! signZ;
107 if ( expB == 0x1F ) {
108 if ( sigB ) goto propagateNaN;
109 uiZ = packToF16UI( signZ, 0x1F, 0 );
110 goto uiZ;
111 }
112 if ( expDiff <= -13 ) {
113 uiZ = packToF16UI( signZ, expB, sigB );
114 if ( expA | sigA ) goto subEpsilon;
115 goto uiZ;
116 }
117 expZ = expA + 19;
118 sigX = sigB | 0x0400;
119 sigY = sigA + (expA ? 0x0400 : sigA);
120 expDiff = -expDiff;
121 } else {
122 /*----------------------------------------------------------------
123 *----------------------------------------------------------------*/
124 uiZ = uiA;
125 if ( expA == 0x1F ) {
126 if ( sigA ) goto propagateNaN;
127 goto uiZ;
128 }
129 if ( 13 <= expDiff ) {
130 if ( expB | sigB ) goto subEpsilon;
131 goto uiZ;
132 }
133 expZ = expB + 19;
134 sigX = sigA | 0x0400;
135 sigY = sigB + (expB ? 0x0400 : sigB);
136 }
137 sig32Z = ((uint_fast32_t) sigX<<expDiff) - sigY;
138 shiftDist = softfloat_countLeadingZeros32( sig32Z ) - 1;
139 sig32Z <<= shiftDist;
140 expZ -= shiftDist;
141 sigZ = sig32Z>>16;
142 if ( sig32Z & 0xFFFF ) {
143 sigZ |= 1;
144 } else {
145 if ( ! (sigZ & 0xF) && ((unsigned int) expZ < 0x1E) ) {
146 sigZ >>= 4;
147 goto pack;
148 }
149 }
150 return softfloat_roundPackToF16( signZ, expZ, sigZ );
151 }
152 /*------------------------------------------------------------------------
153 *------------------------------------------------------------------------*/
154 propagateNaN:
155 uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
156 goto uiZ;
157 /*------------------------------------------------------------------------
158 *------------------------------------------------------------------------*/
159 subEpsilon:
160 roundingMode = softfloat_roundingMode;
161 if ( roundingMode != softfloat_round_near_even ) {
162 if (
163 (roundingMode == softfloat_round_minMag)
164 || (roundingMode
165 == (signF16UI( uiZ ) ? softfloat_round_max
166 : softfloat_round_min))
167 ) {
168 --uiZ;
169 }
170#ifdef SOFTFLOAT_ROUND_ODD
171 else if ( roundingMode == softfloat_round_odd ) {
172 uiZ = (uiZ - 1) | 1;
173 }
174#endif
175 }
176 softfloat_exceptionFlags |= softfloat_flag_inexact;
177 goto uiZ;
178 /*------------------------------------------------------------------------
179 *------------------------------------------------------------------------*/
180 pack:
181 uiZ = packToF16UI( signZ, expZ, sigZ );
182 uiZ:
183 uZ.ui = uiZ;
184 return uZ.f;
185
186}
187
deps/SoftFloat-3e/source/s_subMagsF32.c created+143
......@@ -0,0 +1,143 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float32_t softfloat_subMagsF32( uint_fast32_t uiA, uint_fast32_t uiB )
45{
46 int_fast16_t expA;
47 uint_fast32_t sigA;
48 int_fast16_t expB;
49 uint_fast32_t sigB;
50 int_fast16_t expDiff;
51 uint_fast32_t uiZ;
52 int_fast32_t sigDiff;
53 bool signZ;
54 int_fast8_t shiftDist;
55 int_fast16_t expZ;
56 uint_fast32_t sigX, sigY;
57 union ui32_f32 uZ;
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 expA = expF32UI( uiA );
62 sigA = fracF32UI( uiA );
63 expB = expF32UI( uiB );
64 sigB = fracF32UI( uiB );
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 expDiff = expA - expB;
68 if ( ! expDiff ) {
69 /*--------------------------------------------------------------------
70 *--------------------------------------------------------------------*/
71 if ( expA == 0xFF ) {
72 if ( sigA | sigB ) goto propagateNaN;
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 uiZ = defaultNaNF32UI;
75 goto uiZ;
76 }
77 sigDiff = sigA - sigB;
78 if ( ! sigDiff ) {
79 uiZ =
80 packToF32UI(
81 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
82 goto uiZ;
83 }
84 if ( expA ) --expA;
85 signZ = signF32UI( uiA );
86 if ( sigDiff < 0 ) {
87 signZ = ! signZ;
88 sigDiff = -sigDiff;
89 }
90 shiftDist = softfloat_countLeadingZeros32( sigDiff ) - 8;
91 expZ = expA - shiftDist;
92 if ( expZ < 0 ) {
93 shiftDist = expA;
94 expZ = 0;
95 }
96 uiZ = packToF32UI( signZ, expZ, sigDiff<<shiftDist );
97 goto uiZ;
98 } else {
99 /*--------------------------------------------------------------------
100 *--------------------------------------------------------------------*/
101 signZ = signF32UI( uiA );
102 sigA <<= 7;
103 sigB <<= 7;
104 if ( expDiff < 0 ) {
105 /*----------------------------------------------------------------
106 *----------------------------------------------------------------*/
107 signZ = ! signZ;
108 if ( expB == 0xFF ) {
109 if ( sigB ) goto propagateNaN;
110 uiZ = packToF32UI( signZ, 0xFF, 0 );
111 goto uiZ;
112 }
113 expZ = expB - 1;
114 sigX = sigB | 0x40000000;
115 sigY = sigA + (expA ? 0x40000000 : sigA);
116 expDiff = -expDiff;
117 } else {
118 /*----------------------------------------------------------------
119 *----------------------------------------------------------------*/
120 if ( expA == 0xFF ) {
121 if ( sigA ) goto propagateNaN;
122 uiZ = uiA;
123 goto uiZ;
124 }
125 expZ = expA - 1;
126 sigX = sigA | 0x40000000;
127 sigY = sigB + (expB ? 0x40000000 : sigB);
128 }
129 return
130 softfloat_normRoundPackToF32(
131 signZ, expZ, sigX - softfloat_shiftRightJam32( sigY, expDiff )
132 );
133 }
134 /*------------------------------------------------------------------------
135 *------------------------------------------------------------------------*/
136 propagateNaN:
137 uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
138 uiZ:
139 uZ.ui = uiZ;
140 return uZ.f;
141
142}
143
deps/SoftFloat-3e/source/s_subMagsF64.c created+141
......@@ -0,0 +1,141 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44float64_t
45 softfloat_subMagsF64( uint_fast64_t uiA, uint_fast64_t uiB, bool signZ )
46{
47 int_fast16_t expA;
48 uint_fast64_t sigA;
49 int_fast16_t expB;
50 uint_fast64_t sigB;
51 int_fast16_t expDiff;
52 uint_fast64_t uiZ;
53 int_fast64_t sigDiff;
54 int_fast8_t shiftDist;
55 int_fast16_t expZ;
56 uint_fast64_t sigZ;
57 union ui64_f64 uZ;
58
59 /*------------------------------------------------------------------------
60 *------------------------------------------------------------------------*/
61 expA = expF64UI( uiA );
62 sigA = fracF64UI( uiA );
63 expB = expF64UI( uiB );
64 sigB = fracF64UI( uiB );
65 /*------------------------------------------------------------------------
66 *------------------------------------------------------------------------*/
67 expDiff = expA - expB;
68 if ( ! expDiff ) {
69 /*--------------------------------------------------------------------
70 *--------------------------------------------------------------------*/
71 if ( expA == 0x7FF ) {
72 if ( sigA | sigB ) goto propagateNaN;
73 softfloat_raiseFlags( softfloat_flag_invalid );
74 uiZ = defaultNaNF64UI;
75 goto uiZ;
76 }
77 sigDiff = sigA - sigB;
78 if ( ! sigDiff ) {
79 uiZ =
80 packToF64UI(
81 (softfloat_roundingMode == softfloat_round_min), 0, 0 );
82 goto uiZ;
83 }
84 if ( expA ) --expA;
85 if ( sigDiff < 0 ) {
86 signZ = ! signZ;
87 sigDiff = -sigDiff;
88 }
89 shiftDist = softfloat_countLeadingZeros64( sigDiff ) - 11;
90 expZ = expA - shiftDist;
91 if ( expZ < 0 ) {
92 shiftDist = expA;
93 expZ = 0;
94 }
95 uiZ = packToF64UI( signZ, expZ, sigDiff<<shiftDist );
96 goto uiZ;
97 } else {
98 /*--------------------------------------------------------------------
99 *--------------------------------------------------------------------*/
100 sigA <<= 10;
101 sigB <<= 10;
102 if ( expDiff < 0 ) {
103 /*----------------------------------------------------------------
104 *----------------------------------------------------------------*/
105 signZ = ! signZ;
106 if ( expB == 0x7FF ) {
107 if ( sigB ) goto propagateNaN;
108 uiZ = packToF64UI( signZ, 0x7FF, 0 );
109 goto uiZ;
110 }
111 sigA += expA ? UINT64_C( 0x4000000000000000 ) : sigA;
112 sigA = softfloat_shiftRightJam64( sigA, -expDiff );
113 sigB |= UINT64_C( 0x4000000000000000 );
114 expZ = expB;
115 sigZ = sigB - sigA;
116 } else {
117 /*----------------------------------------------------------------
118 *----------------------------------------------------------------*/
119 if ( expA == 0x7FF ) {
120 if ( sigA ) goto propagateNaN;
121 uiZ = uiA;
122 goto uiZ;
123 }
124 sigB += expB ? UINT64_C( 0x4000000000000000 ) : sigB;
125 sigB = softfloat_shiftRightJam64( sigB, expDiff );
126 sigA |= UINT64_C( 0x4000000000000000 );
127 expZ = expA;
128 sigZ = sigA - sigB;
129 }
130 return softfloat_normRoundPackToF64( signZ, expZ - 1, sigZ );
131 }
132 /*------------------------------------------------------------------------
133 *------------------------------------------------------------------------*/
134 propagateNaN:
135 uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
136 uiZ:
137 uZ.ui = uiZ;
138 return uZ.f;
139
140}
141
deps/SoftFloat-3e/source/s_tryPropagateNaNExtF80M.c created+64
......@@ -0,0 +1,64 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41
42bool
43 softfloat_tryPropagateNaNExtF80M(
44 const struct extFloat80M *aSPtr,
45 const struct extFloat80M *bSPtr,
46 struct extFloat80M *zSPtr
47 )
48{
49 uint_fast16_t ui64;
50 uint64_t ui0;
51
52 ui64 = aSPtr->signExp;
53 ui0 = aSPtr->signif;
54 if ( isNaNExtF80UI( ui64, ui0 ) ) goto propagateNaN;
55 ui64 = bSPtr->signExp;
56 ui0 = bSPtr->signif;
57 if ( isNaNExtF80UI( ui64, ui0 ) ) goto propagateNaN;
58 return false;
59 propagateNaN:
60 softfloat_propagateNaNExtF80M( aSPtr, bSPtr, zSPtr );
61 return true;
62
63}
64
deps/SoftFloat-3e/source/s_tryPropagateNaNF128M.c created+55
......@@ -0,0 +1,55 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42
43bool
44 softfloat_tryPropagateNaNF128M(
45 const uint32_t *aWPtr, const uint32_t *bWPtr, uint32_t *zWPtr )
46{
47
48 if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
49 softfloat_propagateNaNF128M( aWPtr, bWPtr, zWPtr );
50 return true;
51 }
52 return false;
53
54}
55
deps/SoftFloat-3e/source/softfloat_state.c created+52
......@@ -0,0 +1,52 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "specialize.h"
41#include "softfloat.h"
42
43#ifndef THREAD_LOCAL
44#define THREAD_LOCAL
45#endif
46
47THREAD_LOCAL uint_fast8_t softfloat_roundingMode = softfloat_round_near_even;
48THREAD_LOCAL uint_fast8_t softfloat_detectTininess = init_detectTininess;
49THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags = 0;
50
51THREAD_LOCAL uint_fast8_t extF80_roundingPrecision = 80;
52
deps/SoftFloat-3e/source/ui32_to_extF80.c created+59
......@@ -0,0 +1,59 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42extFloat80_t ui32_to_extF80( uint32_t a )
43{
44 uint_fast16_t uiZ64;
45 int_fast8_t shiftDist;
46 union { struct extFloat80M s; extFloat80_t f; } uZ;
47
48 uiZ64 = 0;
49 if ( a ) {
50 shiftDist = softfloat_countLeadingZeros32( a );
51 uiZ64 = 0x401E - shiftDist;
52 a <<= shiftDist;
53 }
54 uZ.s.signExp = uiZ64;
55 uZ.s.signif = (uint_fast64_t) a<<32;
56 return uZ.f;
57
58}
59
deps/SoftFloat-3e/source/ui32_to_extF80M.c created+74
......@@ -0,0 +1,74 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void ui32_to_extF80M( uint32_t a, extFloat80_t *zPtr )
45{
46
47 *zPtr = ui32_to_extF80( a );
48
49}
50
51#else
52
53void ui32_to_extF80M( uint32_t a, extFloat80_t *zPtr )
54{
55 struct extFloat80M *zSPtr;
56 uint_fast16_t uiZ64;
57 uint64_t sigZ;
58 int_fast8_t shiftDist;
59
60 zSPtr = (struct extFloat80M *) zPtr;
61 uiZ64 = 0;
62 sigZ = 0;
63 if ( a ) {
64 shiftDist = softfloat_countLeadingZeros32( a );
65 uiZ64 = packToExtF80UI64( 0, 0x401E - shiftDist );
66 sigZ = (uint64_t) (a<<shiftDist)<<32;
67 }
68 zSPtr->signExp = uiZ64;
69 zSPtr->signif = sigZ;
70
71}
72
73#endif
74
deps/SoftFloat-3e/source/ui32_to_f128.c created+60
......@@ -0,0 +1,60 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float128_t ui32_to_f128( uint32_t a )
43{
44 uint_fast64_t uiZ64;
45 int_fast8_t shiftDist;
46 union ui128_f128 uZ;
47
48 uiZ64 = 0;
49 if ( a ) {
50 shiftDist = softfloat_countLeadingZeros32( a ) + 17;
51 uiZ64 =
52 packToF128UI64(
53 0, 0x402E - shiftDist, (uint_fast64_t) a<<shiftDist );
54 }
55 uZ.ui.v64 = uiZ64;
56 uZ.ui.v0 = 0;
57 return uZ.f;
58
59}
60
deps/SoftFloat-3e/source/ui32_to_f128M.c created+76
......@@ -0,0 +1,76 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void ui32_to_f128M( uint32_t a, float128_t *zPtr )
45{
46
47 *zPtr = ui32_to_f128( a );
48
49}
50
51#else
52
53void ui32_to_f128M( uint32_t a, float128_t *zPtr )
54{
55 uint32_t *zWPtr, uiZ96, uiZ64;
56 int_fast8_t shiftDist;
57 uint64_t normA;
58
59 zWPtr = (uint32_t *) zPtr;
60 uiZ96 = 0;
61 uiZ64 = 0;
62 if ( a ) {
63 shiftDist = softfloat_countLeadingZeros32( a ) + 17;
64 normA = (uint64_t) a<<shiftDist;
65 uiZ96 = packToF128UI96( 0, 0x402E - shiftDist, normA>>32 );
66 uiZ64 = normA;
67 }
68 zWPtr[indexWord( 4, 3 )] = uiZ96;
69 zWPtr[indexWord( 4, 2 )] = uiZ64;
70 zWPtr[indexWord( 4, 1 )] = 0;
71 zWPtr[indexWord( 4, 0 )] = 0;
72
73}
74
75#endif
76
deps/SoftFloat-3e/source/ui32_to_f16.c created+65
......@@ -0,0 +1,65 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float16_t ui32_to_f16( uint32_t a )
43{
44 int_fast8_t shiftDist;
45 union ui16_f16 u;
46 uint_fast16_t sig;
47
48 shiftDist = softfloat_countLeadingZeros32( a ) - 21;
49 if ( 0 <= shiftDist ) {
50 u.ui =
51 a ? packToF16UI(
52 0, 0x18 - shiftDist, (uint_fast16_t) a<<shiftDist )
53 : 0;
54 return u.f;
55 } else {
56 shiftDist += 4;
57 sig =
58 (shiftDist < 0)
59 ? a>>(-shiftDist) | ((uint32_t) (a<<(shiftDist & 31)) != 0)
60 : (uint_fast16_t) a<<shiftDist;
61 return softfloat_roundPackToF16( 0, 0x1C - shiftDist, sig );
62 }
63
64}
65
deps/SoftFloat-3e/source/ui32_to_f32.c created+57
......@@ -0,0 +1,57 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float32_t ui32_to_f32( uint32_t a )
43{
44 union ui32_f32 uZ;
45
46 if ( ! a ) {
47 uZ.ui = 0;
48 return uZ.f;
49 }
50 if ( a & 0x80000000 ) {
51 return softfloat_roundPackToF32( 0, 0x9D, a>>1 | (a & 1) );
52 } else {
53 return softfloat_normRoundPackToF32( 0, 0x9C, a );
54 }
55
56}
57
deps/SoftFloat-3e/source/ui32_to_f64.c created+59
......@@ -0,0 +1,59 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float64_t ui32_to_f64( uint32_t a )
43{
44 uint_fast64_t uiZ;
45 int_fast8_t shiftDist;
46 union ui64_f64 uZ;
47
48 if ( ! a ) {
49 uiZ = 0;
50 } else {
51 shiftDist = softfloat_countLeadingZeros32( a ) + 21;
52 uiZ =
53 packToF64UI( 0, 0x432 - shiftDist, (uint_fast64_t) a<<shiftDist );
54 }
55 uZ.ui = uiZ;
56 return uZ.f;
57
58}
59
deps/SoftFloat-3e/source/ui64_to_extF80.c created+59
......@@ -0,0 +1,59 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42extFloat80_t ui64_to_extF80( uint64_t a )
43{
44 uint_fast16_t uiZ64;
45 int_fast8_t shiftDist;
46 union { struct extFloat80M s; extFloat80_t f; } uZ;
47
48 uiZ64 = 0;
49 if ( a ) {
50 shiftDist = softfloat_countLeadingZeros64( a );
51 uiZ64 = 0x403E - shiftDist;
52 a <<= shiftDist;
53 }
54 uZ.s.signExp = uiZ64;
55 uZ.s.signif = a;
56 return uZ.f;
57
58}
59
deps/SoftFloat-3e/source/ui64_to_extF80M.c created+74
......@@ -0,0 +1,74 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void ui64_to_extF80M( uint64_t a, extFloat80_t *zPtr )
45{
46
47 *zPtr = ui64_to_extF80( a );
48
49}
50
51#else
52
53void ui64_to_extF80M( uint64_t a, extFloat80_t *zPtr )
54{
55 struct extFloat80M *zSPtr;
56 uint_fast16_t uiZ64;
57 uint64_t sigZ;
58 int_fast8_t shiftDist;
59
60 zSPtr = (struct extFloat80M *) zPtr;
61 uiZ64 = 0;
62 sigZ = 0;
63 if ( a ) {
64 shiftDist = softfloat_countLeadingZeros64( a );
65 uiZ64 = packToExtF80UI64( 0, 0x403E - shiftDist );
66 sigZ = a<<shiftDist;
67 }
68 zSPtr->signExp = uiZ64;
69 zSPtr->signif = sigZ;
70
71}
72
73#endif
74
deps/SoftFloat-3e/source/ui64_to_f128.c created+68
......@@ -0,0 +1,68 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float128_t ui64_to_f128( uint64_t a )
43{
44 uint_fast64_t uiZ64, uiZ0;
45 int_fast8_t shiftDist;
46 struct uint128 zSig;
47 union ui128_f128 uZ;
48
49 if ( ! a ) {
50 uiZ64 = 0;
51 uiZ0 = 0;
52 } else {
53 shiftDist = softfloat_countLeadingZeros64( a ) + 49;
54 if ( 64 <= shiftDist ) {
55 zSig.v64 = a<<(shiftDist - 64);
56 zSig.v0 = 0;
57 } else {
58 zSig = softfloat_shortShiftLeft128( 0, a, shiftDist );
59 }
60 uiZ64 = packToF128UI64( 0, 0x406E - shiftDist, zSig.v64 );
61 uiZ0 = zSig.v0;
62 }
63 uZ.ui.v64 = uiZ64;
64 uZ.ui.v0 = uiZ0;
65 return uZ.f;
66
67}
68
deps/SoftFloat-3e/source/ui64_to_f128M.c created+86
......@@ -0,0 +1,86 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42#ifdef SOFTFLOAT_FAST_INT64
43
44void ui64_to_f128M( uint64_t a, float128_t *zPtr )
45{
46
47 *zPtr = ui64_to_f128( a );
48
49}
50
51#else
52
53void ui64_to_f128M( uint64_t a, float128_t *zPtr )
54{
55 uint32_t *zWPtr, uiZ96, uiZ64;
56 uint_fast8_t shiftDist;
57 uint32_t *ptr;
58
59 zWPtr = (uint32_t *) zPtr;
60 uiZ96 = 0;
61 uiZ64 = 0;
62 zWPtr[indexWord( 4, 1 )] = 0;
63 zWPtr[indexWord( 4, 0 )] = 0;
64 if ( a ) {
65 shiftDist = softfloat_countLeadingZeros64( a ) + 17;
66 if ( shiftDist < 32 ) {
67 ptr = zWPtr + indexMultiwordHi( 4, 3 );
68 ptr[indexWord( 3, 2 )] = 0;
69 ptr[indexWord( 3, 1 )] = a>>32;
70 ptr[indexWord( 3, 0 )] = a;
71 softfloat_shortShiftLeft96M( ptr, shiftDist, ptr );
72 ptr[indexWordHi( 3 )] =
73 packToF128UI96( 0, 0x404E - shiftDist, ptr[indexWordHi( 3 )] );
74 return;
75 }
76 a <<= shiftDist - 32;
77 uiZ96 = packToF128UI96( 0, 0x404E - shiftDist, a>>32 );
78 uiZ64 = a;
79 }
80 zWPtr[indexWord( 4, 3 )] = uiZ96;
81 zWPtr[indexWord( 4, 2 )] = uiZ64;
82
83}
84
85#endif
86
deps/SoftFloat-3e/source/ui64_to_f16.c created+64
......@@ -0,0 +1,64 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float16_t ui64_to_f16( uint64_t a )
43{
44 int_fast8_t shiftDist;
45 union ui16_f16 u;
46 uint_fast16_t sig;
47
48 shiftDist = softfloat_countLeadingZeros64( a ) - 53;
49 if ( 0 <= shiftDist ) {
50 u.ui =
51 a ? packToF16UI(
52 0, 0x18 - shiftDist, (uint_fast16_t) a<<shiftDist )
53 : 0;
54 return u.f;
55 } else {
56 shiftDist += 4;
57 sig =
58 (shiftDist < 0) ? softfloat_shortShiftRightJam64( a, -shiftDist )
59 : (uint_fast16_t) a<<shiftDist;
60 return softfloat_roundPackToF16( 0, 0x1C - shiftDist, sig );
61 }
62
63}
64
deps/SoftFloat-3e/source/ui64_to_f32.c created+64
......@@ -0,0 +1,64 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8California. All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float32_t ui64_to_f32( uint64_t a )
43{
44 int_fast8_t shiftDist;
45 union ui32_f32 u;
46 uint_fast32_t sig;
47
48 shiftDist = softfloat_countLeadingZeros64( a ) - 40;
49 if ( 0 <= shiftDist ) {
50 u.ui =
51 a ? packToF32UI(
52 0, 0x95 - shiftDist, (uint_fast32_t) a<<shiftDist )
53 : 0;
54 return u.f;
55 } else {
56 shiftDist += 7;
57 sig =
58 (shiftDist < 0) ? softfloat_shortShiftRightJam64( a, -shiftDist )
59 : (uint_fast32_t) a<<shiftDist;
60 return softfloat_roundPackToF32( 0, 0x9C - shiftDist, sig );
61 }
62
63}
64
deps/SoftFloat-3e/source/ui64_to_f64.c created+59
......@@ -0,0 +1,59 @@
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All Rights Reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdint.h>
38#include "platform.h"
39#include "internals.h"
40#include "softfloat.h"
41
42float64_t ui64_to_f64( uint64_t a )
43{
44 union ui64_f64 uZ;
45
46 if ( ! a ) {
47 uZ.ui = 0;
48 return uZ.f;
49 }
50 if ( a & UINT64_C( 0x8000000000000000 ) ) {
51 return
52 softfloat_roundPackToF64(
53 0, 0x43D, softfloat_shortShiftRightJam64( a, 1 ) );
54 } else {
55 return softfloat_normRoundPackToF64( 0, 0x43C, a );
56 }
57
58}
59