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