aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-pretty-print.c
diff options
context:
space:
mode:
authorSteven Bosscher <steven@gcc.gnu.org>2012-07-17 23:17:20 +0000
committerSteven Bosscher <steven@gcc.gnu.org>2012-07-17 23:17:20 +0000
commit02c9393003330e43fdfaf59bc8cb536f4f9bf2c2 (patch)
tree9d5c1ea84c526379245c9986d831f4ce16757d79 /gcc/gimple-pretty-print.c
parent6773fcd58e983a55e2b5d91ed5d56cc5b9d7ef3e (diff)
* dumpfile.h (TDF_COMMENT): New define.
* basic-block.h (EDGE_FALLTHRU, EDGE_ABNORMAL, EDGE_ABNORMAL_CALL, EDGE_EH, EDGE_FAKE, EDGE_DFS_BACK, EDGE_CAN_FALLTHRU, EDGE_IRREDUCIBLE_LOOP, EDGE_SIBCALL, EDGE_LOOP_EXIT, EDGE_TRUE_VALUE, EDGE_FALSE_VALUE, EDGE_EXECUTABLE, EDGE_CROSSING, EDGE_PRESERVE): Move to new file cfg-flags.h. (enum cfg_edge_flags): New enum, using cfg-flags.h. (EDGE_ALL_FLAGS): Compute value automatically. (BB_NEW, BB_REACHABLE, BB_IRREDUCIBLE_LOOP, BB_SUPERBLOCK, BB_DISABLE_SCHEDULE, BB_HOT_PARTITION, BB_COLD_PARTITION, BB_DUPLICATED, BB_NON_LOCAL_GOTO_TARGET, BB_RTL, BB_FORWARDER_BLOCK, BB_NONTHREADABLE_BLOCK, BB_MODIFIED, BB_VISITED, BB_IN_TRANSACTION): Move to new file cfg-flags.h. (enum bb_flags): Rename to cfg_bb_flags. Use cfg-flags.h. (BB_ALL_FLAGS): New, compute value automatically. (dump_bb_info): Update prototype. (dump_edge_info): Update prototype. * cfg-flags.h: New file. * cfg.c (dump_edge_info): Take flags argument. Be verbose only if TDF_DETAILS and not TDF_SLIM. Include cfg-flags.h for bitnames. Check that the edge flags are within the range of EDGE_ALL_FLAGS. (debug_bb): Update dump_bb call. (dump_cfg_bb_info): Remove. (dump_bb_info): New function. Use cfg-flags.h for bitnames. Adjust verbosity using TDF_* flags. Check that the basic block flags are within the range of BB_ALL_FLAGS. (brief_dump_cfg): Use dump_bb_info instead of dump_cfg_bb_info. * cfghooks.h (struct cfghooks): Update dump_bb hook, take a FILE first for consistency with other dump functions. (dump_bb): Update prototype accordingly. * cfghooks.c: Include dumpfile.h. (verify_flow_info): Update dump_edge_info calls. (dump_bb): Take a flags argument and pass it around. Use dump_bb_info to dump common information about a basic block. (dump_flow_info): Moved here from cfgrtl.c. Make IL agnostic. (debug_flow_info): Moved here from cfgrtl.c. * profile.c (is_edge_inconsistent): Update dump_bb calls. * loop-invariant.c (find_defs): Update print_rtl_with_bb call. * rtl.h (debug_bb_n_slim, debug_bb_slim, print_rtl_slim, print_rtl_slim_with_bb): Remove prototypes. (dump_insn_slim): Adjust prototype to take a const_rtx. (print_rtl_with_bb): Adjust prototype. * sched-rgn.c (debug_region): Use dump_bb instead of debug_bb_n_slim. * sched-vis.c (dump_insn_slim): Take a const_rtx. (debug_insn_slim): Prototype here near DEBUG_FUNCTION marker. (print_rtl_slim_with_bb): Remove. (print_rtl_slim): Rename to debug_rtl_slim. Print only insn info, not basic block info (print_rtl_with_bb with TDF_SLIM should be used for that. Prototype here near DEBUG_FUNCTION marker. (debug_bb_slim): Prototype here near DEBUG_FUNCTION marker. Use dump_bb. (debug_bb_n_slim): Prototype here near DEBUG_FUNCTION marker. * tree-cfg.c (gimple_can_merge_blocks_p): Use EDGE_COMPLEX. (remove_bb): Update dump_bb call. (gimple_debug_bb): Use dump_bb. (dump_function_to_file): Update gimple_dump_bb call. (print_loops_bb): Likewise. * tree-flow.h (gimple_dump_bb): Update prototype. * gimple-pretty-print.c (dump_bb_header): Rename to dump_gimple_bb_header. Write to a stream instead of a pretty printer. Use dump_bb_info to dump basic block info. (dump_bb_end): Rename to dump_gimple_bb_footer. Write to a stream instead of a pretty printer. Use dump_bb_info. (gimple_dump_bb_buff): Do not call dump_bb_header and dump_bb_end. (gimple_dump_bb): Do it here with dump_gimple_bb_header and dump_gimple_bb_footer. * cfgrtl.c (rtl_dump_bb): Update prototype. Only dump DF if the dump flags have TDF_DETAILS. Use dump_insn_slim if TDF_SLIM. (print_rtl_with_bb): Take a flags argument and pass it around. Use dump_insn_slim if TDF_SLIM. (dump_bb_info): Removed and re-incarnated in cfg.c. (dump_flow_info): Moved to cfghooks.c. (debug_flow_info): Moved to cfghooks.c. * passes.c (execute_function_dump): Unconditionally use print_rtl_with_bb for RTL dumps, now that it understands TDF_SLIM. * final.c (dump_basic_block_info): Update dump_edge_info calls. * tree-vrp.c (dump_asserts_for): Likewise. * ifcvt.c (if_convert): Unconditionally use print_rtl_with_bb. * tree-if-conv.c (if_convertible_bb_p): Don't look at EDGE_ABNORMAL_CALL, it has no meaning in the GIMPLE world. * trans-mem.c (make_tm_edge): Don't set EDGE_ABNORMAL_CALL, for the same reason. * config/rl78/rl78.c (rl78_reorg): Update print_rtl_with_bb calls. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@189590 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple-pretty-print.c')
-rw-r--r--gcc/gimple-pretty-print.c100
1 files changed, 25 insertions, 75 deletions
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index fc38f8f1302..febf1d98dbc 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -2059,83 +2059,52 @@ dump_gimple_stmt (pretty_printer *buffer, gimple gs, int spc, int flags)
}
-/* Dumps header of basic block BB to buffer BUFFER indented by INDENT
+/* Dumps header of basic block BB to OUTF indented by INDENT
spaces and details described by flags. */
static void
-dump_bb_header (pretty_printer *buffer, basic_block bb, int indent, int flags)
+dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
{
- edge e;
- gimple stmt;
- edge_iterator ei;
-
if (flags & TDF_BLOCKS)
{
- INDENT (indent);
- pp_string (buffer, "# BLOCK ");
- pp_decimal_int (buffer, bb->index);
- if (bb->frequency)
- {
- pp_string (buffer, " freq:");
- pp_decimal_int (buffer, bb->frequency);
- }
- if (bb->count)
- {
- pp_string (buffer, " count:");
- pp_widest_integer (buffer, bb->count);
- }
+ dump_bb_info (outf, bb, indent, flags, true, false);
if (flags & TDF_LINENO)
{
gimple_stmt_iterator gsi;
+ char *s_indent = (char *) alloca ((size_t) indent + 1);
+ memset (s_indent, ' ', (size_t) indent);
+ s_indent[indent] = '\0';
+
+ if (flags & TDF_COMMENT)
+ fputs (";; ", outf);
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
if (!is_gimple_debug (gsi_stmt (gsi))
&& get_lineno (gsi_stmt (gsi)) != UNKNOWN_LOCATION)
{
- pp_string (buffer, ", starting at line ");
- pp_decimal_int (buffer, get_lineno (gsi_stmt (gsi)));
+ fprintf (outf, "%sstarting at line %d",
+ s_indent, get_lineno (gsi_stmt (gsi)));
break;
}
-
- if (bb->discriminator)
- {
- pp_string (buffer, ", discriminator ");
- pp_decimal_int (buffer, bb->discriminator);
- }
+ if (bb->discriminator)
+ fprintf (outf, ", discriminator %i", bb->discriminator);
+ fputc ('\n', outf);
}
- newline_and_indent (buffer, indent);
-
- pp_string (buffer, "# PRED:");
- pp_write_text_to_stream (buffer);
- FOR_EACH_EDGE (e, ei, bb->preds)
- if (flags & TDF_SLIM)
- {
- pp_character (buffer, ' ');
- if (e->src == ENTRY_BLOCK_PTR)
- pp_string (buffer, "ENTRY");
- else
- pp_decimal_int (buffer, e->src->index);
- }
- else
- dump_edge_info (buffer->buffer->stream, e, 0);
- pp_newline (buffer);
}
else
{
- stmt = first_stmt (bb);
+ gimple stmt = first_stmt (bb);
if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
{
- INDENT (indent - 2);
- pp_string (buffer, "<bb ");
- pp_decimal_int (buffer, bb->index);
- pp_string (buffer, ">:");
- pp_newline (buffer);
+ char *s_indent = (char *) alloca ((size_t) indent - 2 + 1);
+ memset (s_indent, ' ', (size_t) indent);
+ s_indent[indent] = '\0';
+ fprintf (outf, "%s<bb %d>:\n", s_indent, bb->index);
}
}
- pp_write_text_to_stream (buffer);
if (cfun)
- check_bb_profile (bb, buffer->buffer->stream);
+ check_bb_profile (bb, outf);
}
@@ -2143,26 +2112,9 @@ dump_bb_header (pretty_printer *buffer, basic_block bb, int indent, int flags)
spaces. */
static void
-dump_bb_end (pretty_printer *buffer, basic_block bb, int indent, int flags)
+dump_gimple_bb_footer (FILE *outf, basic_block bb, int indent, int flags)
{
- edge e;
- edge_iterator ei;
-
- INDENT (indent);
- pp_string (buffer, "# SUCC:");
- pp_write_text_to_stream (buffer);
- FOR_EACH_EDGE (e, ei, bb->succs)
- if (flags & TDF_SLIM)
- {
- pp_character (buffer, ' ');
- if (e->dest == EXIT_BLOCK_PTR)
- pp_string (buffer, "EXIT");
- else
- pp_decimal_int (buffer, e->dest->index);
- }
- else
- dump_edge_info (buffer->buffer->stream, e, 1);
- pp_newline (buffer);
+ dump_bb_info (outf, bb, indent, flags, false, true);
}
@@ -2292,7 +2244,6 @@ gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
if (label_indent < 0)
label_indent = 0;
- dump_bb_header (buffer, bb, indent, flags);
dump_phi_nodes (buffer, bb, indent, flags);
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
@@ -2310,9 +2261,6 @@ gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
}
dump_implicit_edges (buffer, bb, indent, flags);
-
- if (flags & TDF_BLOCKS)
- dump_bb_end (buffer, bb, indent, flags);
}
@@ -2320,9 +2268,11 @@ gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
indented by INDENT spaces. */
void
-gimple_dump_bb (basic_block bb, FILE *file, int indent, int flags)
+gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
{
+ dump_gimple_bb_header (file, bb, indent, flags);
maybe_init_pretty_print (file);
gimple_dump_bb_buff (&buffer, bb, indent, flags);
pp_flush (&buffer);
+ dump_gimple_bb_footer (file, bb, indent, flags);
}