2 * IEEE754 floating point
3 * double precision internal header file
6 * MIPS floating point support
7 * Copyright (C) 1994-2000 Algorithmics Ltd.
9 * ########################################################################
11 * This program is free software; you can distribute it and/or modify it
12 * under the terms of the GNU General Public License (Version 2) as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
24 * ########################################################################
27 #include <linux/compiler.h>
29 #include "ieee754int.h"
31 #define assert(expr) ((void)0)
34 #define SP_EMIN (-126)
39 #define SP_MBIT(x) ((u32)1 << (x))
40 #define SP_HIDDEN_BIT SP_MBIT(SP_FBITS)
41 #define SP_SIGN_BIT SP_MBIT(31)
43 #define SPSIGN(sp) (sp.parts.sign)
44 #define SPBEXP(sp) (sp.parts.bexp)
45 #define SPMANT(sp) (sp.parts.mant)
47 static inline int ieee754sp_finite(union ieee754sp x)
49 return SPBEXP(x) != SP_EMAX + 1 + SP_EBIAS;
52 /* 3bit extended single precision sticky right shift */
53 #define SPXSRSXn(rs) \
55 xm = (rs > (SP_FBITS+3))?1:((xm) >> (rs)) | ((xm) << (32-(rs)) != 0))
58 (xe++, (xm = (xm >> 1) | (xm & 1)))
60 #define SPXSRSYn(rs) \
62 ym = (rs > (SP_FBITS+3))?1:((ym) >> (rs)) | ((ym) << (32-(rs)) != 0))
65 (ye++, (ym = (ym >> 1) | (ym & 1)))
67 /* convert denormal to normalized with extended exponent */
68 #define SPDNORMx(m,e) \
69 while ((m >> SP_FBITS) == 0) { m <<= 1; e--; }
70 #define SPDNORMX SPDNORMx(xm, xe)
71 #define SPDNORMY SPDNORMx(ym, ye)
73 static inline union ieee754sp buildsp(int s, int bx, unsigned m)
77 assert((s) == 0 || (s) == 1);
78 assert((bx) >= SP_EMIN - 1 + SP_EBIAS
79 && (bx) <= SP_EMAX + 1 + SP_EBIAS);
80 assert(((m) >> SP_FBITS) == 0);
89 extern int ieee754sp_isnan(union ieee754sp);
90 extern int __cold ieee754si_xcpt(int, const char *, ...);
91 extern s64 __cold ieee754di_xcpt(s64, const char *, ...);
92 extern union ieee754sp __cold ieee754sp_xcpt(union ieee754sp, const char *, ...);
93 extern union ieee754sp __cold ieee754sp_nanxcpt(union ieee754sp, const char *, ...);
94 extern union ieee754sp ieee754sp_format(int, int, unsigned);
97 #define SPNORMRET2(s, e, m, name, a0, a1) \
99 union ieee754sp V = ieee754sp_format(s, e, m); \
101 if (ieee754_tstx()) \
102 return ieee754sp_xcpt(V, name, a0, a1); \
107 #define SPNORMRET1(s, e, m, name, a0) SPNORMRET2(s, e, m, name, a0, a0)