Commit 06d43afd by Steven Bosscher

tree-ssa-coalesce.c (struct ssa_conflicts_d): Make contents of this a VEC and add a bitmap obstack.

	* tree-ssa-coalesce.c (struct ssa_conflicts_d): Make contents
	of this a VEC and add a bitmap obstack.
	(ssa_conflicts_new): Allocate the obstack and grow the VEC cleared
	to the right size.
	(ssa_conflicts_delete): Free the VEC and release the obstack.
	(ssa_conflicts_test_p, ssa_conflicts_test_p, ssa_conflicts_add_one,
	ssa_conflicts_merge, ssa_conflicts_dump): Update for above changes.
	(truct live_track_d): Add another bitmap obstack here.
	(new_live_track): Initialize it and use it for all bitmaps.
	(delete_live_track): Don't free the bitmaps one at a time, just
	release the obstack.
	(create_outofssa_var_map): Fix to conform to GCC code style rules.

From-SVN: r190589
parent 130e00bd
2012-08-22 Steven Bosscher <steven@gcc.gnu.org>
* tree-ssa-coalesce.c (struct ssa_conflicts_d): Make contents
of this a VEC and add a bitmap obstack.
(ssa_conflicts_new): Allocate the obstack and grow the VEC cleared
to the right size.
(ssa_conflicts_delete): Free the VEC and release the obstack.
(ssa_conflicts_test_p, ssa_conflicts_test_p, ssa_conflicts_add_one,
ssa_conflicts_merge, ssa_conflicts_dump): Update for above changes.
(truct live_track_d): Add another bitmap obstack here.
(new_live_track): Initialize it and use it for all bitmaps.
(delete_live_track): Don't free the bitmaps one at a time, just
release the obstack.
(create_outofssa_var_map): Fix to conform to GCC code style rules.
2012-08-21 Nathan Froyd <froydnj@gcc.gnu.org> 2012-08-21 Nathan Froyd <froydnj@gcc.gnu.org>
* config/m32c/constraints.md: New file. * config/m32c/constraints.md: New file.
......
...@@ -504,11 +504,10 @@ dump_coalesce_list (FILE *f, coalesce_list_p cl) ...@@ -504,11 +504,10 @@ dump_coalesce_list (FILE *f, coalesce_list_p cl)
typedef struct ssa_conflicts_d typedef struct ssa_conflicts_d
{ {
unsigned size; bitmap_obstack obstack; /* A place to allocate our bitmaps. */
bitmap *conflicts; VEC(bitmap, heap)* conflicts;
} * ssa_conflicts_p; } * ssa_conflicts_p;
/* Return an empty new conflict graph for SIZE elements. */ /* Return an empty new conflict graph for SIZE elements. */
static inline ssa_conflicts_p static inline ssa_conflicts_p
...@@ -517,8 +516,9 @@ ssa_conflicts_new (unsigned size) ...@@ -517,8 +516,9 @@ ssa_conflicts_new (unsigned size)
ssa_conflicts_p ptr; ssa_conflicts_p ptr;
ptr = XNEW (struct ssa_conflicts_d); ptr = XNEW (struct ssa_conflicts_d);
ptr->conflicts = XCNEWVEC (bitmap, size); bitmap_obstack_initialize (&ptr->obstack);
ptr->size = size; ptr->conflicts = VEC_alloc (bitmap, heap, size);
VEC_safe_grow_cleared (bitmap, heap, ptr->conflicts, size);
return ptr; return ptr;
} }
...@@ -528,12 +528,8 @@ ssa_conflicts_new (unsigned size) ...@@ -528,12 +528,8 @@ ssa_conflicts_new (unsigned size)
static inline void static inline void
ssa_conflicts_delete (ssa_conflicts_p ptr) ssa_conflicts_delete (ssa_conflicts_p ptr)
{ {
unsigned x; bitmap_obstack_release (&ptr->obstack);
for (x = 0; x < ptr->size; x++) VEC_free (bitmap, heap, ptr->conflicts);
if (ptr->conflicts[x])
BITMAP_FREE (ptr->conflicts[x]);
free (ptr->conflicts);
free (ptr); free (ptr);
} }
...@@ -543,16 +539,14 @@ ssa_conflicts_delete (ssa_conflicts_p ptr) ...@@ -543,16 +539,14 @@ ssa_conflicts_delete (ssa_conflicts_p ptr)
static inline bool static inline bool
ssa_conflicts_test_p (ssa_conflicts_p ptr, unsigned x, unsigned y) ssa_conflicts_test_p (ssa_conflicts_p ptr, unsigned x, unsigned y)
{ {
bitmap b; bitmap bx = VEC_index (bitmap, ptr->conflicts, x);
bitmap by = VEC_index (bitmap, ptr->conflicts, y);
gcc_checking_assert (x < ptr->size);
gcc_checking_assert (y < ptr->size);
gcc_checking_assert (x != y); gcc_checking_assert (x != y);
b = ptr->conflicts[x]; if (bx)
if (b)
/* Avoid the lookup if Y has no conflicts. */ /* Avoid the lookup if Y has no conflicts. */
return ptr->conflicts[y] ? bitmap_bit_p (b, y) : false; return by ? bitmap_bit_p (bx, y) : false;
else else
return false; return false;
} }
...@@ -563,10 +557,11 @@ ssa_conflicts_test_p (ssa_conflicts_p ptr, unsigned x, unsigned y) ...@@ -563,10 +557,11 @@ ssa_conflicts_test_p (ssa_conflicts_p ptr, unsigned x, unsigned y)
static inline void static inline void
ssa_conflicts_add_one (ssa_conflicts_p ptr, unsigned x, unsigned y) ssa_conflicts_add_one (ssa_conflicts_p ptr, unsigned x, unsigned y)
{ {
bitmap bx = VEC_index (bitmap, ptr->conflicts, x);
/* If there are no conflicts yet, allocate the bitmap and set bit. */ /* If there are no conflicts yet, allocate the bitmap and set bit. */
if (!ptr->conflicts[x]) if (! bx)
ptr->conflicts[x] = BITMAP_ALLOC (NULL); bx = VEC_index (bitmap, ptr->conflicts, x) = BITMAP_ALLOC (&ptr->obstack);
bitmap_set_bit (ptr->conflicts[x], y); bitmap_set_bit (bx, y);
} }
...@@ -575,8 +570,6 @@ ssa_conflicts_add_one (ssa_conflicts_p ptr, unsigned x, unsigned y) ...@@ -575,8 +570,6 @@ ssa_conflicts_add_one (ssa_conflicts_p ptr, unsigned x, unsigned y)
static inline void static inline void
ssa_conflicts_add (ssa_conflicts_p ptr, unsigned x, unsigned y) ssa_conflicts_add (ssa_conflicts_p ptr, unsigned x, unsigned y)
{ {
gcc_checking_assert (x < ptr->size);
gcc_checking_assert (y < ptr->size);
gcc_checking_assert (x != y); gcc_checking_assert (x != y);
ssa_conflicts_add_one (ptr, x, y); ssa_conflicts_add_one (ptr, x, y);
ssa_conflicts_add_one (ptr, y, x); ssa_conflicts_add_one (ptr, y, x);
...@@ -590,29 +583,35 @@ ssa_conflicts_merge (ssa_conflicts_p ptr, unsigned x, unsigned y) ...@@ -590,29 +583,35 @@ ssa_conflicts_merge (ssa_conflicts_p ptr, unsigned x, unsigned y)
{ {
unsigned z; unsigned z;
bitmap_iterator bi; bitmap_iterator bi;
bitmap bx = VEC_index (bitmap, ptr->conflicts, x);
bitmap by = VEC_index (bitmap, ptr->conflicts, y);
gcc_assert (x != y); gcc_checking_assert (x != y);
if (!(ptr->conflicts[y])) if (! by)
return; return;
/* Add a conflict between X and every one Y has. If the bitmap doesn't /* Add a conflict between X and every one Y has. If the bitmap doesn't
exist, then it has already been coalesced, and we don't need to add a exist, then it has already been coalesced, and we don't need to add a
conflict. */ conflict. */
EXECUTE_IF_SET_IN_BITMAP (ptr->conflicts[y], 0, z, bi) EXECUTE_IF_SET_IN_BITMAP (by, 0, z, bi)
if (ptr->conflicts[z]) {
bitmap_set_bit (ptr->conflicts[z], x); bitmap bz = VEC_index (bitmap, ptr->conflicts, z);
if (bz)
bitmap_set_bit (bz, x);
}
if (ptr->conflicts[x]) if (bx)
{ {
/* If X has conflicts, add Y's to X. */ /* If X has conflicts, add Y's to X. */
bitmap_ior_into (ptr->conflicts[x], ptr->conflicts[y]); bitmap_ior_into (bx, by);
BITMAP_FREE (ptr->conflicts[y]); BITMAP_FREE (by);
VEC_replace (bitmap, ptr->conflicts, y, NULL);
} }
else else
{ {
/* If X has no conflicts, simply use Y's. */ /* If X has no conflicts, simply use Y's. */
ptr->conflicts[x] = ptr->conflicts[y]; VEC_replace (bitmap, ptr->conflicts, x, by);
ptr->conflicts[y] = NULL; VEC_replace (bitmap, ptr->conflicts, y, NULL);
} }
} }
...@@ -623,14 +622,15 @@ static void ...@@ -623,14 +622,15 @@ static void
ssa_conflicts_dump (FILE *file, ssa_conflicts_p ptr) ssa_conflicts_dump (FILE *file, ssa_conflicts_p ptr)
{ {
unsigned x; unsigned x;
bitmap b;
fprintf (file, "\nConflict graph:\n"); fprintf (file, "\nConflict graph:\n");
for (x = 0; x < ptr->size; x++) FOR_EACH_VEC_ELT (bitmap, ptr->conflicts, x, b);
if (ptr->conflicts[x]) if (b)
{ {
fprintf (dump_file, "%d: ", x); fprintf (dump_file, "%d: ", x);
dump_bitmap (file, ptr->conflicts[x]); dump_bitmap (file, b);
} }
} }
...@@ -649,6 +649,7 @@ ssa_conflicts_dump (FILE *file, ssa_conflicts_p ptr) ...@@ -649,6 +649,7 @@ ssa_conflicts_dump (FILE *file, ssa_conflicts_p ptr)
typedef struct live_track_d typedef struct live_track_d
{ {
bitmap_obstack obstack; /* A place to allocate our bitmaps. */
bitmap live_base_var; /* Indicates if a basevar is live. */ bitmap live_base_var; /* Indicates if a basevar is live. */
bitmap *live_base_partitions; /* Live partitions for each basevar. */ bitmap *live_base_partitions; /* Live partitions for each basevar. */
var_map map; /* Var_map being used for partition mapping. */ var_map map; /* Var_map being used for partition mapping. */
...@@ -670,10 +671,11 @@ new_live_track (var_map map) ...@@ -670,10 +671,11 @@ new_live_track (var_map map)
ptr = (live_track_p) xmalloc (sizeof (struct live_track_d)); ptr = (live_track_p) xmalloc (sizeof (struct live_track_d));
ptr->map = map; ptr->map = map;
lim = num_basevars (map); lim = num_basevars (map);
bitmap_obstack_initialize (&ptr->obstack);
ptr->live_base_partitions = (bitmap *) xmalloc(sizeof (bitmap *) * lim); ptr->live_base_partitions = (bitmap *) xmalloc(sizeof (bitmap *) * lim);
ptr->live_base_var = BITMAP_ALLOC (NULL); ptr->live_base_var = BITMAP_ALLOC (&ptr->obstack);
for (x = 0; x < lim; x++) for (x = 0; x < lim; x++)
ptr->live_base_partitions[x] = BITMAP_ALLOC (NULL); ptr->live_base_partitions[x] = BITMAP_ALLOC (&ptr->obstack);
return ptr; return ptr;
} }
...@@ -683,12 +685,7 @@ new_live_track (var_map map) ...@@ -683,12 +685,7 @@ new_live_track (var_map map)
static void static void
delete_live_track (live_track_p ptr) delete_live_track (live_track_p ptr)
{ {
int x, lim; bitmap_obstack_release (&ptr->obstack);
lim = num_basevars (ptr->map);
for (x = 0; x < lim; x++)
BITMAP_FREE (ptr->live_base_partitions[x]);
BITMAP_FREE (ptr->live_base_var);
free (ptr->live_base_partitions); free (ptr->live_base_partitions);
free (ptr); free (ptr);
} }
...@@ -1046,10 +1043,11 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy) ...@@ -1046,10 +1043,11 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy)
noutputs = gimple_asm_noutputs (stmt); noutputs = gimple_asm_noutputs (stmt);
ninputs = gimple_asm_ninputs (stmt); ninputs = gimple_asm_ninputs (stmt);
outputs = (tree *) alloca (noutputs * sizeof (tree)); outputs = (tree *) alloca (noutputs * sizeof (tree));
for (i = 0; i < noutputs; ++i) { for (i = 0; i < noutputs; ++i)
link = gimple_asm_output_op (stmt, i); {
outputs[i] = TREE_VALUE (link); link = gimple_asm_output_op (stmt, i);
} outputs[i] = TREE_VALUE (link);
}
for (i = 0; i < ninputs; ++i) for (i = 0; i < ninputs; ++i)
{ {
......
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