Skip to content

Commit

Permalink
MIPS: math-emu: Turn macros into functions where possible.
Browse files Browse the repository at this point in the history
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  • Loading branch information
Ralf Baechle committed May 21, 2014
1 parent bee1653 commit 9e8bad1
Show file tree
Hide file tree
Showing 39 changed files with 143 additions and 131 deletions.
6 changes: 3 additions & 3 deletions arch/mips/math-emu/dp_add.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y)
EXPLODEXDP;
EXPLODEYDP;

CLEARCX;
ieee754_clearcx();

FLUSHXDP;
FLUSHYDP;
Expand All @@ -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_DNORM):
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);

case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
Expand All @@ -75,7 +75,7 @@ union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y)
case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF):
if (xs == ys)
return x;
SETCX(IEEE754_INVALID_OPERATION);
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_xcpt(ieee754dp_indef(), "add", x, y);

case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF):
Expand Down
6 changes: 3 additions & 3 deletions arch/mips/math-emu/dp_cmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ int ieee754dp_cmp(union ieee754dp x, union ieee754dp y, int cmp, int sig)
EXPLODEYDP;
FLUSHXDP;
FLUSHYDP;
CLEARCX; /* Even clear inexact flag here */
ieee754_clearcx(); /* Even clear inexact flag here */

if (ieee754dp_isnan(x) || ieee754dp_isnan(y)) {
if (sig || xc == IEEE754_CLASS_SNAN || yc == IEEE754_CLASS_SNAN)
SETCX(IEEE754_INVALID_OPERATION);
ieee754_setcx(IEEE754_INVALID_OPERATION);
if (cmp & IEEE754_CUN)
return 1;
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 0;
Expand Down
10 changes: 5 additions & 5 deletions arch/mips/math-emu/dp_div.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ union ieee754dp ieee754dp_div(union ieee754dp x, union ieee754dp y)
EXPLODEXDP;
EXPLODEYDP;

CLEARCX;
ieee754_clearcx();

FLUSHXDP;
FLUSHYDP;
Expand All @@ -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_DNORM):
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);

case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
Expand All @@ -72,7 +72,7 @@ union ieee754dp ieee754dp_div(union ieee754dp x, union ieee754dp y)
*/

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);

case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF):
Expand All @@ -89,12 +89,12 @@ union ieee754dp ieee754dp_div(union ieee754dp x, union ieee754dp y)
*/

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);

case CLPAIR(IEEE754_CLASS_NORM, 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);

case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_NORM):
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/math-emu/dp_fint.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ union ieee754dp ieee754dp_fint(int x)
int xe;
int xs;

CLEARCX;
ieee754_clearcx();

if (x == 0)
return ieee754dp_zero(0);
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/math-emu/dp_flong.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ union ieee754dp ieee754dp_flong(s64 x)
int xe;
int xs;

CLEARCX;
ieee754_clearcx();

if (x == 0)
return ieee754dp_zero(0);
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/math-emu/dp_frexp.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
union ieee754dp ieee754dp_frexp(union ieee754dp x, int *eptr)
{
COMPXDP;
CLEARCX;
ieee754_clearcx();
EXPLODEXDP;

switch (xc) {
Expand Down
4 changes: 2 additions & 2 deletions arch/mips/math-emu/dp_fsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ union ieee754dp ieee754dp_fsp(union ieee754sp x)

EXPLODEXSP;

CLEARCX;
ieee754_clearcx();

FLUSHXSP;

switch (xc) {
case IEEE754_CLASS_SNAN:
SETCX(IEEE754_INVALID_OPERATION);
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "fsp");
case IEEE754_CLASS_QNAN:
return ieee754dp_nanxcpt(builddp(xs,
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/math-emu/dp_logb.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ union ieee754dp ieee754dp_logb(union ieee754dp x)
{
COMPXDP;

CLEARCX;
ieee754_clearcx();

EXPLODEXDP;

Expand Down
2 changes: 1 addition & 1 deletion arch/mips/math-emu/dp_modf.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ union ieee754dp ieee754dp_modf(union ieee754dp x, union ieee754dp *ip)
{
COMPXDP;

CLEARCX;
ieee754_clearcx();

EXPLODEXDP;

Expand Down
6 changes: 3 additions & 3 deletions arch/mips/math-emu/dp_mul.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ union ieee754dp ieee754dp_mul(union ieee754dp x, union ieee754dp y)
EXPLODEXDP;
EXPLODEYDP;

CLEARCX;
ieee754_clearcx();

FLUSHXDP;
FLUSHYDP;
Expand All @@ -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_DNORM):
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);

case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
Expand All @@ -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_ZERO, IEEE754_CLASS_INF):
SETCX(IEEE754_INVALID_OPERATION);
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_xcpt(ieee754dp_indef(), "mul", x, y);

case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF):
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/math-emu/dp_scalb.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ union ieee754dp ieee754dp_scalb(union ieee754dp x, int n)
{
COMPXDP;

CLEARCX;
ieee754_clearcx();

EXPLODEXDP;

Expand Down
10 changes: 5 additions & 5 deletions arch/mips/math-emu/dp_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int ieee754dp_finite(union ieee754dp x)

union ieee754dp ieee754dp_copysign(union ieee754dp x, union ieee754dp y)
{
CLEARCX;
ieee754_clearcx();
DPSIGN(x) = DPSIGN(y);
return x;
}
Expand All @@ -44,7 +44,7 @@ union ieee754dp ieee754dp_neg(union ieee754dp x)
COMPXDP;

EXPLODEXDP;
CLEARCX;
ieee754_clearcx();
FLUSHXDP;

/*
Expand All @@ -56,7 +56,7 @@ union ieee754dp ieee754dp_neg(union ieee754dp x)

if (xc == IEEE754_CLASS_SNAN) {
union ieee754dp y = ieee754dp_indef();
SETCX(IEEE754_INVALID_OPERATION);
ieee754_setcx(IEEE754_INVALID_OPERATION);
DPSIGN(y) = DPSIGN(x);
return ieee754dp_nanxcpt(y, "neg");
}
Expand All @@ -70,14 +70,14 @@ union ieee754dp ieee754dp_abs(union ieee754dp x)
COMPXDP;

EXPLODEXDP;
CLEARCX;
ieee754_clearcx();
FLUSHXDP;

/* Clear sign ALWAYS, irrespective of NaN */
DPSIGN(x) = 0;

if (xc == IEEE754_CLASS_SNAN) {
SETCX(IEEE754_INVALID_OPERATION);
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "abs");
}

Expand Down
8 changes: 4 additions & 4 deletions arch/mips/math-emu/dp_sqrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x)
COMPXDP;

EXPLODEXDP;
CLEARCX;
ieee754_clearcx();
FLUSHXDP;

/* x == INF or NAN? */
Expand All @@ -51,15 +51,15 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x)
/* sqrt(Nan) = Nan */
return ieee754dp_nanxcpt(x, "sqrt");
case IEEE754_CLASS_SNAN:
SETCX(IEEE754_INVALID_OPERATION);
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "sqrt");
case IEEE754_CLASS_ZERO:
/* sqrt(0) = 0 */
return x;
case IEEE754_CLASS_INF:
if (xs) {
/* sqrt(-Inf) = Nan */
SETCX(IEEE754_INVALID_OPERATION);
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "sqrt");
}
/* sqrt(+Inf) = Inf */
Expand All @@ -70,7 +70,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x)
case IEEE754_CLASS_NORM:
if (xs) {
/* sqrt(-x) = Nan */
SETCX(IEEE754_INVALID_OPERATION);
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_nanxcpt(ieee754dp_indef(), "sqrt");
}
break;
Expand Down
6 changes: 3 additions & 3 deletions arch/mips/math-emu/dp_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ union ieee754dp ieee754dp_sub(union ieee754dp x, union ieee754dp y)
EXPLODEXDP;
EXPLODEYDP;

CLEARCX;
ieee754_clearcx();

FLUSHXDP;
FLUSHYDP;
Expand All @@ -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_DNORM):
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);

case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_QNAN):
Expand All @@ -74,7 +74,7 @@ union ieee754dp ieee754dp_sub(union ieee754dp x, union ieee754dp y)
case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_INF):
if (xs != ys)
return x;
SETCX(IEEE754_INVALID_OPERATION);
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754dp_xcpt(ieee754dp_indef(), "sub", x, y);

case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF):
Expand Down
10 changes: 5 additions & 5 deletions arch/mips/math-emu/dp_tint.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int ieee754dp_tint(union ieee754dp x)
{
COMPXDP;

CLEARCX;
ieee754_clearcx();

EXPLODEXDP;
FLUSHXDP;
Expand All @@ -39,7 +39,7 @@ int ieee754dp_tint(union ieee754dp x)
case IEEE754_CLASS_SNAN:
case IEEE754_CLASS_QNAN:
case IEEE754_CLASS_INF:
SETCX(IEEE754_INVALID_OPERATION);
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754si_xcpt(ieee754si_indef(), "dp_tint", x);
case IEEE754_CLASS_ZERO:
return 0;
Expand All @@ -50,7 +50,7 @@ int ieee754dp_tint(union ieee754dp x)
if (xe > 31) {
/* Set invalid. We will only use overflow for floating
point overflow */
SETCX(IEEE754_INVALID_OPERATION);
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754si_xcpt(ieee754si_indef(), "dp_tint", x);
}
/* oh gawd */
Expand Down Expand Up @@ -95,11 +95,11 @@ int ieee754dp_tint(union ieee754dp x)
/* look for valid corner case 0x80000000 */
if ((xm >> 31) != 0 && (xs == 0 || xm != 0x80000000)) {
/* This can happen after rounding */
SETCX(IEEE754_INVALID_OPERATION);
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754si_xcpt(ieee754si_indef(), "dp_tint", x);
}
if (round || sticky)
SETCX(IEEE754_INEXACT);
ieee754_setcx(IEEE754_INEXACT);
}
if (xs)
return -xm;
Expand Down
10 changes: 5 additions & 5 deletions arch/mips/math-emu/dp_tlong.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ s64 ieee754dp_tlong(union ieee754dp x)
{
COMPXDP;

CLEARCX;
ieee754_clearcx();

EXPLODEXDP;
FLUSHXDP;
Expand All @@ -39,7 +39,7 @@ s64 ieee754dp_tlong(union ieee754dp x)
case IEEE754_CLASS_SNAN:
case IEEE754_CLASS_QNAN:
case IEEE754_CLASS_INF:
SETCX(IEEE754_INVALID_OPERATION);
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754di_xcpt(ieee754di_indef(), "dp_tlong", x);
case IEEE754_CLASS_ZERO:
return 0;
Expand All @@ -53,7 +53,7 @@ s64 ieee754dp_tlong(union ieee754dp x)
return -0x8000000000000000LL;
/* Set invalid. We will only use overflow for floating
point overflow */
SETCX(IEEE754_INVALID_OPERATION);
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754di_xcpt(ieee754di_indef(), "dp_tlong", x);
}
/* oh gawd */
Expand Down Expand Up @@ -99,11 +99,11 @@ s64 ieee754dp_tlong(union ieee754dp x)
}
if ((xm >> 63) != 0) {
/* This can happen after rounding */
SETCX(IEEE754_INVALID_OPERATION);
ieee754_setcx(IEEE754_INVALID_OPERATION);
return ieee754di_xcpt(ieee754di_indef(), "dp_tlong", x);
}
if (round || sticky)
SETCX(IEEE754_INEXACT);
ieee754_setcx(IEEE754_INEXACT);
}
if (xs)
return -xm;
Expand Down
4 changes: 2 additions & 2 deletions arch/mips/math-emu/ieee754.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int __cold ieee754si_xcpt(int r, const char *op, ...)
{
struct ieee754xctx ax;

if (!TSTX())
if (!ieee754_tstx())
return r;
ax.op = op;
ax.rt = IEEE754_RT_SI;
Expand All @@ -116,7 +116,7 @@ s64 __cold ieee754di_xcpt(s64 r, const char *op, ...)
{
struct ieee754xctx ax;

if (!TSTX())
if (!ieee754_tstx())
return r;
ax.op = op;
ax.rt = IEEE754_RT_DI;
Expand Down
Loading

0 comments on commit 9e8bad1

Please sign in to comment.