This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] show block boundaries in pretty printer [patch]
- From: Diego Novillo <dnovillo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 26 Oct 2002 16:45:54 -0400
- Subject: [tree-ssa] show block boundaries in pretty printer [patch]
- Organization: Red Hat Canada
- Adds a new flags argument to the pretty printer to affect how
it renders the code.
- Adds a PPF_BLOCK flag to show basic block boundaries when
unparsing the function.
- Fixes a bug in the flowgraph. We were not terminating basic
blocks at return, gotos and calls to non-returning functions.
- Fixes handling of BIND_EXPR nodes in the flow graph. We now
create an entry block for the BIND_EXPR to prevent its body
from being disconnected from the rest of the graph.
- Introduces rli_delete() to remove a reference from a ref_list
while iterating.
Bootstrapped and tested x86.
Diego.
* Makefile.in (tree-pretty-print.o): Depend on $(TREE_FLOW_H)
* basic-block.h (BB_COMPOUND_ENTRY): Rename from BB_CONTROL_ENTRY.
* diagnostic.h (dump_generic_tree): Remove extern declaration.
(print_generic_node_brief): Remove. Update all users.
(PPF_BRIEF): Declare.
(PPF_BLOCK): Declare.
(PPF_LINENO): Declare.
(PPF_IS_STMT): Declare.
* tree-pretty-print.c (PPF_BRIEF): New constant.
(PPF_BLOCK): New constant.
(PPF_LINENO): New constant.
(PPF_IS_STMT): New constant.
(dump_block_info): New local function.
(last_bb): New local variable.
(dump_generic_tree): Remove unused function.
(print_generic_tree): Add third argument 'flags'. Update all
users.
(print_generic_node_brief): Remove. Update all users.
(print_generic_node): Add third argument 'flags'. Update all
users.
(dump_generic_node): Add third argument 'flags'. Update all users.
If PPF_BLOCK is set, display basic block information at basic block
boundaries.
If PPF_IS_STMT is set, change the way COMPOUND_EXPR nodes are
rendered.
If PPF_BRIEF is set, don't show the bodies of control statements.
(print_declaration):
* toplev.c (process_options): Update comment for -fdisable-simple.
* tree-cfg.c (remove_tree_bb): Rename from tree_delete_bb.
(latch_block): Move declaration to tree-flow.h. Declare extern.
(make_blocks): Start a new block after finding a control flow
altering statement.
(make_loop_expr_blocks): Set the loop entry block to be the parent
block for the loop latch block.
(cleanup_tree_cfg): Rename from tree_cleanup_cfg.
Call compact_blocks.
(remove_tree_bb): Rename from tree_delete_bb. Update all users.
(dump_tree_bb): Rename from dump_tree_bb. Update all users.
Dump information about loop latch blocks.
(debug_tree_bb): Rename from tree_debug_bb. Update all users.
(debug_tree_cfg): Rename from tree_debug_cfg. Update all users.
(dump_tree_cfg): Rename from tree_dump_cfg. Update all users.
By default, dump the function with markers for basic block
boundaries.
(successor_block): If we can't find a successor following the
parent chain, return the next block in the linked list of blocks.
Update documentation comments.
(stmt_starts_bb_p): Don't let RETURN_EXPR start a new block.
(is_latch_block): New function.
(first_exec_stmt): Don't treat BIND_EXPR nodes as a special case.
(first_stmt): Return NULL_TREE if the block does not exist.
(last_stmt): Likewise.
* tree-dfa.c (find_tree_refs): Rename from tree_find_refs. Update
all users.
(find_refs_in_stmt): Handle BIND_EXPR nodes.
(rli_start): Move from tree-flow-inline.h
(rli_start_last): Likewise.
(rli_start_at): Likewise.
(rli_delete): Likewise.
* tree-flow-inline.h (gsi_start_bb): Handle NULL blocks.
(ref_list_is_empty): New function.
* tree-flow.h (rli_start): Change declaration to extern.
(rli_start_last): Likewise.
(rli_start_at): Likewise.
(rli_delete): Declare.
(latch_block): Declare.
(is_latch_block): Declare.
(get_last_ref): Change to inline declaration.
(get_first_ref): Likewise.
(ref_list_empty): Declare.
* tree-optimize.c (delete_tree_ssa): Remove declaration.
* tree-ssa-dce.c (mark_control_parent_necessary): Call gsi_step_bb
instead of gsi_step.
(tree_ssa_eliminate_dead_code): Likewise.
* tree-ssa.c (compute_tree_rdefs): Rename from compute_tree_rdefs.
Update all users.
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.903.2.44
diff -d -u -p -r1.903.2.44 Makefile.in
--- Makefile.in 22 Oct 2002 18:28:03 -0000 1.903.2.44
+++ Makefile.in 26 Oct 2002 18:06:18 -0000
@@ -1428,7 +1428,7 @@ tree-nomudflap.o : $(CONFIG_H) errors.h
$(C_TREE_H) $(C_COMMON_H) tree-simple.h diagnostic.h $(HASHTAB_H) \
output.h varray.h langhooks.h tree-mudflap.h
tree-pretty-print.o : tree-pretty-print.c $(CONFIG_H) $(SYSTEM_H) \
- errors.h $(TREE_H) diagnostic.h real.h $(HASHTAB_H)
+ errors.h $(TREE_H) diagnostic.h real.h $(HASHTAB_H) $(TREE_FLOW_H)
c-pretty-print.o : c-pretty-print.c $(CONFIG_H) $(SYSTEM_H) $(HASHTAB_H) \
$(RTL_H) $(TREE_H) $(EXPR_H) $(C_COMMON_H) errors.h diagnostic.h
stor-layout.o : stor-layout.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) flags.h \
Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/basic-block.h,v
retrieving revision 1.153.2.14
diff -d -u -p -r1.153.2.14 basic-block.h
--- basic-block.h 14 Oct 2002 17:01:52 -0000 1.153.2.14
+++ basic-block.h 26 Oct 2002 18:06:18 -0000
@@ -252,8 +252,9 @@ typedef struct basic_block_def {
/* Block contains a control flow expression for a loop. */
#define BB_LOOP_CONTROL_EXPR 32
-/* Block is the entry block to a control statement but contains no code. */
-#define BB_CONTROL_ENTRY 64
+/* Block is the entry block to a compound statement (BIND_EXPR, LOOP_EXPR,
+ COND_EXPR, SWITCH_EXPR). */
+#define BB_COMPOUND_ENTRY 64
/* Number of basic blocks in the current function. */
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.334.2.20
diff -d -u -p -r1.334.2.20 c-decl.c
--- c-decl.c 22 Oct 2002 18:28:05 -0000 1.334.2.20
+++ c-decl.c 26 Oct 2002 18:06:19 -0000
@@ -6531,7 +6531,7 @@ c_expand_body (fndecl, nested_p, can_def
dump_node (DECL_SAVED_TREE (fndecl), TDF_SLIM | dump_flags,
dump_file);
else
- print_generic_tree (dump_file, DECL_SAVED_TREE (fndecl));
+ print_generic_tree (dump_file, DECL_SAVED_TREE (fndecl), 0);
fprintf (dump_file, "\n");
dump_end (TDI_simple, dump_file);
Index: diagnostic.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/diagnostic.h,v
retrieving revision 1.44.2.11
diff -d -u -p -r1.44.2.11 diagnostic.h
--- diagnostic.h 18 Oct 2002 03:36:38 -0000 1.44.2.11
+++ diagnostic.h 26 Oct 2002 18:06:19 -0000
@@ -331,11 +331,15 @@ extern void inform
extern void debug_output_buffer PARAMS ((output_buffer *));
/* In tree-pretty-print.c */
-extern void dump_generic_tree PARAMS ((output_buffer *, tree, int));
extern int dump_generic_node PARAMS ((output_buffer *, tree, int,
int));
-extern void print_generic_tree PARAMS ((FILE*, tree));
-extern void print_generic_node PARAMS ((FILE*, tree));
-extern void print_generic_node_brief PARAMS ((FILE*, tree));
+extern void print_generic_tree PARAMS ((FILE*, tree, int));
+extern void print_generic_node PARAMS ((FILE*, tree, int));
+
+/* Modifier flags for print_generic_* functions. */
+extern const int PPF_BRIEF; /* Don't print control stmt bodies. */
+extern const int PPF_BLOCK; /* Show basic block delimiters. */
+extern const int PPF_LINENO; /* Show line number information. */
+extern const int PPF_IS_STMT; /* The tree is a statement. */
#endif /* ! GCC_DIAGNOSTIC_H */
Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gimplify.c,v
retrieving revision 1.1.2.4
diff -d -u -p -r1.1.2.4 gimplify.c
--- gimplify.c 20 Oct 2002 19:24:00 -0000 1.1.2.4
+++ gimplify.c 26 Oct 2002 18:06:19 -0000
@@ -502,7 +502,7 @@ simplify_expr (expr_p, pre_p, post_p, si
else
{
fprintf (stderr, "simplification failed:\n");
- print_generic_tree (stderr, *expr_p);
+ print_generic_tree (stderr, *expr_p, PPF_BRIEF);
debug_tree (*expr_p);
abort ();
}
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.654.2.26
diff -d -u -p -r1.654.2.26 toplev.c
--- toplev.c 22 Oct 2002 18:28:17 -0000 1.654.2.26
+++ toplev.c 26 Oct 2002 18:06:20 -0000
@@ -5174,8 +5174,7 @@ process_options ()
if (flag_signaling_nans)
flag_trapping_math = 1;
- /* -ftree-ssa and -fdisable-simple cannot be used together because the
- tree SSA code can only use SIMPLE trees. */
+ /* -fdisable-simple also disables the tree optimizers. */
if (optimize >= 1 && flag_disable_simple)
warning ("-fdisable-simple also disables optimizations on trees");
Index: tree-alias-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-alias-common.c,v
retrieving revision 1.1.2.7
diff -d -u -p -r1.1.2.7 tree-alias-common.c
--- tree-alias-common.c 18 Oct 2002 03:36:39 -0000 1.1.2.7
+++ tree-alias-common.c 26 Oct 2002 18:06:20 -0000
@@ -650,12 +650,12 @@ display_points_to_set_helper (tvar)
tmp = alias_tvar_pointsto (tvar);
if (VARRAY_ACTIVE_SIZE (tmp) <= 0)
return;
- print_generic_node (stderr, ALIAS_TVAR_DECL (tvar));
+ print_generic_node (stderr, ALIAS_TVAR_DECL (tvar), 0);
fprintf (stderr, " => { ");
for (i = 0; i < VARRAY_ACTIVE_SIZE (tmp); i++)
{
alias_typevar tmpatv = (alias_typevar) VARRAY_GENERIC_PTR (tmp, i);
- print_generic_node (stderr, ALIAS_TVAR_DECL (tmpatv));
+ print_generic_node (stderr, ALIAS_TVAR_DECL (tmpatv), 0);
fprintf (stderr, ", ");
}
fprintf (stderr, " }\n");
Index: tree-alias-steen.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-alias-steen.c,v
retrieving revision 1.1.2.11
diff -d -u -p -r1.1.2.11 tree-alias-steen.c
--- tree-alias-steen.c 18 Oct 2002 03:36:39 -0000 1.1.2.11
+++ tree-alias-steen.c 26 Oct 2002 18:06:20 -0000
@@ -149,7 +149,7 @@ steen_add_var (ops, decl)
{
#if STEEN_DEBUG
fprintf (stderr, "Steen: Adding variable " );
- print_generic_node (stderr, decl);
+ print_generic_node (stderr, decl, 0);
fprintf (stderr, "\n");
#endif
return alias_tvar_new (decl);
@@ -167,9 +167,9 @@ steen_add_var_same (ops, decl, tv)
{
#if STEEN_DEBUG
fprintf (stderr, "Steen: Adding variable " );
- print_generic_node (stderr, decl);
+ print_generic_node (stderr, decl, 0);
fprintf (stderr, " same as ");
- print_generic_node (stderr, ALIAS_TVAR_DECL (tv));
+ print_generic_node (stderr, ALIAS_TVAR_DECL (tv), 0);
fprintf (stderr, "\n");
#endif
return alias_tvar_new_equiv_to (decl, tv);
@@ -187,9 +187,9 @@ steen_simple_assign (ops, lhs, rhs)
#if STEEN_DEBUG
fprintf (stderr, "Steen: simple assignment ");
- print_generic_node (stderr, ALIAS_TVAR_DECL (lhs));
+ print_generic_node (stderr, ALIAS_TVAR_DECL (lhs), 0);
fprintf (stderr, " = ");
- print_generic_node (stderr, ALIAS_TVAR_DECL (rhs));
+ print_generic_node (stderr, ALIAS_TVAR_DECL (rhs), 0);
fprintf (stderr, "\n");
#endif
@@ -226,9 +226,9 @@ steen_addr_assign (ops, lhs, addr)
#if STEEN_DEBUG
fprintf (stderr, "Steen: address assignment ");
- print_generic_node (stderr, ALIAS_TVAR_DECL (lhs));
+ print_generic_node (stderr, ALIAS_TVAR_DECL (lhs), 0);
fprintf (stderr, " = &");
- print_generic_node (stderr, ALIAS_TVAR_DECL (addr));
+ print_generic_node (stderr, ALIAS_TVAR_DECL (addr), 0);
fprintf (stderr, "\n");
#endif
@@ -259,9 +259,9 @@ steen_ptr_assign (ops, lhs, ptr)
return;
#if STEEN_DEBUG
fprintf (stderr, "Steen: pointer assignment ");
- print_generic_node (stderr, ALIAS_TVAR_DECL (lhs));
+ print_generic_node (stderr, ALIAS_TVAR_DECL (lhs), 0);
fprintf (stderr, " = *");
- print_generic_node (stderr, ALIAS_TVAR_DECL (ptr));
+ print_generic_node (stderr, ALIAS_TVAR_DECL (ptr), 0);
fprintf (stderr, "\n");
#endif
@@ -316,7 +316,7 @@ steen_op_assign (ops, lhs, operands)
#if STEEN_DEBUG
fprintf (stderr, "Steen: op assignment ");
- print_generic_node (stderr, ALIAS_TVAR_DECL (lhs));
+ print_generic_node (stderr, ALIAS_TVAR_DECL (lhs), 0);
fprintf (stderr, " = op(...)");
fprintf (stderr, "\n");
#endif
@@ -378,9 +378,9 @@ steen_assign_ptr (ops, ptr, rhs)
#if STEEN_DEBUG
fprintf (stderr, "Steen: assignment to pointer *");
- print_generic_node (stderr, ALIAS_TVAR_DECL (ptr));
+ print_generic_node (stderr, ALIAS_TVAR_DECL (ptr), 0);
fprintf (stderr, " = ");
- print_generic_node (stderr, ALIAS_TVAR_DECL (rhs));
+ print_generic_node (stderr, ALIAS_TVAR_DECL (rhs), 0);
fprintf (stderr, "\n");
#endif
type1 = ECR_get_type (alias_tvar_get_ECR (ptr));
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.20
diff -d -u -p -r1.1.4.20 tree-cfg.c
--- tree-cfg.c 21 Oct 2002 18:35:03 -0000 1.1.4.20
+++ tree-cfg.c 26 Oct 2002 18:06:20 -0000
@@ -52,7 +52,6 @@ static void make_switch_expr_blocks PARA
static basic_block create_bb PARAMS ((tree *, basic_block));
static void set_bb_for_stmt PARAMS ((tree, basic_block));
static void remove_unreachable_blocks PARAMS ((void));
-static void tree_delete_bb PARAMS ((basic_block));
/* Edges. */
static void make_edges PARAMS ((void));
@@ -65,11 +64,11 @@ static void make_case_label_edges PARAMS
/* Various helpers. */
static basic_block successor_block PARAMS ((basic_block));
-static basic_block latch_block PARAMS ((basic_block));
static basic_block first_exec_block PARAMS ((tree *));
static tree *first_exec_stmt PARAMS ((tree *));
static bool block_invalidates_loop PARAMS ((basic_block, struct loop *));
static basic_block switch_parent PARAMS ((basic_block));
+static void remove_tree_bb PARAMS ((basic_block));
/* Remove any COMPOUND_EXPR and WFL container from NODE. */
#define STRIP_CONTAINERS(NODE) \
@@ -141,7 +140,7 @@ build_tree_cfg (fnbody)
dump_file = dump_begin (TDI_cfg, &dump_flags);
if (dump_file)
{
- tree_dump_cfg (dump_file);
+ dump_tree_cfg (dump_file, dump_flags & TDF_DETAILS);
dump_end (TDI_cfg, dump_file);
}
}
@@ -221,6 +220,11 @@ make_blocks (first_p, parent_block)
set_bb_for_stmt (*container, bb);
bb->end_tree_p = container;
}
+
+ /* If STMT alters the flow of control, we need to start a new
+ block on the next iteration. */
+ if (is_ctrl_altering_stmt (stmt))
+ start_new_block = true;
}
}
}
@@ -238,7 +242,7 @@ make_bind_expr_blocks (bind_p, parent_bl
tree bind = *bind_p;
entry = create_bb (bind_p, parent_block);
- entry->flags |= BB_CONTROL_ENTRY;
+ entry->flags |= BB_COMPOUND_ENTRY;
STRIP_CONTAINERS (bind);
make_blocks (&BIND_EXPR_BODY (bind), entry);
@@ -257,7 +261,7 @@ make_loop_expr_blocks (loop_p, parent_bl
tree loop = *loop_p;
entry = create_bb (loop_p, parent_block);
- entry->flags |= BB_CONTROL_ENTRY | BB_CONTROL_EXPR | BB_LOOP_CONTROL_EXPR;
+ entry->flags |= BB_COMPOUND_ENTRY | BB_CONTROL_EXPR | BB_LOOP_CONTROL_EXPR;
/* Create an empty block to serve as latch to prevent flow_loops_find
from finding multiple natural loops in the presence of multiple back
@@ -265,7 +269,7 @@ make_loop_expr_blocks (loop_p, parent_bl
??? Note that latch_block assumes that the latch block is the
successor of the entry block in the linked list of blocks. */
- latch = create_bb (&empty_stmt_node, parent_block);
+ latch = create_bb (&empty_stmt_node, entry);
latch->flags |= BB_CONTROL_EXPR | BB_LOOP_CONTROL_EXPR;
STRIP_CONTAINERS (loop);
@@ -282,7 +286,7 @@ make_cond_expr_blocks (cond_p, parent_bl
{
tree cond = *cond_p;
basic_block entry = create_bb (cond_p, parent_block);
- entry->flags |= BB_CONTROL_ENTRY | BB_CONTROL_EXPR;
+ entry->flags |= BB_COMPOUND_ENTRY | BB_CONTROL_EXPR;
STRIP_CONTAINERS (cond);
make_blocks (&COND_EXPR_THEN (cond), entry);
@@ -300,7 +304,7 @@ make_switch_expr_blocks (switch_e_p, par
{
tree switch_e = *switch_e_p;
basic_block entry = create_bb (switch_e_p, parent_block);
- entry->flags |= BB_CONTROL_ENTRY | BB_CONTROL_EXPR;
+ entry->flags |= BB_COMPOUND_ENTRY | BB_CONTROL_EXPR;
STRIP_CONTAINERS (switch_e);
make_blocks (&SWITCH_BODY (switch_e), entry);
@@ -449,7 +453,7 @@ make_edges ()
}
/* Clean up the graph and warn for unreachable code. */
- tree_cleanup_cfg ();
+ cleanup_tree_cfg ();
}
@@ -694,9 +698,12 @@ make_case_label_edges (bb)
/* Remove unreachable blocks and other miscellaneous clean up work. */
void
-tree_cleanup_cfg ()
+cleanup_tree_cfg ()
{
remove_unreachable_blocks ();
+ /*compact_blocks ();*/
+ /* FIXME Optimize the CFG by stratightening out dead conditionals and
+ whatnot. */
}
@@ -714,7 +721,7 @@ remove_unreachable_blocks ()
next_bb = bb->next_bb;
if (!(bb->flags & BB_REACHABLE))
- tree_delete_bb (bb);
+ remove_tree_bb (bb);
}
}
@@ -722,7 +729,7 @@ remove_unreachable_blocks ()
/* Remove a block from the flowgraph. */
static void
-tree_delete_bb (bb)
+remove_tree_bb (bb)
basic_block bb;
{
gimple_stmt_iterator i;
@@ -731,7 +738,7 @@ tree_delete_bb (bb)
if (dump_file)
{
fprintf (dump_file, "Removed unreachable basic block %d\n", bb->index);
- tree_dump_bb (dump_file, "", bb, 0);
+ dump_tree_bb (dump_file, "", bb, 0);
if (TREE_CODE (first_stmt (bb)) != BIND_EXPR)
fprintf (dump_file, "WARNING: Block %d has executable statements.\n",
bb->index);
@@ -849,7 +856,7 @@ insert_bb_before (new_bb, bb)
/* Dump a basic block to a file. */
void
-tree_dump_bb (outf, prefix, bb, indent)
+dump_tree_bb (outf, prefix, bb, indent)
FILE *outf;
const char *prefix;
basic_block bb;
@@ -865,7 +872,12 @@ tree_dump_bb (outf, prefix, bb, indent)
memset ((void *) s_indent, ' ', (size_t) indent);
s_indent[indent] = '\0';
- fprintf (outf, "%s%sBasic block %d\n", s_indent, prefix, bb->index);
+ fprintf (outf, "%s%sBasic block %d", s_indent, prefix, bb->index);
+
+ if (is_latch_block (bb))
+ fprintf (outf, " (latch for #%d)\n", bb->index - 1);
+ else
+ fprintf (outf, "\n");
fprintf (outf, "%s%sPredecessors: ", s_indent, prefix);
for (e = bb->pred; e; e = e->pred_next)
@@ -881,7 +893,7 @@ tree_dump_bb (outf, prefix, bb, indent)
if (head)
{
lineno = get_lineno (head);
- print_generic_node_brief (outf, head);
+ print_generic_node (outf, head, PPF_BRIEF|PPF_IS_STMT);
fprintf (outf, " (line: %d)\n", lineno);
}
else
@@ -891,7 +903,7 @@ tree_dump_bb (outf, prefix, bb, indent)
if (end)
{
lineno = get_lineno (end);
- print_generic_node_brief (outf, end);
+ print_generic_node (outf, end, PPF_BRIEF|PPF_IS_STMT);
fprintf (outf, " (line: %d)\n", lineno);
}
else
@@ -922,40 +934,52 @@ tree_dump_bb (outf, prefix, bb, indent)
/* Dump a basic block on stderr. */
void
-tree_debug_bb (bb)
+debug_tree_bb (bb)
basic_block bb;
{
- tree_dump_bb (stderr, "", bb, 0);
+ dump_tree_bb (stderr, "", bb, 0);
}
-/* Dump the CFG on stderr. */
+/* Dump the CFG on stderr. If DETAILS is nonzero, a textual representation
+ of each basic block is also produced. */
void
-tree_debug_cfg ()
+debug_tree_cfg (details)
+ int details;
{
- tree_dump_cfg (stderr);
+ dump_tree_cfg (stderr, details);
}
-/* Dump the CFG on the given FILE. */
+/* Dump the program showing basic block boundaries on the given FILE. If
+ DETAILS is set, a textual representation of every basic block will also
+ be dumped. */
void
-tree_dump_cfg (file)
+dump_tree_cfg (file, details)
FILE *file;
+ int details;
{
basic_block bb;
- fputc ('\n', file);
- fprintf (file, "Function %s\n\n", get_name (current_function_decl));
-
- fprintf (file, "\n%d basic blocks, %d edges, last basic block %d.\n",
- n_basic_blocks, n_edges, last_basic_block);
- FOR_EACH_BB (bb)
+ if (details)
{
- tree_dump_bb (file, "", bb, 0);
fputc ('\n', file);
+ fprintf (file, "Function %s\n\n", get_name (current_function_decl));
+ fprintf (file, "\n%d basic blocks, %d edges, last basic block %d.\n",
+ n_basic_blocks, n_edges, last_basic_block);
+
+ FOR_EACH_BB (bb)
+ {
+ dump_tree_bb (file, "", bb, 0);
+ fputc ('\n', file);
+ }
}
+
+ fprintf (file, "%s()\n", get_name (current_function_decl));
+ print_generic_tree (file, DECL_SAVED_TREE (current_function_decl), PPF_BLOCK);
+ fprintf (file, "\n");
}
@@ -1045,36 +1069,7 @@ successor_block (bb)
#endif
/* By default, the successor block will be the block for the statement
- following BB's last statement. Note that this will skip over any
- blocks created for BIND_EXPR nodes.
-
- This is intentional. The only reason why we create basic blocks for
- BIND_EXPR nodes is to be able to find the successor block in cases
- like this:
-
- 1 a = 10;
- 2 b = 5;
- 3 {
- 4 int j;
- 5 {
- 6 int k;
- 7 {
- 8 int l;
- 9
- 10 l = a + k;
- 11 }
- 12 }
- 13 }
- 14 b = a + b;
-
- If we didn't create a basic block for the braces at lines 3, 5 and 7,
- we would not realize that the successor block for line 10 is the block
- at line 14.
-
- However, since blocks for BIND_EXPR nodes do not really contribute
- anything to the flowgraph, we don't want to create edges to them,
- leaving them unreachable. The post-processing cleanup will remove
- them from the graph. */
+ following BB's last statement. */
i = gsi_start (bb->end_tree_p);
gsi_step (&i);
succ_bb = first_exec_block (gsi_container (i));
@@ -1082,7 +1077,7 @@ successor_block (bb)
return succ_bb;
/* We couldn't find a successor for BB. Walk up the control structure to
- see if our parent has a successor. Iterate until we find one or we
+ see if our parent has a successor. Iterate until we find one or we
reach nesting level 0. */
parent_bb = parent_block (bb);
while (parent_bb)
@@ -1104,8 +1099,9 @@ successor_block (bb)
parent_bb = parent_block (parent_bb);
}
- /* We reached nesting level 0. Return the exit block. */
- return EXIT_BLOCK_PTR;
+ /* We reached nesting level 0. Return the next block in the linked list
+ of blocks. */
+ return bb->next_bb;
}
@@ -1127,8 +1123,8 @@ is_ctrl_stmt (t)
}
-/* Return true if T alters the flow of control (i.e., T is BREAK, GOTO,
- CONTINUE or RETURN) */
+/* Return true if T alters the flow of control (i.e., T is GOTO,
+ RETURN or a call to a non-returning function) */
bool
is_ctrl_altering_stmt (t)
@@ -1196,7 +1192,6 @@ stmt_starts_bb_p (t)
STRIP_WFL (t);
return (TREE_CODE (t) == CASE_LABEL_EXPR
|| TREE_CODE (t) == LABEL_EXPR
- || TREE_CODE (t) == RETURN_EXPR
|| TREE_CODE (t) == BIND_EXPR
|| is_ctrl_stmt (t));
}
@@ -1225,25 +1220,46 @@ delete_tree_cfg ()
/* Returns the block marking the end of the loop body. This is the block
that contains the back edge to the start of the loop. */
-static basic_block
+basic_block
latch_block (loop_bb)
basic_block loop_bb;
{
+ int entry_ix, latch_ix;
+ basic_block latch_bb;
tree loop = first_stmt (loop_bb);
-#if defined ENABLE_CHECKING
- if (TREE_CODE (loop) != LOOP_EXPR)
- abort ();
+ if (loop == NULL_TREE || TREE_CODE (loop) != LOOP_EXPR)
+ return NULL;
- if (loop_bb->next_bb == NULL
- || *(loop_bb->next_bb->head_tree_p) != empty_stmt_node
- || *(loop_bb->next_bb->end_tree_p) != empty_stmt_node)
- abort ();
-#endif
+ if (loop_bb->index == INVALID_BLOCK)
+ return NULL;
+
+ entry_ix = loop_bb->index;
+ latch_ix = entry_ix + 1;
+ latch_bb = BASIC_BLOCK (latch_ix);
/* The latch block for a LOOP_EXPR is guaranteed to be the next block in
the linked list (see make_loop_expr_blocks). */
- return loop_bb->next_bb;
+ return latch_bb;
+}
+
+
+/* Return true if BB is a latch block. */
+
+bool
+is_latch_block (bb)
+ basic_block bb;
+{
+ if (bb->index > 0
+ && first_stmt (bb) == empty_stmt_node
+ && last_stmt (bb) == empty_stmt_node)
+ {
+ basic_block loop_bb = BASIC_BLOCK (bb->index - 1);
+ tree loop_t = first_stmt (loop_bb);
+ return (loop_t && TREE_CODE (loop_t) == LOOP_EXPR);
+ }
+
+ return false;
}
@@ -1262,20 +1278,10 @@ first_exec_stmt (entry_p)
STRIP_WFL (stmt);
STRIP_NOPS (stmt);
- /* Dive into BIND_EXPR bodies. If the body is empty, keep going with
- the statement following the BIND_EXPR node. */
- if (TREE_CODE (stmt) == BIND_EXPR)
- {
- tree *first = first_exec_stmt (&BIND_EXPR_BODY (stmt));
- if (first)
- return first;
- }
-
- /* Don't consider empty_stmt_node to be executable. Note that we
- actually return the container for the executable statement, not
- the statement itself. This is to allow the caller to start
- iterating from this point. */
- else if (is_exec_stmt (stmt))
+ /* Note that we actually return the container for the executable
+ statement, not the statement itself. This is to allow the caller to
+ start iterating from this point. */
+ if (is_exec_stmt (stmt))
return gsi_container (i);
}
@@ -1325,6 +1331,9 @@ first_stmt (bb)
gimple_stmt_iterator i;
tree t;
+ if (bb == NULL || bb->index == INVALID_BLOCK)
+ return NULL_TREE;
+
i = gsi_start_bb (bb);
t = gsi_stmt (i);
STRIP_WFL (t);
@@ -1343,6 +1352,9 @@ last_stmt (bb)
gimple_stmt_iterator i;
tree t;
+ if (bb == NULL || bb->index == INVALID_BLOCK)
+ return NULL_TREE;
+
i = gsi_start (bb->end_tree_p);
t = gsi_stmt (i);
STRIP_WFL (t);
Index: tree-dfa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-dfa.c,v
retrieving revision 1.1.4.36
diff -d -u -p -r1.1.4.36 tree-dfa.c
--- tree-dfa.c 23 Oct 2002 00:36:00 -0000 1.1.4.36
+++ tree-dfa.c 26 Oct 2002 18:06:20 -0000
@@ -128,7 +128,7 @@ const unsigned TRM_ADDRESSOF = 1 << 7;
/* Look for variable references in every block of the flowgraph. */
void
-tree_find_refs ()
+find_tree_refs ()
{
basic_block bb;
@@ -200,6 +200,7 @@ find_refs_in_stmt (stmt_p, bb)
/* These nodes contain no variable references. */
case LOOP_EXPR:
+ case BIND_EXPR:
case CASE_LABEL_EXPR:
break;
@@ -498,6 +499,7 @@ create_ref_list ()
return list;
}
+
/* Free the nodes in LIST, but keep the empty list around.
(i.e., empty the list). */
@@ -511,6 +513,7 @@ empty_ref_list (list)
list->first = list->last = NULL;
}
+
/* Remove REF from LIST. */
void
@@ -638,6 +641,89 @@ find_list_node (list, ref)
return node;
}
+/* Start a new forward iterator on the first element of LIST. */
+
+ref_list_iterator
+rli_start (list)
+ ref_list list;
+{
+ ref_list_iterator i;
+
+ if (list)
+ {
+ /* rli_delete may have left list->first empty. Reset it here. */
+ while (list->first && list->first->ref == NULL)
+ list->first = list->first->next;
+
+ i.node = list->first;
+ }
+ else
+ i.node = NULL;
+
+ return i;
+}
+
+
+/* Start a new iterator on the last element of LIST. */
+
+ref_list_iterator
+rli_start_last (list)
+ ref_list list;
+{
+ ref_list_iterator i;
+
+ if (list)
+ {
+ /* rli_delete may have left list->last empty. Reset it here. */
+ while (list->last && list->last->ref == NULL)
+ list->last = list->last->prev;
+
+ i.node = list->last;
+ }
+ else
+ i.node = NULL;
+
+ return i;
+}
+
+
+/* Start a new iterator on a specific list node N. */
+
+ref_list_iterator
+rli_start_at (n)
+ struct ref_list_node *n;
+{
+ ref_list_iterator i;
+ i.node = n;
+ return i;
+}
+
+
+/* Delete the reference at the current position of iterator I.
+
+ NOTE: This will not remove the first and last element of a list. It
+ will merely nullify the reference that they are pointing to. This will
+ be "corrected" the next time an iterator is started on the same list.
+
+ FIXME This is a bit hackish, but otherwise we need to either keep
+ handles on ref_list nodes in the iterator or include the list in
+ the structure. */
+
+void
+rli_delete (i)
+ ref_list_iterator i;
+{
+ struct ref_list_node *n = i.node;
+
+ n->ref = NULL;
+
+ if (n->prev)
+ n->prev->next = n->next;
+
+ if (n->next)
+ n->next->prev = n->prev;
+}
+
/* Add REF after NODE. */
@@ -834,11 +920,10 @@ create_ref (var, ref_type, ref_mod, bb,
if (parent_expr)
add_tree_ref (parent_expr, ref);
- /* In same cases the parent statement and parent expression are the
+ /* In some cases the parent statement and parent expression are the
same tree node. For instance 'a = 5;'. Avoid adding the same
reference twice to the same list in these cases. */
- if (parent_stmt
- && parent_stmt != parent_expr)
+ if (parent_stmt && parent_stmt != parent_expr)
add_tree_ref (parent_stmt, ref);
}
@@ -1045,14 +1131,14 @@ dump_ref (outf, prefix, ref, indent, det
fprintf (outf, "%s%s%s(", s_indent, prefix, type);
if (ref_var (ref))
- print_generic_node (outf, ref_var (ref));
+ print_generic_node (outf, ref_var (ref), 0);
else
fprintf (outf, "nil");
fprintf (outf, "): line %d, bb %d, id %lu, ", lineno, bbix, ref_id (ref));
if (ref_expr (ref))
- print_generic_node (outf, ref_expr (ref));
+ print_generic_node (outf, ref_expr (ref), 0);
else
fprintf (outf, "<nil>");
@@ -1229,7 +1315,7 @@ dump_variable (file, var)
size_t num;
fprintf (file, "Variable: ");
- print_generic_node (file, var);
+ print_generic_node (file, var, 0);
num = num_may_alias (var);
if (num > 0)
@@ -1240,7 +1326,7 @@ dump_variable (file, var)
for (i = 0; i < num; i++)
{
- print_generic_node (file, may_alias (var, i));
+ print_generic_node (file, may_alias (var, i), 0);
if (i < num - 1)
fprintf (file, ", ");
}
Index: tree-flow-inline.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow-inline.h,v
retrieving revision 1.1.2.8
diff -d -u -p -r1.1.2.8 tree-flow-inline.h
--- tree-flow-inline.h 23 Oct 2002 00:36:00 -0000 1.1.2.8
+++ tree-flow-inline.h 26 Oct 2002 18:06:20 -0000
@@ -632,8 +632,17 @@ static inline gimple_stmt_iterator
gsi_start_bb (bb)
basic_block bb;
{
- tree *tp = bb->head_tree_p;
- return gsi_start (tp);
+ if (bb && bb->index != INVALID_BLOCK)
+ {
+ tree *tp = bb->head_tree_p;
+ return gsi_start (tp);
+ }
+ else
+ {
+ gimple_stmt_iterator i;
+ i.tp = NULL;
+ return i;
+ }
}
static inline bool
@@ -752,36 +761,6 @@ is_pure_use (ref)
&& ref_type (ref) == V_USE;
}
-/* Start a new forward iterator on the first element of LIST. */
-static inline ref_list_iterator
-rli_start (list)
- ref_list list;
-{
- ref_list_iterator i;
- i.node = (list) ? list->first : NULL;
- return i;
-}
-
-/* Start a new reverse iterator on the last element of LIST. */
-static inline ref_list_iterator
-rli_start_rev (list)
- ref_list list;
-{
- ref_list_iterator i;
- i.node = (list) ? list->last : NULL;
- return i;
-}
-
-/* Start a new reverse iterator on a specific list node N. */
-static inline ref_list_iterator
-rli_start_at (n)
- struct ref_list_node *n;
-{
- ref_list_iterator i;
- i.node = n;
- return i;
-}
-
/* Return TRUE if we reached the end of the list with iterator I. */
static inline bool
rli_after_end (i)
@@ -826,6 +805,17 @@ get_first_ref (list)
ref_list list;
{
return list->first->ref;
+}
+
+static inline bool
+ref_list_is_empty (list)
+ ref_list list;
+{
+ return (list == NULL
+ || list->first == NULL
+ || list->last == NULL
+ /* rli_delete cannot remove list->first nor list->last. */
+ || (list->first->ref == NULL && list->last->ref == NULL));
}
#endif /* _TREE_FLOW_INLINE_H */
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow.h,v
retrieving revision 1.1.4.29
diff -d -u -p -r1.1.4.29 tree-flow.h
--- tree-flow.h 23 Oct 2002 00:36:00 -0000 1.1.4.29
+++ tree-flow.h 26 Oct 2002 18:06:20 -0000
@@ -599,13 +599,14 @@ typedef struct {
struct ref_list_node *node;
} ref_list_iterator;
-static inline ref_list_iterator rli_start PARAMS ((ref_list));
-static inline ref_list_iterator rli_start_rev PARAMS ((ref_list));
-static inline ref_list_iterator rli_start_at PARAMS ((struct ref_list_node *));
+extern ref_list_iterator rli_start PARAMS ((ref_list));
+extern ref_list_iterator rli_start_last PARAMS ((ref_list));
+extern ref_list_iterator rli_start_at PARAMS ((struct ref_list_node *));
static inline bool rli_after_end PARAMS ((ref_list_iterator));
static inline void rli_step PARAMS ((ref_list_iterator *));
static inline void rli_step_rev PARAMS ((ref_list_iterator *));
static inline tree_ref rli_ref PARAMS ((ref_list_iterator));
+extern void rli_delete PARAMS ((ref_list_iterator));
/* Global declarations. */
@@ -645,21 +646,23 @@ extern tree loop_body PARAMS ((tree));
extern void set_loop_body PARAMS ((tree, tree));
extern bool stmt_starts_bb_p PARAMS ((tree));
extern bb_ann create_bb_ann PARAMS ((basic_block));
-extern void tree_dump_bb PARAMS ((FILE *, const char *,
- basic_block, int));
-extern void tree_debug_bb PARAMS ((basic_block));
-extern void tree_dump_cfg PARAMS ((FILE *));
-extern void tree_debug_cfg PARAMS ((void));
+extern void dump_tree_bb PARAMS ((FILE *, const char *,
+ basic_block, int));
+extern void debug_tree_bb PARAMS ((basic_block));
+extern void dump_tree_cfg PARAMS ((FILE *, int));
+extern void debug_tree_cfg PARAMS ((int));
extern void tree_cfg2dot PARAMS ((FILE *));
extern void validate_loops PARAMS ((struct loops *));
extern void insert_bb_before PARAMS ((basic_block, basic_block));
-extern void tree_cleanup_cfg PARAMS ((void));
+extern void cleanup_tree_cfg PARAMS ((void));
extern tree first_stmt PARAMS ((basic_block));
extern tree last_stmt PARAMS ((basic_block));
+extern basic_block latch_block PARAMS ((basic_block));
+extern bool is_latch_block PARAMS ((basic_block));
/* In tree-dfa.c */
-extern void tree_find_refs PARAMS ((void));
+extern void find_tree_refs PARAMS ((void));
extern void find_refs_in_stmt PARAMS ((tree *, basic_block));
extern tree_ann create_tree_ann PARAMS ((tree));
extern tree_ref create_ref PARAMS ((tree, enum tree_ref_type,
@@ -695,8 +698,9 @@ extern void add_list_to_list_end
extern void add_list_to_list_begin PARAMS ((ref_list, ref_list));
extern void remove_ref_from_list PARAMS ((ref_list, tree_ref));
extern struct ref_list_node *find_list_node PARAMS ((ref_list, tree_ref));
-extern tree_ref get_last_ref PARAMS ((ref_list));
-extern tree_ref get_first_ref PARAMS ((ref_list));
+static inline tree_ref get_last_ref PARAMS ((ref_list));
+static inline tree_ref get_first_ref PARAMS ((ref_list));
+static inline bool ref_list_is_empty PARAMS ((ref_list));
extern const char *ref_type_name PARAMS ((tree_ref));
extern bool ref_defines PARAMS ((tree_ref, tree));
extern bool is_killing_def PARAMS ((tree_ref, tree_ref));
@@ -707,7 +711,7 @@ extern enum tree_ref_structure_enum tree
/* In tree-ssa.c */
extern void build_tree_ssa PARAMS ((tree));
extern void delete_tree_ssa PARAMS ((tree));
-extern void tree_compute_rdefs PARAMS ((void));
+extern void compute_tree_rdefs PARAMS ((void));
extern void analyze_rdefs PARAMS ((void));
extern void tree_ssa_remove_phi_alternative PARAMS ((tree_ref, basic_block));
extern void dump_reaching_defs PARAMS ((FILE *));
Index: tree-mudflap.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-mudflap.c,v
retrieving revision 1.1.2.19
diff -d -u -p -r1.1.2.19 tree-mudflap.c
--- tree-mudflap.c 21 Oct 2002 16:37:07 -0000 1.1.2.19
+++ tree-mudflap.c 26 Oct 2002 18:06:20 -0000
@@ -84,13 +84,13 @@ mudflap_c_function (t)
if (getenv ("UNPARSE")) /* XXX */
{
- print_generic_tree (stderr, DECL_RESULT (t));
+ print_generic_tree (stderr, DECL_RESULT (t), 0);
fprintf (stderr, " ");
- print_generic_tree (stderr, DECL_NAME (t));
+ print_generic_tree (stderr, DECL_NAME (t), 0);
fprintf (stderr, " (");
- print_generic_tree (stderr, DECL_ARGUMENTS (t));
+ print_generic_tree (stderr, DECL_ARGUMENTS (t), 0);
fprintf (stderr, " )\n");
- print_generic_tree (stderr, DECL_SAVED_TREE (t));
+ print_generic_tree (stderr, DECL_SAVED_TREE (t), 0);
}
mf_init_extern_trees ();
@@ -101,7 +101,7 @@ mudflap_c_function (t)
if (getenv ("UNPARSE")) /* XXX */
{
fprintf (stderr, "/* after -fmudflap: */\n");
- print_generic_tree (stderr, DECL_SAVED_TREE (t));
+ print_generic_tree (stderr, DECL_SAVED_TREE (t), 0);
}
}
@@ -137,7 +137,7 @@ mudflap_enqueue_decl (obj, label)
/*
fprintf (stderr, "enqueue_decl obj=`");
- print_generic_tree (stderr, obj);
+ print_generic_tree (stderr, obj, 0);
fprintf (stderr, "' label=`%s'\n", label);
*/
@@ -733,7 +733,7 @@ mx_xfn_indirect_ref (t, continue_p, data
#if 0
fprintf (stderr, "expr=%s: ", tree_code_name [TREE_CODE (*t)]);
- print_generic_tree (stderr, *t);
+ print_generic_tree (stderr, *t, 0);
fprintf (stderr, "\n");
#endif
@@ -830,7 +830,7 @@ mx_xfn_indirect_ref (t, continue_p, data
#if 0
warning ("mudflap is omitting array bounds checks");
fprintf (stderr, " for expression: ");
- print_generic_tree (stderr, *t);
+ print_generic_tree (stderr, *t, 0);
fprintf (stderr, " array-size=%u", int_size_in_bytes (TREE_TYPE (base_array)));
fprintf (stderr, " check-size=%u", TREE_INT_CST_LOW (check_size));
fprintf (stderr, "\n");
@@ -1164,9 +1164,9 @@ mx_xfn_find_addrof (t, continue_p, data)
if (gotit != NULL)
{
fprintf (stderr, "matched decl=");
- print_generic_tree (stderr, decl);
+ print_generic_tree (stderr, decl, 0);
fprintf (stderr, " in tree=");
- print_generic_tree (stderr, gotit);
+ print_generic_tree (stderr, gotit, 0);
fprintf (stderr, "\n");
}
#endif
Index: tree-optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-optimize.c,v
retrieving revision 1.1.4.18
diff -d -u -p -r1.1.4.18 tree-optimize.c
--- tree-optimize.c 22 Oct 2002 16:07:09 -0000 1.1.4.18
+++ tree-optimize.c 26 Oct 2002 18:06:20 -0000
@@ -35,10 +35,6 @@ Boston, MA 02111-1307, USA. */
#include "tree-dchain.h"
#include "timevar.h"
-/* Shared functions with tree-cfg.c and tree-ssa.c. */
-extern void delete_tree_ssa PARAMS ((tree));
-
-
/* Main entry point to the tree SSA transformation routines. FNDECL is
the FUNCTION_DECL node for the function to optimize. */
@@ -118,7 +114,7 @@ optimize_function_tree (fndecl)
if (dump_flags & TDF_RAW)
dump_node (fnbody, TDF_SLIM | dump_flags, dump_file);
else
- print_generic_tree (dump_file, fnbody);
+ print_generic_tree (dump_file, fnbody, 0);
fprintf (dump_file, "\n");
dump_end (TDI_optimized, dump_file);
Index: tree-pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-pretty-print.c,v
retrieving revision 1.1.2.2
diff -d -u -p -r1.1.2.2 tree-pretty-print.c
--- tree-pretty-print.c 22 Oct 2002 18:28:19 -0000 1.1.2.2
+++ tree-pretty-print.c 26 Oct 2002 18:06:20 -0000
@@ -26,7 +26,17 @@ Software Foundation, 59 Temple Place - S
#include "diagnostic.h"
#include "real.h"
#include "hashtab.h"
+#include "tree-flow.h"
+
+/* Modifier flags for print_generic_* functions. See diagnostic.h for
+ documentation. */
+const int PPF_BRIEF = 1 << 0;
+const int PPF_BLOCK = 1 << 1;
+const int PPF_LINENO = 1 << 2;
+const int PPF_IS_STMT = 1 << 3;
+
+/* Local functions, macros and variables. */
static int op_prio PARAMS ((tree));
static const char *op_symbol PARAMS ((tree));
static void pretty_print_string PARAMS ((output_buffer *,
@@ -39,6 +49,8 @@ static void print_declaration PARAMS (
int, int));
static void print_struct_decl PARAMS ((output_buffer *, tree,
int));
+static void dump_block_info PARAMS ((output_buffer *,
+ basic_block, int));
#define INDENT(SPACE) do { \
int i; for (i = 0; i<SPACE; i++) output_add_space (buffer); } while (0)
@@ -55,114 +67,51 @@ static void print_struct_decl PARAMS (
static output_buffer buffer;
static int initialized = 0;
+static int last_bb = -1;
-/* Print the tree T in full, on file FILE. */
-
-void
-print_generic_tree (file, t)
- FILE *file;
- tree t;
-{
- maybe_init_pretty_print ();
- dump_generic_tree (&buffer, t, 0);
- fprintf (file, "%s", output_finalize_message (&buffer));
- output_clear_message_text (&buffer);
-}
-
-/* Print the node T on file FILE. */
+/* Print the tree T, and its successors, on file FILE. FLAGS specifies details
+ to show in the dump. See PPF_* in diagnostic.h. */
void
-print_generic_node (file, t)
+print_generic_tree (file, t, flags)
FILE *file;
tree t;
+ int flags;
{
maybe_init_pretty_print ();
- dump_generic_node (&buffer, t, 0, 0);
+ last_bb = -1;
+ dump_generic_node (&buffer, t, 0, flags | PPF_IS_STMT);
fprintf (file, "%s", output_finalize_message (&buffer));
output_clear_message_text (&buffer);
}
-/* Print the first line of node T on file FILE. For control statement
- nodes, only print the header expressions. */
-void
-print_generic_node_brief (file, t)
+/* Print a single node T on file FILE. FLAGS specifies details to show in the
+ dump. See PPF_* in diagnostic.h. */
+
+void
+print_generic_node (file, t, flags)
FILE *file;
tree t;
+ int flags;
{
maybe_init_pretty_print ();
- dump_generic_node (&buffer, t, 0, 1);
+ last_bb = -1;
+ dump_generic_node (&buffer, t, 0, flags);
fprintf (file, "%s", output_finalize_message (&buffer));
output_clear_message_text (&buffer);
}
-static void
-newline_and_indent (buffer, spc)
- output_buffer *buffer;
- int spc;
-{
- output_add_newline (buffer);
- INDENT (spc);
-}
-
-/* Dump the tree T on the output_buffer BUFFER. */
-
-void
-dump_generic_tree (buffer, t, spc)
- output_buffer *buffer;
- tree t;
- int spc;
-{
- tree node = t;
- htab_t htab;
- int circularity_p = 0;
-
- htab = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL);
- while (node && node != error_mark_node)
- {
- void **slot;
- slot = htab_find_slot (htab, node, INSERT);
- *slot = (void *) node;
-
- spc = dump_generic_node (buffer, node, spc, 0);
-
- if (circularity_p)
- break;
-
- switch (TREE_CODE (node))
- {
- case TYPE_DECL:
- case FIELD_DECL:
- case VAR_DECL:
- case PARM_DECL:
- /* Some nodes on which we need to stop the recursive printing,
- otherwise we print all declared vars in the scope. */
- {
- htab_delete (htab);
- return;
- }
- default:
- break;
- }
- node = TREE_CHAIN (node);
- if (htab_find (htab, node))
- {
- output_add_string (buffer, "/* circularity detected! */\n");
- circularity_p = 1; /* Allow one final loop iteration. */
- }
- }
- htab_delete (htab);
-}
/* Dump the node NODE on the output_buffer BUFFER, SPC spaces of indent. */
int
-dump_generic_node (buffer, node, spc, brief_dump)
+dump_generic_node (buffer, node, spc, flags)
output_buffer *buffer;
tree node;
int spc;
- int brief_dump;
+ int flags;
{
tree type;
tree op0, op1;
@@ -171,6 +120,11 @@ dump_generic_node (buffer, node, spc, br
if (node == NULL_TREE)
return spc;
+ if ((flags & PPF_BLOCK)
+ && node != empty_stmt_node
+ && node != error_mark_node)
+ dump_block_info (buffer, bb_for_stmt (node), spc);
+
switch (TREE_CODE (node))
{
case ERROR_MARK:
@@ -186,10 +140,10 @@ dump_generic_node (buffer, node, spc, br
{
if (TREE_PURPOSE (node))
{
- dump_generic_node (buffer, TREE_PURPOSE (node), spc, brief_dump);
+ dump_generic_node (buffer, TREE_PURPOSE (node), spc, flags);
output_add_space (buffer);
}
- dump_generic_node (buffer, TREE_VALUE (node), spc, brief_dump);
+ dump_generic_node (buffer, TREE_VALUE (node), spc, flags);
node = TREE_CHAIN (node);
if (node && TREE_CODE (node) == TREE_LIST)
{
@@ -200,7 +154,7 @@ dump_generic_node (buffer, node, spc, br
break;
case TREE_VEC:
- dump_generic_node (buffer, BINFO_TYPE (node), spc, brief_dump);
+ dump_generic_node (buffer, BINFO_TYPE (node), spc, flags);
break;
case BLOCK:
@@ -256,11 +210,12 @@ dump_generic_node (buffer, node, spc, br
}
break;
}
+
case POINTER_TYPE:
if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
{
tree fnode = TREE_TYPE (node);
- dump_generic_node (buffer, TREE_TYPE (fnode), spc, brief_dump);
+ dump_generic_node (buffer, TREE_TYPE (fnode), spc, flags);
output_add_space (buffer);
output_add_string (buffer, "(*");
if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
@@ -277,7 +232,7 @@ dump_generic_node (buffer, node, spc, br
tree tmp = TYPE_ARG_TYPES (fnode);
while (tmp && TREE_CHAIN (tmp) && tmp != error_mark_node)
{
- dump_generic_node (buffer, TREE_VALUE (tmp), spc, brief_dump);
+ dump_generic_node (buffer, TREE_VALUE (tmp), spc, flags);
tmp = TREE_CHAIN (tmp);
if (TREE_CHAIN (tmp) && TREE_CODE (TREE_CHAIN (tmp)) == TREE_LIST)
{
@@ -292,7 +247,7 @@ dump_generic_node (buffer, node, spc, br
{
unsigned int quals = TYPE_QUALS (node);
- dump_generic_node (buffer, TREE_TYPE (node), spc, brief_dump);
+ dump_generic_node (buffer, TREE_TYPE (node), spc, flags);
output_add_string (buffer, " *");
if (quals & TYPE_QUAL_CONST)
@@ -312,7 +267,7 @@ dump_generic_node (buffer, node, spc, br
case REFERENCE_TYPE:
/* FIXME : What is the exact syntax of this node for C? */
- dump_generic_node (buffer, TREE_TYPE (node), spc, brief_dump);
+ dump_generic_node (buffer, TREE_TYPE (node), spc, flags);
break;
case METHOD_TYPE:
@@ -330,7 +285,7 @@ dump_generic_node (buffer, node, spc, br
tree tmp;
/* Print the array type. */
- dump_generic_node (buffer, TREE_TYPE (node), spc, brief_dump);
+ dump_generic_node (buffer, TREE_TYPE (node), spc, flags);
/* Print the dimensions. */
tmp = node;
@@ -360,7 +315,7 @@ dump_generic_node (buffer, node, spc, br
output_add_string (buffer, "union ");
if (TYPE_NAME (node))
- dump_generic_node (buffer, TYPE_NAME (node), spc, brief_dump);
+ dump_generic_node (buffer, TYPE_NAME (node), spc, flags);
else
print_struct_decl (buffer, node, spc);
break;
@@ -439,9 +394,9 @@ dump_generic_node (buffer, node, spc, br
case COMPLEX_CST:
output_add_string (buffer, "__complex__ (");
- dump_generic_node (buffer, TREE_REALPART (node), spc, brief_dump);
+ dump_generic_node (buffer, TREE_REALPART (node), spc, flags);
output_add_string (buffer, ", ");
- dump_generic_node (buffer, TREE_IMAGPART (node), spc, brief_dump);
+ dump_generic_node (buffer, TREE_IMAGPART (node), spc, flags);
output_add_string (buffer, ")");
break;
@@ -489,12 +444,12 @@ dump_generic_node (buffer, node, spc, br
/* The type is a c++ class: all structures have at least
4 methods. */
output_add_string (buffer, "class ");
- dump_generic_node (buffer, TREE_TYPE (node), spc, brief_dump);
+ dump_generic_node (buffer, TREE_TYPE (node), spc, flags);
}
else
{
output_add_string (buffer, "struct ");
- dump_generic_node (buffer, TREE_TYPE (node), spc, brief_dump);
+ dump_generic_node (buffer, TREE_TYPE (node), spc, flags);
output_add_character (buffer, ';');
output_add_newline (buffer);
}
@@ -510,7 +465,7 @@ dump_generic_node (buffer, node, spc, br
break;
case RESULT_DECL:
- dump_generic_node (buffer, TREE_TYPE (node), spc, brief_dump);
+ dump_generic_node (buffer, TREE_TYPE (node), spc, flags);
break;
case FIELD_DECL:
@@ -537,20 +492,20 @@ dump_generic_node (buffer, node, spc, br
}
if (op_prio (op0) < op_prio (node))
output_add_character (buffer, '(');
- dump_generic_node (buffer, op0, spc, brief_dump);
+ dump_generic_node (buffer, op0, spc, flags);
if (op_prio (op0) < op_prio (node))
output_add_character (buffer, ')');
output_add_string (buffer, str);
- dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags);
break;
case BIT_FIELD_REF:
output_add_string (buffer, "BIT_FIELD_REF <");
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
output_add_string (buffer, ", ");
- dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags);
output_add_string (buffer, ", ");
- dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags);
output_add_string (buffer, ">");
break;
@@ -562,11 +517,11 @@ dump_generic_node (buffer, node, spc, br
op0 = TREE_OPERAND (node, 0);
if (op_prio (op0) < op_prio (node))
output_add_character (buffer, '(');
- dump_generic_node (buffer, op0, spc, brief_dump);
+ dump_generic_node (buffer, op0, spc, flags);
if (op_prio (op0) < op_prio (node))
output_add_character (buffer, ')');
output_add_character (buffer, '[');
- dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags);
output_add_character (buffer, ']');
break;
@@ -590,7 +545,7 @@ dump_generic_node (buffer, node, spc, br
if (TREE_PURPOSE (lnode) && is_struct_init)
{
output_add_character (buffer, '.');
- dump_generic_node (buffer, TREE_PURPOSE (lnode), spc, brief_dump);
+ dump_generic_node (buffer, TREE_PURPOSE (lnode), spc, flags);
output_add_string (buffer, "=");
}
val = TREE_VALUE (lnode);
@@ -606,7 +561,7 @@ dump_generic_node (buffer, node, spc, br
}
else
{
- dump_generic_node (buffer, TREE_VALUE (lnode), spc, brief_dump);
+ dump_generic_node (buffer, TREE_VALUE (lnode), spc, flags);
}
lnode = TREE_CHAIN (lnode);
if (lnode && TREE_CODE (lnode) == TREE_LIST)
@@ -620,38 +575,38 @@ dump_generic_node (buffer, node, spc, br
break;
case COMPOUND_EXPR:
- if (TREE_TYPE (node) == void_type_node)
+ if (flags & PPF_IS_STMT)
{
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
- if (!brief_dump)
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
+ if (!(flags & PPF_BRIEF))
{
output_add_character (buffer, ';');
newline_and_indent (buffer, spc);
- dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags);
}
}
else
{
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
output_add_character (buffer, ',');
output_add_space (buffer);
- dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags);
}
break;
case MODIFY_EXPR:
case INIT_EXPR:
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
output_add_space (buffer);
output_add_character (buffer, '=');
output_add_space (buffer);
- dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags);
break;
case TARGET_EXPR:
- dump_generic_node (buffer, TYPE_NAME (TREE_TYPE (node)), spc, brief_dump);
+ dump_generic_node (buffer, TYPE_NAME (TREE_TYPE (node)), spc, flags);
output_add_character (buffer, '(');
- dump_generic_node (buffer, TARGET_EXPR_INITIAL (node), spc, brief_dump);
+ dump_generic_node (buffer, TARGET_EXPR_INITIAL (node), spc, flags);
output_add_character (buffer, ')');
break;
@@ -659,9 +614,9 @@ dump_generic_node (buffer, node, spc, br
if (TREE_TYPE (node) == void_type_node)
{
output_add_string (buffer, "if (");
- dump_generic_node (buffer, COND_EXPR_COND (node), spc, brief_dump);
+ dump_generic_node (buffer, COND_EXPR_COND (node), spc, flags);
output_add_character (buffer, ')');
- if (!brief_dump)
+ if (!(flags & PPF_BRIEF))
{
if (COND_EXPR_THEN (node) == empty_stmt_node)
{
@@ -672,7 +627,8 @@ dump_generic_node (buffer, node, spc, br
newline_and_indent (buffer, spc+2);
output_add_character (buffer, '{');
newline_and_indent (buffer, spc+4);
- dump_generic_node (buffer, TREE_OPERAND (node, 1), spc+4, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 1), spc+4,
+ flags);
newline_and_indent (buffer, spc+2);
output_add_character (buffer, '}');
}
@@ -684,7 +640,7 @@ dump_generic_node (buffer, node, spc, br
output_add_character (buffer, '{');
newline_and_indent (buffer, spc+4);
dump_generic_node (buffer, TREE_OPERAND (node, 2), spc+4,
- brief_dump);
+ flags);
newline_and_indent (buffer, spc+2);
output_add_character (buffer, '}');
}
@@ -692,29 +648,32 @@ dump_generic_node (buffer, node, spc, br
}
else
{
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
output_add_space (buffer);
output_add_character (buffer, '?');
output_add_space (buffer);
- dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags);
output_add_space (buffer);
output_add_character (buffer, ':');
output_add_space (buffer);
- dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags);
}
break;
case BIND_EXPR:
output_add_character (buffer, '{');
- if (!brief_dump)
+ if (!(flags & PPF_BRIEF))
{
- output_add_newline (buffer);
+ if (BIND_EXPR_VARS (node))
+ {
+ output_add_newline (buffer);
- for (op0 = BIND_EXPR_VARS (node); op0; op0 = TREE_CHAIN (op0))
- print_declaration (buffer, op0, spc+2, brief_dump);
+ for (op0 = BIND_EXPR_VARS (node); op0; op0 = TREE_CHAIN (op0))
+ print_declaration (buffer, op0, spc+2, flags);
+ }
newline_and_indent (buffer, spc+2);
- dump_generic_node (buffer, BIND_EXPR_BODY (node), spc+2, brief_dump);
+ dump_generic_node (buffer, BIND_EXPR_BODY (node), spc+2, flags);
newline_and_indent (buffer, spc);
output_add_character (buffer, '}');
}
@@ -728,7 +687,7 @@ dump_generic_node (buffer, node, spc, br
output_add_character (buffer, '(');
op1 = TREE_OPERAND (node, 1);
if (op1)
- dump_generic_node (buffer, op1, 0, brief_dump);
+ dump_generic_node (buffer, op1, 0, flags);
output_add_character (buffer, ')');
break;
@@ -800,11 +759,11 @@ dump_generic_node (buffer, node, spc, br
if (op_prio (op0) < op_prio (node))
{
output_add_character (buffer, '(');
- dump_generic_node (buffer, op0, spc, brief_dump);
+ dump_generic_node (buffer, op0, spc, flags);
output_add_character (buffer, ')');
}
else
- dump_generic_node (buffer, op0, spc, brief_dump);
+ dump_generic_node (buffer, op0, spc, flags);
output_add_space (buffer);
output_add_string (buffer, op);
@@ -815,11 +774,11 @@ dump_generic_node (buffer, node, spc, br
if (op_prio (op1) < op_prio (node))
{
output_add_character (buffer, '(');
- dump_generic_node (buffer, op1, spc, brief_dump);
+ dump_generic_node (buffer, op1, spc, flags);
output_add_character (buffer, ')');
}
else
- dump_generic_node (buffer, op1, spc, brief_dump);
+ dump_generic_node (buffer, op1, spc, flags);
}
break;
@@ -842,11 +801,11 @@ dump_generic_node (buffer, node, spc, br
if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
{
output_add_character (buffer, '(');
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
output_add_character (buffer, ')');
}
else
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
break;
case POSTDECREMENT_EXPR:
@@ -854,43 +813,43 @@ dump_generic_node (buffer, node, spc, br
if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
{
output_add_character (buffer, '(');
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
output_add_character (buffer, ')');
}
else
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
output_add_string (buffer, op_symbol (node));
break;
case MIN_EXPR:
/* #define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) */
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
output_add_string (buffer, " < ");
- dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags);
output_add_string (buffer, " ? ");
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
output_add_string (buffer, " : ");
- dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags);
break;
case MAX_EXPR:
/* #define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) */
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
output_add_string (buffer, " > ");
- dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags);
output_add_string (buffer, " ? ");
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
output_add_string (buffer, " : ");
- dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags);
break;
case ABS_EXPR:
/* n < 0 ? -n : n */
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
output_add_string (buffer, " < 0 ? -");
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
output_add_string (buffer, " : ");
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
break;
case FFS_EXPR:
@@ -933,29 +892,29 @@ dump_generic_node (buffer, node, spc, br
if (type != TREE_TYPE (op0))
{
output_add_character (buffer, '(');
- dump_generic_node (buffer, type, spc, brief_dump);
+ dump_generic_node (buffer, type, spc, flags);
output_add_string (buffer, ")");
}
if (op_prio (op0) < op_prio (node))
output_add_character (buffer, '(');
- dump_generic_node (buffer, op0, spc, brief_dump);
+ dump_generic_node (buffer, op0, spc, flags);
if (op_prio (op0) < op_prio (node))
output_add_character (buffer, ')');
break;
case NON_LVALUE_EXPR:
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
break;
case SAVE_EXPR:
output_add_string (buffer, "SAVE_EXPR <");
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
output_add_character (buffer, '>');
break;
case UNSAVE_EXPR:
output_add_string (buffer, "UNSAVE_EXPR <");
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
output_add_character (buffer, '>');
break;
@@ -969,30 +928,30 @@ dump_generic_node (buffer, node, spc, br
case COMPLEX_EXPR:
output_add_string (buffer, "__complex__ (");
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
output_add_string (buffer, ", ");
- dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags);
output_add_string (buffer, ")");
break;
case CONJ_EXPR:
output_add_string (buffer, "__builtin_conjf (");
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
break;
case REALPART_EXPR:
output_add_string (buffer, "__real__ ");
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
break;
case IMAGPART_EXPR:
output_add_string (buffer, "__imag__ ");
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
break;
case VA_ARG_EXPR:
output_add_string (buffer, "__builtin_va_arg (");
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
output_add_string (buffer, ")");
break;
@@ -1002,7 +961,7 @@ dump_generic_node (buffer, node, spc, br
newline_and_indent (buffer, spc+2);
output_add_string (buffer, "{");
newline_and_indent (buffer, spc+4);
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc+4, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc+4, flags);
newline_and_indent (buffer, spc+2);
output_add_string (buffer, "}");
newline_and_indent (buffer, spc);
@@ -1011,7 +970,7 @@ dump_generic_node (buffer, node, spc, br
newline_and_indent (buffer, spc+2);
output_add_string (buffer, "{");
newline_and_indent (buffer, spc+4);
- dump_generic_node (buffer, TREE_OPERAND (node, 1), spc+4, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 1), spc+4, flags);
newline_and_indent (buffer, spc+2);
output_add_string (buffer, "}");
break;
@@ -1030,7 +989,7 @@ dump_generic_node (buffer, node, spc, br
|| strcmp (name, "continue") == 0)
break;
}
- dump_generic_node (buffer, op0, spc, brief_dump);
+ dump_generic_node (buffer, op0, spc, flags);
output_add_character (buffer, ':');
output_add_character (buffer, ';');
break;
@@ -1044,16 +1003,16 @@ dump_generic_node (buffer, node, spc, br
if (strcmp (name, "break") == 0
|| strcmp (name, "continue") == 0)
{
- dump_generic_node (buffer, LABELED_BLOCK_BODY (node), spc, brief_dump);
+ dump_generic_node (buffer, LABELED_BLOCK_BODY (node), spc, flags);
break;
}
}
- dump_generic_node (buffer, LABELED_BLOCK_LABEL (node), spc, brief_dump);
+ dump_generic_node (buffer, LABELED_BLOCK_LABEL (node), spc, flags);
output_add_string (buffer, ": {");
- if (!brief_dump)
+ if (!(flags & PPF_BRIEF))
newline_and_indent (buffer, spc+2);
- dump_generic_node (buffer, LABELED_BLOCK_BODY (node), spc+2, brief_dump);
- if (!brief_dump)
+ dump_generic_node (buffer, LABELED_BLOCK_BODY (node), spc+2, flags);
+ if (!flags)
newline_and_indent (buffer, spc);
output_add_character (buffer, '}');
break;
@@ -1072,12 +1031,12 @@ dump_generic_node (buffer, node, spc, br
}
}
output_add_string (buffer, "<<<exit block ");
- dump_generic_node (buffer, op0, spc, brief_dump);
+ dump_generic_node (buffer, op0, spc, flags);
output_add_string (buffer, ">>>");
break;
case EXPR_WITH_FILE_LOCATION:
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
break;
case EXC_PTR_EXPR:
@@ -1086,14 +1045,25 @@ dump_generic_node (buffer, node, spc, br
case LOOP_EXPR:
output_add_string (buffer, "while (1)");
- if (!brief_dump)
+ if (!(flags & PPF_BRIEF))
{
newline_and_indent (buffer, spc+2);
output_add_character (buffer, '{');
newline_and_indent (buffer, spc+4);
- dump_generic_node (buffer, LOOP_EXPR_BODY (node), spc+4, brief_dump);
+ dump_generic_node (buffer, LOOP_EXPR_BODY (node), spc+4, flags);
newline_and_indent (buffer, spc+2);
output_add_character (buffer, '}');
+
+ /* FIXME. Hack. Latch blocks are empty blocks not associated
+ with any statement in the program. If we are dumping
+ flowgraph information, we should show them to avoid confusing
+ the user. This perhaps should be fixed by actually inserting
+ an empty statement at the end of LOOP_EXPRs. */
+ if ((flags & PPF_BLOCK) && bb_for_stmt (node))
+ {
+ newline_and_indent (buffer, spc);
+ dump_block_info (buffer, latch_block (bb_for_stmt (node)), spc);
+ }
}
break;
@@ -1104,29 +1074,29 @@ dump_generic_node (buffer, node, spc, br
{
output_add_space (buffer);
if (TREE_CODE (op0) == MODIFY_EXPR)
- dump_generic_node (buffer, TREE_OPERAND (op0, 1), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (op0, 1), spc, flags);
else
- dump_generic_node (buffer, op0, spc, brief_dump);
+ dump_generic_node (buffer, op0, spc, flags);
}
output_add_character (buffer, ';');
break;
case EXIT_EXPR:
output_add_string (buffer, "if (");
- dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, brief_dump);
+ dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags);
output_add_string (buffer, ") break;");
break;
case SWITCH_EXPR:
output_add_string (buffer, "switch (");
- dump_generic_node (buffer, SWITCH_COND (node), spc, brief_dump);
+ dump_generic_node (buffer, SWITCH_COND (node), spc, flags);
output_add_character (buffer, ')');
- if (!brief_dump)
+ if (!(flags & PPF_BRIEF))
{
newline_and_indent (buffer, spc+2);
output_add_character (buffer, '{');
newline_and_indent (buffer, spc+4);
- dump_generic_node (buffer, SWITCH_BODY (node), spc+4, brief_dump);
+ dump_generic_node (buffer, SWITCH_BODY (node), spc+4, flags);
newline_and_indent (buffer, spc+2);
output_add_character (buffer, '}');
}
@@ -1145,7 +1115,7 @@ dump_generic_node (buffer, node, spc, br
}
}
output_add_string (buffer, "goto ");
- dump_generic_node (buffer, op0, spc, brief_dump);
+ dump_generic_node (buffer, op0, spc, flags);
output_add_character (buffer, ';');
break;
@@ -1155,18 +1125,18 @@ dump_generic_node (buffer, node, spc, br
if (ASM_VOLATILE_P (node))
output_add_string (buffer, " __volatile__");
output_add_character (buffer, '(');
- dump_generic_node (buffer, ASM_STRING (node), spc, brief_dump);
+ dump_generic_node (buffer, ASM_STRING (node), spc, flags);
output_add_character (buffer, ':');
- dump_generic_node (buffer, ASM_OUTPUTS (node), spc, brief_dump);
+ dump_generic_node (buffer, ASM_OUTPUTS (node), spc, flags);
output_add_character (buffer, ':');
- dump_generic_node (buffer, ASM_INPUTS (node), spc, brief_dump);
+ dump_generic_node (buffer, ASM_INPUTS (node), spc, flags);
if (ASM_CLOBBERS (node))
{
output_add_character (buffer, ':');
- dump_generic_node (buffer, ASM_CLOBBERS (node), spc, brief_dump);
+ dump_generic_node (buffer, ASM_CLOBBERS (node), spc, flags);
}
output_add_string (buffer, ");");
- if (!brief_dump)
+ if (!(flags & PPF_BRIEF))
output_add_newline (buffer);
break;
@@ -1174,14 +1144,14 @@ dump_generic_node (buffer, node, spc, br
if (CASE_LOW (node) && CASE_HIGH (node))
{
output_add_string (buffer, "case ");
- dump_generic_node (buffer, CASE_LOW (node), spc, brief_dump);
+ dump_generic_node (buffer, CASE_LOW (node), spc, flags);
output_add_string (buffer, " ... ");
- dump_generic_node (buffer, CASE_HIGH (node), spc, brief_dump);
+ dump_generic_node (buffer, CASE_HIGH (node), spc, flags);
}
else if (CASE_LOW (node))
{
output_add_string (buffer, "case ");
- dump_generic_node (buffer, CASE_LOW (node), spc, brief_dump);
+ dump_generic_node (buffer, CASE_LOW (node), spc, flags);
}
else
output_add_string (buffer, "default ");
@@ -1197,11 +1167,11 @@ dump_generic_node (buffer, node, spc, br
/* Print the declaration of a variable. */
static void
-print_declaration (buffer, t, spc, brief_dump)
+print_declaration (buffer, t, spc, flags)
output_buffer *buffer;
tree t;
int spc;
- int brief_dump;
+ int flags;
{
/* Don't print type declarations. */
if (TREE_CODE (t) == TYPE_DECL)
@@ -1276,7 +1246,7 @@ print_declaration (buffer, t, spc, brief
}
output_add_character (buffer, ';');
- if (!brief_dump)
+ if (!(flags & PPF_BRIEF))
output_add_newline (buffer);
}
@@ -1767,5 +1737,43 @@ maybe_init_pretty_print ()
{
init_output_buffer (&buffer, /* prefix */NULL, /* line-width */0);
initialized = 1;
+ }
+}
+
+static void
+newline_and_indent (buffer, spc)
+ output_buffer *buffer;
+ int spc;
+{
+ output_add_newline (buffer);
+ INDENT (spc);
+}
+
+
+static void
+dump_block_info (buffer, bb, spc)
+ output_buffer *buffer;
+ basic_block bb;
+ int spc;
+{
+ if (bb && bb->index != last_bb)
+ {
+ edge e;
+
+ output_formatted_scalar (buffer, "# BLOCK %d", bb->index);
+
+ output_add_string (buffer, ". PRED:");
+ for (e = bb->pred; e; e = e->pred_next)
+ if (e->src)
+ output_formatted_scalar (buffer, " %d", e->src->index);
+
+ output_add_string (buffer, ". SUCC:");
+ for (e = bb->succ; e; e = e->succ_next)
+ if (e->dest)
+ output_formatted_scalar (buffer, " %d", e->dest->index);
+
+ output_add_character (buffer, '.');
+ newline_and_indent (buffer, spc);
+ last_bb = bb->index;
}
}
Index: tree-ssa-ccp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-ccp.c,v
retrieving revision 1.1.2.26
diff -d -u -p -r1.1.2.26 tree-ssa-ccp.c
--- tree-ssa-ccp.c 23 Oct 2002 00:36:00 -0000 1.1.2.26
+++ tree-ssa-ccp.c 26 Oct 2002 18:06:20 -0000
@@ -163,7 +163,7 @@ tree_ssa_ccp (fndecl)
optimize_unexecutable_edges (edges);
/* Now cleanup any unreachable code. */
- tree_cleanup_cfg ();
+ cleanup_tree_cfg ();
/* Now remove all unreachable insns and update the DF information.
as appropriate. */
@@ -177,7 +177,7 @@ tree_ssa_ccp (fndecl)
if (dump_flags & TDF_RAW)
dump_node (fnbody, TDF_SLIM | dump_flags, dump_file);
else
- print_generic_tree (dump_file, fnbody);
+ print_generic_tree (dump_file, fnbody, 0);
fprintf (dump_file, "\n");
dump_end (TDI_ccp, dump_file);
@@ -363,7 +363,7 @@ substitute_and_fold ()
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Line %d: replaced ", get_lineno (expr));
- print_generic_node (dump_file, expr);
+ print_generic_node (dump_file, expr, 0);
}
replace_uses_in (expr);
@@ -374,7 +374,7 @@ substitute_and_fold ()
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, " with ");
- print_generic_node (dump_file, new_expr);
+ print_generic_node (dump_file, new_expr, 0);
fprintf (dump_file, "\n");
}
}
@@ -544,7 +544,7 @@ visit_expression_for (ref)
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "\nVisiting expression: ");
- print_generic_node (dump_file, expr);
+ print_generic_node (dump_file, expr, 0);
dump_ref (dump_file, "\nfor reference: ", ref, 0, 0);
}
@@ -733,12 +733,12 @@ evaluate_expr (expr)
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Expression evaluates to ");
- print_generic_node (dump_file, expr);
+ print_generic_node (dump_file, expr, 0);
fprintf (dump_file, " which is ");
if (val.lattice_val == CONSTANT)
{
fprintf (dump_file, "constant ");
- print_generic_node (dump_file, simplified);
+ print_generic_node (dump_file, simplified, 0);
}
else if (val.lattice_val == VARYING)
fprintf (dump_file, "not a constant");
@@ -769,7 +769,7 @@ dump_lattice_value (outf, prefix, val)
else
{
fprintf (outf, "%sCONSTANT ", prefix);
- print_generic_node (outf, val.const_value);
+ print_generic_node (outf, val.const_value, 0);
}
}
@@ -981,7 +981,7 @@ set_lattice_value (def, val)
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Lattice value changed to ");
- print_generic_node (dump_file, val.const_value);
+ print_generic_node (dump_file, val.const_value, 0);
fprintf (dump_file, ". Adding definition to SSA edges.\n");
}
Index: tree-ssa-dce.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dce.c,v
retrieving revision 1.1.2.9
diff -d -u -p -r1.1.2.9 tree-ssa-dce.c
--- tree-ssa-dce.c 21 Oct 2002 18:35:04 -0000 1.1.2.9
+++ tree-ssa-dce.c 26 Oct 2002 18:06:20 -0000
@@ -96,7 +96,7 @@ mark_control_parent_necessary (bb)
if (bb == NULL)
return;
- for (i = gsi_start_bb (bb); !gsi_after_end (i); gsi_step (&i))
+ for (i = gsi_start_bb (bb); !gsi_after_end (i); gsi_step_bb (&i))
{
tree t = gsi_stmt (i);
mark_necessary (t);
@@ -152,7 +152,7 @@ tree_ssa_eliminate_dead_code (fndecl)
if (dump_flags & TDF_RAW)
dump_node (fnbody, TDF_SLIM | dump_flags, dump_file);
else
- print_generic_tree (dump_file, fnbody);
+ print_generic_tree (dump_file, fnbody, 0);
fprintf (dump_file, "Finding obviously useful instructions:\n");
}
@@ -166,7 +166,7 @@ tree_ssa_eliminate_dead_code (fndecl)
if (bb_empty_p (bb))
continue;
- for (i = gsi_start_bb (bb); !gsi_after_end (i); gsi_step (&i))
+ for (i = gsi_start_bb (bb); !gsi_after_end (i); gsi_step_bb (&i))
{
ref_list_iterator j;
t = gsi_stmt (i);
@@ -270,7 +270,7 @@ tree_ssa_eliminate_dead_code (fndecl)
continue;
prev = NULL_TREE;
- for (i = gsi_start_bb (bb); !gsi_after_end (i); gsi_step (&i))
+ for (i = gsi_start_bb (bb); !gsi_after_end (i); gsi_step_bb (&i))
{
t = gsi_stmt (i);
stats.total++;
@@ -282,12 +282,12 @@ tree_ssa_eliminate_dead_code (fndecl)
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Warning: removing ");
- print_generic_node (dump_file, t);
+ print_generic_node (dump_file, t, PPF_IS_STMT);
}
stats.removed++;
/* Unlink `i'. Head and tail are special cases. */
- /* FIXME: Call gsi_delete_stmt() */
+ /* FIXME: Call gsi_remove () */
#if 0
if (t == bb->head_tree)
bb->head_tree = TREE_CHAIN (t);
@@ -312,7 +312,7 @@ tree_ssa_eliminate_dead_code (fndecl)
if (dump_flags & TDF_RAW)
dump_node (fnbody, TDF_SLIM | dump_flags, dump_file);
else
- print_generic_tree (dump_file, fnbody);
+ print_generic_tree (dump_file, fnbody, 0);
print_stats ();
Index: tree-ssa-pre.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-pre.c,v
retrieving revision 1.1.4.29
diff -d -u -p -r1.1.4.29 tree-ssa-pre.c
--- tree-ssa-pre.c 21 Oct 2002 18:35:04 -0000 1.1.4.29
+++ tree-ssa-pre.c 26 Oct 2002 18:06:21 -0000
@@ -1490,11 +1490,12 @@ finalize_1 (ei, temp)
{
fprintf (dump_file, "In BB %d, insert save of ",
ref_bb (X)->index);
- print_generic_tree (dump_file, ei->expr);
+ print_generic_tree (dump_file, ei->expr, 0);
fprintf (dump_file, " to ");
- print_generic_tree (dump_file, temp);
+ print_generic_tree (dump_file, temp, 0);
fprintf (dump_file, " after ");
- print_generic_node (dump_file, last_stmt (ref_bb (X)));
+ print_generic_node (dump_file, last_stmt (ref_bb (X)),
+ PPF_IS_STMT);
fprintf (dump_file,
" (at end of BB), because of ExprPhi");
fprintf (dump_file, " in BB %d\n",
@@ -1952,7 +1953,7 @@ calculate_increment (ei, expr)
if (dump_file)
{
fprintf (dump_file, "Increment calculated to be: ");
- print_generic_tree (dump_file, incr);
+ print_generic_tree (dump_file, incr, 0);
fprintf (dump_file, "\n");
}
#endif
@@ -2021,7 +2022,7 @@ repair_injury (ei, use, temp, orig_euse)
if (dump_file)
{
fprintf (dump_file, "Injuring def to repair is: ");
- print_generic_tree (dump_file, ref_expr (v));
+ print_generic_tree (dump_file, ref_expr (v), 0);
fprintf (dump_file, "\n");
}
#endif
@@ -2388,11 +2389,11 @@ code_motion (ei, temp)
{
fprintf (dump_file, "In BB %d, insert save of ",
use_bb->index);
- print_generic_tree (dump_file, ei->expr);
+ print_generic_tree (dump_file, ei->expr, 0);
fprintf (dump_file, " to ");
- print_generic_tree (dump_file, temp);
+ print_generic_tree (dump_file, temp, 0);
fprintf (dump_file, " before statement ");
- print_generic_tree (dump_file,TREE_OPERAND (use_stmt, 0));
+ print_generic_tree (dump_file,TREE_OPERAND (use_stmt, 0), 0);
fprintf (dump_file, " on line %d\n",
EXPR_WFL_LINENO (use_expr));
}
@@ -2466,11 +2467,11 @@ code_motion (ei, temp)
{
fprintf (dump_file, "In BB %d, insert reload of ",
use_bb->index);
- print_generic_tree (dump_file, ei->expr);
+ print_generic_tree (dump_file, ei->expr, 0);
fprintf (dump_file, " from ");
- print_generic_tree (dump_file, temp);
+ print_generic_tree (dump_file, temp, 0);
fprintf (dump_file, " in statement ");
- print_generic_tree (dump_file, TREE_OPERAND (use_stmt, 0));
+ print_generic_tree (dump_file, TREE_OPERAND (use_stmt, 0), 0);
fprintf (dump_file, " on line %d\n",
EXPR_WFL_LINENO (use_stmt));
}
@@ -2647,7 +2648,7 @@ pre_part_1_trav (slot, data)
if (dump_file)
{
fprintf (dump_file, "Occurrences for expression ");
- print_generic_tree (dump_file, ei->expr);
+ print_generic_tree (dump_file, ei->expr, 0);
fprintf (dump_file, "\n");
dump_ref_array (dump_file, "", ei->refs, 0, 1);
}
@@ -2656,7 +2657,7 @@ pre_part_1_trav (slot, data)
if (dump_file)
{
fprintf (dump_file, "ExprPhi's for expression ");
- print_generic_tree (dump_file, ei->expr);
+ print_generic_tree (dump_file, ei->expr, 0);
fprintf (dump_file, "\n");
dump_ref_array (dump_file, "", ei->phis, 0, 1);
}
@@ -2864,7 +2865,7 @@ tree_perform_ssapre ()
if (dump_flags & TDF_RAW)
dump_node (fn, TDF_SLIM | dump_flags, dump_file);
else
- print_generic_tree (dump_file, fn);
+ print_generic_tree (dump_file, fn, 0);
dump_end (TDI_pre, dump_file);
}
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v
retrieving revision 1.1.4.25
diff -d -u -p -r1.1.4.25 tree-ssa.c
--- tree-ssa.c 21 Oct 2002 18:35:04 -0000 1.1.4.25
+++ tree-ssa.c 26 Oct 2002 18:06:21 -0000
@@ -66,7 +66,7 @@ Boston, MA 02111-1307, USA. */
(def-def link) between the current definition and the previous one.
This is used to chain definitions to arrays and structures, so that all
- possible reaching defs can be found later by tree_compute_rdefs. For
+ possible reaching defs can be found later by compute_tree_rdefs. For
instance,
1 A[i] = 5;
@@ -197,7 +197,7 @@ build_tree_ssa (fndecl)
fprintf (tree_ssa_dump_file, "\nFunction %s\n\n", get_name (fndecl));
/* Find variable references. */
- tree_find_refs ();
+ find_tree_refs ();
/* Compute immediate dominators. */
idom = calculate_dominance_info (CDI_DOMINATORS);
@@ -214,7 +214,7 @@ build_tree_ssa (fndecl)
free_dominance_info (idom);
/* Compute reaching definitions. */
- tree_compute_rdefs ();
+ compute_tree_rdefs ();
if (tree_ssa_dump_file)
{
@@ -423,7 +423,7 @@ search_fud_chains (bb, idom)
/* Restore the current reaching definition for each variable referenced
in the block (in reverse order). */
- for (i = rli_start_rev (bb_refs (bb)); !rli_after_end (i); rli_step_rev (&i))
+ for (i = rli_start_last (bb_refs (bb)); !rli_after_end (i); rli_step_rev (&i))
{
tree_ref ref = rli_ref (i);
@@ -449,7 +449,7 @@ search_fud_chains (bb, idom)
referenced in the current function. */
void
-tree_compute_rdefs ()
+compute_tree_rdefs ()
{
size_t i;
@@ -727,7 +727,7 @@ dump_tree_ssa (file)
FOR_EACH_BB (bb)
{
- tree_dump_bb (file, "", bb, 0);
+ dump_tree_bb (file, "", bb, 0);
dump_ref_list (file, " ", bb_refs (bb), 0, 1);
fputs ("\n\n", file);
}