aboutsummaryrefslogtreecommitdiff
path: root/gcc/cfganal.c
diff options
context:
space:
mode:
authorsteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>2012-07-23 14:28:29 +0000
committersteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>2012-07-23 14:28:29 +0000
commit34ad4b87beab64861192f0566b48a49b79532d6e (patch)
treef6da776c8dafac61253e8fb4ce7919242d83abf0 /gcc/cfganal.c
parent099ee83067db8aef6cde5594ad8d7ad3f65a70ca (diff)
* sbitmap.h (struct int_list): Remove.
(sbitmap_intersect_of_predsucc, sbitmap_union_of_predsucc): Remove prototypes of non-existing function. (sbitmap_intersect_of_predecessors, sbitmap_intersect_of_successors, sbitmap_union_of_predecessors, sbitmap_union_of_successors): Remove unused defines. (sbitmap_intersection_of_succs, sbitmap_intersection_of_preds, sbitmap_union_of_succs, sbitmap_union_of_preds): Move prototypes to... * basic-block.h: ... here. * sbitmap.c: Do not include basic-block.h. (sbitmap_intersection_of_succs, sbitmap_intersection_of_preds, sbitmap_union_of_succs, sbitmap_union_of_preds): Move functions to... * cfganal.c: ... here. * bt-load.c (compute_out, link_btr_uses): Update for above changes. * gcse.c (compute_code_hoist_vbeinout): Likewise. * lcm.c (compute_antinout_edge, compute_available): Likewise. * Makefile.in: Fix sbitmap.o dependencies. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@189785 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfganal.c')
-rw-r--r--gcc/cfganal.c173
1 files changed, 173 insertions, 0 deletions
diff --git a/gcc/cfganal.c b/gcc/cfganal.c
index c906e17e358..692be3808b8 100644
--- a/gcc/cfganal.c
+++ b/gcc/cfganal.c
@@ -1182,4 +1182,177 @@ compute_idf (bitmap def_blocks, bitmap_head *dfs)
return phi_insertion_points;
}
+/* Intersection and union of preds/succs for sbitmap based data flow
+ solvers. All four functions defined below take the same arguments:
+ B is the basic block to perform the operation for. DST is the
+ target sbitmap, i.e. the result. SRC is an sbitmap vector of size
+ last_basic_block so that it can be indexed with basic block indices.
+ DST may be (but does not have to be) SRC[B->index]. */
+/* Set the bitmap DST to the intersection of SRC of successors of
+ basic block B. */
+
+void
+sbitmap_intersection_of_succs (sbitmap dst, sbitmap *src,
+ basic_block b)
+{
+ unsigned int set_size = dst->size;
+ edge e;
+ unsigned ix;
+
+ gcc_assert (!dst->popcount);
+
+ for (e = NULL, ix = 0; ix < EDGE_COUNT (b->succs); ix++)
+ {
+ e = EDGE_SUCC (b, ix);
+ if (e->dest == EXIT_BLOCK_PTR)
+ continue;
+
+ sbitmap_copy (dst, src[e->dest->index]);
+ break;
+ }
+
+ if (e == 0)
+ sbitmap_ones (dst);
+ else
+ for (++ix; ix < EDGE_COUNT (b->succs); ix++)
+ {
+ unsigned int i;
+ SBITMAP_ELT_TYPE *p, *r;
+
+ e = EDGE_SUCC (b, ix);
+ if (e->dest == EXIT_BLOCK_PTR)
+ continue;
+
+ p = src[e->dest->index]->elms;
+ r = dst->elms;
+ for (i = 0; i < set_size; i++)
+ *r++ &= *p++;
+ }
+}
+
+/* Set the bitmap DST to the intersection of SRC of predecessors of
+ basic block B. */
+
+void
+sbitmap_intersection_of_preds (sbitmap dst, sbitmap *src,
+ basic_block b)
+{
+ unsigned int set_size = dst->size;
+ edge e;
+ unsigned ix;
+
+ gcc_assert (!dst->popcount);
+
+ for (e = NULL, ix = 0; ix < EDGE_COUNT (b->preds); ix++)
+ {
+ e = EDGE_PRED (b, ix);
+ if (e->src == ENTRY_BLOCK_PTR)
+ continue;
+
+ sbitmap_copy (dst, src[e->src->index]);
+ break;
+ }
+
+ if (e == 0)
+ sbitmap_ones (dst);
+ else
+ for (++ix; ix < EDGE_COUNT (b->preds); ix++)
+ {
+ unsigned int i;
+ SBITMAP_ELT_TYPE *p, *r;
+
+ e = EDGE_PRED (b, ix);
+ if (e->src == ENTRY_BLOCK_PTR)
+ continue;
+
+ p = src[e->src->index]->elms;
+ r = dst->elms;
+ for (i = 0; i < set_size; i++)
+ *r++ &= *p++;
+ }
+}
+
+/* Set the bitmap DST to the union of SRC of successors of
+ basic block B. */
+
+void
+sbitmap_union_of_succs (sbitmap dst, sbitmap *src,
+ basic_block b)
+{
+ unsigned int set_size = dst->size;
+ edge e;
+ unsigned ix;
+
+ gcc_assert (!dst->popcount);
+
+ for (ix = 0; ix < EDGE_COUNT (b->succs); ix++)
+ {
+ e = EDGE_SUCC (b, ix);
+ if (e->dest == EXIT_BLOCK_PTR)
+ continue;
+
+ sbitmap_copy (dst, src[e->dest->index]);
+ break;
+ }
+
+ if (ix == EDGE_COUNT (b->succs))
+ sbitmap_zero (dst);
+ else
+ for (ix++; ix < EDGE_COUNT (b->succs); ix++)
+ {
+ unsigned int i;
+ SBITMAP_ELT_TYPE *p, *r;
+
+ e = EDGE_SUCC (b, ix);
+ if (e->dest == EXIT_BLOCK_PTR)
+ continue;
+
+ p = src[e->dest->index]->elms;
+ r = dst->elms;
+ for (i = 0; i < set_size; i++)
+ *r++ |= *p++;
+ }
+}
+
+/* Set the bitmap DST to the union of SRC of predecessors of
+ basic block B. */
+
+void
+sbitmap_union_of_preds (sbitmap dst, sbitmap *src,
+ basic_block b)
+{
+ unsigned int set_size = dst->size;
+ edge e;
+ unsigned ix;
+
+ gcc_assert (!dst->popcount);
+
+ for (ix = 0; ix < EDGE_COUNT (b->preds); ix++)
+ {
+ e = EDGE_PRED (b, ix);
+ if (e->src== ENTRY_BLOCK_PTR)
+ continue;
+
+ sbitmap_copy (dst, src[e->src->index]);
+ break;
+ }
+
+ if (ix == EDGE_COUNT (b->preds))
+ sbitmap_zero (dst);
+ else
+ for (ix++; ix < EDGE_COUNT (b->preds); ix++)
+ {
+ unsigned int i;
+ SBITMAP_ELT_TYPE *p, *r;
+
+ e = EDGE_PRED (b, ix);
+ if (e->src == ENTRY_BLOCK_PTR)
+ continue;
+
+ p = src[e->src->index]->elms;
+ r = dst->elms;
+ for (i = 0; i < set_size; i++)
+ *r++ |= *p++;
+ }
+}