aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-06-05 08:03:45 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-06-05 08:03:45 +0000
commitb7442fb5553f2ea9d738e5f2a1177c655baa442d (patch)
treeb6681bcaabfa37891f4e13f70111f31f94d5e53e /gcc/cp
parenteb537d4fbb0987ec557b14aa6864b231efdb6e7f (diff)
downloadgcc-b7442fb5553f2ea9d738e5f2a1177c655baa442d.zip
gcc-b7442fb5553f2ea9d738e5f2a1177c655baa442d.tar.gz
gcc-b7442fb5553f2ea9d738e5f2a1177c655baa442d.tar.bz2
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
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog22
-rw-r--r--gcc/cp/class.c226
-rw-r--r--gcc/cp/decl2.c36
-rw-r--r--gcc/cp/dump.c29
-rw-r--r--gcc/cp/optimize.c30
-rw-r--r--gcc/cp/semantics.c2
6 files changed, 264 insertions, 81 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 8f49fc6..8f5ebaa 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,25 @@
+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>
PR g++/2936
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index eca199f..7a7f69b 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -171,8 +171,12 @@ static void layout_vtable_decl PARAMS ((tree, int));
static tree dfs_find_final_overrider PARAMS ((tree, void *));
static tree find_final_overrider PARAMS ((tree, tree, tree));
static int make_new_vtable PARAMS ((tree, tree));
-static void dump_class_hierarchy_r PARAMS ((FILE *, tree, tree, int));
-extern void dump_class_hierarchy PARAMS ((const char *, tree));
+static int maybe_indent_hierarchy PARAMS ((FILE *, int, int));
+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 void initialize_vtable PARAMS ((tree, tree));
static void initialize_array PARAMS ((tree, tree));
@@ -5308,11 +5312,6 @@ finish_struct_1 (t)
layout_class_type (t, &empty, &vfuns,
&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
might need to know it for setting up the offsets in the vtable
(or in thunks) below. */
@@ -5468,6 +5467,8 @@ finish_struct_1 (t)
maybe_suppress_debug_info (t);
+ dump_class_hierarchy (t);
+
/* Finish debugging output for this type. */
rest_of_type_compilation (t, ! LOCAL_CLASS_P (t));
}
@@ -6805,22 +6806,38 @@ get_primary_binfo (binfo)
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
dominated by T) to stderr. INDENT should be zero when called from
the top level; it is incremented recursively. */
static void
-dump_class_hierarchy_r (stream, t, binfo, indent)
+dump_class_hierarchy_r (stream, flags, t, binfo, indent)
FILE *stream;
+ int flags;
tree t;
tree binfo;
int indent;
{
int i;
-
- fprintf (stream, "%*s0x%lx (%s) ", indent, "",
- (unsigned long) binfo,
- type_as_string (binfo, TFF_PLAIN_IDENTIFIER));
+ int indented = 0;
+
+ indented = maybe_indent_hierarchy (stream, indent, 0);
+ fprintf (stream, "%s (0x%lx) ",
+ type_as_string (binfo, TFF_PLAIN_IDENTIFIER),
+ (unsigned long) binfo);
fprintf (stream, HOST_WIDE_INT_PRINT_DEC,
tree_low_cst (BINFO_OFFSET (binfo), 0));
if (is_empty_class (BINFO_TYPE (binfo)))
@@ -6830,51 +6847,174 @@ dump_class_hierarchy_r (stream, t, binfo, indent)
if (TREE_VIA_VIRTUAL (binfo))
{
tree canonical = binfo_for_vbase (BINFO_TYPE (binfo), t);
-
+
+ fprintf (stream, " virtual");
if (canonical == binfo)
- fprintf (stream, " virtual-canonical");
+ fprintf (stream, " canonical");
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");
+ 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)
- 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. */
-void
-dump_class_hierarchy (name, t)
- const char *name;
+static void
+dump_class_hierarchy (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");
- if (!stream)
- error ("could not open dump file `%s'", name);
- return;
+ fprintf (stream, "%s for %s",
+ ctor_vtbl_p ? "Construction vtable" : "Vtable",
+ type_as_string (binfo, TFF_PLAIN_IDENTIFIER));
+ 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,
- tree_low_cst (TYPE_SIZE (t), 0) / BITS_PER_UNIT);
- fprintf (stream, " align=%lu\n",
- (unsigned long)(TYPE_ALIGN (t) / BITS_PER_UNIT));
- dump_class_hierarchy_r (stream, t, TYPE_BINFO (t), 0);
- fprintf (stream, "\n");
- if (name)
- fclose (stream);
+
+ dump_end (TDI_class, stream);
+}
+
+static void
+dump_vtt (t, vtt)
+ tree t;
+ tree vtt;
+{
+ 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. */
@@ -6957,6 +7097,7 @@ initialize_vtable (binfo, inits)
layout_vtable_decl (binfo, list_length (inits));
decl = get_vtbl_decl_for_binfo (binfo);
initialize_array (decl, inits);
+ dump_vtable (BINFO_TYPE (binfo), binfo, decl);
}
/* Initialize DECL (a declaration for a namespace-scope array) with
@@ -7015,6 +7156,8 @@ build_vtt (t)
vtt = build_vtable (t, get_vtt_name (t), type);
pushdecl_top_level (vtt);
initialize_array (vtt, inits);
+
+ dump_vtt (t, vtt);
}
/* 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)
/* Initialize the construction vtable. */
pushdecl_top_level (vtbl);
initialize_array (vtbl, inits);
+ dump_vtable (t, binfo, vtbl);
}
/* Add the vtbl initializers for BINFO (and its bases other than
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 3dac866..c1aa328 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -368,10 +368,6 @@ int flag_operator_names = 1;
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'
initialization variables.
0: Old rules, set by -fno-for-scope.
@@ -590,24 +586,8 @@ cxx_decode_option (argc, argv)
warning ("-fname-mangling-version is no longer supported");
return 1;
}
- else if ((option_value
- = 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 if (dump_switch_p (p))
+ ;
else
{
int found = 0;
@@ -3715,9 +3695,17 @@ finish_file ()
/* The entire file is now complete. If requested, dump everything
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
unit, let it do so now. */
if (back_end_hook)
diff --git a/gcc/cp/dump.c b/gcc/cp/dump.c
index 6706ebf..4826585 100644
--- a/gcc/cp/dump.c
+++ b/gcc/cp/dump.c
@@ -101,19 +101,20 @@ cp_dump_tree (di, t)
}
dump_child ("vfld", TYPE_VFIELD (t));
-
- {
- int 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));
- if (TREE_VIA_VIRTUAL (base_binfo))
- dump_string (di, "virtual");
- dump_access (di, base_binfo);
- }
- }
+
+ if (!dump_flag (di, TDF_SLIM, t))
+ {
+ int 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));
+ if (TREE_VIA_VIRTUAL (base_binfo))
+ dump_string (di, "virtual");
+ dump_access (di, base_binfo);
+ }
+ }
break;
case FIELD_DECL:
@@ -163,7 +164,7 @@ cp_dump_tree (di, t)
break;
if (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));
break;
diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index 8676dd8..aee64f5 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -100,6 +100,7 @@ static void remap_block PARAMS ((tree, tree, inline_data *));
static void copy_scope_stmt PARAMS ((tree *, int *, inline_data *));
static tree calls_setjmp_r PARAMS ((tree *, int *, void *));
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
need not be particularly accurate; it is used only to make
@@ -933,12 +934,14 @@ expand_calls_inline (tp, id)
walk_tree (tp, expand_call_inline, id, id->tree_pruner);
}
-/* Optimize the body of FN. */
+/* Optimize the body of FN. */
void
optimize_function (fn)
tree fn;
{
+ dump_function (TDI_original, fn);
+
/* While in this function, we may choose to go off and compile
another function. For example, we might instantiate a function
in the hopes of inlining it. Normally, that wouldn't trigger any
@@ -1010,6 +1013,8 @@ optimize_function (fn)
/* Undo the call to ggc_push_context above. */
--function_depth;
+
+ dump_function (TDI_optimized, fn);
}
/* Called from calls_setjmp_p via walk_tree. */
@@ -1225,3 +1230,26 @@ maybe_clone_body (fn)
/* We don't need to process the original function any further. */
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);
+ }
+}
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 7425f98..b30c80e 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2435,7 +2435,7 @@ expand_body (fn)
/* If possible, obliterate the body of the function so that it can
be garbage collected. */
- if (flag_dump_translation_unit)
+ if (dump_enabled_p (TDI_all))
/* Keep the body; we're going to dump it. */
;
else if (DECL_INLINE (fn) && flag_inline_trees)