]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
MIPS: Correct the handling of reserved FCSR bits
authorMaciej W. Rozycki <macro@codesourcery.com>
Thu, 22 Aug 2013 16:50:20 +0000 (17:50 +0100)
committerMaciej W. Rozycki <macro@codesourcery.com>
Thu, 22 Aug 2013 16:55:17 +0000 (17:55 +0100)
Reserved bits in the Floating-Point Control and Status Register (FCSR)
should not be implicitly cleared by fedisableexcept or feenableexcept,
there is no reason to.  Among these are the 8 condition codes and one of
the two bits reserved for architecture implementers (bits #22 & #21).

As to the latter, there is no reason to treat any of them as reserved
either, they should be user controllable and settable via __fpu_control
override as the user sees fit.  For example in processors implemented by
MIPS Technologies, such as the 5Kf or the 24Kf, these bits are used to
change the treatment of denormalised operands and tiny results: bit #22
is Flush Override (FO) and bit #21 is Flush to Nearest (FN).  They cause
non-IEEE-compliant behaviour, but some programs may have a use for such
modes of operation; the library should not obstruct such use just as it
does not for the architectural Flush to Zero (FS) bit (bit #24).

Therefore the change adjusts the reserved mask accordingly and also
documents the distinction between bits 22:21 and 20:18.

ports/ChangeLog.mips
ports/sysdeps/mips/fpu/fedisblxcpt.c
ports/sysdeps/mips/fpu/feenablxcpt.c
ports/sysdeps/mips/fpu_control.h

index 6e42b77de3b7b861c1f3fcffcb10d4126a45330a..9b952c61015cc33f7aa15d1664b96e60e7ddf909 100644 (file)
@@ -1,3 +1,12 @@
+2013-08-22  Maciej W. Rozycki  <macro@codesourcery.com>
+
+       * sysdeps/mips/fpu_control.h: Document bits reserved for
+       architecture implementers.
+       (_FPU_RESERVED): Clear bit #21.
+       * sysdeps/mips/fpu/fedisblxcpt.c (fedisableexcept): Don't clear
+       reserved bits.
+       * sysdeps/mips/fpu/feenablxcpt.c (feenableexcept): Likewise.
+
 2013-07-02  Joseph Myers  <joseph@codesourcery.com>
 
        * sysdeps/mips/mips32/libm-test-ulps: Regenerated.
index 1db197f21300e5963be30636cea712bc069ea0c6..7498c0c27c56349a788548e1498922164e0b2a6d 100644 (file)
@@ -34,7 +34,6 @@ fedisableexcept (int excepts)
   excepts &= FE_ALL_EXCEPT;
 
   new_exc &= ~(excepts << ENABLE_SHIFT);
-  new_exc &= ~_FPU_RESERVED;
   _FPU_SETCW (new_exc);
 
   return old_exc;
index 2a3a07618db8d344441d1190f0848eae0b2b27e8..bca8e3d23e8c591f1d3e16b2e8144b021dd0015b 100644 (file)
@@ -34,7 +34,6 @@ feenableexcept (int excepts)
   excepts &= FE_ALL_EXCEPT;
 
   new_exc |= excepts << ENABLE_SHIFT;
-  new_exc &= ~_FPU_RESERVED;
   _FPU_SETCW (new_exc);
 
   return old_exc;
index 6aecb3bc8b15d63658341160ed6c8dcf8015ef7b..770cbb31d843ab661d0a674d70af0075e3dd411a 100644 (file)
@@ -28,7 +28,8 @@
  *           causing unimplemented operation exception.  This bit is only
  *           available for MIPS III and newer.
  * 23     -> Condition bit
- * 22-18  -> reserved (read as 0, write with 0)
+ * 22-21  -> reserved for architecture implementers
+ * 20-18  -> reserved (read as 0, write with 0)
  * 17     -> cause bit for unimplemented operation
  * 16     -> cause bit for invalid exception
  * 15     -> cause bit for division by zero exception
@@ -84,7 +85,7 @@ extern fpu_control_t __fpu_control;
 #define _FPU_RC_UP      0x2
 #define _FPU_RC_DOWN    0x3
 
-#define _FPU_RESERVED 0xfebc0000  /* Reserved bits in cw */
+#define _FPU_RESERVED 0xfe9c0000  /* Reserved bits in cw */
 
 
 /* The fdlibm code requires strict IEEE double precision arithmetic,