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]

[tree-ssa] Emit flowgraph in VCG format


The changes are mechanical.  VCG is not as good as GraphViz in laying
out graphs.  In particular, VCG doesn't seem to support multiple graphs
in the same file.  But, oh well.

Tested by building cc1 on x86 and trying out the generated files with
xvcg.


Diego.


	* tree-cfg.c (tree_cfg2vcg): Rename from tree_cfg2dot.  Update all
	users.
	Emit flowgraph using VCG syntax.
	* tree-dump.c (dump_files): Rename -fdump-tree-dot to
	-fdump-tree-vcg.
	* tree.h (enum tree_dump_index): Rename TDI_dot to TDI_vcg.
	* doc/invoke.texi: Update documentation to describe
	-fdump-tree-vcg.

Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.281
diff -d -c -p -r1.1.4.281 tree-cfg.c
*** tree-cfg.c	24 Apr 2004 14:46:28 -0000	1.1.4.281
--- tree-cfg.c	4 May 2004 04:37:30 -0000
*************** static void tree_make_forwarder_block (e
*** 94,100 ****
  static bool thread_jumps (void);
  static bool tree_forwarder_block_p (basic_block);
  static void bsi_commit_edge_inserts_1 (edge e);
! static void tree_cfg2dot (FILE *);
  
  /* Flowgraph optimization and cleanup.  */
  static void tree_merge_blocks (basic_block, basic_block);
--- 94,100 ----
  static bool thread_jumps (void);
  static bool tree_forwarder_block_p (basic_block);
  static void bsi_commit_edge_inserts_1 (edge e);
! static void tree_cfg2vcg (FILE *);
  
  /* Flowgraph optimization and cleanup.  */
  static void tree_merge_blocks (basic_block, basic_block);
*************** build_tree_cfg (tree *tp)
*** 165,178 ****
  
    /* Debugging dumps.  */
  
!   /* Write the flowgraph to a dot file.  */
    {
      int local_dump_flags;
!     FILE *dump_file = dump_begin (TDI_dot, &local_dump_flags);
      if (dump_file)
        {
! 	tree_cfg2dot (dump_file);
! 	dump_end (TDI_dot, dump_file);
        }
    }
  
--- 165,178 ----
  
    /* Debugging dumps.  */
  
!   /* Write the flowgraph to a VCG file.  */
    {
      int local_dump_flags;
!     FILE *dump_file = dump_begin (TDI_vcg, &local_dump_flags);
      if (dump_file)
        {
! 	tree_cfg2vcg (dump_file);
! 	dump_end (TDI_vcg, dump_file);
        }
    }
  
*************** debug_cfg_stats (void)
*** 2229,2238 ****
  }
  
  
! /* Dump the flowgraph to a .dot FILE.  */
  
  static void
! tree_cfg2dot (FILE *file)
  {
    edge e;
    basic_block bb;
--- 2229,2238 ----
  }
  
  
! /* Dump the flowgraph to a .vcg FILE.  */
  
  static void
! tree_cfg2vcg (FILE *file)
  {
    edge e;
    basic_block bb;
*************** tree_cfg2dot (FILE *file)
*** 2240,2256 ****
      = (*lang_hooks.decl_printable_name) (current_function_decl, 2);
  
    /* Write the file header.  */
!   fprintf (file, "digraph %s\n{\n", funcname);
  
    /* Write blocks and edges.  */
    for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
      {
!       fprintf (file, "\tENTRY -> %d", e->dest->index);
  
        if (e->flags & EDGE_FAKE)
! 	fprintf (file, " [weight=0, style=dotted]");
  
!       fprintf (file, ";\n");
      }
    fputc ('\n', file);
  
--- 2240,2261 ----
      = (*lang_hooks.decl_printable_name) (current_function_decl, 2);
  
    /* Write the file header.  */
!   fprintf (file, "graph: { title: \"%s\"\n", funcname);
!   fprintf (file, "node: { title: \"ENTRY\" label: \"ENTRY\" }\n");
!   fprintf (file, "node: { title: \"EXIT\" label: \"EXIT\" }\n");
  
    /* Write blocks and edges.  */
    for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
      {
!       fprintf (file, "edge: { sourcename: \"ENTRY\" targetname: \"%d\"",
! 	       e->dest->index);
  
        if (e->flags & EDGE_FAKE)
! 	fprintf (file, " linestyle: dotted priority: 10");
!       else
! 	fprintf (file, " linestyle: solid priority: 100");
  
!       fprintf (file, " }\n");
      }
    fputc ('\n', file);
  
*************** tree_cfg2dot (FILE *file)
*** 2281,2301 ****
        else
  	end_name = "no-statement";
  
!       fprintf (file, "\t%d [label=\"#%d\\n%s (%d)\\n%s (%d)\"];\n",
  	       bb->index, bb->index, head_name, head_line, end_name,
  	       end_line);
  
        for (e = bb->succ; e; e = e->succ_next)
  	{
  	  if (e->dest == EXIT_BLOCK_PTR)
! 	    fprintf (file, "\t%d -> EXIT", bb->index);
  	  else
! 	    fprintf (file, "\t%d -> %d", bb->index, e->dest->index);
  
  	  if (e->flags & EDGE_FAKE)
! 	    fprintf (file, " [weight=0, style=dotted]");
  
! 	  fprintf (file, ";\n");
  	}
  
        if (bb->next_bb != EXIT_BLOCK_PTR)
--- 2286,2308 ----
        else
  	end_name = "no-statement";
  
!       fprintf (file, "node: { title: \"%d\" label: \"#%d\\n%s (%d)\\n%s (%d)\"}\n",
  	       bb->index, bb->index, head_name, head_line, end_name,
  	       end_line);
  
        for (e = bb->succ; e; e = e->succ_next)
  	{
  	  if (e->dest == EXIT_BLOCK_PTR)
! 	    fprintf (file, "edge: { sourcename: \"%d\" targetname: \"EXIT\"", bb->index);
  	  else
! 	    fprintf (file, "edge: { sourcename: \"%d\" targetname: \"%d\"", bb->index, e->dest->index);
  
  	  if (e->flags & EDGE_FAKE)
! 	    fprintf (file, " priority: 10 linestyle: dotted");
! 	  else
! 	    fprintf (file, " priority: 100 linestyle: solid");
  
! 	  fprintf (file, " }\n");
  	}
  
        if (bb->next_bb != EXIT_BLOCK_PTR)
Index: tree-dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-dump.c,v
retrieving revision 1.6.2.67
diff -d -c -p -r1.6.2.67 tree-dump.c
*** tree-dump.c	13 Apr 2004 22:33:32 -0000	1.6.2.67
--- tree-dump.c	4 May 2004 04:37:30 -0000
*************** static struct dump_file_info dump_files[
*** 652,658 ****
    {".generic", "tree-generic", 0, 0},
    {".nested", "tree-nested", 0, 0},
    {".inlined", "tree-inlined", 0, 0},
!   {".dot", "tree-dot", 0, 0},
    {".xml", "call-graph", 0, 0},
    {NULL, "tree-all", 0, 0},
  };
--- 652,658 ----
    {".generic", "tree-generic", 0, 0},
    {".nested", "tree-nested", 0, 0},
    {".inlined", "tree-inlined", 0, 0},
!   {".vcg", "tree-vcg", 0, 0},
    {".xml", "call-graph", 0, 0},
    {NULL, "tree-all", 0, 0},
  };
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.342.2.186
diff -d -c -p -r1.342.2.186 tree.h
*** tree.h	1 May 2004 21:55:57 -0000	1.342.2.186
--- tree.h	4 May 2004 04:37:31 -0000
*************** enum tree_dump_index
*** 3731,3737 ****
    TDI_nested,			/* dump each function after unnesting it */
    TDI_inlined,			/* dump each function after inlining
  				   within it.  */
!   TDI_dot,			/* create a dot graph file for each 
  				   function's flowgraph.  */
    TDI_xml,                      /* dump function call graph.   */
    TDI_all,			/* enable all the dumps.  */
--- 3731,3737 ----
    TDI_nested,			/* dump each function after unnesting it */
    TDI_inlined,			/* dump each function after inlining
  				   within it.  */
!   TDI_vcg,			/* create a VCG graph file for each 
  				   function's flowgraph.  */
    TDI_xml,                      /* dump function call graph.   */
    TDI_all,			/* enable all the dumps.  */
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.152.2.92
diff -d -c -p -r1.152.2.92 invoke.texi
*** doc/invoke.texi	29 Apr 2004 19:45:39 -0000	1.152.2.92
--- doc/invoke.texi	4 May 2004 04:37:34 -0000
*************** in the following sections.
*** 249,255 ****
  -fdump-tree-original@r{[}-@var{n}@r{]}  @gol
  -fdump-tree-optimized@r{[}-@var{n}@r{]} @gol
  -fdump-tree-inlined@r{[}-@var{n}@r{]} @gol
! -fdump-tree-cfg -fdump-tree-dot -fdump-tree-alias @gol
  -fdump-tree-ch @gol
  -fdump-tree-ssa@r{[}-@var{n}@r{]} -fdump-tree-pre@r{[}-@var{n}@r{]} @gol
  -fdump-tree-ccp@r{[}-@var{n}@r{]} -fdump-tree-dce@r{[}-@var{n}@r{]} @gol
--- 249,255 ----
  -fdump-tree-original@r{[}-@var{n}@r{]}  @gol
  -fdump-tree-optimized@r{[}-@var{n}@r{]} @gol
  -fdump-tree-inlined@r{[}-@var{n}@r{]} @gol
! -fdump-tree-cfg -fdump-tree-vcg -fdump-tree-alias @gol
  -fdump-tree-ch @gol
  -fdump-tree-ssa@r{[}-@var{n}@r{]} -fdump-tree-pre@r{[}-@var{n}@r{]} @gol
  -fdump-tree-ccp@r{[}-@var{n}@r{]} -fdump-tree-dce@r{[}-@var{n}@r{]} @gol
*************** file name is made by appending @file{.gi
*** 3498,3507 ****
  Dump the control flow graph of each function to a file.  The file name is
  made by appending @file{.cfg} to the source file name.
  
! @item dot
! @opindex fdump-tree-dot
! Dump a dot language representation of the control flow graph to a file.  The
! file name is made by appending @file{.dot} to the source file name.
  
  @item ch
  @opindex fdump-tree-ch
--- 3498,3510 ----
  Dump the control flow graph of each function to a file.  The file name is
  made by appending @file{.cfg} to the source file name.
  
! @item vcg
! @opindex fdump-tree-vcg
! Dump the control flow graph of each function to a file in VCG format.  The
! file name is made by appending @file{.vcg} to the source file name.  Note
! that if the file contains more than one function, the generated file cannot
! be used directly by VCG.  You will need to cut and paste each function's
! graph into its own separate file first.
  
  @item ch
  @opindex fdump-tree-ch



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