Commit 789a7c70 authored by Matthias Braun's avatar Matthias Braun
Browse files

perform end/first block mature in libfirm

The first block in a new ir_graph is not an immature block anymore. The
end block is matured in irg_finalize_cons() now (since maturing blocks
twice doesn't hurt this shouldn't break existing code).
parent 6bb28287
......@@ -314,6 +314,7 @@ void mature_immBlock(ir_node *block)
size_t n_preds;
ir_node *next;
ir_node *phi;
ir_node **new_in;
ir_graph *irg;
assert(is_Block(block));
......@@ -340,6 +341,15 @@ void mature_immBlock(ir_node *block)
set_Block_matured(block, 1);
/* create final in-array for the block */
if (block->attr.block.dynamic_ins) {
new_in = NEW_ARR_D(ir_node*, irg->obst, n_preds+1);
memcpy(new_in, block->in, (n_preds+1) * sizeof(new_in[0]));
DEL_ARR_F(block->in);
block->in = new_in;
block->attr.block.dynamic_ins = false;
}
/* Now, as the block is a finished Firm node, we can optimize it.
Since other nodes have been allocated since the block was created
we can not free the node on the obstack. Therefore we have to call
......@@ -462,6 +472,7 @@ ir_node *new_rd_immBlock(dbg_info *dbgi, ir_graph *irg)
res = new_ir_node(dbgi, irg, NULL, op_Block, mode_BB, -1, NULL);
set_Block_matured(res, 0);
res->attr.block.dynamic_ins = true;
res->attr.block.irg.irg = irg;
res->attr.block.backedge = NULL;
res->attr.block.in_cg = NULL;
......@@ -699,6 +710,9 @@ void ir_set_uninitialized_local_variable_func(
void irg_finalize_cons(ir_graph *irg)
{
ir_node *end_block = get_irg_end_block(irg);
mature_immBlock(end_block);
set_irg_phase_state(irg, phase_high);
}
......
......@@ -187,7 +187,7 @@ ir_graph *new_r_ir_graph(ir_entity *ent, int n_loc)
res->anchor = new_r_Anchor(res);
/*-- Nodes needed in every graph --*/
set_irg_end_block (res, new_r_immBlock(res));
set_irg_end_block(res, new_r_immBlock(res));
set_irg_end(res, new_r_End(res, 0, NULL));
start_block = new_r_Block_noopt(res, 0, NULL);
......@@ -213,9 +213,8 @@ ir_graph *new_r_ir_graph(ir_entity *ent, int n_loc)
set_r_store(res, initial_mem);
/*-- Make a block to start with --*/
first_block = new_r_immBlock(res);
first_block = new_r_Block(res, 1, &projX);
set_r_cur_block(res, first_block);
add_immBlock_pred(first_block, projX);
res->method_execution_frequency = -1.0;
res->estimated_node_count = 0;
......
......@@ -2286,6 +2286,7 @@ static ir_graph *read_irg(read_env_t *env)
ir_type *frame = read_type_ref(env);
irg_inline_property prop = read_inline_property(env);
unsigned props = read_unsigned(env);
irg_finalize_cons(irg);
set_irg_frame_type(irg, frame);
set_irg_inline_property(irg, prop);
set_irg_additional_properties(irg, (mtp_additional_properties)props);
......
......@@ -41,10 +41,10 @@ static void prepare_blocks(ir_node *block, void *env)
{
unsigned n_loc = current_ir_graph->n_loc;
struct obstack *obst = current_ir_graph->obst;
(void)env;
(void)env;
/* reset mature flag */
set_Block_matured(block, 0);
block->attr.block.graph_arr = NEW_ARR_D(ir_node *, obst, n_loc);
block->attr.block.graph_arr = NEW_ARR_D(ir_node *, obst, n_loc);
memset(block->attr.block.graph_arr, 0, sizeof(ir_node*) * n_loc);
set_Block_phis(block, NULL);
}
......
......@@ -201,6 +201,7 @@ typedef struct block_attr {
ir_visited_t block_visited; /**< For the walker that walks over all blocks. */
/* Attributes private to construction: */
unsigned is_matured:1; /**< If set, all in-nodes of the block are fixed. */
unsigned dynamic_ins:1; /**< if set in-array is an ARR_F on the heap. */
unsigned marked:1; /**< Can be set/unset to temporary mark a block. */
ir_node **graph_arr; /**< An array to store all parameters. */
/* Attributes holding analyses information */
......
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