]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
real.h (real_format): Add a canonical_nan_lsbs_set field.
authorRichard Sandiford <richard@codesourcery.com>
Thu, 18 Jan 2007 19:45:13 +0000 (19:45 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Thu, 18 Jan 2007 19:45:13 +0000 (19:45 +0000)
gcc/
* real.h (real_format): Add a canonical_nan_lsbs_set field.
(coldfire_single_format): Declare.
(coldfire_double_format): Likewise.
* real.c (encode_ieee_single): Use canonical_nan_lsbs_set instead
of qnan_msb_set to determine the lower bits of a canonical
NaN significand.
(encode_ieee_double): Likewise.
(encode_ieee_quad): Likewise.
(ieee_single_format): Initialize canonical_nan_lsbs_set.
(mips_single_format): Likewise.
(ieee_double_format): Likewise.
(mips_double_format): Likewise.
(ieee_extended_motorola_format): Likewise.
(ieee_extended_intel_96_format): Likewise.
(ieee_extended_intel_128_format): Likewise.
(ieee_extended_intel_96_round_53_format): Likewise.
(ibm_extended_format): Likewise.
(mips_extended_format): Likewise.
(ieee_quad_format): Likewise.
(mips_quad_format): Likewise.
(vax_f_format): Likewise.
(vax_d_format): Likewise.
(vax_g_format): Likewise.
(i370_single_format): Likewise.
(i370_double_format): Likewise.
(decimal_single_format): Likewise.
(decimal_double_format): Likewise.
(decimal_quad_format): Likewise.
(c4x_single_format): Likewise.
(c4x_extended_format): Likewise.
(real_internal_format): Likewise.
(coldfire_single_format): New real_format.
(coldfire_double_format): Likewise.
* config/pdp11/pdp11.c (pdp11_f_format): Initialize
canonical_nan_lsbs_set.
(pdp11_d_format): Likewise.
* config/m68k/m68k.c (override_options): Override REAL_FORMAT_MODE
if TARGET_COLDFIRE_CPU.

From-SVN: r120922

gcc/ChangeLog
gcc/config/m68k/m68k.c
gcc/config/pdp11/pdp11.c
gcc/real.c
gcc/real.h

index 2459a97ce57944e38b91b4cf9824a415dd82fe16..646470a8df9bb81062572b7b2e6af518b8498549 100644 (file)
@@ -1,3 +1,44 @@
+2007-01-18  Richard Sandiford  <richard@codesourcery.com>
+
+       * real.h (real_format): Add a canonical_nan_lsbs_set field.
+       (coldfire_single_format): Declare.
+       (coldfire_double_format): Likewise.
+       * real.c (encode_ieee_single): Use canonical_nan_lsbs_set instead
+       of qnan_msb_set to determine the lower bits of a canonical
+       NaN significand.
+       (encode_ieee_double): Likewise.
+       (encode_ieee_quad): Likewise.
+       (ieee_single_format): Initialize canonical_nan_lsbs_set.
+       (mips_single_format): Likewise.
+       (ieee_double_format): Likewise.
+       (mips_double_format): Likewise.
+       (ieee_extended_motorola_format): Likewise.
+       (ieee_extended_intel_96_format): Likewise.
+       (ieee_extended_intel_128_format): Likewise.
+       (ieee_extended_intel_96_round_53_format): Likewise.
+       (ibm_extended_format): Likewise.
+       (mips_extended_format): Likewise.
+       (ieee_quad_format): Likewise.
+       (mips_quad_format): Likewise.
+       (vax_f_format): Likewise.
+       (vax_d_format): Likewise.
+       (vax_g_format): Likewise.
+       (i370_single_format): Likewise.
+       (i370_double_format): Likewise.
+       (decimal_single_format): Likewise.
+       (decimal_double_format): Likewise.
+       (decimal_quad_format): Likewise.
+       (c4x_single_format): Likewise.
+       (c4x_extended_format): Likewise.
+       (real_internal_format): Likewise.
+       (coldfire_single_format): New real_format.
+       (coldfire_double_format): Likewise.
+       * config/pdp11/pdp11.c (pdp11_f_format): Initialize
+       canonical_nan_lsbs_set.
+       (pdp11_d_format): Likewise.
+       * config/m68k/m68k.c (override_options): Override REAL_FORMAT_MODE
+       if TARGET_COLDFIRE_CPU.
+
 2007-01-18  Richard Sandiford  <richard@codesourcery.com>
 
        * config/m68k/m68k-protos.h (m68k_output_pic_call): Delete.
index 03d59b98f9b082cef5eb9e12e7ea7899de8be9ef..aa91b72df00dcc91812d4479e18996c84e64cfd1 100644 (file)
@@ -512,6 +512,12 @@ override_options (void)
              : (m68k_cpu_flags & FL_COLDFIRE) != 0 ? FPUTYPE_COLDFIRE
              : FPUTYPE_68881);
 
+  if (TARGET_COLDFIRE_FPU)
+    {
+      REAL_MODE_FORMAT (SFmode) = &coldfire_single_format;
+      REAL_MODE_FORMAT (DFmode) = &coldfire_double_format;
+    }
+
   /* Sanity check to ensure that msep-data and mid-sahred-library are not
    * both specified together.  Doing so simply doesn't make sense.
    */
index 4036b12449a03306f44d2b10189eda1d33823f08..3e295b174b6e112a10ca9b77f1ddd76e4e1ef24c 100644 (file)
@@ -78,6 +78,7 @@ const struct real_format pdp11_f_format =
     false,
     false,
     false,
+    false,
     false
   };
 
@@ -96,6 +97,7 @@ const struct real_format pdp11_d_format =
     false,
     false,
     false,
+    false,
     false
   };
 
index b6e5ed6ee3e9a5a3f79bc1223b47c5925667f21b..b966917ae8f176cdc7b14e008299578432551b0c 100644 (file)
@@ -2681,18 +2681,12 @@ encode_ieee_single (const struct real_format *fmt, long *buf,
       if (fmt->has_nans)
        {
          if (r->canonical)
-           sig = 0;
+           sig = (fmt->canonical_nan_lsbs_set ? (1 << 22) - 1 : 0);
          if (r->signalling == fmt->qnan_msb_set)
            sig &= ~(1 << 22);
          else
            sig |= 1 << 22;
-         /* We overload qnan_msb_set here: it's only clear for
-            mips_ieee_single, which wants all mantissa bits but the
-            quiet/signalling one set in canonical NaNs (at least
-            Quiet ones).  */
-         if (r->canonical && !fmt->qnan_msb_set)
-           sig |= (1 << 22) - 1;
-         else if (sig == 0)
+         if (sig == 0)
            sig = 1 << 21;
 
          image |= 255 << 23;
@@ -2787,7 +2781,8 @@ const struct real_format ieee_single_format =
     true,
     true,
     true,
-    true
+    true,
+    false
   };
 
 const struct real_format mips_single_format =
@@ -2806,9 +2801,29 @@ const struct real_format mips_single_format =
     true,
     true,
     true,
-    false
+    false,
+    true
   };
 
+const struct real_format coldfire_single_format =
+  {
+    encode_ieee_single,
+    decode_ieee_single,
+    2,
+    1,
+    24,
+    24,
+    -125,
+    128,
+    31,
+    31,
+    true,
+    true,
+    true,
+    true,
+    true,
+    true
+  };
 \f
 /* IEEE double-precision format.  */
 
@@ -2860,21 +2875,23 @@ encode_ieee_double (const struct real_format *fmt, long *buf,
       if (fmt->has_nans)
        {
          if (r->canonical)
-           sig_hi = sig_lo = 0;
+           {
+             if (fmt->canonical_nan_lsbs_set)
+               {
+                 sig_hi = (1 << 19) - 1;
+                 sig_lo = 0xffffffff;
+               }
+             else
+               {
+                 sig_hi = 0;
+                 sig_lo = 0;
+               }
+           }
          if (r->signalling == fmt->qnan_msb_set)
            sig_hi &= ~(1 << 19);
          else
            sig_hi |= 1 << 19;
-         /* We overload qnan_msb_set here: it's only clear for
-            mips_ieee_single, which wants all mantissa bits but the
-            quiet/signalling one set in canonical NaNs (at least
-            Quiet ones).  */
-         if (r->canonical && !fmt->qnan_msb_set)
-           {
-             sig_hi |= (1 << 19) - 1;
-             sig_lo = 0xffffffff;
-           }
-         else if (sig_hi == 0 && sig_lo == 0)
+         if (sig_hi == 0 && sig_lo == 0)
            sig_hi = 1 << 18;
 
          image_hi |= 2047 << 20;
@@ -3012,7 +3029,8 @@ const struct real_format ieee_double_format =
     true,
     true,
     true,
-    true
+    true,
+    false
   };
 
 const struct real_format mips_double_format =
@@ -3031,9 +3049,29 @@ const struct real_format mips_double_format =
     true,
     true,
     true,
-    false
+    false,
+    true
   };
 
+const struct real_format coldfire_double_format =
+  {
+    encode_ieee_double,
+    decode_ieee_double,
+    2,
+    1,
+    53,
+    53,
+    -1021,
+    1024,
+    63,
+    63,
+    true,
+    true,
+    true,
+    true,
+    true,
+    true
+  };
 \f
 /* IEEE extended real format.  This comes in three flavors: Intel's as
    a 12 byte image, Intel's as a 16 byte image, and Motorola's.  Intel
@@ -3361,7 +3399,8 @@ const struct real_format ieee_extended_motorola_format =
     true,
     true,
     true,
-    true
+    true,
+    false
   };
 
 const struct real_format ieee_extended_intel_96_format =
@@ -3380,7 +3419,8 @@ const struct real_format ieee_extended_intel_96_format =
     true,
     true,
     true,
-    true
+    true,
+    false
   };
 
 const struct real_format ieee_extended_intel_128_format =
@@ -3399,7 +3439,8 @@ const struct real_format ieee_extended_intel_128_format =
     true,
     true,
     true,
-    true
+    true,
+    false
   };
 
 /* The following caters to i386 systems that set the rounding precision
@@ -3420,7 +3461,8 @@ const struct real_format ieee_extended_intel_96_round_53_format =
     true,
     true,
     true,
-    true
+    true,
+    false
   };
 \f
 /* IBM 128-bit extended precision format: a pair of IEEE double precision
@@ -3506,7 +3548,8 @@ const struct real_format ibm_extended_format =
     true,
     true,
     true,
-    true
+    true,
+    false
   };
 
 const struct real_format mips_extended_format =
@@ -3525,7 +3568,8 @@ const struct real_format mips_extended_format =
     true,
     true,
     true,
-    false
+    false,
+    true
   };
 
 \f
@@ -3575,8 +3619,11 @@ encode_ieee_quad (const struct real_format *fmt, long *buf,
 
          if (r->canonical)
            {
-             /* Don't use bits from the significand.  The
-                initialization above is right.  */
+             if (fmt->canonical_nan_lsbs_set)
+               {
+                 image3 |= 0x7fff;
+                 image2 = image1 = image0 = 0xffffffff;
+               }
            }
          else if (HOST_BITS_PER_LONG == 32)
            {
@@ -3598,16 +3645,7 @@ encode_ieee_quad (const struct real_format *fmt, long *buf,
            image3 &= ~0x8000;
          else
            image3 |= 0x8000;
-         /* We overload qnan_msb_set here: it's only clear for
-            mips_ieee_single, which wants all mantissa bits but the
-            quiet/signalling one set in canonical NaNs (at least
-            Quiet ones).  */
-         if (r->canonical && !fmt->qnan_msb_set)
-           {
-             image3 |= 0x7fff;
-             image2 = image1 = image0 = 0xffffffff;
-           }
-         else if (((image3 & 0xffff) | image2 | image1 | image0) == 0)
+         if (((image3 & 0xffff) | image2 | image1 | image0) == 0)
            image3 |= 0x4000;
        }
       else
@@ -3792,7 +3830,8 @@ const struct real_format ieee_quad_format =
     true,
     true,
     true,
-    true
+    true,
+    false
   };
 
 const struct real_format mips_quad_format =
@@ -3811,7 +3850,8 @@ const struct real_format mips_quad_format =
     true,
     true,
     true,
-    false
+    false,
+    true
   };
 \f
 /* Descriptions of VAX floating point formats can be found beginning at
@@ -4109,6 +4149,7 @@ const struct real_format vax_f_format =
     false,
     false,
     false,
+    false,
     false
   };
 
@@ -4128,6 +4169,7 @@ const struct real_format vax_d_format =
     false,
     false,
     false,
+    false,
     false
   };
 
@@ -4147,6 +4189,7 @@ const struct real_format vax_g_format =
     false,
     false,
     false,
+    false,
     false
   };
 \f
@@ -4323,6 +4366,7 @@ const struct real_format i370_single_format =
     false,
     false, /* ??? The encoding does allow for "unnormals".  */
     false, /* ??? The encoding does allow for "unnormals".  */
+    false,
     false
   };
 
@@ -4342,6 +4386,7 @@ const struct real_format i370_double_format =
     false,
     false, /* ??? The encoding does allow for "unnormals".  */
     false, /* ??? The encoding does allow for "unnormals".  */
+    false,
     false
   };
 \f
@@ -4416,7 +4461,8 @@ const struct real_format decimal_single_format =
     true,
     true,
     true, 
-    true
+    true,
+    false
   };
 
 /* Double precision decimal floating point (IEEE 754R). */
@@ -4436,7 +4482,8 @@ const struct real_format decimal_double_format =
     true,
     true,
     true,
-    true
+    true,
+    false
   };
 
 /* Quad precision decimal floating point (IEEE 754R). */
@@ -4456,7 +4503,8 @@ const struct real_format decimal_quad_format =
     true,
     true, 
     true, 
-    true
+    true,
+    false
   };
 \f
 /* The "twos-complement" c4x format is officially defined as
@@ -4665,6 +4713,7 @@ const struct real_format c4x_single_format =
     false,
     false,
     false,
+    false,
     false
   };
 
@@ -4684,6 +4733,7 @@ const struct real_format c4x_extended_format =
     false,
     false,
     false,
+    false,
     false
   };
 
@@ -4728,7 +4778,8 @@ const struct real_format real_internal_format =
     true,
     false,
     true,
-    true
+    true,
+    false
   };
 \f
 /* Calculate the square root of X in mode MODE, and store the result
index 4198b02aee6e3bdf86f1c2de7e7bab575b1c0a46..81ee855dbfae5b1a5df3f1ee4933cafda2bb1ac6 100644 (file)
@@ -155,6 +155,7 @@ struct real_format
   bool has_denorm;
   bool has_signed_zero;
   bool qnan_msb_set;
+  bool canonical_nan_lsbs_set;
 };
 
 
@@ -255,8 +256,10 @@ extern unsigned int real_hash (const REAL_VALUE_TYPE *);
 /* Target formats defined in real.c.  */
 extern const struct real_format ieee_single_format;
 extern const struct real_format mips_single_format;
+extern const struct real_format coldfire_single_format;
 extern const struct real_format ieee_double_format;
 extern const struct real_format mips_double_format;
+extern const struct real_format coldfire_double_format;
 extern const struct real_format ieee_extended_motorola_format;
 extern const struct real_format ieee_extended_intel_96_format;
 extern const struct real_format ieee_extended_intel_96_round_53_format;