Commit 80c7a9eb by Richard Henderson Committed by Richard Henderson

cfgexpand.c (expand_gimple_cond_expr, [...]): Split,

        * cfgexpand.c (expand_gimple_cond_expr, expand_gimple_tailcall): Split,
        (expand_gimple_basic_block): out from here.  Renamed from expand_block.

From-SVN: r84993
parent e08eb33c
2004-07-20 Richard Henderson <rth@redhat.com>
* cfgexpand.c (expand_gimple_cond_expr, expand_gimple_tailcall): Split,
(expand_gimple_basic_block): out from here. Renamed from expand_block.
2004-07-20 David S. Miller <davem@nuts.davemloft.net>
* config/sparc/sparc.c (sparc_rtx_costs case MULT): Emit
......
......@@ -35,77 +35,15 @@ Boston, MA 02111-1307, USA. */
#include "tree-pass.h"
#include "except.h"
#include "flags.h"
/* Expand basic block BB from GIMPLE trees to RTL. */
static basic_block
expand_block (basic_block bb, FILE * dump_file)
{
block_stmt_iterator bsi = bsi_start (bb);
tree stmt = NULL;
rtx note, last;
edge e;
if (dump_file)
{
tree_register_cfg_hooks ();
dump_bb (bb, dump_file, 0);
rtl_register_cfg_hooks ();
}
if (!bsi_end_p (bsi))
stmt = bsi_stmt (bsi);
if (stmt && TREE_CODE (stmt) == LABEL_EXPR)
{
last = get_last_insn ();
/* A subroutine of expand_gimple_basic_block. Expand one COND_EXPR.
Returns a new basic block if we've terminated the current basic
block and created a new one. */
expand_expr_stmt (stmt);
/* Java emits line number notes in the top of labels.
??? Make this go away once line number notes are obsoleted. */
BB_HEAD (bb) = NEXT_INSN (last);
if (NOTE_P (BB_HEAD (bb)))
BB_HEAD (bb) = NEXT_INSN (BB_HEAD (bb));
bsi_next (&bsi);
note = emit_note_after (NOTE_INSN_BASIC_BLOCK, BB_HEAD (bb));
}
else
note = BB_HEAD (bb) = emit_note (NOTE_INSN_BASIC_BLOCK);
NOTE_BASIC_BLOCK (note) = bb;
e = bb->succ;
while (e)
{
edge next = e->succ_next;
/* Clear EDGE_EXECUTABLE. This flag is never used in the backend. */
e->flags &= ~EDGE_EXECUTABLE;
/* At the moment not all abnormal edges match the RTL representation.
It is safe to remove them here as find_sub_basic_blocks will
rediscover them. In the future we should get this fixed properly. */
if (e->flags & EDGE_ABNORMAL)
remove_edge (e);
e = next;
}
for (; !bsi_end_p (bsi); bsi_next (&bsi))
{
tree stmt = bsi_stmt (bsi);
last = get_last_insn ();
if (!stmt)
continue;
/* Expand this statement, then evaluate the resulting RTL and
fixup the CFG accordingly. */
switch (TREE_CODE (stmt))
{
case COND_EXPR:
{
static basic_block
expand_gimple_cond_expr (basic_block bb, tree stmt)
{
basic_block new_bb, dest;
edge new_edge;
edge true_edge;
......@@ -113,7 +51,7 @@ expand_block (basic_block bb, FILE * dump_file)
tree pred = COND_EXPR_COND (stmt);
tree then_exp = COND_EXPR_THEN (stmt);
tree else_exp = COND_EXPR_ELSE (stmt);
rtx last = get_last_insn ();
rtx last;
extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
if (EXPR_LOCUS (stmt))
......@@ -126,23 +64,19 @@ expand_block (basic_block bb, FILE * dump_file)
true_edge->flags &= ~EDGE_TRUE_VALUE;
false_edge->flags &= ~EDGE_FALSE_VALUE;
/* We can either have a pure conditional jump with one fallthru
edge or two-way jump that needs to be decomposed into two
basic blocks. */
if (TREE_CODE (then_exp) == GOTO_EXPR
&& TREE_CODE (else_exp) == NOP_EXPR)
/* We can either have a pure conditional jump with one fallthru edge or
two-way jump that needs to be decomposed into two basic blocks. */
if (TREE_CODE (then_exp) == GOTO_EXPR && IS_EMPTY_STMT (else_exp))
{
jumpif (pred, label_rtx (GOTO_DESTINATION (then_exp)));
break;
return NULL;
}
if (TREE_CODE (else_exp) == GOTO_EXPR
&& TREE_CODE (then_exp) == NOP_EXPR)
if (TREE_CODE (else_exp) == GOTO_EXPR && IS_EMPTY_STMT (then_exp))
{
jumpifnot (pred, label_rtx (GOTO_DESTINATION (else_exp)));
break;
return NULL;
}
if (TREE_CODE (then_exp) != GOTO_EXPR
|| TREE_CODE (else_exp) != GOTO_EXPR)
if (TREE_CODE (then_exp) != GOTO_EXPR || TREE_CODE (else_exp) != GOTO_EXPR)
abort ();
jumpif (pred, label_rtx (GOTO_DESTINATION (then_exp)));
......@@ -172,14 +106,21 @@ expand_block (basic_block bb, FILE * dump_file)
dump_bb (bb, dump_file, 0);
dump_bb (new_bb, dump_file, 0);
}
return new_bb;
}
}
/* A subroutine of expand_gimple_basic_block. Expand one CALL_EXPR
that has CALL_EXPR_TAILCALL set. Returns a new basic block if we've
terminated the current basic block and created a new one. */
static basic_block
expand_gimple_tailcall (basic_block bb, tree stmt)
{
rtx last = get_last_insn ();
/* Update after expansion of sibling call. */
case CALL_EXPR:
case MODIFY_EXPR:
case RETURN_EXPR:
expand_expr_stmt (stmt);
for (last = NEXT_INSN (last); last; last = NEXT_INSN (last))
{
if (CALL_P (last) && SIBLING_CALL_P (last))
......@@ -213,9 +154,10 @@ expand_block (basic_block bb, FILE * dump_file)
e = next;
}
/* This is somewhat ugly: the call_expr expander often emits instructions
after the sibcall (to perform the function return). These confuse the
find_sub_basic_blocks code, so we need to get rid of these. */
/* This is somewhat ugly: the call_expr expander often emits
instructions after the sibcall (to perform the function
return). These confuse the find_sub_basic_blocks code,
so we need to get rid of these. */
last = NEXT_INSN (last);
if (!BARRIER_P (last))
abort ();
......@@ -227,8 +169,7 @@ expand_block (basic_block bb, FILE * dump_file)
break;
delete_insn (NEXT_INSN (last));
}
e = make_edge (bb, EXIT_BLOCK_PTR,
EDGE_ABNORMAL | EDGE_SIBCALL);
e = make_edge (bb, EXIT_BLOCK_PTR, EDGE_ABNORMAL | EDGE_SIBCALL);
e->probability += probability;
e->count += count;
BB_END (bb) = last;
......@@ -239,12 +180,89 @@ expand_block (basic_block bb, FILE * dump_file)
return bb;
}
}
break;
default:
return NULL;
}
/* Expand basic block BB from GIMPLE trees to RTL. */
static basic_block
expand_gimple_basic_block (basic_block bb, FILE * dump_file)
{
block_stmt_iterator bsi = bsi_start (bb);
tree stmt = NULL;
rtx note, last;
edge e;
if (dump_file)
{
tree_register_cfg_hooks ();
dump_bb (bb, dump_file, 0);
rtl_register_cfg_hooks ();
}
if (!bsi_end_p (bsi))
stmt = bsi_stmt (bsi);
if (stmt && TREE_CODE (stmt) == LABEL_EXPR)
{
last = get_last_insn ();
expand_expr_stmt (stmt);
break;
/* Java emits line number notes in the top of labels.
??? Make this go away once line number notes are obsoleted. */
BB_HEAD (bb) = NEXT_INSN (last);
if (NOTE_P (BB_HEAD (bb)))
BB_HEAD (bb) = NEXT_INSN (BB_HEAD (bb));
bsi_next (&bsi);
note = emit_note_after (NOTE_INSN_BASIC_BLOCK, BB_HEAD (bb));
}
else
note = BB_HEAD (bb) = emit_note (NOTE_INSN_BASIC_BLOCK);
NOTE_BASIC_BLOCK (note) = bb;
e = bb->succ;
while (e)
{
edge next = e->succ_next;
/* Clear EDGE_EXECUTABLE. This flag is never used in the backend. */
e->flags &= ~EDGE_EXECUTABLE;
/* At the moment not all abnormal edges match the RTL representation.
It is safe to remove them here as find_sub_basic_blocks will
rediscover them. In the future we should get this fixed properly. */
if (e->flags & EDGE_ABNORMAL)
remove_edge (e);
e = next;
}
for (; !bsi_end_p (bsi); bsi_next (&bsi))
{
tree stmt = bsi_stmt (bsi);
basic_block new_bb = NULL;
if (!stmt)
continue;
/* Expand this statement, then evaluate the resulting RTL and
fixup the CFG accordingly. */
if (TREE_CODE (stmt) == COND_EXPR)
new_bb = expand_gimple_cond_expr (bb, stmt);
else
{
tree call = get_call_expr_in (stmt);
if (call && CALL_EXPR_TAILCALL (call))
new_bb = expand_gimple_tailcall (bb, stmt);
else
expand_expr_stmt (stmt);
}
if (new_bb)
return new_bb;
}
do_pending_stack_adjust ();
......@@ -261,6 +279,7 @@ expand_block (basic_block bb, FILE * dump_file)
if (dump_file)
dump_bb (bb, dump_file, 0);
update_bb_for_insn (bb);
return bb;
}
......@@ -332,7 +351,8 @@ construct_exit_block (void)
return;
while (NEXT_INSN (head) && NOTE_P (NEXT_INSN (head)))
head = NEXT_INSN (head);
exit_block = create_basic_block (NEXT_INSN (head), end, EXIT_BLOCK_PTR->prev_bb);
exit_block = create_basic_block (NEXT_INSN (head), end,
EXIT_BLOCK_PTR->prev_bb);
exit_block->frequency = EXIT_BLOCK_PTR->frequency;
exit_block->count = EXIT_BLOCK_PTR->count;
for (e = EXIT_BLOCK_PTR->pred; e; e = next)
......@@ -408,7 +428,7 @@ tree_expand_cfg (void)
init_block = construct_init_block ();
FOR_BB_BETWEEN (bb, init_block->next_bb, EXIT_BLOCK_PTR, next_bb)
bb = expand_block (bb, dump_file);
bb = expand_gimple_basic_block (bb, dump_file);
construct_exit_block ();
......@@ -448,4 +468,3 @@ struct tree_opt_pass pass_expand =
0, /* todo_flags_start */
0 /* todo_flags_finish */
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment