aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog17
-rw-r--r--gcc/c-common.c2
-rw-r--r--gcc/c-pretty-print.c3
-rw-r--r--gcc/config/arc/arc.c5
-rw-r--r--gcc/config/c4x/c4x.c5
-rw-r--r--gcc/config/fr30/fr30.c5
-rw-r--r--gcc/config/i370/i370.h24
-rw-r--r--gcc/config/i386/i386.c8
-rw-r--r--gcc/config/i960/i960.c4
-rw-r--r--gcc/config/ip2k/ip2k.c5
-rw-r--r--gcc/config/m32r/m32r.c5
-rw-r--r--gcc/config/m68hc11/m68hc11.c5
-rw-r--r--gcc/config/m68k/hp320.h20
-rw-r--r--gcc/config/m68k/m68k.h6
-rw-r--r--gcc/config/m68k/sun2o4.h4
-rw-r--r--gcc/config/m68k/sun3.h4
-rw-r--r--gcc/config/mips/mips.c6
-rw-r--r--gcc/config/ns32k/ns32k.c8
-rw-r--r--gcc/config/pdp11/pdp11.h6
-rw-r--r--gcc/config/vax/vax.h12
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/error.c3
-rw-r--r--gcc/doc/tm.texi11
-rw-r--r--gcc/f/ChangeLog5
-rw-r--r--gcc/f/target.h6
-rw-r--r--gcc/print-rtl.c6
-rw-r--r--gcc/print-tree.c10
-rw-r--r--gcc/real.c64
-rw-r--r--gcc/real.h7
-rw-r--r--gcc/sched-vis.c7
30 files changed, 149 insertions, 129 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6026be3..9b033e4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,20 @@
+2002-10-15 Richard Henderson <rth@redhat.com>
+
+ * real.c (real_to_decimal): Accept BUF_SIZE and CROP_TRAILING_ZEROS
+ as arguments. Bound DIGITS by the available buffer size.
+ (real_to_hexadecimal): Likewise.
+ * real.h (real_to_decimal, real_to_hexadecimal): Update prototypes.
+ (REAL_VALUE_TO_DECIMAL): Remove.
+ * c-common.c, c-pretty-print.c, print-rtl.c, print-tree.c,
+ sched-vis.c, config/arc/arc.c, config/c4x/c4x.c, config/fr30/fr30.c,
+ config/i370/i370.h, config/i386/i386.c, config/i960/i960.c,
+ config/ip2k/ip2k.c, config/m32r/m32r.c, config/m68hc11/m68hc11.c,
+ config/m68k/hp320.h, config/m68k/m68k.h, config/m68k/sun2o4.h,
+ config/m68k/sun3.h, config/mips/mips.c, config/ns32k/ns32k.c,
+ config/pdp11/pdp11.h, config/vax/vax.h: Update all callers to
+ use real_to_decimal directly, and with the proper arguments.
+ * doc/tm.texi (REAL_VALUE_TO_DECIMAL): Remove.
+
2002-10-15 Jim Wilson <wilson@redhat.com>
* reload1.c (merge_assigned_reloads): After converting overlapping
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 48283e5..75c2911 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -5100,7 +5100,7 @@ builtin_define_with_hex_fp_value (macro, type, digits, hex_str, fp_suffix)
then print it back out as decimal. */
real_from_string (&real, hex_str);
- real_to_decimal (dec_str, &real, digits);
+ real_to_decimal (dec_str, &real, sizeof (dec_str), digits, 0);
sprintf (buf, "%s=%s%s", macro, dec_str, fp_suffix);
cpp_define (parse_in, buf);
diff --git a/gcc/c-pretty-print.c b/gcc/c-pretty-print.c
index 0961798..377018e 100644
--- a/gcc/c-pretty-print.c
+++ b/gcc/c-pretty-print.c
@@ -469,7 +469,8 @@ pp_c_real_literal (ppi, r)
c_pretty_printer ppi;
tree r;
{
- REAL_VALUE_TO_DECIMAL (TREE_REAL_CST (r), pp_buffer (ppi)->digit_buffer, -1);
+ real_to_decimal (pp_buffer (ppi)->digit_buffer, &TREE_REAL_CST (r),
+ sizeof (pp_buffer (ppi)->digit_buffer), 0, 1);
pp_identifier (ppi, pp_buffer(ppi)->digit_buffer);
}
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index a8de317..ab7fe42 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -1741,14 +1741,13 @@ arc_print_operand (file, x, code)
return;
case 'A' :
{
- REAL_VALUE_TYPE d;
char str[30];
if (GET_CODE (x) != CONST_DOUBLE
|| GET_MODE_CLASS (GET_MODE (x)) != MODE_FLOAT)
abort ();
- REAL_VALUE_FROM_CONST_DOUBLE (d, x);
- REAL_VALUE_TO_DECIMAL (d, str, -1);
+
+ real_to_decimal (str, CONST_DOUBLE_REAL_VALUE (x), sizeof (str), 0, 1);
fprintf (file, "%s", str);
return;
}
diff --git a/gcc/config/c4x/c4x.c b/gcc/config/c4x/c4x.c
index 78cd053..354ac76 100644
--- a/gcc/config/c4x/c4x.c
+++ b/gcc/config/c4x/c4x.c
@@ -1960,10 +1960,9 @@ c4x_print_operand (file, op, letter)
case CONST_DOUBLE:
{
char str[64];
- REAL_VALUE_TYPE r;
- REAL_VALUE_FROM_CONST_DOUBLE (r, op);
- REAL_VALUE_TO_DECIMAL (r, str, -1);
+ real_to_decimal (str, CONST_DOUBLE_REAL_VALUE (op),
+ sizeof (str), 0, 1);
fprintf (file, "%s", str);
}
break;
diff --git a/gcc/config/fr30/fr30.c b/gcc/config/fr30/fr30.c
index 0298e75..e163f92 100644
--- a/gcc/config/fr30/fr30.c
+++ b/gcc/config/fr30/fr30.c
@@ -553,11 +553,10 @@ fr30_print_operand (file, x, code)
output_operand_lossage ("fr30_print_operand: invalid %%F code");
else
{
- REAL_VALUE_TYPE d;
char str[30];
- REAL_VALUE_FROM_CONST_DOUBLE (d, x);
- REAL_VALUE_TO_DECIMAL (d, str, 8);
+ real_to_decimal (str, CONST_DOUBLE_REAL_VALUE (x),
+ sizeof (str), 0, 1);
fputs (str, file);
}
return;
diff --git a/gcc/config/i370/i370.h b/gcc/config/i370/i370.h
index a2aff67..23cf036 100644
--- a/gcc/config/i370/i370.h
+++ b/gcc/config/i370/i370.h
@@ -1371,21 +1371,21 @@ enum reg_class
else \
{ \
char buf[50]; \
- REAL_VALUE_TYPE rval; \
- REAL_VALUE_FROM_CONST_DOUBLE(rval, XV); \
- REAL_VALUE_TO_DECIMAL (rval, buf, -1); \
if (GET_MODE (XV) == SFmode) \
{ \
mvs_page_lit += 4; \
+ real_to_decimal (buf, CONST_DOUBLE_REAL_VALUE (XV), \
+ sizeof (buf), 0, 1); \
fprintf (FILE, "=E'%s'", buf); \
} \
- else \
- if (GET_MODE (XV) == DFmode) \
+ else if (GET_MODE (XV) == DFmode) \
{ \
mvs_page_lit += 8; \
+ real_to_decimal (buf, CONST_DOUBLE_REAL_VALUE (XV), \
+ sizeof (buf), 0, 1); \
fprintf (FILE, "=D'%s'", buf); \
} \
- else /* VOIDmode !?!? strange but true ... */ \
+ else /* VOIDmode */ \
{ \
mvs_page_lit += 8; \
fprintf (FILE, "=XL8'%08X%08X'", \
@@ -1665,21 +1665,21 @@ enum reg_class
else \
{ \
char buf[50]; \
- REAL_VALUE_TYPE rval; \
- REAL_VALUE_FROM_CONST_DOUBLE(rval, XV); \
- REAL_VALUE_TO_DECIMAL (rval, buf, -1); \
if (GET_MODE (XV) == SFmode) \
{ \
mvs_page_lit += 4; \
+ real_to_decimal (buf, CONST_DOUBLE_REAL_VALUE (XV), \
+ sizeof (buf), 0, 1); \
fprintf (FILE, "=E'%s'", buf); \
} \
- else \
- if (GET_MODE (XV) == DFmode) \
+ else if (GET_MODE (XV) == DFmode) \
{ \
mvs_page_lit += 8; \
+ real_to_decimal (buf, CONST_DOUBLE_REAL_VALUE (XV), \
+ sizeof (buf), 0, 1); \
fprintf (FILE, "=D'%s'", buf); \
} \
- else /* VOIDmode !?!? strange but true ... */ \
+ else /* VOIDmode */ \
{ \
mvs_page_lit += 8; \
fprintf (FILE, "=XL8'%08X%08X'", \
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 82b22dc..2f06f0777 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -6742,22 +6742,18 @@ print_operand (file, x, code)
/* These float cases don't actually occur as immediate operands. */
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, dstr, -1);
+ real_to_decimal (dstr, CONST_DOUBLE_REAL_VALUE (x), sizeof (dstr), 0, 1);
fprintf (file, "%s", dstr);
}
else if (GET_CODE (x) == CONST_DOUBLE
&& (GET_MODE (x) == XFmode || GET_MODE (x) == TFmode))
{
- REAL_VALUE_TYPE r;
char dstr[30];
- REAL_VALUE_FROM_CONST_DOUBLE (r, x);
- REAL_VALUE_TO_DECIMAL (r, dstr, -1);
+ real_to_decimal (dstr, CONST_DOUBLE_REAL_VALUE (x), sizeof (dstr), 0, 1);
fprintf (file, "%s", dstr);
}
diff --git a/gcc/config/i960/i960.c b/gcc/config/i960/i960.c
index f353c72..4917ae2 100644
--- a/gcc/config/i960/i960.c
+++ b/gcc/config/i960/i960.c
@@ -1785,7 +1785,6 @@ i960_print_operand (file, x, code)
}
else if (rtxcode == CONST_DOUBLE)
{
- REAL_VALUE_TYPE d;
char dstr[30];
if (x == CONST0_RTX (GET_MODE (x)))
@@ -1799,8 +1798,7 @@ i960_print_operand (file, x, code)
return;
}
- REAL_VALUE_FROM_CONST_DOUBLE (d, x);
- REAL_VALUE_TO_DECIMAL (d, dstr, -1);
+ real_to_decimal (dstr, CONST_DOUBLE_REAL_VALUE (x), sizeof (dstr), 0, 1);
fprintf (file, "0f%s", dstr);
return;
}
diff --git a/gcc/config/ip2k/ip2k.c b/gcc/config/ip2k/ip2k.c
index 36c9b5f..c0a643a 100644
--- a/gcc/config/ip2k/ip2k.c
+++ b/gcc/config/ip2k/ip2k.c
@@ -3072,8 +3072,9 @@ asm_output_float (file, n)
char dstr[100];
REAL_VALUE_TO_TARGET_SINGLE (n, val);
- REAL_VALUE_TO_DECIMAL (n, dstr, -1);
- fprintf (file, "\t.long 0x%08lx\t/* %s */\n",val, dstr);
+ real_to_decimal (dstr, &n, sizeof (dstr), 0, 1);
+
+ fprintf (file, "\t.long 0x%08lx\t/* %s */\n", val, dstr);
}
/* Sets section name for declaration DECL. */
diff --git a/gcc/config/m32r/m32r.c b/gcc/config/m32r/m32r.c
index b3c0767..5903277 100644
--- a/gcc/config/m32r/m32r.c
+++ b/gcc/config/m32r/m32r.c
@@ -2311,14 +2311,13 @@ m32r_print_operand (file, x, code)
case 'A' :
{
- REAL_VALUE_TYPE d;
char str[30];
if (GET_CODE (x) != CONST_DOUBLE
|| 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, str, -1);
+
+ real_to_decimal (str, CONST_DOUBLE_REAL_VALUE (x), sizeof (str), 0, 1);
fprintf (file, "%s", str);
return;
}
diff --git a/gcc/config/m68hc11/m68hc11.c b/gcc/config/m68hc11/m68hc11.c
index c17c3f1..ac16b52 100644
--- a/gcc/config/m68hc11/m68hc11.c
+++ b/gcc/config/m68hc11/m68hc11.c
@@ -2260,11 +2260,10 @@ print_operand (file, op, letter)
else if (GET_CODE (op) == CONST_DOUBLE
&& (GET_MODE (op) == DFmode || GET_MODE (op) == XFmode))
{
- REAL_VALUE_TYPE r;
char dstr[30];
- REAL_VALUE_FROM_CONST_DOUBLE (r, op);
- REAL_VALUE_TO_DECIMAL (r, dstr, -1);
+ real_to_decimal (dstr, CONST_DOUBLE_REAL_VALUE (op),
+ sizeof (dstr), 0, 1);
asm_fprintf (file, "%I0r%s", dstr);
}
else
diff --git a/gcc/config/m68k/hp320.h b/gcc/config/m68k/hp320.h
index 17dcb69..680aab4 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, dstr, 9); \
+ real_to_decimal (dstr, &(VALUE), sizeof (dstr), 9, 0); \
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, dstr, -1); \
+ real_to_decimal (dstr, &(VALUE), sizeof (dstr), 0, 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, dstr, -1); \
+ real_to_decimal (dstr, &(VALUE), sizeof (dstr), 0, 1); \
fprintf (FILE, "&0f%s", dstr); \
} while (0)
@@ -351,15 +351,11 @@ do { \
{ REAL_VALUE_TYPE r; long l; \
REAL_VALUE_FROM_CONST_DOUBLE (r, X); \
PRINT_OPERAND_FLOAT (CODE, FILE, r, l); } \
- 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, 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, dstr, -1); \
+ else if (GET_CODE (X) == CONST_DOUBLE \
+ && (GET_MODE (X) == DFmode || GET_MODE (X) == XFmode)) \
+ { char dstr[30]; \
+ real_to_decimal (dstr, CONST_DOUBLE_REAL_VALUE (X), \
+ sizeof (dstr), 0, 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 703a379..eff0ce2 100644
--- a/gcc/config/m68k/m68k.h
+++ b/gcc/config/m68k/m68k.h
@@ -1823,7 +1823,7 @@ __transfer_from_trampoline () \
if (CODE == 'f') \
{ \
char dstr[30]; \
- REAL_VALUE_TO_DECIMAL (VALUE, dstr, 9); \
+ real_to_decimal (dstr, &(VALUE), sizeof (dstr), 9, 0); \
asm_fprintf ((FILE), "%I0r%s", dstr); \
} \
else \
@@ -1838,7 +1838,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, dstr, -1); \
+ real_to_decimal (dstr, &(VALUE), sizeof (dstr), 0, 1); \
asm_fprintf (FILE, "%I0r%s", dstr); \
} while (0)
@@ -1846,7 +1846,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, dstr, -1); \
+ real_to_decimal (dstr, &(VALUE), sizeof (dstr), 0, 1); \
asm_fprintf (FILE, "%I0r%s", dstr); \
} while (0)
diff --git a/gcc/config/m68k/sun2o4.h b/gcc/config/m68k/sun2o4.h
index 5b09262..0601bd0 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), dstr, 9); \
+ real_to_decimal (dstr, &(VALUE), sizeof (dstr), 9, 0); \
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), dstr, -1); \
+ real_to_decimal (dstr, &(VALUE), sizeof (dstr), 0, 1); \
fprintf (FILE, "#0r%s", dstr); \
} \
} while (0)
diff --git a/gcc/config/m68k/sun3.h b/gcc/config/m68k/sun3.h
index 3dcb85a..1d64599 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), dstr, 9); \
+ real_to_decimal (dstr, &(VALUE), sizeof (dstr), 9, 0); \
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), dstr, -1); \
+ real_to_decimal (dstr, &(VALUE), sizeof (dstr), 0, 1); \
asm_fprintf (FILE, "%I0r%s", dstr); \
} \
} while (0)
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 82e2307..07cc657 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -5910,12 +5910,10 @@ print_operand (file, op, letter)
else if (code == CONST_DOUBLE
&& GET_MODE_CLASS (GET_MODE (op)) == MODE_FLOAT)
{
- REAL_VALUE_TYPE d;
char s[60];
- REAL_VALUE_FROM_CONST_DOUBLE (d, op);
- REAL_VALUE_TO_DECIMAL (d, s, -1);
- fprintf (file, s);
+ real_to_decimal (s, CONST_DOUBLE_REAL_VALUE (op), sizeof (s), 0, 1);
+ fputs (s, file);
}
else if (letter == 'x' && GET_CODE (op) == CONST_INT)
diff --git a/gcc/config/ns32k/ns32k.c b/gcc/config/ns32k/ns32k.c
index b94e704..b94765b 100644
--- a/gcc/config/ns32k/ns32k.c
+++ b/gcc/config/ns32k/ns32k.c
@@ -1130,11 +1130,13 @@ print_operand (file, x, code)
{
#ifdef SEQUENT_ASM
/* Sequent likes its floating point constants as integers */
+ long l[2];
+ REAL_VALUE_TO_TARGET_DOUBLE (r, l);
fprintf (file, "0Dx%08x%08x",
- CONST_DOUBLE_HIGH (x), CONST_DOUBLE_LOW (x));
+ l[!WORDS_BIG_ENDIAN], l[WORDS_BIG_ENDIAN]);
#else
char s[30];
- REAL_VALUE_TO_DECIMAL (r, s, -1);
+ real_to_decimal (s, &r, sizeof (s), 0, 1);
#ifdef ENCORE_ASM
fprintf (file, "0f%s", s);
#else
@@ -1150,7 +1152,7 @@ print_operand (file, x, code)
fprintf (file, "0Fx%08lx", l);
#else
char s[30];
- REAL_VALUE_TO_DECIMAL (r, s, -1);
+ real_to_decimal (s, &r, sizeof (s), 0, 1);
fprintf (file, "0f%s", s);
#endif
}
diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h
index a30dde7..f246aa4 100644
--- a/gcc/config/pdp11/pdp11.h
+++ b/gcc/config/pdp11/pdp11.h
@@ -1149,10 +1149,8 @@ fprintf (FILE, "$help$: . = .+8 ; space for tmp moves!\n") \
else if (GET_CODE (X) == MEM) \
output_address (XEXP (X, 0)); \
else if (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) != SImode) \
- { REAL_VALUE_TYPE r; \
- char buf[30]; \
- REAL_VALUE_FROM_CONST_DOUBLE (r, X); \
- REAL_VALUE_TO_DECIMAL (r, buf, -1); \
+ { char buf[30]; \
+ real_to_decimal (buf, CONST_DOUBLE_REAL_VALUE (X), sizeof (buf), 0, 1); \
fprintf (FILE, "$0F%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 fe07f42..68d5fa3 100644
--- a/gcc/config/vax/vax.h
+++ b/gcc/config/vax/vax.h
@@ -1227,14 +1227,14 @@ VAX operand formatting codes:
else if (GET_CODE (X) == MEM) \
output_address (XEXP (X, 0)); \
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, dstr, -1); \
+ { char dstr[30]; \
+ real_to_decimal (dstr, CONST_DOUBLE_REAL_VALUE (X), \
+ sizeof (dstr), 0, 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, dstr, -1); \
+ { char dstr[30]; \
+ real_to_decimal (dstr, CONST_DOUBLE_REAL_VALUE (X), \
+ sizeof (dstr), 0, 1); \
fprintf (FILE, "$0%c%s", ASM_DOUBLE_CHAR, dstr); } \
else { putc ('$', FILE); output_addr_const (FILE, X); }}
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c529abb..a3ef2da 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2002-10-15 Richard Henderson <rth@redhat.com>
+
+ * error.c (dump_expr): Use real_to_decimal directly, and with
+ the new arguments.
+
2002-10-15 Mark Mitchell <mark@codesourcery.com>
* decl.c (reshape_init): Fix typo.
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 314cf70..872a556 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -1508,7 +1508,8 @@ dump_expr (t, flags)
break;
case REAL_CST:
- REAL_VALUE_TO_DECIMAL (TREE_REAL_CST (t), digit_buffer, -1);
+ real_to_decimal (digit_buffer, &TREE_REAL_CST (t),
+ sizeof (digit_buffer), 0, 1);
output_add_string (scratch_buffer, digit_buffer);
break;
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index bf94d58..c2dfd39 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -6326,17 +6326,6 @@ host machine.
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{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{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 ef81853..23f119d 100644
--- a/gcc/f/ChangeLog
+++ b/gcc/f/ChangeLog
@@ -1,3 +1,8 @@
+2002-10-15 Richard Henderson <rth@redhat.com>
+
+ * target.h (ffetarget_print_real1, ffetarget_print_real2): Use
+ real_to_decimal directly, and with the new arguments.
+
2002-09-23 Zack Weinberg <zack@codesourcery.com>
* Make-lang.in (g77spec.o): Don't depend on f/version.h.
diff --git a/gcc/f/target.h b/gcc/f/target.h
index 2716a7b5..b96504f 100644
--- a/gcc/f/target.h
+++ b/gcc/f/target.h
@@ -1469,13 +1469,15 @@ 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, ffetarget_string_, -1); \
+ real_to_decimal (ffetarget_string_, &lr \
+ sizeof(ffetarget_string_), 0, 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, ffetarget_string_, -1); \
+ real_to_decimal (ffetarget_string_, &lr, \
+ sizeof(ffetarget_string_), 0, 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 7a69d02..c01f918 100644
--- a/gcc/print-rtl.c
+++ b/gcc/print-rtl.c
@@ -524,10 +524,12 @@ print_rtx (in_rtx)
{
char s[60];
- real_to_decimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx), -1);
+ real_to_decimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx),
+ sizeof (s), 0, 1);
fprintf (outfile, " %s", s);
- real_to_hexadecimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx), -1);
+ real_to_hexadecimal (s, CONST_DOUBLE_REAL_VALUE (in_rtx),
+ sizeof (s), 0, 1);
fprintf (outfile, " [%s]", s);
}
break;
diff --git a/gcc/print-tree.c b/gcc/print-tree.c
index ccfa19b..e7c1655 100644
--- a/gcc/print-tree.c
+++ b/gcc/print-tree.c
@@ -131,9 +131,8 @@ print_node_brief (file, prefix, node, indent)
fprintf (file, " Nan");
else
{
- char string[100];
-
- REAL_VALUE_TO_DECIMAL (d, string, -1);
+ char string[60];
+ real_to_decimal (string, &d, sizeof (string), 0, 1);
fprintf (file, " %s", string);
}
}
@@ -684,9 +683,8 @@ print_node (file, prefix, node, indent)
fprintf (file, " Nan");
else
{
- char string[100];
-
- REAL_VALUE_TO_DECIMAL (d, string, -1);
+ char string[64];
+ real_to_decimal (string, &d, sizeof (string), 0, 1);
fprintf (file, " %s", string);
}
}
diff --git a/gcc/real.c b/gcc/real.c
index 075da40..0e776c7 100644
--- a/gcc/real.c
+++ b/gcc/real.c
@@ -1397,23 +1397,26 @@ real_to_integer2 (plow, phigh, r)
}
/* Render R as a decimal floating point constant. Emit DIGITS significant
- digits in the result. If DIGITS <= 0, choose the maximum for the
- representation. If DIGITS < 0, strip trailing zeros. */
+ digits in the result, bounded by BUF_SIZE. If DIGITS is 0, choose the
+ maximum for the representation. If CROP_TRAILING_ZEROS, strip trailing
+ zeros. */
#define M_LOG10_2 0.30102999566398119521
void
-real_to_decimal (str, r_orig, digits)
+real_to_decimal (str, r_orig, buf_size, digits, crop_trailing_zeros)
char *str;
const REAL_VALUE_TYPE *r_orig;
- int digits;
+ size_t buf_size, digits;
+ int crop_trailing_zeros;
{
REAL_VALUE_TYPE r;
const REAL_VALUE_TYPE *one, *ten;
- int dec_exp, max_digits, d, cmp_half;
+ int dec_exp, d, cmp_half;
+ size_t max_digits;
char *p, *first, *last;
+ char exp_buf[16];
bool sign;
- bool crop_trailing_zeros;
r = *r_orig;
switch (r.class)
@@ -1434,11 +1437,6 @@ real_to_decimal (str, r_orig, digits)
abort ();
}
- max_digits = SIGNIFICAND_BITS * M_LOG10_2;
- crop_trailing_zeros = digits < 0;
- if (digits <= 0 || digits > max_digits)
- digits = max_digits;
-
one = real_digit (1);
ten = ten_to_ptwo (0);
@@ -1468,6 +1466,21 @@ real_to_decimal (str, r_orig, digits)
if (sign)
*p++ = '-';
first = p++;
+
+ sprintf (exp_buf, "e%+d", dec_exp);
+
+ /* Bound the number of digits printed by the size of the representation. */
+ max_digits = SIGNIFICAND_BITS * M_LOG10_2;
+ if (digits == 0 || digits > max_digits)
+ digits = max_digits;
+
+ /* Bound the number of digits printed by the size of the output buffer. */
+ max_digits = buf_size - strlen (exp_buf) - sign - 1;
+ if (max_digits > buf_size)
+ abort ();
+ if (digits > max_digits)
+ digits = max_digits;
+
while (1)
{
d = real_to_integer ((const REAL_VALUE_TYPE *) &r);
@@ -1514,22 +1527,25 @@ real_to_decimal (str, r_orig, digits)
while (last > first + 3 && last[-1] == '0')
last--;
- sprintf (last, "e%+d", dec_exp);
+ strcpy (last, exp_buf);
}
/* Render R as a hexadecimal floating point constant. Emit DIGITS
- significant digits in the result. If DIGITS <= 0, choose the maximum
- for the representation. If DIGITS < 0, strip trailing zeros. */
+ significant digits in the result, bounded by BUF_SIZE. If DIGITS is 0,
+ choose the maximum for the representation. If CROP_TRAILING_ZEROS,
+ strip trailing zeros. */
void
-real_to_hexadecimal (str, r, digits)
+real_to_hexadecimal (str, r, buf_size, digits, crop_trailing_zeros)
char *str;
const REAL_VALUE_TYPE *r;
- int digits;
+ size_t buf_size, digits;
+ int crop_trailing_zeros;
{
int i, j, exp = r->exp;
char *p, *first;
- bool crop_trailing_zeros;
+ char exp_buf[16];
+ size_t max_digits;
switch (r->class)
{
@@ -1549,10 +1565,18 @@ real_to_hexadecimal (str, r, digits)
abort ();
}
- crop_trailing_zeros = digits < 0;
- if (digits <= 0)
+ if (digits == 0)
digits = SIGNIFICAND_BITS / 4;
+ /* Bound the number of digits printed by the size of the output buffer. */
+
+ sprintf (exp_buf, "p%+d", exp);
+ max_digits = buf_size - strlen (exp_buf) - r->sign - 4 - 1;
+ if (max_digits > buf_size)
+ abort ();
+ if (digits > max_digits)
+ digits = max_digits;
+
p = str;
if (r->sign)
*p++ = '-';
@@ -1572,7 +1596,7 @@ real_to_hexadecimal (str, r, digits)
out:
if (crop_trailing_zeros)
- while (p > first + 2 && p[-1] == '0')
+ while (p > first + 1 && p[-1] == '0')
p--;
sprintf (p, "p%+d", exp);
diff --git a/gcc/real.h b/gcc/real.h
index 59340f7..2bdca76 100644
--- a/gcc/real.h
+++ b/gcc/real.h
@@ -176,11 +176,11 @@ extern bool exact_real_truncate PARAMS ((enum machine_mode,
/* Render R as a decimal floating point constant. */
extern void real_to_decimal PARAMS ((char *, const REAL_VALUE_TYPE *,
- int));
+ size_t, size_t, int));
/* Render R as a hexadecimal floating point constant. */
extern void real_to_hexadecimal PARAMS ((char *, const REAL_VALUE_TYPE *,
- int));
+ size_t, size_t, int));
/* Render R as an integer. */
extern HOST_WIDE_INT real_to_integer PARAMS ((const REAL_VALUE_TYPE *));
@@ -267,9 +267,6 @@ extern const struct real_format c4x_extended_format;
#define REAL_VALUE_TO_TARGET_SINGLE(IN, OUT) \
((OUT) = real_to_target (NULL, &(IN), mode_for_size (32, MODE_FLOAT, 0)))
-#define REAL_VALUE_TO_DECIMAL(r, s, dig) \
- real_to_decimal (s, &(r), dig)
-
#define REAL_VALUE_FROM_INT(r, lo, hi, mode) \
real_from_integer (&(r), mode, lo, hi, 0)
diff --git a/gcc/sched-vis.c b/gcc/sched-vis.c
index 571c4ce..237d446 100644
--- a/gcc/sched-vis.c
+++ b/gcc/sched-vis.c
@@ -562,12 +562,7 @@ print_value (buf, x, verbose)
break;
case CONST_DOUBLE:
if (FLOAT_MODE_P (GET_MODE (x)))
- {
- REAL_VALUE_TYPE r;
-
- REAL_VALUE_FROM_CONST_DOUBLE (r, x);
- REAL_VALUE_TO_DECIMAL(r, t, 6);
- }
+ real_to_decimal (t, CONST_DOUBLE_REAL_VALUE (x), sizeof (t), 0, 1);
else
sprintf (t, "<0x%lx,0x%lx>", (long) XWINT (x, 2), (long) XWINT (x, 3));
cur = safe_concat (buf, cur, t);