Commit eab02feb by Michael Hayes Committed by Michael Hayes

flow.c (flow_loop_scan): Break out of ...

	* flow.c (flow_loop_scan): Break out of ...
	(flow_loops_find) ... here.
	* basic-block.h (flow_loop_scan): New.
	(LOOP_ENTRY_EDGES, LOOP_EXIT_EDGES): Add.
	(LOOP_EDGES, LOOP_EXITS_DOMS, LOOP_ALL): Redefine.

From-SVN: r38822
parent 4b49c365
2001-01-09 Michael Hayes <mhayes@redhat.com>
* flow.c (flow_loop_scan): Break out of ...
(flow_loops_find) ... here.
* basic-block.h (flow_loop_scan): New.
(LOOP_ENTRY_EDGES, LOOP_EXIT_EDGES): Add.
(LOOP_EDGES, LOOP_EXITS_DOMS, LOOP_ALL): Redefine.
2001-01-09 Alexandre Oliva <aoliva@redhat.com> 2001-01-09 Alexandre Oliva <aoliva@redhat.com>
* cppinit.c (cpp_cleanup): NULLify macro_buffer and zero * cppinit.c (cpp_cleanup): NULLify macro_buffer and zero
......
...@@ -428,6 +428,7 @@ extern void flow_loops_dump PARAMS ((const struct loops *, FILE *, ...@@ -428,6 +428,7 @@ extern void flow_loops_dump PARAMS ((const struct loops *, FILE *,
extern void flow_loop_dump PARAMS ((const struct loop *, FILE *, extern void flow_loop_dump PARAMS ((const struct loop *, FILE *,
void (*)(const struct loop *, void (*)(const struct loop *,
FILE *, int), int)); FILE *, int), int));
extern int flow_loop_scan PARAMS ((struct loops *, struct loop *, int));
/* This structure maintains an edge list vector. */ /* This structure maintains an edge list vector. */
struct edge_list struct edge_list
...@@ -485,9 +486,11 @@ enum update_life_extent ...@@ -485,9 +486,11 @@ enum update_life_extent
#define LOOP_TREE 1 /* Build loop hierarchy tree. */ #define LOOP_TREE 1 /* Build loop hierarchy tree. */
#define LOOP_PRE_HEADER 2 /* Analyse loop pre-header. */ #define LOOP_PRE_HEADER 2 /* Analyse loop pre-header. */
#define LOOP_EDGES 4 /* Find entry and exit edges. */ #define LOOP_ENTRY_EDGES 4 /* Find entry edges. */
#define LOOP_EXITS_DOMS 8 /* Find nodes that dom. all exits. */ #define LOOP_EXIT_EDGES 8 /* Find exit edges. */
#define LOOP_ALL 15 /* All of the above */ #define LOOP_EDGES (LOOP_ENTRY_EDGES | LOOP_EXIT_EDGES)
#define LOOP_EXITS_DOMS 16 /* Find nodes that dom. all exits. */
#define LOOP_ALL 31 /* All of the above */
extern void life_analysis PARAMS ((rtx, FILE *, int)); extern void life_analysis PARAMS ((rtx, FILE *, int));
extern void update_life_info PARAMS ((sbitmap, enum update_life_extent, extern void update_life_info PARAMS ((sbitmap, enum update_life_extent,
......
...@@ -8137,6 +8137,70 @@ flow_loops_level_compute (loops) ...@@ -8137,6 +8137,70 @@ flow_loops_level_compute (loops)
} }
/* Scan a single natural loop specified by LOOP collecting information
about it specified by FLAGS. */
int
flow_loop_scan (loops, loop, flags)
struct loops *loops;
struct loop *loop;
int flags;
{
/* Determine prerequisites. */
if ((flags & LOOP_EXITS_DOMS) && ! loop->exit_edges)
flags |= LOOP_EXIT_EDGES;
if (flags & LOOP_ENTRY_EDGES)
{
/* Find edges which enter the loop header.
Note that the entry edges should only
enter the header of a natural loop. */
loop->num_entries
= flow_loop_entry_edges_find (loop->header,
loop->nodes,
&loop->entry_edges);
}
if (flags & LOOP_EXIT_EDGES)
{
/* Find edges which exit the loop. */
loop->num_exits
= flow_loop_exit_edges_find (loop->nodes,
&loop->exit_edges);
}
if (flags & LOOP_EXITS_DOMS)
{
int j;
/* Determine which loop nodes dominate all the exits
of the loop. */
loop->exits_doms = sbitmap_alloc (n_basic_blocks);
sbitmap_copy (loop->exits_doms, loop->nodes);
for (j = 0; j < loop->num_exits; j++)
sbitmap_a_and_b (loop->exits_doms, loop->exits_doms,
loops->cfg.dom[loop->exit_edges[j]->src->index]);
/* The header of a natural loop must dominate
all exits. */
if (! TEST_BIT (loop->exits_doms, loop->header->index))
abort ();
}
if (flags & LOOP_PRE_HEADER)
{
/* Look to see if the loop has a pre-header node. */
loop->pre_header
= flow_loop_pre_header_find (loop->header, loops->cfg.dom);
/* Find the blocks within the extended basic block of
the loop pre-header. */
flow_loop_pre_header_scan (loop);
}
return 1;
}
/* Find all the natural loops in the function and save in LOOPS structure /* Find all the natural loops in the function and save in LOOPS structure
and recalculate loop_depth information in basic block structures. and recalculate loop_depth information in basic block structures.
FLAGS controls which loop information is collected. FLAGS controls which loop information is collected.
...@@ -8213,6 +8277,11 @@ flow_loops_find (loops, flags) ...@@ -8213,6 +8277,11 @@ flow_loops_find (loops, flags)
rc_order = (int *) xmalloc (n_basic_blocks * sizeof (int)); rc_order = (int *) xmalloc (n_basic_blocks * sizeof (int));
flow_depth_first_order_compute (dfs_order, rc_order); flow_depth_first_order_compute (dfs_order, rc_order);
/* Save CFG derived information to avoid recomputing it. */
loops->cfg.dom = dom;
loops->cfg.dfs_order = dfs_order;
loops->cfg.rc_order = rc_order;
/* Allocate loop structures. */ /* Allocate loop structures. */
loops->array loops->array
= (struct loop *) xcalloc (num_loops, sizeof (struct loop)); = (struct loop *) xcalloc (num_loops, sizeof (struct loop));
...@@ -8264,7 +8333,6 @@ flow_loops_find (loops, flags) ...@@ -8264,7 +8333,6 @@ flow_loops_find (loops, flags)
for (i = 0; i < num_loops; i++) for (i = 0; i < num_loops; i++)
{ {
struct loop *loop = &loops->array[i]; struct loop *loop = &loops->array[i];
int j;
/* Keep track of blocks that are loop headers so /* Keep track of blocks that are loop headers so
that we can tell which loops should be merged. */ that we can tell which loops should be merged. */
...@@ -8286,43 +8354,7 @@ flow_loops_find (loops, flags) ...@@ -8286,43 +8354,7 @@ flow_loops_find (loops, flags)
loop->last loop->last
= BASIC_BLOCK (sbitmap_last_set_bit (loop->nodes)); = BASIC_BLOCK (sbitmap_last_set_bit (loop->nodes));
if (flags & LOOP_EDGES) flow_loop_scan (loops, loop, flags);
{
/* Find edges which enter the loop header.
Note that the entry edges should only
enter the header of a natural loop. */
loop->num_entries
= flow_loop_entry_edges_find (loop->header,
loop->nodes,
&loop->entry_edges);
/* Find edges which exit the loop. */
loop->num_exits
= flow_loop_exit_edges_find (loop->nodes,
&loop->exit_edges);
/* Determine which loop nodes dominate all the exits
of the loop. */
loop->exits_doms = sbitmap_alloc (n_basic_blocks);
sbitmap_copy (loop->exits_doms, loop->nodes);
for (j = 0; j < loop->num_exits; j++)
sbitmap_a_and_b (loop->exits_doms, loop->exits_doms,
dom[loop->exit_edges[j]->src->index]);
/* The header of a natural loop must dominate
all exits. */
if (! TEST_BIT (loop->exits_doms, loop->header->index))
abort ();
}
if (flags & LOOP_PRE_HEADER)
{
/* Look to see if the loop has a pre-header node. */
loop->pre_header
= flow_loop_pre_header_find (loop->header, dom);
flow_loop_pre_header_scan (loop);
}
} }
/* Natural loops with shared headers may either be disjoint or /* Natural loops with shared headers may either be disjoint or
...@@ -8338,11 +8370,6 @@ flow_loops_find (loops, flags) ...@@ -8338,11 +8370,6 @@ flow_loops_find (loops, flags)
loops->num = num_loops; loops->num = num_loops;
/* Save CFG derived information to avoid recomputing it. */
loops->cfg.dom = dom;
loops->cfg.dfs_order = dfs_order;
loops->cfg.rc_order = rc_order;
/* Build the loop hierarchy tree. */ /* Build the loop hierarchy tree. */
flow_loops_tree_build (loops); flow_loops_tree_build (loops);
......
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