Commit 9e8bad1f authored by Ralf Baechle's avatar Ralf Baechle

MIPS: math-emu: Turn macros into functions where possible.

Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent bee16535
...@@ -35,7 +35,7 @@ union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y) ...@@ -35,7 +35,7 @@ union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y)
EXPLODEXDP; EXPLODEXDP;
EXPLODEYDP; EXPLODEYDP;
CLEARCX; ieee754_clearcx();
FLUSHXDP; FLUSHXDP;
FLUSHYDP; FLUSHYDP;
...@@ -52,7 +52,7 @@ union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y) ...@@ -52,7 +52,7 @@ union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y)
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_NORM): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_NORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF):
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "add", x, y); return ieee754dp_nanxcpt(ieee754dp_indef(), "add", x, y);
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
...@@ -75,7 +75,7 @@ union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y) ...@@ -75,7 +75,7 @@ union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y)
case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF):
if (xs == ys) if (xs == ys)
return x; return x;
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_xcpt(ieee754dp_indef(), "add", x, y); return ieee754dp_xcpt(ieee754dp_indef(), "add", x, y);
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF):
......
...@@ -35,15 +35,15 @@ int ieee754dp_cmp(union ieee754dp x, union ieee754dp y, int cmp, int sig) ...@@ -35,15 +35,15 @@ int ieee754dp_cmp(union ieee754dp x, union ieee754dp y, int cmp, int sig)
EXPLODEYDP; EXPLODEYDP;
FLUSHXDP; FLUSHXDP;
FLUSHYDP; FLUSHYDP;
CLEARCX; /* Even clear inexact flag here */ ieee754_clearcx(); /* Even clear inexact flag here */
if (ieee754dp_isnan(x) || ieee754dp_isnan(y)) { if (ieee754dp_isnan(x) || ieee754dp_isnan(y)) {
if (sig || xc == IEEE754_CLASS_SNAN || yc == IEEE754_CLASS_SNAN) if (sig || xc == IEEE754_CLASS_SNAN || yc == IEEE754_CLASS_SNAN)
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
if (cmp & IEEE754_CUN) if (cmp & IEEE754_CUN)
return 1; return 1;
if (cmp & (IEEE754_CLT | IEEE754_CGT)) { if (cmp & (IEEE754_CLT | IEEE754_CGT)) {
if (sig && SETANDTESTCX(IEEE754_INVALID_OPERATION)) if (sig && ieee754_setandtestcx(IEEE754_INVALID_OPERATION))
return ieee754si_xcpt(0, "fcmpf", x); return ieee754si_xcpt(0, "fcmpf", x);
} }
return 0; return 0;
......
...@@ -34,7 +34,7 @@ union ieee754dp ieee754dp_div(union ieee754dp x, union ieee754dp y) ...@@ -34,7 +34,7 @@ union ieee754dp ieee754dp_div(union ieee754dp x, union ieee754dp y)
EXPLODEXDP; EXPLODEXDP;
EXPLODEYDP; EXPLODEYDP;
CLEARCX; ieee754_clearcx();
FLUSHXDP; FLUSHXDP;
FLUSHYDP; FLUSHYDP;
...@@ -51,7 +51,7 @@ union ieee754dp ieee754dp_div(union ieee754dp x, union ieee754dp y) ...@@ -51,7 +51,7 @@ union ieee754dp ieee754dp_div(union ieee754dp x, union ieee754dp y)
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_NORM): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_NORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF):
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "div", x, y); return ieee754dp_nanxcpt(ieee754dp_indef(), "div", x, y);
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
...@@ -72,7 +72,7 @@ union ieee754dp ieee754dp_div(union ieee754dp x, union ieee754dp y) ...@@ -72,7 +72,7 @@ union ieee754dp ieee754dp_div(union ieee754dp x, union ieee754dp y)
*/ */
case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF):
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_xcpt(ieee754dp_indef(), "div", x, y); return ieee754dp_xcpt(ieee754dp_indef(), "div", x, y);
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF):
...@@ -89,12 +89,12 @@ union ieee754dp ieee754dp_div(union ieee754dp x, union ieee754dp y) ...@@ -89,12 +89,12 @@ union ieee754dp ieee754dp_div(union ieee754dp x, union ieee754dp y)
*/ */
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO):
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_xcpt(ieee754dp_indef(), "div", x, y); return ieee754dp_xcpt(ieee754dp_indef(), "div", x, y);
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_ZERO): case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_ZERO):
case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_ZERO): case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_ZERO):
SETCX(IEEE754_ZERO_DIVIDE); ieee754_setcx(IEEE754_ZERO_DIVIDE);
return ieee754dp_xcpt(ieee754dp_inf(xs ^ ys), "div", x, y); return ieee754dp_xcpt(ieee754dp_inf(xs ^ ys), "div", x, y);
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_NORM): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_NORM):
......
...@@ -32,7 +32,7 @@ union ieee754dp ieee754dp_fint(int x) ...@@ -32,7 +32,7 @@ union ieee754dp ieee754dp_fint(int x)
int xe; int xe;
int xs; int xs;
CLEARCX; ieee754_clearcx();
if (x == 0) if (x == 0)
return ieee754dp_zero(0); return ieee754dp_zero(0);
......
...@@ -32,7 +32,7 @@ union ieee754dp ieee754dp_flong(s64 x) ...@@ -32,7 +32,7 @@ union ieee754dp ieee754dp_flong(s64 x)
int xe; int xe;
int xs; int xs;
CLEARCX; ieee754_clearcx();
if (x == 0) if (x == 0)
return ieee754dp_zero(0); return ieee754dp_zero(0);
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
union ieee754dp ieee754dp_frexp(union ieee754dp x, int *eptr) union ieee754dp ieee754dp_frexp(union ieee754dp x, int *eptr)
{ {
COMPXDP; COMPXDP;
CLEARCX; ieee754_clearcx();
EXPLODEXDP; EXPLODEXDP;
switch (xc) { switch (xc) {
......
...@@ -32,13 +32,13 @@ union ieee754dp ieee754dp_fsp(union ieee754sp x) ...@@ -32,13 +32,13 @@ union ieee754dp ieee754dp_fsp(union ieee754sp x)
EXPLODEXSP; EXPLODEXSP;
CLEARCX; ieee754_clearcx();
FLUSHXSP; FLUSHXSP;
switch (xc) { switch (xc) {
case IEEE754_CLASS_SNAN: case IEEE754_CLASS_SNAN:
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "fsp"); return ieee754dp_nanxcpt(ieee754dp_indef(), "fsp");
case IEEE754_CLASS_QNAN: case IEEE754_CLASS_QNAN:
return ieee754dp_nanxcpt(builddp(xs, return ieee754dp_nanxcpt(builddp(xs,
......
...@@ -30,7 +30,7 @@ union ieee754dp ieee754dp_logb(union ieee754dp x) ...@@ -30,7 +30,7 @@ union ieee754dp ieee754dp_logb(union ieee754dp x)
{ {
COMPXDP; COMPXDP;
CLEARCX; ieee754_clearcx();
EXPLODEXDP; EXPLODEXDP;
......
...@@ -32,7 +32,7 @@ union ieee754dp ieee754dp_modf(union ieee754dp x, union ieee754dp *ip) ...@@ -32,7 +32,7 @@ union ieee754dp ieee754dp_modf(union ieee754dp x, union ieee754dp *ip)
{ {
COMPXDP; COMPXDP;
CLEARCX; ieee754_clearcx();
EXPLODEXDP; EXPLODEXDP;
......
...@@ -34,7 +34,7 @@ union ieee754dp ieee754dp_mul(union ieee754dp x, union ieee754dp y) ...@@ -34,7 +34,7 @@ union ieee754dp ieee754dp_mul(union ieee754dp x, union ieee754dp y)
EXPLODEXDP; EXPLODEXDP;
EXPLODEYDP; EXPLODEYDP;
CLEARCX; ieee754_clearcx();
FLUSHXDP; FLUSHXDP;
FLUSHYDP; FLUSHYDP;
...@@ -51,7 +51,7 @@ union ieee754dp ieee754dp_mul(union ieee754dp x, union ieee754dp y) ...@@ -51,7 +51,7 @@ union ieee754dp ieee754dp_mul(union ieee754dp x, union ieee754dp y)
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_NORM): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_NORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF):
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "mul", x, y); return ieee754dp_nanxcpt(ieee754dp_indef(), "mul", x, y);
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
...@@ -72,7 +72,7 @@ union ieee754dp ieee754dp_mul(union ieee754dp x, union ieee754dp y) ...@@ -72,7 +72,7 @@ union ieee754dp ieee754dp_mul(union ieee754dp x, union ieee754dp y)
case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_ZERO): case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_ZERO):
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF):
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_xcpt(ieee754dp_indef(), "mul", x, y); return ieee754dp_xcpt(ieee754dp_indef(), "mul", x, y);
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF):
......
...@@ -30,7 +30,7 @@ union ieee754dp ieee754dp_scalb(union ieee754dp x, int n) ...@@ -30,7 +30,7 @@ union ieee754dp ieee754dp_scalb(union ieee754dp x, int n)
{ {
COMPXDP; COMPXDP;
CLEARCX; ieee754_clearcx();
EXPLODEXDP; EXPLODEXDP;
......
...@@ -33,7 +33,7 @@ int ieee754dp_finite(union ieee754dp x) ...@@ -33,7 +33,7 @@ int ieee754dp_finite(union ieee754dp x)
union ieee754dp ieee754dp_copysign(union ieee754dp x, union ieee754dp y) union ieee754dp ieee754dp_copysign(union ieee754dp x, union ieee754dp y)
{ {
CLEARCX; ieee754_clearcx();
DPSIGN(x) = DPSIGN(y); DPSIGN(x) = DPSIGN(y);
return x; return x;
} }
...@@ -44,7 +44,7 @@ union ieee754dp ieee754dp_neg(union ieee754dp x) ...@@ -44,7 +44,7 @@ union ieee754dp ieee754dp_neg(union ieee754dp x)
COMPXDP; COMPXDP;
EXPLODEXDP; EXPLODEXDP;
CLEARCX; ieee754_clearcx();
FLUSHXDP; FLUSHXDP;
/* /*
...@@ -56,7 +56,7 @@ union ieee754dp ieee754dp_neg(union ieee754dp x) ...@@ -56,7 +56,7 @@ union ieee754dp ieee754dp_neg(union ieee754dp x)
if (xc == IEEE754_CLASS_SNAN) { if (xc == IEEE754_CLASS_SNAN) {
union ieee754dp y = ieee754dp_indef(); union ieee754dp y = ieee754dp_indef();
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
DPSIGN(y) = DPSIGN(x); DPSIGN(y) = DPSIGN(x);
return ieee754dp_nanxcpt(y, "neg"); return ieee754dp_nanxcpt(y, "neg");
} }
...@@ -70,14 +70,14 @@ union ieee754dp ieee754dp_abs(union ieee754dp x) ...@@ -70,14 +70,14 @@ union ieee754dp ieee754dp_abs(union ieee754dp x)
COMPXDP; COMPXDP;
EXPLODEXDP; EXPLODEXDP;
CLEARCX; ieee754_clearcx();
FLUSHXDP; FLUSHXDP;
/* Clear sign ALWAYS, irrespective of NaN */ /* Clear sign ALWAYS, irrespective of NaN */
DPSIGN(x) = 0; DPSIGN(x) = 0;
if (xc == IEEE754_CLASS_SNAN) { if (xc == IEEE754_CLASS_SNAN) {
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "abs"); return ieee754dp_nanxcpt(ieee754dp_indef(), "abs");
} }
......
...@@ -42,7 +42,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x) ...@@ -42,7 +42,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x)
COMPXDP; COMPXDP;
EXPLODEXDP; EXPLODEXDP;
CLEARCX; ieee754_clearcx();
FLUSHXDP; FLUSHXDP;
/* x == INF or NAN? */ /* x == INF or NAN? */
...@@ -51,7 +51,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x) ...@@ -51,7 +51,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x)
/* sqrt(Nan) = Nan */ /* sqrt(Nan) = Nan */
return ieee754dp_nanxcpt(x, "sqrt"); return ieee754dp_nanxcpt(x, "sqrt");
case IEEE754_CLASS_SNAN: case IEEE754_CLASS_SNAN:
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "sqrt"); return ieee754dp_nanxcpt(ieee754dp_indef(), "sqrt");
case IEEE754_CLASS_ZERO: case IEEE754_CLASS_ZERO:
/* sqrt(0) = 0 */ /* sqrt(0) = 0 */
...@@ -59,7 +59,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x) ...@@ -59,7 +59,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x)
case IEEE754_CLASS_INF: case IEEE754_CLASS_INF:
if (xs) { if (xs) {
/* sqrt(-Inf) = Nan */ /* sqrt(-Inf) = Nan */
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "sqrt"); return ieee754dp_nanxcpt(ieee754dp_indef(), "sqrt");
} }
/* sqrt(+Inf) = Inf */ /* sqrt(+Inf) = Inf */
...@@ -70,7 +70,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x) ...@@ -70,7 +70,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x)
case IEEE754_CLASS_NORM: case IEEE754_CLASS_NORM:
if (xs) { if (xs) {
/* sqrt(-x) = Nan */ /* sqrt(-x) = Nan */
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "sqrt"); return ieee754dp_nanxcpt(ieee754dp_indef(), "sqrt");
} }
break; break;
......
...@@ -34,7 +34,7 @@ union ieee754dp ieee754dp_sub(union ieee754dp x, union ieee754dp y) ...@@ -34,7 +34,7 @@ union ieee754dp ieee754dp_sub(union ieee754dp x, union ieee754dp y)
EXPLODEXDP; EXPLODEXDP;
EXPLODEYDP; EXPLODEYDP;
CLEARCX; ieee754_clearcx();
FLUSHXDP; FLUSHXDP;
FLUSHYDP; FLUSHYDP;
...@@ -51,7 +51,7 @@ union ieee754dp ieee754dp_sub(union ieee754dp x, union ieee754dp y) ...@@ -51,7 +51,7 @@ union ieee754dp ieee754dp_sub(union ieee754dp x, union ieee754dp y)
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_NORM): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_NORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF):
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "sub", x, y); return ieee754dp_nanxcpt(ieee754dp_indef(), "sub", x, y);
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
...@@ -74,7 +74,7 @@ union ieee754dp ieee754dp_sub(union ieee754dp x, union ieee754dp y) ...@@ -74,7 +74,7 @@ union ieee754dp ieee754dp_sub(union ieee754dp x, union ieee754dp y)
case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF):
if (xs != ys) if (xs != ys)
return x; return x;
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_xcpt(ieee754dp_indef(), "sub", x, y); return ieee754dp_xcpt(ieee754dp_indef(), "sub", x, y);
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF):
......
...@@ -30,7 +30,7 @@ int ieee754dp_tint(union ieee754dp x) ...@@ -30,7 +30,7 @@ int ieee754dp_tint(union ieee754dp x)
{ {
COMPXDP; COMPXDP;
CLEARCX; ieee754_clearcx();
EXPLODEXDP; EXPLODEXDP;
FLUSHXDP; FLUSHXDP;
...@@ -39,7 +39,7 @@ int ieee754dp_tint(union ieee754dp x) ...@@ -39,7 +39,7 @@ int ieee754dp_tint(union ieee754dp x)
case IEEE754_CLASS_SNAN: case IEEE754_CLASS_SNAN:
case IEEE754_CLASS_QNAN: case IEEE754_CLASS_QNAN:
case IEEE754_CLASS_INF: case IEEE754_CLASS_INF:
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754si_xcpt(ieee754si_indef(), "dp_tint", x); return ieee754si_xcpt(ieee754si_indef(), "dp_tint", x);
case IEEE754_CLASS_ZERO: case IEEE754_CLASS_ZERO:
return 0; return 0;
...@@ -50,7 +50,7 @@ int ieee754dp_tint(union ieee754dp x) ...@@ -50,7 +50,7 @@ int ieee754dp_tint(union ieee754dp x)
if (xe > 31) { if (xe > 31) {
/* Set invalid. We will only use overflow for floating /* Set invalid. We will only use overflow for floating
point overflow */ point overflow */
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754si_xcpt(ieee754si_indef(), "dp_tint", x); return ieee754si_xcpt(ieee754si_indef(), "dp_tint", x);
} }
/* oh gawd */ /* oh gawd */
...@@ -95,11 +95,11 @@ int ieee754dp_tint(union ieee754dp x) ...@@ -95,11 +95,11 @@ int ieee754dp_tint(union ieee754dp x)
/* look for valid corner case 0x80000000 */ /* look for valid corner case 0x80000000 */
if ((xm >> 31) != 0 && (xs == 0 || xm != 0x80000000)) { if ((xm >> 31) != 0 && (xs == 0 || xm != 0x80000000)) {
/* This can happen after rounding */ /* This can happen after rounding */
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754si_xcpt(ieee754si_indef(), "dp_tint", x); return ieee754si_xcpt(ieee754si_indef(), "dp_tint", x);
} }
if (round || sticky) if (round || sticky)
SETCX(IEEE754_INEXACT); ieee754_setcx(IEEE754_INEXACT);
} }
if (xs) if (xs)
return -xm; return -xm;
......
...@@ -30,7 +30,7 @@ s64 ieee754dp_tlong(union ieee754dp x) ...@@ -30,7 +30,7 @@ s64 ieee754dp_tlong(union ieee754dp x)
{ {
COMPXDP; COMPXDP;
CLEARCX; ieee754_clearcx();
EXPLODEXDP; EXPLODEXDP;
FLUSHXDP; FLUSHXDP;
...@@ -39,7 +39,7 @@ s64 ieee754dp_tlong(union ieee754dp x) ...@@ -39,7 +39,7 @@ s64 ieee754dp_tlong(union ieee754dp x)
case IEEE754_CLASS_SNAN: case IEEE754_CLASS_SNAN:
case IEEE754_CLASS_QNAN: case IEEE754_CLASS_QNAN:
case IEEE754_CLASS_INF: case IEEE754_CLASS_INF:
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754di_xcpt(ieee754di_indef(), "dp_tlong", x); return ieee754di_xcpt(ieee754di_indef(), "dp_tlong", x);
case IEEE754_CLASS_ZERO: case IEEE754_CLASS_ZERO:
return 0; return 0;
...@@ -53,7 +53,7 @@ s64 ieee754dp_tlong(union ieee754dp x) ...@@ -53,7 +53,7 @@ s64 ieee754dp_tlong(union ieee754dp x)
return -0x8000000000000000LL; return -0x8000000000000000LL;
/* Set invalid. We will only use overflow for floating /* Set invalid. We will only use overflow for floating
point overflow */ point overflow */
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754di_xcpt(ieee754di_indef(), "dp_tlong", x); return ieee754di_xcpt(ieee754di_indef(), "dp_tlong", x);
} }
/* oh gawd */ /* oh gawd */
...@@ -99,11 +99,11 @@ s64 ieee754dp_tlong(union ieee754dp x) ...@@ -99,11 +99,11 @@ s64 ieee754dp_tlong(union ieee754dp x)
} }
if ((xm >> 63) != 0) { if ((xm >> 63) != 0) {
/* This can happen after rounding */ /* This can happen after rounding */
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754di_xcpt(ieee754di_indef(), "dp_tlong", x); return ieee754di_xcpt(ieee754di_indef(), "dp_tlong", x);
} }
if (round || sticky) if (round || sticky)
SETCX(IEEE754_INEXACT); ieee754_setcx(IEEE754_INEXACT);
} }
if (xs) if (xs)
return -xm; return -xm;
......
...@@ -101,7 +101,7 @@ int __cold ieee754si_xcpt(int r, const char *op, ...) ...@@ -101,7 +101,7 @@ int __cold ieee754si_xcpt(int r, const char *op, ...)
{ {
struct ieee754xctx ax; struct ieee754xctx ax;
if (!TSTX()) if (!ieee754_tstx())
return r; return r;
ax.op = op; ax.op = op;
ax.rt = IEEE754_RT_SI; ax.rt = IEEE754_RT_SI;
...@@ -116,7 +116,7 @@ s64 __cold ieee754di_xcpt(s64 r, const char *op, ...) ...@@ -116,7 +116,7 @@ s64 __cold ieee754di_xcpt(s64 r, const char *op, ...)
{ {
struct ieee754xctx ax; struct ieee754xctx ax;
if (!TSTX()) if (!ieee754_tstx())
return r; return r;
ax.op = op; ax.op = op;
ax.rt = IEEE754_RT_DI; ax.rt = IEEE754_RT_DI;
......
...@@ -170,12 +170,14 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x); ...@@ -170,12 +170,14 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x);
/* 5 types of floating point number /* 5 types of floating point number
*/ */
#define IEEE754_CLASS_NORM 0x00 enum {
#define IEEE754_CLASS_ZERO 0x01 IEEE754_CLASS_NORM = 0x00,
#define IEEE754_CLASS_DNORM 0x02 IEEE754_CLASS_ZERO = 0x01,
#define IEEE754_CLASS_INF 0x03 IEEE754_CLASS_DNORM = 0x02,
#define IEEE754_CLASS_SNAN 0x04 IEEE754_CLASS_INF = 0x03,
#define IEEE754_CLASS_QNAN 0x05 IEEE754_CLASS_SNAN = 0x04,
IEEE754_CLASS_QNAN = 0x05,
};
/* exception numbers */ /* exception numbers */
#define IEEE754_INEXACT 0x01 #define IEEE754_INEXACT 0x01
......
...@@ -49,7 +49,7 @@ int ieee754dp_issnan(union ieee754dp x) ...@@ -49,7 +49,7 @@ int ieee754dp_issnan(union ieee754dp x)
union ieee754dp __cold ieee754dp_xcpt(union ieee754dp r, const char *op, ...) union ieee754dp __cold ieee754dp_xcpt(union ieee754dp r, const char *op, ...)
{ {
struct ieee754xctx ax; struct ieee754xctx ax;
if (!TSTX()) if (!ieee754_tstx())
return r; return r;
ax.op = op; ax.op = op;
...@@ -70,7 +70,7 @@ union ieee754dp __cold ieee754dp_nanxcpt(union ieee754dp r, const char *op, ...) ...@@ -70,7 +70,7 @@ union ieee754dp __cold ieee754dp_nanxcpt(union ieee754dp r, const char *op, ...)
if (!ieee754dp_issnan(r)) /* QNAN does not cause invalid op !! */ if (!ieee754dp_issnan(r)) /* QNAN does not cause invalid op !! */
return r; return r;
if (!SETANDTESTCX(IEEE754_INVALID_OPERATION)) { if (!ieee754_setandtestcx(IEEE754_INVALID_OPERATION)) {
/* not enabled convert to a quiet NaN */ /* not enabled convert to a quiet NaN */
DPMANT(r) &= (~DP_MBIT(DP_MBITS-1)); DPMANT(r) &= (~DP_MBIT(DP_MBITS-1));
if (ieee754dp_isnan(r)) if (ieee754dp_isnan(r))
...@@ -143,8 +143,8 @@ union ieee754dp ieee754dp_format(int sn, int xe, u64 xm) ...@@ -143,8 +143,8 @@ union ieee754dp ieee754dp_format(int sn, int xe, u64 xm)
int es = DP_EMIN - xe; int es = DP_EMIN - xe;
if (ieee754_csr.nod) { if (ieee754_csr.nod) {
SETCX(IEEE754_UNDERFLOW); ieee754_setcx(IEEE754_UNDERFLOW);
SETCX(IEEE754_INEXACT); ieee754_setcx(IEEE754_INEXACT);
switch(ieee754_csr.rm) { switch(ieee754_csr.rm) {
case IEEE754_RN: case IEEE754_RN:
...@@ -167,7 +167,7 @@ union ieee754dp ieee754dp_format(int sn, int xe, u64 xm) ...@@ -167,7 +167,7 @@ union ieee754dp ieee754dp_format(int sn, int xe, u64 xm)
&& get_rounding(sn, xm) >> (DP_MBITS + 1 + 3)) && get_rounding(sn, xm) >> (DP_MBITS + 1 + 3))
{ {
/* Not tiny after rounding */ /* Not tiny after rounding */
SETCX(IEEE754_INEXACT); ieee754_setcx(IEEE754_INEXACT);
xm = get_rounding(sn, xm); xm = get_rounding(sn, xm);
xm >>= 1; xm >>= 1;
/* Clear grs bits */ /* Clear grs bits */
...@@ -184,9 +184,9 @@ union ieee754dp ieee754dp_format(int sn, int xe, u64 xm) ...@@ -184,9 +184,9 @@ union ieee754dp ieee754dp_format(int sn, int xe, u64 xm)
} }
} }
if (xm & (DP_MBIT(3) - 1)) { if (xm & (DP_MBIT(3) - 1)) {
SETCX(IEEE754_INEXACT); ieee754_setcx(IEEE754_INEXACT);
if ((xm & (DP_HIDDEN_BIT << 3)) == 0) { if ((xm & (DP_HIDDEN_BIT << 3)) == 0) {
SETCX(IEEE754_UNDERFLOW); ieee754_setcx(IEEE754_UNDERFLOW);
} }
/* inexact must round of 3 bits /* inexact must round of 3 bits
...@@ -207,8 +207,8 @@ union ieee754dp ieee754dp_format(int sn, int xe, u64 xm) ...@@ -207,8 +207,8 @@ union ieee754dp ieee754dp_format(int sn, int xe, u64 xm)
assert(xe >= DP_EMIN); assert(xe >= DP_EMIN);
if (xe > DP_EMAX) { if (xe > DP_EMAX) {
SETCX(IEEE754_OVERFLOW); ieee754_setcx(IEEE754_OVERFLOW);
SETCX(IEEE754_INEXACT); ieee754_setcx(IEEE754_INEXACT);
/* -O can be table indexed by (rm,sn) */ /* -O can be table indexed by (rm,sn) */
switch (ieee754_csr.rm) { switch (ieee754_csr.rm) {
case IEEE754_RN: case IEEE754_RN:
...@@ -233,7 +233,7 @@ union ieee754dp ieee754dp_format(int sn, int xe, u64 xm) ...@@ -233,7 +233,7 @@ union ieee754dp ieee754dp_format(int sn, int xe, u64 xm)
/* we underflow (tiny/zero) */ /* we underflow (tiny/zero) */
assert(xe == DP_EMIN); assert(xe == DP_EMIN);
if (ieee754_csr.mx & IEEE754_UNDERFLOW) if (ieee754_csr.mx & IEEE754_UNDERFLOW)
SETCX(IEEE754_UNDERFLOW); ieee754_setcx(IEEE754_UNDERFLOW);
return builddp(sn, DP_EMIN - 1 + DP_EBIAS, xm); return builddp(sn, DP_EMIN - 1 + DP_EBIAS, xm);
} else { } else {
assert((xm >> (DP_MBITS + 1)) == 0); /* no execess */ assert((xm >> (DP_MBITS + 1)) == 0); /* no execess */
......
...@@ -74,7 +74,7 @@ extern union ieee754dp ieee754dp_format(int, int, u64); ...@@ -74,7 +74,7 @@ extern union ieee754dp ieee754dp_format(int, int, u64);
#define DPNORMRET2(s, e, m, name, a0, a1) \ #define DPNORMRET2(s, e, m, name, a0, a1) \
{ \ { \
union ieee754dp V = ieee754dp_format(s, e, m); \ union ieee754dp V = ieee754dp_format(s, e, m); \
if (TSTX()) \ if (ieee754_tstx()) \
return ieee754dp_xcpt(V, name, a0, a1); \ return ieee754dp_xcpt(V, name, a0, a1); \
else \ else \
return V; \ return V; \
......
...@@ -57,18 +57,28 @@ ...@@ -57,18 +57,28 @@
#define CLPAIR(x, y) ((x)*6+(y)) #define CLPAIR(x, y) ((x)*6+(y))
#define CLEARCX \ static inline void ieee754_clearcx(void)
(ieee754_csr.cx = 0) {
ieee754_csr.cx = 0;
}
#define SETCX(x) \ static inline void ieee754_setcx(const unsigned int flags)
(ieee754_csr.cx |= (x), ieee754_csr.sx |= (x)) {
ieee754_csr.cx |= flags;
ieee754_csr.sx |= flags;
}
#define SETANDTESTCX(x) \ static inline int ieee754_setandtestcx(const unsigned int x)
(SETCX(x), ieee754_csr.mx & (x)) {
ieee754_setcx(x);
#define TSTX() \ return ieee754_csr.mx & x;
(ieee754_csr.cx & ieee754_csr.mx) }
static inline int ieee754_tstx(void)
{
return ieee754_csr.cx & ieee754_csr.mx;
}
#define COMPXSP \ #define COMPXSP \
unsigned xm; int xe; int xs __maybe_unused; int xc unsigned xm; int xe; int xs __maybe_unused; int xc
...@@ -140,7 +150,7 @@ ...@@ -140,7 +150,7 @@
#define FLUSHDP(v, vc, vs, ve, vm) \ #define FLUSHDP(v, vc, vs, ve, vm) \
if (vc==IEEE754_CLASS_DNORM) { \ if (vc==IEEE754_CLASS_DNORM) { \
if (ieee754_csr.nod) { \ if (ieee754_csr.nod) { \
SETCX(IEEE754_INEXACT); \ ieee754_setcx(IEEE754_INEXACT); \
vc = IEEE754_CLASS_ZERO; \ vc = IEEE754_CLASS_ZERO; \
ve = DP_EMIN-1+DP_EBIAS; \ ve = DP_EMIN-1+DP_EBIAS; \
vm = 0; \ vm = 0; \
...@@ -151,7 +161,7 @@ ...@@ -151,7 +161,7 @@
#define FLUSHSP(v, vc, vs, ve, vm) \ #define FLUSHSP(v, vc, vs, ve, vm) \
if (vc==IEEE754_CLASS_DNORM) { \ if (vc==IEEE754_CLASS_DNORM) { \
if (ieee754_csr.nod) { \ if (ieee754_csr.nod) { \
SETCX(IEEE754_INEXACT); \ ieee754_setcx(IEEE754_INEXACT); \
vc = IEEE754_CLASS_ZERO; \ vc = IEEE754_CLASS_ZERO; \
ve = SP_EMIN-1+SP_EBIAS; \ ve = SP_EMIN-1+SP_EBIAS; \
vm = 0; \ vm = 0; \
......
...@@ -50,7 +50,7 @@ union ieee754sp __cold ieee754sp_xcpt(union ieee754sp r, const char *op, ...) ...@@ -50,7 +50,7 @@ union ieee754sp __cold ieee754sp_xcpt(union ieee754sp r, const char *op, ...)
{ {
struct ieee754xctx ax; struct ieee754xctx ax;
if (!TSTX()) if (!ieee754_tstx())
return r; return r;
ax.op = op; ax.op = op;
...@@ -71,7 +71,7 @@ union ieee754sp __cold ieee754sp_nanxcpt(union ieee754sp r, const char *op, ...) ...@@ -71,7 +71,7 @@ union ieee754sp __cold ieee754sp_nanxcpt(union ieee754sp r, const char *op, ...)
if (!ieee754sp_issnan(r)) /* QNAN does not cause invalid op !! */ if (!ieee754sp_issnan(r)) /* QNAN does not cause invalid op !! */
return r; return r;
if (!SETANDTESTCX(IEEE754_INVALID_OPERATION)) { if (!ieee754_setandtestcx(IEEE754_INVALID_OPERATION)) {
/* not enabled convert to a quiet NaN */ /* not enabled convert to a quiet NaN */
SPMANT(r) &= (~SP_MBIT(SP_MBITS-1)); SPMANT(r) &= (~SP_MBIT(SP_MBITS-1));
if (ieee754sp_isnan(r)) if (ieee754sp_isnan(r))
...@@ -144,8 +144,8 @@ union ieee754sp ieee754sp_format(int sn, int xe, unsigned xm) ...@@ -144,8 +144,8 @@ union ieee754sp ieee754sp_format(int sn, int xe, unsigned xm)
int es = SP_EMIN - xe; int es = SP_EMIN - xe;
if (ieee754_csr.nod) { if (ieee754_csr.nod) {
SETCX(IEEE754_UNDERFLOW); ieee754_setcx(IEEE754_UNDERFLOW);
SETCX(IEEE754_INEXACT); ieee754_setcx(IEEE754_INEXACT);
switch(ieee754_csr.rm) { switch(ieee754_csr.rm) {
case IEEE754_RN: case IEEE754_RN:
...@@ -168,7 +168,7 @@ union ieee754sp ieee754sp_format(int sn, int xe, unsigned xm) ...@@ -168,7 +168,7 @@ union ieee754sp ieee754sp_format(int sn, int xe, unsigned xm)
&& get_rounding(sn, xm) >> (SP_MBITS + 1 + 3)) && get_rounding(sn, xm) >> (SP_MBITS + 1 + 3))
{ {
/* Not tiny after rounding */ /* Not tiny after rounding */
SETCX(IEEE754_INEXACT); ieee754_setcx(IEEE754_INEXACT);
xm = get_rounding(sn, xm); xm = get_rounding(sn, xm);
xm >>= 1; xm >>= 1;
/* Clear grs bits */ /* Clear grs bits */
...@@ -183,9 +183,9 @@ union ieee754sp ieee754sp_format(int sn, int xe, unsigned xm) ...@@ -183,9 +183,9 @@ union ieee754sp ieee754sp_format(int sn, int xe, unsigned xm)
} }
} }
if (xm & (SP_MBIT(3) - 1)) { if (xm & (SP_MBIT(3) - 1)) {
SETCX(IEEE754_INEXACT); ieee754_setcx(IEEE754_INEXACT);
if ((xm & (SP_HIDDEN_BIT << 3)) == 0) { if ((xm & (SP_HIDDEN_BIT << 3)) == 0) {
SETCX(IEEE754_UNDERFLOW); ieee754_setcx(IEEE754_UNDERFLOW);
} }
/* inexact must round of 3 bits /* inexact must round of 3 bits
...@@ -206,8 +206,8 @@ union ieee754sp ieee754sp_format(int sn, int xe, unsigned xm) ...@@ -206,8 +206,8 @@ union ieee754sp ieee754sp_format(int sn, int xe, unsigned xm)
assert(xe >= SP_EMIN); assert(xe >= SP_EMIN);
if (xe > SP_EMAX) { if (xe > SP_EMAX) {
SETCX(IEEE754_OVERFLOW); ieee754_setcx(IEEE754_OVERFLOW);
SETCX(IEEE754_INEXACT); ieee754_setcx(IEEE754_INEXACT);
/* -O can be table indexed by (rm,sn) */ /* -O can be table indexed by (rm,sn) */
switch (ieee754_csr.rm) { switch (ieee754_csr.rm) {
case IEEE754_RN: case IEEE754_RN:
...@@ -232,7 +232,7 @@ union ieee754sp ieee754sp_format(int sn, int xe, unsigned xm) ...@@ -232,7 +232,7 @@ union ieee754sp ieee754sp_format(int sn, int xe, unsigned xm)
/* we underflow (tiny/zero) */ /* we underflow (tiny/zero) */
assert(xe == SP_EMIN); assert(xe == SP_EMIN);
if (ieee754_csr.mx & IEEE754_UNDERFLOW) if (ieee754_csr.mx & IEEE754_UNDERFLOW)
SETCX(IEEE754_UNDERFLOW); ieee754_setcx(IEEE754_UNDERFLOW);
return buildsp(sn, SP_EMIN - 1 + SP_EBIAS, xm); return buildsp(sn, SP_EMIN - 1 + SP_EBIAS, xm);
} else { } else {
assert((xm >> (SP_MBITS + 1)) == 0); /* no execess */ assert((xm >> (SP_MBITS + 1)) == 0); /* no execess */
......
...@@ -81,7 +81,7 @@ extern union ieee754sp ieee754sp_format(int, int, unsigned); ...@@ -81,7 +81,7 @@ extern union ieee754sp ieee754sp_format(int, int, unsigned);
{ \ { \
union ieee754sp V = ieee754sp_format(s, e, m); \ union ieee754sp V = ieee754sp_format(s, e, m); \
\ \
if (TSTX()) \ if (ieee754_tstx()) \
return ieee754sp_xcpt(V, name, a0, a1); \ return ieee754sp_xcpt(V, name, a0, a1); \
else \ else \
return V; \ return V; \
......
...@@ -34,7 +34,7 @@ union ieee754sp ieee754sp_add(union ieee754sp x, union ieee754sp y) ...@@ -34,7 +34,7 @@ union ieee754sp ieee754sp_add(union ieee754sp x, union ieee754sp y)
EXPLODEXSP; EXPLODEXSP;
EXPLODEYSP; EXPLODEYSP;
CLEARCX; ieee754_clearcx();
FLUSHXSP; FLUSHXSP;
FLUSHYSP; FLUSHYSP;
...@@ -51,7 +51,7 @@ union ieee754sp ieee754sp_add(union ieee754sp x, union ieee754sp y) ...@@ -51,7 +51,7 @@ union ieee754sp ieee754sp_add(union ieee754sp x, union ieee754sp y)
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_NORM): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_NORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF):
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "add", x, y); return ieee754sp_nanxcpt(ieee754sp_indef(), "add", x, y);
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
...@@ -74,7 +74,7 @@ union ieee754sp ieee754sp_add(union ieee754sp x, union ieee754sp y) ...@@ -74,7 +74,7 @@ union ieee754sp ieee754sp_add(union ieee754sp x, union ieee754sp y)
case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF):
if (xs == ys) if (xs == ys)
return x; return x;
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_xcpt(ieee754sp_indef(), "add", x, y); return ieee754sp_xcpt(ieee754sp_indef(), "add", x, y);
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF):
......
...@@ -35,15 +35,15 @@ int ieee754sp_cmp(union ieee754sp x, union ieee754sp y, int cmp, int sig) ...@@ -35,15 +35,15 @@ int ieee754sp_cmp(union ieee754sp x, union ieee754sp y, int cmp, int sig)
EXPLODEYSP; EXPLODEYSP;
FLUSHXSP; FLUSHXSP;
FLUSHYSP; FLUSHYSP;
CLEARCX; /* Even clear inexact flag here */ ieee754_clearcx(); /* Even clear inexact flag here */
if (ieee754sp_isnan(x) || ieee754sp_isnan(y)) { if (ieee754sp_isnan(x) || ieee754sp_isnan(y)) {
if (sig || xc == IEEE754_CLASS_SNAN || yc == IEEE754_CLASS_SNAN) if (sig || xc == IEEE754_CLASS_SNAN || yc == IEEE754_CLASS_SNAN)
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
if (cmp & IEEE754_CUN) if (cmp & IEEE754_CUN)
return 1; return 1;
if (cmp & (IEEE754_CLT | IEEE754_CGT)) { if (cmp & (IEEE754_CLT | IEEE754_CGT)) {
if (sig && SETANDTESTCX(IEEE754_INVALID_OPERATION)) if (sig && ieee754_setandtestcx(IEEE754_INVALID_OPERATION))
return ieee754si_xcpt(0, "fcmpf", x); return ieee754si_xcpt(0, "fcmpf", x);
} }
return 0; return 0;
......
...@@ -34,7 +34,7 @@ union ieee754sp ieee754sp_div(union ieee754sp x, union ieee754sp y) ...@@ -34,7 +34,7 @@ union ieee754sp ieee754sp_div(union ieee754sp x, union ieee754sp y)
EXPLODEXSP; EXPLODEXSP;
EXPLODEYSP; EXPLODEYSP;
CLEARCX; ieee754_clearcx();
FLUSHXSP; FLUSHXSP;
FLUSHYSP; FLUSHYSP;
...@@ -51,7 +51,7 @@ union ieee754sp ieee754sp_div(union ieee754sp x, union ieee754sp y) ...@@ -51,7 +51,7 @@ union ieee754sp ieee754sp_div(union ieee754sp x, union ieee754sp y)
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_NORM): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_NORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF):
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "div", x, y); return ieee754sp_nanxcpt(ieee754sp_indef(), "div", x, y);
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
...@@ -72,7 +72,7 @@ union ieee754sp ieee754sp_div(union ieee754sp x, union ieee754sp y) ...@@ -72,7 +72,7 @@ union ieee754sp ieee754sp_div(union ieee754sp x, union ieee754sp y)
*/ */
case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF):
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_xcpt(ieee754sp_indef(), "div", x, y); return ieee754sp_xcpt(ieee754sp_indef(), "div", x, y);
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF):
...@@ -89,12 +89,12 @@ union ieee754sp ieee754sp_div(union ieee754sp x, union ieee754sp y) ...@@ -89,12 +89,12 @@ union ieee754sp ieee754sp_div(union ieee754sp x, union ieee754sp y)
*/ */
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO):
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_xcpt(ieee754sp_indef(), "div", x, y); return ieee754sp_xcpt(ieee754sp_indef(), "div", x, y);
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_ZERO): case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_ZERO):
case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_ZERO): case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_ZERO):
SETCX(IEEE754_ZERO_DIVIDE); ieee754_setcx(IEEE754_ZERO_DIVIDE);
return ieee754sp_xcpt(ieee754sp_inf(xs ^ ys), "div", x, y); return ieee754sp_xcpt(ieee754sp_inf(xs ^ ys), "div", x, y);
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_NORM): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_NORM):
......
...@@ -33,13 +33,13 @@ union ieee754sp ieee754sp_fdp(union ieee754dp x) ...@@ -33,13 +33,13 @@ union ieee754sp ieee754sp_fdp(union ieee754dp x)
EXPLODEXDP; EXPLODEXDP;
CLEARCX; ieee754_clearcx();
FLUSHXDP; FLUSHXDP;
switch (xc) { switch (xc) {
case IEEE754_CLASS_SNAN: case IEEE754_CLASS_SNAN:
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "fdp"); return ieee754sp_nanxcpt(ieee754sp_indef(), "fdp");
case IEEE754_CLASS_QNAN: case IEEE754_CLASS_QNAN:
nan = buildsp(xs, SP_EMAX + 1 + SP_EBIAS, (u32) nan = buildsp(xs, SP_EMAX + 1 + SP_EBIAS, (u32)
...@@ -53,8 +53,8 @@ union ieee754sp ieee754sp_fdp(union ieee754dp x) ...@@ -53,8 +53,8 @@ union ieee754sp ieee754sp_fdp(union ieee754dp x)
return ieee754sp_zero(xs); return ieee754sp_zero(xs);
case IEEE754_CLASS_DNORM: case IEEE754_CLASS_DNORM:
/* can't possibly be sp representable */ /* can't possibly be sp representable */
SETCX(IEEE754_UNDERFLOW); ieee754_setcx(IEEE754_UNDERFLOW);
SETCX(IEEE754_INEXACT); ieee754_setcx(IEEE754_INEXACT);
if ((ieee754_csr.rm == IEEE754_RU && !xs) || if ((ieee754_csr.rm == IEEE754_RU && !xs) ||
(ieee754_csr.rm == IEEE754_RD && xs)) (ieee754_csr.rm == IEEE754_RD && xs))
return ieee754sp_xcpt(ieee754sp_mind(xs), "fdp", x); return ieee754sp_xcpt(ieee754sp_mind(xs), "fdp", x);
......
...@@ -32,7 +32,7 @@ union ieee754sp ieee754sp_fint(int x) ...@@ -32,7 +32,7 @@ union ieee754sp ieee754sp_fint(int x)
int xe; int xe;
int xs; int xs;
CLEARCX; ieee754_clearcx();
if (x == 0) if (x == 0)
return ieee754sp_zero(0); return ieee754sp_zero(0);
......
...@@ -32,7 +32,7 @@ union ieee754sp ieee754sp_flong(s64 x) ...@@ -32,7 +32,7 @@ union ieee754sp ieee754sp_flong(s64 x)
int xe; int xe;
int xs; int xs;
CLEARCX; ieee754_clearcx();
if (x == 0) if (x == 0)
return ieee754sp_zero(0); return ieee754sp_zero(0);
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
union ieee754sp ieee754sp_frexp(union ieee754sp x, int *eptr) union ieee754sp ieee754sp_frexp(union ieee754sp x, int *eptr)
{ {
COMPXSP; COMPXSP;
CLEARCX; ieee754_clearcx();
EXPLODEXSP; EXPLODEXSP;
switch (xc) { switch (xc) {
......
...@@ -30,7 +30,7 @@ union ieee754sp ieee754sp_logb(union ieee754sp x) ...@@ -30,7 +30,7 @@ union ieee754sp ieee754sp_logb(union ieee754sp x)
{ {
COMPXSP; COMPXSP;
CLEARCX; ieee754_clearcx();
EXPLODEXSP; EXPLODEXSP;
......
...@@ -32,7 +32,7 @@ union ieee754sp ieee754sp_modf(union ieee754sp x, union ieee754sp *ip) ...@@ -32,7 +32,7 @@ union ieee754sp ieee754sp_modf(union ieee754sp x, union ieee754sp *ip)
{ {
COMPXSP; COMPXSP;
CLEARCX; ieee754_clearcx();
EXPLODEXSP; EXPLODEXSP;
......
...@@ -34,7 +34,7 @@ union ieee754sp ieee754sp_mul(union ieee754sp x, union ieee754sp y) ...@@ -34,7 +34,7 @@ union ieee754sp ieee754sp_mul(union ieee754sp x, union ieee754sp y)
EXPLODEXSP; EXPLODEXSP;
EXPLODEYSP; EXPLODEYSP;
CLEARCX; ieee754_clearcx();
FLUSHXSP; FLUSHXSP;
FLUSHYSP; FLUSHYSP;
...@@ -51,7 +51,7 @@ union ieee754sp ieee754sp_mul(union ieee754sp x, union ieee754sp y) ...@@ -51,7 +51,7 @@ union ieee754sp ieee754sp_mul(union ieee754sp x, union ieee754sp y)
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_NORM): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_NORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF):
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "mul", x, y); return ieee754sp_nanxcpt(ieee754sp_indef(), "mul", x, y);
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
...@@ -72,7 +72,7 @@ union ieee754sp ieee754sp_mul(union ieee754sp x, union ieee754sp y) ...@@ -72,7 +72,7 @@ union ieee754sp ieee754sp_mul(union ieee754sp x, union ieee754sp y)
case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_ZERO): case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_ZERO):
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF):
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_xcpt(ieee754sp_indef(), "mul", x, y); return ieee754sp_xcpt(ieee754sp_indef(), "mul", x, y);
case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF):
......
...@@ -30,7 +30,7 @@ union ieee754sp ieee754sp_scalb(union ieee754sp x, int n) ...@@ -30,7 +30,7 @@ union ieee754sp ieee754sp_scalb(union ieee754sp x, int n)
{ {
COMPXSP; COMPXSP;
CLEARCX; ieee754_clearcx();
EXPLODEXSP; EXPLODEXSP;
......
...@@ -33,7 +33,7 @@ int ieee754sp_finite(union ieee754sp x) ...@@ -33,7 +33,7 @@ int ieee754sp_finite(union ieee754sp x)
union ieee754sp ieee754sp_copysign(union ieee754sp x, union ieee754sp y) union ieee754sp ieee754sp_copysign(union ieee754sp x, union ieee754sp y)
{ {
CLEARCX; ieee754_clearcx();
SPSIGN(x) = SPSIGN(y); SPSIGN(x) = SPSIGN(y);
return x; return x;
} }
...@@ -44,7 +44,7 @@ union ieee754sp ieee754sp_neg(union ieee754sp x) ...@@ -44,7 +44,7 @@ union ieee754sp ieee754sp_neg(union ieee754sp x)
COMPXSP; COMPXSP;
EXPLODEXSP; EXPLODEXSP;
CLEARCX; ieee754_clearcx();
FLUSHXSP; FLUSHXSP;
/* /*
...@@ -56,7 +56,7 @@ union ieee754sp ieee754sp_neg(union ieee754sp x) ...@@ -56,7 +56,7 @@ union ieee754sp ieee754sp_neg(union ieee754sp x)
if (xc == IEEE754_CLASS_SNAN) { if (xc == IEEE754_CLASS_SNAN) {
union ieee754sp y = ieee754sp_indef(); union ieee754sp y = ieee754sp_indef();
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
SPSIGN(y) = SPSIGN(x); SPSIGN(y) = SPSIGN(x);
return ieee754sp_nanxcpt(y, "neg"); return ieee754sp_nanxcpt(y, "neg");
} }
...@@ -70,14 +70,14 @@ union ieee754sp ieee754sp_abs(union ieee754sp x) ...@@ -70,14 +70,14 @@ union ieee754sp ieee754sp_abs(union ieee754sp x)
COMPXSP; COMPXSP;
EXPLODEXSP; EXPLODEXSP;
CLEARCX; ieee754_clearcx();
FLUSHXSP; FLUSHXSP;
/* Clear sign ALWAYS, irrespective of NaN */ /* Clear sign ALWAYS, irrespective of NaN */
SPSIGN(x) = 0; SPSIGN(x) = 0;
if (xc == IEEE754_CLASS_SNAN) { if (xc == IEEE754_CLASS_SNAN) {
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "abs"); return ieee754sp_nanxcpt(ieee754sp_indef(), "abs");
} }
......
...@@ -35,7 +35,7 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x) ...@@ -35,7 +35,7 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x)
/* take care of Inf and NaN */ /* take care of Inf and NaN */
EXPLODEXSP; EXPLODEXSP;
CLEARCX; ieee754_clearcx();
FLUSHXSP; FLUSHXSP;
/* x == INF or NAN? */ /* x == INF or NAN? */
...@@ -44,7 +44,7 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x) ...@@ -44,7 +44,7 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x)
/* sqrt(Nan) = Nan */ /* sqrt(Nan) = Nan */
return ieee754sp_nanxcpt(x, "sqrt"); return ieee754sp_nanxcpt(x, "sqrt");
case IEEE754_CLASS_SNAN: case IEEE754_CLASS_SNAN:
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "sqrt"); return ieee754sp_nanxcpt(ieee754sp_indef(), "sqrt");
case IEEE754_CLASS_ZERO: case IEEE754_CLASS_ZERO:
/* sqrt(0) = 0 */ /* sqrt(0) = 0 */
...@@ -52,7 +52,7 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x) ...@@ -52,7 +52,7 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x)
case IEEE754_CLASS_INF: case IEEE754_CLASS_INF:
if (xs) { if (xs) {
/* sqrt(-Inf) = Nan */ /* sqrt(-Inf) = Nan */
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "sqrt"); return ieee754sp_nanxcpt(ieee754sp_indef(), "sqrt");
} }
/* sqrt(+Inf) = Inf */ /* sqrt(+Inf) = Inf */
...@@ -61,7 +61,7 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x) ...@@ -61,7 +61,7 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x)
case IEEE754_CLASS_NORM: case IEEE754_CLASS_NORM:
if (xs) { if (xs) {
/* sqrt(-x) = Nan */ /* sqrt(-x) = Nan */
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "sqrt"); return ieee754sp_nanxcpt(ieee754sp_indef(), "sqrt");
} }
break; break;
...@@ -99,7 +99,7 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x) ...@@ -99,7 +99,7 @@ union ieee754sp ieee754sp_sqrt(union ieee754sp x)
} }
if (ix != 0) { if (ix != 0) {
SETCX(IEEE754_INEXACT); ieee754_setcx(IEEE754_INEXACT);
switch (ieee754_csr.rm) { switch (ieee754_csr.rm) {
case IEEE754_RP: case IEEE754_RP:
q += 2; q += 2;
......
...@@ -34,7 +34,7 @@ union ieee754sp ieee754sp_sub(union ieee754sp x, union ieee754sp y) ...@@ -34,7 +34,7 @@ union ieee754sp ieee754sp_sub(union ieee754sp x, union ieee754sp y)
EXPLODEXSP; EXPLODEXSP;
EXPLODEYSP; EXPLODEYSP;
CLEARCX; ieee754_clearcx();
FLUSHXSP; FLUSHXSP;
FLUSHYSP; FLUSHYSP;
...@@ -51,7 +51,7 @@ union ieee754sp ieee754sp_sub(union ieee754sp x, union ieee754sp y) ...@@ -51,7 +51,7 @@ union ieee754sp ieee754sp_sub(union ieee754sp x, union ieee754sp y)
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_NORM): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_NORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_DNORM):
case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_SNAN, IEEE754_CLASS_INF):
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_nanxcpt(ieee754sp_indef(), "sub", x, y); return ieee754sp_nanxcpt(ieee754sp_indef(), "sub", x, y);
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
...@@ -74,7 +74,7 @@ union ieee754sp ieee754sp_sub(union ieee754sp x, union ieee754sp y) ...@@ -74,7 +74,7 @@ union ieee754sp ieee754sp_sub(union ieee754sp x, union ieee754sp y)
case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF):
if (xs != ys) if (xs != ys)
return x; return x;
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754sp_xcpt(ieee754sp_indef(), "sub", x, y); return ieee754sp_xcpt(ieee754sp_indef(), "sub", x, y);
case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF): case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF):
......
...@@ -30,7 +30,7 @@ int ieee754sp_tint(union ieee754sp x) ...@@ -30,7 +30,7 @@ int ieee754sp_tint(union ieee754sp x)
{ {
COMPXSP; COMPXSP;
CLEARCX; ieee754_clearcx();
EXPLODEXSP; EXPLODEXSP;
FLUSHXSP; FLUSHXSP;
...@@ -39,7 +39,7 @@ int ieee754sp_tint(union ieee754sp x) ...@@ -39,7 +39,7 @@ int ieee754sp_tint(union ieee754sp x)
case IEEE754_CLASS_SNAN: case IEEE754_CLASS_SNAN:
case IEEE754_CLASS_QNAN: case IEEE754_CLASS_QNAN:
case IEEE754_CLASS_INF: case IEEE754_CLASS_INF:
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754si_xcpt(ieee754si_indef(), "sp_tint", x); return ieee754si_xcpt(ieee754si_indef(), "sp_tint", x);
case IEEE754_CLASS_ZERO: case IEEE754_CLASS_ZERO:
return 0; return 0;
...@@ -53,7 +53,7 @@ int ieee754sp_tint(union ieee754sp x) ...@@ -53,7 +53,7 @@ int ieee754sp_tint(union ieee754sp x)
return -0x80000000; return -0x80000000;
/* Set invalid. We will only use overflow for floating /* Set invalid. We will only use overflow for floating
point overflow */ point overflow */
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754si_xcpt(ieee754si_indef(), "sp_tint", x); return ieee754si_xcpt(ieee754si_indef(), "sp_tint", x);
} }
/* oh gawd */ /* oh gawd */
...@@ -99,11 +99,11 @@ int ieee754sp_tint(union ieee754sp x) ...@@ -99,11 +99,11 @@ int ieee754sp_tint(union ieee754sp x)
} }
if ((xm >> 31) != 0) { if ((xm >> 31) != 0) {
/* This can happen after rounding */ /* This can happen after rounding */
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754si_xcpt(ieee754si_indef(), "sp_tint", x); return ieee754si_xcpt(ieee754si_indef(), "sp_tint", x);
} }
if (round || sticky) if (round || sticky)
SETCX(IEEE754_INEXACT); ieee754_setcx(IEEE754_INEXACT);
} }
if (xs) if (xs)
return -xm; return -xm;
......
...@@ -30,7 +30,7 @@ s64 ieee754sp_tlong(union ieee754sp x) ...@@ -30,7 +30,7 @@ s64 ieee754sp_tlong(union ieee754sp x)
{ {
COMPXDP; /* <-- need 64-bit mantissa tmp */ COMPXDP; /* <-- need 64-bit mantissa tmp */
CLEARCX; ieee754_clearcx();
EXPLODEXSP; EXPLODEXSP;
FLUSHXSP; FLUSHXSP;
...@@ -39,7 +39,7 @@ s64 ieee754sp_tlong(union ieee754sp x) ...@@ -39,7 +39,7 @@ s64 ieee754sp_tlong(union ieee754sp x)
case IEEE754_CLASS_SNAN: case IEEE754_CLASS_SNAN:
case IEEE754_CLASS_QNAN: case IEEE754_CLASS_QNAN:
case IEEE754_CLASS_INF: case IEEE754_CLASS_INF:
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754di_xcpt(ieee754di_indef(), "sp_tlong", x); return ieee754di_xcpt(ieee754di_indef(), "sp_tlong", x);
case IEEE754_CLASS_ZERO: case IEEE754_CLASS_ZERO:
return 0; return 0;
...@@ -53,7 +53,7 @@ s64 ieee754sp_tlong(union ieee754sp x) ...@@ -53,7 +53,7 @@ s64 ieee754sp_tlong(union ieee754sp x)
return -0x8000000000000000LL; return -0x8000000000000000LL;
/* Set invalid. We will only use overflow for floating /* Set invalid. We will only use overflow for floating
point overflow */ point overflow */
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754di_xcpt(ieee754di_indef(), "sp_tlong", x); return ieee754di_xcpt(ieee754di_indef(), "sp_tlong", x);
} }
/* oh gawd */ /* oh gawd */
...@@ -95,11 +95,11 @@ s64 ieee754sp_tlong(union ieee754sp x) ...@@ -95,11 +95,11 @@ s64 ieee754sp_tlong(union ieee754sp x)
} }
if ((xm >> 63) != 0) { if ((xm >> 63) != 0) {
/* This can happen after rounding */ /* This can happen after rounding */
SETCX(IEEE754_INVALID_OPERATION); ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754di_xcpt(ieee754di_indef(), "sp_tlong", x); return ieee754di_xcpt(ieee754di_indef(), "sp_tlong", x);
} }
if (round || sticky) if (round || sticky)
SETCX(IEEE754_INEXACT); ieee754_setcx(IEEE754_INEXACT);
} }
if (xs) if (xs)
return -xm; return -xm;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment