mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[liba] Implement AEABI double helpers using the softfloat library
Change-Id: If329dcc55425f6e8db4b2ce26ea7d8be15c31c8d
This commit is contained in:
@@ -71,14 +71,45 @@ tests += $(addprefix liba/test/, \
|
||||
ieee754.c \
|
||||
stdint.c \
|
||||
strlcpy.c \
|
||||
double.c \
|
||||
)
|
||||
|
||||
# The use of aeabi-rt could be made conditional to an AEABI target.
|
||||
# In practice we're always using liba on such a target.
|
||||
objs += $(addprefix liba/src/aeabi-rt/, \
|
||||
atexit.o \
|
||||
double.o \
|
||||
llsl.o \
|
||||
llsr.o \
|
||||
memclr.o \
|
||||
memcpy.o \
|
||||
)
|
||||
|
||||
liba/src/external/softfloat/src/%.o: CFLAGS += -Iliba/src/external/softfloat/include -Iliba/src/external/softfloat/src/8086 -Iliba/src/external/softfloat/port
|
||||
|
||||
objs += $(addprefix liba/src/external/softfloat/src/, \
|
||||
8086/s_propagateNaNF64UI.o \
|
||||
8086/softfloat_raiseFlags.o \
|
||||
f64_add.o \
|
||||
f64_div.o \
|
||||
f64_eq.o \
|
||||
f64_le.o \
|
||||
f64_lt.o \
|
||||
f64_mul.o \
|
||||
f64_sub.o \
|
||||
f64_to_i32_r_minMag.o \
|
||||
i32_to_f64.o \
|
||||
s_addMagsF64.o \
|
||||
s_approxRecip32_1.o \
|
||||
s_approxRecip_1Ks.o \
|
||||
s_countLeadingZeros32.o \
|
||||
s_countLeadingZeros64.o \
|
||||
s_countLeadingZeros8.o \
|
||||
s_mul64To128M.o \
|
||||
s_normRoundPackToF64.o \
|
||||
s_normSubnormalF64Sig.o \
|
||||
s_roundPackToF64.o \
|
||||
s_shiftRightJam64.o \
|
||||
s_subMagsF64.o \
|
||||
softfloat_state.o \
|
||||
)
|
||||
|
||||
53
liba/src/aeabi-rt/double.c
Normal file
53
liba/src/aeabi-rt/double.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/* See the "Run-time ABI for the ARM Architecture", Section 4.1.2 */
|
||||
|
||||
#include "../external/softfloat/port/softfloat.h"
|
||||
|
||||
// Conversions
|
||||
|
||||
int __aeabi_d2iz(double d) {
|
||||
return f64_to_i32_r_minMag(d, 0);
|
||||
}
|
||||
|
||||
double __aeabi_i2d(int i) {
|
||||
return i32_to_f64(i);
|
||||
}
|
||||
|
||||
// Comparisons
|
||||
|
||||
int __aeabi_dcmpeq(double a, double b) {
|
||||
return f64_eq(a, b);
|
||||
}
|
||||
|
||||
int __aeabi_dcmpge(double a, double b) {
|
||||
return f64_le(b, a);
|
||||
}
|
||||
|
||||
int __aeabi_dcmpgt(double a, double b) {
|
||||
return f64_lt(b, a);
|
||||
}
|
||||
|
||||
int __aeabi_dcmple(double a, double b) {
|
||||
return f64_le(a, b);
|
||||
}
|
||||
|
||||
int __aeabi_dcmplt(double a, double b) {
|
||||
return f64_lt(a, b);
|
||||
}
|
||||
|
||||
// Arithmetics
|
||||
|
||||
double __aeabi_dadd(double a, double b) {
|
||||
return f64_add(a, b);
|
||||
}
|
||||
|
||||
double __aeabi_dsub(double a, double b) {
|
||||
return f64_sub(a, b);
|
||||
}
|
||||
|
||||
double __aeabi_dmul(double a, double b) {
|
||||
return f64_mul(a, b);
|
||||
}
|
||||
|
||||
double __aeabi_ddiv(double a, double b) {
|
||||
return f64_div(a, b);
|
||||
}
|
||||
278
liba/src/external/softfloat/include/internals.h
vendored
Normal file
278
liba/src/external/softfloat/include/internals.h
vendored
Normal file
@@ -0,0 +1,278 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#ifndef internals_h
|
||||
#define internals_h 1
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "primitives.h"
|
||||
#include "softfloat_types.h"
|
||||
|
||||
union ui16_f16 { uint16_t ui; float16_t f; };
|
||||
union ui32_f32 { uint32_t ui; float32_t f; };
|
||||
union ui64_f64 { uint64_t ui; float64_t f; };
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
union extF80M_extF80 { struct extFloat80M fM; extFloat80_t f; };
|
||||
union ui128_f128 { struct uint128 ui; float128_t f; };
|
||||
#endif
|
||||
|
||||
enum {
|
||||
softfloat_mulAdd_subC = 1,
|
||||
softfloat_mulAdd_subProd = 2
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
*----------------------------------------------------------------------------*/
|
||||
uint_fast32_t softfloat_roundToUI32( bool, uint_fast64_t, uint_fast8_t, bool );
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
uint_fast64_t
|
||||
softfloat_roundToUI64(
|
||||
bool, uint_fast64_t, uint_fast64_t, uint_fast8_t, bool );
|
||||
#else
|
||||
uint_fast64_t softfloat_roundMToUI64( bool, uint32_t *, uint_fast8_t, bool );
|
||||
#endif
|
||||
|
||||
int_fast32_t softfloat_roundToI32( bool, uint_fast64_t, uint_fast8_t, bool );
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
int_fast64_t
|
||||
softfloat_roundToI64(
|
||||
bool, uint_fast64_t, uint_fast64_t, uint_fast8_t, bool );
|
||||
#else
|
||||
int_fast64_t softfloat_roundMToI64( bool, uint32_t *, uint_fast8_t, bool );
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define signF16UI( a ) ((bool) ((uint16_t) (a)>>15))
|
||||
#define expF16UI( a ) ((int_fast8_t) ((a)>>10) & 0x1F)
|
||||
#define fracF16UI( a ) ((a) & 0x03FF)
|
||||
#define packToF16UI( sign, exp, sig ) (((uint16_t) (sign)<<15) + ((uint16_t) (exp)<<10) + (sig))
|
||||
|
||||
#define isNaNF16UI( a ) (((~(a) & 0x7C00) == 0) && ((a) & 0x03FF))
|
||||
|
||||
struct exp8_sig16 { int_fast8_t exp; uint_fast16_t sig; };
|
||||
struct exp8_sig16 softfloat_normSubnormalF16Sig( uint_fast16_t );
|
||||
|
||||
float16_t softfloat_roundPackToF16( bool, int_fast16_t, uint_fast16_t );
|
||||
float16_t softfloat_normRoundPackToF16( bool, int_fast16_t, uint_fast16_t );
|
||||
|
||||
float16_t softfloat_addMagsF16( uint_fast16_t, uint_fast16_t );
|
||||
float16_t softfloat_subMagsF16( uint_fast16_t, uint_fast16_t );
|
||||
float16_t
|
||||
softfloat_mulAddF16(
|
||||
uint_fast16_t, uint_fast16_t, uint_fast16_t, uint_fast8_t );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define signF32UI( a ) ((bool) ((uint32_t) (a)>>31))
|
||||
#define expF32UI( a ) ((int_fast16_t) ((a)>>23) & 0xFF)
|
||||
#define fracF32UI( a ) ((a) & 0x007FFFFF)
|
||||
#define packToF32UI( sign, exp, sig ) (((uint32_t) (sign)<<31) + ((uint32_t) (exp)<<23) + (sig))
|
||||
|
||||
#define isNaNF32UI( a ) (((~(a) & 0x7F800000) == 0) && ((a) & 0x007FFFFF))
|
||||
|
||||
struct exp16_sig32 { int_fast16_t exp; uint_fast32_t sig; };
|
||||
struct exp16_sig32 softfloat_normSubnormalF32Sig( uint_fast32_t );
|
||||
|
||||
float32_t softfloat_roundPackToF32( bool, int_fast16_t, uint_fast32_t );
|
||||
float32_t softfloat_normRoundPackToF32( bool, int_fast16_t, uint_fast32_t );
|
||||
|
||||
float32_t softfloat_addMagsF32( uint_fast32_t, uint_fast32_t );
|
||||
float32_t softfloat_subMagsF32( uint_fast32_t, uint_fast32_t );
|
||||
float32_t
|
||||
softfloat_mulAddF32(
|
||||
uint_fast32_t, uint_fast32_t, uint_fast32_t, uint_fast8_t );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define signF64UI( a ) ((bool) ((uint64_t) (a)>>63))
|
||||
#define expF64UI( a ) ((int_fast16_t) ((a)>>52) & 0x7FF)
|
||||
#define fracF64UI( a ) ((a) & UINT64_C( 0x000FFFFFFFFFFFFF ))
|
||||
#define packToF64UI( sign, exp, sig ) ((uint64_t) (((uint_fast64_t) (sign)<<63) + ((uint_fast64_t) (exp)<<52) + (sig)))
|
||||
|
||||
#define isNaNF64UI( a ) (((~(a) & UINT64_C( 0x7FF0000000000000 )) == 0) && ((a) & UINT64_C( 0x000FFFFFFFFFFFFF )))
|
||||
|
||||
struct exp16_sig64 { int_fast16_t exp; uint_fast64_t sig; };
|
||||
struct exp16_sig64 softfloat_normSubnormalF64Sig( uint_fast64_t );
|
||||
|
||||
float64_t softfloat_roundPackToF64( bool, int_fast16_t, uint_fast64_t );
|
||||
float64_t softfloat_normRoundPackToF64( bool, int_fast16_t, uint_fast64_t );
|
||||
|
||||
float64_t softfloat_addMagsF64( uint_fast64_t, uint_fast64_t, bool );
|
||||
float64_t softfloat_subMagsF64( uint_fast64_t, uint_fast64_t, bool );
|
||||
float64_t
|
||||
softfloat_mulAddF64(
|
||||
uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast8_t );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define signExtF80UI64( a64 ) ((bool) ((uint16_t) (a64)>>15))
|
||||
#define expExtF80UI64( a64 ) ((a64) & 0x7FFF)
|
||||
#define packToExtF80UI64( sign, exp ) ((uint_fast16_t) (sign)<<15 | (exp))
|
||||
|
||||
#define isNaNExtF80UI( a64, a0 ) ((((a64) & 0x7FFF) == 0x7FFF) && ((a0) & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
struct exp32_sig64 { int_fast32_t exp; uint64_t sig; };
|
||||
struct exp32_sig64 softfloat_normSubnormalExtF80Sig( uint_fast64_t );
|
||||
|
||||
extFloat80_t
|
||||
softfloat_roundPackToExtF80(
|
||||
bool, int_fast32_t, uint_fast64_t, uint_fast64_t, uint_fast8_t );
|
||||
extFloat80_t
|
||||
softfloat_normRoundPackToExtF80(
|
||||
bool, int_fast32_t, uint_fast64_t, uint_fast64_t, uint_fast8_t );
|
||||
|
||||
extFloat80_t
|
||||
softfloat_addMagsExtF80(
|
||||
uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
|
||||
extFloat80_t
|
||||
softfloat_subMagsExtF80(
|
||||
uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define signF128UI64( a64 ) ((bool) ((uint64_t) (a64)>>63))
|
||||
#define expF128UI64( a64 ) ((int_fast32_t) ((a64)>>48) & 0x7FFF)
|
||||
#define fracF128UI64( a64 ) ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))
|
||||
#define packToF128UI64( sign, exp, sig64 ) (((uint_fast64_t) (sign)<<63) + ((uint_fast64_t) (exp)<<48) + (sig64))
|
||||
|
||||
#define isNaNF128UI( a64, a0 ) (((~(a64) & UINT64_C( 0x7FFF000000000000 )) == 0) && (a0 || ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))))
|
||||
|
||||
struct exp32_sig128 { int_fast32_t exp; struct uint128 sig; };
|
||||
struct exp32_sig128
|
||||
softfloat_normSubnormalF128Sig( uint_fast64_t, uint_fast64_t );
|
||||
|
||||
float128_t
|
||||
softfloat_roundPackToF128(
|
||||
bool, int_fast32_t, uint_fast64_t, uint_fast64_t, uint_fast64_t );
|
||||
float128_t
|
||||
softfloat_normRoundPackToF128(
|
||||
bool, int_fast32_t, uint_fast64_t, uint_fast64_t );
|
||||
|
||||
float128_t
|
||||
softfloat_addMagsF128(
|
||||
uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
|
||||
float128_t
|
||||
softfloat_subMagsF128(
|
||||
uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
|
||||
float128_t
|
||||
softfloat_mulAddF128(
|
||||
uint_fast64_t,
|
||||
uint_fast64_t,
|
||||
uint_fast64_t,
|
||||
uint_fast64_t,
|
||||
uint_fast64_t,
|
||||
uint_fast64_t,
|
||||
uint_fast8_t
|
||||
);
|
||||
|
||||
#else
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
bool
|
||||
softfloat_tryPropagateNaNExtF80M(
|
||||
const struct extFloat80M *,
|
||||
const struct extFloat80M *,
|
||||
struct extFloat80M *
|
||||
);
|
||||
void softfloat_invalidExtF80M( struct extFloat80M * );
|
||||
|
||||
int softfloat_normExtF80SigM( uint64_t * );
|
||||
|
||||
void
|
||||
softfloat_roundPackMToExtF80M(
|
||||
bool, int32_t, uint32_t *, uint_fast8_t, struct extFloat80M * );
|
||||
void
|
||||
softfloat_normRoundPackMToExtF80M(
|
||||
bool, int32_t, uint32_t *, uint_fast8_t, struct extFloat80M * );
|
||||
|
||||
void
|
||||
softfloat_addExtF80M(
|
||||
const struct extFloat80M *,
|
||||
const struct extFloat80M *,
|
||||
struct extFloat80M *,
|
||||
bool
|
||||
);
|
||||
|
||||
int
|
||||
softfloat_compareNonnormExtF80M(
|
||||
const struct extFloat80M *, const struct extFloat80M * );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define signF128UI96( a96 ) ((bool) ((uint32_t) (a96)>>31))
|
||||
#define expF128UI96( a96 ) ((int32_t) ((a96)>>16) & 0x7FFF)
|
||||
#define fracF128UI96( a96 ) ((a96) & 0x0000FFFF)
|
||||
#define packToF128UI96( sign, exp, sig96 ) (((uint32_t) (sign)<<31) + ((uint32_t) (exp)<<16) + (sig96))
|
||||
|
||||
bool softfloat_isNaNF128M( const uint32_t * );
|
||||
|
||||
bool
|
||||
softfloat_tryPropagateNaNF128M(
|
||||
const uint32_t *, const uint32_t *, uint32_t * );
|
||||
void softfloat_invalidF128M( uint32_t * );
|
||||
|
||||
int softfloat_shiftNormSigF128M( const uint32_t *, uint_fast8_t, uint32_t * );
|
||||
|
||||
void softfloat_roundPackMToF128M( bool, int32_t, uint32_t *, uint32_t * );
|
||||
void softfloat_normRoundPackMToF128M( bool, int32_t, uint32_t *, uint32_t * );
|
||||
|
||||
void
|
||||
softfloat_addF128M( const uint32_t *, const uint32_t *, uint32_t *, bool );
|
||||
void
|
||||
softfloat_mulAddF128M(
|
||||
const uint32_t *,
|
||||
const uint32_t *,
|
||||
const uint32_t *,
|
||||
uint32_t *,
|
||||
uint_fast8_t
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
85
liba/src/external/softfloat/include/primitiveTypes.h
vendored
Normal file
85
liba/src/external/softfloat/include/primitiveTypes.h
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#ifndef primitiveTypes_h
|
||||
#define primitiveTypes_h 1
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
#ifdef LITTLEENDIAN
|
||||
struct uint128 { uint64_t v0, v64; };
|
||||
struct uint64_extra { uint64_t extra, v; };
|
||||
struct uint128_extra { uint64_t extra; struct uint128 v; };
|
||||
#else
|
||||
struct uint128 { uint64_t v64, v0; };
|
||||
struct uint64_extra { uint64_t v, extra; };
|
||||
struct uint128_extra { struct uint128 v; uint64_t extra; };
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| These macros are used to isolate the differences in word order between big-
|
||||
| endian and little-endian platforms.
|
||||
*----------------------------------------------------------------------------*/
|
||||
#ifdef LITTLEENDIAN
|
||||
#define wordIncr 1
|
||||
#define indexWord( total, n ) (n)
|
||||
#define indexWordHi( total ) ((total) - 1)
|
||||
#define indexWordLo( total ) 0
|
||||
#define indexMultiword( total, m, n ) (n)
|
||||
#define indexMultiwordHi( total, n ) ((total) - (n))
|
||||
#define indexMultiwordLo( total, n ) 0
|
||||
#define indexMultiwordHiBut( total, n ) (n)
|
||||
#define indexMultiwordLoBut( total, n ) 0
|
||||
#define INIT_UINTM4( v3, v2, v1, v0 ) { v0, v1, v2, v3 }
|
||||
#else
|
||||
#define wordIncr -1
|
||||
#define indexWord( total, n ) ((total) - 1 - (n))
|
||||
#define indexWordHi( total ) 0
|
||||
#define indexWordLo( total ) ((total) - 1)
|
||||
#define indexMultiword( total, m, n ) ((total) - 1 - (m))
|
||||
#define indexMultiwordHi( total, n ) 0
|
||||
#define indexMultiwordLo( total, n ) ((total) - (n))
|
||||
#define indexMultiwordHiBut( total, n ) 0
|
||||
#define indexMultiwordLoBut( total, n ) (n)
|
||||
#define INIT_UINTM4( v3, v2, v1, v0 ) { v3, v2, v1, v0 }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
1160
liba/src/external/softfloat/include/primitives.h
vendored
Normal file
1160
liba/src/external/softfloat/include/primitives.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
372
liba/src/external/softfloat/include/softfloat.h
vendored
Normal file
372
liba/src/external/softfloat/include/softfloat.h
vendored
Normal file
@@ -0,0 +1,372 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*============================================================================
|
||||
| Note: If SoftFloat is made available as a general library for programs to
|
||||
| use, it is strongly recommended that a platform-specific version of this
|
||||
| header, "softfloat.h", be created that folds in "softfloat_types.h" and that
|
||||
| eliminates all dependencies on compile-time macros.
|
||||
*============================================================================*/
|
||||
|
||||
|
||||
#ifndef softfloat_h
|
||||
#define softfloat_h 1
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "softfloat_types.h"
|
||||
|
||||
#ifndef THREAD_LOCAL
|
||||
#define THREAD_LOCAL
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Software floating-point underflow tininess-detection mode.
|
||||
*----------------------------------------------------------------------------*/
|
||||
extern THREAD_LOCAL uint_fast8_t softfloat_detectTininess;
|
||||
enum {
|
||||
softfloat_tininess_beforeRounding = 0,
|
||||
softfloat_tininess_afterRounding = 1
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Software floating-point rounding mode. (Mode "odd" is supported only if
|
||||
| SoftFloat is compiled with macro 'SOFTFLOAT_ROUND_ODD' defined.)
|
||||
*----------------------------------------------------------------------------*/
|
||||
extern THREAD_LOCAL uint_fast8_t softfloat_roundingMode;
|
||||
enum {
|
||||
softfloat_round_near_even = 0,
|
||||
softfloat_round_minMag = 1,
|
||||
softfloat_round_min = 2,
|
||||
softfloat_round_max = 3,
|
||||
softfloat_round_near_maxMag = 4,
|
||||
softfloat_round_odd = 5
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Software floating-point exception flags.
|
||||
*----------------------------------------------------------------------------*/
|
||||
extern THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags;
|
||||
enum {
|
||||
softfloat_flag_inexact = 1,
|
||||
softfloat_flag_underflow = 2,
|
||||
softfloat_flag_overflow = 4,
|
||||
softfloat_flag_infinite = 8,
|
||||
softfloat_flag_invalid = 16
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Routine to raise any or all of the software floating-point exception flags.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void softfloat_raiseFlags( uint_fast8_t );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Integer-to-floating-point conversion routines.
|
||||
*----------------------------------------------------------------------------*/
|
||||
float16_t ui32_to_f16( uint32_t );
|
||||
float32_t ui32_to_f32( uint32_t );
|
||||
float64_t ui32_to_f64( uint32_t );
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
extFloat80_t ui32_to_extF80( uint32_t );
|
||||
float128_t ui32_to_f128( uint32_t );
|
||||
#endif
|
||||
void ui32_to_extF80M( uint32_t, extFloat80_t * );
|
||||
void ui32_to_f128M( uint32_t, float128_t * );
|
||||
float16_t ui64_to_f16( uint64_t );
|
||||
float32_t ui64_to_f32( uint64_t );
|
||||
float64_t ui64_to_f64( uint64_t );
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
extFloat80_t ui64_to_extF80( uint64_t );
|
||||
float128_t ui64_to_f128( uint64_t );
|
||||
#endif
|
||||
void ui64_to_extF80M( uint64_t, extFloat80_t * );
|
||||
void ui64_to_f128M( uint64_t, float128_t * );
|
||||
float16_t i32_to_f16( int32_t );
|
||||
float32_t i32_to_f32( int32_t );
|
||||
float64_t i32_to_f64( int32_t );
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
extFloat80_t i32_to_extF80( int32_t );
|
||||
float128_t i32_to_f128( int32_t );
|
||||
#endif
|
||||
void i32_to_extF80M( int32_t, extFloat80_t * );
|
||||
void i32_to_f128M( int32_t, float128_t * );
|
||||
float16_t i64_to_f16( int64_t );
|
||||
float32_t i64_to_f32( int64_t );
|
||||
float64_t i64_to_f64( int64_t );
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
extFloat80_t i64_to_extF80( int64_t );
|
||||
float128_t i64_to_f128( int64_t );
|
||||
#endif
|
||||
void i64_to_extF80M( int64_t, extFloat80_t * );
|
||||
void i64_to_f128M( int64_t, float128_t * );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| 16-bit (half-precision) floating-point operations.
|
||||
*----------------------------------------------------------------------------*/
|
||||
uint_fast32_t f16_to_ui32( float16_t, uint_fast8_t, bool );
|
||||
uint_fast64_t f16_to_ui64( float16_t, uint_fast8_t, bool );
|
||||
int_fast32_t f16_to_i32( float16_t, uint_fast8_t, bool );
|
||||
int_fast64_t f16_to_i64( float16_t, uint_fast8_t, bool );
|
||||
uint_fast32_t f16_to_ui32_r_minMag( float16_t, bool );
|
||||
uint_fast64_t f16_to_ui64_r_minMag( float16_t, bool );
|
||||
int_fast32_t f16_to_i32_r_minMag( float16_t, bool );
|
||||
int_fast64_t f16_to_i64_r_minMag( float16_t, bool );
|
||||
float32_t f16_to_f32( float16_t );
|
||||
float64_t f16_to_f64( float16_t );
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
extFloat80_t f16_to_extF80( float16_t );
|
||||
float128_t f16_to_f128( float16_t );
|
||||
#endif
|
||||
void f16_to_extF80M( float16_t, extFloat80_t * );
|
||||
void f16_to_f128M( float16_t, float128_t * );
|
||||
float16_t f16_roundToInt( float16_t, uint_fast8_t, bool );
|
||||
float16_t f16_add( float16_t, float16_t );
|
||||
float16_t f16_sub( float16_t, float16_t );
|
||||
float16_t f16_mul( float16_t, float16_t );
|
||||
float16_t f16_mulAdd( float16_t, float16_t, float16_t );
|
||||
float16_t f16_div( float16_t, float16_t );
|
||||
float16_t f16_rem( float16_t, float16_t );
|
||||
float16_t f16_sqrt( float16_t );
|
||||
bool f16_eq( float16_t, float16_t );
|
||||
bool f16_le( float16_t, float16_t );
|
||||
bool f16_lt( float16_t, float16_t );
|
||||
bool f16_eq_signaling( float16_t, float16_t );
|
||||
bool f16_le_quiet( float16_t, float16_t );
|
||||
bool f16_lt_quiet( float16_t, float16_t );
|
||||
bool f16_isSignalingNaN( float16_t );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| 32-bit (single-precision) floating-point operations.
|
||||
*----------------------------------------------------------------------------*/
|
||||
uint_fast32_t f32_to_ui32( float32_t, uint_fast8_t, bool );
|
||||
uint_fast64_t f32_to_ui64( float32_t, uint_fast8_t, bool );
|
||||
int_fast32_t f32_to_i32( float32_t, uint_fast8_t, bool );
|
||||
int_fast64_t f32_to_i64( float32_t, uint_fast8_t, bool );
|
||||
uint_fast32_t f32_to_ui32_r_minMag( float32_t, bool );
|
||||
uint_fast64_t f32_to_ui64_r_minMag( float32_t, bool );
|
||||
int_fast32_t f32_to_i32_r_minMag( float32_t, bool );
|
||||
int_fast64_t f32_to_i64_r_minMag( float32_t, bool );
|
||||
float16_t f32_to_f16( float32_t );
|
||||
float64_t f32_to_f64( float32_t );
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
extFloat80_t f32_to_extF80( float32_t );
|
||||
float128_t f32_to_f128( float32_t );
|
||||
#endif
|
||||
void f32_to_extF80M( float32_t, extFloat80_t * );
|
||||
void f32_to_f128M( float32_t, float128_t * );
|
||||
float32_t f32_roundToInt( float32_t, uint_fast8_t, bool );
|
||||
float32_t f32_add( float32_t, float32_t );
|
||||
float32_t f32_sub( float32_t, float32_t );
|
||||
float32_t f32_mul( float32_t, float32_t );
|
||||
float32_t f32_mulAdd( float32_t, float32_t, float32_t );
|
||||
float32_t f32_div( float32_t, float32_t );
|
||||
float32_t f32_rem( float32_t, float32_t );
|
||||
float32_t f32_sqrt( float32_t );
|
||||
bool f32_eq( float32_t, float32_t );
|
||||
bool f32_le( float32_t, float32_t );
|
||||
bool f32_lt( float32_t, float32_t );
|
||||
bool f32_eq_signaling( float32_t, float32_t );
|
||||
bool f32_le_quiet( float32_t, float32_t );
|
||||
bool f32_lt_quiet( float32_t, float32_t );
|
||||
bool f32_isSignalingNaN( float32_t );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| 64-bit (double-precision) floating-point operations.
|
||||
*----------------------------------------------------------------------------*/
|
||||
uint_fast32_t f64_to_ui32( float64_t, uint_fast8_t, bool );
|
||||
uint_fast64_t f64_to_ui64( float64_t, uint_fast8_t, bool );
|
||||
int_fast32_t f64_to_i32( float64_t, uint_fast8_t, bool );
|
||||
int_fast64_t f64_to_i64( float64_t, uint_fast8_t, bool );
|
||||
uint_fast32_t f64_to_ui32_r_minMag( float64_t, bool );
|
||||
uint_fast64_t f64_to_ui64_r_minMag( float64_t, bool );
|
||||
int_fast32_t f64_to_i32_r_minMag( float64_t, bool );
|
||||
int_fast64_t f64_to_i64_r_minMag( float64_t, bool );
|
||||
float16_t f64_to_f16( float64_t );
|
||||
float32_t f64_to_f32( float64_t );
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
extFloat80_t f64_to_extF80( float64_t );
|
||||
float128_t f64_to_f128( float64_t );
|
||||
#endif
|
||||
void f64_to_extF80M( float64_t, extFloat80_t * );
|
||||
void f64_to_f128M( float64_t, float128_t * );
|
||||
float64_t f64_roundToInt( float64_t, uint_fast8_t, bool );
|
||||
float64_t f64_add( float64_t, float64_t );
|
||||
float64_t f64_sub( float64_t, float64_t );
|
||||
float64_t f64_mul( float64_t, float64_t );
|
||||
float64_t f64_mulAdd( float64_t, float64_t, float64_t );
|
||||
float64_t f64_div( float64_t, float64_t );
|
||||
float64_t f64_rem( float64_t, float64_t );
|
||||
float64_t f64_sqrt( float64_t );
|
||||
bool f64_eq( float64_t, float64_t );
|
||||
bool f64_le( float64_t, float64_t );
|
||||
bool f64_lt( float64_t, float64_t );
|
||||
bool f64_eq_signaling( float64_t, float64_t );
|
||||
bool f64_le_quiet( float64_t, float64_t );
|
||||
bool f64_lt_quiet( float64_t, float64_t );
|
||||
bool f64_isSignalingNaN( float64_t );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Rounding precision for 80-bit extended double-precision floating-point.
|
||||
| Valid values are 32, 64, and 80.
|
||||
*----------------------------------------------------------------------------*/
|
||||
extern THREAD_LOCAL uint_fast8_t extF80_roundingPrecision;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| 80-bit extended double-precision floating-point operations.
|
||||
*----------------------------------------------------------------------------*/
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
uint_fast32_t extF80_to_ui32( extFloat80_t, uint_fast8_t, bool );
|
||||
uint_fast64_t extF80_to_ui64( extFloat80_t, uint_fast8_t, bool );
|
||||
int_fast32_t extF80_to_i32( extFloat80_t, uint_fast8_t, bool );
|
||||
int_fast64_t extF80_to_i64( extFloat80_t, uint_fast8_t, bool );
|
||||
uint_fast32_t extF80_to_ui32_r_minMag( extFloat80_t, bool );
|
||||
uint_fast64_t extF80_to_ui64_r_minMag( extFloat80_t, bool );
|
||||
int_fast32_t extF80_to_i32_r_minMag( extFloat80_t, bool );
|
||||
int_fast64_t extF80_to_i64_r_minMag( extFloat80_t, bool );
|
||||
float16_t extF80_to_f16( extFloat80_t );
|
||||
float32_t extF80_to_f32( extFloat80_t );
|
||||
float64_t extF80_to_f64( extFloat80_t );
|
||||
float128_t extF80_to_f128( extFloat80_t );
|
||||
extFloat80_t extF80_roundToInt( extFloat80_t, uint_fast8_t, bool );
|
||||
extFloat80_t extF80_add( extFloat80_t, extFloat80_t );
|
||||
extFloat80_t extF80_sub( extFloat80_t, extFloat80_t );
|
||||
extFloat80_t extF80_mul( extFloat80_t, extFloat80_t );
|
||||
extFloat80_t extF80_div( extFloat80_t, extFloat80_t );
|
||||
extFloat80_t extF80_rem( extFloat80_t, extFloat80_t );
|
||||
extFloat80_t extF80_sqrt( extFloat80_t );
|
||||
bool extF80_eq( extFloat80_t, extFloat80_t );
|
||||
bool extF80_le( extFloat80_t, extFloat80_t );
|
||||
bool extF80_lt( extFloat80_t, extFloat80_t );
|
||||
bool extF80_eq_signaling( extFloat80_t, extFloat80_t );
|
||||
bool extF80_le_quiet( extFloat80_t, extFloat80_t );
|
||||
bool extF80_lt_quiet( extFloat80_t, extFloat80_t );
|
||||
bool extF80_isSignalingNaN( extFloat80_t );
|
||||
#endif
|
||||
uint_fast32_t extF80M_to_ui32( const extFloat80_t *, uint_fast8_t, bool );
|
||||
uint_fast64_t extF80M_to_ui64( const extFloat80_t *, uint_fast8_t, bool );
|
||||
int_fast32_t extF80M_to_i32( const extFloat80_t *, uint_fast8_t, bool );
|
||||
int_fast64_t extF80M_to_i64( const extFloat80_t *, uint_fast8_t, bool );
|
||||
uint_fast32_t extF80M_to_ui32_r_minMag( const extFloat80_t *, bool );
|
||||
uint_fast64_t extF80M_to_ui64_r_minMag( const extFloat80_t *, bool );
|
||||
int_fast32_t extF80M_to_i32_r_minMag( const extFloat80_t *, bool );
|
||||
int_fast64_t extF80M_to_i64_r_minMag( const extFloat80_t *, bool );
|
||||
float16_t extF80M_to_f16( const extFloat80_t * );
|
||||
float32_t extF80M_to_f32( const extFloat80_t * );
|
||||
float64_t extF80M_to_f64( const extFloat80_t * );
|
||||
void extF80M_to_f128M( const extFloat80_t *, float128_t * );
|
||||
void
|
||||
extF80M_roundToInt(
|
||||
const extFloat80_t *, uint_fast8_t, bool, extFloat80_t * );
|
||||
void extF80M_add( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
|
||||
void extF80M_sub( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
|
||||
void extF80M_mul( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
|
||||
void extF80M_div( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
|
||||
void extF80M_rem( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
|
||||
void extF80M_sqrt( const extFloat80_t *, extFloat80_t * );
|
||||
bool extF80M_eq( const extFloat80_t *, const extFloat80_t * );
|
||||
bool extF80M_le( const extFloat80_t *, const extFloat80_t * );
|
||||
bool extF80M_lt( const extFloat80_t *, const extFloat80_t * );
|
||||
bool extF80M_eq_signaling( const extFloat80_t *, const extFloat80_t * );
|
||||
bool extF80M_le_quiet( const extFloat80_t *, const extFloat80_t * );
|
||||
bool extF80M_lt_quiet( const extFloat80_t *, const extFloat80_t * );
|
||||
bool extF80M_isSignalingNaN( const extFloat80_t * );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| 128-bit (quadruple-precision) floating-point operations.
|
||||
*----------------------------------------------------------------------------*/
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
uint_fast32_t f128_to_ui32( float128_t, uint_fast8_t, bool );
|
||||
uint_fast64_t f128_to_ui64( float128_t, uint_fast8_t, bool );
|
||||
int_fast32_t f128_to_i32( float128_t, uint_fast8_t, bool );
|
||||
int_fast64_t f128_to_i64( float128_t, uint_fast8_t, bool );
|
||||
uint_fast32_t f128_to_ui32_r_minMag( float128_t, bool );
|
||||
uint_fast64_t f128_to_ui64_r_minMag( float128_t, bool );
|
||||
int_fast32_t f128_to_i32_r_minMag( float128_t, bool );
|
||||
int_fast64_t f128_to_i64_r_minMag( float128_t, bool );
|
||||
float16_t f128_to_f16( float128_t );
|
||||
float32_t f128_to_f32( float128_t );
|
||||
float64_t f128_to_f64( float128_t );
|
||||
extFloat80_t f128_to_extF80( float128_t );
|
||||
float128_t f128_roundToInt( float128_t, uint_fast8_t, bool );
|
||||
float128_t f128_add( float128_t, float128_t );
|
||||
float128_t f128_sub( float128_t, float128_t );
|
||||
float128_t f128_mul( float128_t, float128_t );
|
||||
float128_t f128_mulAdd( float128_t, float128_t, float128_t );
|
||||
float128_t f128_div( float128_t, float128_t );
|
||||
float128_t f128_rem( float128_t, float128_t );
|
||||
float128_t f128_sqrt( float128_t );
|
||||
bool f128_eq( float128_t, float128_t );
|
||||
bool f128_le( float128_t, float128_t );
|
||||
bool f128_lt( float128_t, float128_t );
|
||||
bool f128_eq_signaling( float128_t, float128_t );
|
||||
bool f128_le_quiet( float128_t, float128_t );
|
||||
bool f128_lt_quiet( float128_t, float128_t );
|
||||
bool f128_isSignalingNaN( float128_t );
|
||||
#endif
|
||||
uint_fast32_t f128M_to_ui32( const float128_t *, uint_fast8_t, bool );
|
||||
uint_fast64_t f128M_to_ui64( const float128_t *, uint_fast8_t, bool );
|
||||
int_fast32_t f128M_to_i32( const float128_t *, uint_fast8_t, bool );
|
||||
int_fast64_t f128M_to_i64( const float128_t *, uint_fast8_t, bool );
|
||||
uint_fast32_t f128M_to_ui32_r_minMag( const float128_t *, bool );
|
||||
uint_fast64_t f128M_to_ui64_r_minMag( const float128_t *, bool );
|
||||
int_fast32_t f128M_to_i32_r_minMag( const float128_t *, bool );
|
||||
int_fast64_t f128M_to_i64_r_minMag( const float128_t *, bool );
|
||||
float16_t f128M_to_f16( const float128_t * );
|
||||
float32_t f128M_to_f32( const float128_t * );
|
||||
float64_t f128M_to_f64( const float128_t * );
|
||||
void f128M_to_extF80M( const float128_t *, extFloat80_t * );
|
||||
void f128M_roundToInt( const float128_t *, uint_fast8_t, bool, float128_t * );
|
||||
void f128M_add( const float128_t *, const float128_t *, float128_t * );
|
||||
void f128M_sub( const float128_t *, const float128_t *, float128_t * );
|
||||
void f128M_mul( const float128_t *, const float128_t *, float128_t * );
|
||||
void
|
||||
f128M_mulAdd(
|
||||
const float128_t *, const float128_t *, const float128_t *, float128_t *
|
||||
);
|
||||
void f128M_div( const float128_t *, const float128_t *, float128_t * );
|
||||
void f128M_rem( const float128_t *, const float128_t *, float128_t * );
|
||||
void f128M_sqrt( const float128_t *, float128_t * );
|
||||
bool f128M_eq( const float128_t *, const float128_t * );
|
||||
bool f128M_le( const float128_t *, const float128_t * );
|
||||
bool f128M_lt( const float128_t *, const float128_t * );
|
||||
bool f128M_eq_signaling( const float128_t *, const float128_t * );
|
||||
bool f128M_le_quiet( const float128_t *, const float128_t * );
|
||||
bool f128M_lt_quiet( const float128_t *, const float128_t * );
|
||||
bool f128M_isSignalingNaN( const float128_t * );
|
||||
|
||||
#endif
|
||||
|
||||
81
liba/src/external/softfloat/include/softfloat_types.h
vendored
Normal file
81
liba/src/external/softfloat/include/softfloat_types.h
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#ifndef softfloat_types_h
|
||||
#define softfloat_types_h 1
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Types used to pass 16-bit, 32-bit, 64-bit, and 128-bit floating-point
|
||||
| arguments and results to/from functions. These types must be exactly
|
||||
| 16 bits, 32 bits, 64 bits, and 128 bits in size, respectively. Where a
|
||||
| platform has "native" support for IEEE-Standard floating-point formats,
|
||||
| the types below may, if desired, be defined as aliases for the native types
|
||||
| (typically 'float' and 'double', and possibly 'long double').
|
||||
*----------------------------------------------------------------------------*/
|
||||
typedef struct { uint16_t v; } float16_t;
|
||||
typedef struct { uint32_t v; } float32_t;
|
||||
typedef struct { uint64_t v; } float64_t;
|
||||
typedef struct { uint64_t v[2]; } float128_t;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| The format of an 80-bit extended floating-point number in memory. This
|
||||
| structure must contain a 16-bit field named 'signExp' and a 64-bit field
|
||||
| named 'signif'.
|
||||
*----------------------------------------------------------------------------*/
|
||||
#ifdef LITTLEENDIAN
|
||||
struct extFloat80M { uint64_t signif; uint16_t signExp; };
|
||||
#else
|
||||
struct extFloat80M { uint16_t signExp; uint64_t signif; };
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| The type used to pass 80-bit extended floating-point arguments and
|
||||
| results to/from functions. This type must have size identical to
|
||||
| 'struct extFloat80M'. Type 'extFloat80_t' can be defined as an alias for
|
||||
| 'struct extFloat80M'. Alternatively, if a platform has "native" support
|
||||
| for IEEE-Standard 80-bit extended floating-point, it may be possible,
|
||||
| if desired, to define 'extFloat80_t' as an alias for the native type
|
||||
| (presumably either 'long double' or a nonstandard compiler-intrinsic type).
|
||||
| In that case, the 'signif' and 'signExp' fields of 'struct extFloat80M'
|
||||
| must align exactly with the locations in memory of the sign, exponent, and
|
||||
| significand of the native type.
|
||||
*----------------------------------------------------------------------------*/
|
||||
typedef struct extFloat80M extFloat80_t;
|
||||
|
||||
#endif
|
||||
|
||||
7
liba/src/external/softfloat/port/platform.h
vendored
Normal file
7
liba/src/external/softfloat/port/platform.h
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef LIBA_SOFTFLOAT_PORT_PLATFORM_H
|
||||
#define LIBA_SOFTFLOAT_PORT_PLATFORM_H 1
|
||||
|
||||
#define LITTLEENDIAN 1
|
||||
#define INLINE inline
|
||||
|
||||
#endif
|
||||
19
liba/src/external/softfloat/port/softfloat.h
vendored
Normal file
19
liba/src/external/softfloat/port/softfloat.h
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef LIBA_SOFTFLOAT_H
|
||||
#define LIBA_SOFTFLOAT_H 1
|
||||
|
||||
/* As instructed in the softfloat documentation, we do not expose the original
|
||||
* softfloat.h header. Instead, we create our own. This has the great upside of
|
||||
* letting us declare functions that takes native types (i.e. float, double). */
|
||||
|
||||
int f64_to_ui32_r_minMag(double x, int i);
|
||||
double ui32_to_f64(int i);
|
||||
|
||||
int f64_eq(double x, double y);
|
||||
int f64_le(double x, double y);
|
||||
int f64_lt(double x, double y);
|
||||
double f64_add(double x, double y);
|
||||
double f64_sub(double x, double y);
|
||||
double f64_mul(double x, double y);
|
||||
double f64_div(double x, double y);
|
||||
|
||||
#endif
|
||||
84
liba/src/external/softfloat/src/8086/s_propagateNaNF64UI.c
vendored
Normal file
84
liba/src/external/softfloat/src/8086/s_propagateNaNF64UI.c
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Interpreting `uiA' and `uiB' as the bit patterns of two 64-bit floating-
|
||||
| point values, at least one of which is a NaN, returns the bit pattern of
|
||||
| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
|
||||
| signaling NaN, the invalid exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
uint_fast64_t
|
||||
softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB )
|
||||
{
|
||||
bool isSigNaNA, isSigNaNB;
|
||||
uint_fast64_t uiNonsigA, uiNonsigB, uiMagA, uiMagB;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
isSigNaNA = softfloat_isSigNaNF64UI( uiA );
|
||||
isSigNaNB = softfloat_isSigNaNF64UI( uiB );
|
||||
/*------------------------------------------------------------------------
|
||||
| Make NaNs non-signaling.
|
||||
*------------------------------------------------------------------------*/
|
||||
uiNonsigA = uiA | UINT64_C( 0x0008000000000000 );
|
||||
uiNonsigB = uiB | UINT64_C( 0x0008000000000000 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( isSigNaNA | isSigNaNB ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
if ( isSigNaNA ) {
|
||||
if ( isSigNaNB ) goto returnLargerMag;
|
||||
return isNaNF64UI( uiB ) ? uiNonsigB : uiNonsigA;
|
||||
} else {
|
||||
return isNaNF64UI( uiA ) ? uiNonsigA : uiNonsigB;
|
||||
}
|
||||
}
|
||||
returnLargerMag:
|
||||
uiMagA = uiNonsigA & UINT64_C( 0x7FFFFFFFFFFFFFFF );
|
||||
uiMagB = uiNonsigB & UINT64_C( 0x7FFFFFFFFFFFFFFF );
|
||||
if ( uiMagA < uiMagB ) return uiNonsigB;
|
||||
if ( uiMagB < uiMagA ) return uiNonsigA;
|
||||
return (uiNonsigA < uiNonsigB) ? uiNonsigA : uiNonsigB;
|
||||
|
||||
}
|
||||
|
||||
52
liba/src/external/softfloat/src/8086/softfloat_raiseFlags.c
vendored
Normal file
52
liba/src/external/softfloat/src/8086/softfloat_raiseFlags.c
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include "platform.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Raises the exceptions specified by `flags'. Floating-point traps can be
|
||||
| defined here if desired. It is currently not possible for such a trap
|
||||
| to substitute a result value. If traps are not implemented, this routine
|
||||
| should be simply `softfloat_exceptionFlags |= flags;'.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void softfloat_raiseFlags( uint_fast8_t flags )
|
||||
{
|
||||
|
||||
softfloat_exceptionFlags |= flags;
|
||||
|
||||
}
|
||||
|
||||
375
liba/src/external/softfloat/src/8086/specialize.h
vendored
Normal file
375
liba/src/external/softfloat/src/8086/specialize.h
vendored
Normal file
@@ -0,0 +1,375 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#ifndef specialize_h
|
||||
#define specialize_h 1
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "softfloat_types.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Default value for `softfloat_detectTininess'.
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define init_detectTininess softfloat_tininess_afterRounding
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| The values to return on conversions to 32-bit integer formats that raise an
|
||||
| invalid exception.
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define ui32_fromPosOverflow 0xFFFFFFFF
|
||||
#define ui32_fromNegOverflow 0
|
||||
#define ui32_fromNaN 0xFFFFFFFF
|
||||
#define i32_fromPosOverflow 0x7FFFFFFF
|
||||
#define i32_fromNegOverflow (-0x7FFFFFFF - 1)
|
||||
#define i32_fromNaN 0x7FFFFFFF
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| The values to return on conversions to 64-bit integer formats that raise an
|
||||
| invalid exception.
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define ui64_fromPosOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
|
||||
#define ui64_fromNegOverflow 0
|
||||
#define ui64_fromNaN UINT64_C( 0xFFFFFFFFFFFFFFFF )
|
||||
#define i64_fromPosOverflow UINT64_C( 0x7FFFFFFFFFFFFFFF )
|
||||
#define i64_fromNegOverflow (-UINT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
|
||||
#define i64_fromNaN UINT64_C( 0x7FFFFFFFFFFFFFFF )
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| "Common NaN" structure, used to transfer NaN representations from one format
|
||||
| to another.
|
||||
*----------------------------------------------------------------------------*/
|
||||
struct commonNaN {
|
||||
bool sign;
|
||||
#ifdef LITTLEENDIAN
|
||||
uint64_t v0, v64;
|
||||
#else
|
||||
uint64_t v64, v0;
|
||||
#endif
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| The bit pattern for a default generated 16-bit floating-point NaN.
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define defaultNaNF16UI 0xFE00
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns true when 16-bit unsigned integer `uiA' has the bit pattern of a
|
||||
| 16-bit floating-point signaling NaN.
|
||||
| Note: This macro evaluates its argument more than once.
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define softfloat_isSigNaNF16UI( uiA ) ((((uiA) & 0x7E00) == 0x7C00) && ((uiA) & 0x01FF))
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Assuming `uiA' has the bit pattern of a 16-bit floating-point NaN, converts
|
||||
| this NaN to the common NaN form, and stores the resulting common NaN at the
|
||||
| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
|
||||
| exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Converts the common NaN pointed to by `aPtr' into a 16-bit floating-point
|
||||
| NaN, and returns the bit pattern of this value as an unsigned integer.
|
||||
*----------------------------------------------------------------------------*/
|
||||
uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Interpreting `uiA' and `uiB' as the bit patterns of two 16-bit floating-
|
||||
| point values, at least one of which is a NaN, returns the bit pattern of
|
||||
| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
|
||||
| signaling NaN, the invalid exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
uint_fast16_t
|
||||
softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| The bit pattern for a default generated 32-bit floating-point NaN.
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define defaultNaNF32UI 0xFFC00000
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns true when 32-bit unsigned integer `uiA' has the bit pattern of a
|
||||
| 32-bit floating-point signaling NaN.
|
||||
| Note: This macro evaluates its argument more than once.
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define softfloat_isSigNaNF32UI( uiA ) ((((uiA) & 0x7FC00000) == 0x7F800000) && ((uiA) & 0x003FFFFF))
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Assuming `uiA' has the bit pattern of a 32-bit floating-point NaN, converts
|
||||
| this NaN to the common NaN form, and stores the resulting common NaN at the
|
||||
| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
|
||||
| exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void softfloat_f32UIToCommonNaN( uint_fast32_t uiA, struct commonNaN *zPtr );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Converts the common NaN pointed to by `aPtr' into a 32-bit floating-point
|
||||
| NaN, and returns the bit pattern of this value as an unsigned integer.
|
||||
*----------------------------------------------------------------------------*/
|
||||
uint_fast32_t softfloat_commonNaNToF32UI( const struct commonNaN *aPtr );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Interpreting `uiA' and `uiB' as the bit patterns of two 32-bit floating-
|
||||
| point values, at least one of which is a NaN, returns the bit pattern of
|
||||
| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
|
||||
| signaling NaN, the invalid exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
uint_fast32_t
|
||||
softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| The bit pattern for a default generated 64-bit floating-point NaN.
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define defaultNaNF64UI UINT64_C( 0xFFF8000000000000 )
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns true when 64-bit unsigned integer `uiA' has the bit pattern of a
|
||||
| 64-bit floating-point signaling NaN.
|
||||
| Note: This macro evaluates its argument more than once.
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define softfloat_isSigNaNF64UI( uiA ) ((((uiA) & UINT64_C( 0x7FF8000000000000 )) == UINT64_C( 0x7FF0000000000000 )) && ((uiA) & UINT64_C( 0x0007FFFFFFFFFFFF )))
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Assuming `uiA' has the bit pattern of a 64-bit floating-point NaN, converts
|
||||
| this NaN to the common NaN form, and stores the resulting common NaN at the
|
||||
| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
|
||||
| exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void softfloat_f64UIToCommonNaN( uint_fast64_t uiA, struct commonNaN *zPtr );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Converts the common NaN pointed to by `aPtr' into a 64-bit floating-point
|
||||
| NaN, and returns the bit pattern of this value as an unsigned integer.
|
||||
*----------------------------------------------------------------------------*/
|
||||
uint_fast64_t softfloat_commonNaNToF64UI( const struct commonNaN *aPtr );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Interpreting `uiA' and `uiB' as the bit patterns of two 64-bit floating-
|
||||
| point values, at least one of which is a NaN, returns the bit pattern of
|
||||
| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
|
||||
| signaling NaN, the invalid exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
uint_fast64_t
|
||||
softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| The bit pattern for a default generated 80-bit extended floating-point NaN.
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define defaultNaNExtF80UI64 0xFFFF
|
||||
#define defaultNaNExtF80UI0 UINT64_C( 0xC000000000000000 )
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns true when the 80-bit unsigned integer formed from concatenating
|
||||
| 16-bit `uiA64' and 64-bit `uiA0' has the bit pattern of an 80-bit extended
|
||||
| floating-point signaling NaN.
|
||||
| Note: This macro evaluates its arguments more than once.
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ((((uiA64) & 0x7FFF) == 0x7FFF) && ! ((uiA0) & UINT64_C( 0x4000000000000000 )) && ((uiA0) & UINT64_C( 0x3FFFFFFFFFFFFFFF )))
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| The following functions are needed only when `SOFTFLOAT_FAST_INT64' is
|
||||
| defined.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Assuming the unsigned integer formed from concatenating `uiA64' and `uiA0'
|
||||
| has the bit pattern of an 80-bit extended floating-point NaN, converts
|
||||
| this NaN to the common NaN form, and stores the resulting common NaN at the
|
||||
| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
|
||||
| exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
softfloat_extF80UIToCommonNaN(
|
||||
uint_fast16_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Converts the common NaN pointed to by `aPtr' into an 80-bit extended
|
||||
| floating-point NaN, and returns the bit pattern of this value as an unsigned
|
||||
| integer.
|
||||
*----------------------------------------------------------------------------*/
|
||||
struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Interpreting the unsigned integer formed from concatenating `uiA64' and
|
||||
| `uiA0' as an 80-bit extended floating-point value, and likewise interpreting
|
||||
| the unsigned integer formed from concatenating `uiB64' and `uiB0' as another
|
||||
| 80-bit extended floating-point value, and assuming at least on of these
|
||||
| floating-point values is a NaN, returns the bit pattern of the combined NaN
|
||||
| result. If either original floating-point value is a signaling NaN, the
|
||||
| invalid exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
struct uint128
|
||||
softfloat_propagateNaNExtF80UI(
|
||||
uint_fast16_t uiA64,
|
||||
uint_fast64_t uiA0,
|
||||
uint_fast16_t uiB64,
|
||||
uint_fast64_t uiB0
|
||||
);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| The bit pattern for a default generated 128-bit floating-point NaN.
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define defaultNaNF128UI64 UINT64_C( 0xFFFF800000000000 )
|
||||
#define defaultNaNF128UI0 UINT64_C( 0 )
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Returns true when the 128-bit unsigned integer formed from concatenating
|
||||
| 64-bit `uiA64' and 64-bit `uiA0' has the bit pattern of a 128-bit floating-
|
||||
| point signaling NaN.
|
||||
| Note: This macro evaluates its arguments more than once.
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define softfloat_isSigNaNF128UI( uiA64, uiA0 ) ((((uiA64) & UINT64_C( 0x7FFF800000000000 )) == UINT64_C( 0x7FFF000000000000 )) && ((uiA0) || ((uiA64) & UINT64_C( 0x00007FFFFFFFFFFF ))))
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Assuming the unsigned integer formed from concatenating `uiA64' and `uiA0'
|
||||
| has the bit pattern of a 128-bit floating-point NaN, converts this NaN to
|
||||
| the common NaN form, and stores the resulting common NaN at the location
|
||||
| pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid exception
|
||||
| is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
softfloat_f128UIToCommonNaN(
|
||||
uint_fast64_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Converts the common NaN pointed to by `aPtr' into a 128-bit floating-point
|
||||
| NaN, and returns the bit pattern of this value as an unsigned integer.
|
||||
*----------------------------------------------------------------------------*/
|
||||
struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN * );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Interpreting the unsigned integer formed from concatenating `uiA64' and
|
||||
| `uiA0' as a 128-bit floating-point value, and likewise interpreting the
|
||||
| unsigned integer formed from concatenating `uiB64' and `uiB0' as another
|
||||
| 128-bit floating-point value, and assuming at least on of these floating-
|
||||
| point values is a NaN, returns the bit pattern of the combined NaN result.
|
||||
| If either original floating-point value is a signaling NaN, the invalid
|
||||
| exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
struct uint128
|
||||
softfloat_propagateNaNF128UI(
|
||||
uint_fast64_t uiA64,
|
||||
uint_fast64_t uiA0,
|
||||
uint_fast64_t uiB64,
|
||||
uint_fast64_t uiB0
|
||||
);
|
||||
|
||||
#else
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| The following functions are needed only when `SOFTFLOAT_FAST_INT64' is not
|
||||
| defined.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Assuming the 80-bit extended floating-point value pointed to by `aSPtr' is
|
||||
| a NaN, converts this NaN to the common NaN form, and stores the resulting
|
||||
| common NaN at the location pointed to by `zPtr'. If the NaN is a signaling
|
||||
| NaN, the invalid exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
softfloat_extF80MToCommonNaN(
|
||||
const struct extFloat80M *aSPtr, struct commonNaN *zPtr );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Converts the common NaN pointed to by `aPtr' into an 80-bit extended
|
||||
| floating-point NaN, and stores this NaN at the location pointed to by
|
||||
| `zSPtr'.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
softfloat_commonNaNToExtF80M(
|
||||
const struct commonNaN *aPtr, struct extFloat80M *zSPtr );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Assuming at least one of the two 80-bit extended floating-point values
|
||||
| pointed to by `aSPtr' and `bSPtr' is a NaN, stores the combined NaN result
|
||||
| at the location pointed to by `zSPtr'. If either original floating-point
|
||||
| value is a signaling NaN, the invalid exception is raised.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
softfloat_propagateNaNExtF80M(
|
||||
const struct extFloat80M *aSPtr,
|
||||
const struct extFloat80M *bSPtr,
|
||||
struct extFloat80M *zSPtr
|
||||
);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| The bit pattern for a default generated 128-bit floating-point NaN.
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define defaultNaNF128UI96 0xFFFF8000
|
||||
#define defaultNaNF128UI64 0
|
||||
#define defaultNaNF128UI32 0
|
||||
#define defaultNaNF128UI0 0
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Assuming the 128-bit floating-point value pointed to by `aWPtr' is a NaN,
|
||||
| converts this NaN to the common NaN form, and stores the resulting common
|
||||
| NaN at the location pointed to by `zPtr'. If the NaN is a signaling NaN,
|
||||
| the invalid exception is raised. Argument `aWPtr' points to an array of
|
||||
| four 32-bit elements that concatenate in the platform's normal endian order
|
||||
| to form a 128-bit floating-point value.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
softfloat_f128MToCommonNaN( const uint32_t *aWPtr, struct commonNaN *zPtr );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Converts the common NaN pointed to by `aPtr' into a 128-bit floating-point
|
||||
| NaN, and stores this NaN at the location pointed to by `zWPtr'. Argument
|
||||
| `zWPtr' points to an array of four 32-bit elements that concatenate in the
|
||||
| platform's normal endian order to form a 128-bit floating-point value.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
softfloat_commonNaNToF128M( const struct commonNaN *aPtr, uint32_t *zWPtr );
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
| Assuming at least one of the two 128-bit floating-point values pointed to by
|
||||
| `aWPtr' and `bWPtr' is a NaN, stores the combined NaN result at the location
|
||||
| pointed to by `zWPtr'. If either original floating-point value is a
|
||||
| signaling NaN, the invalid exception is raised. Each of `aWPtr', `bWPtr',
|
||||
| and `zWPtr' points to an array of four 32-bit elements that concatenate in
|
||||
| the platform's normal endian order to form a 128-bit floating-point value.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
softfloat_propagateNaNF128M(
|
||||
const uint32_t *aWPtr, const uint32_t *bWPtr, uint32_t *zWPtr );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
74
liba/src/external/softfloat/src/f64_add.c
vendored
Normal file
74
liba/src/external/softfloat/src/f64_add.c
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float64_t f64_add( float64_t a, float64_t b )
|
||||
{
|
||||
union ui64_f64 uA;
|
||||
uint_fast64_t uiA;
|
||||
bool signA;
|
||||
union ui64_f64 uB;
|
||||
uint_fast64_t uiB;
|
||||
bool signB;
|
||||
#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
|
||||
float64_t (*magsFuncPtr)( uint_fast64_t, uint_fast64_t, bool );
|
||||
#endif
|
||||
|
||||
uA.f = a;
|
||||
uiA = uA.ui;
|
||||
signA = signF64UI( uiA );
|
||||
uB.f = b;
|
||||
uiB = uB.ui;
|
||||
signB = signF64UI( uiB );
|
||||
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
||||
if ( signA == signB ) {
|
||||
return softfloat_addMagsF64( uiA, uiB, signA );
|
||||
} else {
|
||||
return softfloat_subMagsF64( uiA, uiB, signA );
|
||||
}
|
||||
#else
|
||||
magsFuncPtr =
|
||||
(signA == signB) ? softfloat_addMagsF64 : softfloat_subMagsF64;
|
||||
return (*magsFuncPtr)( uiA, uiB, signA );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
172
liba/src/external/softfloat/src/f64_div.c
vendored
Normal file
172
liba/src/external/softfloat/src/f64_div.c
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float64_t f64_div( float64_t a, float64_t b )
|
||||
{
|
||||
union ui64_f64 uA;
|
||||
uint_fast64_t uiA;
|
||||
bool signA;
|
||||
int_fast16_t expA;
|
||||
uint_fast64_t sigA;
|
||||
union ui64_f64 uB;
|
||||
uint_fast64_t uiB;
|
||||
bool signB;
|
||||
int_fast16_t expB;
|
||||
uint_fast64_t sigB;
|
||||
bool signZ;
|
||||
struct exp16_sig64 normExpSig;
|
||||
int_fast16_t expZ;
|
||||
uint32_t recip32, sig32Z, doubleTerm;
|
||||
uint_fast64_t rem;
|
||||
uint32_t q;
|
||||
uint_fast64_t sigZ;
|
||||
uint_fast64_t uiZ;
|
||||
union ui64_f64 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA = uA.ui;
|
||||
signA = signF64UI( uiA );
|
||||
expA = expF64UI( uiA );
|
||||
sigA = fracF64UI( uiA );
|
||||
uB.f = b;
|
||||
uiB = uB.ui;
|
||||
signB = signF64UI( uiB );
|
||||
expB = expF64UI( uiB );
|
||||
sigB = fracF64UI( uiB );
|
||||
signZ = signA ^ signB;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( expA == 0x7FF ) {
|
||||
if ( sigA ) goto propagateNaN;
|
||||
if ( expB == 0x7FF ) {
|
||||
if ( sigB ) goto propagateNaN;
|
||||
goto invalid;
|
||||
}
|
||||
goto infinity;
|
||||
}
|
||||
if ( expB == 0x7FF ) {
|
||||
if ( sigB ) goto propagateNaN;
|
||||
goto zero;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! expB ) {
|
||||
if ( ! sigB ) {
|
||||
if ( ! (expA | sigA) ) goto invalid;
|
||||
softfloat_raiseFlags( softfloat_flag_infinite );
|
||||
goto infinity;
|
||||
}
|
||||
normExpSig = softfloat_normSubnormalF64Sig( sigB );
|
||||
expB = normExpSig.exp;
|
||||
sigB = normExpSig.sig;
|
||||
}
|
||||
if ( ! expA ) {
|
||||
if ( ! sigA ) goto zero;
|
||||
normExpSig = softfloat_normSubnormalF64Sig( sigA );
|
||||
expA = normExpSig.exp;
|
||||
sigA = normExpSig.sig;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = expA - expB + 0x3FE;
|
||||
sigA |= UINT64_C( 0x0010000000000000 );
|
||||
sigB |= UINT64_C( 0x0010000000000000 );
|
||||
if ( sigA < sigB ) {
|
||||
--expZ;
|
||||
sigA <<= 11;
|
||||
} else {
|
||||
sigA <<= 10;
|
||||
}
|
||||
sigB <<= 11;
|
||||
recip32 = softfloat_approxRecip32_1( sigB>>32 ) - 2;
|
||||
sig32Z = ((uint32_t) (sigA>>32) * (uint_fast64_t) recip32)>>32;
|
||||
doubleTerm = sig32Z<<1;
|
||||
rem =
|
||||
((sigA - (uint_fast64_t) doubleTerm * (uint32_t) (sigB>>32))<<28)
|
||||
- (uint_fast64_t) doubleTerm * ((uint32_t) sigB>>4);
|
||||
q = (((uint32_t) (rem>>32) * (uint_fast64_t) recip32)>>32) + 4;
|
||||
sigZ = ((uint_fast64_t) sig32Z<<32) + ((uint_fast64_t) q<<4);
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (sigZ & 0x1FF) < 4<<4 ) {
|
||||
q &= ~7;
|
||||
sigZ &= ~(uint_fast64_t) 0x7F;
|
||||
doubleTerm = q<<1;
|
||||
rem =
|
||||
((rem - (uint_fast64_t) doubleTerm * (uint32_t) (sigB>>32))<<28)
|
||||
- (uint_fast64_t) doubleTerm * ((uint32_t) sigB>>4);
|
||||
if ( rem & UINT64_C( 0x8000000000000000 ) ) {
|
||||
sigZ -= 1<<7;
|
||||
} else {
|
||||
if ( rem ) sigZ |= 1;
|
||||
}
|
||||
}
|
||||
return softfloat_roundPackToF64( signZ, expZ, sigZ );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
propagateNaN:
|
||||
uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
uiZ = defaultNaNF64UI;
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
infinity:
|
||||
uiZ = packToF64UI( signZ, 0x7FF, 0 );
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
zero:
|
||||
uiZ = packToF64UI( signZ, 0, 0 );
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
66
liba/src/external/softfloat/src/f64_eq.c
vendored
Normal file
66
liba/src/external/softfloat/src/f64_eq.c
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool f64_eq( float64_t a, float64_t b )
|
||||
{
|
||||
union ui64_f64 uA;
|
||||
uint_fast64_t uiA;
|
||||
union ui64_f64 uB;
|
||||
uint_fast64_t uiB;
|
||||
|
||||
uA.f = a;
|
||||
uiA = uA.ui;
|
||||
uB.f = b;
|
||||
uiB = uB.ui;
|
||||
if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
|
||||
if (
|
||||
softfloat_isSigNaNF64UI( uiA ) || softfloat_isSigNaNF64UI( uiB )
|
||||
) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return (uiA == uiB) || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ));
|
||||
|
||||
}
|
||||
|
||||
67
liba/src/external/softfloat/src/f64_le.c
vendored
Normal file
67
liba/src/external/softfloat/src/f64_le.c
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool f64_le( float64_t a, float64_t b )
|
||||
{
|
||||
union ui64_f64 uA;
|
||||
uint_fast64_t uiA;
|
||||
union ui64_f64 uB;
|
||||
uint_fast64_t uiB;
|
||||
bool signA, signB;
|
||||
|
||||
uA.f = a;
|
||||
uiA = uA.ui;
|
||||
uB.f = b;
|
||||
uiB = uB.ui;
|
||||
if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
signA = signF64UI( uiA );
|
||||
signB = signF64UI( uiB );
|
||||
return
|
||||
(signA != signB)
|
||||
? signA || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
: (uiA == uiB) || (signA ^ (uiA < uiB));
|
||||
|
||||
}
|
||||
|
||||
67
liba/src/external/softfloat/src/f64_lt.c
vendored
Normal file
67
liba/src/external/softfloat/src/f64_lt.c
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool f64_lt( float64_t a, float64_t b )
|
||||
{
|
||||
union ui64_f64 uA;
|
||||
uint_fast64_t uiA;
|
||||
union ui64_f64 uB;
|
||||
uint_fast64_t uiB;
|
||||
bool signA, signB;
|
||||
|
||||
uA.f = a;
|
||||
uiA = uA.ui;
|
||||
uB.f = b;
|
||||
uiB = uB.ui;
|
||||
if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
signA = signF64UI( uiA );
|
||||
signB = signF64UI( uiB );
|
||||
return
|
||||
(signA != signB)
|
||||
? signA && ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
: (uiA != uiB) && (signA ^ (uiA < uiB));
|
||||
|
||||
}
|
||||
|
||||
150
liba/src/external/softfloat/src/f64_mul.c
vendored
Normal file
150
liba/src/external/softfloat/src/f64_mul.c
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float64_t f64_mul( float64_t a, float64_t b )
|
||||
{
|
||||
union ui64_f64 uA;
|
||||
uint_fast64_t uiA;
|
||||
bool signA;
|
||||
int_fast16_t expA;
|
||||
uint_fast64_t sigA;
|
||||
union ui64_f64 uB;
|
||||
uint_fast64_t uiB;
|
||||
bool signB;
|
||||
int_fast16_t expB;
|
||||
uint_fast64_t sigB;
|
||||
bool signZ;
|
||||
uint_fast64_t magBits;
|
||||
struct exp16_sig64 normExpSig;
|
||||
int_fast16_t expZ;
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
struct uint128 sig128Z;
|
||||
#else
|
||||
uint32_t sig128Z[4];
|
||||
#endif
|
||||
uint_fast64_t sigZ, uiZ;
|
||||
union ui64_f64 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA = uA.ui;
|
||||
signA = signF64UI( uiA );
|
||||
expA = expF64UI( uiA );
|
||||
sigA = fracF64UI( uiA );
|
||||
uB.f = b;
|
||||
uiB = uB.ui;
|
||||
signB = signF64UI( uiB );
|
||||
expB = expF64UI( uiB );
|
||||
sigB = fracF64UI( uiB );
|
||||
signZ = signA ^ signB;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( expA == 0x7FF ) {
|
||||
if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN;
|
||||
magBits = expB | sigB;
|
||||
goto infArg;
|
||||
}
|
||||
if ( expB == 0x7FF ) {
|
||||
if ( sigB ) goto propagateNaN;
|
||||
magBits = expA | sigA;
|
||||
goto infArg;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! expA ) {
|
||||
if ( ! sigA ) goto zero;
|
||||
normExpSig = softfloat_normSubnormalF64Sig( sigA );
|
||||
expA = normExpSig.exp;
|
||||
sigA = normExpSig.sig;
|
||||
}
|
||||
if ( ! expB ) {
|
||||
if ( ! sigB ) goto zero;
|
||||
normExpSig = softfloat_normSubnormalF64Sig( sigB );
|
||||
expB = normExpSig.exp;
|
||||
sigB = normExpSig.sig;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = expA + expB - 0x3FF;
|
||||
sigA = (sigA | UINT64_C( 0x0010000000000000 ))<<10;
|
||||
sigB = (sigB | UINT64_C( 0x0010000000000000 ))<<11;
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
sig128Z = softfloat_mul64To128( sigA, sigB );
|
||||
sigZ = sig128Z.v64 | (sig128Z.v0 != 0);
|
||||
#else
|
||||
softfloat_mul64To128M( sigA, sigB, sig128Z );
|
||||
sigZ =
|
||||
(uint64_t) sig128Z[indexWord( 4, 3 )]<<32 | sig128Z[indexWord( 4, 2 )];
|
||||
if ( sig128Z[indexWord( 4, 1 )] || sig128Z[indexWord( 4, 0 )] ) sigZ |= 1;
|
||||
#endif
|
||||
if ( sigZ < UINT64_C( 0x4000000000000000 ) ) {
|
||||
--expZ;
|
||||
sigZ <<= 1;
|
||||
}
|
||||
return softfloat_roundPackToF64( signZ, expZ, sigZ );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
propagateNaN:
|
||||
uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
infArg:
|
||||
if ( ! magBits ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
uiZ = defaultNaNF64UI;
|
||||
} else {
|
||||
uiZ = packToF64UI( signZ, 0x7FF, 0 );
|
||||
}
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
zero:
|
||||
uiZ = packToF64UI( signZ, 0, 0 );
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
74
liba/src/external/softfloat/src/f64_sub.c
vendored
Normal file
74
liba/src/external/softfloat/src/f64_sub.c
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float64_t f64_sub( float64_t a, float64_t b )
|
||||
{
|
||||
union ui64_f64 uA;
|
||||
uint_fast64_t uiA;
|
||||
bool signA;
|
||||
union ui64_f64 uB;
|
||||
uint_fast64_t uiB;
|
||||
bool signB;
|
||||
#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
|
||||
float64_t (*magsFuncPtr)( uint_fast64_t, uint_fast64_t, bool );
|
||||
#endif
|
||||
|
||||
uA.f = a;
|
||||
uiA = uA.ui;
|
||||
signA = signF64UI( uiA );
|
||||
uB.f = b;
|
||||
uiB = uB.ui;
|
||||
signB = signF64UI( uiB );
|
||||
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
||||
if ( signA == signB ) {
|
||||
return softfloat_subMagsF64( uiA, uiB, signA );
|
||||
} else {
|
||||
return softfloat_addMagsF64( uiA, uiB, signA );
|
||||
}
|
||||
#else
|
||||
magsFuncPtr =
|
||||
(signA == signB) ? softfloat_subMagsF64 : softfloat_addMagsF64;
|
||||
return (*magsFuncPtr)( uiA, uiB, signA );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
96
liba/src/external/softfloat/src/f64_to_i32_r_minMag.c
vendored
Normal file
96
liba/src/external/softfloat/src/f64_to_i32_r_minMag.c
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
int_fast32_t f64_to_i32_r_minMag( float64_t a, bool exact )
|
||||
{
|
||||
union ui64_f64 uA;
|
||||
uint_fast64_t uiA;
|
||||
int_fast16_t exp;
|
||||
uint_fast64_t sig;
|
||||
int_fast16_t shiftDist;
|
||||
bool sign;
|
||||
int_fast32_t absZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA = uA.ui;
|
||||
exp = expF64UI( uiA );
|
||||
sig = fracF64UI( uiA );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x433 - exp;
|
||||
if ( 53 <= shiftDist ) {
|
||||
if ( exact && (exp | sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sign = signF64UI( uiA );
|
||||
if ( shiftDist < 22 ) {
|
||||
if (
|
||||
sign && (exp == 0x41E) && (sig < UINT64_C( 0x0000000000200000 ))
|
||||
) {
|
||||
if ( exact && sig ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return -0x7FFFFFFF - 1;
|
||||
}
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FF) && sig ? i32_fromNaN
|
||||
: sign ? i32_fromNegOverflow : i32_fromPosOverflow;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sig |= UINT64_C( 0x0010000000000000 );
|
||||
absZ = sig>>shiftDist;
|
||||
if ( exact && ((uint_fast64_t) (uint_fast32_t) absZ<<shiftDist != sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return sign ? -absZ : absZ;
|
||||
|
||||
}
|
||||
|
||||
65
liba/src/external/softfloat/src/i32_to_f64.c
vendored
Normal file
65
liba/src/external/softfloat/src/i32_to_f64.c
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float64_t i32_to_f64( int32_t a )
|
||||
{
|
||||
uint_fast64_t uiZ;
|
||||
bool sign;
|
||||
uint_fast32_t absA;
|
||||
int_fast8_t shiftDist;
|
||||
union ui64_f64 uZ;
|
||||
|
||||
if ( ! a ) {
|
||||
uiZ = 0;
|
||||
} else {
|
||||
sign = (a < 0);
|
||||
absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
|
||||
shiftDist = softfloat_countLeadingZeros32( absA ) + 21;
|
||||
uiZ =
|
||||
packToF64UI(
|
||||
sign, 0x432 - shiftDist, (uint_fast64_t) absA<<shiftDist );
|
||||
}
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
128
liba/src/external/softfloat/src/s_addMagsF64.c
vendored
Normal file
128
liba/src/external/softfloat/src/s_addMagsF64.c
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
|
||||
float64_t
|
||||
softfloat_addMagsF64( uint_fast64_t uiA, uint_fast64_t uiB, bool signZ )
|
||||
{
|
||||
int_fast16_t expA;
|
||||
uint_fast64_t sigA;
|
||||
int_fast16_t expB;
|
||||
uint_fast64_t sigB;
|
||||
int_fast16_t expDiff;
|
||||
uint_fast64_t uiZ;
|
||||
int_fast16_t expZ;
|
||||
uint_fast64_t sigZ;
|
||||
union ui64_f64 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expA = expF64UI( uiA );
|
||||
sigA = fracF64UI( uiA );
|
||||
expB = expF64UI( uiB );
|
||||
sigB = fracF64UI( uiB );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expDiff = expA - expB;
|
||||
if ( ! expDiff ) {
|
||||
/*--------------------------------------------------------------------
|
||||
*--------------------------------------------------------------------*/
|
||||
if ( ! expA ) {
|
||||
uiZ = uiA + sigB;
|
||||
goto uiZ;
|
||||
}
|
||||
if ( expA == 0x7FF ) {
|
||||
if ( sigA | sigB ) goto propagateNaN;
|
||||
uiZ = uiA;
|
||||
goto uiZ;
|
||||
}
|
||||
expZ = expA;
|
||||
sigZ = UINT64_C( 0x0020000000000000 ) + sigA + sigB;
|
||||
sigZ <<= 9;
|
||||
} else {
|
||||
/*--------------------------------------------------------------------
|
||||
*--------------------------------------------------------------------*/
|
||||
sigA <<= 9;
|
||||
sigB <<= 9;
|
||||
if ( expDiff < 0 ) {
|
||||
if ( expB == 0x7FF ) {
|
||||
if ( sigB ) goto propagateNaN;
|
||||
uiZ = packToF64UI( signZ, 0x7FF, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
expZ = expB;
|
||||
if ( expA ) {
|
||||
sigA += UINT64_C( 0x2000000000000000 );
|
||||
} else {
|
||||
sigA <<= 1;
|
||||
}
|
||||
sigA = softfloat_shiftRightJam64( sigA, -expDiff );
|
||||
} else {
|
||||
if ( expA == 0x7FF ) {
|
||||
if ( sigA ) goto propagateNaN;
|
||||
uiZ = uiA;
|
||||
goto uiZ;
|
||||
}
|
||||
expZ = expA;
|
||||
if ( expB ) {
|
||||
sigB += UINT64_C( 0x2000000000000000 );
|
||||
} else {
|
||||
sigB <<= 1;
|
||||
}
|
||||
sigB = softfloat_shiftRightJam64( sigB, expDiff );
|
||||
}
|
||||
sigZ = UINT64_C( 0x2000000000000000 ) + sigA + sigB;
|
||||
if ( sigZ < UINT64_C( 0x4000000000000000 ) ) {
|
||||
--expZ;
|
||||
sigZ <<= 1;
|
||||
}
|
||||
}
|
||||
return softfloat_roundPackToF64( signZ, expZ, sigZ );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
propagateNaN:
|
||||
uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
66
liba/src/external/softfloat/src/s_approxRecip32_1.c
vendored
Normal file
66
liba/src/external/softfloat/src/s_approxRecip32_1.c
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
|
||||
#ifndef softfloat_approxRecip32_1
|
||||
|
||||
extern const uint16_t softfloat_approxRecip_1k0s[16];
|
||||
extern const uint16_t softfloat_approxRecip_1k1s[16];
|
||||
|
||||
uint32_t softfloat_approxRecip32_1( uint32_t a )
|
||||
{
|
||||
int index;
|
||||
uint16_t eps, r0;
|
||||
uint32_t sigma0;
|
||||
uint_fast32_t r;
|
||||
uint32_t sqrSigma0;
|
||||
|
||||
index = a>>27 & 0xF;
|
||||
eps = (uint16_t) (a>>11);
|
||||
r0 = softfloat_approxRecip_1k0s[index]
|
||||
- ((softfloat_approxRecip_1k1s[index] * (uint_fast32_t) eps)>>20);
|
||||
sigma0 = ~(uint_fast32_t) ((r0 * (uint_fast64_t) a)>>7);
|
||||
r = ((uint_fast32_t) r0<<16) + ((r0 * (uint_fast64_t) sigma0)>>24);
|
||||
sqrSigma0 = ((uint_fast64_t) sigma0 * sigma0)>>32;
|
||||
r += ((uint32_t) r * (uint_fast64_t) sqrSigma0)>>48;
|
||||
return r;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
49
liba/src/external/softfloat/src/s_approxRecip_1Ks.c
vendored
Normal file
49
liba/src/external/softfloat/src/s_approxRecip_1Ks.c
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "primitives.h"
|
||||
|
||||
const uint16_t softfloat_approxRecip_1k0s[16] = {
|
||||
0xFFC4, 0xF0BE, 0xE363, 0xD76F, 0xCCAD, 0xC2F0, 0xBA16, 0xB201,
|
||||
0xAA97, 0xA3C6, 0x9D7A, 0x97A6, 0x923C, 0x8D32, 0x887E, 0x8417
|
||||
};
|
||||
const uint16_t softfloat_approxRecip_1k1s[16] = {
|
||||
0xF0F1, 0xD62C, 0xBFA1, 0xAC77, 0x9C0A, 0x8DDB, 0x8185, 0x76BA,
|
||||
0x6D3B, 0x64D4, 0x5D5C, 0x56B1, 0x50B6, 0x4B55, 0x4679, 0x4211
|
||||
};
|
||||
|
||||
64
liba/src/external/softfloat/src/s_countLeadingZeros32.c
vendored
Normal file
64
liba/src/external/softfloat/src/s_countLeadingZeros32.c
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
|
||||
#ifndef softfloat_countLeadingZeros32
|
||||
|
||||
#define softfloat_countLeadingZeros32 softfloat_countLeadingZeros32
|
||||
#include "primitives.h"
|
||||
|
||||
uint_fast8_t softfloat_countLeadingZeros32( uint32_t a )
|
||||
{
|
||||
uint_fast8_t count;
|
||||
|
||||
count = 0;
|
||||
if ( a < 0x10000 ) {
|
||||
count = 16;
|
||||
a <<= 16;
|
||||
}
|
||||
if ( a < 0x1000000 ) {
|
||||
count += 8;
|
||||
a <<= 8;
|
||||
}
|
||||
count += softfloat_countLeadingZeros8[a>>24];
|
||||
return count;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
73
liba/src/external/softfloat/src/s_countLeadingZeros64.c
vendored
Normal file
73
liba/src/external/softfloat/src/s_countLeadingZeros64.c
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
|
||||
#ifndef softfloat_countLeadingZeros64
|
||||
|
||||
#define softfloat_countLeadingZeros64 softfloat_countLeadingZeros64
|
||||
#include "primitives.h"
|
||||
|
||||
uint_fast8_t softfloat_countLeadingZeros64( uint64_t a )
|
||||
{
|
||||
uint_fast8_t count;
|
||||
uint32_t a32;
|
||||
|
||||
count = 0;
|
||||
a32 = a>>32;
|
||||
if ( ! a32 ) {
|
||||
count = 32;
|
||||
a32 = a;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
| From here, result is current count + count leading zeros of `a32'.
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( a32 < 0x10000 ) {
|
||||
count += 16;
|
||||
a32 <<= 16;
|
||||
}
|
||||
if ( a32 < 0x1000000 ) {
|
||||
count += 8;
|
||||
a32 <<= 8;
|
||||
}
|
||||
count += softfloat_countLeadingZeros8[a32>>24];
|
||||
return count;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
59
liba/src/external/softfloat/src/s_countLeadingZeros8.c
vendored
Normal file
59
liba/src/external/softfloat/src/s_countLeadingZeros8.c
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "primitives.h"
|
||||
|
||||
const uint_least8_t softfloat_countLeadingZeros8[256] = {
|
||||
8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
68
liba/src/external/softfloat/src/s_mul64To128M.c
vendored
Normal file
68
liba/src/external/softfloat/src/s_mul64To128M.c
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "primitiveTypes.h"
|
||||
|
||||
#ifndef softfloat_mul64To128M
|
||||
|
||||
void softfloat_mul64To128M( uint64_t a, uint64_t b, uint32_t *zPtr )
|
||||
{
|
||||
uint32_t a32, a0, b32, b0;
|
||||
uint64_t z0, mid1, z64, mid;
|
||||
|
||||
a32 = a>>32;
|
||||
a0 = a;
|
||||
b32 = b>>32;
|
||||
b0 = b;
|
||||
z0 = (uint64_t) a0 * b0;
|
||||
mid1 = (uint64_t) a32 * b0;
|
||||
mid = mid1 + (uint64_t) a0 * b32;
|
||||
z64 = (uint64_t) a32 * b32;
|
||||
z64 += (uint64_t) (mid < mid1)<<32 | mid>>32;
|
||||
mid <<= 32;
|
||||
z0 += mid;
|
||||
zPtr[indexWord( 4, 1 )] = z0>>32;
|
||||
zPtr[indexWord( 4, 0 )] = z0;
|
||||
z64 += (z0 < mid);
|
||||
zPtr[indexWord( 4, 3 )] = z64>>32;
|
||||
zPtr[indexWord( 4, 2 )] = z64;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
58
liba/src/external/softfloat/src/s_normRoundPackToF64.c
vendored
Normal file
58
liba/src/external/softfloat/src/s_normRoundPackToF64.c
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
|
||||
float64_t
|
||||
softfloat_normRoundPackToF64( bool sign, int_fast16_t exp, uint_fast64_t sig )
|
||||
{
|
||||
int_fast8_t shiftDist;
|
||||
union ui64_f64 uZ;
|
||||
|
||||
shiftDist = softfloat_countLeadingZeros64( sig ) - 1;
|
||||
exp -= shiftDist;
|
||||
if ( (10 <= shiftDist) && ((unsigned int) exp < 0x7FD) ) {
|
||||
uZ.ui = packToF64UI( sign, sig ? exp : 0, sig<<(shiftDist - 10) );
|
||||
return uZ.f;
|
||||
} else {
|
||||
return softfloat_roundPackToF64( sign, exp, sig<<shiftDist );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
52
liba/src/external/softfloat/src/s_normSubnormalF64Sig.c
vendored
Normal file
52
liba/src/external/softfloat/src/s_normSubnormalF64Sig.c
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
|
||||
struct exp16_sig64 softfloat_normSubnormalF64Sig( uint_fast64_t sig )
|
||||
{
|
||||
int_fast8_t shiftDist;
|
||||
struct exp16_sig64 z;
|
||||
|
||||
shiftDist = softfloat_countLeadingZeros64( sig ) - 11;
|
||||
z.exp = 1 - shiftDist;
|
||||
z.sig = sig<<shiftDist;
|
||||
return z;
|
||||
|
||||
}
|
||||
|
||||
117
liba/src/external/softfloat/src/s_roundPackToF64.c
vendored
Normal file
117
liba/src/external/softfloat/src/s_roundPackToF64.c
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float64_t
|
||||
softfloat_roundPackToF64( bool sign, int_fast16_t exp, uint_fast64_t sig )
|
||||
{
|
||||
uint_fast8_t roundingMode;
|
||||
bool roundNearEven;
|
||||
uint_fast16_t roundIncrement, roundBits;
|
||||
bool isTiny;
|
||||
uint_fast64_t uiZ;
|
||||
union ui64_f64 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
roundingMode = softfloat_roundingMode;
|
||||
roundNearEven = (roundingMode == softfloat_round_near_even);
|
||||
roundIncrement = 0x200;
|
||||
if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
|
||||
roundIncrement =
|
||||
(roundingMode
|
||||
== (sign ? softfloat_round_min : softfloat_round_max))
|
||||
? 0x3FF
|
||||
: 0;
|
||||
}
|
||||
roundBits = sig & 0x3FF;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( 0x7FD <= (uint16_t) exp ) {
|
||||
if ( exp < 0 ) {
|
||||
/*----------------------------------------------------------------
|
||||
*----------------------------------------------------------------*/
|
||||
isTiny =
|
||||
(softfloat_detectTininess == softfloat_tininess_beforeRounding)
|
||||
|| (exp < -1)
|
||||
|| (sig + roundIncrement < UINT64_C( 0x8000000000000000 ));
|
||||
sig = softfloat_shiftRightJam64( sig, -exp );
|
||||
exp = 0;
|
||||
roundBits = sig & 0x3FF;
|
||||
if ( isTiny && roundBits ) {
|
||||
softfloat_raiseFlags( softfloat_flag_underflow );
|
||||
}
|
||||
} else if (
|
||||
(0x7FD < exp)
|
||||
|| (UINT64_C( 0x8000000000000000 ) <= sig + roundIncrement)
|
||||
) {
|
||||
/*----------------------------------------------------------------
|
||||
*----------------------------------------------------------------*/
|
||||
softfloat_raiseFlags(
|
||||
softfloat_flag_overflow | softfloat_flag_inexact );
|
||||
uiZ = packToF64UI( sign, 0x7FF, 0 ) - ! roundIncrement;
|
||||
goto uiZ;
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sig = (sig + roundIncrement)>>10;
|
||||
if ( roundBits ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
#ifdef SOFTFLOAT_ROUND_ODD
|
||||
if ( roundingMode == softfloat_round_odd ) {
|
||||
sig |= 1;
|
||||
goto packReturn;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
sig &= ~(uint_fast64_t) (! (roundBits ^ 0x200) & roundNearEven);
|
||||
if ( ! sig ) exp = 0;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
packReturn:
|
||||
uiZ = packToF64UI( sign, exp, sig );
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
51
liba/src/external/softfloat/src/s_shiftRightJam64.c
vendored
Normal file
51
liba/src/external/softfloat/src/s_shiftRightJam64.c
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
|
||||
#ifndef softfloat_shiftRightJam64
|
||||
|
||||
uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist )
|
||||
{
|
||||
|
||||
return
|
||||
(dist < 63) ? a>>dist | ((uint64_t) (a<<(-dist & 63)) != 0) : (a != 0);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
141
liba/src/external/softfloat/src/s_subMagsF64.c
vendored
Normal file
141
liba/src/external/softfloat/src/s_subMagsF64.c
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
float64_t
|
||||
softfloat_subMagsF64( uint_fast64_t uiA, uint_fast64_t uiB, bool signZ )
|
||||
{
|
||||
int_fast16_t expA;
|
||||
uint_fast64_t sigA;
|
||||
int_fast16_t expB;
|
||||
uint_fast64_t sigB;
|
||||
int_fast16_t expDiff;
|
||||
uint_fast64_t uiZ;
|
||||
int_fast64_t sigDiff;
|
||||
int_fast8_t shiftDist;
|
||||
int_fast16_t expZ;
|
||||
uint_fast64_t sigZ;
|
||||
union ui64_f64 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expA = expF64UI( uiA );
|
||||
sigA = fracF64UI( uiA );
|
||||
expB = expF64UI( uiB );
|
||||
sigB = fracF64UI( uiB );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expDiff = expA - expB;
|
||||
if ( ! expDiff ) {
|
||||
/*--------------------------------------------------------------------
|
||||
*--------------------------------------------------------------------*/
|
||||
if ( expA == 0x7FF ) {
|
||||
if ( sigA | sigB ) goto propagateNaN;
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
uiZ = defaultNaNF64UI;
|
||||
goto uiZ;
|
||||
}
|
||||
sigDiff = sigA - sigB;
|
||||
if ( ! sigDiff ) {
|
||||
uiZ =
|
||||
packToF64UI(
|
||||
(softfloat_roundingMode == softfloat_round_min), 0, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
if ( expA ) --expA;
|
||||
if ( sigDiff < 0 ) {
|
||||
signZ = ! signZ;
|
||||
sigDiff = -sigDiff;
|
||||
}
|
||||
shiftDist = softfloat_countLeadingZeros64( sigDiff ) - 11;
|
||||
expZ = expA - shiftDist;
|
||||
if ( expZ < 0 ) {
|
||||
shiftDist = expA;
|
||||
expZ = 0;
|
||||
}
|
||||
uiZ = packToF64UI( signZ, expZ, sigDiff<<shiftDist );
|
||||
goto uiZ;
|
||||
} else {
|
||||
/*--------------------------------------------------------------------
|
||||
*--------------------------------------------------------------------*/
|
||||
sigA <<= 10;
|
||||
sigB <<= 10;
|
||||
if ( expDiff < 0 ) {
|
||||
/*----------------------------------------------------------------
|
||||
*----------------------------------------------------------------*/
|
||||
signZ = ! signZ;
|
||||
if ( expB == 0x7FF ) {
|
||||
if ( sigB ) goto propagateNaN;
|
||||
uiZ = packToF64UI( signZ, 0x7FF, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
sigA += expA ? UINT64_C( 0x4000000000000000 ) : sigA;
|
||||
sigA = softfloat_shiftRightJam64( sigA, -expDiff );
|
||||
sigB |= UINT64_C( 0x4000000000000000 );
|
||||
expZ = expB;
|
||||
sigZ = sigB - sigA;
|
||||
} else {
|
||||
/*----------------------------------------------------------------
|
||||
*----------------------------------------------------------------*/
|
||||
if ( expA == 0x7FF ) {
|
||||
if ( sigA ) goto propagateNaN;
|
||||
uiZ = uiA;
|
||||
goto uiZ;
|
||||
}
|
||||
sigB += expB ? UINT64_C( 0x4000000000000000 ) : sigB;
|
||||
sigB = softfloat_shiftRightJam64( sigB, expDiff );
|
||||
sigA |= UINT64_C( 0x4000000000000000 );
|
||||
expZ = expA;
|
||||
sigZ = sigA - sigB;
|
||||
}
|
||||
return softfloat_normRoundPackToF64( signZ, expZ - 1, sigZ );
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
propagateNaN:
|
||||
uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
52
liba/src/external/softfloat/src/softfloat_state.c
vendored
Normal file
52
liba/src/external/softfloat/src/softfloat_state.c
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3c, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the University nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifndef THREAD_LOCAL
|
||||
#define THREAD_LOCAL
|
||||
#endif
|
||||
|
||||
THREAD_LOCAL uint_fast8_t softfloat_roundingMode = softfloat_round_near_even;
|
||||
THREAD_LOCAL uint_fast8_t softfloat_detectTininess = init_detectTininess;
|
||||
THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags = 0;
|
||||
|
||||
THREAD_LOCAL uint_fast8_t extF80_roundingPrecision = 80;
|
||||
|
||||
16
liba/test/double.c
Normal file
16
liba/test/double.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <quiz.h>
|
||||
#include <assert.h>
|
||||
|
||||
QUIZ_CASE(double_arithmetic) {
|
||||
assert(3.12+2.00001 - 5.12001 < 0.0000000001);
|
||||
assert(1e106+1e104 - 1.01e106 < 0.0000000001);
|
||||
assert(1e-106+1e-104 - 1.01e104 < 0.0000000001);
|
||||
assert(3.12345678901234567890/2.0000000000000001 - 1.56172839450617276136 < 0.0000000001);
|
||||
assert(1.09876e206/2.45678e207 - 0.04472358127304846180773 < 0.0000000001);
|
||||
assert(3.12345678901234567890*2.0000000000000001 - 6.24691357802469167014 < 0.0000000001);
|
||||
assert(1.09876e106*2.45678e107 - 2.6994115928e213 < 0.0000000001);
|
||||
assert(-3.12345678901234567890+2.0000000000000001 == -1.1234567890123457);
|
||||
assert(-1e36+1e34 + 9.9e35 < 0.0000000001);
|
||||
assert(3.12345678901234567890-2.0000000000000001 == 1.1234567890123457);
|
||||
assert(1e36-1e34 - 9.9e35 < 0.0000000001);
|
||||
}
|
||||
Reference in New Issue
Block a user