===================================================================
@@ -1748,33 +1748,40 @@ calculate_allocation_cost (void)
static void
check_allocation (void)
{
- ira_allocno_t a, conflict_a;
- int hard_regno, conflict_hard_regno, nregs, conflict_nregs;
- ira_allocno_conflict_iterator aci;
+ ira_allocno_t a;
+ int hard_regno, nregs;
ira_allocno_iterator ai;
FOR_EACH_ALLOCNO (a, ai)
{
+ ira_object_t obj, conflict_obj;
+ ira_object_conflict_iterator oci;
+
if (ALLOCNO_CAP_MEMBER (a) != NULL
|| (hard_regno = ALLOCNO_HARD_REGNO (a)) < 0)
continue;
nregs = hard_regno_nregs[hard_regno][ALLOCNO_MODE (a)];
- FOR_EACH_ALLOCNO_CONFLICT (a, conflict_a, aci)
- if ((conflict_hard_regno = ALLOCNO_HARD_REGNO (conflict_a)) >= 0)
- {
- conflict_nregs
- = (hard_regno_nregs
- [conflict_hard_regno][ALLOCNO_MODE (conflict_a)]);
- if ((conflict_hard_regno <= hard_regno
- && hard_regno < conflict_hard_regno + conflict_nregs)
- || (hard_regno <= conflict_hard_regno
- && conflict_hard_regno < hard_regno + nregs))
- {
- fprintf (stderr, "bad allocation for %d and %d\n",
- ALLOCNO_REGNO (a), ALLOCNO_REGNO (conflict_a));
- gcc_unreachable ();
- }
- }
+ obj = ALLOCNO_OBJECT (a);
+ FOR_EACH_OBJECT_CONFLICT (obj, conflict_obj, oci)
+ {
+ ira_allocno_t conflict_a = OBJECT_ALLOCNO (conflict_obj);
+ int conflict_hard_regno = ALLOCNO_HARD_REGNO (conflict_a);
+ if (conflict_hard_regno >= 0)
+ {
+ int conflict_nregs
+ = (hard_regno_nregs
+ [conflict_hard_regno][ALLOCNO_MODE (conflict_a)]);
+ if ((conflict_hard_regno <= hard_regno
+ && hard_regno < conflict_hard_regno + conflict_nregs)
+ || (hard_regno <= conflict_hard_regno
+ && conflict_hard_regno < hard_regno + nregs))
+ {
+ fprintf (stderr, "bad allocation for %d and %d\n",
+ ALLOCNO_REGNO (a), ALLOCNO_REGNO (conflict_a));
+ gcc_unreachable ();
+ }
+ }
+ }
}
}
#endif
===================================================================
@@ -446,8 +446,7 @@ assign_hard_reg (ira_allocno_t allocno,
int *conflict_costs;
enum reg_class cover_class, conflict_cover_class;
enum machine_mode mode;
- ira_allocno_t a, conflict_allocno;
- ira_allocno_conflict_iterator aci;
+ ira_allocno_t a;
static int costs[FIRST_PSEUDO_REGISTER], full_costs[FIRST_PSEUDO_REGISTER];
#ifndef HONOR_REG_ALLOC_ORDER
enum reg_class rclass;
@@ -477,6 +476,8 @@ assign_hard_reg (ira_allocno_t allocno,
a = ALLOCNO_NEXT_COALESCED_ALLOCNO (a))
{
ira_object_t obj = ALLOCNO_OBJECT (a);
+ ira_object_t conflict_obj;
+ ira_object_conflict_iterator oci;
mem_cost += ALLOCNO_UPDATED_MEMORY_COST (a);
IOR_HARD_REG_SET (conflicting_regs,
@@ -500,60 +501,64 @@ assign_hard_reg (ira_allocno_t allocno,
full_costs[i] += cost;
}
/* Take preferences of conflicting allocnos into account. */
- FOR_EACH_ALLOCNO_CONFLICT (a, conflict_allocno, aci)
- /* Reload can give another class so we need to check all
- allocnos. */
- if (retry_p || bitmap_bit_p (consideration_allocno_bitmap,
- ALLOCNO_NUM (conflict_allocno)))
- {
- conflict_cover_class = ALLOCNO_COVER_CLASS (conflict_allocno);
- ira_assert (ira_reg_classes_intersect_p
- [cover_class][conflict_cover_class]);
- if (allocno_coalesced_p)
- {
- if (bitmap_bit_p (processed_coalesced_allocno_bitmap,
- ALLOCNO_NUM (conflict_allocno)))
- continue;
- bitmap_set_bit (processed_coalesced_allocno_bitmap,
- ALLOCNO_NUM (conflict_allocno));
- }
- if (ALLOCNO_ASSIGNED_P (conflict_allocno))
- {
- if ((hard_regno = ALLOCNO_HARD_REGNO (conflict_allocno)) >= 0
- && ira_class_hard_reg_index[cover_class][hard_regno] >= 0)
- {
- IOR_HARD_REG_SET
- (conflicting_regs,
- ira_reg_mode_hard_regset
- [hard_regno][ALLOCNO_MODE (conflict_allocno)]);
- if (hard_reg_set_subset_p (reg_class_contents[cover_class],
- conflicting_regs))
- goto fail;
- }
- }
- else if (! ALLOCNO_MAY_BE_SPILLED_P (ALLOCNO_FIRST_COALESCED_ALLOCNO
- (conflict_allocno)))
- {
- ira_allocate_and_copy_costs
- (&ALLOCNO_UPDATED_CONFLICT_HARD_REG_COSTS (conflict_allocno),
- conflict_cover_class,
- ALLOCNO_CONFLICT_HARD_REG_COSTS (conflict_allocno));
- conflict_costs
- = ALLOCNO_UPDATED_CONFLICT_HARD_REG_COSTS (conflict_allocno);
- if (conflict_costs != NULL)
- for (j = class_size - 1; j >= 0; j--)
- {
- hard_regno = ira_class_hard_regs[cover_class][j];
- ira_assert (hard_regno >= 0);
- k = (ira_class_hard_reg_index
- [conflict_cover_class][hard_regno]);
- if (k < 0)
- continue;
- full_costs[j] -= conflict_costs[k];
- }
- queue_update_cost (conflict_allocno, COST_HOP_DIVISOR);
- }
- }
+ FOR_EACH_OBJECT_CONFLICT (obj, conflict_obj, oci)
+ {
+ ira_allocno_t conflict_allocno = OBJECT_ALLOCNO (conflict_obj);
+
+ /* Reload can give another class so we need to check all
+ allocnos. */
+ if (retry_p || bitmap_bit_p (consideration_allocno_bitmap,
+ ALLOCNO_NUM (conflict_allocno)))
+ {
+ conflict_cover_class = ALLOCNO_COVER_CLASS (conflict_allocno);
+ ira_assert (ira_reg_classes_intersect_p
+ [cover_class][conflict_cover_class]);
+ if (allocno_coalesced_p)
+ {
+ if (bitmap_bit_p (processed_coalesced_allocno_bitmap,
+ ALLOCNO_NUM (conflict_allocno)))
+ continue;
+ bitmap_set_bit (processed_coalesced_allocno_bitmap,
+ ALLOCNO_NUM (conflict_allocno));
+ }
+ if (ALLOCNO_ASSIGNED_P (conflict_allocno))
+ {
+ if ((hard_regno = ALLOCNO_HARD_REGNO (conflict_allocno)) >= 0
+ && ira_class_hard_reg_index[cover_class][hard_regno] >= 0)
+ {
+ IOR_HARD_REG_SET
+ (conflicting_regs,
+ ira_reg_mode_hard_regset
+ [hard_regno][ALLOCNO_MODE (conflict_allocno)]);
+ if (hard_reg_set_subset_p (reg_class_contents[cover_class],
+ conflicting_regs))
+ goto fail;
+ }
+ }
+ else if (! ALLOCNO_MAY_BE_SPILLED_P (ALLOCNO_FIRST_COALESCED_ALLOCNO
+ (conflict_allocno)))
+ {
+ ira_allocate_and_copy_costs
+ (&ALLOCNO_UPDATED_CONFLICT_HARD_REG_COSTS (conflict_allocno),
+ conflict_cover_class,
+ ALLOCNO_CONFLICT_HARD_REG_COSTS (conflict_allocno));
+ conflict_costs
+ = ALLOCNO_UPDATED_CONFLICT_HARD_REG_COSTS (conflict_allocno);
+ if (conflict_costs != NULL)
+ for (j = class_size - 1; j >= 0; j--)
+ {
+ hard_regno = ira_class_hard_regs[cover_class][j];
+ ira_assert (hard_regno >= 0);
+ k = (ira_class_hard_reg_index
+ [conflict_cover_class][hard_regno]);
+ if (k < 0)
+ continue;
+ full_costs[j] -= conflict_costs[k];
+ }
+ queue_update_cost (conflict_allocno, COST_HOP_DIVISOR);
+ }
+ }
+ }
if (a == allocno)
break;
}
@@ -869,9 +874,8 @@ static void
push_allocno_to_stack (ira_allocno_t allocno)
{
int left_conflicts_size, conflict_size, size;
- ira_allocno_t a, conflict_allocno;
+ ira_allocno_t a;
enum reg_class cover_class;
- ira_allocno_conflict_iterator aci;
ALLOCNO_IN_GRAPH_P (allocno) = false;
VEC_safe_push (ira_allocno_t, heap, allocno_stack_vec, allocno);
@@ -884,8 +888,14 @@ push_allocno_to_stack (ira_allocno_t all
for (a = ALLOCNO_NEXT_COALESCED_ALLOCNO (allocno);;
a = ALLOCNO_NEXT_COALESCED_ALLOCNO (a))
{
- FOR_EACH_ALLOCNO_CONFLICT (a, conflict_allocno, aci)
+ ira_object_t obj = ALLOCNO_OBJECT (a);
+ ira_object_t conflict_obj;
+ ira_object_conflict_iterator oci;
+
+ FOR_EACH_OBJECT_CONFLICT (obj, conflict_obj, oci)
{
+ ira_allocno_t conflict_allocno = OBJECT_ALLOCNO (conflict_obj);
+
conflict_allocno = ALLOCNO_FIRST_COALESCED_ALLOCNO (conflict_allocno);
if (bitmap_bit_p (coloring_allocno_bitmap,
ALLOCNO_NUM (conflict_allocno)))
@@ -1402,10 +1412,9 @@ static void
setup_allocno_left_conflicts_size (ira_allocno_t allocno)
{
int i, hard_regs_num, hard_regno, conflict_allocnos_size;
- ira_allocno_t a, conflict_allocno;
+ ira_allocno_t a;
enum reg_class cover_class;
HARD_REG_SET temp_set;
- ira_allocno_conflict_iterator aci;
cover_class = ALLOCNO_COVER_CLASS (allocno);
hard_regs_num = ira_class_hard_regs_num[cover_class];
@@ -1441,8 +1450,14 @@ setup_allocno_left_conflicts_size (ira_a
for (a = ALLOCNO_NEXT_COALESCED_ALLOCNO (allocno);;
a = ALLOCNO_NEXT_COALESCED_ALLOCNO (a))
{
- FOR_EACH_ALLOCNO_CONFLICT (a, conflict_allocno, aci)
+ ira_object_t obj = ALLOCNO_OBJECT (a);
+ ira_object_t conflict_obj;
+ ira_object_conflict_iterator oci;
+
+ FOR_EACH_OBJECT_CONFLICT (obj, conflict_obj, oci)
{
+ ira_allocno_t conflict_allocno = OBJECT_ALLOCNO (conflict_obj);
+
conflict_allocno
= ALLOCNO_FIRST_COALESCED_ALLOCNO (conflict_allocno);
if (bitmap_bit_p (consideration_allocno_bitmap,
@@ -1560,8 +1575,7 @@ static bool
coalesced_allocno_conflict_p (ira_allocno_t a1, ira_allocno_t a2,
bool reload_p)
{
- ira_allocno_t a, conflict_allocno;
- ira_allocno_conflict_iterator aci;
+ ira_allocno_t a;
if (allocno_coalesced_p)
{
@@ -1579,6 +1593,7 @@ coalesced_allocno_conflict_p (ira_allocn
{
if (reload_p)
{
+ ira_allocno_t conflict_allocno;
for (conflict_allocno = ALLOCNO_NEXT_COALESCED_ALLOCNO (a1);;
conflict_allocno
= ALLOCNO_NEXT_COALESCED_ALLOCNO (conflict_allocno))
@@ -1592,12 +1607,19 @@ coalesced_allocno_conflict_p (ira_allocn
}
else
{
- FOR_EACH_ALLOCNO_CONFLICT (a, conflict_allocno, aci)
- if (conflict_allocno == a1
- || (allocno_coalesced_p
- && bitmap_bit_p (processed_coalesced_allocno_bitmap,
- ALLOCNO_NUM (conflict_allocno))))
- return true;
+ ira_object_t obj = ALLOCNO_OBJECT (a);
+ ira_object_t conflict_obj;
+ ira_object_conflict_iterator oci;
+
+ FOR_EACH_OBJECT_CONFLICT (obj, conflict_obj, oci)
+ {
+ ira_allocno_t conflict_allocno = OBJECT_ALLOCNO (conflict_obj);
+ if (conflict_allocno == a1
+ || (allocno_coalesced_p
+ && bitmap_bit_p (processed_coalesced_allocno_bitmap,
+ ALLOCNO_NUM (conflict_allocno))))
+ return true;
+ }
}
if (a == a2)
break;
@@ -2288,8 +2310,7 @@ void
ira_reassign_conflict_allocnos (int start_regno)
{
int i, allocnos_to_color_num;
- ira_allocno_t a, conflict_a;
- ira_allocno_conflict_iterator aci;
+ ira_allocno_t a;
enum reg_class cover_class;
bitmap allocnos_to_color;
ira_allocno_iterator ai;
@@ -2298,6 +2319,10 @@ ira_reassign_conflict_allocnos (int star
allocnos_to_color_num = 0;
FOR_EACH_ALLOCNO (a, ai)
{
+ ira_object_t obj = ALLOCNO_OBJECT (a);
+ ira_object_t conflict_obj;
+ ira_object_conflict_iterator oci;
+
if (! ALLOCNO_ASSIGNED_P (a)
&& ! bitmap_bit_p (allocnos_to_color, ALLOCNO_NUM (a)))
{
@@ -2315,8 +2340,9 @@ ira_reassign_conflict_allocnos (int star
if (ALLOCNO_REGNO (a) < start_regno
|| (cover_class = ALLOCNO_COVER_CLASS (a)) == NO_REGS)
continue;
- FOR_EACH_ALLOCNO_CONFLICT (a, conflict_a, aci)
+ FOR_EACH_OBJECT_CONFLICT (obj, conflict_obj, oci)
{
+ ira_allocno_t conflict_a = OBJECT_ALLOCNO (conflict_obj);
ira_assert (ira_reg_classes_intersect_p
[cover_class][ALLOCNO_COVER_CLASS (conflict_a)]);
if (bitmap_bit_p (allocnos_to_color, ALLOCNO_NUM (conflict_a)))
@@ -2873,9 +2899,8 @@ ira_reassign_pseudos (int *spilled_pseud
{
int i, n, regno;
bool changed_p;
- ira_allocno_t a, conflict_a;
+ ira_allocno_t a;
HARD_REG_SET forbidden_regs;
- ira_allocno_conflict_iterator aci;
bitmap temp = BITMAP_ALLOC (NULL);
/* Add pseudos which conflict with pseudos already in
@@ -2887,21 +2912,27 @@ ira_reassign_pseudos (int *spilled_pseud
for (i = 0, n = num; i < n; i++)
{
+ ira_object_t obj, conflict_obj;
+ ira_object_conflict_iterator oci;
int regno = spilled_pseudo_regs[i];
bitmap_set_bit (temp, regno);
a = ira_regno_allocno_map[regno];
- FOR_EACH_ALLOCNO_CONFLICT (a, conflict_a, aci)
- if (ALLOCNO_HARD_REGNO (conflict_a) < 0
- && ! ALLOCNO_DONT_REASSIGN_P (conflict_a)
- && ! bitmap_bit_p (temp, ALLOCNO_REGNO (conflict_a)))
- {
- spilled_pseudo_regs[num++] = ALLOCNO_REGNO (conflict_a);
- bitmap_set_bit (temp, ALLOCNO_REGNO (conflict_a));
- /* ?!? This seems wrong. */
- bitmap_set_bit (consideration_allocno_bitmap,
- ALLOCNO_NUM (conflict_a));
- }
+ obj = ALLOCNO_OBJECT (a);
+ FOR_EACH_OBJECT_CONFLICT (obj, conflict_obj, oci)
+ {
+ ira_allocno_t conflict_a = OBJECT_ALLOCNO (conflict_obj);
+ if (ALLOCNO_HARD_REGNO (conflict_a) < 0
+ && ! ALLOCNO_DONT_REASSIGN_P (conflict_a)
+ && ! bitmap_bit_p (temp, ALLOCNO_REGNO (conflict_a)))
+ {
+ spilled_pseudo_regs[num++] = ALLOCNO_REGNO (conflict_a);
+ bitmap_set_bit (temp, ALLOCNO_REGNO (conflict_a));
+ /* ?!? This seems wrong. */
+ bitmap_set_bit (consideration_allocno_bitmap,
+ ALLOCNO_NUM (conflict_a));
+ }
+ }
}
if (num > 1)
===================================================================
@@ -717,9 +717,8 @@ static void
print_allocno_conflicts (FILE * file, bool reg_p, ira_allocno_t a)
{
HARD_REG_SET conflicting_hard_regs;
- ira_object_t obj;
- ira_allocno_t conflict_a;
- ira_allocno_conflict_iterator aci;
+ ira_object_t obj, conflict_obj;
+ ira_object_conflict_iterator oci;
basic_block bb;
if (reg_p)
@@ -737,8 +736,9 @@ print_allocno_conflicts (FILE * file, bo
fputs (" conflicts:", file);
obj = ALLOCNO_OBJECT (a);
if (OBJECT_CONFLICT_ARRAY (obj) != NULL)
- FOR_EACH_ALLOCNO_CONFLICT (a, conflict_a, aci)
+ FOR_EACH_OBJECT_CONFLICT (obj, conflict_obj, oci)
{
+ ira_allocno_t conflict_a = OBJECT_ALLOCNO (conflict_obj);
if (reg_p)
fprintf (file, " r%d,", ALLOCNO_REGNO (conflict_a));
else
===================================================================
@@ -1088,14 +1088,13 @@ typedef struct {
/* The word of bit vector currently visited. It is defined only if
OBJECT_CONFLICT_VEC_P is FALSE. */
unsigned IRA_INT_TYPE word;
-} ira_allocno_conflict_iterator;
+} ira_object_conflict_iterator;
/* Initialize the iterator I with ALLOCNO conflicts. */
static inline void
-ira_allocno_conflict_iter_init (ira_allocno_conflict_iterator *i,
- ira_allocno_t allocno)
+ira_object_conflict_iter_init (ira_object_conflict_iterator *i,
+ ira_object_t obj)
{
- ira_object_t obj = ALLOCNO_OBJECT (allocno);
i->conflict_vec_p = OBJECT_CONFLICT_VEC_P (obj);
i->vec = OBJECT_CONFLICT_ARRAY (obj);
i->word_num = 0;
@@ -1119,8 +1118,8 @@ ira_allocno_conflict_iter_init (ira_allo
case *A is set to the allocno to be visited. Otherwise, return
FALSE. */
static inline bool
-ira_allocno_conflict_iter_cond (ira_allocno_conflict_iterator *i,
- ira_allocno_t *a)
+ira_object_conflict_iter_cond (ira_object_conflict_iterator *i,
+ ira_object_t *pobj)
{
ira_object_t obj;
@@ -1151,13 +1150,13 @@ ira_allocno_conflict_iter_cond (ira_allo
obj = ira_object_id_map[i->bit_num + i->base_conflict_id];
}
- *a = OBJECT_ALLOCNO (obj);
+ *pobj = obj;
return true;
}
/* Advance to the next conflicting allocno. */
static inline void
-ira_allocno_conflict_iter_next (ira_allocno_conflict_iterator *i)
+ira_object_conflict_iter_next (ira_object_conflict_iterator *i)
{
if (i->conflict_vec_p)
i->word_num++;
@@ -1168,14 +1167,13 @@ ira_allocno_conflict_iter_next (ira_allo
}
}
-/* Loop over all allocnos conflicting with ALLOCNO. In each
- iteration, A is set to the next conflicting allocno. ITER is an
- instance of ira_allocno_conflict_iterator used to iterate the
- conflicts. */
-#define FOR_EACH_ALLOCNO_CONFLICT(ALLOCNO, A, ITER) \
- for (ira_allocno_conflict_iter_init (&(ITER), (ALLOCNO)); \
- ira_allocno_conflict_iter_cond (&(ITER), &(A)); \
- ira_allocno_conflict_iter_next (&(ITER)))
+/* Loop over all objects conflicting with OBJ. In each iteration,
+ CONF is set to the next conflicting object. ITER is an instance
+ of ira_object_conflict_iterator used to iterate the conflicts. */
+#define FOR_EACH_OBJECT_CONFLICT(OBJ, CONF, ITER) \
+ for (ira_object_conflict_iter_init (&(ITER), (OBJ)); \
+ ira_object_conflict_iter_cond (&(ITER), &(CONF)); \
+ ira_object_conflict_iter_next (&(ITER)))