2 * IEEE754 floating point
3 * common internal header file
6 * MIPS floating point support
7 * Copyright (C) 1994-2000 Algorithmics Ltd.
8 * http://www.algor.co.uk
10 * ########################################################################
12 * This program is free software; you can distribute it and/or modify it
13 * under the terms of the GNU General Public License (Version 2) as
14 * published by the Free Software Foundation.
16 * This program is distributed in the hope it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
25 * ########################################################################
32 #define DP_EMIN (-1022)
37 #define SP_EMIN (-126)
41 #define DP_MBIT(x) ((u64)1 << (x))
42 #define DP_HIDDEN_BIT DP_MBIT(DP_MBITS)
43 #define DP_SIGN_BIT DP_MBIT(63)
45 #define SP_MBIT(x) ((u32)1 << (x))
46 #define SP_HIDDEN_BIT SP_MBIT(SP_MBITS)
47 #define SP_SIGN_BIT SP_MBIT(31)
50 #define SPSIGN(sp) (sp.parts.sign)
51 #define SPBEXP(sp) (sp.parts.bexp)
52 #define SPMANT(sp) (sp.parts.mant)
54 #define DPSIGN(dp) (dp.parts.sign)
55 #define DPBEXP(dp) (dp.parts.bexp)
56 #define DPMANT(dp) (dp.parts.mant)
58 #define CLPAIR(x, y) ((x)*6+(y))
64 (ieee754_csr.cx |= (x), ieee754_csr.sx |= (x))
66 #define SETANDTESTCX(x) \
67 (SETCX(x), ieee754_csr.mx & (x))
70 (ieee754_csr.cx & ieee754_csr.mx)
74 unsigned xm; int xe; int xs; int xc
77 unsigned ym; int ye; int ys; int yc
79 #define EXPLODESP(v, vc, vs, ve, vm) \
84 if(ve == SP_EMAX+1+SP_EBIAS){\
86 vc = IEEE754_CLASS_INF;\
87 else if(vm & SP_MBIT(SP_MBITS-1)) \
88 vc = IEEE754_CLASS_SNAN;\
90 vc = IEEE754_CLASS_QNAN;\
91 } else if(ve == SP_EMIN-1+SP_EBIAS) {\
94 vc = IEEE754_CLASS_DNORM;\
96 vc = IEEE754_CLASS_ZERO;\
100 vc = IEEE754_CLASS_NORM;\
103 #define EXPLODEXSP EXPLODESP(x, xc, xs, xe, xm)
104 #define EXPLODEYSP EXPLODESP(y, yc, ys, ye, ym)
108 u64 xm; int xe; int xs; int xc
111 u64 ym; int ye; int ys; int yc
113 #define EXPLODEDP(v, vc, vs, ve, vm) \
118 if(ve == DP_EMAX+1+DP_EBIAS){\
120 vc = IEEE754_CLASS_INF;\
121 else if(vm & DP_MBIT(DP_MBITS-1)) \
122 vc = IEEE754_CLASS_SNAN;\
124 vc = IEEE754_CLASS_QNAN;\
125 } else if(ve == DP_EMIN-1+DP_EBIAS) {\
128 vc = IEEE754_CLASS_DNORM;\
130 vc = IEEE754_CLASS_ZERO;\
133 vm |= DP_HIDDEN_BIT;\
134 vc = IEEE754_CLASS_NORM;\
137 #define EXPLODEXDP EXPLODEDP(x, xc, xs, xe, xm)
138 #define EXPLODEYDP EXPLODEDP(y, yc, ys, ye, ym)
140 #define FLUSHDP(v, vc, vs, ve, vm) \
141 if(vc==IEEE754_CLASS_DNORM) {\
142 if(ieee754_csr.nod) {\
143 SETCX(IEEE754_INEXACT);\
144 vc = IEEE754_CLASS_ZERO;\
145 ve = DP_EMIN-1+DP_EBIAS;\
147 v = ieee754dp_zero(vs);\
151 #define FLUSHSP(v, vc, vs, ve, vm) \
152 if(vc==IEEE754_CLASS_DNORM) {\
153 if(ieee754_csr.nod) {\
154 SETCX(IEEE754_INEXACT);\
155 vc = IEEE754_CLASS_ZERO;\
156 ve = SP_EMIN-1+SP_EBIAS;\
158 v = ieee754sp_zero(vs);\
162 #define FLUSHXDP FLUSHDP(x, xc, xs, xe, xm)
163 #define FLUSHYDP FLUSHDP(y, yc, ys, ye, ym)
164 #define FLUSHXSP FLUSHSP(x, xc, xs, xe, xm)
165 #define FLUSHYSP FLUSHSP(y, yc, ys, ye, ym)