4 #include "sfp-machine.h"
7 #define _FP_WORK_LSB ((_FP_W_TYPE)1 << 3)
8 #define _FP_WORK_ROUND ((_FP_W_TYPE)1 << 2)
9 #define _FP_WORK_GUARD ((_FP_W_TYPE)1 << 1)
10 #define _FP_WORK_STICKY ((_FP_W_TYPE)1 << 0)
12 #ifndef FP_RND_NEAREST
13 # define FP_RND_NEAREST 0
14 # define FP_RND_ZERO 1
15 # define FP_RND_PINF 2
16 # define FP_RND_MINF 3
18 # define FP_ROUNDMODE FP_RND_NEAREST
22 #define _FP_ROUND_NEAREST(wc, X) \
24 int __frac = _FP_FRAC_LOW_##wc(X) & 15; \
26 __ret = EFLAG_INEXACT; \
27 if ((__frac & 7) != _FP_WORK_ROUND) \
28 _FP_FRAC_ADDI_##wc(X, _FP_WORK_ROUND); \
29 else if (__frac & _FP_WORK_LSB) \
30 _FP_FRAC_ADDI_##wc(X, _FP_WORK_ROUND); \
35 #define _FP_ROUND_ZERO(wc, X) \
37 if (_FP_FRAC_LOW_##wc(X) & 7) \
38 __ret = EFLAG_INEXACT; \
42 #define _FP_ROUND_PINF(wc, X) \
43 ({ int __ret = EFLAG_INEXACT; \
44 if (!X##_s && (_FP_FRAC_LOW_##wc(X) & 7)) \
45 _FP_FRAC_ADDI_##wc(X, _FP_WORK_LSB); \
50 #define _FP_ROUND_MINF(wc, X) \
51 ({ int __ret = EFLAG_INEXACT; \
52 if (X##_s && (_FP_FRAC_LOW_##wc(X) & 7)) \
53 _FP_FRAC_ADDI_##wc(X, _FP_WORK_LSB); \
58 #define _FP_ROUND(wc, X) \
60 switch (FP_ROUNDMODE) \
62 case FP_RND_NEAREST: \
63 __ret |= _FP_ROUND_NEAREST(wc,X); \
66 __ret |= _FP_ROUND_ZERO(wc,X); \
69 __ret |= _FP_ROUND_PINF(wc,X); \
72 __ret |= _FP_ROUND_MINF(wc,X); \
78 #define FP_CLS_NORMAL 0
83 #define _FP_CLS_COMBINE(x,y) (((x) << 2) | (y))
88 #include "op-common.h"
90 /* Sigh. Silly things longlong.h needs. */
91 #define UWtype _FP_W_TYPE
92 #define W_TYPE_SIZE _FP_W_TYPE_SIZE
94 typedef int SItype __attribute__((mode(SI)));
95 typedef int DItype __attribute__((mode(DI)));
96 typedef unsigned int USItype __attribute__((mode(SI)));
97 typedef unsigned int UDItype __attribute__((mode(DI)));
98 #if _FP_W_TYPE_SIZE == 32
99 typedef unsigned int UHWtype __attribute__((mode(HI)));
100 #elif _FP_W_TYPE_SIZE == 64
101 typedef USItype UHWtype;