real.c (c4xtoe, toc4x): Do some special conversion on long doubles for the c4x target.
authorHerman A.J. ten Brugge <Haj.Ten.Brugge@net.HCC.nl>
Wed, 9 Jan 2002 20:48:48 +0000 (21:48 +0100)
committerRichard Henderson <rth@gcc.gnu.org>
Wed, 9 Jan 2002 20:48:48 +0000 (12:48 -0800)
        * real.c (c4xtoe, toc4x): Do some special conversion on long doubles
        for the c4x target. Also improve layout.

From-SVN: r48688

gcc/ChangeLog
gcc/real.c

index 65dc90f93cb98bcad2e77b21b7efeda3497516eb..4623baa7b07a9dbf596492b223747aa457cdafb3 100644 (file)
@@ -1,3 +1,8 @@
+2002-01-09  Herman A.J. ten Brugge  <Haj.Ten.Brugge@net.HCC.nl>
+
+        * real.c (c4xtoe, toc4x): Do some special conversion on long doubles
+        for the c4x target. Also improve layout.
+
 2002-01-09  Richard Henderson  <rth@redhat.com>
 
        * config/m32r/m32r.c (move_src_operand): Fix 32-bit int test.
index a52ef0b900bc13e488c4e66adb4931f3c8e61db9..1986cad3dae6816c5b5fe95c101d722afa940fe9 100644 (file)
@@ -6064,16 +6064,25 @@ c4xtoe (d, e, mode)
      enum machine_mode mode;
 {
   UEMUSHORT y[NI];
+  UEMUSHORT dn[4];
   int r;
   int isnegative;
   int size;
   int i;
   int carry;
 
+  dn[0] = d[0];
+  dn[1] = d[1];
+  if (mode != QFmode)
+    {
+      dn[2] = d[3] << 8;
+      dn[3] = 0;
+    }
+
   /* Short-circuit the zero case.  */
-  if ((d[0] == 0x8000)
-      && (d[1] == 0x0000)
-      && ((mode == QFmode) || ((d[2] == 0x0000) && (d[3] == 0x0000))))
+  if ((dn[0] == 0x8000)
+      && (dn[1] == 0x0000)
+      && ((mode == QFmode) || ((dn[2] == 0x0000) && (dn[3] == 0x0000))))
     {
       e[0] = 0;
       e[1] = 0;
@@ -6085,87 +6094,79 @@ c4xtoe (d, e, mode)
     }
 
   ecleaz (y);                  /* start with a zero */
-  r = d[0];                    /* get sign/exponent part */
+  r = dn[0];                   /* get sign/exponent part */
   if (r & (unsigned int) 0x0080)
-  {
-     y[0] = 0xffff;            /* fill in our sign */
-     isnegative = TRUE;
-  }
+    {
+      y[0] = 0xffff;           /* fill in our sign */
+      isnegative = TRUE;
+    }
   else
-  {
-     isnegative = FALSE;
-  }
+    isnegative = FALSE;
 
   r >>= 8;                     /* Shift exponent word down 8 bits.  */
   if (r & 0x80)                        /* Make the exponent negative if it is.  */
-  {
-     r = r | (~0 & ~0xff);
-  }
+    r = r | (~0 & ~0xff);
 
   if (isnegative)
-  {
-     /* Now do the high order mantissa.  We don't "or" on the high bit
-       because it is 2 (not 1) and is handled a little differently
-       below.  */
-     y[M] = d[0] & 0x7f;
+    {
+      /* Now do the high order mantissa.  We don't "or" on the high bit
+        because it is 2 (not 1) and is handled a little differently
+        below.  */
+      y[M] = dn[0] & 0x7f;
 
-     y[M+1] = d[1];
-     if (mode != QFmode)       /* There are only 2 words in QFmode.  */
-     {
-       y[M+2] = d[2];          /* Fill in the rest of our mantissa.  */
-       y[M+3] = d[3];
-       size = 4;
-     }
-     else
-     {
+      y[M+1] = dn[1];
+      if (mode != QFmode)      /* There are only 2 words in QFmode.  */
+        {
+         y[M+2] = dn[2];       /* Fill in the rest of our mantissa.  */
+         y[M+3] = dn[3];
+         size = 4;
+        }
+      else
        size = 2;
-     }
-     eshift(y, -8);
+      eshift(y, -8);
 
-     /* Now do the two's complement on the data.  */
+      /* Now do the two's complement on the data.  */
 
-     carry = 1;        /* Initially add 1 for the two's complement.  */
-     for (i=size + M; i > M; i--)
-     {
-       if (carry && (y[i] == 0x0000))
-       {
-          /* We overflowed into the next word, carry is the same.  */
-          y[i] = carry ? 0x0000 : 0xffff;
-       }
-       else
-       {
-          /* No overflow, just invert and add carry.  */
-          y[i] = ((~y[i]) + carry) & 0xffff;
-          carry = 0;
-       }
-     }
-
-     if (carry)
-     {
-       eshift(y, -1);
-       y[M+1] |= 0x8000;
-       r++;
-     }
-     y[1] = r + EXONE;
-  }
+      carry = 1;       /* Initially add 1 for the two's complement.  */
+      for (i=size + M; i > M; i--)
+        {
+         if (carry && (y[i] == 0x0000))
+           /* We overflowed into the next word, carry is the same.  */
+           y[i] = carry ? 0x0000 : 0xffff;
+         else
+           {
+             /* No overflow, just invert and add carry.  */
+             y[i] = ((~y[i]) + carry) & 0xffff;
+             carry = 0;
+           }
+        }
+
+      if (carry)
+        {
+         eshift(y, -1);
+         y[M+1] |= 0x8000;
+         r++;
+         }
+       y[1] = r + EXONE;
+    }
   else
-  {
-    /* Add our e type exponent offset to form our exponent.  */
-     r += EXONE;
-     y[1] = r;
+    {
+      /* Add our e type exponent offset to form our exponent.  */
+      r += EXONE;
+      y[1] = r;
 
      /* Now do the high order mantissa strip off the exponent and sign
        bits and add the high 1 bit.  */
-     y[M] = (d[0] & 0x7f) | 0x80;
+     y[M] = (dn[0] & 0x7f) | 0x80;
 
-     y[M+1] = d[1];
+     y[M+1] = dn[1];
      if (mode != QFmode)       /* There are only 2 words in QFmode.  */
-     {
-       y[M+2] = d[2];          /* Fill in the rest of our mantissa.  */
-       y[M+3] = d[3];
-     }
+       {
+        y[M+2] = dn[2];        /* Fill in the rest of our mantissa.  */
+        y[M+3] = dn[3];
+       }
      eshift(y, -8);
-  }
+    }
 
   emovo (y, e);
 }
@@ -6243,9 +6244,7 @@ toc4x (x, y, mode)
       while (v > M)
        {
          if (x[v] == 0x0000)
-           {
-             x[v] = carry ? 0x0000 : 0xffff;
-           }
+           x[v] = carry ? 0x0000 : 0xffff;
          else
            {
              x[v] = ((~x[v]) + carry) & 0xffff;
@@ -6267,9 +6266,7 @@ toc4x (x, y, mode)
        }
     }
   else
-    {
-      i = ((int) x[1]) - 0x7f;
-    }
+    i = ((int) x[1]) - 0x7f;
 
   if ((i < -128) || (i > 127))
     {
@@ -6279,6 +6276,8 @@ toc4x (x, y, mode)
        {
          y[2] = 0xffff;
          y[3] = 0xffff;
+         y[3] = (y[1] << 8) | ((y[2] >> 8) & 0xff);
+         y[2] = (y[0] << 8) | ((y[1] >> 8) & 0xff);
        }
 #ifdef ERANGE
       errno = ERANGE;
@@ -6296,6 +6295,8 @@ toc4x (x, y, mode)
     {
       y[2] = x[M + 2];
       y[3] = x[M + 3];
+      y[3] = (y[1] << 8) | ((y[2] >> 8) & 0xff);
+      y[2] = (y[0] << 8) | ((y[1] >> 8) & 0xff);
     }
 }
 #endif /* C4X */