Commit b7442fb5 by Nathan Sidwell Committed by Nathan Sidwell

c-common.h (flag_dump_translation_unit): Remove.

	* c-common.h (flag_dump_translation_unit): Remove.
	(enum tree_dump_index): Define.
	(TDF_ADDRESS, TDF_SLIM): New #defines.
	(dump_node_to_file): Remove.
	(dump_node): Make extern. Add flags.
	(dump_flag, dump_enabled_p, dump_begin, dump_end,
	dump_switch_p): Prototype.
	* c-common.c (flag_dump_translation_unit): Remove.
	* c-decl.c (c_decode_option): Remove -fdump-translation-unit
	logic. Use dump_switch_p.
	* c-dump.h (struct dump_info): Add node and user fields.
	(dump_pointer): Declare.
	* c-dump.c (dump_node): Make extern. Add flags.
	(SOL_COLUMN, EOL_COLUMN, COLUMN_ALIGNMENT): New #defines.
	(dump_new_line, dump_maybe_newline): Use them.
	(dump_pointer): New function.
	(dequeue_and_dump): Check TDF_SLIM before dumping a _DECL's
	chain or function's body. Dump address, if TDF_ADDRESS set.
	(dump_flag): Define.
	(dump_node_to_file): Remove.
	(struct dump_file_info): New struct.
	(dump_files): New array.
	(dump_begin, dump_end, dump_enabled_p, dump_switch_p): Define.
	* c-lang.c (finish_file): Adjust dumping.
	* toplev.h (dump_base_name): Make extern.
	* invoke.texi: Document new flags.
cp:
	* class.c (maybe_indent_hierarchy): New function.
	(dump_class_hierarchy_r): Add flags. Dump extra binfo
	information, if enabled. Use maybe_indent_hierarchy. Adjust
	output format.
	(dump_class_hierarchy): Adjust prototype. Adjust output format.
	(dump_array, dump_vtable, dump_vtt): New functions.
	(finish_struct_1): Adjust hierarchy dumping.
	(initialize_vtable): Call dump_vtable.
	(build_vtt): Call dump_vtt.
	(build_ctor_vtbl_group): Call dump_vtable.
	* decl2.c (flag_dump_class_layout): Remove.
	(cxx_decode_option): Remove dump translation unit
	and dump class hierarchy check. Call dump_switch_p.
	(finish_file): Adjust dumping.
	(dump.c): Only dump base classes if not TDF_SLIM.
	Only dump namespace members if not TDF_SLIM.
	* optimize.c (dump_function): New function.
	(optimize_function): Call dump_function.
	* semantics.c (expand_body): Use dump_enabled_p.

From-SVN: r42896
parent eb537d4f
2001-06-05 Nathan Sidwell <nathan@codesourcery.com>
* c-common.h (flag_dump_translation_unit): Remove.
(enum tree_dump_index): Define.
(TDF_ADDRESS, TDF_SLIM): New #defines.
(dump_node_to_file): Remove.
(dump_node): Make extern. Add flags.
(dump_flag, dump_enabled_p, dump_begin, dump_end,
dump_switch_p): Prototype.
* c-common.c (flag_dump_translation_unit): Remove.
* c-decl.c (c_decode_option): Remove -fdump-translation-unit
logic. Use dump_switch_p.
* c-dump.h (struct dump_info): Add node and user fields.
(dump_pointer): Declare.
* c-dump.c (dump_node): Make extern. Add flags.
(SOL_COLUMN, EOL_COLUMN, COLUMN_ALIGNMENT): New #defines.
(dump_new_line, dump_maybe_newline): Use them.
(dump_pointer): New function.
(dequeue_and_dump): Check TDF_SLIM before dumping a _DECL's
chain or function's body. Dump address, if TDF_ADDRESS set.
(dump_flag): Define.
(dump_node_to_file): Remove.
(struct dump_file_info): New struct.
(dump_files): New array.
(dump_begin, dump_end, dump_enabled_p, dump_switch_p): Define.
* c-lang.c (finish_file): Adjust dumping.
* toplev.h (dump_base_name): Make extern.
* invoke.texi: Document new flags.
2001-06-04 Mark Mitchell <mark@codesourcery.com> 2001-06-04 Mark Mitchell <mark@codesourcery.com>
* c-tree.h (lang_decl): Add pending_sizes fields. * c-tree.h (lang_decl): Add pending_sizes fields.
......
...@@ -189,11 +189,6 @@ int flag_short_double; ...@@ -189,11 +189,6 @@ int flag_short_double;
int flag_short_wchar; int flag_short_wchar;
/* If non-NULL, dump the tree structure for the entire translation
unit to this file. */
const char *flag_dump_translation_unit;
/* Nonzero means warn about possible violations of sequence point rules. */ /* Nonzero means warn about possible violations of sequence point rules. */
int warn_sequence_point; int warn_sequence_point;
......
...@@ -427,11 +427,6 @@ extern int flag_no_builtin; ...@@ -427,11 +427,6 @@ extern int flag_no_builtin;
extern int flag_no_nonansi_builtin; extern int flag_no_nonansi_builtin;
/* If non-NULL, dump the tree structure for the entire translation
unit to this file. */
extern const char *flag_dump_translation_unit;
/* Nonzero means warn about suggesting putting in ()'s. */ /* Nonzero means warn about suggesting putting in ()'s. */
extern int warn_parentheses; extern int warn_parentheses;
...@@ -811,6 +806,20 @@ extern int c_unsafe_for_reeval PARAMS ((tree)); ...@@ -811,6 +806,20 @@ extern int c_unsafe_for_reeval PARAMS ((tree));
/* In dump.c */ /* In dump.c */
/* Different tree dump places. */
enum tree_dump_index
{
TDI_all, /* dump the whole translation unit */
TDI_original, /* dump each function before optimizing it */
TDI_optimized, /* dump each function after optimizing it */
TDI_class, /* dump class heirarchy */
TDI_end
};
/* Bit masks to control tree dumping. */
#define TDF_ADDRESS (1 << 0) /* dump node addresses */
#define TDF_SLIM (1 << 1) /* don't go wild following links */
typedef struct dump_info *dump_info_p; typedef struct dump_info *dump_info_p;
/* A callback function used dump language-specific parts of tree /* A callback function used dump language-specific parts of tree
...@@ -821,7 +830,12 @@ typedef int (*dump_tree_fn) PARAMS ((dump_info_p, tree)); ...@@ -821,7 +830,12 @@ typedef int (*dump_tree_fn) PARAMS ((dump_info_p, tree));
extern dump_tree_fn lang_dump_tree; extern dump_tree_fn lang_dump_tree;
extern void dump_node_to_file PARAMS ((tree, const char *)); extern int dump_flag PARAMS ((dump_info_p, int, tree));
extern int dump_enabled_p PARAMS ((enum tree_dump_index));
extern FILE *dump_begin PARAMS ((enum tree_dump_index, int *));
extern void dump_end PARAMS ((enum tree_dump_index, FILE *));
extern void dump_node PARAMS ((tree, int, FILE *));
extern int dump_switch_p PARAMS ((const char *));
/* Information recorded about each file examined during compilation. */ /* Information recorded about each file examined during compilation. */
......
...@@ -447,7 +447,6 @@ c_decode_option (argc, argv) ...@@ -447,7 +447,6 @@ c_decode_option (argc, argv)
char **argv; char **argv;
{ {
int strings_processed; int strings_processed;
const char *option_value = NULL;
char *p = argv[0]; char *p = argv[0];
strings_processed = cpp_handle_option (parse_in, argc, argv); strings_processed = cpp_handle_option (parse_in, argc, argv);
...@@ -593,14 +592,8 @@ c_decode_option (argc, argv) ...@@ -593,14 +592,8 @@ c_decode_option (argc, argv)
flag_no_builtin = 0; flag_no_builtin = 0;
else if (!strcmp (p, "-fno-builtin")) else if (!strcmp (p, "-fno-builtin"))
flag_no_builtin = 1; flag_no_builtin = 1;
else if ((option_value else if (dump_switch_p (p))
= skip_leading_substring (p, "-fdump-translation-unit-"))) ;
{
if (p[22] == '\0')
error ("no file specified with -fdump-translation-unit");
else
flag_dump_translation_unit = option_value;
}
else if (!strcmp (p, "-ansi")) else if (!strcmp (p, "-ansi"))
goto iso_1990; goto iso_1990;
else if (!strcmp (p, "-Werror-implicit-function-declaration")) else if (!strcmp (p, "-Werror-implicit-function-declaration"))
......
...@@ -40,7 +40,6 @@ static void dequeue_and_dump PARAMS ((dump_info_p)); ...@@ -40,7 +40,6 @@ static void dequeue_and_dump PARAMS ((dump_info_p));
static void dump_new_line PARAMS ((dump_info_p)); static void dump_new_line PARAMS ((dump_info_p));
static void dump_maybe_newline PARAMS ((dump_info_p)); static void dump_maybe_newline PARAMS ((dump_info_p));
static void dump_string_field PARAMS ((dump_info_p, const char *, const char *)); static void dump_string_field PARAMS ((dump_info_p, const char *, const char *));
static void dump_node PARAMS ((tree, FILE *));
/* Add T to the end of the queue of nodes to dump. Returns the index /* Add T to the end of the queue of nodes to dump. Returns the index
assigned to T. */ assigned to T. */
...@@ -139,6 +138,11 @@ queue_and_dump_type (di, t) ...@@ -139,6 +138,11 @@ queue_and_dump_type (di, t)
queue_and_dump_index (di, "type", TREE_TYPE (t), DUMP_NONE); queue_and_dump_index (di, "type", TREE_TYPE (t), DUMP_NONE);
} }
/* Dump column control */
#define SOL_COLUMN 25 /* Start of line column. */
#define EOL_COLUMN 55 /* End of line column. */
#define COLUMN_ALIGNMENT 15 /* Alignment. */
/* Insert a new line in the dump output, and indent to an appropriate /* Insert a new line in the dump output, and indent to an appropriate
place to start printing more fields. */ place to start printing more fields. */
...@@ -146,8 +150,8 @@ static void ...@@ -146,8 +150,8 @@ static void
dump_new_line (di) dump_new_line (di)
dump_info_p di; dump_info_p di;
{ {
fprintf (di->stream, "\n%25s", ""); fprintf (di->stream, "\n%*s", SOL_COLUMN, "");
di->column = 25; di->column = SOL_COLUMN;
} }
/* If necessary, insert a new line. */ /* If necessary, insert a new line. */
...@@ -156,18 +160,33 @@ static void ...@@ -156,18 +160,33 @@ static void
dump_maybe_newline (di) dump_maybe_newline (di)
dump_info_p di; dump_info_p di;
{ {
int extra;
/* See if we need a new line. */ /* See if we need a new line. */
if (di->column > 53) if (di->column > EOL_COLUMN)
dump_new_line (di); dump_new_line (di);
/* See if we need any padding. */ /* See if we need any padding. */
else if ((di->column - 25) % 14 != 0) else if ((extra = (di->column - SOL_COLUMN) % COLUMN_ALIGNMENT) != 0)
{ {
fprintf (di->stream, "%*s", 14 - ((di->column - 25) % 14), ""); fprintf (di->stream, "%*s", COLUMN_ALIGNMENT - extra, "");
di->column += 14 - (di->column - 25) % 14; di->column += COLUMN_ALIGNMENT - extra;
} }
} }
/* Dump I using FIELD to identity it. */ /* Dump pointer PTR using FIELD to identify it. */
void
dump_pointer (di, field, ptr)
dump_info_p di;
const char *field;
void *ptr;
{
dump_maybe_newline (di);
fprintf (di->stream, "%-4s: %-8lx ", field, (long) ptr);
di->column += 15;
}
/* Dump integer I using FIELD to identify it. */
void void
dump_int (di, field, i) dump_int (di, field, i)
...@@ -349,7 +368,7 @@ dequeue_and_dump (di) ...@@ -349,7 +368,7 @@ dequeue_and_dump (di)
/* And any declaration can be compiler-generated. */ /* And any declaration can be compiler-generated. */
if (DECL_ARTIFICIAL (t)) if (DECL_ARTIFICIAL (t))
dump_string (di, "artificial"); dump_string (di, "artificial");
if (TREE_CHAIN (t)) if (TREE_CHAIN (t) && !dump_flag (di, TDF_SLIM, NULL))
dump_child ("chan", TREE_CHAIN (t)); dump_child ("chan", TREE_CHAIN (t));
} }
else if (code_class == 't') else if (code_class == 't')
...@@ -504,7 +523,7 @@ dequeue_and_dump (di) ...@@ -504,7 +523,7 @@ dequeue_and_dump (di)
dump_string (di, "extern"); dump_string (di, "extern");
else else
dump_string (di, "static"); dump_string (di, "static");
if (DECL_LANG_SPECIFIC (t)) if (DECL_LANG_SPECIFIC (t) && !dump_flag (di, TDF_SLIM, t))
dump_child ("body", DECL_SAVED_TREE (t)); dump_child ("body", DECL_SAVED_TREE (t));
break; break;
...@@ -709,15 +728,30 @@ dequeue_and_dump (di) ...@@ -709,15 +728,30 @@ dequeue_and_dump (di)
} }
done: done:
if (dump_flag (di, TDF_ADDRESS, NULL))
dump_pointer (di, "addr", (void *)t);
/* Terminate the line. */ /* Terminate the line. */
fprintf (di->stream, "\n"); fprintf (di->stream, "\n");
} }
/* Return non-zero if FLAG has been specified for the dump, and NODE
is not the root node of the dump. */
int dump_flag (di, flag, node)
dump_info_p di;
int flag;
tree node;
{
return (di->flags & flag) && (node != di->node);
}
/* Dump T, and all its children, on STREAM. */ /* Dump T, and all its children, on STREAM. */
static void void
dump_node (t, stream) dump_node (t, flags, stream)
tree t; tree t;
int flags;
FILE *stream; FILE *stream;
{ {
struct dump_info di; struct dump_info di;
...@@ -731,6 +765,8 @@ dump_node (t, stream) ...@@ -731,6 +765,8 @@ dump_node (t, stream)
di.queue = 0; di.queue = 0;
di.queue_end = 0; di.queue_end = 0;
di.free_list = 0; di.free_list = 0;
di.flags = flags;
di.node = t;
di.nodes = splay_tree_new (splay_tree_compare_pointers, 0, di.nodes = splay_tree_new (splay_tree_compare_pointers, 0,
(splay_tree_delete_value_fn) &free); (splay_tree_delete_value_fn) &free);
...@@ -750,21 +786,92 @@ dump_node (t, stream) ...@@ -750,21 +786,92 @@ dump_node (t, stream)
splay_tree_delete (di.nodes); splay_tree_delete (di.nodes);
} }
/* Dump T, and all its children, to FILE. */ /* Define a tree dump switch. */
struct dump_file_info
{
const char *suffix; /* suffix to give output file. */
const char *swtch; /* command line switch */
int flags; /* user flags */
int state; /* state of play */
};
/* Table of tree dump switches. */
static struct dump_file_info dump_files[TDI_end] =
{
{".tu", "dump-translation-unit", 0, 0},
{".original", "dump-ast-original", 0, 0},
{".optimized", "dump-ast-optimized", 0, 0},
{".class", "dump-class-hierarchy", 0, 0},
};
/* Begin a tree dump for PHASE. Stores any user supplied flag in
*FLAG_PTR and returns a stream to write to. If the dump is not
enabled, returns NULL.
Multiple calls will reopen and append to the dump file. */
FILE *
dump_begin (phase, flag_ptr)
enum tree_dump_index phase;
int *flag_ptr;
{
FILE *stream;
char *name;
if (!dump_files[phase].state)
return NULL;
name = concat (dump_base_name, dump_files[phase].suffix, NULL);
stream = fopen (name, dump_files[phase].state < 0 ? "w" : "a");
if (!stream)
error ("could not open dump file `%s'", name);
else
dump_files[phase].state = 1;
free (name);
if (flag_ptr)
*flag_ptr = dump_files[phase].flags;
return stream;
}
void /* Returns non-zero if tree dump PHASE is enabled. */
dump_node_to_file (t, file)
tree t; int dump_enabled_p (phase)
const char *file; enum tree_dump_index phase;
{ {
FILE *f; return dump_files[phase].state;
}
f = fopen (file, "w"); /* Finish a tree dump for PHASE. STREAM is the stream created by
if (!f) dump_begin. */
error ("could not open dump file `%s'", file);
else void dump_end (phase, stream)
{ enum tree_dump_index phase ATTRIBUTE_UNUSED;
dump_node (t, f); FILE *stream;
fclose (f); {
} fclose (stream);
}
/* Parse ARG as a dump switch. Return non-zero if it is, and store the
relevant details in the dump_files array. */
int dump_switch_p (arg)
const char *arg;
{
unsigned ix;
const char *option_value;
for (ix = 0; ix != TDI_end; ix++)
if ((option_value = skip_leading_substring (arg, dump_files[ix].swtch)))
{
dump_files[ix].state = -1;
if (*option_value == '-')
dump_files[ix].flags
= read_integral_parameter (option_value + 1, arg, 0);
else if (*option_value)
warning ("ignoring `%s' at end of `-f%s'",
option_value, dump_files[ix].swtch);
return 1;
}
return 0;
} }
...@@ -53,6 +53,10 @@ struct dump_info ...@@ -53,6 +53,10 @@ struct dump_info
{ {
/* The stream on which to dump the information. */ /* The stream on which to dump the information. */
FILE *stream; FILE *stream;
/* The original node. */
tree node;
/* User flags. */
int flags;
/* The next unused node index. */ /* The next unused node index. */
unsigned int index; unsigned int index;
/* The next column. */ /* The next column. */
...@@ -73,6 +77,8 @@ struct dump_info ...@@ -73,6 +77,8 @@ struct dump_info
#define dump_child(field, child) \ #define dump_child(field, child) \
queue_and_dump_index (di, field, child, DUMP_NONE) queue_and_dump_index (di, field, child, DUMP_NONE)
extern void dump_pointer
PARAMS ((dump_info_p, const char *, void *));
extern void dump_int extern void dump_int
PARAMS ((dump_info_p, const char *, int)); PARAMS ((dump_info_p, const char *, int));
extern void dump_string extern void dump_string
......
...@@ -252,9 +252,17 @@ finish_file () ...@@ -252,9 +252,17 @@ finish_file ()
if (back_end_hook) if (back_end_hook)
(*back_end_hook) (getdecls ()); (*back_end_hook) (getdecls ());
{
int flags;
FILE *stream = dump_begin (TDI_all, &flags);
if (flag_dump_translation_unit) if (stream)
dump_node_to_file (getdecls (), flag_dump_translation_unit); {
dump_node (getdecls (), flags & ~TDF_SLIM, stream);
dump_end (TDI_all, stream);
}
}
} }
/* Called during diagnostic message formatting process to print a /* Called during diagnostic message formatting process to print a
......
2001-06-05 Nathan Sidwell <nathan@codesourcery.com>
* class.c (maybe_indent_hierarchy): New function.
(dump_class_hierarchy_r): Add flags. Dump extra binfo
information, if enabled. Use maybe_indent_hierarchy. Adjust
output format.
(dump_class_hierarchy): Adjust prototype. Adjust output format.
(dump_array, dump_vtable, dump_vtt): New functions.
(finish_struct_1): Adjust hierarchy dumping.
(initialize_vtable): Call dump_vtable.
(build_vtt): Call dump_vtt.
(build_ctor_vtbl_group): Call dump_vtable.
* decl2.c (flag_dump_class_layout): Remove.
(cxx_decode_option): Remove dump translation unit
and dump class hierarchy check. Call dump_switch_p.
(finish_file): Adjust dumping.
(dump.c): Only dump base classes if not TDF_SLIM.
Only dump namespace members if not TDF_SLIM.
* optimize.c (dump_function): New function.
(optimize_function): Call dump_function.
* semantics.c (expand_body): Use dump_enabled_p.
2001-06-01 Nathan Sidwell <nathan@codesourcery.com> 2001-06-01 Nathan Sidwell <nathan@codesourcery.com>
PR g++/2936 PR g++/2936
......
...@@ -171,8 +171,12 @@ static void layout_vtable_decl PARAMS ((tree, int)); ...@@ -171,8 +171,12 @@ static void layout_vtable_decl PARAMS ((tree, int));
static tree dfs_find_final_overrider PARAMS ((tree, void *)); static tree dfs_find_final_overrider PARAMS ((tree, void *));
static tree find_final_overrider PARAMS ((tree, tree, tree)); static tree find_final_overrider PARAMS ((tree, tree, tree));
static int make_new_vtable PARAMS ((tree, tree)); static int make_new_vtable PARAMS ((tree, tree));
static void dump_class_hierarchy_r PARAMS ((FILE *, tree, tree, int)); static int maybe_indent_hierarchy PARAMS ((FILE *, int, int));
extern void dump_class_hierarchy PARAMS ((const char *, tree)); static void dump_class_hierarchy_r PARAMS ((FILE *, int, tree, tree, int));
static void dump_class_hierarchy PARAMS ((tree));
static void dump_array PARAMS ((FILE *, tree));
static void dump_vtable PARAMS ((tree, tree, tree));
static void dump_vtt PARAMS ((tree, tree));
static tree build_vtable PARAMS ((tree, tree, tree)); static tree build_vtable PARAMS ((tree, tree, tree));
static void initialize_vtable PARAMS ((tree, tree)); static void initialize_vtable PARAMS ((tree, tree));
static void initialize_array PARAMS ((tree, tree)); static void initialize_array PARAMS ((tree, tree));
...@@ -5308,11 +5312,6 @@ finish_struct_1 (t) ...@@ -5308,11 +5312,6 @@ finish_struct_1 (t)
layout_class_type (t, &empty, &vfuns, layout_class_type (t, &empty, &vfuns,
&new_virtuals, &overridden_virtuals); &new_virtuals, &overridden_virtuals);
if (flag_dump_class_layout)
dump_class_hierarchy (*flag_dump_class_layout
? flag_dump_class_layout : NULL,
t);
/* Set up the DECL_FIELD_BITPOS of the vfield if we need to, as we /* Set up the DECL_FIELD_BITPOS of the vfield if we need to, as we
might need to know it for setting up the offsets in the vtable might need to know it for setting up the offsets in the vtable
(or in thunks) below. */ (or in thunks) below. */
...@@ -5468,6 +5467,8 @@ finish_struct_1 (t) ...@@ -5468,6 +5467,8 @@ finish_struct_1 (t)
maybe_suppress_debug_info (t); maybe_suppress_debug_info (t);
dump_class_hierarchy (t);
/* Finish debugging output for this type. */ /* Finish debugging output for this type. */
rest_of_type_compilation (t, ! LOCAL_CLASS_P (t)); rest_of_type_compilation (t, ! LOCAL_CLASS_P (t));
} }
...@@ -6805,22 +6806,38 @@ get_primary_binfo (binfo) ...@@ -6805,22 +6806,38 @@ get_primary_binfo (binfo)
return result; return result;
} }
/* If INDENTED_P is zero, indent to INDENT. Return non-zero. */
static int
maybe_indent_hierarchy (stream, indent, indented_p)
FILE *stream;
int indent;
int indented_p;
{
if (!indented_p)
fprintf (stream, "%*s", indent, "");
return 1;
}
/* Dump the offsets of all the bases rooted at BINFO (in the hierarchy /* Dump the offsets of all the bases rooted at BINFO (in the hierarchy
dominated by T) to stderr. INDENT should be zero when called from dominated by T) to stderr. INDENT should be zero when called from
the top level; it is incremented recursively. */ the top level; it is incremented recursively. */
static void static void
dump_class_hierarchy_r (stream, t, binfo, indent) dump_class_hierarchy_r (stream, flags, t, binfo, indent)
FILE *stream; FILE *stream;
int flags;
tree t; tree t;
tree binfo; tree binfo;
int indent; int indent;
{ {
int i; int i;
int indented = 0;
fprintf (stream, "%*s0x%lx (%s) ", indent, "",
(unsigned long) binfo, indented = maybe_indent_hierarchy (stream, indent, 0);
type_as_string (binfo, TFF_PLAIN_IDENTIFIER)); fprintf (stream, "%s (0x%lx) ",
type_as_string (binfo, TFF_PLAIN_IDENTIFIER),
(unsigned long) binfo);
fprintf (stream, HOST_WIDE_INT_PRINT_DEC, fprintf (stream, HOST_WIDE_INT_PRINT_DEC,
tree_low_cst (BINFO_OFFSET (binfo), 0)); tree_low_cst (BINFO_OFFSET (binfo), 0));
if (is_empty_class (BINFO_TYPE (binfo))) if (is_empty_class (BINFO_TYPE (binfo)))
...@@ -6830,51 +6847,174 @@ dump_class_hierarchy_r (stream, t, binfo, indent) ...@@ -6830,51 +6847,174 @@ dump_class_hierarchy_r (stream, t, binfo, indent)
if (TREE_VIA_VIRTUAL (binfo)) if (TREE_VIA_VIRTUAL (binfo))
{ {
tree canonical = binfo_for_vbase (BINFO_TYPE (binfo), t); tree canonical = binfo_for_vbase (BINFO_TYPE (binfo), t);
fprintf (stream, " virtual");
if (canonical == binfo) if (canonical == binfo)
fprintf (stream, " virtual-canonical"); fprintf (stream, " canonical");
else else
fprintf (stream, " virtual-non-canonical"); fprintf (stream, " non-canonical");
} }
if (BINFO_PRIMARY_P (binfo))
fprintf (stream, " primary-for 0x%lx (%s)",
(unsigned long)BINFO_PRIMARY_BASE_OF (binfo),
type_as_string (BINFO_PRIMARY_BASE_OF (binfo), TFF_PLAIN_IDENTIFIER));
if (BINFO_LOST_PRIMARY_P (binfo))
fprintf (stream, " lost-primary");
fprintf (stream, "\n"); fprintf (stream, "\n");
indented = 0;
if (BINFO_PRIMARY_BASE_OF (binfo))
{
indented = maybe_indent_hierarchy (stream, indent + 3, indented);
fprintf (stream, " primary-for %s (0x%lx)",
type_as_string (BINFO_PRIMARY_BASE_OF (binfo),
TFF_PLAIN_IDENTIFIER),
(unsigned long)BINFO_PRIMARY_BASE_OF (binfo));
}
if (BINFO_LOST_PRIMARY_P (binfo))
{
indented = maybe_indent_hierarchy (stream, indent + 3, indented);
fprintf (stream, " lost-primary");
}
if (indented)
fprintf (stream, "\n");
if (!(flags & TDF_SLIM))
{
int indented = 0;
if (BINFO_SUBVTT_INDEX (binfo))
{
indented = maybe_indent_hierarchy (stream, indent + 3, indented);
fprintf (stream, " subvttidx=%s",
expr_as_string (BINFO_SUBVTT_INDEX (binfo),
TFF_PLAIN_IDENTIFIER));
}
if (BINFO_VPTR_INDEX (binfo))
{
indented = maybe_indent_hierarchy (stream, indent + 3, indented);
fprintf (stream, " vptridx=%s",
expr_as_string (BINFO_VPTR_INDEX (binfo),
TFF_PLAIN_IDENTIFIER));
}
if (BINFO_VPTR_FIELD (binfo))
{
indented = maybe_indent_hierarchy (stream, indent + 3, indented);
fprintf (stream, " vbaseoffset=%s",
expr_as_string (BINFO_VPTR_FIELD (binfo),
TFF_PLAIN_IDENTIFIER));
}
if (BINFO_VTABLE (binfo))
{
indented = maybe_indent_hierarchy (stream, indent + 3, indented);
fprintf (stream, " vptr=%s",
expr_as_string (BINFO_VTABLE (binfo),
TFF_PLAIN_IDENTIFIER));
}
if (indented)
fprintf (stream, "\n");
}
for (i = 0; i < BINFO_N_BASETYPES (binfo); ++i) for (i = 0; i < BINFO_N_BASETYPES (binfo); ++i)
dump_class_hierarchy_r (stream, t, BINFO_BASETYPE (binfo, i), indent + 2); dump_class_hierarchy_r (stream, flags,
t, BINFO_BASETYPE (binfo, i),
indent + 2);
} }
/* Dump the BINFO hierarchy for T. */ /* Dump the BINFO hierarchy for T. */
void static void
dump_class_hierarchy (name, t) dump_class_hierarchy (t)
const char *name;
tree t; tree t;
{ {
FILE *stream = stderr; int flags;
FILE *stream = dump_begin (TDI_class, &flags);
if (!stream)
return;
if (name) fprintf (stream, "Class %s\n", type_as_string (t, TFF_PLAIN_IDENTIFIER));
fprintf (stream, " size=%lu align=%lu\n",
(unsigned long)(tree_low_cst (TYPE_SIZE (t), 0) / BITS_PER_UNIT),
(unsigned long)(TYPE_ALIGN (t) / BITS_PER_UNIT));
dump_class_hierarchy_r (stream, flags, t, TYPE_BINFO (t), 0);
fprintf (stream, "\n");
dump_end (TDI_class, stream);
}
static void
dump_array (stream, decl)
FILE *stream;
tree decl;
{
tree inits;
int ix;
HOST_WIDE_INT elt;
tree size = TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (decl)));
elt = (tree_low_cst (TYPE_SIZE (TREE_TYPE (TREE_TYPE (decl))), 0)
/ BITS_PER_UNIT);
fprintf (stream, "%s:", decl_as_string (decl, TFF_PLAIN_IDENTIFIER));
fprintf (stream, " %s entries",
expr_as_string (size_binop (PLUS_EXPR, size, size_one_node),
TFF_PLAIN_IDENTIFIER));
fprintf (stream, "\n");
for (ix = 0, inits = TREE_OPERAND (DECL_INITIAL (decl), 1);
inits; ix++, inits = TREE_CHAIN (inits))
fprintf (stream, "%-4d %s\n", ix * elt,
expr_as_string (TREE_VALUE (inits), TFF_PLAIN_IDENTIFIER));
}
static void
dump_vtable (t, binfo, vtable)
tree t;
tree binfo;
tree vtable;
{
int flags;
FILE *stream = dump_begin (TDI_class, &flags);
if (!stream)
return;
if (!(flags & TDF_SLIM))
{ {
static int append = 0; int ctor_vtbl_p = TYPE_BINFO (t) != binfo;
stream = fopen (name, append++ ? "a" : "w"); fprintf (stream, "%s for %s",
if (!stream) ctor_vtbl_p ? "Construction vtable" : "Vtable",
error ("could not open dump file `%s'", name); type_as_string (binfo, TFF_PLAIN_IDENTIFIER));
return; if (ctor_vtbl_p)
{
if (!TREE_VIA_VIRTUAL (binfo))
fprintf (stream, " (0x%lx instance)", (unsigned long)binfo);
fprintf (stream, " in %s", type_as_string (t, TFF_PLAIN_IDENTIFIER));
}
fprintf (stream, "\n");
dump_array (stream, vtable);
fprintf (stream, "\n");
} }
fprintf (stream, "%s size=", type_as_string (t, TFF_PLAIN_IDENTIFIER));
fprintf (stream, HOST_WIDE_INT_PRINT_DEC, dump_end (TDI_class, stream);
tree_low_cst (TYPE_SIZE (t), 0) / BITS_PER_UNIT); }
fprintf (stream, " align=%lu\n",
(unsigned long)(TYPE_ALIGN (t) / BITS_PER_UNIT)); static void
dump_class_hierarchy_r (stream, t, TYPE_BINFO (t), 0); dump_vtt (t, vtt)
fprintf (stream, "\n"); tree t;
if (name) tree vtt;
fclose (stream); {
int flags;
FILE *stream = dump_begin (TDI_class, &flags);
if (!stream)
return;
if (!(flags & TDF_SLIM))
{
fprintf (stream, "VTT for %s\n",
type_as_string (t, TFF_PLAIN_IDENTIFIER));
dump_array (stream, vtt);
fprintf (stream, "\n");
}
dump_end (TDI_class, stream);
} }
/* Virtual function table initialization. */ /* Virtual function table initialization. */
...@@ -6957,6 +7097,7 @@ initialize_vtable (binfo, inits) ...@@ -6957,6 +7097,7 @@ initialize_vtable (binfo, inits)
layout_vtable_decl (binfo, list_length (inits)); layout_vtable_decl (binfo, list_length (inits));
decl = get_vtbl_decl_for_binfo (binfo); decl = get_vtbl_decl_for_binfo (binfo);
initialize_array (decl, inits); initialize_array (decl, inits);
dump_vtable (BINFO_TYPE (binfo), binfo, decl);
} }
/* Initialize DECL (a declaration for a namespace-scope array) with /* Initialize DECL (a declaration for a namespace-scope array) with
...@@ -7015,6 +7156,8 @@ build_vtt (t) ...@@ -7015,6 +7156,8 @@ build_vtt (t)
vtt = build_vtable (t, get_vtt_name (t), type); vtt = build_vtable (t, get_vtt_name (t), type);
pushdecl_top_level (vtt); pushdecl_top_level (vtt);
initialize_array (vtt, inits); initialize_array (vtt, inits);
dump_vtt (t, vtt);
} }
/* The type corresponding to BASE_BINFO is a base of the type of BINFO, but /* The type corresponding to BASE_BINFO is a base of the type of BINFO, but
...@@ -7332,6 +7475,7 @@ build_ctor_vtbl_group (binfo, t) ...@@ -7332,6 +7475,7 @@ build_ctor_vtbl_group (binfo, t)
/* Initialize the construction vtable. */ /* Initialize the construction vtable. */
pushdecl_top_level (vtbl); pushdecl_top_level (vtbl);
initialize_array (vtbl, inits); initialize_array (vtbl, inits);
dump_vtable (t, binfo, vtbl);
} }
/* Add the vtbl initializers for BINFO (and its bases other than /* Add the vtbl initializers for BINFO (and its bases other than
......
...@@ -368,10 +368,6 @@ int flag_operator_names = 1; ...@@ -368,10 +368,6 @@ int flag_operator_names = 1;
int flag_check_new; int flag_check_new;
/* Nonnull if we want to dump class heirarchies. */
const char *flag_dump_class_layout;
/* Nonzero if we want the new ISO rules for pushing a new scope for `for' /* Nonzero if we want the new ISO rules for pushing a new scope for `for'
initialization variables. initialization variables.
0: Old rules, set by -fno-for-scope. 0: Old rules, set by -fno-for-scope.
...@@ -590,24 +586,8 @@ cxx_decode_option (argc, argv) ...@@ -590,24 +586,8 @@ cxx_decode_option (argc, argv)
warning ("-fname-mangling-version is no longer supported"); warning ("-fname-mangling-version is no longer supported");
return 1; return 1;
} }
else if ((option_value else if (dump_switch_p (p))
= skip_leading_substring (p, "dump-translation-unit="))) ;
{
if (!*option_value)
error ("no file specified with -fdump-translation-unit");
else
flag_dump_translation_unit = option_value;
}
else if ((option_value
= skip_leading_substring (p, "dump-class-layout=")))
{
if (!*option_value)
error ("no file specified with -fdump-class-layout");
else
flag_dump_class_layout = option_value;
}
else if (!strcmp (p, "dump-class-layout"))
flag_dump_class_layout = ""; /* empty string for stderr */
else else
{ {
int found = 0; int found = 0;
...@@ -3715,9 +3695,17 @@ finish_file () ...@@ -3715,9 +3695,17 @@ finish_file ()
/* The entire file is now complete. If requested, dump everything /* The entire file is now complete. If requested, dump everything
to a file. */ to a file. */
if (flag_dump_translation_unit) {
dump_node_to_file (global_namespace, flag_dump_translation_unit); int flags;
FILE *stream = dump_begin (TDI_all, &flags);
if (stream)
{
dump_node (global_namespace, flags & ~TDF_SLIM, stream);
dump_end (TDI_all, stream);
}
}
/* If there's some tool that wants to examine the entire translation /* If there's some tool that wants to examine the entire translation
unit, let it do so now. */ unit, let it do so now. */
if (back_end_hook) if (back_end_hook)
......
...@@ -101,19 +101,20 @@ cp_dump_tree (di, t) ...@@ -101,19 +101,20 @@ cp_dump_tree (di, t)
} }
dump_child ("vfld", TYPE_VFIELD (t)); dump_child ("vfld", TYPE_VFIELD (t));
{ if (!dump_flag (di, TDF_SLIM, t))
int i; {
int i;
for (i = 0; i < CLASSTYPE_N_BASECLASSES (t); ++i)
{ for (i = 0; i < CLASSTYPE_N_BASECLASSES (t); ++i)
tree base_binfo = BINFO_BASETYPE (TYPE_BINFO (t), i); {
dump_child ("base", BINFO_TYPE (base_binfo)); tree base_binfo = BINFO_BASETYPE (TYPE_BINFO (t), i);
if (TREE_VIA_VIRTUAL (base_binfo)) dump_child ("base", BINFO_TYPE (base_binfo));
dump_string (di, "virtual"); if (TREE_VIA_VIRTUAL (base_binfo))
dump_access (di, base_binfo); dump_string (di, "virtual");
} dump_access (di, base_binfo);
} }
}
break; break;
case FIELD_DECL: case FIELD_DECL:
...@@ -163,7 +164,7 @@ cp_dump_tree (di, t) ...@@ -163,7 +164,7 @@ cp_dump_tree (di, t)
break; break;
if (DECL_NAMESPACE_ALIAS (t)) if (DECL_NAMESPACE_ALIAS (t))
dump_child ("alis", DECL_NAMESPACE_ALIAS (t)); dump_child ("alis", DECL_NAMESPACE_ALIAS (t));
else else if (!dump_flag (di, TDF_SLIM, t))
dump_child ("dcls", cp_namespace_decls (t)); dump_child ("dcls", cp_namespace_decls (t));
break; break;
......
...@@ -100,6 +100,7 @@ static void remap_block PARAMS ((tree, tree, inline_data *)); ...@@ -100,6 +100,7 @@ static void remap_block PARAMS ((tree, tree, inline_data *));
static void copy_scope_stmt PARAMS ((tree *, int *, inline_data *)); static void copy_scope_stmt PARAMS ((tree *, int *, inline_data *));
static tree calls_setjmp_r PARAMS ((tree *, int *, void *)); static tree calls_setjmp_r PARAMS ((tree *, int *, void *));
static void update_cloned_parm PARAMS ((tree, tree)); static void update_cloned_parm PARAMS ((tree, tree));
static void dump_function PARAMS ((enum tree_dump_index, tree));
/* The approximate number of instructions per statement. This number /* The approximate number of instructions per statement. This number
need not be particularly accurate; it is used only to make need not be particularly accurate; it is used only to make
...@@ -933,12 +934,14 @@ expand_calls_inline (tp, id) ...@@ -933,12 +934,14 @@ expand_calls_inline (tp, id)
walk_tree (tp, expand_call_inline, id, id->tree_pruner); walk_tree (tp, expand_call_inline, id, id->tree_pruner);
} }
/* Optimize the body of FN. */ /* Optimize the body of FN. */
void void
optimize_function (fn) optimize_function (fn)
tree fn; tree fn;
{ {
dump_function (TDI_original, fn);
/* While in this function, we may choose to go off and compile /* While in this function, we may choose to go off and compile
another function. For example, we might instantiate a function another function. For example, we might instantiate a function
in the hopes of inlining it. Normally, that wouldn't trigger any in the hopes of inlining it. Normally, that wouldn't trigger any
...@@ -1010,6 +1013,8 @@ optimize_function (fn) ...@@ -1010,6 +1013,8 @@ optimize_function (fn)
/* Undo the call to ggc_push_context above. */ /* Undo the call to ggc_push_context above. */
--function_depth; --function_depth;
dump_function (TDI_optimized, fn);
} }
/* Called from calls_setjmp_p via walk_tree. */ /* Called from calls_setjmp_p via walk_tree. */
...@@ -1225,3 +1230,26 @@ maybe_clone_body (fn) ...@@ -1225,3 +1230,26 @@ maybe_clone_body (fn)
/* We don't need to process the original function any further. */ /* We don't need to process the original function any further. */
return 1; return 1;
} }
/* Dump FUNCTION_DECL FN as tree dump PHASE. */
static void
dump_function (phase, fn)
enum tree_dump_index phase;
tree fn;
{
FILE *stream;
int flags;
stream = dump_begin (phase, &flags);
if (stream)
{
fprintf (stream, "\n;; Function %s",
decl_as_string (fn, TFF_DECL_SPECIFIERS));
fprintf (stream, " (%s)", decl_as_string (DECL_ASSEMBLER_NAME (fn), 0));
fprintf (stream, "\n\n");
dump_node (fn, TDF_SLIM | flags, stream);
dump_end (phase, stream);
}
}
...@@ -2435,7 +2435,7 @@ expand_body (fn) ...@@ -2435,7 +2435,7 @@ expand_body (fn)
/* If possible, obliterate the body of the function so that it can /* If possible, obliterate the body of the function so that it can
be garbage collected. */ be garbage collected. */
if (flag_dump_translation_unit) if (dump_enabled_p (TDI_all))
/* Keep the body; we're going to dump it. */ /* Keep the body; we're going to dump it. */
; ;
else if (DECL_INLINE (fn) && flag_inline_trees) else if (DECL_INLINE (fn) && flag_inline_trees)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -137,6 +137,7 @@ extern int warningcount; ...@@ -137,6 +137,7 @@ extern int warningcount;
extern int sorrycount; extern int sorrycount;
extern const char *progname; extern const char *progname;
extern const char *dump_base_name;
/* Language-specific hooks. Can be NULL unless otherwise specified. */ /* Language-specific hooks. Can be NULL unless otherwise specified. */
struct lang_hooks struct lang_hooks
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment