gcc/gcc/graph.c
Rodney Brown 2c3c49dec3 alias.c (mark_constant_function): Use INSN_P.
* alias.c (mark_constant_function): Use INSN_P.
	(init_alias_analysis): Likewise.
	* combine.c (combine_instructions): Use INSN_P.
	(can_combine_p): Likewise.
	(try_combine): Likewise.
	(distribute_notes): Likewise.
	(distribute_links): Likewise.
	* cse.c (cse_around_loop): Use INSN_P.
	(invalidate_skipped_block): Likewise.
	(cse_set_around_loop): Likewise.
	(cse_end_of_basic_block): Likewise.
	(delete_trivially_dead_insns): Likewise.
	* emit-rtl.c (unshare_all_rtl_again): Use INSN_P.
	(unshare_all_rtl_1): Likewise.
	(next_cc0_user): Likewise.
	(try_split make_insn_raw): Likewise.
	(remove_unnecessary_notes): Likewise.
	* final.c (shorten_branches): Use INSN_P.
	(leaf_renumber_regs): Likewise.
	(leaf_renumber_regs_insn): Likewise.
	* flow.c (find_label_refs): Use INSN_P.
	(verify_wide_reg): Likewise.
	(notice_stack_pointer_modification): Likewise.
	(count_or_remove_death_notes): Likewise.
	(verify_flow_info): Likewise.
	(clear_log_links): Likewise.
	* function.c (fixup_var_refs_insns): Use INSN_P.
	(compute_insns_for_mem): Likewise.
	* gcse.c (alloc_gcse_mem): Use INSN_P.
	(compute_sets): Likewise.
	(compute_hash_table): Likewise.
	(classic_gcse): Likewise.
	(cprop): Likewise.
	(insert_insn_end_bb): Likewise.
	(delete_null_pointer_checks_1): Likewise.
	* global.c (expand_preferences): Use INSN_P.
	(build_insn_chain): Likewise.
	* graph.c (node_data): Use INSN_P.
	* haifa-sched.c (priority): Use INSN_P.
	(rm_line_notes): Likewise.
	(rm_other_notes): Likewise.
	(find_insn_reg_weight): Likewise.
	(init_target_units): Likewise.
	(schedule_block): Likewise.
	(compute_block_forward_dependences): Likewise.
	(debug_dependencies): Likewise.
	(set_priorities): Likewise.
	* integrate.c (function_cannot_inline_p): Use INSN_P.
	(save_parm_insns): Likewise.
	(copy_insn_list): Likewise.
	* jump.c (mark_all_labels): Use INSN_P.
	(never_reached_warning): Likewise.
	* lcm.c (optimize_mode_switching): Use INSN_P.
	* local-alloc.c (validate_equiv_mem): Use INSN_P.
	(memref_used_between_p): Likewise.
	(update_equiv_regs): Likewise.
	(block_alloc): Likewise.
	(no_conflict_p): Likewise.
	* loop.c (scan_loop): Use INSN_P.
	(find_and_verify_loops): Likewise.
	(count_loop_regs_set): Likewise.
	(loop_reg_used_before_p): Likewise.
	(strength_reduce): Likewise.
	(recombine_givs): Likewise.
	(check_dbra_loop): Likewise.
	(load_mems): Likewise.
	(try_copy_prop): Likewise.
	* print-rtl.c (print_rtx): Use INSN_P.
	* recog.c (find_single_use): Use INSN_P.
	* reg-stack.c (stack_regs_mentioned): Use INSN_P.
	(next_flags_user): Likewise.
	(swap_rtx_condition): Likewise.
	* regmove.c (mark_flags_life_zones): Use INSN_P.
	(optimize_reg_copy_1): Likewise.
	(optimize_reg_copy_2): Likewise.
	(optimize_reg_copy_3): Likewise.
	(reg_is_remote_constant_p): Likewise.
	(fixup_match_2): Likewise.
	(regmove_optimize): Likewise.
	(fixup_match_1): Likewise.
	* regrename.c (build_def_use): Use INSN_P.
	(replace_reg_in_block): Likewise.
	(consider_use): Likewise.
	* reload.c (find_equiv_reg): Use INSN_P.
	* reload1.c (reload): Use INSN_P.
	(maybe_fix_stack_asms): Likewise.
	(calculate_needs_all_insns): Likewise.
	(reload_as_needed): Likewise.
	(emit_output_reload_insns): Likewise.
	(delete_address_reloads_1): Likewise.
	(reload_cse_regs_1): Likewise.
	(reload_combine): Likewise.
	(reload_cse_move2add): Likewise.
	* reorg.c (redundant_insn): Use INSN_P.
	(dbr_schedule): Likewise.
	* resource.c (find_dead_or_set_registers): Use INSN_P.
	(mark_target_live_regs): Likewise.
	* rtlanal.c (reg_used_between_p): Use INSN_P.
	(reg_referenced_between_p): Likewise.
	(reg_set_between_p): Likewise.
	(reg_set_p): Likewise.
	(single_set): Likewise.
	(multiple_sets): Likewise.
	(find_last_value): Likewise.
	(reg_set_last): Likewise.
	(find_reg_note): Likewise.
	(find_regno_note): Likewise.
	* sibcall.c (sequence_uses_addressof): Use INSN_P.
	* simplify-rtx.c (cselib_process_insn): Use INSN_P.
	* ssa.c (find_evaluations): Use INSN_P.
	(rename_block): Likewise.
	(rename_equivalent_regs): Likewise.
	* unroll.c (loop_find_equiv_value): Use INSN_P.
	(set_dominates_use): Likewise.
	* varasm.c (mark_constant_pool): Use INSN_P.
	(mark_constants): Likewise.
	* config/alpha/alpha.c (alpha_does_function_need_gp): Use INSN_P.
	(alphaev4_next_group): Likewise.
	(alphaev5_next_group): Likewise.
	* config/c4x/c4x.c (c4x_process_after_reload): Use INSN_P.
	(c4x_rptb_rpts_p): Likewise.
	* config/mips/mips.c (mips16_optimize_gp): Use INSN_P.
	* config/rs6000/rs6000.c (uses_TOC): Use INSN_P.
	(rs6000_adjust_priority): Likewise.
	* config/sh/sh.c (sh_loop_align): Use INSN_P.
	(machine_dependent_reorg): Likewise.
	(split_branches): Likewise.
	* config/tahoe/tahoe.c (tahoe_cmp_check): Use INSN_P.

From-SVN: r35494
2000-08-04 14:28:08 -06:00

466 lines
10 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* Output routines for graphical representation.
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
This file is part of GNU CC.
GNU CC 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.
GNU CC 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.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <config.h>
#include "system.h"
#include "rtl.h"
#include "flags.h"
#include "output.h"
#include "function.h"
#include "hard-reg-set.h"
#include "basic-block.h"
#include "toplev.h"
#include "graph.h"
static const char *graph_ext[] =
{
/* no_graph */ "",
/* 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 *));
/* Output text for new basic block. */
static void
start_fct (fp)
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);
break;
case no_graph:
break;
}
}
static void
start_bb (fp, bb)
FILE *fp;
int bb;
{
switch (graph_dump_format)
{
case vcg:
fprintf (fp, "\
graph: {\ntitle: \"%s.BB%d\"\nfolding: 1\ncolor: lightblue\n\
label: \"basic block %d",
current_function_name, bb, bb);
break;
case no_graph:
break;
}
#if 0
/* FIXME Should this be printed? It makes the graph significantly larger. */
/* Print the live-at-start register list. */
fputc ('\n', fp);
EXECUTE_IF_SET_IN_REG_SET (basic_block_live_at_start[bb], 0, i,
{
fprintf (fp, " %d", i);
if (i < FIRST_PSEUDO_REGISTER)
fprintf (fp, " [%s]",
reg_names[i]);
});
#endif
switch (graph_dump_format)
{
case vcg:
fputs ("\"\n\n", fp);
break;
case no_graph:
break;
}
}
static void
node_data (fp, tmp_rtx)
FILE *fp;
rtx tmp_rtx;
{
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",
current_function_name,
current_function_name, XINT (tmp_rtx, 0));
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",
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"
: GET_CODE (tmp_rtx) == CALL_INSN ? "darkgreen"
: GET_CODE (tmp_rtx) == CODE_LABEL ? "\
darkgrey\n shape: ellipse" : "white",
GET_RTX_NAME (GET_CODE (tmp_rtx)), XINT (tmp_rtx, 0));
break;
case no_graph:
break;
}
/* Print the RTL. */
if (GET_CODE (tmp_rtx) == NOTE)
{
const char *name = "";
if (NOTE_LINE_NUMBER (tmp_rtx) < 0)
name = GET_NOTE_INSN_NAME (NOTE_LINE_NUMBER (tmp_rtx));
fprintf (fp, " %s", name);
}
else if (INSN_P (tmp_rtx))
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
draw_edge (fp, from, to, bb_edge, class)
FILE *fp;
int from;
int to;
int bb_edge;
int class;
{
const char * color;
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",
current_function_name, from,
current_function_name, to, color);
if (class)
fprintf (fp, "class: %d ", class);
fputs ("}\n", fp);
break;
case no_graph:
break;
}
}
static void
end_bb (fp)
FILE *fp;
{
switch (graph_dump_format)
{
case vcg:
fputs ("}\n", fp);
break;
case no_graph:
break;
}
}
static void
end_fct (fp)
FILE *fp;
{
switch (graph_dump_format)
{
case vcg:
fprintf (fp, "node: { title: \"%s.999999\" label: \"END\" }\n}\n",
current_function_name);
break;
case no_graph:
break;
}
}
/* 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;
{
register 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);
FILE *fp;
if (basic_block_info == NULL)
return;
memcpy (buf, base, namelen);
memcpy (buf + namelen, suffix, suffixlen);
memcpy (buf + namelen + suffixlen, graph_ext[graph_dump_format], extlen);
fp = fopen (buf, "a");
if (fp == NULL)
return;
if (rtx_first == 0)
fprintf (fp, "(nil)\n");
else
{
int i;
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));
basic_block bb;
for (i = 0; i < max_uid; ++i)
{
start[i] = end[i] = -1;
in_bb_p[i] = NOT_IN_BB;
}
for (i = n_basic_blocks - 1; i >= 0; --i)
{
rtx x;
bb = BASIC_BLOCK (i);
start[INSN_UID (bb->head)] = i;
end[INSN_UID (bb->end)] = i;
for (x = bb->head; 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)
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)
{
if (GET_CODE (tmp_rtx) == BARRIER)
continue;
if (GET_CODE (tmp_rtx) == NOTE
&& (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;
bb = BASIC_BLOCK (i);
/* End of the basic block. */
end_bb (fp);
/* Now specify the edges to all the successors of this
basic block. */
for (e = bb->succ; e ; e = e->succ_next)
{
if (e->dest != EXIT_BLOCK_PTR)
{
rtx block_head = e->dest->head;
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
|| GET_CODE (next_insn) != BARRIER)
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
&& (GET_CODE (next_insn) == NOTE
|| GET_CODE (next_insn) == BARRIER));
draw_edge (fp, XINT (tmp_rtx, 0),
next_insn ? INSN_UID (next_insn) : 999999, 0, 3);
}
}
}
dump_for_graph = 0;
end_fct (fp);
/* Clean up. */
free (start);
free (end);
free (in_bb_p);
}
fclose (fp);
}
/* 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;
{
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);
FILE *fp;
memcpy (buf, base, namelen);
memcpy (buf + namelen, suffix, suffixlen);
memcpy (buf + namelen + suffixlen, graph_ext[graph_dump_format], extlen);
fp = fopen (buf, "w");
if (fp == NULL)
pfatal_with_name (buf);
switch (graph_dump_format)
{
case vcg:
fputs ("graph: {\nport_sharing: no\n", fp);
break;
case no_graph:
abort ();
}
fclose (fp);
}
/* Do final work on the graph output file. */
void
finish_graph_dump_file (base, suffix)
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);
FILE *fp;
memcpy (buf, base, namelen);
memcpy (buf + namelen, suffix, suffixlen);
memcpy (buf + namelen + suffixlen, graph_ext[graph_dump_format], extlen);
fp = fopen (buf, "a");
if (fp != NULL)
{
switch (graph_dump_format)
{
case vcg:
fputs ("}\n", fp);
break;
case no_graph:
abort ();
}
fclose (fp);
}
}