Commit 9defb1fe by Diego Novillo

[multiple changes]

2008-05-16  Nathan Froyd  <froydnj@codesourcery.com>

	* tree-flow.h (init_empty_tree_cfg_for_function): Declare.
	* tree-cfg.c (init_empty_tree_cfg_for_function): Define.
	(init_empty_tree_cfg): Call it.

2008-05-16  Kenneth Zadeck <zadeck@naturalbridge.com>

	* cfg.c (init_flow): Add argument THE_FUN.  Use it
	instead of cfun.  Update all users.

From-SVN: r135418
parent 3e894af1
2008-05-16 Nathan Froyd <froydnj@codesourcery.com>
* tree-flow.h (init_empty_tree_cfg_for_function): Declare.
* tree-cfg.c (init_empty_tree_cfg_for_function): Define.
(init_empty_tree_cfg): Call it.
2008-05-16 Kenneth Zadeck <zadeck@naturalbridge.com>
* cfg.c (init_flow): Add argument THE_FUN. Use it
instead of cfun. Update all users.
2008-05-16 Kenneth Zadeck <zadeck@naturalbridge.com> 2008-05-16 Kenneth Zadeck <zadeck@naturalbridge.com>
* doc/invoke.text (-fdump-tree-*-verbose): New option. * doc/invoke.text (-fdump-tree-*-verbose): New option.
......
...@@ -414,9 +414,12 @@ struct control_flow_graph GTY(()) ...@@ -414,9 +414,12 @@ struct control_flow_graph GTY(())
#define n_edges_for_function(FN) ((FN)->cfg->x_n_edges) #define n_edges_for_function(FN) ((FN)->cfg->x_n_edges)
#define last_basic_block_for_function(FN) ((FN)->cfg->x_last_basic_block) #define last_basic_block_for_function(FN) ((FN)->cfg->x_last_basic_block)
#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 profile_status_for_function(FN) ((FN)->cfg->x_profile_status)
#define BASIC_BLOCK_FOR_FUNCTION(FN,N) \ #define BASIC_BLOCK_FOR_FUNCTION(FN,N) \
(VEC_index (basic_block, basic_block_info_for_function(FN), (N))) (VEC_index (basic_block, basic_block_info_for_function(FN), (N)))
#define SET_BASIC_BLOCK_FOR_FUNCTION(FN,N,BB) \
(VEC_replace (basic_block, basic_block_info_for_function(FN), (N), (BB)))
/* 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)
...@@ -839,7 +842,7 @@ extern bool br_prob_note_reliable_p (const_rtx); ...@@ -839,7 +842,7 @@ extern bool br_prob_note_reliable_p (const_rtx);
/* In cfg.c */ /* In cfg.c */
extern void dump_regset (regset, FILE *); extern void dump_regset (regset, FILE *);
extern void debug_regset (regset); extern void debug_regset (regset);
extern void init_flow (void); extern void init_flow (struct function *);
extern void debug_bb (basic_block); extern void debug_bb (basic_block);
extern basic_block debug_bb_n (int); extern basic_block debug_bb_n (int);
extern void dump_regset (regset, FILE *); extern void dump_regset (regset, FILE *);
......
...@@ -81,17 +81,21 @@ static void free_edge (edge); ...@@ -81,17 +81,21 @@ static void free_edge (edge);
/* Called once at initialization time. */ /* Called once at initialization time. */
void void
init_flow (void) init_flow (struct function *the_fun)
{ {
if (!cfun->cfg) if (!the_fun->cfg)
cfun->cfg = GGC_CNEW (struct control_flow_graph); the_fun->cfg = GGC_CNEW (struct control_flow_graph);
n_edges = 0; n_edges_for_function (the_fun) = 0;
ENTRY_BLOCK_PTR = GGC_CNEW (struct basic_block_def); ENTRY_BLOCK_PTR_FOR_FUNCTION (the_fun)
ENTRY_BLOCK_PTR->index = ENTRY_BLOCK; = GGC_CNEW (struct basic_block_def);
EXIT_BLOCK_PTR = GGC_CNEW (struct basic_block_def); ENTRY_BLOCK_PTR_FOR_FUNCTION (the_fun)->index = ENTRY_BLOCK;
EXIT_BLOCK_PTR->index = EXIT_BLOCK; EXIT_BLOCK_PTR_FOR_FUNCTION (the_fun)
ENTRY_BLOCK_PTR->next_bb = EXIT_BLOCK_PTR; = GGC_CNEW (struct basic_block_def);
EXIT_BLOCK_PTR->prev_bb = ENTRY_BLOCK_PTR; EXIT_BLOCK_PTR_FOR_FUNCTION (the_fun)->index = EXIT_BLOCK;
ENTRY_BLOCK_PTR_FOR_FUNCTION (the_fun)->next_bb
= EXIT_BLOCK_PTR_FOR_FUNCTION (the_fun);
EXIT_BLOCK_PTR_FOR_FUNCTION (the_fun)->prev_bb
= ENTRY_BLOCK_PTR_FOR_FUNCTION (the_fun);
} }
/* Helper function for remove_edge and clear_edges. Frees edge structure /* Helper function for remove_edge and clear_edges. Frees edge structure
......
...@@ -114,26 +114,41 @@ static edge find_taken_edge_switch_expr (basic_block, tree); ...@@ -114,26 +114,41 @@ static edge find_taken_edge_switch_expr (basic_block, tree);
static tree find_case_label_for_value (tree, tree); static tree find_case_label_for_value (tree, tree);
void void
init_empty_tree_cfg (void) init_empty_tree_cfg_for_function (struct function *fn)
{ {
/* Initialize the basic block array. */ /* Initialize the basic block array. */
init_flow (); init_flow (fn);
profile_status = PROFILE_ABSENT; profile_status_for_function (fn) = PROFILE_ABSENT;
n_basic_blocks = NUM_FIXED_BLOCKS; n_basic_blocks_for_function (fn) = NUM_FIXED_BLOCKS;
last_basic_block = NUM_FIXED_BLOCKS; last_basic_block_for_function (fn) = NUM_FIXED_BLOCKS;
basic_block_info = VEC_alloc (basic_block, gc, initial_cfg_capacity); basic_block_info_for_function (fn)
VEC_safe_grow_cleared (basic_block, gc, basic_block_info, = VEC_alloc (basic_block, gc, initial_cfg_capacity);
VEC_safe_grow_cleared (basic_block, gc,
basic_block_info_for_function (fn),
initial_cfg_capacity); 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_for_function (fn)
VEC_safe_grow_cleared (basic_block, gc, label_to_block_map, = VEC_alloc (basic_block, gc, initial_cfg_capacity);
VEC_safe_grow_cleared (basic_block, gc,
label_to_block_map_for_function (fn),
initial_cfg_capacity); initial_cfg_capacity);
SET_BASIC_BLOCK (ENTRY_BLOCK, ENTRY_BLOCK_PTR); SET_BASIC_BLOCK_FOR_FUNCTION (fn, ENTRY_BLOCK,
SET_BASIC_BLOCK (EXIT_BLOCK, EXIT_BLOCK_PTR); ENTRY_BLOCK_PTR_FOR_FUNCTION (fn));
ENTRY_BLOCK_PTR->next_bb = EXIT_BLOCK_PTR; SET_BASIC_BLOCK_FOR_FUNCTION (fn, EXIT_BLOCK,
EXIT_BLOCK_PTR->prev_bb = ENTRY_BLOCK_PTR; EXIT_BLOCK_PTR_FOR_FUNCTION (fn));
ENTRY_BLOCK_PTR_FOR_FUNCTION (fn)->next_bb
= EXIT_BLOCK_PTR_FOR_FUNCTION (fn);
EXIT_BLOCK_PTR_FOR_FUNCTION (fn)->prev_bb
= ENTRY_BLOCK_PTR_FOR_FUNCTION (fn);
}
void
init_empty_tree_cfg (void)
{
init_empty_tree_cfg_for_function (cfun);
} }
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
......
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