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]

-dT option to dump trees



I found this patch quite helpful in understanding front-end
operations, especially when used in conjunction with -dy.  It might be
of general utility -- it should certainly be harmless.  Patch is
relative to current gcc_3_0_branch.  Admittedly it is a bit zealous in
it's dumping, but zeal is the defense of freedom is no vice, eh?

cvs -z3 -q diff -u flags.h diagnostic.c function.c stmt.c toplev.c varasm.c
Index: flags.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/flags.h,v
retrieving revision 1.57.4.1
diff -u -r1.57.4.1 flags.h
--- flags.h	2001/03/01 16:55:39	1.57.4.1
+++ flags.h	2001/04/27 06:19:27
@@ -496,6 +496,11 @@
 
 extern int flag_dump_rtl_in_asm;
 
+/* -dT causes debug information describing the AST to be dumped to stderr
+   before conversion to RTL */
+
+extern int flag_dump_trees;
+
 /* -fgnu-linker specifies use of the GNU linker for initializations.
    -fno-gnu-linker says that collect will be used.  */
 extern int flag_gnu_linker;
Index: diagnostic.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/diagnostic.c,v
retrieving revision 1.51.2.2
diff -u -r1.51.2.2 diagnostic.c
--- diagnostic.c	2001/02/23 21:18:14	1.51.2.2
+++ diagnostic.c	2001/04/27 06:19:26
@@ -1250,6 +1250,11 @@
 announce_function (decl)
      tree decl;
 {
+  if (flag_dump_trees) {
+    fprintf(stderr,"announce_function:\n");
+    debug_tree(decl);  
+  }	  
+
   if (! quiet_flag)
     {
       if (rtl_dump_and_exit)
Index: function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.250.2.5
diff -u -r1.250.2.5 function.c
--- function.c	2001/04/15 08:39:14	1.250.2.5
+++ function.c	2001/04/27 06:19:32
@@ -6182,6 +6182,11 @@
      const char *filename;
      int line;
 {
+  if (flag_dump_trees) {
+    fprintf(stderr,"init_function_start: %s:%d\n",filename,line);
+    debug_tree(subr);  
+  }	  
+
   prepare_function_start ();
 
   /* Remember this function for later.  */
@@ -6284,6 +6289,11 @@
   tree tem;
   rtx last_ptr = NULL_RTX;
 
+  if (flag_dump_trees) {
+    fprintf(stderr,"expand_function_start:\n");
+    debug_tree(subr);  
+  }	  
+
   /* Make sure volatile mem refs aren't considered
      valid operands of arithmetic insns.  */
   init_recog_no_volatile ();
@@ -6636,6 +6646,10 @@
 #ifdef TRAMPOLINE_TEMPLATE
   static rtx initial_trampoline;
 #endif
+
+  if (flag_dump_trees) {
+    fprintf(stderr,"expand_function_end: %s:%d\n",filename,line);
+  }	  
 
   finish_expr_for_function ();
 
Index: stmt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stmt.c,v
retrieving revision 1.184.2.2
diff -u -r1.184.2.2 stmt.c
--- stmt.c	2001/03/14 18:26:32	1.184.2.2
+++ stmt.c	2001/04/27 06:19:34
@@ -3281,6 +3281,11 @@
   int exit_flag = ((flags & 1) != 0);
   int block_flag = ((flags & 2) == 0);
 
+  if (flag_dump_trees) {
+    fprintf(stderr,"expand_start_bindings:\n");
+    debug_tree(block);  
+  }	  
+
   /* If a BLOCK is supplied, then the caller should be requesting a
      NOTE_INSN_BLOCK_BEG note.  */
   if (!block_flag && block)
@@ -3656,6 +3661,11 @@
 {
   register struct nesting *thisblock;
 
+  if (flag_dump_trees) {
+    fprintf(stderr,"expand_end_bindings:\n");
+    debug_tree(vars);  
+  }	  
+
   while (block_stack->data.block.exception_region)
     {
       /* Because we don't need or want a new temporary level and
@@ -3971,6 +3981,11 @@
 {
   int was_used = TREE_USED (decl);
 
+  if (flag_dump_trees) {
+    fprintf(stderr,"expand_decl_init:\n");
+    debug_tree(decl);  
+  }	  
+
   /* If this is a CONST_DECL, we don't have to generate any code, but
      if DECL_INITIAL is a constant, call expand_expr to force TREE_CST_RTL
      to be set while in the obstack containing the constant.  If we don't
@@ -4031,6 +4046,14 @@
      tree decl, cleanup;
 {
   struct nesting *thisblock;
+
+  if (flag_dump_trees) {
+    fprintf(stderr,"expand_decl_cleanup:\n");
+    fprintf(stderr,"decl::\n");
+    debug_tree(decl);  
+    fprintf(stderr,"cleanup::\n");
+    debug_tree(cleanup);  
+  }	  
 
   /* Error if we are not in any block.  */
   if (cfun == 0 || block_stack == 0)
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.420.2.12
diff -u -r1.420.2.12 toplev.c
--- toplev.c	2001/04/19 19:51:15	1.420.2.12
+++ toplev.c	2001/04/27 06:19:36
@@ -800,6 +800,10 @@
 
 int flag_dump_rtl_in_asm = 0;
 
+/* -dT causes the front-end to dump trees before conversion to rtl */
+
+int flag_dump_trees = 0;
+
 /* -fgnu-linker specifies use of the GNU linker for initializations.
    (Or, more generally, a linker that handles initializations.)
    -fno-gnu-linker says that collect2 will be used.  */
@@ -2715,6 +2719,11 @@
   int rebuild_label_notes_after_reload;
   int register_life_up_to_date;
 
+  if (flag_dump_trees) {
+    fprintf(stderr,"rest_of_compilation:\n");
+    debug_tree(decl);  
+  }	  
+
   timevar_push (TV_REST_OF_COMPILATION);
 
   /* Now that we're out of the frontend, we shouldn't have any more
@@ -4004,6 +4013,9 @@
         flag_dump_rtl_in_asm = 1;
         flag_print_asm_name = 1;
         break;
+      case 'T':
+	flag_dump_trees = 1;
+	break;
       case 'v':
 	graph_dump_format = vcg;
 	break;
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.161.2.9
diff -u -r1.161.2.9 varasm.c
--- varasm.c	2001/04/11 10:01:12	1.161.2.9
+++ varasm.c	2001/04/27 06:19:38
@@ -579,6 +579,11 @@
   const char *new_name = 0;
   int reg_number;
 
+  if (flag_dump_trees) {
+    fprintf(stderr,"make_decl_rtl: %s\n",asmspec);
+    debug_tree(decl);  
+  }	  
+
   /* Check that we are not being given an automatic variable.  */
   /* A weak alias has TREE_PUBLIC set but not the other bits.  */
   if (TREE_CODE (decl) == PARM_DECL


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