Commit 68f9b844 by Kazu Hirata Committed by Kazu Hirata

basic-block.h (control_flow_graph): Change the type of x_basic_block_info to VEC(basic_block,gc) *.

	* basic-block.h (control_flow_graph): Change the type of
	x_basic_block_info to VEC(basic_block,gc) *.
	(BASIC_BLOCK_FOR_FUNCTION, BASIC_BLOCK): Adjust the uses of
	basic_block_info.
	(SET_BASIC_BLOCK): New.
	* cfg.c (compact_blocks, expunge_block): Use SET_BASIC_BLOCK
	instead of BASIC_BLOCK when assigning to BASIC_BLOCK.
	* cfgbuild.c (find_basic_blocks): Likewise.
	* cfglayout.c (fixup_reorder_chain): Likewise.
	* cfgrtl.c (create_basic_block_structure,
	rtl_create_basic_block): Likewise.
	* ifcvt.c (find_if_case_1): Likewise.
	* tree-cfg.c (init_empty_tree_cfg, build_tree_cfg, create_bb):
	Likewise.

From-SVN: r109596
parent 043c2d9e
2006-01-11 Kazu Hirata <kazu@codesourcery.com>
* basic-block.h (control_flow_graph): Change the type of
x_basic_block_info to VEC(basic_block,gc) *.
(BASIC_BLOCK_FOR_FUNCTION, BASIC_BLOCK): Adjust the uses of
basic_block_info.
(SET_BASIC_BLOCK): New.
* cfg.c (compact_blocks, expunge_block): Use SET_BASIC_BLOCK
instead of BASIC_BLOCK when assigning to BASIC_BLOCK.
* cfgbuild.c (find_basic_blocks): Likewise.
* cfglayout.c (fixup_reorder_chain): Likewise.
* cfgrtl.c (create_basic_block_structure,
rtl_create_basic_block): Likewise.
* ifcvt.c (find_if_case_1): Likewise.
* tree-cfg.c (init_empty_tree_cfg, build_tree_cfg, create_bb):
Likewise.
2005-01-11 Kenneth Zadeck <zadeck@naturalbridge.com> 2005-01-11 Kenneth Zadeck <zadeck@naturalbridge.com>
* Makefile.in Removed rotted odf.c entry. * Makefile.in Removed rotted odf.c entry.
......
...@@ -367,7 +367,7 @@ struct control_flow_graph GTY(()) ...@@ -367,7 +367,7 @@ struct control_flow_graph GTY(())
basic_block x_exit_block_ptr; basic_block x_exit_block_ptr;
/* Index by basic block number, get basic block struct info. */ /* Index by basic block number, get basic block struct info. */
varray_type x_basic_block_info; VEC(basic_block,gc) *x_basic_block_info;
/* Number of basic blocks in this flow graph. */ /* Number of basic blocks in this flow graph. */
int x_n_basic_blocks; int x_n_basic_blocks;
...@@ -399,7 +399,7 @@ struct control_flow_graph GTY(()) ...@@ -399,7 +399,7 @@ struct control_flow_graph GTY(())
#define label_to_block_map_for_function(FN) ((FN)->cfg->x_label_to_block_map) #define label_to_block_map_for_function(FN) ((FN)->cfg->x_label_to_block_map)
#define BASIC_BLOCK_FOR_FUNCTION(FN,N) \ #define BASIC_BLOCK_FOR_FUNCTION(FN,N) \
(VARRAY_BB (basic_block_info_for_function(FN), (N))) (VEC_index (basic_block, basic_block_info_for_function(FN), (N)))
/* Defines for textual backward source compatibility. */ /* Defines for textual backward source compatibility. */
#define ENTRY_BLOCK_PTR (cfun->cfg->x_entry_block_ptr) #define ENTRY_BLOCK_PTR (cfun->cfg->x_entry_block_ptr)
...@@ -411,7 +411,8 @@ struct control_flow_graph GTY(()) ...@@ -411,7 +411,8 @@ struct control_flow_graph GTY(())
#define label_to_block_map (cfun->cfg->x_label_to_block_map) #define label_to_block_map (cfun->cfg->x_label_to_block_map)
#define profile_status (cfun->cfg->x_profile_status) #define profile_status (cfun->cfg->x_profile_status)
#define BASIC_BLOCK(N) (VARRAY_BB (basic_block_info, (N))) #define BASIC_BLOCK(N) (VEC_index (basic_block, basic_block_info, (N)))
#define SET_BASIC_BLOCK(N,BB) (VEC_replace (basic_block, basic_block_info, (N), (BB)))
/* TRUE if we should re-run loop discovery after threading jumps, FALSE /* TRUE if we should re-run loop discovery after threading jumps, FALSE
otherwise. */ otherwise. */
......
...@@ -163,13 +163,13 @@ compact_blocks (void) ...@@ -163,13 +163,13 @@ compact_blocks (void)
int i; int i;
basic_block bb; basic_block bb;
BASIC_BLOCK (ENTRY_BLOCK) = ENTRY_BLOCK_PTR; SET_BASIC_BLOCK (ENTRY_BLOCK, ENTRY_BLOCK_PTR);
BASIC_BLOCK (EXIT_BLOCK) = EXIT_BLOCK_PTR; SET_BASIC_BLOCK (EXIT_BLOCK, EXIT_BLOCK_PTR);
i = NUM_FIXED_BLOCKS; i = NUM_FIXED_BLOCKS;
FOR_EACH_BB (bb) FOR_EACH_BB (bb)
{ {
BASIC_BLOCK (i) = bb; SET_BASIC_BLOCK (i, bb);
bb->index = i; bb->index = i;
i++; i++;
} }
...@@ -177,7 +177,7 @@ compact_blocks (void) ...@@ -177,7 +177,7 @@ compact_blocks (void)
gcc_assert (i == n_basic_blocks); gcc_assert (i == n_basic_blocks);
for (; i < last_basic_block; i++) for (; i < last_basic_block; i++)
BASIC_BLOCK (i) = NULL; SET_BASIC_BLOCK (i, NULL);
last_basic_block = n_basic_blocks; last_basic_block = n_basic_blocks;
} }
...@@ -188,7 +188,7 @@ void ...@@ -188,7 +188,7 @@ void
expunge_block (basic_block b) expunge_block (basic_block b)
{ {
unlink_block (b); unlink_block (b);
BASIC_BLOCK (b->index) = NULL; SET_BASIC_BLOCK (b->index, NULL);
n_basic_blocks--; n_basic_blocks--;
/* We should be able to ggc_free here, but we are not. /* We should be able to ggc_free here, but we are not.
The dead SSA_NAMES are left pointing to dead statements that are pointing The dead SSA_NAMES are left pointing to dead statements that are pointing
......
...@@ -542,9 +542,12 @@ find_basic_blocks (rtx f) ...@@ -542,9 +542,12 @@ find_basic_blocks (rtx f)
instructions at all until close to the end of compilation when we instructions at all until close to the end of compilation when we
actually lay them out. */ actually lay them out. */
VARRAY_BB_INIT (basic_block_info, n_basic_blocks, "basic_block_info"); basic_block_info = VEC_alloc (basic_block, gc, n_basic_blocks);
BASIC_BLOCK (ENTRY_BLOCK) = ENTRY_BLOCK_PTR; VEC_safe_grow (basic_block, gc, basic_block_info, n_basic_blocks);
BASIC_BLOCK (EXIT_BLOCK) = EXIT_BLOCK_PTR; memset (VEC_address (basic_block, basic_block_info), 0,
sizeof (basic_block) * n_basic_blocks);
SET_BASIC_BLOCK (ENTRY_BLOCK, ENTRY_BLOCK_PTR);
SET_BASIC_BLOCK (EXIT_BLOCK, EXIT_BLOCK_PTR);
find_basic_blocks_1 (f); find_basic_blocks_1 (f);
......
...@@ -814,7 +814,7 @@ fixup_reorder_chain (void) ...@@ -814,7 +814,7 @@ fixup_reorder_chain (void)
for (; bb; prev_bb = bb, bb = bb->aux, index ++) for (; bb; prev_bb = bb, bb = bb->aux, index ++)
{ {
bb->index = index; bb->index = index;
BASIC_BLOCK (index) = bb; SET_BASIC_BLOCK (index, bb);
bb->prev_bb = prev_bb; bb->prev_bb = prev_bb;
prev_bb->next_bb = bb; prev_bb->next_bb = bb;
......
...@@ -305,7 +305,7 @@ create_basic_block_structure (rtx head, rtx end, rtx bb_note, basic_block after) ...@@ -305,7 +305,7 @@ create_basic_block_structure (rtx head, rtx end, rtx bb_note, basic_block after)
bb->index = last_basic_block++; bb->index = last_basic_block++;
bb->flags = BB_NEW | BB_RTL; bb->flags = BB_NEW | BB_RTL;
link_block (bb, after); link_block (bb, after);
BASIC_BLOCK (bb->index) = bb; SET_BASIC_BLOCK (bb->index, bb);
update_bb_for_insn (bb); update_bb_for_insn (bb);
BB_SET_PARTITION (bb, BB_UNPARTITIONED); BB_SET_PARTITION (bb, BB_UNPARTITIONED);
...@@ -328,10 +328,14 @@ rtl_create_basic_block (void *headp, void *endp, basic_block after) ...@@ -328,10 +328,14 @@ rtl_create_basic_block (void *headp, void *endp, basic_block after)
basic_block bb; basic_block bb;
/* Grow the basic block array if needed. */ /* Grow the basic block array if needed. */
if ((size_t) last_basic_block >= VARRAY_SIZE (basic_block_info)) if ((size_t) last_basic_block >= VEC_length (basic_block, basic_block_info))
{ {
size_t old_size = VEC_length (basic_block, basic_block_info);
size_t new_size = last_basic_block + (last_basic_block + 3) / 4; size_t new_size = last_basic_block + (last_basic_block + 3) / 4;
VARRAY_GROW (basic_block_info, new_size); basic_block *p;
VEC_safe_grow (basic_block, gc, basic_block_info, new_size);
p = VEC_address (basic_block, basic_block_info);
memset (&p[old_size], 0, sizeof (basic_block) * (new_size - old_size));
} }
n_basic_blocks++; n_basic_blocks++;
......
...@@ -3135,7 +3135,7 @@ find_if_case_1 (basic_block test_bb, edge then_edge, edge else_edge) ...@@ -3135,7 +3135,7 @@ find_if_case_1 (basic_block test_bb, edge then_edge, edge else_edge)
if (new_bb) if (new_bb)
{ {
new_bb->index = then_bb_index; new_bb->index = then_bb_index;
BASIC_BLOCK (then_bb_index) = new_bb; SET_BASIC_BLOCK (then_bb_index, new_bb);
/* Since the fallthru edge was redirected from test_bb to new_bb, /* Since the fallthru edge was redirected from test_bb to new_bb,
we need to ensure that new_bb is in the same partition as we need to ensure that new_bb is in the same partition as
test bb (you can not fall through across section boundaries). */ test bb (you can not fall through across section boundaries). */
......
...@@ -131,7 +131,10 @@ init_empty_tree_cfg (void) ...@@ -131,7 +131,10 @@ init_empty_tree_cfg (void)
profile_status = PROFILE_ABSENT; profile_status = PROFILE_ABSENT;
n_basic_blocks = NUM_FIXED_BLOCKS; n_basic_blocks = NUM_FIXED_BLOCKS;
last_basic_block = NUM_FIXED_BLOCKS; last_basic_block = NUM_FIXED_BLOCKS;
VARRAY_BB_INIT (basic_block_info, initial_cfg_capacity, "basic_block_info"); basic_block_info = VEC_alloc (basic_block, gc, initial_cfg_capacity);
VEC_safe_grow (basic_block, gc, basic_block_info, initial_cfg_capacity);
memset (VEC_address (basic_block, basic_block_info), 0,
sizeof (basic_block) * initial_cfg_capacity);
/* Build a mapping of labels to their associated blocks. */ /* Build a mapping of labels to their associated blocks. */
label_to_block_map = VEC_alloc (basic_block, gc, initial_cfg_capacity); label_to_block_map = VEC_alloc (basic_block, gc, initial_cfg_capacity);
...@@ -139,8 +142,8 @@ init_empty_tree_cfg (void) ...@@ -139,8 +142,8 @@ init_empty_tree_cfg (void)
memset (VEC_address (basic_block, label_to_block_map), memset (VEC_address (basic_block, label_to_block_map),
0, sizeof (basic_block) * initial_cfg_capacity); 0, sizeof (basic_block) * initial_cfg_capacity);
BASIC_BLOCK (ENTRY_BLOCK) = ENTRY_BLOCK_PTR; SET_BASIC_BLOCK (ENTRY_BLOCK, ENTRY_BLOCK_PTR);
BASIC_BLOCK (EXIT_BLOCK) = EXIT_BLOCK_PTR; SET_BASIC_BLOCK (EXIT_BLOCK, EXIT_BLOCK_PTR);
ENTRY_BLOCK_PTR->next_bb = EXIT_BLOCK_PTR; ENTRY_BLOCK_PTR->next_bb = EXIT_BLOCK_PTR;
EXIT_BLOCK_PTR->prev_bb = ENTRY_BLOCK_PTR; EXIT_BLOCK_PTR->prev_bb = ENTRY_BLOCK_PTR;
} }
...@@ -178,7 +181,15 @@ build_tree_cfg (tree *tp) ...@@ -178,7 +181,15 @@ build_tree_cfg (tree *tp)
create_empty_bb (ENTRY_BLOCK_PTR); create_empty_bb (ENTRY_BLOCK_PTR);
/* Adjust the size of the array. */ /* Adjust the size of the array. */
VARRAY_GROW (basic_block_info, n_basic_blocks); if (VEC_length (basic_block, basic_block_info) < (size_t) n_basic_blocks)
{
size_t old_size = VEC_length (basic_block, basic_block_info);
basic_block *p;
VEC_safe_grow (basic_block, gc, basic_block_info, n_basic_blocks);
p = VEC_address (basic_block, basic_block_info);
memset (&p[old_size], 0,
sizeof (basic_block) * (n_basic_blocks - old_size));
}
/* To speed up statement iterator walks, we first purge dead labels. */ /* To speed up statement iterator walks, we first purge dead labels. */
cleanup_dead_labels (); cleanup_dead_labels ();
...@@ -382,14 +393,18 @@ create_bb (void *h, void *e, basic_block after) ...@@ -382,14 +393,18 @@ create_bb (void *h, void *e, basic_block after)
link_block (bb, after); link_block (bb, after);
/* Grow the basic block array if needed. */ /* Grow the basic block array if needed. */
if ((size_t) last_basic_block == VARRAY_SIZE (basic_block_info)) if ((size_t) last_basic_block == VEC_length (basic_block, basic_block_info))
{ {
size_t old_size = VEC_length (basic_block, basic_block_info);
size_t new_size = last_basic_block + (last_basic_block + 3) / 4; size_t new_size = last_basic_block + (last_basic_block + 3) / 4;
VARRAY_GROW (basic_block_info, new_size); basic_block *p;
VEC_safe_grow (basic_block, gc, basic_block_info, new_size);
p = VEC_address (basic_block, basic_block_info);
memset (&p[old_size], 0, sizeof (basic_block) * (new_size - old_size));
} }
/* Add the newly created block to the array. */ /* Add the newly created block to the array. */
BASIC_BLOCK (last_basic_block) = bb; SET_BASIC_BLOCK (last_basic_block, bb);
n_basic_blocks++; n_basic_blocks++;
last_basic_block++; last_basic_block++;
......
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