]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
real.c (real_to_decimal): Accept BUF_SIZE and CROP_TRAILING_ZEROS as arguments.
authorRichard Henderson <rth@redhat.com>
Wed, 16 Oct 2002 00:40:39 +0000 (17:40 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Wed, 16 Oct 2002 00:40:39 +0000 (17:40 -0700)
gcc/
        * 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.

gcc/cp/
        * error.c (dump_expr): Use real_to_decimal directly, and with
        the new arguments.

gcc/f/
        * target.h (ffetarget_print_real1, ffetarget_print_real2): Use
        real_to_decimal directly, and with the new arguments.

From-SVN: r58187

30 files changed:
gcc/ChangeLog
gcc/c-common.c
gcc/c-pretty-print.c
gcc/config/arc/arc.c
gcc/config/c4x/c4x.c
gcc/config/fr30/fr30.c
gcc/config/i370/i370.h
gcc/config/i386/i386.c
gcc/config/i960/i960.c
gcc/config/ip2k/ip2k.c
gcc/config/m32r/m32r.c
gcc/config/m68hc11/m68hc11.c
gcc/config/m68k/hp320.h
gcc/config/m68k/m68k.h
gcc/config/m68k/sun2o4.h
gcc/config/m68k/sun3.h
gcc/config/mips/mips.c
gcc/config/ns32k/ns32k.c
gcc/config/pdp11/pdp11.h
gcc/config/vax/vax.h
gcc/cp/ChangeLog
gcc/cp/error.c
gcc/doc/tm.texi
gcc/f/ChangeLog
gcc/f/target.h
gcc/print-rtl.c
gcc/print-tree.c
gcc/real.c
gcc/real.h
gcc/sched-vis.c

index 6026be3b5e55c988d3afdb4ece81efb1d88ae9ae..9b033e48fa38490aeebd33614fb0cc29a52e3faa 100644 (file)
@@ -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
index 48283e5b348dd811a41145e1a226e5af66ced40c..75c29118851daef26a52ee62d4f22d7def5f9edc 100644 (file)
@@ -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);
index 0961798d6d08fa61ce48ea3aebb4f8b087336967..377018ed21ee48199c1e9d9f900e12a9a19073ca 100644 (file)
@@ -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);
 }
 
index a8de317726d3cb760ba20cffa6edd986142a7d2d..ab7fe4280d2f6a79e006b0c68d05345745d823fd 100644 (file)
@@ -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;
       }
index 78cd053a95ce4c40f8c00da2e4f65e2a22365b72..354ac76d1fad0e73c4c31a097c50b979e3137c83 100644 (file)
@@ -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;
index 0298e7519f056471c508f66e02d71252d1d98008..e163f92661435f83e3975c939e799562cd71cc89 100644 (file)
@@ -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;
index a2aff6754d92a140794bc1d764b39523f973db80..23cf036b0df017e74fa70cf604dd9a47a59734ac 100644 (file)
@@ -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'",                        \
index 82b22dc90aafe2a716396568012ab334c4900cbc..2f06f0777d9bd994129f796c2587da642776fc52 100644 (file)
@@ -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);
     }
 
index f353c729ac2d07456e860ce1add987015243b37b..4917ae229815f085fc8b1cda7e0d6a70515c5ea9 100644 (file)
@@ -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;
     }
index 36c9b5fe4b005c129abe40532b7ade41bdff9cca..c0a643ae1d189ac1a68daa6d924ce3d337d2a7fd 100644 (file)
@@ -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.  */
index b3c0767b5eca8598998dd28c12bc493f00894461..5903277c8c2b529eeb2ec380de3c13f0050bbe5e 100644 (file)
@@ -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;
       }
index c17c3f10301972a801bf28a119f45b4c7b52b7e5..ac16b527a974783282f72d1843203126ba4ed82d 100644 (file)
@@ -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
index 17dcb69afc5a009bf94665aab7ce562d23211046..680aab4c2f686d84897eeb72a4be16c2037af0d3 100644 (file)
@@ -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
index 703a37966112c37910034b49c53f1f65d57cd234..eff0ce2984ee729361663fee477ce8ae009a5876 100644 (file)
@@ -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)
 
index 5b09262513b229093bbd10238a037061072cee60..0601bd07f84c949a4c9a3d9a959da6ecbe5b6520 100644 (file)
@@ -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)
index 3dcb85a798e918162d7e938e90fb7b0e2970eb8e..1d64599f332c5839c2448738e30a78451c12539e 100644 (file)
@@ -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)
index 82e23077ceb6d49415ecb6c551c89261606f105c..07cc657d9c04923e10c607fda4a652873bab3494 100644 (file)
@@ -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)
index b94e7042c537b7d32a0fcb74f175f781c93bcf90..b94765bfb3a3e0a31fb917400bc5af0dc706be38 100644 (file)
@@ -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
        }
index a30dde7296673d177460cab846b29c9aace21696..f246aa47e5c1b196bd5f9ef423a9305570095985 100644 (file)
@@ -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); }}
 \f
index fe07f42e8505aaf2b272252bc7f49f141b254393..68d5fa395268ee4da2228a2333f69fe53786a922 100644 (file)
@@ -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); }}
 
index c529abbb3236aafb469713fc22af7bf9cb12c56d..a3ef2da426bd43496630723c99bad5e26abc2f64 100644 (file)
@@ -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.
index 314cf70df56616402c3b2ccac5ba27ddc9191519..872a55677a212df0baf2841a20493a9ba4fdbffd 100644 (file)
@@ -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;
 
index bf94d584a884c960f7ff4de9e2e3765aadc5b38f..c2dfd399c273ae29996686d37cbad3ad219b0945 100644 (file)
@@ -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
index ef81853324f89f7dffbce3f3814edede5ad53e71..23f119dc34c146100f91eb3f0cfa9eb18a0ce5a8 100644 (file)
@@ -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.
index 2716a7b559fd658dfbc9c188503b5e1ca1d8d4d7..b96504f46280600203c28bbaccbc6610753e05ce 100644 (file)
@@ -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))
index 7a69d02aebff999e6272ca6ff737cd96d5740af7..c01f9185addb090ad1dd8235235f45ffbae6b41f 100644 (file)
@@ -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;
index ccfa19bbd761febf2cb53edecb605f7d1f6afa6c..e7c16559e560c6801d5e6ffa86edb489e46cdbd8 100644 (file)
@@ -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);
              }
          }
index 075da40f78c3e2f279ac9f52236c6d7f2d02dbb1..0e776c752c1fd862876a4d585e206255ccd6a0ab 100644 (file)
@@ -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);
index 59340f7d905cbe9547e57f779e2e0bf38147ddc3..2bdca76081fc1f8ff512f8ba5997758fbac8c684 100644 (file)
@@ -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)
 
index 571c4ce13058843154d7ad0b5e02fdc435ad0b97..237d4460d51a43a3d0080a2f64d168c23425cda1 100644 (file)
@@ -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);