real.c (ereal_to_decimal): Add digits parameter.

* 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
This commit is contained in:
Richard Henderson 2002-09-04 09:24:24 -07:00 committed by Richard Henderson
parent 01abf342f8
commit 4b67a27441
26 changed files with 134 additions and 46 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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; \

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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);
}

View File

@ -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
}

View File

@ -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); }}

View File

@ -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); }}

View File

@ -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

View File

@ -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.

View File

@ -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))

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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,

View File

@ -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 **** */

View File

@ -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));