diff options
author | bernds <bernds@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-07-14 01:53:35 +0000 |
---|---|---|
committer | bernds <bernds@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-07-14 01:53:35 +0000 |
commit | ae9587ed110597fc000021d88e1e5080628e4c66 (patch) | |
tree | fe78855d67c4408f0380b53d7b9fc52d0f6ffd91 /gcc/ira-build.c | |
parent | 483df1400516d9df4df37c34ad46b02561331336 (diff) | |
download | gcc-ae9587ed110597fc000021d88e1e5080628e4c66.tar.gz |
* ira-int.h (struct ira_object): New.
(ira_object_t): New typedef. Add DEF_VEC_P and DEF_VEC_ALLOC_P
for it.
(struct ira_allocno): Remove members min, max,
conflict_allocno_array, conflict_id, conflict_allocno_array_size,
conflict_allocnos_num and conflict_vec_p. Add new member object.
(OBJECT_CONFLICT_ARRAY, OBJECT_CONFLICT_VEC_P,
OBJECT_NUM_CONFLICTS, OBJECT_CONFLICT_ARRAY_SIZE,
OBJECT_CONFLICT_HARD_REGS, OBJECT_TOTAL_CONFLICT_HARD_REGS,
OBJECT_MIN, OBJECT_MAX, OBJECT_CONFLICT_ID): Renamed from
ALLOCNO_CONFLICT_ALLOCNO_ARRAY, ALLOCNO_CONFLICT_VEC_P,
ALLOCNO_CONFLICT_ALLOCNOS_NUM, ALLOCNO_CONFLICT_ALLOCNO_ARRAY_SIZE,
ALLOCNO_CONFLICT_HARD_REGS, ALLOCNO_TOTAL_CONFLICT_HARD_REGS)
ALLOCNO_MIN, ALLOCNO_MAX, and ALLOCNO_CONFLICT_ID; now operate on
an ira_object_t rather than ira_allocno_t. All uses changed.
(ira_object_id_map): Renamed from ira_conflict_id_allocno_map; now
contains a vector of ira_object_t; all uses changed.
(ira_objects_num): Declare variable.
(ira_create_allocno_object): Declare function.
(ira_conflict_vector_profitable_p): Adjust prototype.
(ira_allocate_conflict_vec): Renamed from
ira_allocate_allocno_conflict_vec; first arg now ira_object_t.
(ira_allocate_object_conflicts): Renamed from
ira_allocate_allocno_conflicts; first arg now ira_object_t.
(struct ira_object_iterator): New.
(ira_object_iter_init, ira_object_iter_cond, FOR_EACH_OBJECT): New.
(ira_allocno_conflict_iterator): Renamed member allocno_conflict_vec_p
to conflict_vec_p. All uses changed.
(ira_allocno_conflict_iter_init, ira_allocno_conflict_iter_cond):
Changed to take into account that conflicts are now tracked for
objects.
* ira-conflicts.c (OBJECTS_CONFLICT_P): Renamed from
CONFLICT_ALLOCNO_P. Args changed to accept ira_object_t. All
uses changed.
(allocnos_conflict_p): New static function.
(collected_conflict_objects): Renamed from collected_allocno_objects;
now a vector of ira_object_t. All uses changed.
(build_conflict_bit_table): Changed to take into account that
conflicts are now tracked for objects.
(process_regs_for_copy, propagate_copies, build_allocno_conflicts)
(print_allocno_conflicts, ira_build_conflicts): Likewise.
* ira-color.c (assign_hard_reg, setup_allocno_available_regs_num)
setup_allocno_left_conflicts_size, allocno_reload_assign,
fast_allocation): Likewise.
* ira-lives.c (make_hard_regno_born, make_allocno_born)
process_single_reg_class_operands, process_bb_node_lives): Likewise.
* ira-emit.c (modify_move_list, add_range_and_copies_from_move_list):
Likewise.
* ira-build.c (ira_objects_num): New variable.
(ira_object_id_map): Renamed from ira_conflict_id_allocno_map; now
contains a vector of ira_object_t; all uses changed.
(ira_object_id_map_vec): Corresponding change.
(object_pool): New static variable.
(initiate_allocnos): Initialize it.
(finish_allocnos): Free it.
(ira_create_object, ira_create_allocno_object, create_allocno_objects):
New functions.
(ira_create_allocno): Don't set members that were removed.
(ira_set_allocno_cover_class): Don't change conflict hard regs.
(merge_hard_reg_conflicts): Changed to take into account that
conflicts are now tracked for objects.
(ira_conflict_vector_profitable_p, ira_allocate_conflict_vec,
allocate_conflict_bit_vec, ira_allocate_object_conflicts,
compress_conflict_vecs, remove_low_level_allocnos, ira_flattening,
setup_min_max_allocno_live_range_point, allocno_range_compare_func,
setup_min_max_conflict_allocno_ids, ): Likewise.
((add_to_conflicts): Renamed from add_to_allocno_conflicts, args changed
to ira_object_t; all callers changed.
(ira_add_conflict): Renamed from ira_add_allocno_conflict, args changed
to ira_object_t, all callers changed.
(clear_conflicts): Renamed from clear_allocno_conflicts, arg changed
to ira_object_t, all callers changed.
(conflict_check, curr_conflict_check_tick): Renamed from
allocno_conflict_check and curr_allocno_conflict_check_tick; all uses
changed.
(compress_conflict_vec): Renamed from compress_allocno_conflict_vec,
arg changed to ira_object_t, all callers changed.
(create_cap_allocno): Call ira_create_allocno_object.
(finish_allocno): Free the corresponding object.
(sort_conflict_id_map): Renamed from sort_conflict_id_allocno_map; all
callers changed. Adjusted for dealing with objects.
(ira_build): Call create_allocno_objects after ira_costs. Adjusted for
dealing with objects.
* ira.c (ira_bad_reload_regno_1): Adjusted for dealing with objects.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162166 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ira-build.c')
-rw-r--r-- | gcc/ira-build.c | 459 |
1 files changed, 264 insertions, 195 deletions
diff --git a/gcc/ira-build.c b/gcc/ira-build.c index 01f5ad75020..34e3149af0d 100644 --- a/gcc/ira-build.c +++ b/gcc/ira-build.c @@ -72,9 +72,12 @@ ira_allocno_t *ira_allocnos; /* Sizes of the previous array. */ int ira_allocnos_num; -/* Map conflict id -> allocno with given conflict id (see comments for - allocno member `conflict_id'). */ -ira_allocno_t *ira_conflict_id_allocno_map; +/* Count of conflict record structures we've created, used when creating + a new conflict id. */ +int ira_objects_num; + +/* Map a conflict id to its conflict record. */ +ira_object_t *ira_object_id_map; /* Array of references to all copies. The order number of the copy corresponds to the index in the array. Removed copies have NULL @@ -381,19 +384,18 @@ rebuild_regno_allocno_maps (void) loop_tree_node->regno_allocno_map[regno] = a; } } - -/* Pools for allocnos and live ranges. */ -static alloc_pool allocno_pool, live_range_pool; +/* Pools for allocnos, allocno live ranges and objects. */ +static alloc_pool allocno_pool, live_range_pool, object_pool; /* Vec containing references to all created allocnos. It is a container of array allocnos. */ static VEC(ira_allocno_t,heap) *allocno_vec; -/* Vec containing references to all created allocnos. It is a - container of ira_conflict_id_allocno_map. */ -static VEC(ira_allocno_t,heap) *ira_conflict_id_allocno_map_vec; +/* Vec containing references to all created ira_objects. It is a + container of ira_object_id_map. */ +static VEC(ira_object_t,heap) *ira_object_id_map_vec; /* Initialize data concerning allocnos. */ static void @@ -404,17 +406,48 @@ initiate_allocnos (void) sizeof (struct live_range), 100); allocno_pool = create_alloc_pool ("allocnos", sizeof (struct ira_allocno), 100); + object_pool + = create_alloc_pool ("objects", sizeof (struct ira_object), 100); allocno_vec = VEC_alloc (ira_allocno_t, heap, max_reg_num () * 2); ira_allocnos = NULL; ira_allocnos_num = 0; - ira_conflict_id_allocno_map_vec - = VEC_alloc (ira_allocno_t, heap, max_reg_num () * 2); - ira_conflict_id_allocno_map = NULL; + ira_objects_num = 0; + ira_object_id_map_vec + = VEC_alloc (ira_object_t, heap, max_reg_num () * 2); + ira_object_id_map = NULL; ira_regno_allocno_map = (ira_allocno_t *) ira_allocate (max_reg_num () * sizeof (ira_allocno_t)); memset (ira_regno_allocno_map, 0, max_reg_num () * sizeof (ira_allocno_t)); } +/* Create and return an object corresponding to a new allocno A. */ +static ira_object_t +ira_create_object (ira_allocno_t a) +{ + enum reg_class cover_class = ALLOCNO_COVER_CLASS (a); + ira_object_t obj = (ira_object_t) pool_alloc (object_pool); + + OBJECT_ALLOCNO (obj) = a; + OBJECT_CONFLICT_ID (obj) = ira_objects_num; + OBJECT_CONFLICT_VEC_P (obj) = false; + OBJECT_CONFLICT_ARRAY (obj) = NULL; + OBJECT_NUM_CONFLICTS (obj) = 0; + COPY_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj), ira_no_alloc_regs); + COPY_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), ira_no_alloc_regs); + IOR_COMPL_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj), + reg_class_contents[cover_class]); + IOR_COMPL_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), + reg_class_contents[cover_class]); + OBJECT_MIN (obj) = INT_MAX; + OBJECT_MAX (obj) = -1; + + VEC_safe_push (ira_object_t, heap, ira_object_id_map_vec, obj); + ira_object_id_map + = VEC_address (ira_object_t, ira_object_id_map_vec); + ira_objects_num = VEC_length (ira_object_t, ira_object_id_map_vec); + return obj; +} + /* Create and return the allocno corresponding to REGNO in LOOP_TREE_NODE. Add the allocno to the list of allocnos with the same regno if CAP_P is FALSE. */ @@ -440,10 +473,6 @@ ira_create_allocno (int regno, bool cap_p, ira_loop_tree_node_t loop_tree_node) ALLOCNO_CAP_MEMBER (a) = NULL; ALLOCNO_NUM (a) = ira_allocnos_num; bitmap_set_bit (loop_tree_node->all_allocnos, ALLOCNO_NUM (a)); - ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a) = NULL; - ALLOCNO_CONFLICT_ALLOCNOS_NUM (a) = 0; - COPY_HARD_REG_SET (ALLOCNO_CONFLICT_HARD_REGS (a), ira_no_alloc_regs); - COPY_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a), ira_no_alloc_regs); ALLOCNO_NREFS (a) = 0; ALLOCNO_FREQ (a) = 0; ALLOCNO_HARD_REGNO (a) = -1; @@ -463,7 +492,6 @@ ira_create_allocno (int regno, bool cap_p, ira_loop_tree_node_t loop_tree_node) ALLOCNO_ASSIGNED_P (a) = false; ALLOCNO_MAY_BE_SPILLED_P (a) = false; ALLOCNO_SPLAY_REMOVED_P (a) = false; - ALLOCNO_CONFLICT_VEC_P (a) = false; ALLOCNO_MODE (a) = (regno < 0 ? VOIDmode : PSEUDO_REGNO_MODE (regno)); ALLOCNO_COPIES (a) = NULL; ALLOCNO_HARD_REG_COSTS (a) = NULL; @@ -482,15 +510,10 @@ ira_create_allocno (int regno, bool cap_p, ira_loop_tree_node_t loop_tree_node) ALLOCNO_FIRST_COALESCED_ALLOCNO (a) = a; ALLOCNO_NEXT_COALESCED_ALLOCNO (a) = a; ALLOCNO_LIVE_RANGES (a) = NULL; - ALLOCNO_MIN (a) = INT_MAX; - ALLOCNO_MAX (a) = -1; - ALLOCNO_CONFLICT_ID (a) = ira_allocnos_num; + VEC_safe_push (ira_allocno_t, heap, allocno_vec, a); ira_allocnos = VEC_address (ira_allocno_t, allocno_vec); ira_allocnos_num = VEC_length (ira_allocno_t, allocno_vec); - VEC_safe_push (ira_allocno_t, heap, ira_conflict_id_allocno_map_vec, a); - ira_conflict_id_allocno_map - = VEC_address (ira_allocno_t, ira_conflict_id_allocno_map_vec); return a; } @@ -499,10 +522,24 @@ void ira_set_allocno_cover_class (ira_allocno_t a, enum reg_class cover_class) { ALLOCNO_COVER_CLASS (a) = cover_class; - IOR_COMPL_HARD_REG_SET (ALLOCNO_CONFLICT_HARD_REGS (a), - reg_class_contents[cover_class]); - IOR_COMPL_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a), - reg_class_contents[cover_class]); +} + +/* Allocate an object for allocno A and set ALLOCNO_OBJECT. */ +void +ira_create_allocno_object (ira_allocno_t a) +{ + ALLOCNO_OBJECT (a) = ira_create_object (a); +} + +/* For each allocno, create the corresponding ALLOCNO_OBJECT structure. */ +static void +create_allocno_objects (void) +{ + ira_allocno_t a; + ira_allocno_iterator ai; + + FOR_EACH_ALLOCNO (a, ai) + ira_create_allocno_object (a); } /* Merge hard register conflicts from allocno FROM into allocno TO. If @@ -511,11 +548,13 @@ static void merge_hard_reg_conflicts (ira_allocno_t from, ira_allocno_t to, bool total_only) { + ira_object_t from_obj = ALLOCNO_OBJECT (from); + ira_object_t to_obj = ALLOCNO_OBJECT (to); if (!total_only) - IOR_HARD_REG_SET (ALLOCNO_CONFLICT_HARD_REGS (to), - ALLOCNO_CONFLICT_HARD_REGS (from)); - IOR_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (to), - ALLOCNO_TOTAL_CONFLICT_HARD_REGS (from)); + IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (to_obj), + OBJECT_CONFLICT_HARD_REGS (from_obj)); + IOR_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (to_obj), + OBJECT_TOTAL_CONFLICT_HARD_REGS (from_obj)); #ifdef STACK_REGS if (!total_only && ALLOCNO_NO_STACK_REG_P (from)) ALLOCNO_NO_STACK_REG_P (to) = true; @@ -524,111 +563,110 @@ merge_hard_reg_conflicts (ira_allocno_t from, ira_allocno_t to, #endif } -/* Return TRUE if the conflict vector with NUM elements is more - profitable than conflict bit vector for A. */ +/* Return TRUE if a conflict vector with NUM elements is more + profitable than a conflict bit vector for OBJ. */ bool -ira_conflict_vector_profitable_p (ira_allocno_t a, int num) +ira_conflict_vector_profitable_p (ira_object_t obj, int num) { int nw; + int max = OBJECT_MAX (obj); + int min = OBJECT_MIN (obj); - if (ALLOCNO_MAX (a) < ALLOCNO_MIN (a)) - /* We prefer bit vector in such case because it does not result in - allocation. */ + if (max < min) + /* We prefer a bit vector in such case because it does not result + in allocation. */ return false; - nw = (ALLOCNO_MAX (a) - ALLOCNO_MIN (a) + IRA_INT_BITS) / IRA_INT_BITS; - return (2 * sizeof (ira_allocno_t) * (num + 1) + nw = (max - min + IRA_INT_BITS) / IRA_INT_BITS; + return (2 * sizeof (ira_object_t) * (num + 1) < 3 * nw * sizeof (IRA_INT_TYPE)); } -/* Allocates and initialize the conflict vector of A for NUM - conflicting allocnos. */ +/* Allocates and initialize the conflict vector of OBJ for NUM + conflicting objects. */ void -ira_allocate_allocno_conflict_vec (ira_allocno_t a, int num) +ira_allocate_conflict_vec (ira_object_t obj, int num) { int size; - ira_allocno_t *vec; + ira_object_t *vec; - ira_assert (ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a) == NULL); + ira_assert (OBJECT_CONFLICT_ARRAY (obj) == NULL); num++; /* for NULL end marker */ - size = sizeof (ira_allocno_t) * num; - ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a) = ira_allocate (size); - vec = (ira_allocno_t *) ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a); + size = sizeof (ira_object_t) * num; + OBJECT_CONFLICT_ARRAY (obj) = ira_allocate (size); + vec = (ira_object_t *) OBJECT_CONFLICT_ARRAY (obj); vec[0] = NULL; - ALLOCNO_CONFLICT_ALLOCNOS_NUM (a) = 0; - ALLOCNO_CONFLICT_ALLOCNO_ARRAY_SIZE (a) = size; - ALLOCNO_CONFLICT_VEC_P (a) = true; + OBJECT_NUM_CONFLICTS (obj) = 0; + OBJECT_CONFLICT_ARRAY_SIZE (obj) = size; + OBJECT_CONFLICT_VEC_P (obj) = true; } -/* Allocate and initialize the conflict bit vector of A. */ +/* Allocate and initialize the conflict bit vector of OBJ. */ static void -allocate_allocno_conflict_bit_vec (ira_allocno_t a) +allocate_conflict_bit_vec (ira_object_t obj) { unsigned int size; - ira_assert (ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a) == NULL); - size = ((ALLOCNO_MAX (a) - ALLOCNO_MIN (a) + IRA_INT_BITS) + ira_assert (OBJECT_CONFLICT_ARRAY (obj) == NULL); + size = ((OBJECT_MAX (obj) - OBJECT_MIN (obj) + IRA_INT_BITS) / IRA_INT_BITS * sizeof (IRA_INT_TYPE)); - ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a) = ira_allocate (size); - memset (ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a), 0, size); - ALLOCNO_CONFLICT_ALLOCNO_ARRAY_SIZE (a) = size; - ALLOCNO_CONFLICT_VEC_P (a) = false; + OBJECT_CONFLICT_ARRAY (obj) = ira_allocate (size); + memset (OBJECT_CONFLICT_ARRAY (obj), 0, size); + OBJECT_CONFLICT_ARRAY_SIZE (obj) = size; + OBJECT_CONFLICT_VEC_P (obj) = false; } /* Allocate and initialize the conflict vector or conflict bit vector of A for NUM conflicting allocnos whatever is more profitable. */ void -ira_allocate_allocno_conflicts (ira_allocno_t a, int num) +ira_allocate_object_conflicts (ira_object_t a, int num) { if (ira_conflict_vector_profitable_p (a, num)) - ira_allocate_allocno_conflict_vec (a, num); + ira_allocate_conflict_vec (a, num); else - allocate_allocno_conflict_bit_vec (a); + allocate_conflict_bit_vec (a); } -/* Add A2 to the conflicts of A1. */ +/* Add OBJ2 to the conflicts of OBJ1. */ static void -add_to_allocno_conflicts (ira_allocno_t a1, ira_allocno_t a2) +add_to_conflicts (ira_object_t obj1, ira_object_t obj2) { int num; unsigned int size; - if (ALLOCNO_CONFLICT_VEC_P (a1)) + if (OBJECT_CONFLICT_VEC_P (obj1)) { - ira_allocno_t *vec; - - num = ALLOCNO_CONFLICT_ALLOCNOS_NUM (a1) + 2; - if (ALLOCNO_CONFLICT_ALLOCNO_ARRAY_SIZE (a1) - >= num * sizeof (ira_allocno_t)) - vec = (ira_allocno_t *) ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a1); - else + ira_object_t *vec = OBJECT_CONFLICT_VEC (obj1); + int curr_num = OBJECT_NUM_CONFLICTS (obj1); + num = curr_num + 2; + if (OBJECT_CONFLICT_ARRAY_SIZE (obj1) < num * sizeof (ira_object_t)) { + ira_object_t *newvec; size = (3 * num / 2 + 1) * sizeof (ira_allocno_t); - vec = (ira_allocno_t *) ira_allocate (size); - memcpy (vec, ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a1), - sizeof (ira_allocno_t) * ALLOCNO_CONFLICT_ALLOCNOS_NUM (a1)); - ira_free (ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a1)); - ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a1) = vec; - ALLOCNO_CONFLICT_ALLOCNO_ARRAY_SIZE (a1) = size; + newvec = (ira_object_t *) ira_allocate (size); + memcpy (newvec, vec, curr_num * sizeof (ira_object_t)); + ira_free (vec); + vec = newvec; + OBJECT_CONFLICT_ARRAY (obj1) = vec; + OBJECT_CONFLICT_ARRAY_SIZE (obj1) = size; } - vec[num - 2] = a2; + vec[num - 2] = obj2; vec[num - 1] = NULL; - ALLOCNO_CONFLICT_ALLOCNOS_NUM (a1)++; + OBJECT_NUM_CONFLICTS (obj1)++; } else { int nw, added_head_nw, id; - IRA_INT_TYPE *vec; + IRA_INT_TYPE *vec = OBJECT_CONFLICT_BITVEC (obj1); - id = ALLOCNO_CONFLICT_ID (a2); - vec = (IRA_INT_TYPE *) ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a1); - if (ALLOCNO_MIN (a1) > id) + id = OBJECT_CONFLICT_ID (obj2); + if (OBJECT_MIN (obj1) > id) { /* Expand head of the bit vector. */ - added_head_nw = (ALLOCNO_MIN (a1) - id - 1) / IRA_INT_BITS + 1; - nw = (ALLOCNO_MAX (a1) - ALLOCNO_MIN (a1)) / IRA_INT_BITS + 1; + added_head_nw = (OBJECT_MIN (obj1) - id - 1) / IRA_INT_BITS + 1; + nw = (OBJECT_MAX (obj1) - OBJECT_MIN (obj1)) / IRA_INT_BITS + 1; size = (nw + added_head_nw) * sizeof (IRA_INT_TYPE); - if (ALLOCNO_CONFLICT_ALLOCNO_ARRAY_SIZE (a1) >= size) + if (OBJECT_CONFLICT_ARRAY_SIZE (obj1) >= size) { memmove ((char *) vec + added_head_nw * sizeof (IRA_INT_TYPE), vec, nw * sizeof (IRA_INT_TYPE)); @@ -640,97 +678,93 @@ add_to_allocno_conflicts (ira_allocno_t a1, ira_allocno_t a2) = (3 * (nw + added_head_nw) / 2 + 1) * sizeof (IRA_INT_TYPE); vec = (IRA_INT_TYPE *) ira_allocate (size); memcpy ((char *) vec + added_head_nw * sizeof (IRA_INT_TYPE), - ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a1), - nw * sizeof (IRA_INT_TYPE)); + OBJECT_CONFLICT_ARRAY (obj1), nw * sizeof (IRA_INT_TYPE)); memset (vec, 0, added_head_nw * sizeof (IRA_INT_TYPE)); memset ((char *) vec + (nw + added_head_nw) * sizeof (IRA_INT_TYPE), 0, size - (nw + added_head_nw) * sizeof (IRA_INT_TYPE)); - ira_free (ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a1)); - ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a1) = vec; - ALLOCNO_CONFLICT_ALLOCNO_ARRAY_SIZE (a1) = size; + ira_free (OBJECT_CONFLICT_ARRAY (obj1)); + OBJECT_CONFLICT_ARRAY (obj1) = vec; + OBJECT_CONFLICT_ARRAY_SIZE (obj1) = size; } - ALLOCNO_MIN (a1) -= added_head_nw * IRA_INT_BITS; + OBJECT_MIN (obj1) -= added_head_nw * IRA_INT_BITS; } - else if (ALLOCNO_MAX (a1) < id) + else if (OBJECT_MAX (obj1) < id) { - nw = (id - ALLOCNO_MIN (a1)) / IRA_INT_BITS + 1; + nw = (id - OBJECT_MIN (obj1)) / IRA_INT_BITS + 1; size = nw * sizeof (IRA_INT_TYPE); - if (ALLOCNO_CONFLICT_ALLOCNO_ARRAY_SIZE (a1) < size) + if (OBJECT_CONFLICT_ARRAY_SIZE (obj1) < size) { /* Expand tail of the bit vector. */ size = (3 * nw / 2 + 1) * sizeof (IRA_INT_TYPE); vec = (IRA_INT_TYPE *) ira_allocate (size); - memcpy (vec, ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a1), - ALLOCNO_CONFLICT_ALLOCNO_ARRAY_SIZE (a1)); - memset ((char *) vec + ALLOCNO_CONFLICT_ALLOCNO_ARRAY_SIZE (a1), - 0, size - ALLOCNO_CONFLICT_ALLOCNO_ARRAY_SIZE (a1)); - ira_free (ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a1)); - ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a1) = vec; - ALLOCNO_CONFLICT_ALLOCNO_ARRAY_SIZE (a1) = size; + memcpy (vec, OBJECT_CONFLICT_ARRAY (obj1), OBJECT_CONFLICT_ARRAY_SIZE (obj1)); + memset ((char *) vec + OBJECT_CONFLICT_ARRAY_SIZE (obj1), + 0, size - OBJECT_CONFLICT_ARRAY_SIZE (obj1)); + ira_free (OBJECT_CONFLICT_ARRAY (obj1)); + OBJECT_CONFLICT_ARRAY (obj1) = vec; + OBJECT_CONFLICT_ARRAY_SIZE (obj1) = size; } - ALLOCNO_MAX (a1) = id; + OBJECT_MAX (obj1) = id; } - SET_MINMAX_SET_BIT (vec, id, ALLOCNO_MIN (a1), ALLOCNO_MAX (a1)); + SET_MINMAX_SET_BIT (vec, id, OBJECT_MIN (obj1), OBJECT_MAX (obj1)); } } -/* Add A1 to the conflicts of A2 and vise versa. */ -void -ira_add_allocno_conflict (ira_allocno_t a1, ira_allocno_t a2) +/* Add OBJ1 to the conflicts of OBJ2 and vice versa. */ +static void +ira_add_conflict (ira_object_t obj1, ira_object_t obj2) { - add_to_allocno_conflicts (a1, a2); - add_to_allocno_conflicts (a2, a1); + add_to_conflicts (obj1, obj2); + add_to_conflicts (obj2, obj1); } -/* Clear all conflicts of allocno A. */ +/* Clear all conflicts of OBJ. */ static void -clear_allocno_conflicts (ira_allocno_t a) +clear_conflicts (ira_object_t obj) { - if (ALLOCNO_CONFLICT_VEC_P (a)) + if (OBJECT_CONFLICT_VEC_P (obj)) { - ALLOCNO_CONFLICT_ALLOCNOS_NUM (a) = 0; - ((ira_allocno_t *) ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a))[0] = NULL; + OBJECT_NUM_CONFLICTS (obj) = 0; + OBJECT_CONFLICT_VEC (obj)[0] = NULL; } - else if (ALLOCNO_CONFLICT_ALLOCNO_ARRAY_SIZE (a) != 0) + else if (OBJECT_CONFLICT_ARRAY_SIZE (obj) != 0) { int nw; - nw = (ALLOCNO_MAX (a) - ALLOCNO_MIN (a)) / IRA_INT_BITS + 1; - memset (ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a), 0, - nw * sizeof (IRA_INT_TYPE)); + nw = (OBJECT_MAX (obj) - OBJECT_MIN (obj)) / IRA_INT_BITS + 1; + memset (OBJECT_CONFLICT_BITVEC (obj), 0, nw * sizeof (IRA_INT_TYPE)); } } /* The array used to find duplications in conflict vectors of allocnos. */ -static int *allocno_conflict_check; +static int *conflict_check; /* The value used to mark allocation presence in conflict vector of the current allocno. */ -static int curr_allocno_conflict_check_tick; +static int curr_conflict_check_tick; -/* Remove duplications in conflict vector of A. */ +/* Remove duplications in conflict vector of OBJ. */ static void -compress_allocno_conflict_vec (ira_allocno_t a) +compress_conflict_vec (ira_object_t obj) { - ira_allocno_t *vec, conflict_a; + ira_object_t *vec, conflict_obj; int i, j; - ira_assert (ALLOCNO_CONFLICT_VEC_P (a)); - vec = (ira_allocno_t *) ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a); - curr_allocno_conflict_check_tick++; - for (i = j = 0; (conflict_a = vec[i]) != NULL; i++) + ira_assert (OBJECT_CONFLICT_VEC_P (obj)); + vec = OBJECT_CONFLICT_VEC (obj); + curr_conflict_check_tick++; + for (i = j = 0; (conflict_obj = vec[i]) != NULL; i++) { - if (allocno_conflict_check[ALLOCNO_NUM (conflict_a)] - != curr_allocno_conflict_check_tick) + int id = OBJECT_CONFLICT_ID (conflict_obj); + if (conflict_check[id] != curr_conflict_check_tick) { - allocno_conflict_check[ALLOCNO_NUM (conflict_a)] - = curr_allocno_conflict_check_tick; - vec[j++] = conflict_a; + conflict_check[id] = curr_conflict_check_tick; + vec[j++] = conflict_obj; } } - ALLOCNO_CONFLICT_ALLOCNOS_NUM (a) = j; + OBJECT_NUM_CONFLICTS (obj) = j; vec[j] = NULL; } @@ -741,14 +775,16 @@ compress_conflict_vecs (void) ira_allocno_t a; ira_allocno_iterator ai; - allocno_conflict_check - = (int *) ira_allocate (sizeof (int) * ira_allocnos_num); - memset (allocno_conflict_check, 0, sizeof (int) * ira_allocnos_num); - curr_allocno_conflict_check_tick = 0; + conflict_check = (int *) ira_allocate (sizeof (int) * ira_objects_num); + memset (conflict_check, 0, sizeof (int) * ira_objects_num); + curr_conflict_check_tick = 0; FOR_EACH_ALLOCNO (a, ai) - if (ALLOCNO_CONFLICT_VEC_P (a)) - compress_allocno_conflict_vec (a); - ira_free (allocno_conflict_check); + { + ira_object_t obj = ALLOCNO_OBJECT (a); + if (OBJECT_CONFLICT_VEC_P (obj)) + compress_conflict_vec (obj); + } + ira_free (conflict_check); } /* This recursive function outputs allocno A and if it is a cap the @@ -787,6 +823,7 @@ create_cap_allocno (ira_allocno_t a) ALLOCNO_MODE (cap) = ALLOCNO_MODE (a); cover_class = ALLOCNO_COVER_CLASS (a); ira_set_allocno_cover_class (cap, cover_class); + ira_create_allocno_object (cap); ALLOCNO_AVAILABLE_REGS_NUM (cap) = ALLOCNO_AVAILABLE_REGS_NUM (a); ALLOCNO_CAP_MEMBER (cap) = a; ALLOCNO_CAP (a) = cap; @@ -995,11 +1032,9 @@ static void finish_allocno (ira_allocno_t a) { enum reg_class cover_class = ALLOCNO_COVER_CLASS (a); + ira_object_t obj = ALLOCNO_OBJECT (a); ira_allocnos[ALLOCNO_NUM (a)] = NULL; - ira_conflict_id_allocno_map[ALLOCNO_CONFLICT_ID (a)] = NULL; - if (ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a) != NULL) - ira_free (ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a)); if (ALLOCNO_HARD_REG_COSTS (a) != NULL) ira_free_cost_vector (ALLOCNO_HARD_REG_COSTS (a), cover_class); if (ALLOCNO_CONFLICT_HARD_REG_COSTS (a) != NULL) @@ -1011,6 +1046,11 @@ finish_allocno (ira_allocno_t a) cover_class); ira_finish_allocno_live_range_list (ALLOCNO_LIVE_RANGES (a)); pool_free (allocno_pool, a); + + ira_object_id_map[OBJECT_CONFLICT_ID (obj)] = NULL; + if (OBJECT_CONFLICT_ARRAY (obj) != NULL) + ira_free (OBJECT_CONFLICT_ARRAY (obj)); + pool_free (object_pool, obj); } /* Free the memory allocated for all allocnos. */ @@ -1023,9 +1063,10 @@ finish_allocnos (void) FOR_EACH_ALLOCNO (a, ai) finish_allocno (a); ira_free (ira_regno_allocno_map); - VEC_free (ira_allocno_t, heap, ira_conflict_id_allocno_map_vec); + VEC_free (ira_object_t, heap, ira_object_id_map_vec); VEC_free (ira_allocno_t, heap, allocno_vec); free_alloc_pool (allocno_pool); + free_alloc_pool (object_pool); free_alloc_pool (live_range_pool); } @@ -2080,11 +2121,13 @@ remove_low_level_allocnos (void) regno = ALLOCNO_REGNO (a); if (ira_loop_tree_root->regno_allocno_map[regno] == a) { + ira_object_t obj = ALLOCNO_OBJECT (a); + ira_regno_allocno_map[regno] = a; ALLOCNO_NEXT_REGNO_ALLOCNO (a) = NULL; ALLOCNO_CAP_MEMBER (a) = NULL; - COPY_HARD_REG_SET (ALLOCNO_CONFLICT_HARD_REGS (a), - ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a)); + COPY_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj), + OBJECT_TOTAL_CONFLICT_HARD_REGS (obj)); #ifdef STACK_REGS if (ALLOCNO_TOTAL_NO_STACK_REG_P (a)) ALLOCNO_NO_STACK_REG_P (a) = true; @@ -2203,20 +2246,24 @@ setup_min_max_allocno_live_range_point (void) FOR_EACH_ALLOCNO (a, ai) { + ira_object_t obj = ALLOCNO_OBJECT (a); r = ALLOCNO_LIVE_RANGES (a); if (r == NULL) continue; - ALLOCNO_MAX (a) = r->finish; + OBJECT_MAX (obj) = r->finish; for (; r->next != NULL; r = r->next) ; - ALLOCNO_MIN (a) = r->start; + OBJECT_MIN (obj) = r->start; } for (i = max_reg_num () - 1; i >= FIRST_PSEUDO_REGISTER; i--) for (a = ira_regno_allocno_map[i]; a != NULL; a = ALLOCNO_NEXT_REGNO_ALLOCNO (a)) { - if (ALLOCNO_MAX (a) < 0) + ira_object_t obj = ALLOCNO_OBJECT (a); + ira_object_t parent_obj; + + if (OBJECT_MAX (obj) < 0) continue; ira_assert (ALLOCNO_CAP_MEMBER (a) == NULL); /* Accumulation of range info. */ @@ -2224,26 +2271,29 @@ setup_min_max_allocno_live_range_point (void) { for (cap = ALLOCNO_CAP (a); cap != NULL; cap = ALLOCNO_CAP (cap)) { - if (ALLOCNO_MAX (cap) < ALLOCNO_MAX (a)) - ALLOCNO_MAX (cap) = ALLOCNO_MAX (a); - if (ALLOCNO_MIN (cap) > ALLOCNO_MIN (a)) - ALLOCNO_MIN (cap) = ALLOCNO_MIN (a); + ira_object_t cap_obj = ALLOCNO_OBJECT (cap); + if (OBJECT_MAX (cap_obj) < OBJECT_MAX (obj)) + OBJECT_MAX (cap_obj) = OBJECT_MAX (obj); + if (OBJECT_MIN (cap_obj) > OBJECT_MIN (obj)) + OBJECT_MIN (cap_obj) = OBJECT_MIN (obj); } continue; } if ((parent = ALLOCNO_LOOP_TREE_NODE (a)->parent) == NULL) continue; parent_a = parent->regno_allocno_map[i]; - if (ALLOCNO_MAX (parent_a) < ALLOCNO_MAX (a)) - ALLOCNO_MAX (parent_a) = ALLOCNO_MAX (a); - if (ALLOCNO_MIN (parent_a) > ALLOCNO_MIN (a)) - ALLOCNO_MIN (parent_a) = ALLOCNO_MIN (a); + parent_obj = ALLOCNO_OBJECT (parent_a); + if (OBJECT_MAX (parent_obj) < OBJECT_MAX (obj)) + OBJECT_MAX (parent_obj) = OBJECT_MAX (obj); + if (OBJECT_MIN (parent_obj) > OBJECT_MIN (obj)) + OBJECT_MIN (parent_obj) = OBJECT_MIN (obj); } #ifdef ENABLE_IRA_CHECKING FOR_EACH_ALLOCNO (a, ai) { - if ((0 <= ALLOCNO_MIN (a) && ALLOCNO_MIN (a) <= ira_max_point) - && (0 <= ALLOCNO_MAX (a) && ALLOCNO_MAX (a) <= ira_max_point)) + ira_object_t obj = ALLOCNO_OBJECT (a); + if ((0 <= OBJECT_MIN (obj) && OBJECT_MIN (obj) <= ira_max_point) + && (0 <= OBJECT_MAX (obj) && OBJECT_MAX (obj) <= ira_max_point)) continue; gcc_unreachable (); } @@ -2252,30 +2302,31 @@ setup_min_max_allocno_live_range_point (void) /* Sort allocnos according to their live ranges. Allocnos with smaller cover class are put first unless we use priority coloring. - Allocnos with the same cove class are ordered according their start + Allocnos with the same cover class are ordered according their start (min). Allocnos with the same start are ordered according their finish (max). */ static int allocno_range_compare_func (const void *v1p, const void *v2p) { int diff; - ira_allocno_t a1 = *(const ira_allocno_t *) v1p; - ira_allocno_t a2 = *(const ira_allocno_t *) v2p; + ira_object_t obj1 = *(const ira_object_t *) v1p; + ira_object_t obj2 = *(const ira_object_t *) v2p; + ira_allocno_t a1 = OBJECT_ALLOCNO (obj1); + ira_allocno_t a2 = OBJECT_ALLOCNO (obj2); if (flag_ira_algorithm != IRA_ALGORITHM_PRIORITY && (diff = ALLOCNO_COVER_CLASS (a1) - ALLOCNO_COVER_CLASS (a2)) != 0) return diff; - if ((diff = ALLOCNO_MIN (a1) - ALLOCNO_MIN (a2)) != 0) + if ((diff = OBJECT_MIN (obj1) - OBJECT_MIN (obj2)) != 0) return diff; - if ((diff = ALLOCNO_MAX (a1) - ALLOCNO_MAX (a2)) != 0) + if ((diff = OBJECT_MAX (obj1) - OBJECT_MAX (obj2)) != 0) return diff; return ALLOCNO_NUM (a1) - ALLOCNO_NUM (a2); } -/* Sort ira_conflict_id_allocno_map and set up conflict id of - allocnos. */ +/* Sort ira_object_id_map and set up conflict id of allocnos. */ static void -sort_conflict_id_allocno_map (void) +sort_conflict_id_map (void) { int i, num; ira_allocno_t a; @@ -2283,14 +2334,17 @@ sort_conflict_id_allocno_map (void) num = 0; FOR_EACH_ALLOCNO (a, ai) - ira_conflict_id_allocno_map[num++] = a; - qsort (ira_conflict_id_allocno_map, num, sizeof (ira_allocno_t), + ira_object_id_map[num++] = ALLOCNO_OBJECT (a); + qsort (ira_object_id_map, num, sizeof (ira_object_t), allocno_range_compare_func); for (i = 0; i < num; i++) - if ((a = ira_conflict_id_allocno_map[i]) != NULL) - ALLOCNO_CONFLICT_ID (a) = i; - for (i = num; i < ira_allocnos_num; i++) - ira_conflict_id_allocno_map[i] = NULL; + { + ira_object_t obj = ira_object_id_map[i]; + gcc_assert (obj != NULL); + OBJECT_CONFLICT_ID (obj) = i; + } + for (i = num; i < ira_objects_num; i++) + ira_object_id_map[i] = NULL; } /* Set up minimal and maximal conflict ids of allocnos with which @@ -2303,14 +2357,17 @@ setup_min_max_conflict_allocno_ids (void) int *live_range_min, *last_lived; ira_allocno_t a; - live_range_min = (int *) ira_allocate (sizeof (int) * ira_allocnos_num); + live_range_min = (int *) ira_allocate (sizeof (int) * ira_objects_num); cover_class = -1; first_not_finished = -1; - for (i = 0; i < ira_allocnos_num; i++) + for (i = 0; i < ira_objects_num; i++) { - a = ira_conflict_id_allocno_map[i]; - if (a == NULL) + ira_object_t obj = ira_object_id_map[i]; + if (obj == NULL) continue; + + a = OBJECT_ALLOCNO (obj); + if (cover_class < 0 || (flag_ira_algorithm != IRA_ALGORITHM_PRIORITY && cover_class != (int) ALLOCNO_COVER_CLASS (a))) @@ -2321,13 +2378,13 @@ setup_min_max_conflict_allocno_ids (void) } else { - start = ALLOCNO_MIN (a); + start = OBJECT_MIN (obj); /* If we skip an allocno, the allocno with smaller ids will be also skipped because of the secondary sorting the range finishes (see function allocno_range_compare_func). */ while (first_not_finished < i - && start > ALLOCNO_MAX (ira_conflict_id_allocno_map + && start > OBJECT_MAX (ira_object_id_map [first_not_finished])) first_not_finished++; min = first_not_finished; @@ -2336,17 +2393,19 @@ setup_min_max_conflict_allocno_ids (void) /* We could increase min further in this case but it is good enough. */ min++; - live_range_min[i] = ALLOCNO_MIN (a); - ALLOCNO_MIN (a) = min; + live_range_min[i] = OBJECT_MIN (obj); + OBJECT_MIN (obj) = min; } last_lived = (int *) ira_allocate (sizeof (int) * ira_max_point); cover_class = -1; filled_area_start = -1; - for (i = ira_allocnos_num - 1; i >= 0; i--) + for (i = ira_objects_num - 1; i >= 0; i--) { - a = ira_conflict_id_allocno_map[i]; - if (a == NULL) + ira_object_t obj = ira_object_id_map[i]; + if (obj == NULL) continue; + + a = OBJECT_ALLOCNO (obj); if (cover_class < 0 || (flag_ira_algorithm != IRA_ALGORITHM_PRIORITY && cover_class != (int) ALLOCNO_COVER_CLASS (a))) @@ -2357,13 +2416,13 @@ setup_min_max_conflict_allocno_ids (void) filled_area_start = ira_max_point; } min = live_range_min[i]; - finish = ALLOCNO_MAX (a); + finish = OBJECT_MAX (obj); max = last_lived[finish]; if (max < 0) /* We could decrease max further in this case but it is good enough. */ - max = ALLOCNO_CONFLICT_ID (a) - 1; - ALLOCNO_MAX (a) = max; + max = OBJECT_CONFLICT_ID (obj) - 1; + OBJECT_MAX (obj) = max; /* In filling, we can go further A range finish to recognize intersection quickly because if the finish of subsequently processed allocno (it has smaller conflict id) range is @@ -2518,13 +2577,14 @@ ira_flattening (int max_regno_before_emit, int ira_max_point_before_emit) new_pseudos_p = merged_p = false; FOR_EACH_ALLOCNO (a, ai) { + ira_object_t obj = ALLOCNO_OBJECT (a); if (ALLOCNO_CAP_MEMBER (a) != NULL) /* Caps are not in the regno allocno maps and they are never will be transformed into allocnos existing after IR flattening. */ continue; - COPY_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a), - ALLOCNO_CONFLICT_HARD_REGS (a)); + COPY_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), + OBJECT_CONFLICT_HARD_REGS (obj)); #ifdef STACK_REGS ALLOCNO_TOTAL_NO_STACK_REG_P (a) = ALLOCNO_NO_STACK_REG_P (a); #endif @@ -2612,7 +2672,7 @@ ira_flattening (int max_regno_before_emit, int ira_max_point_before_emit) continue; for (r = ALLOCNO_LIVE_RANGES (a); r != NULL; r = r->next) ira_assert (r->allocno == a); - clear_allocno_conflicts (a); + clear_conflicts (ALLOCNO_OBJECT (a)); } allocnos_live = sparseset_alloc (ira_allocnos_num); for (i = 0; i < ira_max_point; i++) @@ -2634,7 +2694,11 @@ ira_flattening (int max_regno_before_emit, int ira_max_point_before_emit) [cover_class][ALLOCNO_COVER_CLASS (live_a)] /* Don't set up conflict for the allocno with itself. */ && num != (int) n) - ira_add_allocno_conflict (a, live_a); + { + ira_object_t obj = ALLOCNO_OBJECT (a); + ira_object_t live_obj = ALLOCNO_OBJECT (live_a); + ira_add_conflict (obj, live_obj); + } } } @@ -2826,6 +2890,7 @@ ira_build (bool loops_p) form_loop_tree (); create_allocnos (); ira_costs (); + create_allocno_objects (); ira_create_allocno_live_ranges (); remove_unnecessary_regions (false); ira_compress_allocno_live_ranges (); @@ -2841,7 +2906,7 @@ ira_build (bool loops_p) check_allocno_creation (); #endif setup_min_max_allocno_live_range_point (); - sort_conflict_id_allocno_map (); + sort_conflict_id_map (); setup_min_max_conflict_allocno_ids (); ira_build_conflicts (); update_conflict_hard_reg_costs (); @@ -2862,9 +2927,10 @@ ira_build (bool loops_p) FOR_EACH_ALLOCNO (a, ai) if (ALLOCNO_CALLS_CROSSED_NUM (a) != 0) { - IOR_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a), + ira_object_t obj = ALLOCNO_OBJECT (a); + IOR_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), call_used_reg_set); - IOR_HARD_REG_SET (ALLOCNO_CONFLICT_HARD_REGS (a), + IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj), call_used_reg_set); } } @@ -2879,7 +2945,10 @@ ira_build (bool loops_p) n = 0; FOR_EACH_ALLOCNO (a, ai) - n += ALLOCNO_CONFLICT_ALLOCNOS_NUM (a); + { + ira_object_t obj = ALLOCNO_OBJECT (a); + n += OBJECT_NUM_CONFLICTS (obj); + } nr = 0; FOR_EACH_ALLOCNO (a, ai) for (r = ALLOCNO_LIVE_RANGES (a); r != NULL; r = r->next) |