* 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.
* f/target.h (ffetarget_print_real1, ffetarget_print_real2): Update
call to REAL_VALUE_TO_DECIMAL.
From-SVN: r56798
+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
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);
}
|| 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;
}
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;
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; \
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; \
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);
}
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);
}
}
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;
}
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);
}
|| 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;
}
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
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 \
#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)
#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)
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
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 \
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)
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)
} \
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)
} \
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)
} \
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)
} \
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)
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);
}
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
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
}
{ 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); }}
\f
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); }}
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
+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.
#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))
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;
{
char string[100];
- REAL_VALUE_TO_DECIMAL (d, "%e", string);
+ REAL_VALUE_TO_DECIMAL (d, string, -1);
fprintf (file, " %s", string);
}
}
{
char string[100];
- REAL_VALUE_TO_DECIMAL (d, "%e", string);
+ REAL_VALUE_TO_DECIMAL (d, string, -1);
fprintf (file, " %s", string);
}
}
{
char dstr[30];
- REAL_VALUE_TO_DECIMAL (r, "%.20g", dstr);
+ REAL_VALUE_TO_DECIMAL (r, dstr, -1);
fprintf (stderr, "%s", dstr);
}
/* 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,
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));
#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 **** */
\f
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));