OMAP3 SRF: Add virt clk nodes for VDD1/VDD2
[linux-ginger.git] / arch / mips / math-emu / ieee754int.h
blob1a846c5425cd5f38a7026586c1112c4d93eff6a9
1 /*
2 * IEEE754 floating point
3 * common internal header file
4 */
5 /*
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
19 * for more details.
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 * ########################################################################
29 #include "ieee754.h"
31 #define DP_EBIAS 1023
32 #define DP_EMIN (-1022)
33 #define DP_EMAX 1023
34 #define DP_MBITS 52
36 #define SP_EBIAS 127
37 #define SP_EMIN (-126)
38 #define SP_EMAX 127
39 #define SP_MBITS 23
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))
60 #define CLEARCX \
61 (ieee754_csr.cx = 0)
63 #define SETCX(x) \
64 (ieee754_csr.cx |= (x), ieee754_csr.sx |= (x))
66 #define SETANDTESTCX(x) \
67 (SETCX(x), ieee754_csr.mx & (x))
69 #define TSTX() \
70 (ieee754_csr.cx & ieee754_csr.mx)
73 #define COMPXSP \
74 unsigned xm; int xe; int xs; int xc
76 #define COMPYSP \
77 unsigned ym; int ye; int ys; int yc
79 #define EXPLODESP(v, vc, vs, ve, vm) \
81 vs = SPSIGN(v);\
82 ve = SPBEXP(v);\
83 vm = SPMANT(v);\
84 if(ve == SP_EMAX+1+SP_EBIAS){\
85 if(vm == 0)\
86 vc = IEEE754_CLASS_INF;\
87 else if(vm & SP_MBIT(SP_MBITS-1)) \
88 vc = IEEE754_CLASS_SNAN;\
89 else \
90 vc = IEEE754_CLASS_QNAN;\
91 } else if(ve == SP_EMIN-1+SP_EBIAS) {\
92 if(vm) {\
93 ve = SP_EMIN;\
94 vc = IEEE754_CLASS_DNORM;\
95 } else\
96 vc = IEEE754_CLASS_ZERO;\
97 } else {\
98 ve -= SP_EBIAS;\
99 vm |= SP_HIDDEN_BIT;\
100 vc = IEEE754_CLASS_NORM;\
103 #define EXPLODEXSP EXPLODESP(x, xc, xs, xe, xm)
104 #define EXPLODEYSP EXPLODESP(y, yc, ys, ye, ym)
107 #define COMPXDP \
108 u64 xm; int xe; int xs; int xc
110 #define COMPYDP \
111 u64 ym; int ye; int ys; int yc
113 #define EXPLODEDP(v, vc, vs, ve, vm) \
115 vm = DPMANT(v);\
116 vs = DPSIGN(v);\
117 ve = DPBEXP(v);\
118 if(ve == DP_EMAX+1+DP_EBIAS){\
119 if(vm == 0)\
120 vc = IEEE754_CLASS_INF;\
121 else if(vm & DP_MBIT(DP_MBITS-1)) \
122 vc = IEEE754_CLASS_SNAN;\
123 else \
124 vc = IEEE754_CLASS_QNAN;\
125 } else if(ve == DP_EMIN-1+DP_EBIAS) {\
126 if(vm) {\
127 ve = DP_EMIN;\
128 vc = IEEE754_CLASS_DNORM;\
129 } else\
130 vc = IEEE754_CLASS_ZERO;\
131 } else {\
132 ve -= DP_EBIAS;\
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;\
146 vm = 0;\
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;\
157 vm = 0;\
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)