4 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
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 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Modified to build and operate in Linux kernel environment.
25 * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
26 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
29 #include <linux/kernel.h>
33 #define DP_EMIN (-1022)
38 #define SP_EMIN (-126)
42 #define DP_MBIT(x) ((u64)1 << (x))
43 #define DP_HIDDEN_BIT DP_MBIT(DP_FBITS)
44 #define DP_SIGN_BIT DP_MBIT(63)
47 #define SP_MBIT(x) ((u32)1 << (x))
48 #define SP_HIDDEN_BIT SP_MBIT(SP_FBITS)
49 #define SP_SIGN_BIT SP_MBIT(31)
52 #define SPSIGN(sp) (sp.parts.sign)
53 #define SPBEXP(sp) (sp.parts.bexp)
54 #define SPMANT(sp) (sp.parts.mant)
56 #define DPSIGN(dp) (dp.parts.sign)
57 #define DPBEXP(dp) (dp.parts.bexp)
58 #define DPMANT(dp) (dp.parts.mant)
60 ieee754dp
ieee754dp_dump(char *m
, ieee754dp x
)
65 printk("<%08x,%08x>\n", (unsigned) (x
.bits
>> 32),
68 switch (ieee754dp_class(x
)) {
69 case IEEE754_CLASS_QNAN
:
70 case IEEE754_CLASS_SNAN
:
71 printk("Nan %c", DPSIGN(x
) ? '-' : '+');
72 for (i
= DP_FBITS
- 1; i
>= 0; i
--)
73 printk("%c", DPMANT(x
) & DP_MBIT(i
) ? '1' : '0');
75 case IEEE754_CLASS_INF
:
76 printk("%cInfinity", DPSIGN(x
) ? '-' : '+');
78 case IEEE754_CLASS_ZERO
:
79 printk("%cZero", DPSIGN(x
) ? '-' : '+');
81 case IEEE754_CLASS_DNORM
:
82 printk("%c0.", DPSIGN(x
) ? '-' : '+');
83 for (i
= DP_FBITS
- 1; i
>= 0; i
--)
84 printk("%c", DPMANT(x
) & DP_MBIT(i
) ? '1' : '0');
85 printk("e%d", DPBEXP(x
) - DP_EBIAS
);
87 case IEEE754_CLASS_NORM
:
88 printk("%c1.", DPSIGN(x
) ? '-' : '+');
89 for (i
= DP_FBITS
- 1; i
>= 0; i
--)
90 printk("%c", DPMANT(x
) & DP_MBIT(i
) ? '1' : '0');
91 printk("e%d", DPBEXP(x
) - DP_EBIAS
);
94 printk("Illegal/Unknown IEEE754 value class");
100 ieee754sp
ieee754sp_dump(char *m
, ieee754sp x
)
105 printk("<%08x>\n", (unsigned) x
.bits
);
107 switch (ieee754sp_class(x
)) {
108 case IEEE754_CLASS_QNAN
:
109 case IEEE754_CLASS_SNAN
:
110 printk("Nan %c", SPSIGN(x
) ? '-' : '+');
111 for (i
= SP_FBITS
- 1; i
>= 0; i
--)
112 printk("%c", SPMANT(x
) & SP_MBIT(i
) ? '1' : '0');
114 case IEEE754_CLASS_INF
:
115 printk("%cInfinity", SPSIGN(x
) ? '-' : '+');
117 case IEEE754_CLASS_ZERO
:
118 printk("%cZero", SPSIGN(x
) ? '-' : '+');
120 case IEEE754_CLASS_DNORM
:
121 printk("%c0.", SPSIGN(x
) ? '-' : '+');
122 for (i
= SP_FBITS
- 1; i
>= 0; i
--)
123 printk("%c", SPMANT(x
) & SP_MBIT(i
) ? '1' : '0');
124 printk("e%d", SPBEXP(x
) - SP_EBIAS
);
126 case IEEE754_CLASS_NORM
:
127 printk("%c1.", SPSIGN(x
) ? '-' : '+');
128 for (i
= SP_FBITS
- 1; i
>= 0; i
--)
129 printk("%c", SPMANT(x
) & SP_MBIT(i
) ? '1' : '0');
130 printk("e%d", SPBEXP(x
) - SP_EBIAS
);
133 printk("Illegal/Unknown IEEE754 value class");