| 1 |
/*============================================================================ |
| 2 |
|
| 3 |
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic |
| 4 |
Package, Release 3e, by John R. Hauser. |
| 5 |
|
| 6 |
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the |
| 7 |
University of California. All rights reserved. |
| 8 |
|
| 9 |
Redistribution and use in source and binary forms, with or without |
| 10 |
modification, are permitted provided that the following conditions are met: |
| 11 |
|
| 12 |
1. Redistributions of source code must retain the above copyright notice, |
| 13 |
this list of conditions, and the following disclaimer. |
| 14 |
|
| 15 |
2. Redistributions in binary form must reproduce the above copyright notice, |
| 16 |
this list of conditions, and the following disclaimer in the documentation |
| 17 |
and/or other materials provided with the distribution. |
| 18 |
|
| 19 |
3. Neither the name of the University nor the names of its contributors may |
| 20 |
be used to endorse or promote products derived from this software without |
| 21 |
specific prior written permission. |
| 22 |
|
| 23 |
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY |
| 24 |
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 25 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE |
| 26 |
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY |
| 27 |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 28 |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 29 |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 30 |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 31 |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 32 |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 |
|
| 34 |
=============================================================================*/ |
| 35 |
|
| 36 |
#ifndef internals_h |
| 37 |
#define internals_h 1 |
| 38 |
|
| 39 |
// #include <stdbool.h> |
| 40 |
// #include <stdint.h> |
| 41 |
#include "softfloat/primitives.h" |
| 42 |
#include "softfloat/softfloat_types.h" |
| 43 |
|
| 44 |
union ui32_f32 { uint32_t ui; float32_t f; }; |
| 45 |
union ui64_f64 { uint64_t ui; float64_t f; }; |
| 46 |
|
| 47 |
enum { |
| 48 |
softfloat_mulAdd_subC = 1, |
| 49 |
softfloat_mulAdd_subProd = 2 |
| 50 |
}; |
| 51 |
|
| 52 |
/*----------------------------------------------------------------------------*/ |
| 53 |
#ifdef SOFTFLOAT_FAST_INT64 |
| 54 |
uint_fast64_t |
| 55 |
softfloat_roundToUI64( |
| 56 |
bool, uint_fast64_t, uint_fast64_t, uint_fast8_t, bool ); |
| 57 |
#else |
| 58 |
uint_fast64_t softfloat_roundMToUI64( bool, uint32_t *, uint_fast8_t, bool ); |
| 59 |
#endif |
| 60 |
|
| 61 |
#ifdef SOFTFLOAT_FAST_INT64 |
| 62 |
int_fast64_t |
| 63 |
softfloat_roundToI64( |
| 64 |
bool, uint_fast64_t, uint_fast64_t, uint_fast8_t, bool ); |
| 65 |
#else |
| 66 |
int_fast64_t softfloat_roundMToI64( bool, uint32_t *, uint_fast8_t, bool ); |
| 67 |
#endif |
| 68 |
|
| 69 |
/*---------------------------------------------------------------------------- |
| 70 |
*----------------------------------------------------------------------------*/ |
| 71 |
#define signF32UI( a ) ((bool) ((uint32_t) (a)>>31)) |
| 72 |
#define expF32UI( a ) ((int_fast16_t) ((a)>>23) & 0xFF) |
| 73 |
#define fracF32UI( a ) ((a) & 0x007FFFFF) |
| 74 |
#define packToF32UI( sign, exp, sig ) (((uint32_t) (sign)<<31) + ((uint32_t) (exp)<<23) + (sig)) |
| 75 |
|
| 76 |
#define isNaNF32UI( a ) (((~(a) & 0x7F800000) == 0) && ((a) & 0x007FFFFF)) |
| 77 |
|
| 78 |
struct exp16_sig32 { int_fast16_t exp; uint_fast32_t sig; }; |
| 79 |
struct exp16_sig32 softfloat_normSubnormalF32Sig( uint_fast32_t ); |
| 80 |
|
| 81 |
float32_t softfloat_roundPackToF32( bool, int_fast16_t, uint_fast32_t ); |
| 82 |
float32_t softfloat_normRoundPackToF32( bool, int_fast16_t, uint_fast32_t ); |
| 83 |
|
| 84 |
/*----------------------------------------------------------------------------*/ |
| 85 |
/*----------------------------------------------------------------------------*/ |
| 86 |
#define signF64UI( a ) ((bool) ((uint64_t) (a)>>63)) |
| 87 |
#define expF64UI( a ) ((int_fast16_t) ((a)>>52) & 0x7FF) |
| 88 |
#define fracF64UI( a ) ((a) & UINT64_C( 0x000FFFFFFFFFFFFF )) |
| 89 |
#define packToF64UI( sign, exp, sig ) ((uint64_t) (((uint_fast64_t) (sign)<<63) + ((uint_fast64_t) (exp)<<52) + (sig))) |
| 90 |
|
| 91 |
#define isNaNF64UI( a ) (((~(a) & UINT64_C( 0x7FF0000000000000 )) == 0) && ((a) & UINT64_C( 0x000FFFFFFFFFFFFF ))) |
| 92 |
|
| 93 |
struct exp16_sig64 { int_fast16_t exp; uint_fast64_t sig; }; |
| 94 |
struct exp16_sig64 softfloat_normSubnormalF64Sig( uint_fast64_t ); |
| 95 |
|
| 96 |
float64_t softfloat_roundPackToF64( bool, int_fast16_t, uint_fast64_t ); |
| 97 |
float64_t softfloat_normRoundPackToF64( bool, int_fast16_t, uint_fast64_t ); |
| 98 |
|
| 99 |
float64_t softfloat_addMagsF64( uint_fast64_t, uint_fast64_t, bool ); |
| 100 |
float64_t softfloat_subMagsF64( uint_fast64_t, uint_fast64_t, bool ); |
| 101 |
float64_t softfloat_mulAddF64( uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast8_t ); |
| 102 |
|
| 103 |
/*---------------------------------------------------------------------------- */ |
| 104 |
|
| 105 |
#endif |