fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / arch / arm / nwfpe / fpa11_cprt.c
index db01fbc..9843dc5 100644 (file)
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-#include <linux/config.h>
 #include "fpa11.h"
 #include "fpopcode.h"
 #include "fpa11.inl"
 #include "fpmodule.h"
 #include "fpmodule.inl"
+#include "softfloat.h"
 
 #ifdef CONFIG_FPE_NWFPE_XP
 extern flag floatx80_is_nan(floatx80);
 #endif
-extern flag float64_is_nan(float64);
-extern flag float32_is_nan(float32);
-
-void SetRoundingMode(const unsigned int opcode);
 
 unsigned int PerformFLT(const unsigned int opcode);
 unsigned int PerformFIX(const unsigned int opcode);
@@ -77,14 +73,17 @@ unsigned int EmulateCPRT(const unsigned int opcode)
 unsigned int PerformFLT(const unsigned int opcode)
 {
        FPA11 *fpa11 = GET_FPA11();
-       SetRoundingMode(opcode);
-       SetRoundingPrecision(opcode);
+       struct roundingData roundData;
+
+       roundData.mode = SetRoundingMode(opcode);
+       roundData.precision = SetRoundingPrecision(opcode);
+       roundData.exception = 0;
 
        switch (opcode & MASK_ROUNDING_PRECISION) {
        case ROUND_SINGLE:
                {
                        fpa11->fType[getFn(opcode)] = typeSingle;
-                       fpa11->fpreg[getFn(opcode)].fSingle = int32_to_float32(readRegister(getRd(opcode)));
+                       fpa11->fpreg[getFn(opcode)].fSingle = int32_to_float32(&roundData, readRegister(getRd(opcode)));
                }
                break;
 
@@ -108,6 +107,9 @@ unsigned int PerformFLT(const unsigned int opcode)
                return 0;
        }
 
+       if (roundData.exception)
+               float_raise(roundData.exception);
+
        return 1;
 }
 
@@ -115,26 +117,29 @@ unsigned int PerformFIX(const unsigned int opcode)
 {
        FPA11 *fpa11 = GET_FPA11();
        unsigned int Fn = getFm(opcode);
+       struct roundingData roundData;
 
-       SetRoundingMode(opcode);
+       roundData.mode = SetRoundingMode(opcode);
+       roundData.precision = SetRoundingPrecision(opcode);
+       roundData.exception = 0;
 
        switch (fpa11->fType[Fn]) {
        case typeSingle:
                {
-                       writeRegister(getRd(opcode), float32_to_int32(fpa11->fpreg[Fn].fSingle));
+                       writeRegister(getRd(opcode), float32_to_int32(&roundData, fpa11->fpreg[Fn].fSingle));
                }
                break;
 
        case typeDouble:
                {
-                       writeRegister(getRd(opcode), float64_to_int32(fpa11->fpreg[Fn].fDouble));
+                       writeRegister(getRd(opcode), float64_to_int32(&roundData, fpa11->fpreg[Fn].fDouble));
                }
                break;
 
 #ifdef CONFIG_FPE_NWFPE_XP
        case typeExtended:
                {
-                       writeRegister(getRd(opcode), floatx80_to_int32(fpa11->fpreg[Fn].fExtended));
+                       writeRegister(getRd(opcode), floatx80_to_int32(&roundData, fpa11->fpreg[Fn].fExtended));
                }
                break;
 #endif
@@ -143,6 +148,9 @@ unsigned int PerformFIX(const unsigned int opcode)
                return 0;
        }
 
+       if (roundData.exception)
+               float_raise(roundData.exception);
+
        return 1;
 }