This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: tree dumping for gcj
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: 22 Dec 2001 16:06:56 -0700
- Subject: Patch: tree dumping for gcj
- Reply-to: tromey at redhat dot com
This patch adds some support for tree-dumping to gcj.
With this, you can dump a class or a function before optimizations are
done.
Ok?
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* parse.y (dump_java_tree): New function.
(source_end_java_method): Call it.
(end_class_declaration): Likewise.
* lang.c (java_decode_option): Call dump_switch_p.
Index: lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.82
diff -u -r1.82 lang.c
--- lang.c 2001/12/15 08:31:48 1.82
+++ lang.c 2001/12/22 22:56:18
@@ -340,8 +340,10 @@
P's value is the option sans `-f'.
Search for it in the table of options. */
p += 2;
- return process_option_with_no (p, lang_f_options,
- ARRAY_SIZE (lang_f_options));
+ if (process_option_with_no (p, lang_f_options,
+ ARRAY_SIZE (lang_f_options)))
+ return 1;
+ return dump_switch_p (p);
}
if (strcmp (p, "-Wall") == 0)
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.340
diff -u -r1.340 parse.y
--- parse.y 2001/12/21 19:18:52 1.340
+++ parse.y 2001/12/22 22:56:58
@@ -108,6 +108,7 @@
static tree lookup_package_type PARAMS ((const char *, int));
static tree resolve_class PARAMS ((tree, tree, tree, tree));
static void declare_local_variables PARAMS ((int, tree, tree));
+static void dump_java_tree PARAMS ((enum tree_dump_index, tree));
static void source_start_java_method PARAMS ((tree));
static void source_end_java_method PARAMS ((void));
static tree find_name_in_single_imports PARAMS ((tree));
@@ -4060,6 +4061,9 @@
popped by a resume. */
int no_error_occurred = ctxp->next && GET_CPC () != error_mark_node;
+ if (GET_CPC () != error_mark_node)
+ dump_java_tree (TDI_class, GET_CPC ());
+
java_parser_context_pop_initialized_field ();
POP_CPC ();
if (resume && no_error_occurred)
@@ -7391,6 +7395,24 @@
exit_block ();
}
+/* Dump a tree of some kind. This is a convenience wrapper for the
+ dump_* functions in tree-dump.c. */
+static void
+dump_java_tree (phase, fn)
+ enum tree_dump_index phase;
+ tree t;
+{
+ FILE *stream;
+ int flags;
+
+ stream = dump_begin (phase, &flags);
+ if (stream)
+ {
+ dump_node (t, flags, stream);
+ dump_end (phase, stream);
+ }
+}
+
/* Terminate a function and expand its body. */
static void
@@ -7409,6 +7431,10 @@
-Wall flags. */
if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node)
BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE;
+
+ /* We've generated all the trees for this function, and it has been
+ patched. Dump it to a file if the user requested it. */
+ dump_java_tree (TDI_original, fndecl);
/* Generate function's code */
if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))