summaryrefslogtreecommitdiffstats
path: root/gcc/real.c
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2002-09-04 16:24:24 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2002-09-04 16:24:24 +0000
commit5fc9578e6716f5c32696dec26d7f1b0ec5a445c6 (patch)
treeb08cf3dd22396dc00c208124fa79e09623e672ab /gcc/real.c
parent5f4442bc925142e053cc9f3fe5a6d1d27d3b523c (diff)
downloadppe42-gcc-5fc9578e6716f5c32696dec26d7f1b0ec5a445c6.tar.gz
ppe42-gcc-5fc9578e6716f5c32696dec26d7f1b0ec5a445c6.zip
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@56798 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/real.c')
-rw-r--r--gcc/real.c63
1 files changed, 58 insertions, 5 deletions
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,
OpenPOWER on IntegriCloud