Commit bdca3c33 by Herman A.J. ten Brugge Committed by Richard Henderson

real.c (c4xtoe, toc4x): Do some special conversion on long doubles for the c4x target.

        * real.c (c4xtoe, toc4x): Do some special conversion on long doubles
        for the c4x target. Also improve layout.

From-SVN: r48688
parent d66ae36a
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> 2002-01-09 Richard Henderson <rth@redhat.com>
* config/m32r/m32r.c (move_src_operand): Fix 32-bit int test. * config/m32r/m32r.c (move_src_operand): Fix 32-bit int test.
......
...@@ -6064,16 +6064,25 @@ c4xtoe (d, e, mode) ...@@ -6064,16 +6064,25 @@ c4xtoe (d, e, mode)
enum machine_mode mode; enum machine_mode mode;
{ {
UEMUSHORT y[NI]; UEMUSHORT y[NI];
UEMUSHORT dn[4];
int r; int r;
int isnegative; int isnegative;
int size; int size;
int i; int i;
int carry; 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. */ /* Short-circuit the zero case. */
if ((d[0] == 0x8000) if ((dn[0] == 0x8000)
&& (d[1] == 0x0000) && (dn[1] == 0x0000)
&& ((mode == QFmode) || ((d[2] == 0x0000) && (d[3] == 0x0000)))) && ((mode == QFmode) || ((dn[2] == 0x0000) && (dn[3] == 0x0000))))
{ {
e[0] = 0; e[0] = 0;
e[1] = 0; e[1] = 0;
...@@ -6085,87 +6094,79 @@ c4xtoe (d, e, mode) ...@@ -6085,87 +6094,79 @@ c4xtoe (d, e, mode)
} }
ecleaz (y); /* start with a zero */ 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) if (r & (unsigned int) 0x0080)
{ {
y[0] = 0xffff; /* fill in our sign */ y[0] = 0xffff; /* fill in our sign */
isnegative = TRUE; isnegative = TRUE;
} }
else else
{ isnegative = FALSE;
isnegative = FALSE;
}
r >>= 8; /* Shift exponent word down 8 bits. */ r >>= 8; /* Shift exponent word down 8 bits. */
if (r & 0x80) /* Make the exponent negative if it is. */ if (r & 0x80) /* Make the exponent negative if it is. */
{ r = r | (~0 & ~0xff);
r = r | (~0 & ~0xff);
}
if (isnegative) if (isnegative)
{ {
/* Now do the high order mantissa. We don't "or" on the high bit /* 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 because it is 2 (not 1) and is handled a little differently
below. */ below. */
y[M] = d[0] & 0x7f; y[M] = dn[0] & 0x7f;
y[M+1] = d[1]; y[M+1] = dn[1];
if (mode != QFmode) /* There are only 2 words in QFmode. */ if (mode != QFmode) /* There are only 2 words in QFmode. */
{ {
y[M+2] = d[2]; /* Fill in the rest of our mantissa. */ y[M+2] = dn[2]; /* Fill in the rest of our mantissa. */
y[M+3] = d[3]; y[M+3] = dn[3];
size = 4; size = 4;
} }
else else
{
size = 2; 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. */ carry = 1; /* Initially add 1 for the two's complement. */
for (i=size + M; i > M; i--) for (i=size + M; i > M; i--)
{ {
if (carry && (y[i] == 0x0000)) if (carry && (y[i] == 0x0000))
{ /* We overflowed into the next word, carry is the same. */
/* We overflowed into the next word, carry is the same. */ y[i] = carry ? 0x0000 : 0xffff;
y[i] = carry ? 0x0000 : 0xffff; else
} {
else /* No overflow, just invert and add carry. */
{ y[i] = ((~y[i]) + carry) & 0xffff;
/* No overflow, just invert and add carry. */ carry = 0;
y[i] = ((~y[i]) + carry) & 0xffff; }
carry = 0; }
}
} if (carry)
{
if (carry) eshift(y, -1);
{ y[M+1] |= 0x8000;
eshift(y, -1); r++;
y[M+1] |= 0x8000; }
r++; y[1] = r + EXONE;
} }
y[1] = r + EXONE;
}
else else
{ {
/* Add our e type exponent offset to form our exponent. */ /* Add our e type exponent offset to form our exponent. */
r += EXONE; r += EXONE;
y[1] = r; y[1] = r;
/* Now do the high order mantissa strip off the exponent and sign /* Now do the high order mantissa strip off the exponent and sign
bits and add the high 1 bit. */ 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. */ if (mode != QFmode) /* There are only 2 words in QFmode. */
{ {
y[M+2] = d[2]; /* Fill in the rest of our mantissa. */ y[M+2] = dn[2]; /* Fill in the rest of our mantissa. */
y[M+3] = d[3]; y[M+3] = dn[3];
} }
eshift(y, -8); eshift(y, -8);
} }
emovo (y, e); emovo (y, e);
} }
...@@ -6243,9 +6244,7 @@ toc4x (x, y, mode) ...@@ -6243,9 +6244,7 @@ toc4x (x, y, mode)
while (v > M) while (v > M)
{ {
if (x[v] == 0x0000) if (x[v] == 0x0000)
{ x[v] = carry ? 0x0000 : 0xffff;
x[v] = carry ? 0x0000 : 0xffff;
}
else else
{ {
x[v] = ((~x[v]) + carry) & 0xffff; x[v] = ((~x[v]) + carry) & 0xffff;
...@@ -6267,9 +6266,7 @@ toc4x (x, y, mode) ...@@ -6267,9 +6266,7 @@ toc4x (x, y, mode)
} }
} }
else else
{ i = ((int) x[1]) - 0x7f;
i = ((int) x[1]) - 0x7f;
}
if ((i < -128) || (i > 127)) if ((i < -128) || (i > 127))
{ {
...@@ -6279,6 +6276,8 @@ toc4x (x, y, mode) ...@@ -6279,6 +6276,8 @@ toc4x (x, y, mode)
{ {
y[2] = 0xffff; y[2] = 0xffff;
y[3] = 0xffff; y[3] = 0xffff;
y[3] = (y[1] << 8) | ((y[2] >> 8) & 0xff);
y[2] = (y[0] << 8) | ((y[1] >> 8) & 0xff);
} }
#ifdef ERANGE #ifdef ERANGE
errno = ERANGE; errno = ERANGE;
...@@ -6296,6 +6295,8 @@ toc4x (x, y, mode) ...@@ -6296,6 +6295,8 @@ toc4x (x, y, mode)
{ {
y[2] = x[M + 2]; y[2] = x[M + 2];
y[3] = x[M + 3]; 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 */ #endif /* C4X */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment