Commit 69bd00e6 by Richard Henderson Committed by Richard Henderson

real.c (real_to_decimal): Crop trailing zeros for DIGITS < 0.

        * real.c (real_to_decimal): Crop trailing zeros for DIGITS < 0.
        (real_to_hexadecimal): Likewise.
        * print-rtl.c (print_rtx): If we are linked with real.c, don't
        dump the XWINT fields of a floating point CONST_DOUBLE.

From-SVN: r57719
parent ebc4cdc1
2002-10-01 Richard Henderson <rth@redhat.com>
* real.c (real_to_decimal): Crop trailing zeros for DIGITS < 0.
(real_to_hexadecimal): Likewise.
* print-rtl.c (print_rtx): If we are linked with real.c, don't
dump the XWINT fields of a floating point CONST_DOUBLE.
2002-10-01 Jason Thorpe <thorpej@wasabisystems.com> 2002-10-01 Jason Thorpe <thorpej@wasabisystems.com>
* config/vax/elf.h (FUNCTION_PROFILER): Fix __mcount call. * config/vax/elf.h (FUNCTION_PROFILER): Fix __mcount call.
......
...@@ -195,6 +195,11 @@ print_rtx (in_rtx) ...@@ -195,6 +195,11 @@ print_rtx (in_rtx)
} }
} }
#ifndef GENERATOR_FILE
if (GET_CODE (in_rtx) == CONST_DOUBLE && FLOAT_MODE_P (GET_MODE (in_rtx)))
i = 5;
#endif
/* Get the format string and skip the first elements if we have handled /* Get the format string and skip the first elements if we have handled
them already. */ them already. */
format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx)) + i; format_ptr = GET_RTX_FORMAT (GET_CODE (in_rtx)) + i;
...@@ -517,11 +522,12 @@ print_rtx (in_rtx) ...@@ -517,11 +522,12 @@ print_rtx (in_rtx)
case CONST_DOUBLE: case CONST_DOUBLE:
if (FLOAT_MODE_P (GET_MODE (in_rtx))) if (FLOAT_MODE_P (GET_MODE (in_rtx)))
{ {
REAL_VALUE_TYPE val;
char s[30]; char s[30];
REAL_VALUE_FROM_CONST_DOUBLE (val, in_rtx); real_to_decimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx), -1);
REAL_VALUE_TO_DECIMAL (val, s, -1); fprintf (outfile, " %s", s);
real_to_hexadecimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx), -1);
fprintf (outfile, " [%s]", s); fprintf (outfile, " [%s]", s);
} }
break; break;
......
...@@ -1388,9 +1388,9 @@ real_to_integer2 (plow, phigh, r) ...@@ -1388,9 +1388,9 @@ real_to_integer2 (plow, phigh, r)
*phigh = high; *phigh = high;
} }
/* Render R as a decimal floating point constant. Emit DIGITS /* Render R as a decimal floating point constant. Emit DIGITS significant
significant digits in the result. If DIGITS <= 0, choose the digits in the result. If DIGITS <= 0, choose the maximum for the
maximum for the representation. */ representation. If DIGITS < 0, strip trailing zeros. */
#define M_LOG10_2 0.30102999566398119521 #define M_LOG10_2 0.30102999566398119521
...@@ -1405,6 +1405,7 @@ real_to_decimal (str, r_orig, digits) ...@@ -1405,6 +1405,7 @@ real_to_decimal (str, r_orig, digits)
int dec_exp, max_digits, d, cmp_half; int dec_exp, max_digits, d, cmp_half;
char *p, *first, *last; char *p, *first, *last;
bool sign; bool sign;
bool crop_trailing_zeros;
r = *r_orig; r = *r_orig;
switch (r.class) switch (r.class)
...@@ -1426,6 +1427,7 @@ real_to_decimal (str, r_orig, digits) ...@@ -1426,6 +1427,7 @@ real_to_decimal (str, r_orig, digits)
} }
max_digits = SIGNIFICAND_BITS * M_LOG10_2; max_digits = SIGNIFICAND_BITS * M_LOG10_2;
crop_trailing_zeros = digits < 0;
if (digits <= 0 || digits > max_digits) if (digits <= 0 || digits > max_digits)
digits = max_digits; digits = max_digits;
...@@ -1514,12 +1516,16 @@ real_to_decimal (str, r_orig, digits) ...@@ -1514,12 +1516,16 @@ real_to_decimal (str, r_orig, digits)
first[0] = first[1]; first[0] = first[1];
first[1] = '.'; first[1] = '.';
if (crop_trailing_zeros)
while (last > first + 3 && last[-1] == '0')
last--;
sprintf (last, "e%+d", dec_exp); sprintf (last, "e%+d", dec_exp);
} }
/* Render R as a hexadecimal floating point constant. Emit DIGITS /* Render R as a hexadecimal floating point constant. Emit DIGITS
significant digits in the result. If DIGITS <= 0, choose the maximum significant digits in the result. If DIGITS <= 0, choose the maximum
for the representation. */ for the representation. If DIGITS < 0, strip trailing zeros. */
void void
real_to_hexadecimal (str, r, digits) real_to_hexadecimal (str, r, digits)
...@@ -1528,7 +1534,8 @@ real_to_hexadecimal (str, r, digits) ...@@ -1528,7 +1534,8 @@ real_to_hexadecimal (str, r, digits)
int digits; int digits;
{ {
int i, j, exp = r->exp; int i, j, exp = r->exp;
char *p; char *p, *first;
bool crop_trailing_zeros;
switch (r->class) switch (r->class)
{ {
...@@ -1548,6 +1555,7 @@ real_to_hexadecimal (str, r, digits) ...@@ -1548,6 +1555,7 @@ real_to_hexadecimal (str, r, digits)
abort (); abort ();
} }
crop_trailing_zeros = digits < 0;
if (digits <= 0) if (digits <= 0)
digits = SIGNIFICAND_BITS / 4; digits = SIGNIFICAND_BITS / 4;
...@@ -1558,6 +1566,7 @@ real_to_hexadecimal (str, r, digits) ...@@ -1558,6 +1566,7 @@ real_to_hexadecimal (str, r, digits)
*p++ = 'x'; *p++ = 'x';
*p++ = '0'; *p++ = '0';
*p++ = '.'; *p++ = '.';
first = p;
for (i = SIGSZ - 1; i >= 0; --i) for (i = SIGSZ - 1; i >= 0; --i)
for (j = HOST_BITS_PER_LONG - 4; j >= 0; j -= 4) for (j = HOST_BITS_PER_LONG - 4; j >= 0; j -= 4)
...@@ -1566,7 +1575,12 @@ real_to_hexadecimal (str, r, digits) ...@@ -1566,7 +1575,12 @@ real_to_hexadecimal (str, r, digits)
if (--digits == 0) if (--digits == 0)
goto out; goto out;
} }
out: out:
if (crop_trailing_zeros)
while (p > first + 2 && p[-1] == '0')
p--;
sprintf (p, "p%+d", exp); sprintf (p, "p%+d", exp);
} }
......
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