Skip to content

Commit

Permalink
libgcc: Support for softfloat to emulate hw exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
stffrdhrn committed Jan 24, 2020
1 parent d3f7f3c commit 8e99e25
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion libgcc/config/or1k/sfp-machine.h
Expand Up @@ -41,12 +41,51 @@
R##_c = FP_CLS_NAN; \
} while (0)

/* Handle getting and setting rounding mode for soft fp operations. */

#define FP_RND_NEAREST (0x0 << 1)
#define FP_RND_ZERO (0x1 << 1)
#define FP_RND_PINF (0x2 << 1)
#define FP_RND_MINF (0x3 << 1)
#define FP_RND_MASK (0x3 << 1)

#define FP_EX_OVERFLOW 1 << 3
#define FP_EX_UNDERFLOW 1 << 4
#define FP_EX_INEXACT 1 << 8
#define FP_EX_INVALID 1 << 9
#define FP_EX_DIVZERO 1 << 11
#define FP_EX_ALL \
(FP_EX_INVALID | FP_EX_DIVZERO | FP_EX_OVERFLOW | FP_EX_UNDERFLOW \
| FP_EX_INEXACT)

#define _FP_DECL_EX \
unsigned int _fpcsr __attribute__ ((unused)) = FP_RND_NEAREST

#define FP_ROUNDMODE (_fpcsr & FP_RND_MASK)

#ifdef __or1k_hard_float__
#define FP_INIT_ROUNDMODE \
do { \
__asm__ volatile ("l.mfspr %0,r0,20" : "=r" (_fpcsr)); \
} while (0)

#define FP_HANDLE_EXCEPTIONS \
do { \
if (__builtin_expect (_fex, 0)) \
{ \
_fpcsr &= ~FP_EX_ALL; \
_fpcsr |= _fex; \
__asm__ volatile ("l.mtspr r0,%0,20" : : "r" (_fpcsr)); \
} \
} while (0)
#endif

#define __LITTLE_ENDIAN 1234
#define __BIG_ENDIAN 4321

#define __BYTE_ORDER __BIG_ENDIAN

#define _FP_TININESS_AFTER_ROUNDING 0
#define _FP_TININESS_AFTER_ROUNDING 1

/* Define ALIASNAME as a strong alias for NAME. */
# define strong_alias(name, aliasname) _strong_alias(name, aliasname)
Expand Down

0 comments on commit 8e99e25

Please sign in to comment.