MIPS: math-emu: Add z argument macros
[deliverable/linux.git] / arch / mips / math-emu / sp_maddf.c
index dd1dd83e34eb0ba604a2b88c9e4db20c96174d8c..86e1d0b254460c096992956ec6149080329130e9 100644 (file)
 
 #include "ieee754sp.h"
 
-union ieee754sp ieee754sp_maddf(union ieee754sp z, union ieee754sp x,
-                               union ieee754sp y)
+enum maddf_flags {
+       maddf_negate_product    = 1 << 0,
+};
+
+static union ieee754sp _sp_maddf(union ieee754sp z, union ieee754sp x,
+                                union ieee754sp y, enum maddf_flags flags)
 {
        int re;
        int rs;
@@ -32,15 +36,15 @@ union ieee754sp ieee754sp_maddf(union ieee754sp z, union ieee754sp x,
 
        COMPXSP;
        COMPYSP;
-       u32 zm; int ze; int zs __maybe_unused; int zc;
+       COMPZSP;
 
        EXPLODEXSP;
        EXPLODEYSP;
-       EXPLODESP(z, zc, zs, ze, zm)
+       EXPLODEZSP;
 
        FLUSHXSP;
        FLUSHYSP;
-       FLUSHSP(z, zc, zs, ze, zm);
+       FLUSHZSP;
 
        ieee754_clearcx();
 
@@ -49,7 +53,7 @@ union ieee754sp ieee754sp_maddf(union ieee754sp z, union ieee754sp x,
                ieee754_setcx(IEEE754_INVALID_OPERATION);
                return ieee754sp_nanxcpt(z);
        case IEEE754_CLASS_DNORM:
-               SPDNORMx(zm, ze);
+               SPDNORMZ;
        /* QNAN is handled separately below */
        }
 
@@ -154,6 +158,8 @@ union ieee754sp ieee754sp_maddf(union ieee754sp z, union ieee754sp x,
 
        re = xe + ye;
        rs = xs ^ ys;
+       if (flags & maddf_negate_product)
+               rs ^= 1;
 
        /* shunt to top of word */
        xm <<= 32 - (SP_FBITS + 1);
@@ -253,3 +259,15 @@ union ieee754sp ieee754sp_maddf(union ieee754sp z, union ieee754sp x,
        }
        return ieee754sp_format(zs, ze, zm);
 }
+
+union ieee754sp ieee754sp_maddf(union ieee754sp z, union ieee754sp x,
+                               union ieee754sp y)
+{
+       return _sp_maddf(z, x, y, 0);
+}
+
+union ieee754sp ieee754sp_msubf(union ieee754sp z, union ieee754sp x,
+                               union ieee754sp y)
+{
+       return _sp_maddf(z, x, y, maddf_negate_product);
+}
This page took 0.03023 seconds and 5 git commands to generate.