diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 30 | ||||
-rw-r--r-- | gcc/c-pretty-print.c | 3 | ||||
-rw-r--r-- | gcc/config/arc/arc.c | 2 | ||||
-rw-r--r-- | gcc/config/c4x/c4x.c | 2 | ||||
-rw-r--r-- | gcc/config/i370/i370.h | 4 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 4 | ||||
-rw-r--r-- | gcc/config/i960/i960.c | 2 | ||||
-rw-r--r-- | gcc/config/ip2k/ip2k.c | 2 | ||||
-rw-r--r-- | gcc/config/m32r/m32r.c | 2 | ||||
-rw-r--r-- | gcc/config/m68hc11/m68hc11.c | 2 | ||||
-rw-r--r-- | gcc/config/m68k/hp320.h | 10 | ||||
-rw-r--r-- | gcc/config/m68k/m68k.h | 6 | ||||
-rw-r--r-- | gcc/config/m68k/sun2o4.h | 4 | ||||
-rw-r--r-- | gcc/config/m68k/sun3.h | 4 | ||||
-rw-r--r-- | gcc/config/mips/mips.c | 2 | ||||
-rw-r--r-- | gcc/config/ns32k/ns32k.c | 4 | ||||
-rw-r--r-- | gcc/config/pdp11/pdp11.h | 2 | ||||
-rw-r--r-- | gcc/config/vax/vax.h | 4 | ||||
-rw-r--r-- | gcc/doc/tm.texi | 7 | ||||
-rw-r--r-- | gcc/f/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/f/target.h | 4 | ||||
-rw-r--r-- | gcc/print-rtl.c | 2 | ||||
-rw-r--r-- | gcc/print-tree.c | 4 | ||||
-rw-r--r-- | gcc/real.c | 63 | ||||
-rw-r--r-- | gcc/real.h | 4 | ||||
-rw-r--r-- | gcc/sched-vis.c | 2 |
26 files changed, 134 insertions, 46 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dc248d88352..a289e8aff32 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,33 @@ +2002-09-04 Richard Henderson <rth@redhat.com> + + * real.c (ereal_to_decimal): Add digits parameter. + * real.h (REAL_VALUE_TO_DECIMAL): Remove format; add digits parameter. + * c-pretty-print.c (pp_c_real_literal): Update call. + * print-rtl.c (print_rtx): Likewise. + * print-tree.c (print_node_brief, print_node): Likewise. + * sched-vis.c (print_value): Likewise. + * config/arc/arc.c (arc_print_operand): Likewise. + * config/c4x/c4x.c (c4x_print_operand): Likewise. + * config/i370/i370.h (PRINT_OPERAND): Likewise. + * config/i386/i386.c (print_operand): Likewise. + * config/i960/i960.c (i960_print_operand): Likewise. + * config/ip2k/ip2k.c (asm_output_float): Likewise. + * config/m32r/m32r.c (m32r_print_operand): Likewise. + * config/m68hc11/m68hc11.c (print_operand): Likewise. + * config/m68k/hp320.h (PRINT_OPERAND, ASM_OUTPUT_FLOAT_OPERAND, + ASM_OUTPUT_DOUBLE_OPERAND, ASM_OUTPUT_LONG_DOUBLE_OPERAND): Likewise. + * config/m68k/m68k.h (ASM_OUTPUT_FLOAT_OPERAND, + ASM_OUTPUT_DOUBLE_OPERAND, ASM_OUTPUT_LONG_DOUBLE_OPERAND): Likewise. + * config/m68k/sun2o4.h (ASM_OUTPUT_FLOAT_OPERAND, + ASM_OUTPUT_DOUBLE_OPERAND): Likewise. + * config/m68k/sun3.h (ASM_OUTPUT_FLOAT_OPERAND, + ASM_OUTPUT_DOUBLE_OPERAND): Likewise. + * config/mips/mips.c (print_operand): Likewise. + * config/ns32k/ns32k.c (print_operand): Likewise. + * config/pdp11/pdp11.h (PRINT_OPERAND): Likewise. + * config/vax/vax.h (PRINT_OPERAND): Likewise. + * doc/tm.texi (REAL_VALUE_TO_DECIMAL): Update docs. + 2002-09-04 Bob Wilson <bob.wilson@acm.org> * config/xtensa/elf.h (TARGET_SECTION_TYPE_FLAGS): Define to diff --git a/gcc/c-pretty-print.c b/gcc/c-pretty-print.c index 1ab0569b6a4..5d9151691cd 100644 --- a/gcc/c-pretty-print.c +++ b/gcc/c-pretty-print.c @@ -469,8 +469,7 @@ pp_c_real_literal (ppi, r) c_pretty_printer ppi; tree r; { - REAL_VALUE_TO_DECIMAL (TREE_REAL_CST (r), "%.16g", - pp_buffer (ppi)->digit_buffer); + REAL_VALUE_TO_DECIMAL (TREE_REAL_CST (r), pp_buffer (ppi)->digit_buffer, -1); pp_identifier (ppi, pp_buffer(ppi)->digit_buffer); } diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 426cc89d8f0..a8de317726d 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -1748,7 +1748,7 @@ arc_print_operand (file, x, code) || GET_MODE_CLASS (GET_MODE (x)) != MODE_FLOAT) abort (); REAL_VALUE_FROM_CONST_DOUBLE (d, x); - REAL_VALUE_TO_DECIMAL (d, "%.20e", str); + REAL_VALUE_TO_DECIMAL (d, str, -1); fprintf (file, "%s", str); return; } diff --git a/gcc/config/c4x/c4x.c b/gcc/config/c4x/c4x.c index 2ed42bee362..79096657da4 100644 --- a/gcc/config/c4x/c4x.c +++ b/gcc/config/c4x/c4x.c @@ -1958,7 +1958,7 @@ c4x_print_operand (file, op, letter) REAL_VALUE_TYPE r; REAL_VALUE_FROM_CONST_DOUBLE (r, op); - REAL_VALUE_TO_DECIMAL (r, "%20f", str); + REAL_VALUE_TO_DECIMAL (r, str, -1); fprintf (file, "%s", str); } break; diff --git a/gcc/config/i370/i370.h b/gcc/config/i370/i370.h index 7bcbdf893a1..d4c29399da2 100644 --- a/gcc/config/i370/i370.h +++ b/gcc/config/i370/i370.h @@ -1371,7 +1371,7 @@ enum reg_class char buf[50]; \ REAL_VALUE_TYPE rval; \ REAL_VALUE_FROM_CONST_DOUBLE(rval, XV); \ - REAL_VALUE_TO_DECIMAL (rval, HOST_WIDE_INT_PRINT_DEC, buf); \ + REAL_VALUE_TO_DECIMAL (rval, buf, -1); \ if (GET_MODE (XV) == SFmode) \ { \ mvs_page_lit += 4; \ @@ -1665,7 +1665,7 @@ enum reg_class char buf[50]; \ REAL_VALUE_TYPE rval; \ REAL_VALUE_FROM_CONST_DOUBLE(rval, XV); \ - REAL_VALUE_TO_DECIMAL (rval, HOST_WIDE_INT_PRINT_DEC, buf); \ + REAL_VALUE_TO_DECIMAL (rval, buf, -1); \ if (GET_MODE (XV) == SFmode) \ { \ mvs_page_lit += 4; \ diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 730bd3d78e2..4e0da606f92 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -6610,7 +6610,7 @@ print_operand (file, x, code) char dstr[30]; REAL_VALUE_FROM_CONST_DOUBLE (r, x); - REAL_VALUE_TO_DECIMAL (r, "%.22e", dstr); + REAL_VALUE_TO_DECIMAL (r, dstr, -1); fprintf (file, "%s", dstr); } @@ -6621,7 +6621,7 @@ print_operand (file, x, code) char dstr[30]; REAL_VALUE_FROM_CONST_DOUBLE (r, x); - REAL_VALUE_TO_DECIMAL (r, "%.22e", dstr); + REAL_VALUE_TO_DECIMAL (r, dstr, -1); fprintf (file, "%s", dstr); } diff --git a/gcc/config/i960/i960.c b/gcc/config/i960/i960.c index 6aec8c50239..ae857112801 100644 --- a/gcc/config/i960/i960.c +++ b/gcc/config/i960/i960.c @@ -1761,7 +1761,7 @@ i960_print_operand (file, x, code) } REAL_VALUE_FROM_CONST_DOUBLE (d, x); - REAL_VALUE_TO_DECIMAL (d, "%#g", dstr); + REAL_VALUE_TO_DECIMAL (d, dstr, -1); fprintf (file, "0f%s", dstr); return; } diff --git a/gcc/config/ip2k/ip2k.c b/gcc/config/ip2k/ip2k.c index bcbed3f08d8..f4c9daf5fff 100644 --- a/gcc/config/ip2k/ip2k.c +++ b/gcc/config/ip2k/ip2k.c @@ -3058,7 +3058,7 @@ asm_output_float (file, n) char dstr[100]; REAL_VALUE_TO_TARGET_SINGLE (n, val); - REAL_VALUE_TO_DECIMAL (n, "%g", dstr); + REAL_VALUE_TO_DECIMAL (n, dstr, -1); fprintf (file, "\t.long 0x%08lx\t/* %s */\n",val, dstr); } diff --git a/gcc/config/m32r/m32r.c b/gcc/config/m32r/m32r.c index c4814317a1d..09099175093 100644 --- a/gcc/config/m32r/m32r.c +++ b/gcc/config/m32r/m32r.c @@ -2318,7 +2318,7 @@ m32r_print_operand (file, x, code) || GET_MODE_CLASS (GET_MODE (x)) != MODE_FLOAT) fatal_insn ("bad insn for 'A'", x); REAL_VALUE_FROM_CONST_DOUBLE (d, x); - REAL_VALUE_TO_DECIMAL (d, "%.20e", str); + REAL_VALUE_TO_DECIMAL (d, str, -1); fprintf (file, "%s", str); return; } diff --git a/gcc/config/m68hc11/m68hc11.c b/gcc/config/m68hc11/m68hc11.c index 169381f7681..c17c3f10301 100644 --- a/gcc/config/m68hc11/m68hc11.c +++ b/gcc/config/m68hc11/m68hc11.c @@ -2264,7 +2264,7 @@ print_operand (file, op, letter) char dstr[30]; REAL_VALUE_FROM_CONST_DOUBLE (r, op); - REAL_VALUE_TO_DECIMAL (r, "%.20g", dstr); + REAL_VALUE_TO_DECIMAL (r, dstr, -1); asm_fprintf (file, "%I0r%s", dstr); } else diff --git a/gcc/config/m68k/hp320.h b/gcc/config/m68k/hp320.h index 7a18c52256a..17dcb69afc5 100644 --- a/gcc/config/m68k/hp320.h +++ b/gcc/config/m68k/hp320.h @@ -300,7 +300,7 @@ do { \ if (CODE == 'f') \ { \ char dstr[30]; \ - REAL_VALUE_TO_DECIMAL (VALUE, "%.9g", dstr); \ + REAL_VALUE_TO_DECIMAL (VALUE, dstr, 9); \ fprintf ((FILE), "&0f%s", dstr); \ } \ else \ @@ -317,7 +317,7 @@ do { \ #undef ASM_OUTPUT_DOUBLE_OPERAND #define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE) \ do { char dstr[30]; \ - REAL_VALUE_TO_DECIMAL (VALUE, "%.20g", dstr); \ + REAL_VALUE_TO_DECIMAL (VALUE, dstr, -1); \ fprintf (FILE, "&0f%s", dstr); \ } while (0) @@ -326,7 +326,7 @@ do { \ #undef ASM_OUTPUT_LONG_DOUBLE_OPERAND #define ASM_OUTPUT_LONG_DOUBLE_OPERAND(FILE,VALUE) \ do { char dstr[30]; \ - REAL_VALUE_TO_DECIMAL (VALUE, "%.20g", dstr); \ + REAL_VALUE_TO_DECIMAL (VALUE, dstr, -1); \ fprintf (FILE, "&0f%s", dstr); \ } while (0) @@ -354,12 +354,12 @@ do { \ else if (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) == DFmode) \ { REAL_VALUE_TYPE r; char dstr[30]; \ REAL_VALUE_FROM_CONST_DOUBLE (r, X); \ - REAL_VALUE_TO_DECIMAL (r, "%.20g", dstr); \ + REAL_VALUE_TO_DECIMAL (r, dstr, -1); \ fprintf (FILE, "&0f%s", dstr); } \ else if (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) == XFmode) \ { REAL_VALUE_TYPE r; char dstr[30]; \ REAL_VALUE_FROM_CONST_DOUBLE (r, X); \ - REAL_VALUE_TO_DECIMAL (r, "%.20g", dstr); \ + REAL_VALUE_TO_DECIMAL (r, dstr, -1); \ fprintf (FILE, "&0f%s", dstr); } \ else { putc ('&', FILE); output_addr_const (FILE, X); }} #endif diff --git a/gcc/config/m68k/m68k.h b/gcc/config/m68k/m68k.h index d04b1add533..bf70352d5a6 100644 --- a/gcc/config/m68k/m68k.h +++ b/gcc/config/m68k/m68k.h @@ -1831,7 +1831,7 @@ __transfer_from_trampoline () \ if (CODE == 'f') \ { \ char dstr[30]; \ - REAL_VALUE_TO_DECIMAL (VALUE, "%.9g", dstr); \ + REAL_VALUE_TO_DECIMAL (VALUE, dstr, 9); \ asm_fprintf ((FILE), "%I0r%s", dstr); \ } \ else \ @@ -1846,7 +1846,7 @@ __transfer_from_trampoline () \ This macro is a 68k-specific macro. */ #define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE) \ do { char dstr[30]; \ - REAL_VALUE_TO_DECIMAL (VALUE, "%.20g", dstr); \ + REAL_VALUE_TO_DECIMAL (VALUE, dstr, -1); \ asm_fprintf (FILE, "%I0r%s", dstr); \ } while (0) @@ -1854,7 +1854,7 @@ __transfer_from_trampoline () \ generated by m68k.md. */ #define ASM_OUTPUT_LONG_DOUBLE_OPERAND(FILE,VALUE) \ do { char dstr[30]; \ - REAL_VALUE_TO_DECIMAL (VALUE, "%.20g", dstr); \ + REAL_VALUE_TO_DECIMAL (VALUE, dstr, -1); \ asm_fprintf (FILE, "%I0r%s", dstr); \ } while (0) diff --git a/gcc/config/m68k/sun2o4.h b/gcc/config/m68k/sun2o4.h index b3564c23335..5b09262513b 100644 --- a/gcc/config/m68k/sun2o4.h +++ b/gcc/config/m68k/sun2o4.h @@ -121,7 +121,7 @@ Boston, MA 02111-1307, USA. */ } \ else \ { char dstr[30]; \ - REAL_VALUE_TO_DECIMAL ((VALUE), "%.9g", dstr); \ + REAL_VALUE_TO_DECIMAL ((VALUE), dstr, 9); \ fprintf (FILE, "#0r%s", dstr); \ } \ } while (0) @@ -141,7 +141,7 @@ Boston, MA 02111-1307, USA. */ } \ else \ { char dstr[30]; \ - REAL_VALUE_TO_DECIMAL ((VALUE), "%.20g", dstr); \ + REAL_VALUE_TO_DECIMAL ((VALUE), dstr, -1); \ fprintf (FILE, "#0r%s", dstr); \ } \ } while (0) diff --git a/gcc/config/m68k/sun3.h b/gcc/config/m68k/sun3.h index e3749eed6c8..3dcb85a798e 100644 --- a/gcc/config/m68k/sun3.h +++ b/gcc/config/m68k/sun3.h @@ -208,7 +208,7 @@ Boston, MA 02111-1307, USA. */ } \ else \ { char dstr[30]; \ - REAL_VALUE_TO_DECIMAL ((VALUE), "%.9g", dstr); \ + REAL_VALUE_TO_DECIMAL ((VALUE), dstr, 9); \ asm_fprintf (FILE, "%I0r%s", dstr); \ } \ } while (0) @@ -228,7 +228,7 @@ Boston, MA 02111-1307, USA. */ } \ else \ { char dstr[30]; \ - REAL_VALUE_TO_DECIMAL ((VALUE), "%.17g", dstr); \ + REAL_VALUE_TO_DECIMAL ((VALUE), dstr, -1); \ asm_fprintf (FILE, "%I0r%s", dstr); \ } \ } while (0) diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index f67c5454c0c..2044cbffc54 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -5888,7 +5888,7 @@ print_operand (file, op, letter) char s[30]; REAL_VALUE_FROM_CONST_DOUBLE (d, op); - REAL_VALUE_TO_DECIMAL (d, "%.20e", s); + REAL_VALUE_TO_DECIMAL (d, s, -1); fprintf (file, s); } diff --git a/gcc/config/ns32k/ns32k.c b/gcc/config/ns32k/ns32k.c index 5c5252cbf02..b94e7042c53 100644 --- a/gcc/config/ns32k/ns32k.c +++ b/gcc/config/ns32k/ns32k.c @@ -1134,7 +1134,7 @@ print_operand (file, x, code) CONST_DOUBLE_HIGH (x), CONST_DOUBLE_LOW (x)); #else char s[30]; - REAL_VALUE_TO_DECIMAL (r, "%.20e", s); + REAL_VALUE_TO_DECIMAL (r, s, -1); #ifdef ENCORE_ASM fprintf (file, "0f%s", s); #else @@ -1150,7 +1150,7 @@ print_operand (file, x, code) fprintf (file, "0Fx%08lx", l); #else char s[30]; - REAL_VALUE_TO_DECIMAL (r, "%.20e", s); + REAL_VALUE_TO_DECIMAL (r, s, -1); fprintf (file, "0f%s", s); #endif } diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h index 12230781d81..f4e40b37a17 100644 --- a/gcc/config/pdp11/pdp11.h +++ b/gcc/config/pdp11/pdp11.h @@ -1128,7 +1128,7 @@ fprintf (FILE, "$help$: . = .+8 ; space for tmp moves!\n") \ { REAL_VALUE_TYPE r; \ char buf[30]; \ REAL_VALUE_FROM_CONST_DOUBLE (r, X); \ - REAL_VALUE_TO_DECIMAL (r, "%.20e", buf); \ + REAL_VALUE_TO_DECIMAL (r, buf, -1); \ fprintf (FILE, "#%s", buf); } \ else { putc ('$', FILE); output_addr_const_pdp11 (FILE, X); }} diff --git a/gcc/config/vax/vax.h b/gcc/config/vax/vax.h index 702125da6a0..3d9767847b3 100644 --- a/gcc/config/vax/vax.h +++ b/gcc/config/vax/vax.h @@ -1207,12 +1207,12 @@ VAX operand formatting codes: else if (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) == SFmode) \ { REAL_VALUE_TYPE r; char dstr[30]; \ REAL_VALUE_FROM_CONST_DOUBLE (r, X); \ - REAL_VALUE_TO_DECIMAL (r, "%.20e", dstr); \ + REAL_VALUE_TO_DECIMAL (r, dstr, -1); \ fprintf (FILE, "$0f%s", dstr); } \ else if (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) == DFmode) \ { REAL_VALUE_TYPE r; char dstr[30]; \ REAL_VALUE_FROM_CONST_DOUBLE (r, X); \ - REAL_VALUE_TO_DECIMAL (r, "%.20e", dstr); \ + REAL_VALUE_TO_DECIMAL (r, dstr, -1); \ fprintf (FILE, "$0%c%s", ASM_DOUBLE_CHAR, dstr); } \ else { putc ('$', FILE); output_addr_const (FILE, X); }} diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 770faefbacc..766167f8569 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -6313,15 +6313,16 @@ The array element values are designed so that you can print them out using @code{fprintf} in the order they should appear in the target machine's memory. -@item REAL_VALUE_TO_DECIMAL (@var{x}, @var{format}, @var{string}) +@item REAL_VALUE_TO_DECIMAL (@var{x}, @var{string}, @var{digits}) @findex REAL_VALUE_TO_DECIMAL This macro converts @var{x}, of type @code{REAL_VALUE_TYPE}, to a decimal number and stores it as a string into @var{string}. You must pass, as @var{string}, the address of a long enough block of space to hold the result. -The argument @var{format} is a @code{printf}-specification that serves -as a suggestion for how to format the output string. +The argument @var{digits} is the number of decimal digits to print, +or @minus{}1 to indicate ``enough'', i.e. @code{DECIMAL_DIG} for +for the target. @end table @node Uninitialized Data diff --git a/gcc/f/ChangeLog b/gcc/f/ChangeLog index 9caccf23fd3..56e33aa67f7 100644 --- a/gcc/f/ChangeLog +++ b/gcc/f/ChangeLog @@ -1,3 +1,8 @@ +2002-09-04 Richard Henderson <rth@redhat.com> + + * target.h (ffetarget_print_real1, ffetarget_print_real2): Update + call to REAL_VALUE_TO_DECIMAL. + 2002-08-31 Toon Moene <toon@moene.indiv.nluug.nl> * com.c: Don't set flag_finite_math_only by default. diff --git a/gcc/f/target.h b/gcc/f/target.h index a8c7c58989a..0601c4a468b 100644 --- a/gcc/f/target.h +++ b/gcc/f/target.h @@ -1493,13 +1493,13 @@ void *ffetarget_memcpy_ (void *dst, void *src, size_t len); #define ffetarget_print_real1(f,l) \ ({ REAL_VALUE_TYPE lr; \ lr = ffetarget_cvt_r1_to_rv_ ((l)); \ - REAL_VALUE_TO_DECIMAL (lr, bad_fmt_val??, ffetarget_string_); \ + REAL_VALUE_TO_DECIMAL (lr, ffetarget_string_, -1); \ fputs (ffetarget_string_, (f)); \ }) #define ffetarget_print_real2(f,l) \ ({ REAL_VALUE_TYPE lr; \ lr = ffetarget_cvt_r2_to_rv_ (&((l).v[0])); \ - REAL_VALUE_TO_DECIMAL (lr, bad_fmt_val??, ffetarget_string_); \ + REAL_VALUE_TO_DECIMAL (lr, ffetarget_string_, -1); \ fputs (ffetarget_string_, (f)); \ }) #define ffetarget_real1_one(res) ffetarget_cvt_rv_to_r1_ (dconst1, *(res)) diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c index 25704eb39a0..eb59587ed69 100644 --- a/gcc/print-rtl.c +++ b/gcc/print-rtl.c @@ -524,7 +524,7 @@ print_rtx (in_rtx) char s[30]; REAL_VALUE_FROM_CONST_DOUBLE (val, in_rtx); - REAL_VALUE_TO_DECIMAL (val, "%.16g", s); + REAL_VALUE_TO_DECIMAL (val, s, -1); fprintf (outfile, " [%s]", s); } break; diff --git a/gcc/print-tree.c b/gcc/print-tree.c index 3104f1be214..949b7f51be0 100644 --- a/gcc/print-tree.c +++ b/gcc/print-tree.c @@ -133,7 +133,7 @@ print_node_brief (file, prefix, node, indent) { char string[100]; - REAL_VALUE_TO_DECIMAL (d, "%e", string); + REAL_VALUE_TO_DECIMAL (d, string, -1); fprintf (file, " %s", string); } } @@ -683,7 +683,7 @@ print_node (file, prefix, node, indent) { char string[100]; - REAL_VALUE_TO_DECIMAL (d, "%e", string); + REAL_VALUE_TO_DECIMAL (d, string, -1); fprintf (file, " %s", string); } } diff --git a/gcc/real.c b/gcc/real.c index d2e0a8d85c5..019821df408 100644 --- a/gcc/real.c +++ b/gcc/real.c @@ -1295,7 +1295,7 @@ debug_real (r) { char dstr[30]; - REAL_VALUE_TO_DECIMAL (r, "%.20g", dstr); + REAL_VALUE_TO_DECIMAL (r, dstr, -1); fprintf (stderr, "%s", dstr); } @@ -1380,17 +1380,70 @@ etarsingle (r) /* Convert X to a decimal ASCII string S for output to an assembly language file. Note, there is no standard way to spell infinity or a NaN, so these values may require special treatment in the tm.h - macros. */ + macros. + + The argument DIGITS is the number of decimal digits to print, + or -1 to indicate "enough", i.e. DECIMAL_DIG for for the target. */ void -ereal_to_decimal (x, s) +ereal_to_decimal (x, s, digits) REAL_VALUE_TYPE x; char *s; + int digits; { UEMUSHORT e[NE]; - GET_REAL (&x, e); - etoasc (e, s, 20); + + /* Find DECIMAL_DIG for the target. */ + if (digits < 0) + switch (TARGET_FLOAT_FORMAT) + { + case IEEE_FLOAT_FORMAT: + switch (LONG_DOUBLE_TYPE_SIZE) + { + case 32: + digits = 9; + break; + case 64: + digits = 17; + break; + case 128: + if (!INTEL_EXTENDED_IEEE_FORMAT) + { + digits = 36; + break; + } + /* FALLTHRU */ + case 96: + digits = 21; + break; + + default: + abort (); + } + break; + + case VAX_FLOAT_FORMAT: + digits = 18; /* D_FLOAT */ + break; + + case IBM_FLOAT_FORMAT: + digits = 18; + break; + + case C4X_FLOAT_FORMAT: + digits = 11; + break; + + default: + abort (); + } + + /* etoasc interprets digits as places after the decimal point. + We interpret digits as total decimal digits, which IMO is + more useful. Since the output will have one digit before + the point, subtract one. */ + etoasc (e, s, digits - 1); } /* Compare X and Y. Return 1 if X > Y, 0 if X == Y, -1 if X < Y, diff --git a/gcc/real.h b/gcc/real.h index 174d2c46abf..cf5fdf21aeb 100644 --- a/gcc/real.h +++ b/gcc/real.h @@ -154,7 +154,7 @@ extern void etartdouble PARAMS ((REAL_VALUE_TYPE, long *)); extern void etarldouble PARAMS ((REAL_VALUE_TYPE, long *)); extern void etardouble PARAMS ((REAL_VALUE_TYPE, long *)); extern long etarsingle PARAMS ((REAL_VALUE_TYPE)); -extern void ereal_to_decimal PARAMS ((REAL_VALUE_TYPE, char *)); +extern void ereal_to_decimal PARAMS ((REAL_VALUE_TYPE, char *, int)); extern int ereal_cmp PARAMS ((REAL_VALUE_TYPE, REAL_VALUE_TYPE)); extern int ereal_isneg PARAMS ((REAL_VALUE_TYPE)); extern REAL_VALUE_TYPE ereal_unto_float PARAMS ((long)); @@ -253,7 +253,7 @@ extern bool exact_real_truncate PARAMS ((enum machine_mode, #define REAL_VALUE_FROM_TARGET_SINGLE(f) (ereal_from_float (f)) /* Conversions to decimal ASCII string. */ -#define REAL_VALUE_TO_DECIMAL(r, fmt, s) (ereal_to_decimal (r, s)) +#define REAL_VALUE_TO_DECIMAL(r, s, dig) (ereal_to_decimal (r, s, dig)) /* **** End of software floating point emulator interface macros **** */ diff --git a/gcc/sched-vis.c b/gcc/sched-vis.c index e44c28a08cc..571c4ce1305 100644 --- a/gcc/sched-vis.c +++ b/gcc/sched-vis.c @@ -566,7 +566,7 @@ print_value (buf, x, verbose) REAL_VALUE_TYPE r; REAL_VALUE_FROM_CONST_DOUBLE (r, x); - REAL_VALUE_TO_DECIMAL(r, "%.6e", t); + REAL_VALUE_TO_DECIMAL(r, t, 6); } else sprintf (t, "<0x%lx,0x%lx>", (long) XWINT (x, 2), (long) XWINT (x, 3)); |