diff options
author | Martin Sebor <msebor@redhat.com> | 2018-07-04 02:14:16 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2018-07-03 20:14:16 -0600 |
commit | 68a8b147efe9b919ace0b05c879697a3314fdca6 (patch) | |
tree | c53d9bb6849213f03c7d55f84e71c6a941bef92d /gcc | |
parent | ec4692b4a59c3a9f667366c426332a3ae86cd046 (diff) | |
download | gcc-68a8b147efe9b919ace0b05c879697a3314fdca6.zip gcc-68a8b147efe9b919ace0b05c879697a3314fdca6.tar.gz gcc-68a8b147efe9b919ace0b05c879697a3314fdca6.tar.bz2 |
print-tree.c (print_real_cst): New function.
gcc/ChangeLog:
* print-tree.c (print_real_cst): New function.
(print_node_brief): Call it.
(print_node): Ditto.
From-SVN: r262367
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/print-tree.c | 103 |
2 files changed, 74 insertions, 37 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c123469..0ed9700 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-07-03 Martin Sebor <msebor@redhat.com> + + * print-tree.c (print_real_cst): New function. + (print_node_brief): Call it. + (print_node): Ditto. + 2018-07-03 Jeff Law <law@redhat.com> * config/h8300/h8300.md (ors code_iterator): New. @@ -12,7 +18,7 @@ (movmd splitters): Similarly. (stpcpy_internal_normal, stpcpy_internal): Similarly for thes patterns. (movsd splitters): Similarly. - + * config/h8300/h8300.c (h8300_insn_length_from_table): Consolidate ADDB, ADDW and ADDL into a single ADD attribute which selects the right table based on the size of the operand. diff --git a/gcc/print-tree.c b/gcc/print-tree.c index 5c736c5..5347e06 100644 --- a/gcc/print-tree.c +++ b/gcc/print-tree.c @@ -52,6 +52,71 @@ dump_addr (FILE *file, const char *prefix, const void *addr) fprintf (file, "%s" HOST_PTR_PRINTF, prefix, addr); } +/* Print to FILE a NODE representing a REAL_CST constant, including + Infinity and NaN. Be verbose when BFRIEF is false. */ + +static void +print_real_cst (FILE *file, const_tree node, bool brief) +{ + if (TREE_OVERFLOW (node)) + fprintf (file, " overflow"); + + REAL_VALUE_TYPE d = TREE_REAL_CST (node); + if (REAL_VALUE_ISINF (d)) + fprintf (file, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf"); + else if (REAL_VALUE_ISNAN (d)) + { + /* Print a NaN in the format [-][Q]NaN[(significand[exponent])] + where significand is a hexadecimal string that starts with + the 0x prefix followed by 0 if the number is not canonical + and a non-zero digit if it is, and exponent is decimal. */ + unsigned start = 0; + const char *psig = (const char *) d.sig; + for (unsigned i = 0; i != sizeof d.sig; ++i) + if (psig[i]) + { + start = i; + break; + } + + fprintf (file, " %s%sNaN", d.sign ? "-" : "", + d.signalling ? "S" : "Q"); + + if (brief) + return; + + if (start) + fprintf (file, "(0x%s", d.canonical ? "" : "0"); + else if (d.uexp) + fprintf (file, "(%s", d.canonical ? "" : "0"); + else if (!d.canonical) + { + fprintf (file, "(0)"); + return; + } + + if (psig[start]) + { + for (unsigned i = start; i != sizeof d.sig; ++i) + if (i == start) + fprintf (file, "%x", psig[i]); + else + fprintf (file, "%02x", psig[i]); + } + + if (d.uexp) + fprintf (file, "%se%u)", psig[start] ? "," : "", d.uexp); + else if (psig[start]) + fputc (')', file); + } + else + { + char string[64]; + real_to_decimal (string, &d, sizeof (string), 0, 1); + fprintf (file, " %s", string); + } +} + /* Print a node in brief fashion, with just the code, address and name. */ void @@ -121,24 +186,7 @@ print_node_brief (FILE *file, const char *prefix, const_tree node, int indent) print_dec (wi::to_wide (node), file, TYPE_SIGN (TREE_TYPE (node))); } if (TREE_CODE (node) == REAL_CST) - { - REAL_VALUE_TYPE d; - - if (TREE_OVERFLOW (node)) - fprintf (file, " overflow"); - - d = TREE_REAL_CST (node); - if (REAL_VALUE_ISINF (d)) - fprintf (file, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf"); - else if (REAL_VALUE_ISNAN (d)) - fprintf (file, " Nan"); - else - { - char string[60]; - real_to_decimal (string, &d, sizeof (string), 0, 1); - fprintf (file, " %s", string); - } - } + print_real_cst (file, node, true); if (TREE_CODE (node) == FIXED_CST) { FIXED_VALUE_TYPE f; @@ -730,24 +778,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent, break; case REAL_CST: - { - REAL_VALUE_TYPE d; - - if (TREE_OVERFLOW (node)) - fprintf (file, " overflow"); - - d = TREE_REAL_CST (node); - if (REAL_VALUE_ISINF (d)) - fprintf (file, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf"); - else if (REAL_VALUE_ISNAN (d)) - fprintf (file, " Nan"); - else - { - char string[64]; - real_to_decimal (string, &d, sizeof (string), 0, 1); - fprintf (file, " %s", string); - } - } + print_real_cst (file, node, false); break; case FIXED_CST: |