1999-10-16 06:09:09 +00:00
|
|
|
|
/* Output routines for graphical representation.
|
2004-07-28 03:11:36 +00:00
|
|
|
|
Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004
|
|
|
|
|
Free Software Foundation, Inc.
|
1999-10-16 06:09:09 +00:00
|
|
|
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
|
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
This file is part of GCC.
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
GCC is free software; you can redistribute it and/or modify it under
|
|
|
|
|
the terms of the GNU General Public License as published by the Free
|
|
|
|
|
Software Foundation; either version 2, or (at your option) any later
|
|
|
|
|
version.
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
|
for more details.
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with GCC; see the file COPYING. If not, write to the Free
|
2007-05-19 01:19:51 +00:00
|
|
|
|
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
|
02110-1301, USA. */
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#include "system.h"
|
2004-07-28 03:11:36 +00:00
|
|
|
|
#include "coretypes.h"
|
|
|
|
|
#include "tm.h"
|
1999-10-16 06:09:09 +00:00
|
|
|
|
#include "rtl.h"
|
|
|
|
|
#include "flags.h"
|
|
|
|
|
#include "output.h"
|
2002-02-01 18:16:02 +00:00
|
|
|
|
#include "function.h"
|
1999-10-16 06:09:09 +00:00
|
|
|
|
#include "hard-reg-set.h"
|
2007-05-19 01:19:51 +00:00
|
|
|
|
#include "obstack.h"
|
1999-10-16 06:09:09 +00:00
|
|
|
|
#include "basic-block.h"
|
|
|
|
|
#include "toplev.h"
|
2002-02-01 18:16:02 +00:00
|
|
|
|
#include "graph.h"
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2002-02-01 18:16:02 +00:00
|
|
|
|
static const char *const graph_ext[] =
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
|
|
|
|
/* no_graph */ "",
|
|
|
|
|
/* vcg */ ".vcg",
|
|
|
|
|
};
|
|
|
|
|
|
2004-07-28 03:11:36 +00:00
|
|
|
|
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 *);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
1999-10-16 06:09:09 +00:00
|
|
|
|
/* Output text for new basic block. */
|
|
|
|
|
static void
|
2004-07-28 03:11:36 +00:00
|
|
|
|
start_fct (FILE *fp)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
|
|
|
|
switch (graph_dump_format)
|
|
|
|
|
{
|
|
|
|
|
case vcg:
|
|
|
|
|
fprintf (fp, "\
|
|
|
|
|
graph: { title: \"%s\"\nfolding: 1\nhidden: 2\nnode: { title: \"%s.0\" }\n",
|
2004-07-28 03:11:36 +00:00
|
|
|
|
current_function_name (), current_function_name ());
|
1999-10-16 06:09:09 +00:00
|
|
|
|
break;
|
|
|
|
|
case no_graph:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2004-07-28 03:11:36 +00:00
|
|
|
|
start_bb (FILE *fp, int bb)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
#if 0
|
|
|
|
|
reg_set_iterator rsi;
|
|
|
|
|
#endif
|
|
|
|
|
|
1999-10-16 06:09:09 +00:00
|
|
|
|
switch (graph_dump_format)
|
|
|
|
|
{
|
|
|
|
|
case vcg:
|
|
|
|
|
fprintf (fp, "\
|
|
|
|
|
graph: {\ntitle: \"%s.BB%d\"\nfolding: 1\ncolor: lightblue\n\
|
|
|
|
|
label: \"basic block %d",
|
2004-07-28 03:11:36 +00:00
|
|
|
|
current_function_name (), bb, bb);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
break;
|
|
|
|
|
case no_graph:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
2002-02-01 18:16:02 +00:00
|
|
|
|
/* FIXME Should this be printed? It makes the graph significantly larger. */
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
|
|
|
|
/* Print the live-at-start register list. */
|
|
|
|
|
fputc ('\n', fp);
|
2007-05-19 01:19:51 +00:00
|
|
|
|
EXECUTE_IF_SET_IN_REG_SET (basic_block_live_at_start[bb], 0, i, rsi)
|
|
|
|
|
{
|
|
|
|
|
fprintf (fp, " %d", i);
|
|
|
|
|
if (i < FIRST_PSEUDO_REGISTER)
|
|
|
|
|
fprintf (fp, " [%s]", reg_names[i]);
|
|
|
|
|
}
|
1999-10-16 06:09:09 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
switch (graph_dump_format)
|
|
|
|
|
{
|
|
|
|
|
case vcg:
|
|
|
|
|
fputs ("\"\n\n", fp);
|
|
|
|
|
break;
|
|
|
|
|
case no_graph:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2004-07-28 03:11:36 +00:00
|
|
|
|
node_data (FILE *fp, rtx tmp_rtx)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
|
|
|
|
if (PREV_INSN (tmp_rtx) == 0)
|
|
|
|
|
{
|
|
|
|
|
/* This is the first instruction. Add an edge from the starting
|
|
|
|
|
block. */
|
|
|
|
|
switch (graph_dump_format)
|
|
|
|
|
{
|
|
|
|
|
case vcg:
|
|
|
|
|
fprintf (fp, "\
|
|
|
|
|
edge: { sourcename: \"%s.0\" targetname: \"%s.%d\" }\n",
|
2004-07-28 03:11:36 +00:00
|
|
|
|
current_function_name (),
|
|
|
|
|
current_function_name (), XINT (tmp_rtx, 0));
|
1999-10-16 06:09:09 +00:00
|
|
|
|
break;
|
|
|
|
|
case no_graph:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (graph_dump_format)
|
|
|
|
|
{
|
|
|
|
|
case vcg:
|
|
|
|
|
fprintf (fp, "node: {\n title: \"%s.%d\"\n color: %s\n \
|
|
|
|
|
label: \"%s %d\n",
|
2004-07-28 03:11:36 +00:00
|
|
|
|
current_function_name (), XINT (tmp_rtx, 0),
|
2007-05-19 01:19:51 +00:00
|
|
|
|
NOTE_P (tmp_rtx) ? "lightgrey"
|
|
|
|
|
: NONJUMP_INSN_P (tmp_rtx) ? "green"
|
|
|
|
|
: JUMP_P (tmp_rtx) ? "darkgreen"
|
|
|
|
|
: CALL_P (tmp_rtx) ? "darkgreen"
|
|
|
|
|
: LABEL_P (tmp_rtx) ? "\
|
1999-10-16 06:09:09 +00:00
|
|
|
|
darkgrey\n shape: ellipse" : "white",
|
|
|
|
|
GET_RTX_NAME (GET_CODE (tmp_rtx)), XINT (tmp_rtx, 0));
|
|
|
|
|
break;
|
|
|
|
|
case no_graph:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Print the RTL. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
if (NOTE_P (tmp_rtx))
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
const char *name = "";
|
|
|
|
|
if (NOTE_LINE_NUMBER (tmp_rtx) < 0)
|
|
|
|
|
name = GET_NOTE_INSN_NAME (NOTE_LINE_NUMBER (tmp_rtx));
|
|
|
|
|
fprintf (fp, " %s", name);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
}
|
2002-02-01 18:16:02 +00:00
|
|
|
|
else if (INSN_P (tmp_rtx))
|
1999-10-16 06:09:09 +00:00
|
|
|
|
print_rtl_single (fp, PATTERN (tmp_rtx));
|
|
|
|
|
else
|
|
|
|
|
print_rtl_single (fp, tmp_rtx);
|
|
|
|
|
|
|
|
|
|
switch (graph_dump_format)
|
|
|
|
|
{
|
|
|
|
|
case vcg:
|
|
|
|
|
fputs ("\"\n}\n", fp);
|
|
|
|
|
break;
|
|
|
|
|
case no_graph:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2004-07-28 03:11:36 +00:00
|
|
|
|
draw_edge (FILE *fp, int from, int to, int bb_edge, int class)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
const char * color;
|
1999-10-16 06:09:09 +00:00
|
|
|
|
switch (graph_dump_format)
|
|
|
|
|
{
|
|
|
|
|
case vcg:
|
|
|
|
|
color = "";
|
|
|
|
|
if (class == 2)
|
|
|
|
|
color = "color: red ";
|
|
|
|
|
else if (bb_edge)
|
|
|
|
|
color = "color: blue ";
|
|
|
|
|
else if (class == 3)
|
|
|
|
|
color = "color: green ";
|
|
|
|
|
fprintf (fp,
|
|
|
|
|
"edge: { sourcename: \"%s.%d\" targetname: \"%s.%d\" %s",
|
2004-07-28 03:11:36 +00:00
|
|
|
|
current_function_name (), from,
|
|
|
|
|
current_function_name (), to, color);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
if (class)
|
|
|
|
|
fprintf (fp, "class: %d ", class);
|
|
|
|
|
fputs ("}\n", fp);
|
|
|
|
|
break;
|
|
|
|
|
case no_graph:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2004-07-28 03:11:36 +00:00
|
|
|
|
end_bb (FILE *fp)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
|
|
|
|
switch (graph_dump_format)
|
|
|
|
|
{
|
|
|
|
|
case vcg:
|
|
|
|
|
fputs ("}\n", fp);
|
|
|
|
|
break;
|
|
|
|
|
case no_graph:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2004-07-28 03:11:36 +00:00
|
|
|
|
end_fct (FILE *fp)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
|
|
|
|
switch (graph_dump_format)
|
|
|
|
|
{
|
|
|
|
|
case vcg:
|
|
|
|
|
fprintf (fp, "node: { title: \"%s.999999\" label: \"END\" }\n}\n",
|
2004-07-28 03:11:36 +00:00
|
|
|
|
current_function_name ());
|
1999-10-16 06:09:09 +00:00
|
|
|
|
break;
|
|
|
|
|
case no_graph:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Like print_rtl, but also print out live information for the start of each
|
|
|
|
|
basic block. */
|
|
|
|
|
void
|
2007-05-19 01:19:51 +00:00
|
|
|
|
print_rtl_graph_with_bb (const char *base, rtx rtx_first)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
2002-02-01 18:16:02 +00:00
|
|
|
|
rtx tmp_rtx;
|
1999-10-16 06:09:09 +00:00
|
|
|
|
size_t namelen = strlen (base);
|
|
|
|
|
size_t extlen = strlen (graph_ext[graph_dump_format]) + 1;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
char *buf = alloca (namelen + extlen);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
|
|
if (basic_block_info == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
memcpy (buf, base, namelen);
|
2007-05-19 01:19:51 +00:00
|
|
|
|
memcpy (buf + namelen, graph_ext[graph_dump_format], extlen);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
|
|
|
|
fp = fopen (buf, "a");
|
|
|
|
|
if (fp == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (rtx_first == 0)
|
|
|
|
|
fprintf (fp, "(nil)\n");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
enum bb_state { NOT_IN_BB, IN_ONE_BB, IN_MULTIPLE_BB };
|
|
|
|
|
int max_uid = get_max_uid ();
|
2007-05-19 01:19:51 +00:00
|
|
|
|
int *start = XNEWVEC (int, max_uid);
|
|
|
|
|
int *end = XNEWVEC (int, max_uid);
|
|
|
|
|
enum bb_state *in_bb_p = XNEWVEC (enum bb_state, max_uid);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
basic_block bb;
|
2003-07-11 03:40:53 +00:00
|
|
|
|
int i;
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < max_uid; ++i)
|
|
|
|
|
{
|
|
|
|
|
start[i] = end[i] = -1;
|
|
|
|
|
in_bb_p[i] = NOT_IN_BB;
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-11 03:40:53 +00:00
|
|
|
|
FOR_EACH_BB_REVERSE (bb)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
|
|
|
|
rtx x;
|
2004-07-28 03:11:36 +00:00
|
|
|
|
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))
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
|
|
|
|
in_bb_p[INSN_UID (x)]
|
|
|
|
|
= (in_bb_p[INSN_UID (x)] == NOT_IN_BB)
|
|
|
|
|
? IN_ONE_BB : IN_MULTIPLE_BB;
|
2004-07-28 03:11:36 +00:00
|
|
|
|
if (x == BB_END (bb))
|
1999-10-16 06:09:09 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Tell print-rtl that we want graph output. */
|
|
|
|
|
dump_for_graph = 1;
|
|
|
|
|
|
|
|
|
|
/* Start new function. */
|
|
|
|
|
start_fct (fp);
|
|
|
|
|
|
|
|
|
|
for (tmp_rtx = NEXT_INSN (rtx_first); NULL != tmp_rtx;
|
|
|
|
|
tmp_rtx = NEXT_INSN (tmp_rtx))
|
|
|
|
|
{
|
|
|
|
|
int edge_printed = 0;
|
|
|
|
|
rtx next_insn;
|
|
|
|
|
|
|
|
|
|
if (start[INSN_UID (tmp_rtx)] < 0 && end[INSN_UID (tmp_rtx)] < 0)
|
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
if (BARRIER_P (tmp_rtx))
|
1999-10-16 06:09:09 +00:00
|
|
|
|
continue;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
if (NOTE_P (tmp_rtx)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
&& (1 || in_bb_p[INSN_UID (tmp_rtx)] == NOT_IN_BB))
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((i = start[INSN_UID (tmp_rtx)]) >= 0)
|
|
|
|
|
{
|
|
|
|
|
/* We start a subgraph for each basic block. */
|
|
|
|
|
start_bb (fp, i);
|
|
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
|
draw_edge (fp, 0, INSN_UID (tmp_rtx), 1, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Print the data for this node. */
|
|
|
|
|
node_data (fp, tmp_rtx);
|
|
|
|
|
next_insn = next_nonnote_insn (tmp_rtx);
|
|
|
|
|
|
|
|
|
|
if ((i = end[INSN_UID (tmp_rtx)]) >= 0)
|
|
|
|
|
{
|
|
|
|
|
edge e;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
edge_iterator ei;
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
|
|
|
|
bb = BASIC_BLOCK (i);
|
|
|
|
|
|
|
|
|
|
/* End of the basic block. */
|
2002-02-01 18:16:02 +00:00
|
|
|
|
end_bb (fp);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
|
|
|
|
/* Now specify the edges to all the successors of this
|
|
|
|
|
basic block. */
|
2007-05-19 01:19:51 +00:00
|
|
|
|
FOR_EACH_EDGE (e, ei, bb->succs)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
|
|
|
|
if (e->dest != EXIT_BLOCK_PTR)
|
|
|
|
|
{
|
2004-07-28 03:11:36 +00:00
|
|
|
|
rtx block_head = BB_HEAD (e->dest);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
|
|
|
|
draw_edge (fp, INSN_UID (tmp_rtx),
|
|
|
|
|
INSN_UID (block_head),
|
|
|
|
|
next_insn != block_head,
|
|
|
|
|
(e->flags & EDGE_ABNORMAL ? 2 : 0));
|
|
|
|
|
|
|
|
|
|
if (block_head == next_insn)
|
|
|
|
|
edge_printed = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
draw_edge (fp, INSN_UID (tmp_rtx), 999999,
|
|
|
|
|
next_insn != 0,
|
|
|
|
|
(e->flags & EDGE_ABNORMAL ? 2 : 0));
|
|
|
|
|
|
|
|
|
|
if (next_insn == 0)
|
|
|
|
|
edge_printed = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!edge_printed)
|
|
|
|
|
{
|
|
|
|
|
/* Don't print edges to barriers. */
|
|
|
|
|
if (next_insn == 0
|
2007-05-19 01:19:51 +00:00
|
|
|
|
|| !BARRIER_P (next_insn))
|
1999-10-16 06:09:09 +00:00
|
|
|
|
draw_edge (fp, XINT (tmp_rtx, 0),
|
|
|
|
|
next_insn ? INSN_UID (next_insn) : 999999, 0, 0);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* We draw the remaining edges in class 3. We have
|
|
|
|
|
to skip over the barrier since these nodes are
|
|
|
|
|
not printed at all. */
|
|
|
|
|
do
|
|
|
|
|
next_insn = NEXT_INSN (next_insn);
|
|
|
|
|
while (next_insn
|
2007-05-19 01:19:51 +00:00
|
|
|
|
&& (NOTE_P (next_insn)
|
|
|
|
|
|| BARRIER_P (next_insn)));
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
|
|
|
|
draw_edge (fp, XINT (tmp_rtx, 0),
|
|
|
|
|
next_insn ? INSN_UID (next_insn) : 999999, 0, 3);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dump_for_graph = 0;
|
|
|
|
|
|
|
|
|
|
end_fct (fp);
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
|
|
|
|
/* Clean up. */
|
|
|
|
|
free (start);
|
|
|
|
|
free (end);
|
|
|
|
|
free (in_bb_p);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fclose (fp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Similar as clean_dump_file, but this time for graph output files. */
|
2002-02-01 18:16:02 +00:00
|
|
|
|
|
1999-10-16 06:09:09 +00:00
|
|
|
|
void
|
2007-05-19 01:19:51 +00:00
|
|
|
|
clean_graph_dump_file (const char *base)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
|
|
|
|
size_t namelen = strlen (base);
|
|
|
|
|
size_t extlen = strlen (graph_ext[graph_dump_format]) + 1;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
char *buf = alloca (namelen + extlen);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
|
|
memcpy (buf, base, namelen);
|
2007-05-19 01:19:51 +00:00
|
|
|
|
memcpy (buf + namelen, graph_ext[graph_dump_format], extlen);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
|
|
|
|
fp = fopen (buf, "w");
|
|
|
|
|
|
|
|
|
|
if (fp == NULL)
|
2004-07-28 03:11:36 +00:00
|
|
|
|
fatal_error ("can't open %s: %m", buf);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
2007-05-19 01:19:51 +00:00
|
|
|
|
gcc_assert (graph_dump_format == vcg);
|
|
|
|
|
fputs ("graph: {\nport_sharing: no\n", fp);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
|
|
|
|
fclose (fp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Do final work on the graph output file. */
|
|
|
|
|
void
|
2007-05-19 01:19:51 +00:00
|
|
|
|
finish_graph_dump_file (const char *base)
|
1999-10-16 06:09:09 +00:00
|
|
|
|
{
|
|
|
|
|
size_t namelen = strlen (base);
|
|
|
|
|
size_t extlen = strlen (graph_ext[graph_dump_format]) + 1;
|
2007-05-19 01:19:51 +00:00
|
|
|
|
char *buf = alloca (namelen + extlen);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
|
|
memcpy (buf, base, namelen);
|
2007-05-19 01:19:51 +00:00
|
|
|
|
memcpy (buf + namelen, graph_ext[graph_dump_format], extlen);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
|
|
|
|
|
fp = fopen (buf, "a");
|
|
|
|
|
if (fp != NULL)
|
|
|
|
|
{
|
2007-05-19 01:19:51 +00:00
|
|
|
|
gcc_assert (graph_dump_format == vcg);
|
|
|
|
|
fputs ("}\n", fp);
|
1999-10-16 06:09:09 +00:00
|
|
|
|
fclose (fp);
|
|
|
|
|
}
|
|
|
|
|
}
|