diff options
Diffstat (limited to 'contrib/gcc/graph.c')
-rw-r--r-- | contrib/gcc/graph.c | 97 |
1 files changed, 39 insertions, 58 deletions
diff --git a/contrib/gcc/graph.c b/contrib/gcc/graph.c index 572c6b2..e663f8e 100644 --- a/contrib/gcc/graph.c +++ b/contrib/gcc/graph.c @@ -1,5 +1,6 @@ /* Output routines for graphical representation. - Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004 + Free Software Foundation, Inc. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. This file is part of GCC. @@ -21,6 +22,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include <config.h> #include "system.h" +#include "coretypes.h" +#include "tm.h" #include "rtl.h" #include "flags.h" @@ -37,25 +40,23 @@ static const char *const graph_ext[] = /* vcg */ ".vcg", }; -static void start_fct PARAMS ((FILE *)); -static void start_bb PARAMS ((FILE *, int)); -static void node_data PARAMS ((FILE *, rtx)); -static void draw_edge PARAMS ((FILE *, int, int, int, int)); -static void end_fct PARAMS ((FILE *)); -static void end_bb PARAMS ((FILE *)); +static void start_fct (FILE *); +static void start_bb (FILE *, int); +static void node_data (FILE *, rtx); +static void draw_edge (FILE *, int, int, int, int); +static void end_fct (FILE *); +static void end_bb (FILE *); /* Output text for new basic block. */ static void -start_fct (fp) - FILE *fp; +start_fct (FILE *fp) { - switch (graph_dump_format) { case vcg: fprintf (fp, "\ graph: { title: \"%s\"\nfolding: 1\nhidden: 2\nnode: { title: \"%s.0\" }\n", - current_function_name, current_function_name); + current_function_name (), current_function_name ()); break; case no_graph: break; @@ -63,9 +64,7 @@ graph: { title: \"%s\"\nfolding: 1\nhidden: 2\nnode: { title: \"%s.0\" }\n", } static void -start_bb (fp, bb) - FILE *fp; - int bb; +start_bb (FILE *fp, int bb) { switch (graph_dump_format) { @@ -73,7 +72,7 @@ start_bb (fp, bb) fprintf (fp, "\ graph: {\ntitle: \"%s.BB%d\"\nfolding: 1\ncolor: lightblue\n\ label: \"basic block %d", - current_function_name, bb, bb); + current_function_name (), bb, bb); break; case no_graph: break; @@ -104,11 +103,8 @@ label: \"basic block %d", } static void -node_data (fp, tmp_rtx) - FILE *fp; - rtx tmp_rtx; +node_data (FILE *fp, rtx tmp_rtx) { - if (PREV_INSN (tmp_rtx) == 0) { /* This is the first instruction. Add an edge from the starting @@ -118,8 +114,8 @@ node_data (fp, tmp_rtx) case vcg: fprintf (fp, "\ edge: { sourcename: \"%s.0\" targetname: \"%s.%d\" }\n", - current_function_name, - current_function_name, XINT (tmp_rtx, 0)); + current_function_name (), + current_function_name (), XINT (tmp_rtx, 0)); break; case no_graph: break; @@ -131,7 +127,7 @@ edge: { sourcename: \"%s.0\" targetname: \"%s.%d\" }\n", case vcg: fprintf (fp, "node: {\n title: \"%s.%d\"\n color: %s\n \ label: \"%s %d\n", - current_function_name, XINT (tmp_rtx, 0), + current_function_name (), XINT (tmp_rtx, 0), GET_CODE (tmp_rtx) == NOTE ? "lightgrey" : GET_CODE (tmp_rtx) == INSN ? "green" : GET_CODE (tmp_rtx) == JUMP_INSN ? "darkgreen" @@ -168,12 +164,7 @@ darkgrey\n shape: ellipse" : "white", } static void -draw_edge (fp, from, to, bb_edge, class) - FILE *fp; - int from; - int to; - int bb_edge; - int class; +draw_edge (FILE *fp, int from, int to, int bb_edge, int class) { const char * color; switch (graph_dump_format) @@ -188,8 +179,8 @@ draw_edge (fp, from, to, bb_edge, class) color = "color: green "; fprintf (fp, "edge: { sourcename: \"%s.%d\" targetname: \"%s.%d\" %s", - current_function_name, from, - current_function_name, to, color); + current_function_name (), from, + current_function_name (), to, color); if (class) fprintf (fp, "class: %d ", class); fputs ("}\n", fp); @@ -200,8 +191,7 @@ draw_edge (fp, from, to, bb_edge, class) } static void -end_bb (fp) - FILE *fp; +end_bb (FILE *fp) { switch (graph_dump_format) { @@ -214,14 +204,13 @@ end_bb (fp) } static void -end_fct (fp) - FILE *fp; +end_fct (FILE *fp) { switch (graph_dump_format) { case vcg: fprintf (fp, "node: { title: \"%s.999999\" label: \"END\" }\n}\n", - current_function_name); + current_function_name ()); break; case no_graph: break; @@ -231,16 +220,13 @@ end_fct (fp) /* Like print_rtl, but also print out live information for the start of each basic block. */ void -print_rtl_graph_with_bb (base, suffix, rtx_first) - const char *base; - const char *suffix; - rtx rtx_first; +print_rtl_graph_with_bb (const char *base, const char *suffix, rtx rtx_first) { rtx tmp_rtx; size_t namelen = strlen (base); size_t suffixlen = strlen (suffix); size_t extlen = strlen (graph_ext[graph_dump_format]) + 1; - char *buf = (char *) alloca (namelen + suffixlen + extlen); + char *buf = alloca (namelen + suffixlen + extlen); FILE *fp; if (basic_block_info == NULL) @@ -260,10 +246,9 @@ print_rtl_graph_with_bb (base, suffix, rtx_first) { enum bb_state { NOT_IN_BB, IN_ONE_BB, IN_MULTIPLE_BB }; int max_uid = get_max_uid (); - int *start = (int *) xmalloc (max_uid * sizeof (int)); - int *end = (int *) xmalloc (max_uid * sizeof (int)); - enum bb_state *in_bb_p = (enum bb_state *) - xmalloc (max_uid * sizeof (enum bb_state)); + int *start = xmalloc (max_uid * sizeof (int)); + int *end = xmalloc (max_uid * sizeof (int)); + enum bb_state *in_bb_p = xmalloc (max_uid * sizeof (enum bb_state)); basic_block bb; int i; @@ -276,14 +261,14 @@ print_rtl_graph_with_bb (base, suffix, rtx_first) FOR_EACH_BB_REVERSE (bb) { rtx x; - start[INSN_UID (bb->head)] = bb->index; - end[INSN_UID (bb->end)] = bb->index; - for (x = bb->head; x != NULL_RTX; x = NEXT_INSN (x)) + start[INSN_UID (BB_HEAD (bb))] = bb->index; + end[INSN_UID (BB_END (bb))] = bb->index; + for (x = BB_HEAD (bb); x != NULL_RTX; x = NEXT_INSN (x)) { in_bb_p[INSN_UID (x)] = (in_bb_p[INSN_UID (x)] == NOT_IN_BB) ? IN_ONE_BB : IN_MULTIPLE_BB; - if (x == bb->end) + if (x == BB_END (bb)) break; } } @@ -337,7 +322,7 @@ print_rtl_graph_with_bb (base, suffix, rtx_first) { if (e->dest != EXIT_BLOCK_PTR) { - rtx block_head = e->dest->head; + rtx block_head = BB_HEAD (e->dest); draw_edge (fp, INSN_UID (tmp_rtx), INSN_UID (block_head), @@ -400,14 +385,12 @@ print_rtl_graph_with_bb (base, suffix, rtx_first) /* Similar as clean_dump_file, but this time for graph output files. */ void -clean_graph_dump_file (base, suffix) - const char *base; - const char *suffix; +clean_graph_dump_file (const char *base, const char *suffix) { size_t namelen = strlen (base); size_t suffixlen = strlen (suffix); size_t extlen = strlen (graph_ext[graph_dump_format]) + 1; - char *buf = (char *) alloca (namelen + extlen + suffixlen); + char *buf = alloca (namelen + extlen + suffixlen); FILE *fp; memcpy (buf, base, namelen); @@ -417,7 +400,7 @@ clean_graph_dump_file (base, suffix) fp = fopen (buf, "w"); if (fp == NULL) - fatal_io_error ("can't open %s", buf); + fatal_error ("can't open %s: %m", buf); switch (graph_dump_format) { @@ -434,14 +417,12 @@ clean_graph_dump_file (base, suffix) /* Do final work on the graph output file. */ void -finish_graph_dump_file (base, suffix) - const char *base; - const char *suffix; +finish_graph_dump_file (const char *base, const char *suffix) { size_t namelen = strlen (base); size_t suffixlen = strlen (suffix); size_t extlen = strlen (graph_ext[graph_dump_format]) + 1; - char *buf = (char *) alloca (namelen + suffixlen + extlen); + char *buf = alloca (namelen + suffixlen + extlen); FILE *fp; memcpy (buf, base, namelen); |