Skip to content

Commit 4bb97ee

Browse files
Omar Almatovrbuchner-aril
authored andcommitted
Extract expF8UI and fracF8UI based on fp8Mode
1 parent 9c6df63 commit 4bb97ee

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

softfloat/internals.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,17 @@ int_fast64_t
8383
int_fast64_t softfloat_roundMToI64( bool, uint32_t *, uint_fast8_t, bool );
8484
#endif
8585

86+
/*----------------------------------------------------------------------------
87+
*---------------------------------------------------------------------------*/
88+
#define f8ExpWidth softfloat_fp8ExpWidths[softfloat_fp8Mode]
89+
8690
/*----------------------------------------------------------------------------
8791
*----------------------------------------------------------------------------*/
8892
#define isNaNF8UI( a ) ((bool) (((uint8_t) a) == defaultNaNF8UI))
8993
#define isInfF8UI( a ) ((bool) ((((uint8_t) a) & 0x7F) == 0x7F))
9094
#define signF8UI( a ) ((bool) ((uint16_t) (a)>>7))
91-
#define expF8UI( a ) ((int_fast8_t) ((a)>>4) & 0x7)
92-
#define fracF8UI( a ) ((a) & 0xF)
95+
#define expF8UI( a ) ((int_fast8_t) ((a)>>(7-f8ExpWidth)) & ((0x1<<f8ExpWidth)-1))
96+
#define fracF8UI( a ) ((a) & ((0x1<<(f8ExpWidth+1))-1))
9397
#define defaultInfF8UI 0x7F
9498
#define signInfF8UI( sign ) (((uint8_t) (sign)<<7) | defaultInfF8UI)
9599
#define packToF8UI( sign, exp, sig ) (((uint8_t) (sign)<<7) + ((uint8_t) (exp)<<4) + (sig))

softfloat/softfloat.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ enum {
7979
softfloat_fp8_8p3 = 2
8080
};
8181

82+
extern THREAD_LOCAL uint_fast8_t softfloat_fp8ExpWidths[3];
83+
8284
/*----------------------------------------------------------------------------
8385
| Software floating-point rounding mode. (Mode "odd" is supported only if
8486
| SoftFloat is compiled with macro 'SOFTFLOAT_ROUND_ODD' defined.)

softfloat/softfloat_state.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4545
#endif
4646

4747
THREAD_LOCAL uint_fast8_t softfloat_fp8Mode = softfloat_fp8_8p5;
48+
THREAD_LOCAL uint_fast8_t softfloat_fp8ExpWidths[3] = {3, 4, 5};
4849
THREAD_LOCAL uint_fast8_t softfloat_roundingMode = softfloat_round_near_even;
4950
THREAD_LOCAL uint_fast8_t softfloat_detectTininess = init_detectTininess;
5051
THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags = 0;

0 commit comments

Comments
 (0)