This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Yet another tree dumper : Part 2 (4/4)



On Oct 24, 2003, at 9:51 AM, Mark Mitchell wrote:


On Fri, 2003-10-17 at 12:33, Devang Patel wrote:
4th alternative is to remove old debug_tree().

2003-10-17 Devang Patel <dpatel@apple.com>

         * print-tree.c (debug_tree): Remove
         * dmp-tree.c (debug_tree): New

Additional patch is required to remove dead code.

I know I'm coming to this debate late.


However, this patch is the only one we should even consider.

There is no reason to have two tree dumpers.  If the new one is better,
let's use it.  If it's not better, then Devang should work on it until
it is.  The last thing we need is more superfluous code in GCC.

OK. Here is the complete patch. This patch replaces old tree dumper with new tree dumper.

Now more than one debug_tree functions are available with new
tree dumper.

debug_tree(node) dumps tree internals using new tree dumper.

debug_tree1(node, depth) is same as debug_tree() but second
parameter controls max. tree walk depth.

debug_tree2(node) is same as debug_tree(), but it dumps tree
node every time it is visited during walk.

debug_tree3(...) is available if someone wants to implement
command line option to dump debug_tree output in a file.

One issue came up recently about this tree dumper in internal
discussion. New implementation forces developer to keep
tree dumper up to date with tree nodes (.defs). If a node
is dropped from tree.def then developer needs to remove
corresponding print_SOME_NODE function from *debug-tree.c.
Similarly new nodes requires new function otherwise it will
cause undefined error. Adding new print function for new
tree node is easy (especially for the developer who is adding
new tree node). In the worst case, developer can supply empty
function with appropriate comments so that later I or someone
else can fill in the blanks.

To give an example, following can be used to dump PHI_NODE.

---
static void
print_PHI_NODE (FILE *file,
                const char *annotation ATTRIBUTE_UNUSED,
                tree node,
                int indent)
{
  int i;

  fprintf (file, " num_args=%d", PHI_NUM_ARGS (node));
  fprintf (file, " capacity=%d", PHI_ARG_CAPACITY (node));

  for (i = 0; i < PHI_ARG_CAPACITY (node); i++)
    {
      dump_tree (file, "(arg)", PHI_ARG_DEF (node, i), indent + INDENT);
      /* FIX ME  Print edge */
    }

  if (PHI_RESULT (node))
      dump_tree (file, "(result)", PHI_RESULT (node), indent + INDENT);

}
---

Bootstrapped on powerpc-darwin for all languages (except Ada).
Ok to commit if make check (currently in progress) does not
reveal any new regression ?

Thank you,
--
Devang

2003-11-20 Devang Patel <dpatel@apple.com>

* debug-tree.c: New file.
* debug-tree.h: New file.
* c-debug-tree.c: New file.
* print-tree.c: Remove file.
* gcc/Makefile.in (C_OBJS): Add c-debug-tree.o
(OBJS-common): Remove print-tree.o. Add debug-tree.o
(c-debug-tree.o): New rule.
(debug-tree.o): New rule.
(print-tree.o): Remove rule.
* c-decl.c (c_print_identifier): Remove.
(debug-tree.h): Include.
(c_init_decl_processing): Set dump_tree_p.
* c-lang.c (LANGS_HOOKS_PRINT_IDENTIFIER): Remove.
(LANG_HOOKS_DUMP_DECL): Add.
(LANG_HOOKS_DUMP_TYPE): Add.
(LANG_HOOKS_DUMP_IDENTIFIER): Add.
(LANG_HOOKS_DUMP_BLANK_LINE_P): Add.
(LANG_HOOKS_DUMP_LINENO_P): Add.
* c-tree.h (c_print_identifier): Remove.
(c_dump_identifier): Add.
(c_dump_decl): Add.
(c_dump_type): Add.
(c_dump_lineno_p): Add.
(c_debug_tree3): Add.
* langhooks-def.h (LANG_HOOKS_PRINT_XCODE): Remove.
(LANG_HOOKS_PRINT_DECL): Remove.
(LANG_HOOKS_PRINT_TYPE): Remove.
(LANG_HOOKS_PRINT_IDENTIFIER): Remove.
(LANG_HOOKS_DUMP_DECL): Add.
(LANG_HOOKS_DUMP_TYPE): Add.
(LANG_HOOKS_DUMP_IDENTIFIER): Add.
(LANG_HOOKS_DUMP_BLANK_LINE_P): Add.
(LANG_HOOKS_DUMP_LINENO_P): Add.
(LANG_HOOKS_DEBUG_TREE3): Add.
(LANG_HOOKS_INITIALIZER): Remove LANG_HOOKS_PRINT_XNODE,
LANG_HOOKS_PRINT_DECL, LANG_HOOKS_PRINT_TYPE and
LANG_HOOKS_PRINT_IDENTIFIER. Add LANG_HOOKS_DUMP_DECL,
LANG_HOOKS_DUMP_TYPE, LANG_HOOKS_DUMP_IDENTIFIER,
LANG_HOOKS_DUMP_BLANK_LINE_P, LANG_HOOKS_DUMP_LINENO_P
and LANG_HOOKS_DEBUG_TREE3.
* langhooks.c (lhd_dump_tree_do_nothing): New.
(lhd_dump_tree_blank_line_do_nothing): New.
(lhd_dump_tree_lineno_do_nothing): New.
(lhd_debug_tree3_do_nothing): New.
* langhooks.h (struct lang_hooks): Remove print_xnode, print_decl,
print_type and print_identifier. Add dump_decl, dump_type,
dump_identifier, dump_blank_line_p, dump_lineno_p and debug_tree3.
* print-rtl.c (print_rtx): Use dump_tree() instead of print_node_brief().
* store-layout.c (debug_rli): Use dmp_tree() instead of
print_node_brief().
* tree.h (dump_tree): New.
(print_node): Remove.
(print_node_brief): Remove.
(indent_to): Remove.


        * objc/Make-lang.in (OBJC_OBJS): Add objc-debug-tree.o
        (objc/objc-debug-tree.o): New rule.
        * objc/objc-debug-tree.c: New file.
        * objc-lang.c (LANG_HOOKS_PRINT_IDENTIFIER): Remove.
        (LANG_HOOKS_DUMP_DECL): Add.
        (LANG_HOOKS_DUMP_TYPE): Add.
        (LANG_HOOKS_DUMP_IDENTIFIER): Add.
        (LANG_HOOKS_DUMP_BLANK_LINE_P): Add.
        (LANG_HOOKS_DUMP_LINENO_P): Add.

cp

* cp-debug-tree.c: New file.
* ptree.c: Remove file.
* Make-lang.in (CXX_C_OBJS): Remove ptree.o and add cp-debug-tree.o
(cp/ptree.o): Remove rule.
(cp/cp-debug-tree.o): Add rule.
* cp-lang.c (LANG_HOOKS_PRINT_XNODE): Remove.
(LANG_HOOKS_PRINT_DECL): Remove.
(LANG_HOOKS_PRINT_TYPE): Remove.
(LANG_HOOKS_PRINT_IDENTIFIER): Remove.
(LANG_HOOKS_DUMP_DECL): Add.
(LANG_HOOKS_DUMP_TYPE): Add.
(LANG_HOOKS_DUMP_IDENTIFIER): Add.
(LANG_HOOKS_DUMP_BLANK_LINE_P): Add.
(LANG_HOOKS_DUMP_LINENO_P): Add.
* cp-tree.h (cxx_dump_identifier): Add.
(cxx_dump_decl): Add.
(cxx_dump_type): Add.
(cxx_dump_blank_line_p): Add.
(cxx_dump_lineno_p): Add.
(cxx_debug_tree3): Add.
* name-lookup.c (bt_print_entry): Use dump_tree() instead of
print_node_brief().
* tree.c (init_tree): Set dump_tree_p.
(debug-tree.h): Include.


f

        * com.c (debug-tree.h): Include.
        (ffe_print_identifier): Remove.
        (ffe_dump_identifier): Add.
        (LANG_HOOKS_PRINT_IDENTIFIER): Remove.
        (LANG_HOOKS_DUMP_IDENTIFIER): Add.

Attachment: debug_tree.diff
Description: Binary data



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]