1 // SPDX-License-Identifier: GPL-2.0-only
5 * MIPS floating point support
7 * Copyright (C) 1994-2000 Algorithmics Ltd.
10 * Modified to build and operate in Linux kernel environment.
12 * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
13 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
16 #include <linux/types.h>
17 #include <linux/printk.h>
19 #include "ieee754sp.h"
20 #include "ieee754dp.h"
22 union ieee754dp ieee754dp_dump(char *m, union ieee754dp x)
27 printk("<%08x,%08x>\n", (unsigned) (x.bits >> 32),
30 switch (ieee754dp_class(x)) {
31 case IEEE754_CLASS_QNAN:
32 case IEEE754_CLASS_SNAN:
33 printk("Nan %c", DPSIGN(x) ? '-' : '+');
34 for (i = DP_FBITS - 1; i >= 0; i--)
35 printk("%c", DPMANT(x) & DP_MBIT(i) ? '1' : '0');
37 case IEEE754_CLASS_INF:
38 printk("%cInfinity", DPSIGN(x) ? '-' : '+');
40 case IEEE754_CLASS_ZERO:
41 printk("%cZero", DPSIGN(x) ? '-' : '+');
43 case IEEE754_CLASS_DNORM:
44 printk("%c0.", DPSIGN(x) ? '-' : '+');
45 for (i = DP_FBITS - 1; i >= 0; i--)
46 printk("%c", DPMANT(x) & DP_MBIT(i) ? '1' : '0');
47 printk("e%d", DPBEXP(x) - DP_EBIAS);
49 case IEEE754_CLASS_NORM:
50 printk("%c1.", DPSIGN(x) ? '-' : '+');
51 for (i = DP_FBITS - 1; i >= 0; i--)
52 printk("%c", DPMANT(x) & DP_MBIT(i) ? '1' : '0');
53 printk("e%d", DPBEXP(x) - DP_EBIAS);
56 printk("Illegal/Unknown IEEE754 value class");
62 union ieee754sp ieee754sp_dump(char *m, union ieee754sp x)
67 printk("<%08x>\n", (unsigned) x.bits);
69 switch (ieee754sp_class(x)) {
70 case IEEE754_CLASS_QNAN:
71 case IEEE754_CLASS_SNAN:
72 printk("Nan %c", SPSIGN(x) ? '-' : '+');
73 for (i = SP_FBITS - 1; i >= 0; i--)
74 printk("%c", SPMANT(x) & SP_MBIT(i) ? '1' : '0');
76 case IEEE754_CLASS_INF:
77 printk("%cInfinity", SPSIGN(x) ? '-' : '+');
79 case IEEE754_CLASS_ZERO:
80 printk("%cZero", SPSIGN(x) ? '-' : '+');
82 case IEEE754_CLASS_DNORM:
83 printk("%c0.", SPSIGN(x) ? '-' : '+');
84 for (i = SP_FBITS - 1; i >= 0; i--)
85 printk("%c", SPMANT(x) & SP_MBIT(i) ? '1' : '0');
86 printk("e%d", SPBEXP(x) - SP_EBIAS);
88 case IEEE754_CLASS_NORM:
89 printk("%c1.", SPSIGN(x) ? '-' : '+');
90 for (i = SP_FBITS - 1; i >= 0; i--)
91 printk("%c", SPMANT(x) & SP_MBIT(i) ? '1' : '0');
92 printk("e%d", SPBEXP(x) - SP_EBIAS);
95 printk("Illegal/Unknown IEEE754 value class");