162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Some debug functions 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * MIPS floating point support 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Copyright (C) 1994-2000 Algorithmics Ltd. 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * Nov 7, 2000 1062306a36Sopenharmony_ci * Modified to build and operate in Linux kernel environment. 1162306a36Sopenharmony_ci * 1262306a36Sopenharmony_ci * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com 1362306a36Sopenharmony_ci * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved. 1462306a36Sopenharmony_ci */ 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci#include <linux/types.h> 1762306a36Sopenharmony_ci#include <linux/printk.h> 1862306a36Sopenharmony_ci#include "ieee754.h" 1962306a36Sopenharmony_ci#include "ieee754sp.h" 2062306a36Sopenharmony_ci#include "ieee754dp.h" 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ciunion ieee754dp ieee754dp_dump(char *m, union ieee754dp x) 2362306a36Sopenharmony_ci{ 2462306a36Sopenharmony_ci int i; 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci printk("%s", m); 2762306a36Sopenharmony_ci printk("<%08x,%08x>\n", (unsigned) (x.bits >> 32), 2862306a36Sopenharmony_ci (unsigned) x.bits); 2962306a36Sopenharmony_ci printk("\t="); 3062306a36Sopenharmony_ci switch (ieee754dp_class(x)) { 3162306a36Sopenharmony_ci case IEEE754_CLASS_QNAN: 3262306a36Sopenharmony_ci case IEEE754_CLASS_SNAN: 3362306a36Sopenharmony_ci printk("Nan %c", DPSIGN(x) ? '-' : '+'); 3462306a36Sopenharmony_ci for (i = DP_FBITS - 1; i >= 0; i--) 3562306a36Sopenharmony_ci printk("%c", DPMANT(x) & DP_MBIT(i) ? '1' : '0'); 3662306a36Sopenharmony_ci break; 3762306a36Sopenharmony_ci case IEEE754_CLASS_INF: 3862306a36Sopenharmony_ci printk("%cInfinity", DPSIGN(x) ? '-' : '+'); 3962306a36Sopenharmony_ci break; 4062306a36Sopenharmony_ci case IEEE754_CLASS_ZERO: 4162306a36Sopenharmony_ci printk("%cZero", DPSIGN(x) ? '-' : '+'); 4262306a36Sopenharmony_ci break; 4362306a36Sopenharmony_ci case IEEE754_CLASS_DNORM: 4462306a36Sopenharmony_ci printk("%c0.", DPSIGN(x) ? '-' : '+'); 4562306a36Sopenharmony_ci for (i = DP_FBITS - 1; i >= 0; i--) 4662306a36Sopenharmony_ci printk("%c", DPMANT(x) & DP_MBIT(i) ? '1' : '0'); 4762306a36Sopenharmony_ci printk("e%d", DPBEXP(x) - DP_EBIAS); 4862306a36Sopenharmony_ci break; 4962306a36Sopenharmony_ci case IEEE754_CLASS_NORM: 5062306a36Sopenharmony_ci printk("%c1.", DPSIGN(x) ? '-' : '+'); 5162306a36Sopenharmony_ci for (i = DP_FBITS - 1; i >= 0; i--) 5262306a36Sopenharmony_ci printk("%c", DPMANT(x) & DP_MBIT(i) ? '1' : '0'); 5362306a36Sopenharmony_ci printk("e%d", DPBEXP(x) - DP_EBIAS); 5462306a36Sopenharmony_ci break; 5562306a36Sopenharmony_ci default: 5662306a36Sopenharmony_ci printk("Illegal/Unknown IEEE754 value class"); 5762306a36Sopenharmony_ci } 5862306a36Sopenharmony_ci printk("\n"); 5962306a36Sopenharmony_ci return x; 6062306a36Sopenharmony_ci} 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ciunion ieee754sp ieee754sp_dump(char *m, union ieee754sp x) 6362306a36Sopenharmony_ci{ 6462306a36Sopenharmony_ci int i; 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci printk("%s=", m); 6762306a36Sopenharmony_ci printk("<%08x>\n", (unsigned) x.bits); 6862306a36Sopenharmony_ci printk("\t="); 6962306a36Sopenharmony_ci switch (ieee754sp_class(x)) { 7062306a36Sopenharmony_ci case IEEE754_CLASS_QNAN: 7162306a36Sopenharmony_ci case IEEE754_CLASS_SNAN: 7262306a36Sopenharmony_ci printk("Nan %c", SPSIGN(x) ? '-' : '+'); 7362306a36Sopenharmony_ci for (i = SP_FBITS - 1; i >= 0; i--) 7462306a36Sopenharmony_ci printk("%c", SPMANT(x) & SP_MBIT(i) ? '1' : '0'); 7562306a36Sopenharmony_ci break; 7662306a36Sopenharmony_ci case IEEE754_CLASS_INF: 7762306a36Sopenharmony_ci printk("%cInfinity", SPSIGN(x) ? '-' : '+'); 7862306a36Sopenharmony_ci break; 7962306a36Sopenharmony_ci case IEEE754_CLASS_ZERO: 8062306a36Sopenharmony_ci printk("%cZero", SPSIGN(x) ? '-' : '+'); 8162306a36Sopenharmony_ci break; 8262306a36Sopenharmony_ci case IEEE754_CLASS_DNORM: 8362306a36Sopenharmony_ci printk("%c0.", SPSIGN(x) ? '-' : '+'); 8462306a36Sopenharmony_ci for (i = SP_FBITS - 1; i >= 0; i--) 8562306a36Sopenharmony_ci printk("%c", SPMANT(x) & SP_MBIT(i) ? '1' : '0'); 8662306a36Sopenharmony_ci printk("e%d", SPBEXP(x) - SP_EBIAS); 8762306a36Sopenharmony_ci break; 8862306a36Sopenharmony_ci case IEEE754_CLASS_NORM: 8962306a36Sopenharmony_ci printk("%c1.", SPSIGN(x) ? '-' : '+'); 9062306a36Sopenharmony_ci for (i = SP_FBITS - 1; i >= 0; i--) 9162306a36Sopenharmony_ci printk("%c", SPMANT(x) & SP_MBIT(i) ? '1' : '0'); 9262306a36Sopenharmony_ci printk("e%d", SPBEXP(x) - SP_EBIAS); 9362306a36Sopenharmony_ci break; 9462306a36Sopenharmony_ci default: 9562306a36Sopenharmony_ci printk("Illegal/Unknown IEEE754 value class"); 9662306a36Sopenharmony_ci } 9762306a36Sopenharmony_ci printk("\n"); 9862306a36Sopenharmony_ci return x; 9962306a36Sopenharmony_ci} 100