MIPS: math-emu: Get rid of the useless parts of exception handling.

All it really did was throw a printk for no obvious reason.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
Ralf Baechle 2014-04-25 03:19:57 +02:00
parent 593d33fe33
commit 90efba36ed
32 changed files with 92 additions and 263 deletions

View File

@ -2,8 +2,8 @@
# Makefile for the Linux/MIPS kernel FPU emulation.
#
obj-y += cp1emu.o ieee754dp.o ieee754sp.o ieee754.o ieee754xcpt.o dp_div.o \
dp_mul.o dp_sub.o dp_add.o dp_fsp.o dp_cmp.o dp_simple.o dp_tint.o \
obj-y += cp1emu.o ieee754dp.o ieee754sp.o ieee754.o dp_div.o dp_mul.o \
dp_sub.o dp_add.o dp_fsp.o dp_cmp.o dp_simple.o dp_tint.o \
dp_fint.o dp_tlong.o dp_flong.o sp_div.o sp_mul.o sp_sub.o \
sp_add.o sp_fdp.o sp_cmp.o sp_simple.o sp_tint.o sp_fint.o \
sp_tlong.o sp_flong.o kernel_linkage.o dsemul.o

View File

@ -53,7 +53,7 @@ union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y)
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF):
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "add", x, y);
return ieee754dp_nanxcpt(ieee754dp_indef());
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN):
@ -76,7 +76,7 @@ union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y)
if (xs == ys)
return x;
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_xcpt(ieee754dp_indef(), "add", x, y);
return ieee754dp_indef();
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF):
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF):
@ -178,5 +178,6 @@ union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y)
}
}
DPNORMRET2(xs, xe, xm, "add", x, y);
return ieee754dp_format(xs, xe, xm);
}

View File

@ -44,7 +44,7 @@ int ieee754dp_cmp(union ieee754dp x, union ieee754dp y, int cmp, int sig)
return 1;
if (cmp & (IEEE754_CLT | IEEE754_CGT)) {
if (sig && ieee754_setandtestcx(IEEE754_INVALID_OPERATION))
return ieee754di_xcpt(0, "fcmpf", x);
return 0;
}
return 0;
} else {

View File

@ -52,7 +52,7 @@ union ieee754dp ieee754dp_div(union ieee754dp x, union ieee754dp y)
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF):
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "div", x, y);
return ieee754dp_nanxcpt(ieee754dp_indef());
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN):
@ -73,7 +73,7 @@ union ieee754dp ieee754dp_div(union ieee754dp x, union ieee754dp y)
case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF):
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_xcpt(ieee754dp_indef(), "div", x, y);
return ieee754dp_indef();
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF):
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF):
@ -90,12 +90,12 @@ union ieee754dp ieee754dp_div(union ieee754dp x, union ieee754dp y)
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO):
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_xcpt(ieee754dp_indef(), "div", x, y);
return ieee754dp_indef();
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_ZERO):
case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_ZERO):
ieee754_setcx(IEEE754_ZERO_DIVIDE);
return ieee754dp_xcpt(ieee754dp_inf(xs ^ ys), "div", x, y);
return ieee754dp_inf(xs ^ ys);
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_NORM):
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_DNORM):
@ -151,6 +151,6 @@ union ieee754dp ieee754dp_div(union ieee754dp x, union ieee754dp y)
re--;
}
DPNORMRET2(xs == ys ? 0 : 1, re, rm, "div", x, y);
return ieee754dp_format(xs == ys ? 0 : 1, re, rm);
}
}

View File

@ -65,5 +65,6 @@ union ieee754dp ieee754dp_flong(s64 x)
xe--;
}
}
DPNORMRET1(xs, xe, xm, "dp_flong", x);
return ieee754dp_format(xs, xe, xm);
}

View File

@ -40,14 +40,13 @@ union ieee754dp ieee754dp_fsp(union ieee754sp x)
switch (xc) {
case IEEE754_CLASS_SNAN:
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "fsp");
return ieee754dp_nanxcpt(ieee754dp_indef());
case IEEE754_CLASS_QNAN:
return ieee754dp_nanxcpt(builddp(xs,
DP_EMAX + 1 + DP_EBIAS,
((u64) xm
<< (DP_FBITS -
SP_FBITS))), "fsp",
x);
SP_FBITS))));
case IEEE754_CLASS_INF:
return ieee754dp_inf(xs);
case IEEE754_CLASS_ZERO:

View File

@ -52,7 +52,7 @@ union ieee754dp ieee754dp_mul(union ieee754dp x, union ieee754dp y)
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF):
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "mul", x, y);
return ieee754dp_nanxcpt(ieee754dp_indef());
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN):
@ -73,7 +73,7 @@ union ieee754dp ieee754dp_mul(union ieee754dp x, union ieee754dp y)
case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_ZERO):
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF):
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_xcpt(ieee754dp_indef(), "mul", x, y);
return ieee754dp_indef();
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF):
case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_INF):
@ -171,6 +171,7 @@ union ieee754dp ieee754dp_mul(union ieee754dp x, union ieee754dp y)
((rm << (DP_FBITS + 1 + 3 + 1)) != 0);
}
assert(rm & (DP_HIDDEN_BIT << 3));
DPNORMRET2(rs, re, rm, "mul", x, y);
return ieee754dp_format(rs, re, rm);
}
}

View File

@ -45,7 +45,7 @@ union ieee754dp ieee754dp_neg(union ieee754dp x)
union ieee754dp y = ieee754dp_indef();
ieee754_setcx(IEEE754_INVALID_OPERATION);
DPSIGN(y) = DPSIGN(x);
return ieee754dp_nanxcpt(y, "neg");
return ieee754dp_nanxcpt(y);
}
return x;
@ -65,7 +65,7 @@ union ieee754dp ieee754dp_abs(union ieee754dp x)
if (xc == IEEE754_CLASS_SNAN) {
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "abs");
return ieee754dp_nanxcpt(ieee754dp_indef());
}
return x;

View File

@ -49,10 +49,10 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x)
switch (xc) {
case IEEE754_CLASS_QNAN:
/* sqrt(Nan) = Nan */
return ieee754dp_nanxcpt(x, "sqrt");
return ieee754dp_nanxcpt(x);
case IEEE754_CLASS_SNAN:
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "sqrt");
return ieee754dp_nanxcpt(ieee754dp_indef());
case IEEE754_CLASS_ZERO:
/* sqrt(0) = 0 */
return x;
@ -60,7 +60,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x)
if (xs) {
/* sqrt(-Inf) = Nan */
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "sqrt");
return ieee754dp_nanxcpt(ieee754dp_indef());
}
/* sqrt(+Inf) = Inf */
return x;
@ -71,7 +71,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x)
if (xs) {
/* sqrt(-x) = Nan */
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "sqrt");
return ieee754dp_nanxcpt(ieee754dp_indef());
}
break;
}

View File

@ -52,7 +52,7 @@ union ieee754dp ieee754dp_sub(union ieee754dp x, union ieee754dp y)
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF):
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "sub", x, y);
return ieee754dp_nanxcpt(ieee754dp_indef());
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN):
@ -75,7 +75,7 @@ union ieee754dp ieee754dp_sub(union ieee754dp x, union ieee754dp y)
if (xs != ys)
return x;
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_xcpt(ieee754dp_indef(), "sub", x, y);
return ieee754dp_indef();
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF):
case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_INF):
@ -186,5 +186,6 @@ union ieee754dp ieee754dp_sub(union ieee754dp x, union ieee754dp y)
xe--;
}
}
DPNORMRET2(xs, xe, xm, "sub", x, y);
return ieee754dp_format(xs, xe, xm);
}

View File

@ -40,7 +40,7 @@ int ieee754dp_tint(union ieee754dp x)
case IEEE754_CLASS_QNAN:
case IEEE754_CLASS_INF:
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754si_xcpt(ieee754si_indef(), "dp_tint", x);
return ieee754si_indef();
case IEEE754_CLASS_ZERO:
return 0;
case IEEE754_CLASS_DNORM:
@ -51,7 +51,7 @@ int ieee754dp_tint(union ieee754dp x)
/* Set invalid. We will only use overflow for floating
point overflow */
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754si_xcpt(ieee754si_indef(), "dp_tint", x);
return ieee754si_indef();
}
/* oh gawd */
if (xe > DP_FBITS) {
@ -96,7 +96,7 @@ int ieee754dp_tint(union ieee754dp x)
if ((xm >> 31) != 0 && (xs == 0 || xm != 0x80000000)) {
/* This can happen after rounding */
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754si_xcpt(ieee754si_indef(), "dp_tint", x);
return ieee754si_indef();
}
if (round || sticky)
ieee754_setcx(IEEE754_INEXACT);

View File

@ -40,7 +40,7 @@ s64 ieee754dp_tlong(union ieee754dp x)
case IEEE754_CLASS_QNAN:
case IEEE754_CLASS_INF:
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754di_xcpt(ieee754di_indef(), "dp_tlong", x);
return ieee754di_indef();
case IEEE754_CLASS_ZERO:
return 0;
case IEEE754_CLASS_DNORM:
@ -54,7 +54,7 @@ s64 ieee754dp_tlong(union ieee754dp x)
/* Set invalid. We will only use overflow for floating
point overflow */
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754di_xcpt(ieee754di_indef(), "dp_tlong", x);
return ieee754di_indef();
}
/* oh gawd */
if (xe > DP_FBITS) {
@ -100,7 +100,7 @@ s64 ieee754dp_tlong(union ieee754dp x)
if ((xm >> 63) != 0) {
/* This can happen after rounding */
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754di_xcpt(ieee754di_indef(), "dp_tlong", x);
return ieee754di_indef();
}
if (round || sticky)
ieee754_setcx(IEEE754_INEXACT);

View File

@ -28,7 +28,6 @@
* ########################################################################
*/
#include <stdarg.h>
#include <linux/compiler.h>
#include "ieee754int.h"
@ -38,15 +37,13 @@
/* special constants
*/
#ifdef __MIPSEB__
#define SPSTR(s, b, m) {s, b, m}
#define DPSTR(s, b, mh, ml) {s, b, mh, ml}
#elif defined(__MIPSEL__)
#define SPSTR(s, b, m) {m, b, s}
#define DPSTR(s, b, mh, ml) {ml, mh, b, s}
#else /* !defined (__MIPSEB__) && !defined (__MIPSEL__) */
#error "MIPS but neither __MIPSEB__ nor __MIPSEL__?"
#endif
#define DPSTR(s, b, mh, ml) \
{ \
.sign = (s), \
.bexp = (b), \
.manthi = (mh), \
.mantlo = (ml) \
}
const struct ieee754dp_const __ieee754dp_spcvals[] = {
DPSTR(0, DP_EMIN - 1 + DP_EBIAS, 0, 0), /* + zero */
@ -68,6 +65,13 @@ const struct ieee754dp_const __ieee754dp_spcvals[] = {
DPSTR(0, 63 + DP_EBIAS, 0, 0), /* + 1.0e63 */
};
#define SPSTR(s, b, m) \
{ \
.sign = (s), \
.bexp = (b), \
.mant = (m) \
}
const struct ieee754sp_const __ieee754sp_spcvals[] = {
SPSTR(0, SP_EMIN - 1 + SP_EBIAS, 0), /* + zero */
SPSTR(1, SP_EMIN - 1 + SP_EBIAS, 0), /* - zero */
@ -87,34 +91,3 @@ const struct ieee754sp_const __ieee754sp_spcvals[] = {
SPSTR(0, 31 + SP_EBIAS, 0), /* + 1.0e31 */
SPSTR(0, 63 + SP_EBIAS, 0), /* + 1.0e63 */
};
int __cold ieee754si_xcpt(int r, const char *op, ...)
{
struct ieee754xctx ax;
if (!ieee754_tstx())
return r;
ax.op = op;
ax.rt = IEEE754_RT_SI;
ax.rv.si = r;
va_start(ax.ap, op);
ieee754_xcpt(&ax);
va_end(ax.ap);
return ax.rv.si;
}
s64 __cold ieee754di_xcpt(s64 r, const char *op, ...)
{
struct ieee754xctx ax;
if (!ieee754_tstx())
return r;
ax.op = op;
ax.rt = IEEE754_RT_DI;
ax.rv.di = r;
va_start(ax.ap, op);
ieee754_xcpt(&ax);
va_end(ax.ap);
return ax.rv.di;
}

View File

@ -24,7 +24,6 @@
#ifndef __ARCH_MIPS_MATH_EMU_IEEE754_H
#define __ARCH_MIPS_MATH_EMU_IEEE754_H
#include <stdarg.h>
#include <linux/compiler.h>
#include <asm/byteorder.h>
#include <linux/kernel.h>
@ -343,19 +342,6 @@ static inline s64 ieee754di_indef(void)
return S64_MAX;
}
/* IEEE exception context, passed to handler */
struct ieee754xctx {
const char *op; /* operation name */
int rt; /* result type */
union {
union ieee754sp sp; /* single precision */
union ieee754dp dp; /* double precision */
int si; /* standard signed integer (32bits) */
s64 di; /* extended signed integer (64bits) */
} rv; /* default result format implied by op */
va_list ap;
};
/* result types for xctx.rt */
#define IEEE754_RT_SP 0
#define IEEE754_RT_DP 1
@ -363,8 +349,6 @@ struct ieee754xctx {
#define IEEE754_RT_SI 3
#define IEEE754_RT_DI 4
extern void __cold ieee754_xcpt(struct ieee754xctx *xcp);
/* compat */
#define ieee754dp_fix(x) ieee754dp_tint(x)
#define ieee754sp_fix(x) ieee754sp_tint(x)

View File

@ -23,7 +23,6 @@
* ########################################################################
*/
#include <stdarg.h>
#include <linux/compiler.h>
#include "ieee754dp.h"
@ -47,25 +46,8 @@ static inline int ieee754dp_issnan(union ieee754dp x)
}
union ieee754dp __cold ieee754dp_xcpt(union ieee754dp r, const char *op, ...)
union ieee754dp __cold ieee754dp_nanxcpt(union ieee754dp r)
{
struct ieee754xctx ax;
if (!ieee754_tstx())
return r;
ax.op = op;
ax.rt = IEEE754_RT_DP;
ax.rv.dp = r;
va_start(ax.ap, op);
ieee754_xcpt(&ax);
va_end(ax.ap);
return ax.rv.dp;
}
union ieee754dp __cold ieee754dp_nanxcpt(union ieee754dp r, const char *op, ...)
{
struct ieee754xctx ax;
assert(ieee754dp_isnan(r));
if (!ieee754dp_issnan(r)) /* QNAN does not cause invalid op !! */
@ -80,13 +62,7 @@ union ieee754dp __cold ieee754dp_nanxcpt(union ieee754dp r, const char *op, ...)
return ieee754dp_indef();
}
ax.op = op;
ax.rt = 0;
ax.rv.dp = r;
va_start(ax.ap, op);
ieee754_xcpt(&ax);
va_end(ax.ap);
return ax.rv.dp;
return r;
}
static u64 get_rounding(int sn, u64 xm)

View File

@ -81,20 +81,5 @@ static inline union ieee754dp builddp(int s, int bx, u64 m)
}
extern int ieee754dp_isnan(union ieee754dp);
extern int __cold ieee754si_xcpt(int, const char *, ...);
extern s64 __cold ieee754di_xcpt(s64, const char *, ...);
extern union ieee754dp __cold ieee754dp_xcpt(union ieee754dp, const char *, ...);
extern union ieee754dp __cold ieee754dp_nanxcpt(union ieee754dp, const char *, ...);
extern union ieee754dp __cold ieee754dp_nanxcpt(union ieee754dp);
extern union ieee754dp ieee754dp_format(int, int, u64);
#define DPNORMRET2(s, e, m, name, a0, a1) \
{ \
union ieee754dp V = ieee754dp_format(s, e, m); \
if (ieee754_tstx()) \
return ieee754dp_xcpt(V, name, a0, a1); \
else \
return V; \
}
#define DPNORMRET1(s, e, m, name, a0) DPNORMRET2(s, e, m, name, a0, a0)

View File

@ -48,11 +48,6 @@ static inline int ieee754_setandtestcx(const unsigned int x)
return ieee754_csr.mx & x;
}
static inline int ieee754_tstx(void)
{
return ieee754_csr.cx & ieee754_csr.mx;
}
#define COMPXSP \
unsigned xm; int xe; int xs __maybe_unused; int xc

View File

@ -23,7 +23,6 @@
* ########################################################################
*/
#include <stdarg.h>
#include <linux/compiler.h>
#include "ieee754sp.h"
@ -47,26 +46,8 @@ static inline int ieee754sp_issnan(union ieee754sp x)
}
union ieee754sp __cold ieee754sp_xcpt(union ieee754sp r, const char *op, ...)
union ieee754sp __cold ieee754sp_nanxcpt(union ieee754sp r)
{
struct ieee754xctx ax;
if (!ieee754_tstx())
return r;
ax.op = op;
ax.rt = IEEE754_RT_SP;
ax.rv.sp = r;
va_start(ax.ap, op);
ieee754_xcpt(&ax);
va_end(ax.ap);
return ax.rv.sp;
}
union ieee754sp __cold ieee754sp_nanxcpt(union ieee754sp r, const char *op, ...)
{
struct ieee754xctx ax;
assert(ieee754sp_isnan(r));
if (!ieee754sp_issnan(r)) /* QNAN does not cause invalid op !! */
@ -81,13 +62,7 @@ union ieee754sp __cold ieee754sp_nanxcpt(union ieee754sp r, const char *op, ...)
return ieee754sp_indef();
}
ax.op = op;
ax.rt = 0;
ax.rv.sp = r;
va_start(ax.ap, op);
ieee754_xcpt(&ax);
va_end(ax.ap);
return ax.rv.sp;
return r;
}
static unsigned get_rounding(int sn, unsigned xm)

View File

@ -87,21 +87,5 @@ static inline union ieee754sp buildsp(int s, int bx, unsigned m)
}
extern int ieee754sp_isnan(union ieee754sp);
extern int __cold ieee754si_xcpt(int, const char *, ...);
extern s64 __cold ieee754di_xcpt(s64, const char *, ...);
extern union ieee754sp __cold ieee754sp_xcpt(union ieee754sp, const char *, ...);
extern union ieee754sp __cold ieee754sp_nanxcpt(union ieee754sp, const char *, ...);
extern union ieee754sp __cold ieee754sp_nanxcpt(union ieee754sp);
extern union ieee754sp ieee754sp_format(int, int, unsigned);
#define SPNORMRET2(s, e, m, name, a0, a1) \
{ \
union ieee754sp V = ieee754sp_format(s, e, m); \
\
if (ieee754_tstx()) \
return ieee754sp_xcpt(V, name, a0, a1); \
else \
return V; \
}
#define SPNORMRET1(s, e, m, name, a0) SPNORMRET2(s, e, m, name, a0, a0)

View File

@ -1,48 +0,0 @@
/*
* MIPS floating point support
* Copyright (C) 1994-2000 Algorithmics Ltd.
*
* ########################################################################
*
* This program is free software; you can distribute it and/or modify it
* under the terms of the GNU General Public License (Version 2) as
* published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
*
* ########################################################################
*/
/**************************************************************************
* Nov 7, 2000
* Added preprocessor hacks to map to Linux kernel diagnostics.
*
* Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
* Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
*************************************************************************/
#include <linux/compiler.h>
#include <linux/printk.h>
#include "ieee754.h"
/*
* Very naff exception handler (you can plug in your own and
* override this).
*/
static const char *const rtnames[] = {
"sp", "dp", "xp", "si", "di"
};
void __cold ieee754_xcpt(struct ieee754xctx *xcp)
{
printk(KERN_DEBUG "floating point exception in \"%s\", type=%s\n",
xcp->op, rtnames[xcp->rt]);
}

View File

@ -52,7 +52,7 @@ union ieee754sp ieee754sp_add(union ieee754sp x, union ieee754sp y)
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF):
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "add", x, y);
return ieee754sp_nanxcpt(ieee754sp_indef());
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN):
@ -75,7 +75,7 @@ union ieee754sp ieee754sp_add(union ieee754sp x, union ieee754sp y)
if (xs == ys)
return x;
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_xcpt(ieee754sp_indef(), "add", x, y);
return ieee754sp_indef();
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF):
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF):
@ -172,5 +172,6 @@ union ieee754sp ieee754sp_add(union ieee754sp x, union ieee754sp y)
}
}
SPNORMRET2(xs, xe, xm, "add", x, y);
return ieee754sp_format(xs, xe, xm);
}

View File

@ -44,7 +44,7 @@ int ieee754sp_cmp(union ieee754sp x, union ieee754sp y, int cmp, int sig)
return 1;
if (cmp & (IEEE754_CLT | IEEE754_CGT)) {
if (sig && ieee754_setandtestcx(IEEE754_INVALID_OPERATION))
return ieee754si_xcpt(0, "fcmpf", x);
return 0;
}
return 0;
} else {

View File

@ -52,7 +52,7 @@ union ieee754sp ieee754sp_div(union ieee754sp x, union ieee754sp y)
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF):
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "div", x, y);
return ieee754sp_nanxcpt(ieee754sp_indef());
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN):
@ -73,7 +73,7 @@ union ieee754sp ieee754sp_div(union ieee754sp x, union ieee754sp y)
case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF):
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_xcpt(ieee754sp_indef(), "div", x, y);
return ieee754sp_indef();
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF):
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF):
@ -90,12 +90,12 @@ union ieee754sp ieee754sp_div(union ieee754sp x, union ieee754sp y)
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO):
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_xcpt(ieee754sp_indef(), "div", x, y);
return ieee754sp_indef();
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_ZERO):
case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_ZERO):
ieee754_setcx(IEEE754_ZERO_DIVIDE);
return ieee754sp_xcpt(ieee754sp_inf(xs ^ ys), "div", x, y);
return ieee754sp_inf(xs ^ ys);
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_NORM):
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_DNORM):
@ -151,6 +151,6 @@ union ieee754sp ieee754sp_div(union ieee754sp x, union ieee754sp y)
re--;
}
SPNORMRET2(xs == ys ? 0 : 1, re, rm, "div", x, y);
return ieee754sp_format(xs == ys ? 0 : 1, re, rm);
}
}

View File

@ -41,13 +41,13 @@ union ieee754sp ieee754sp_fdp(union ieee754dp x)
switch (xc) {
case IEEE754_CLASS_SNAN:
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "fdp");
return ieee754sp_nanxcpt(ieee754sp_indef());
case IEEE754_CLASS_QNAN:
nan = buildsp(xs, SP_EMAX + 1 + SP_EBIAS, (u32)
(xm >> (DP_FBITS - SP_FBITS)));
if (!ieee754sp_isnan(nan))
nan = ieee754sp_indef();
return ieee754sp_nanxcpt(nan, "fdp", x);
return ieee754sp_nanxcpt(nan);
case IEEE754_CLASS_INF:
return ieee754sp_inf(xs);
case IEEE754_CLASS_ZERO:
@ -58,8 +58,8 @@ union ieee754sp ieee754sp_fdp(union ieee754dp x)
ieee754_setcx(IEEE754_INEXACT);
if ((ieee754_csr.rm == IEEE754_RU && !xs) ||
(ieee754_csr.rm == IEEE754_RD && xs))
return ieee754sp_xcpt(ieee754sp_mind(xs), "fdp", x);
return ieee754sp_xcpt(ieee754sp_zero(xs), "fdp", x);
return ieee754sp_mind(xs);
return ieee754sp_zero(xs);
case IEEE754_CLASS_NORM:
break;
}
@ -72,6 +72,6 @@ union ieee754sp ieee754sp_fdp(union ieee754dp x)
rm = (xm >> (DP_FBITS - (SP_FBITS + 3))) |
((xm << (64 - (DP_FBITS - (SP_FBITS + 3)))) != 0);
SPNORMRET1(xs, xe, rm, "fdp", x);
return ieee754sp_format(xs, xe, rm);
}
}

View File

@ -66,5 +66,5 @@ union ieee754sp ieee754sp_fint(int x)
xe--;
}
}
SPNORMRET1(xs, xe, xm, "fint", x);
return ieee754sp_format(xs, xe, xm);
}

View File

@ -65,5 +65,5 @@ union ieee754sp ieee754sp_flong(s64 x)
xe--;
}
}
SPNORMRET1(xs, xe, xm, "sp_flong", x);
return ieee754sp_format(xs, xe, xm);
}

View File

@ -52,7 +52,7 @@ union ieee754sp ieee754sp_mul(union ieee754sp x, union ieee754sp y)
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF):
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "mul", x, y);
return ieee754sp_nanxcpt(ieee754sp_indef());
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN):
@ -73,7 +73,7 @@ union ieee754sp ieee754sp_mul(union ieee754sp x, union ieee754sp y)
case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_ZERO):
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF):
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_xcpt(ieee754sp_indef(), "mul", x, y);
return ieee754sp_indef();
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF):
case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_INF):
@ -165,6 +165,6 @@ union ieee754sp ieee754sp_mul(union ieee754sp x, union ieee754sp y)
}
assert(rm & (SP_HIDDEN_BIT << 3));
SPNORMRET2(rs, re, rm, "mul", x, y);
return ieee754sp_format(rs, re, rm);
}
}

View File

@ -45,7 +45,7 @@ union ieee754sp ieee754sp_neg(union ieee754sp x)
union ieee754sp y = ieee754sp_indef();
ieee754_setcx(IEEE754_INVALID_OPERATION);
SPSIGN(y) = SPSIGN(x);
return ieee754sp_nanxcpt(y, "neg");
return ieee754sp_nanxcpt(y);
}
return x;
@ -65,7 +65,7 @@ union ieee754sp ieee754sp_abs(union ieee754sp x)
if (xc == IEEE754_CLASS_SNAN) {
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "abs");
return ieee754sp_nanxcpt(ieee754sp_indef());
}
return x;

View File

@ -42,10 +42,10 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x)
switch (xc) {
case IEEE754_CLASS_QNAN:
/* sqrt(Nan) = Nan */
return ieee754sp_nanxcpt(x, "sqrt");
return ieee754sp_nanxcpt(x);
case IEEE754_CLASS_SNAN:
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "sqrt");
return ieee754sp_nanxcpt(ieee754sp_indef());
case IEEE754_CLASS_ZERO:
/* sqrt(0) = 0 */
return x;
@ -53,7 +53,7 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x)
if (xs) {
/* sqrt(-Inf) = Nan */
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "sqrt");
return ieee754sp_nanxcpt(ieee754sp_indef());
}
/* sqrt(+Inf) = Inf */
return x;
@ -62,7 +62,7 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x)
if (xs) {
/* sqrt(-x) = Nan */
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "sqrt");
return ieee754sp_nanxcpt(ieee754sp_indef());
}
break;
}

View File

@ -52,7 +52,7 @@ union ieee754sp ieee754sp_sub(union ieee754sp x, union ieee754sp y)
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF):
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "sub", x, y);
return ieee754sp_nanxcpt(ieee754sp_indef());
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_QNAN):
@ -75,7 +75,7 @@ union ieee754sp ieee754sp_sub(union ieee754sp x, union ieee754sp y)
if (xs != ys)
return x;
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_xcpt(ieee754sp_indef(), "sub", x, y);
return ieee754sp_indef();
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF):
case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_INF):
@ -179,5 +179,6 @@ union ieee754sp ieee754sp_sub(union ieee754sp x, union ieee754sp y)
xe--;
}
}
SPNORMRET2(xs, xe, xm, "sub", x, y);
return ieee754sp_format(xs, xe, xm);
}

View File

@ -40,7 +40,7 @@ int ieee754sp_tint(union ieee754sp x)
case IEEE754_CLASS_QNAN:
case IEEE754_CLASS_INF:
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754si_xcpt(ieee754si_indef(), "sp_tint", x);
return ieee754si_indef();
case IEEE754_CLASS_ZERO:
return 0;
case IEEE754_CLASS_DNORM:
@ -54,7 +54,7 @@ int ieee754sp_tint(union ieee754sp x)
/* Set invalid. We will only use overflow for floating
point overflow */
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754si_xcpt(ieee754si_indef(), "sp_tint", x);
return ieee754si_indef();
}
/* oh gawd */
if (xe > SP_FBITS) {
@ -100,7 +100,7 @@ int ieee754sp_tint(union ieee754sp x)
if ((xm >> 31) != 0) {
/* This can happen after rounding */
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754si_xcpt(ieee754si_indef(), "sp_tint", x);
return ieee754si_indef();
}
if (round || sticky)
ieee754_setcx(IEEE754_INEXACT);

View File

@ -41,7 +41,7 @@ s64 ieee754sp_tlong(union ieee754sp x)
case IEEE754_CLASS_QNAN:
case IEEE754_CLASS_INF:
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754di_xcpt(ieee754di_indef(), "sp_tlong", x);
return ieee754di_indef();
case IEEE754_CLASS_ZERO:
return 0;
case IEEE754_CLASS_DNORM:
@ -55,7 +55,7 @@ s64 ieee754sp_tlong(union ieee754sp x)
/* Set invalid. We will only use overflow for floating
point overflow */
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754di_xcpt(ieee754di_indef(), "sp_tlong", x);
return ieee754di_indef();
}
/* oh gawd */
if (xe > SP_FBITS) {
@ -97,7 +97,7 @@ s64 ieee754sp_tlong(union ieee754sp x)
if ((xm >> 63) != 0) {
/* This can happen after rounding */
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754di_xcpt(ieee754di_indef(), "sp_tlong", x);
return ieee754di_indef();
}
if (round || sticky)
ieee754_setcx(IEEE754_INEXACT);