2 * IEEE754 floating point
3 * common internal header file
6 * MIPS floating point support
7 * Copyright (C) 1994-2000 Algorithmics Ltd.
9 * This program is free software; you can distribute it and/or modify it
10 * under the terms of the GNU General Public License (Version 2) as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef __IEEE754INT_H
23 #define __IEEE754INT_H
27 #define CLPAIR(x, y) ((x)*6+(y))
29 static inline void ieee754_clearcx(void)
34 static inline void ieee754_setcx(const unsigned int flags)
36 ieee754_csr.cx |= flags;
37 ieee754_csr.sx |= flags;
40 static inline int ieee754_setandtestcx(const unsigned int x)
44 return ieee754_csr.mx & x;
48 unsigned xm; int xe; int xs __maybe_unused; int xc
51 unsigned ym; int ye; int ys; int yc
53 #define EXPLODESP(v, vc, vs, ve, vm) \
58 if (ve == SP_EMAX+1+SP_EBIAS) { \
60 vc = IEEE754_CLASS_INF; \
61 else if (vm & SP_MBIT(SP_FBITS-1)) \
62 vc = IEEE754_CLASS_SNAN; \
64 vc = IEEE754_CLASS_QNAN; \
65 } else if (ve == SP_EMIN-1+SP_EBIAS) { \
68 vc = IEEE754_CLASS_DNORM; \
70 vc = IEEE754_CLASS_ZERO; \
73 vm |= SP_HIDDEN_BIT; \
74 vc = IEEE754_CLASS_NORM; \
77 #define EXPLODEXSP EXPLODESP(x, xc, xs, xe, xm)
78 #define EXPLODEYSP EXPLODESP(y, yc, ys, ye, ym)
82 u64 xm; int xe; int xs __maybe_unused; int xc
85 u64 ym; int ye; int ys; int yc
87 #define EXPLODEDP(v, vc, vs, ve, vm) \
92 if (ve == DP_EMAX+1+DP_EBIAS) { \
94 vc = IEEE754_CLASS_INF; \
95 else if (vm & DP_MBIT(DP_FBITS-1)) \
96 vc = IEEE754_CLASS_SNAN; \
98 vc = IEEE754_CLASS_QNAN; \
99 } else if (ve == DP_EMIN-1+DP_EBIAS) { \
102 vc = IEEE754_CLASS_DNORM; \
104 vc = IEEE754_CLASS_ZERO; \
107 vm |= DP_HIDDEN_BIT; \
108 vc = IEEE754_CLASS_NORM; \
111 #define EXPLODEXDP EXPLODEDP(x, xc, xs, xe, xm)
112 #define EXPLODEYDP EXPLODEDP(y, yc, ys, ye, ym)
114 #define FLUSHDP(v, vc, vs, ve, vm) \
115 if (vc==IEEE754_CLASS_DNORM) { \
116 if (ieee754_csr.nod) { \
117 ieee754_setcx(IEEE754_INEXACT); \
118 vc = IEEE754_CLASS_ZERO; \
119 ve = DP_EMIN-1+DP_EBIAS; \
121 v = ieee754dp_zero(vs); \
125 #define FLUSHSP(v, vc, vs, ve, vm) \
126 if (vc==IEEE754_CLASS_DNORM) { \
127 if (ieee754_csr.nod) { \
128 ieee754_setcx(IEEE754_INEXACT); \
129 vc = IEEE754_CLASS_ZERO; \
130 ve = SP_EMIN-1+SP_EBIAS; \
132 v = ieee754sp_zero(vs); \
136 #define FLUSHXDP FLUSHDP(x, xc, xs, xe, xm)
137 #define FLUSHYDP FLUSHDP(y, yc, ys, ye, ym)
138 #define FLUSHXSP FLUSHSP(x, xc, xs, xe, xm)
139 #define FLUSHYSP FLUSHSP(y, yc, ys, ye, ym)
141 #endif /* __IEEE754INT_H */