Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Some debug functions
0004  *
0005  * MIPS floating point support
0006  *
0007  * Copyright (C) 1994-2000 Algorithmics Ltd.
0008  *
0009  *  Nov 7, 2000
0010  *  Modified to build and operate in Linux kernel environment.
0011  *
0012  *  Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
0013  *  Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
0014  */
0015 
0016 #include <linux/types.h>
0017 #include <linux/printk.h>
0018 #include "ieee754.h"
0019 #include "ieee754sp.h"
0020 #include "ieee754dp.h"
0021 
0022 union ieee754dp ieee754dp_dump(char *m, union ieee754dp x)
0023 {
0024     int i;
0025 
0026     printk("%s", m);
0027     printk("<%08x,%08x>\n", (unsigned) (x.bits >> 32),
0028            (unsigned) x.bits);
0029     printk("\t=");
0030     switch (ieee754dp_class(x)) {
0031     case IEEE754_CLASS_QNAN:
0032     case IEEE754_CLASS_SNAN:
0033         printk("Nan %c", DPSIGN(x) ? '-' : '+');
0034         for (i = DP_FBITS - 1; i >= 0; i--)
0035             printk("%c", DPMANT(x) & DP_MBIT(i) ? '1' : '0');
0036         break;
0037     case IEEE754_CLASS_INF:
0038         printk("%cInfinity", DPSIGN(x) ? '-' : '+');
0039         break;
0040     case IEEE754_CLASS_ZERO:
0041         printk("%cZero", DPSIGN(x) ? '-' : '+');
0042         break;
0043     case IEEE754_CLASS_DNORM:
0044         printk("%c0.", DPSIGN(x) ? '-' : '+');
0045         for (i = DP_FBITS - 1; i >= 0; i--)
0046             printk("%c", DPMANT(x) & DP_MBIT(i) ? '1' : '0');
0047         printk("e%d", DPBEXP(x) - DP_EBIAS);
0048         break;
0049     case IEEE754_CLASS_NORM:
0050         printk("%c1.", DPSIGN(x) ? '-' : '+');
0051         for (i = DP_FBITS - 1; i >= 0; i--)
0052             printk("%c", DPMANT(x) & DP_MBIT(i) ? '1' : '0');
0053         printk("e%d", DPBEXP(x) - DP_EBIAS);
0054         break;
0055     default:
0056         printk("Illegal/Unknown IEEE754 value class");
0057     }
0058     printk("\n");
0059     return x;
0060 }
0061 
0062 union ieee754sp ieee754sp_dump(char *m, union ieee754sp x)
0063 {
0064     int i;
0065 
0066     printk("%s=", m);
0067     printk("<%08x>\n", (unsigned) x.bits);
0068     printk("\t=");
0069     switch (ieee754sp_class(x)) {
0070     case IEEE754_CLASS_QNAN:
0071     case IEEE754_CLASS_SNAN:
0072         printk("Nan %c", SPSIGN(x) ? '-' : '+');
0073         for (i = SP_FBITS - 1; i >= 0; i--)
0074             printk("%c", SPMANT(x) & SP_MBIT(i) ? '1' : '0');
0075         break;
0076     case IEEE754_CLASS_INF:
0077         printk("%cInfinity", SPSIGN(x) ? '-' : '+');
0078         break;
0079     case IEEE754_CLASS_ZERO:
0080         printk("%cZero", SPSIGN(x) ? '-' : '+');
0081         break;
0082     case IEEE754_CLASS_DNORM:
0083         printk("%c0.", SPSIGN(x) ? '-' : '+');
0084         for (i = SP_FBITS - 1; i >= 0; i--)
0085             printk("%c", SPMANT(x) & SP_MBIT(i) ? '1' : '0');
0086         printk("e%d", SPBEXP(x) - SP_EBIAS);
0087         break;
0088     case IEEE754_CLASS_NORM:
0089         printk("%c1.", SPSIGN(x) ? '-' : '+');
0090         for (i = SP_FBITS - 1; i >= 0; i--)
0091             printk("%c", SPMANT(x) & SP_MBIT(i) ? '1' : '0');
0092         printk("e%d", SPBEXP(x) - SP_EBIAS);
0093         break;
0094     default:
0095         printk("Illegal/Unknown IEEE754 value class");
0096     }
0097     printk("\n");
0098     return x;
0099 }