diff options
Diffstat (limited to 'source/RISCV')
-rw-r--r-- | source/RISCV/s_bf16UIToCommonNaN.c | 5 | ||||
-rw-r--r-- | source/RISCV/s_commonNaNToBF16UI.c | 5 | ||||
-rw-r--r-- | source/RISCV/specialize.h | 26 |
3 files changed, 36 insertions, 0 deletions
diff --git a/source/RISCV/s_bf16UIToCommonNaN.c b/source/RISCV/s_bf16UIToCommonNaN.c new file mode 100644 index 0000000..861b269 --- /dev/null +++ b/source/RISCV/s_bf16UIToCommonNaN.c @@ -0,0 +1,5 @@ + +/*---------------------------------------------------------------------------- +| This file intentionally contains no code. +*----------------------------------------------------------------------------*/ + diff --git a/source/RISCV/s_commonNaNToBF16UI.c b/source/RISCV/s_commonNaNToBF16UI.c new file mode 100644 index 0000000..861b269 --- /dev/null +++ b/source/RISCV/s_commonNaNToBF16UI.c @@ -0,0 +1,5 @@ + +/*---------------------------------------------------------------------------- +| This file intentionally contains no code. +*----------------------------------------------------------------------------*/ + diff --git a/source/RISCV/specialize.h b/source/RISCV/specialize.h index c638264..cb95900 100644 --- a/source/RISCV/specialize.h +++ b/source/RISCV/specialize.h @@ -88,6 +88,13 @@ struct commonNaN { char _unused; }; #define softfloat_isSigNaNF16UI( uiA ) ((((uiA) & 0x7E00) == 0x7C00) && ((uiA) & 0x01FF)) /*---------------------------------------------------------------------------- +| Returns true when 16-bit unsigned integer 'uiA' has the bit pattern of a +| 16-bit brain floating-point (BF16) signaling NaN. +| Note: This macro evaluates its argument more than once. +*----------------------------------------------------------------------------*/ +#define softfloat_isSigNaNBF16UI( uiA ) ((((uiA) & 0x7FC0) == 0x7F80) && ((uiA) & 0x003F)) + +/*---------------------------------------------------------------------------- | 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 @@ -96,6 +103,14 @@ struct commonNaN { char _unused; }; #define softfloat_f16UIToCommonNaN( uiA, zPtr ) if ( ! ((uiA) & 0x0200) ) softfloat_raiseFlags( softfloat_flag_invalid ) /*---------------------------------------------------------------------------- +| Assuming 'uiA' has the bit pattern of a 16-bit BF16 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. +*----------------------------------------------------------------------------*/ +#define softfloat_bf16UIToCommonNaN( uiA, zPtr ) if ( ! ((uiA) & 0x0040) ) softfloat_raiseFlags( softfloat_flag_invalid ) + +/*---------------------------------------------------------------------------- | 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. *----------------------------------------------------------------------------*/ @@ -111,6 +126,17 @@ uint_fast16_t softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB ); /*---------------------------------------------------------------------------- +| The bit pattern for a default generated 16-bit BF16 floating-point NaN. +*----------------------------------------------------------------------------*/ +#define defaultNaNBF16UI 0x7FC0 + +/*---------------------------------------------------------------------------- +| 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. +*----------------------------------------------------------------------------*/ +#define softfloat_commonNaNToBF16UI( aPtr ) ((uint_fast16_t) defaultNaNBF16UI) + +/*---------------------------------------------------------------------------- | The bit pattern for a default generated 32-bit floating-point NaN. *----------------------------------------------------------------------------*/ #define defaultNaNF32UI 0x7FC00000 |