/* Prints out tree in human readable form - GCC
- Copyright (C) 1990, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
- Free Software Foundation, Inc.
+ Copyright (C) 1990-2014 Free Software Foundation, Inc.
This file is part of GCC.
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
+#include "varasm.h"
+#include "print-rtl.h"
+#include "stor-layout.h"
#include "ggc.h"
#include "langhooks.h"
#include "tree-iterator.h"
#include "diagnostic.h"
-#include "gimple-pretty-print.h"
-#include "tree-flow.h"
-#include "tree-pass.h"
+#include "gimple-pretty-print.h" /* FIXME */
+#include "cgraph.h"
+#include "tree-cfg.h"
+#include "tree-dump.h"
+#include "dumpfile.h"
+#include "wide-int-print.h"
/* Define the hash table of nodes already seen.
Such nodes are not repeated; brief cross-references are used. */
static struct bucket **table;
-/* Print the node NODE on standard error, for debugging.
- Most nodes referred to by this one are printed recursively
- down to a depth of six. */
-
-DEBUG_FUNCTION void
-debug_tree (tree node)
-{
- table = XCNEWVEC (struct bucket *, HASH_SIZE);
- print_node (stderr, "", node, 0);
- free (table);
- table = 0;
- putc ('\n', stderr);
-}
-
-/* Print the vector of trees VEC on standard error, for debugging.
- Most nodes referred to by this one are printed recursively
- down to a depth of six. */
-
-DEBUG_FUNCTION void
-debug_vec_tree (VEC(tree,gc) *vec)
-{
- table = XCNEWVEC (struct bucket *, HASH_SIZE);
- print_vec_tree (stderr, "", vec, 0);
- free (table);
- table = 0;
- putc ('\n', stderr);
-}
-
/* Print PREFIX and ADDR to FILE. */
void
dump_addr (FILE *file, const char *prefix, const void *addr)
name if any. */
if (indent > 0)
fprintf (file, " ");
- fprintf (file, "%s <%s", prefix, tree_code_name[(int) TREE_CODE (node)]);
+ fprintf (file, "%s <%s", prefix, get_tree_code_name (TREE_CODE (node)));
dump_addr (file, " ", node);
if (tclass == tcc_declaration)
fprintf (file, " overflow");
fprintf (file, " ");
- if (TREE_INT_CST_HIGH (node) == 0)
- fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED, TREE_INT_CST_LOW (node));
- else if (TREE_INT_CST_HIGH (node) == -1
- && TREE_INT_CST_LOW (node) != 0)
- fprintf (file, "-" HOST_WIDE_INT_PRINT_UNSIGNED,
- -TREE_INT_CST_LOW (node));
- else
- fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
- (unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (node),
- (unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (node));
+ print_dec (node, file, TYPE_SIGN (TREE_TYPE (node)));
}
if (TREE_CODE (node) == REAL_CST)
{
/* Allow this function to be called if the table is not there. */
if (table)
{
- hash = ((unsigned long) node) % HASH_SIZE;
+ hash = ((uintptr_t) node) % HASH_SIZE;
/* If node is in the table, just mention its address. */
for (b = table[hash]; b; b = b->next)
indent_to (file, indent);
/* Print the slot this node is in, and its code, and address. */
- fprintf (file, "%s <%s", prefix, tree_code_name[(int) code]);
+ fprintf (file, "%s <%s", prefix, get_tree_code_name (code));
dump_addr (file, " ", node);
/* Print the name, if any. */
if (TYPE_P (node) ? TYPE_READONLY (node) : TREE_READONLY (node))
fputs (" readonly", file);
+ if (TYPE_P (node) && TYPE_ATOMIC (node))
+ fputs (" atomic", file);
if (!TYPE_P (node) && TREE_CONSTANT (node))
fputs (" constant", file);
else if (TYPE_P (node) && TYPE_SIZES_GIMPLIFIED (node))
fputs (" deprecated", file);
if (TREE_VISITED (node))
fputs (" visited", file);
- if (TREE_LANG_FLAG_0 (node))
- fputs (" tree_0", file);
- if (TREE_LANG_FLAG_1 (node))
- fputs (" tree_1", file);
- if (TREE_LANG_FLAG_2 (node))
- fputs (" tree_2", file);
- if (TREE_LANG_FLAG_3 (node))
- fputs (" tree_3", file);
- if (TREE_LANG_FLAG_4 (node))
- fputs (" tree_4", file);
- if (TREE_LANG_FLAG_5 (node))
- fputs (" tree_5", file);
- if (TREE_LANG_FLAG_6 (node))
- fputs (" tree_6", file);
+
+ if (code != TREE_VEC && code != INTEGER_CST && code != SSA_NAME)
+ {
+ if (TREE_LANG_FLAG_0 (node))
+ fputs (" tree_0", file);
+ if (TREE_LANG_FLAG_1 (node))
+ fputs (" tree_1", file);
+ if (TREE_LANG_FLAG_2 (node))
+ fputs (" tree_2", file);
+ if (TREE_LANG_FLAG_3 (node))
+ fputs (" tree_3", file);
+ if (TREE_LANG_FLAG_4 (node))
+ fputs (" tree_4", file);
+ if (TREE_LANG_FLAG_5 (node))
+ fputs (" tree_5", file);
+ if (TREE_LANG_FLAG_6 (node))
+ fputs (" tree_6", file);
+ }
/* DECL_ nodes have additional attributes. */
fputs (" built-in", file);
if (code == FUNCTION_DECL && DECL_STATIC_CHAIN (node))
fputs (" static-chain", file);
+ if (TREE_CODE (node) == FUNCTION_DECL && decl_is_tm_clone (node))
+ fputs (" tm-clone", file);
if (code == FIELD_DECL && DECL_PACKED (node))
fputs (" packed", file);
if (code == FIELD_DECL && DECL_NONADDRESSABLE_P (node))
fputs (" nonaddressable", file);
- if (code == LABEL_DECL && DECL_ERROR_ISSUED (node))
- fputs (" error-issued", file);
if (code == LABEL_DECL && EH_LANDING_PAD_NR (node))
fprintf (file, " landing-pad:%d", EH_LANDING_PAD_NR (node));
fputs (" common", file);
if (code == VAR_DECL && DECL_THREAD_LOCAL_P (node))
{
- enum tls_model kind = DECL_TLS_MODEL (node);
- switch (kind)
- {
- case TLS_MODEL_GLOBAL_DYNAMIC:
- fputs (" tls-global-dynamic", file);
- break;
- case TLS_MODEL_LOCAL_DYNAMIC:
- fputs (" tls-local-dynamic", file);
- break;
- case TLS_MODEL_INITIAL_EXEC:
- fputs (" tls-initial-exec", file);
- break;
- case TLS_MODEL_LOCAL_EXEC:
- fputs (" tls-local-exec", file);
- break;
- default:
- gcc_unreachable ();
- }
+ fputs (" ", file);
+ fputs (tls_model_names[DECL_TLS_MODEL (node)], file);
}
if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
}
if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
{
- print_node (file, "arguments", DECL_ARGUMENT_FLD (node), indent + 4);
print_node (file, "result", DECL_RESULT_FLD (node), indent + 4);
}
else if (code == FUNCTION_DECL
&& DECL_STRUCT_FUNCTION (node) != 0)
{
+ print_node (file, "arguments", DECL_ARGUMENTS (node), indent + 4);
indent_to (file, indent + 4);
dump_addr (file, "struct-function ", DECL_STRUCT_FUNCTION (node));
}
if (TYPE_UNSIGNED (node))
fputs (" unsigned", file);
- /* The no-force-blk flag is used for different things in
- different types. */
- if ((code == RECORD_TYPE
- || code == UNION_TYPE
- || code == QUAL_UNION_TYPE)
- && TYPE_NO_FORCE_BLK (node))
+ if (TYPE_NO_FORCE_BLK (node))
fputs (" no-force-blk", file);
- else if (code == INTEGER_TYPE
- && TYPE_IS_SIZETYPE (node))
- fputs (" sizetype", file);
if (TYPE_STRING_FLAG (node))
fputs (" string-flag", file);
+
if (TYPE_NEEDS_CONSTRUCTING (node))
fputs (" needs-constructing", file);
fprintf (file, " overflow");
fprintf (file, " ");
- if (TREE_INT_CST_HIGH (node) == 0)
- fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED,
- TREE_INT_CST_LOW (node));
- else if (TREE_INT_CST_HIGH (node) == -1
- && TREE_INT_CST_LOW (node) != 0)
- fprintf (file, "-" HOST_WIDE_INT_PRINT_UNSIGNED,
- -TREE_INT_CST_LOW (node));
- else
- fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
- (unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (node),
- (unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (node));
+ print_dec (node, file, TYPE_SIGN (TREE_TYPE (node)));
break;
case REAL_CST:
case VECTOR_CST:
{
- tree vals = TREE_VECTOR_CST_ELTS (node);
char buf[10];
- tree link;
- int i;
+ unsigned i;
- i = 0;
- for (link = vals; link; link = TREE_CHAIN (link), ++i)
+ for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
{
- sprintf (buf, "elt%d: ", i);
- print_node (file, buf, TREE_VALUE (link), indent + 4);
+ sprintf (buf, "elt%u: ", i);
+ print_node (file, buf, VECTOR_CST_ELT (node, i), indent + 4);
}
}
break;
if (ch >= ' ' && ch < 127)
putc (ch, file);
else
- fprintf(file, "\\%03o", ch & 0xFF);
+ fprintf (file, "\\%03o", ch & 0xFF);
}
fputc ('\"', file);
}
{
unsigned HOST_WIDE_INT cnt;
tree index, value;
- len = VEC_length (constructor_elt, CONSTRUCTOR_ELTS (node));
+ len = vec_safe_length (CONSTRUCTOR_ELTS (node));
fprintf (file, " lngt %d", len);
FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node),
cnt, index, value)
print_node (file, "stmt", tsi_stmt (i), indent + 4);
}
}
- print_node (file, "chain", TREE_CHAIN (node), indent + 4);
break;
case BLOCK:
fprintf (file, ">");
}
-/* Print the tree vector VEC in full on file FILE, preceded by PREFIX,
- starting in column INDENT. */
-void
-print_vec_tree (FILE *file, const char *prefix, VEC(tree,gc) *vec, int indent)
+/* Print the node NODE on standard error, for debugging.
+ Most nodes referred to by this one are printed recursively
+ down to a depth of six. */
+
+DEBUG_FUNCTION void
+debug_tree (tree node)
+{
+ table = XCNEWVEC (struct bucket *, HASH_SIZE);
+ print_node (stderr, "", node, 0);
+ free (table);
+ table = 0;
+ putc ('\n', stderr);
+}
+
+DEBUG_FUNCTION void
+debug_raw (const tree_node &ref)
+{
+ debug_tree (const_cast <tree> (&ref));
+}
+
+DEBUG_FUNCTION void
+debug_raw (const tree_node *ptr)
+{
+ if (ptr)
+ debug_raw (*ptr);
+ else
+ fprintf (stderr, "<nil>\n");
+}
+
+static void
+dump_tree_via_hooks (const tree_node *ptr, int options)
+{
+ if (DECL_P (ptr))
+ lang_hooks.print_decl (stderr, const_cast <tree_node*> (ptr), 0);
+ else if (TYPE_P (ptr))
+ lang_hooks.print_type (stderr, const_cast <tree_node*> (ptr), 0);
+ else if (TREE_CODE (ptr) == IDENTIFIER_NODE)
+ lang_hooks.print_identifier (stderr, const_cast <tree_node*> (ptr), 0);
+ else
+ print_generic_expr (stderr, const_cast <tree_node*> (ptr), options);
+ fprintf (stderr, "\n");
+}
+
+DEBUG_FUNCTION void
+debug (const tree_node &ref)
+{
+ dump_tree_via_hooks (&ref, 0);
+}
+
+DEBUG_FUNCTION void
+debug (const tree_node *ptr)
+{
+ if (ptr)
+ debug (*ptr);
+ else
+ fprintf (stderr, "<nil>\n");
+}
+
+DEBUG_FUNCTION void
+debug_verbose (const tree_node &ref)
+{
+ dump_tree_via_hooks (&ref, TDF_VERBOSE);
+}
+
+DEBUG_FUNCTION void
+debug_verbose (const tree_node *ptr)
+{
+ if (ptr)
+ debug_verbose (*ptr);
+ else
+ fprintf (stderr, "<nil>\n");
+}
+
+DEBUG_FUNCTION void
+debug_head (const tree_node &ref)
+{
+ debug (ref);
+}
+
+DEBUG_FUNCTION void
+debug_head (const tree_node *ptr)
+{
+ if (ptr)
+ debug_head (*ptr);
+ else
+ fprintf (stderr, "<nil>\n");
+}
+
+DEBUG_FUNCTION void
+debug_body (const tree_node &ref)
+{
+ if (TREE_CODE (&ref) == FUNCTION_DECL)
+ dump_function_to_file (const_cast <tree_node*> (&ref), stderr, 0);
+ else
+ debug (ref);
+}
+
+DEBUG_FUNCTION void
+debug_body (const tree_node *ptr)
+{
+ if (ptr)
+ debug_body (*ptr);
+ else
+ fprintf (stderr, "<nil>\n");
+}
+
+/* Print the vector of trees VEC on standard error, for debugging.
+ Most nodes referred to by this one are printed recursively
+ down to a depth of six. */
+
+DEBUG_FUNCTION void
+debug_raw (vec<tree, va_gc> &ref)
{
tree elt;
unsigned ix;
- /* Indent to the specified column, since this is the long form. */
- indent_to (file, indent);
+ /* Print the slot this node is in, and its code, and address. */
+ fprintf (stderr, "<VEC");
+ dump_addr (stderr, " ", ref.address ());
+
+ FOR_EACH_VEC_ELT (ref, ix, elt)
+ {
+ fprintf (stderr, "elt %d ", ix);
+ debug_raw (elt);
+ }
+}
+
+DEBUG_FUNCTION void
+debug (vec<tree, va_gc> &ref)
+{
+ tree elt;
+ unsigned ix;
/* Print the slot this node is in, and its code, and address. */
- fprintf (file, "%s <VEC", prefix);
- dump_addr (file, " ", vec);
+ fprintf (stderr, "<VEC");
+ dump_addr (stderr, " ", ref.address ());
- FOR_EACH_VEC_ELT (tree, vec, ix, elt)
+ FOR_EACH_VEC_ELT (ref, ix, elt)
{
- char temp[10];
- sprintf (temp, "elt %d", ix);
- print_node (file, temp, elt, indent + 4);
+ fprintf (stderr, "elt %d ", ix);
+ debug (elt);
}
}
+
+DEBUG_FUNCTION void
+debug (vec<tree, va_gc> *ptr)
+{
+ if (ptr)
+ debug (*ptr);
+ else
+ fprintf (stderr, "<nil>\n");
+}
+
+DEBUG_FUNCTION void
+debug_raw (vec<tree, va_gc> *ptr)
+{
+ if (ptr)
+ debug_raw (*ptr);
+ else
+ fprintf (stderr, "<nil>\n");
+}
+
+DEBUG_FUNCTION void
+debug_vec_tree (vec<tree, va_gc> *vec)
+{
+ debug_raw (vec);
+}