comparison gcc/ira-conflicts.c @ 67:f6334be47118

update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
date Tue, 22 Mar 2011 17:18:12 +0900
parents b7f97abdc517
children 04ced10e8804
comparison
equal deleted inserted replaced
65:65488c3d617d 67:f6334be47118
30 #include "flags.h" 30 #include "flags.h"
31 #include "hard-reg-set.h" 31 #include "hard-reg-set.h"
32 #include "basic-block.h" 32 #include "basic-block.h"
33 #include "insn-config.h" 33 #include "insn-config.h"
34 #include "recog.h" 34 #include "recog.h"
35 #include "toplev.h" 35 #include "diagnostic-core.h"
36 #include "params.h" 36 #include "params.h"
37 #include "df.h" 37 #include "df.h"
38 #include "sparseset.h" 38 #include "sparseset.h"
39 #include "ira-int.h" 39 #include "ira-int.h"
40 #include "addresses.h" 40 #include "addresses.h"
45 45
46 /* ira_allocnos_num array of arrays of bits, recording whether two 46 /* ira_allocnos_num array of arrays of bits, recording whether two
47 allocno's conflict (can't go in the same hardware register). 47 allocno's conflict (can't go in the same hardware register).
48 48
49 Some arrays will be used as conflict bit vector of the 49 Some arrays will be used as conflict bit vector of the
50 corresponding allocnos see function build_allocno_conflicts. */ 50 corresponding allocnos see function build_object_conflicts. */
51 static IRA_INT_TYPE **conflicts; 51 static IRA_INT_TYPE **conflicts;
52 52
53 /* Macro to test a conflict of A1 and A2 in `conflicts'. */ 53 /* Macro to test a conflict of C1 and C2 in `conflicts'. */
54 #define CONFLICT_ALLOCNO_P(A1, A2) \ 54 #define OBJECTS_CONFLICT_P(C1, C2) \
55 (ALLOCNO_MIN (A1) <= ALLOCNO_CONFLICT_ID (A2) \ 55 (OBJECT_MIN (C1) <= OBJECT_CONFLICT_ID (C2) \
56 && ALLOCNO_CONFLICT_ID (A2) <= ALLOCNO_MAX (A1) \ 56 && OBJECT_CONFLICT_ID (C2) <= OBJECT_MAX (C1) \
57 && TEST_ALLOCNO_SET_BIT (conflicts[ALLOCNO_NUM (A1)], \ 57 && TEST_MINMAX_SET_BIT (conflicts[OBJECT_CONFLICT_ID (C1)], \
58 ALLOCNO_CONFLICT_ID (A2), \ 58 OBJECT_CONFLICT_ID (C2), \
59 ALLOCNO_MIN (A1), \ 59 OBJECT_MIN (C1), OBJECT_MAX (C1)))
60 ALLOCNO_MAX (A1)))
61 60
62 61
62 /* Record a conflict between objects OBJ1 and OBJ2. If necessary,
63 canonicalize the conflict by recording it for lower-order subobjects
64 of the corresponding allocnos. */
65 static void
66 record_object_conflict (ira_object_t obj1, ira_object_t obj2)
67 {
68 ira_allocno_t a1 = OBJECT_ALLOCNO (obj1);
69 ira_allocno_t a2 = OBJECT_ALLOCNO (obj2);
70 int w1 = OBJECT_SUBWORD (obj1);
71 int w2 = OBJECT_SUBWORD (obj2);
72 int id1, id2;
73
74 /* Canonicalize the conflict. If two identically-numbered words
75 conflict, always record this as a conflict between words 0. That
76 is the only information we need, and it is easier to test for if
77 it is collected in each allocno's lowest-order object. */
78 if (w1 == w2 && w1 > 0)
79 {
80 obj1 = ALLOCNO_OBJECT (a1, 0);
81 obj2 = ALLOCNO_OBJECT (a2, 0);
82 }
83 id1 = OBJECT_CONFLICT_ID (obj1);
84 id2 = OBJECT_CONFLICT_ID (obj2);
85
86 SET_MINMAX_SET_BIT (conflicts[id1], id2, OBJECT_MIN (obj1),
87 OBJECT_MAX (obj1));
88 SET_MINMAX_SET_BIT (conflicts[id2], id1, OBJECT_MIN (obj2),
89 OBJECT_MAX (obj2));
90 }
63 91
64 /* Build allocno conflict table by processing allocno live ranges. 92 /* Build allocno conflict table by processing allocno live ranges.
65 Return true if the table was built. The table is not built if it 93 Return true if the table was built. The table is not built if it
66 is too big. */ 94 is too big. */
67 static bool 95 static bool
68 build_conflict_bit_table (void) 96 build_conflict_bit_table (void)
69 { 97 {
70 int i, num, id, allocated_words_num, conflict_bit_vec_words_num; 98 int i;
71 unsigned int j; 99 unsigned int j;
72 enum reg_class cover_class; 100 enum reg_class cover_class;
73 ira_allocno_t allocno, live_a; 101 int object_set_words, allocated_words_num, conflict_bit_vec_words_num;
74 allocno_live_range_t r; 102 live_range_t r;
103 ira_allocno_t allocno;
75 ira_allocno_iterator ai; 104 ira_allocno_iterator ai;
76 sparseset allocnos_live; 105 sparseset objects_live;
77 int allocno_set_words; 106 ira_object_t obj;
78 107 ira_allocno_object_iterator aoi;
79 allocno_set_words = (ira_allocnos_num + IRA_INT_BITS - 1) / IRA_INT_BITS; 108
80 allocated_words_num = 0; 109 allocated_words_num = 0;
81 FOR_EACH_ALLOCNO (allocno, ai) 110 FOR_EACH_ALLOCNO (allocno, ai)
82 { 111 FOR_EACH_ALLOCNO_OBJECT (allocno, obj, aoi)
83 if (ALLOCNO_MAX (allocno) < ALLOCNO_MIN (allocno)) 112 {
113 if (OBJECT_MAX (obj) < OBJECT_MIN (obj))
84 continue; 114 continue;
85 conflict_bit_vec_words_num 115 conflict_bit_vec_words_num
86 = ((ALLOCNO_MAX (allocno) - ALLOCNO_MIN (allocno) + IRA_INT_BITS) 116 = ((OBJECT_MAX (obj) - OBJECT_MIN (obj) + IRA_INT_BITS)
87 / IRA_INT_BITS); 117 / IRA_INT_BITS);
88 allocated_words_num += conflict_bit_vec_words_num; 118 allocated_words_num += conflict_bit_vec_words_num;
89 if ((unsigned long long) allocated_words_num * sizeof (IRA_INT_TYPE) 119 if ((unsigned long long) allocated_words_num * sizeof (IRA_INT_TYPE)
90 > (unsigned long long) IRA_MAX_CONFLICT_TABLE_SIZE * 1024 * 1024) 120 > (unsigned long long) IRA_MAX_CONFLICT_TABLE_SIZE * 1024 * 1024)
91 { 121 {
92 if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL) 122 if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL)
93 fprintf 123 fprintf
94 (ira_dump_file, 124 (ira_dump_file,
95 "+++Conflict table will be too big(>%dMB) -- don't use it\n", 125 "+++Conflict table will be too big(>%dMB) -- don't use it\n",
96 IRA_MAX_CONFLICT_TABLE_SIZE); 126 IRA_MAX_CONFLICT_TABLE_SIZE);
97 return false; 127 return false;
98 } 128 }
99 } 129 }
100 allocnos_live = sparseset_alloc (ira_allocnos_num); 130
101 conflicts = (IRA_INT_TYPE **) ira_allocate (sizeof (IRA_INT_TYPE *) 131 conflicts = (IRA_INT_TYPE **) ira_allocate (sizeof (IRA_INT_TYPE *)
102 * ira_allocnos_num); 132 * ira_objects_num);
103 allocated_words_num = 0; 133 allocated_words_num = 0;
104 FOR_EACH_ALLOCNO (allocno, ai) 134 FOR_EACH_ALLOCNO (allocno, ai)
105 { 135 FOR_EACH_ALLOCNO_OBJECT (allocno, obj, aoi)
106 num = ALLOCNO_NUM (allocno); 136 {
107 if (ALLOCNO_MAX (allocno) < ALLOCNO_MIN (allocno)) 137 int id = OBJECT_CONFLICT_ID (obj);
108 { 138 if (OBJECT_MAX (obj) < OBJECT_MIN (obj))
109 conflicts[num] = NULL; 139 {
110 continue; 140 conflicts[id] = NULL;
111 } 141 continue;
112 conflict_bit_vec_words_num 142 }
113 = ((ALLOCNO_MAX (allocno) - ALLOCNO_MIN (allocno) + IRA_INT_BITS) 143 conflict_bit_vec_words_num
114 / IRA_INT_BITS); 144 = ((OBJECT_MAX (obj) - OBJECT_MIN (obj) + IRA_INT_BITS)
115 allocated_words_num += conflict_bit_vec_words_num; 145 / IRA_INT_BITS);
116 conflicts[num] 146 allocated_words_num += conflict_bit_vec_words_num;
117 = (IRA_INT_TYPE *) ira_allocate (sizeof (IRA_INT_TYPE) 147 conflicts[id]
118 * conflict_bit_vec_words_num); 148 = (IRA_INT_TYPE *) ira_allocate (sizeof (IRA_INT_TYPE)
119 memset (conflicts[num], 0, 149 * conflict_bit_vec_words_num);
120 sizeof (IRA_INT_TYPE) * conflict_bit_vec_words_num); 150 memset (conflicts[id], 0,
121 } 151 sizeof (IRA_INT_TYPE) * conflict_bit_vec_words_num);
152 }
153
154 object_set_words = (ira_objects_num + IRA_INT_BITS - 1) / IRA_INT_BITS;
122 if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL) 155 if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL)
123 fprintf 156 fprintf
124 (ira_dump_file, 157 (ira_dump_file,
125 "+++Allocating %ld bytes for conflict table (uncompressed size %ld)\n", 158 "+++Allocating %ld bytes for conflict table (uncompressed size %ld)\n",
126 (long) allocated_words_num * sizeof (IRA_INT_TYPE), 159 (long) allocated_words_num * sizeof (IRA_INT_TYPE),
127 (long) allocno_set_words * ira_allocnos_num * sizeof (IRA_INT_TYPE)); 160 (long) object_set_words * ira_objects_num * sizeof (IRA_INT_TYPE));
161
162 objects_live = sparseset_alloc (ira_objects_num);
128 for (i = 0; i < ira_max_point; i++) 163 for (i = 0; i < ira_max_point; i++)
129 { 164 {
130 for (r = ira_start_point_ranges[i]; r != NULL; r = r->start_next) 165 for (r = ira_start_point_ranges[i]; r != NULL; r = r->start_next)
131 { 166 {
132 allocno = r->allocno; 167 ira_object_t obj = r->object;
133 num = ALLOCNO_NUM (allocno); 168 ira_allocno_t allocno = OBJECT_ALLOCNO (obj);
134 id = ALLOCNO_CONFLICT_ID (allocno); 169 int id = OBJECT_CONFLICT_ID (obj);
170
171 gcc_assert (id < ira_objects_num);
172
135 cover_class = ALLOCNO_COVER_CLASS (allocno); 173 cover_class = ALLOCNO_COVER_CLASS (allocno);
136 sparseset_set_bit (allocnos_live, num); 174 sparseset_set_bit (objects_live, id);
137 EXECUTE_IF_SET_IN_SPARSESET (allocnos_live, j) 175 EXECUTE_IF_SET_IN_SPARSESET (objects_live, j)
138 { 176 {
139 live_a = ira_allocnos[j]; 177 ira_object_t live_obj = ira_object_id_map[j];
140 if (ira_reg_classes_intersect_p 178 ira_allocno_t live_a = OBJECT_ALLOCNO (live_obj);
141 [cover_class][ALLOCNO_COVER_CLASS (live_a)] 179 enum reg_class live_cover_class = ALLOCNO_COVER_CLASS (live_a);
180
181 if (ira_reg_classes_intersect_p[cover_class][live_cover_class]
142 /* Don't set up conflict for the allocno with itself. */ 182 /* Don't set up conflict for the allocno with itself. */
143 && num != (int) j) 183 && live_a != allocno)
144 { 184 {
145 SET_ALLOCNO_SET_BIT (conflicts[num], 185 record_object_conflict (obj, live_obj);
146 ALLOCNO_CONFLICT_ID (live_a),
147 ALLOCNO_MIN (allocno),
148 ALLOCNO_MAX (allocno));
149 SET_ALLOCNO_SET_BIT (conflicts[j], id,
150 ALLOCNO_MIN (live_a),
151 ALLOCNO_MAX (live_a));
152 } 186 }
153 } 187 }
154 } 188 }
155 189
156 for (r = ira_finish_point_ranges[i]; r != NULL; r = r->finish_next) 190 for (r = ira_finish_point_ranges[i]; r != NULL; r = r->finish_next)
157 sparseset_clear_bit (allocnos_live, ALLOCNO_NUM (r->allocno)); 191 sparseset_clear_bit (objects_live, OBJECT_CONFLICT_ID (r->object));
158 } 192 }
159 sparseset_free (allocnos_live); 193 sparseset_free (objects_live);
160 return true; 194 return true;
161 } 195 }
162
163 196
197 /* Return true iff allocnos A1 and A2 cannot be allocated to the same
198 register due to conflicts. */
199
200 static bool
201 allocnos_conflict_for_copy_p (ira_allocno_t a1, ira_allocno_t a2)
202 {
203 /* Due to the fact that we canonicalize conflicts (see
204 record_object_conflict), we only need to test for conflicts of
205 the lowest order words. */
206 ira_object_t obj1 = ALLOCNO_OBJECT (a1, 0);
207 ira_object_t obj2 = ALLOCNO_OBJECT (a2, 0);
208 return OBJECTS_CONFLICT_P (obj1, obj2);
209 }
164 210
165 /* Return TRUE if the operand constraint STR is commutative. */ 211 /* Return TRUE if the operand constraint STR is commutative. */
166 static bool 212 static bool
167 commutative_constraint_p (const char *str) 213 commutative_constraint_p (const char *str)
168 { 214 {
344 bool only_regs_p; 390 bool only_regs_p;
345 ira_allocno_t a; 391 ira_allocno_t a;
346 enum reg_class rclass, cover_class; 392 enum reg_class rclass, cover_class;
347 enum machine_mode mode; 393 enum machine_mode mode;
348 ira_copy_t cp; 394 ira_copy_t cp;
349 ira_loop_tree_node_t parent;
350 395
351 gcc_assert (REG_SUBREG_P (reg1) && REG_SUBREG_P (reg2)); 396 gcc_assert (REG_SUBREG_P (reg1) && REG_SUBREG_P (reg2));
352 only_regs_p = REG_P (reg1) && REG_P (reg2); 397 only_regs_p = REG_P (reg1) && REG_P (reg2);
353 reg1 = go_through_subreg (reg1, &offset1); 398 reg1 = go_through_subreg (reg1, &offset1);
354 reg2 = go_through_subreg (reg2, &offset2); 399 reg2 = go_through_subreg (reg2, &offset2);
364 else if (HARD_REGISTER_P (reg2)) 409 else if (HARD_REGISTER_P (reg2))
365 { 410 {
366 allocno_preferenced_hard_regno = REGNO (reg2) + offset2 - offset1; 411 allocno_preferenced_hard_regno = REGNO (reg2) + offset2 - offset1;
367 a = ira_curr_regno_allocno_map[REGNO (reg1)]; 412 a = ira_curr_regno_allocno_map[REGNO (reg1)];
368 } 413 }
369 else if (!CONFLICT_ALLOCNO_P (ira_curr_regno_allocno_map[REGNO (reg1)],
370 ira_curr_regno_allocno_map[REGNO (reg2)])
371 && offset1 == offset2)
372 {
373 cp = ira_add_allocno_copy (ira_curr_regno_allocno_map[REGNO (reg1)],
374 ira_curr_regno_allocno_map[REGNO (reg2)],
375 freq, constraint_p, insn,
376 ira_curr_loop_tree_node);
377 bitmap_set_bit (ira_curr_loop_tree_node->local_copies, cp->num);
378 return true;
379 }
380 else 414 else
381 return false; 415 {
416 ira_allocno_t a1 = ira_curr_regno_allocno_map[REGNO (reg1)];
417 ira_allocno_t a2 = ira_curr_regno_allocno_map[REGNO (reg2)];
418 if (!allocnos_conflict_for_copy_p (a1, a2) && offset1 == offset2)
419 {
420 cp = ira_add_allocno_copy (a1, a2, freq, constraint_p, insn,
421 ira_curr_loop_tree_node);
422 bitmap_set_bit (ira_curr_loop_tree_node->local_copies, cp->num);
423 return true;
424 }
425 else
426 return false;
427 }
428
382 if (! IN_RANGE (allocno_preferenced_hard_regno, 0, FIRST_PSEUDO_REGISTER - 1)) 429 if (! IN_RANGE (allocno_preferenced_hard_regno, 0, FIRST_PSEUDO_REGISTER - 1))
383 /* Can not be tied. */ 430 /* Can not be tied. */
384 return false; 431 return false;
385 rclass = REGNO_REG_CLASS (allocno_preferenced_hard_regno); 432 rclass = REGNO_REG_CLASS (allocno_preferenced_hard_regno);
386 mode = ALLOCNO_MODE (a); 433 mode = ALLOCNO_MODE (a);
395 return false; 442 return false;
396 if (HARD_REGISTER_P (reg1)) 443 if (HARD_REGISTER_P (reg1))
397 cost = ira_get_register_move_cost (mode, cover_class, rclass) * freq; 444 cost = ira_get_register_move_cost (mode, cover_class, rclass) * freq;
398 else 445 else
399 cost = ira_get_register_move_cost (mode, rclass, cover_class) * freq; 446 cost = ira_get_register_move_cost (mode, rclass, cover_class) * freq;
400 for (;;) 447 do
401 { 448 {
402 ira_allocate_and_set_costs 449 ira_allocate_and_set_costs
403 (&ALLOCNO_HARD_REG_COSTS (a), cover_class, 450 (&ALLOCNO_HARD_REG_COSTS (a), cover_class,
404 ALLOCNO_COVER_CLASS_COST (a)); 451 ALLOCNO_COVER_CLASS_COST (a));
405 ira_allocate_and_set_costs 452 ira_allocate_and_set_costs
406 (&ALLOCNO_CONFLICT_HARD_REG_COSTS (a), cover_class, 0); 453 (&ALLOCNO_CONFLICT_HARD_REG_COSTS (a), cover_class, 0);
407 ALLOCNO_HARD_REG_COSTS (a)[index] -= cost; 454 ALLOCNO_HARD_REG_COSTS (a)[index] -= cost;
408 ALLOCNO_CONFLICT_HARD_REG_COSTS (a)[index] -= cost; 455 ALLOCNO_CONFLICT_HARD_REG_COSTS (a)[index] -= cost;
409 if (ALLOCNO_HARD_REG_COSTS (a)[index] < ALLOCNO_COVER_CLASS_COST (a)) 456 if (ALLOCNO_HARD_REG_COSTS (a)[index] < ALLOCNO_COVER_CLASS_COST (a))
410 ALLOCNO_COVER_CLASS_COST (a) = ALLOCNO_HARD_REG_COSTS (a)[index]; 457 ALLOCNO_COVER_CLASS_COST (a) = ALLOCNO_HARD_REG_COSTS (a)[index];
411 if (ALLOCNO_CAP (a) != NULL) 458 a = ira_parent_or_cap_allocno (a);
412 a = ALLOCNO_CAP (a); 459 }
413 else if ((parent = ALLOCNO_LOOP_TREE_NODE (a)->parent) == NULL 460 while (a != NULL);
414 || (a = parent->regno_allocno_map[ALLOCNO_REGNO (a)]) == NULL)
415 break;
416 }
417 return true; 461 return true;
418 } 462 }
419 463
420 /* Process all of the output registers of the current insn which are 464 /* Process all of the output registers of the current insn which are
421 not bound (BOUND_P) and the input register REG (its operand number 465 not bound (BOUND_P) and the input register REG (its operand number
449 { 493 {
450 rtx set, operand, dup; 494 rtx set, operand, dup;
451 const char *str; 495 const char *str;
452 bool commut_p, bound_p[MAX_RECOG_OPERANDS]; 496 bool commut_p, bound_p[MAX_RECOG_OPERANDS];
453 int i, j, n, freq; 497 int i, j, n, freq;
454 498
455 freq = REG_FREQ_FROM_BB (BLOCK_FOR_INSN (insn)); 499 freq = REG_FREQ_FROM_BB (BLOCK_FOR_INSN (insn));
456 if (freq == 0) 500 if (freq == 0)
457 freq = 1; 501 freq = 1;
458 if ((set = single_set (insn)) != NULL_RTX 502 if ((set = single_set (insn)) != NULL_RTX
459 && REG_SUBREG_P (SET_DEST (set)) && REG_SUBREG_P (SET_SRC (set)) 503 && REG_SUBREG_P (SET_DEST (set)) && REG_SUBREG_P (SET_SRC (set))
531 propagate_copies (void) 575 propagate_copies (void)
532 { 576 {
533 ira_copy_t cp; 577 ira_copy_t cp;
534 ira_copy_iterator ci; 578 ira_copy_iterator ci;
535 ira_allocno_t a1, a2, parent_a1, parent_a2; 579 ira_allocno_t a1, a2, parent_a1, parent_a2;
536 ira_loop_tree_node_t parent;
537 580
538 FOR_EACH_COPY (cp, ci) 581 FOR_EACH_COPY (cp, ci)
539 { 582 {
540 a1 = cp->first; 583 a1 = cp->first;
541 a2 = cp->second; 584 a2 = cp->second;
542 if (ALLOCNO_LOOP_TREE_NODE (a1) == ira_loop_tree_root) 585 if (ALLOCNO_LOOP_TREE_NODE (a1) == ira_loop_tree_root)
543 continue; 586 continue;
544 ira_assert ((ALLOCNO_LOOP_TREE_NODE (a2) != ira_loop_tree_root)); 587 ira_assert ((ALLOCNO_LOOP_TREE_NODE (a2) != ira_loop_tree_root));
545 parent = ALLOCNO_LOOP_TREE_NODE (a1)->parent; 588 parent_a1 = ira_parent_or_cap_allocno (a1);
546 if ((parent_a1 = ALLOCNO_CAP (a1)) == NULL) 589 parent_a2 = ira_parent_or_cap_allocno (a2);
547 parent_a1 = parent->regno_allocno_map[ALLOCNO_REGNO (a1)];
548 if ((parent_a2 = ALLOCNO_CAP (a2)) == NULL)
549 parent_a2 = parent->regno_allocno_map[ALLOCNO_REGNO (a2)];
550 ira_assert (parent_a1 != NULL && parent_a2 != NULL); 590 ira_assert (parent_a1 != NULL && parent_a2 != NULL);
551 if (! CONFLICT_ALLOCNO_P (parent_a1, parent_a2)) 591 if (! allocnos_conflict_for_copy_p (parent_a1, parent_a2))
552 ira_add_allocno_copy (parent_a1, parent_a2, cp->freq, 592 ira_add_allocno_copy (parent_a1, parent_a2, cp->freq,
553 cp->constraint_p, cp->insn, cp->loop_tree_node); 593 cp->constraint_p, cp->insn, cp->loop_tree_node);
554 } 594 }
555 } 595 }
556 596
557 /* Array used to collect all conflict allocnos for given allocno. */ 597 /* Array used to collect all conflict allocnos for given allocno. */
558 static ira_allocno_t *collected_conflict_allocnos; 598 static ira_object_t *collected_conflict_objects;
559 599
560 /* Build conflict vectors or bit conflict vectors (whatever is more 600 /* Build conflict vectors or bit conflict vectors (whatever is more
561 profitable) for allocno A from the conflict table and propagate the 601 profitable) for object OBJ from the conflict table. */
562 conflicts to upper level allocno. */
563 static void 602 static void
564 build_allocno_conflicts (ira_allocno_t a) 603 build_object_conflicts (ira_object_t obj)
565 { 604 {
566 int i, px, parent_num; 605 int i, px, parent_num;
567 int conflict_bit_vec_words_num; 606 ira_allocno_t parent_a, another_parent_a;
568 ira_loop_tree_node_t parent; 607 ira_object_t parent_obj;
569 ira_allocno_t parent_a, another_a, another_parent_a; 608 ira_allocno_t a = OBJECT_ALLOCNO (obj);
570 ira_allocno_t *vec; 609 IRA_INT_TYPE *object_conflicts;
571 IRA_INT_TYPE *allocno_conflicts; 610 minmax_set_iterator asi;
572 ira_allocno_set_iterator asi; 611
573 612 object_conflicts = conflicts[OBJECT_CONFLICT_ID (obj)];
574 allocno_conflicts = conflicts[ALLOCNO_NUM (a)];
575 px = 0; 613 px = 0;
576 FOR_EACH_ALLOCNO_IN_SET (allocno_conflicts, 614 FOR_EACH_BIT_IN_MINMAX_SET (object_conflicts,
577 ALLOCNO_MIN (a), ALLOCNO_MAX (a), i, asi) 615 OBJECT_MIN (obj), OBJECT_MAX (obj), i, asi)
578 { 616 {
579 another_a = ira_conflict_id_allocno_map[i]; 617 ira_object_t another_obj = ira_object_id_map[i];
618 ira_allocno_t another_a = OBJECT_ALLOCNO (obj);
580 ira_assert (ira_reg_classes_intersect_p 619 ira_assert (ira_reg_classes_intersect_p
581 [ALLOCNO_COVER_CLASS (a)][ALLOCNO_COVER_CLASS (another_a)]); 620 [ALLOCNO_COVER_CLASS (a)][ALLOCNO_COVER_CLASS (another_a)]);
582 collected_conflict_allocnos[px++] = another_a; 621 collected_conflict_objects[px++] = another_obj;
583 } 622 }
584 if (ira_conflict_vector_profitable_p (a, px)) 623 if (ira_conflict_vector_profitable_p (obj, px))
585 { 624 {
586 ira_allocate_allocno_conflict_vec (a, px); 625 ira_object_t *vec;
587 vec = (ira_allocno_t*) ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a); 626 ira_allocate_conflict_vec (obj, px);
588 memcpy (vec, collected_conflict_allocnos, sizeof (ira_allocno_t) * px); 627 vec = OBJECT_CONFLICT_VEC (obj);
628 memcpy (vec, collected_conflict_objects, sizeof (ira_object_t) * px);
589 vec[px] = NULL; 629 vec[px] = NULL;
590 ALLOCNO_CONFLICT_ALLOCNOS_NUM (a) = px; 630 OBJECT_NUM_CONFLICTS (obj) = px;
591 } 631 }
592 else 632 else
593 { 633 {
594 ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a) = conflicts[ALLOCNO_NUM (a)]; 634 int conflict_bit_vec_words_num;
595 if (ALLOCNO_MAX (a) < ALLOCNO_MIN (a)) 635 OBJECT_CONFLICT_ARRAY (obj) = object_conflicts;
636 if (OBJECT_MAX (obj) < OBJECT_MIN (obj))
596 conflict_bit_vec_words_num = 0; 637 conflict_bit_vec_words_num = 0;
597 else 638 else
598 conflict_bit_vec_words_num 639 conflict_bit_vec_words_num
599 = ((ALLOCNO_MAX (a) - ALLOCNO_MIN (a) + IRA_INT_BITS) 640 = ((OBJECT_MAX (obj) - OBJECT_MIN (obj) + IRA_INT_BITS)
600 / IRA_INT_BITS); 641 / IRA_INT_BITS);
601 ALLOCNO_CONFLICT_ALLOCNO_ARRAY_SIZE (a) 642 OBJECT_CONFLICT_ARRAY_SIZE (obj)
602 = conflict_bit_vec_words_num * sizeof (IRA_INT_TYPE); 643 = conflict_bit_vec_words_num * sizeof (IRA_INT_TYPE);
603 } 644 }
604 parent = ALLOCNO_LOOP_TREE_NODE (a)->parent; 645
605 if ((parent_a = ALLOCNO_CAP (a)) == NULL 646 parent_a = ira_parent_or_cap_allocno (a);
606 && (parent == NULL 647 if (parent_a == NULL)
607 || (parent_a = parent->regno_allocno_map[ALLOCNO_REGNO (a)])
608 == NULL))
609 return; 648 return;
610 ira_assert (parent != NULL);
611 ira_assert (ALLOCNO_COVER_CLASS (a) == ALLOCNO_COVER_CLASS (parent_a)); 649 ira_assert (ALLOCNO_COVER_CLASS (a) == ALLOCNO_COVER_CLASS (parent_a));
612 parent_num = ALLOCNO_NUM (parent_a); 650 ira_assert (ALLOCNO_NUM_OBJECTS (a) == ALLOCNO_NUM_OBJECTS (parent_a));
613 FOR_EACH_ALLOCNO_IN_SET (allocno_conflicts, 651 parent_obj = ALLOCNO_OBJECT (parent_a, OBJECT_SUBWORD (obj));
614 ALLOCNO_MIN (a), ALLOCNO_MAX (a), i, asi) 652 parent_num = OBJECT_CONFLICT_ID (parent_obj);
615 { 653 FOR_EACH_BIT_IN_MINMAX_SET (object_conflicts,
616 another_a = ira_conflict_id_allocno_map[i]; 654 OBJECT_MIN (obj), OBJECT_MAX (obj), i, asi)
655 {
656 ira_object_t another_obj = ira_object_id_map[i];
657 ira_allocno_t another_a = OBJECT_ALLOCNO (another_obj);
658 int another_word = OBJECT_SUBWORD (another_obj);
659
617 ira_assert (ira_reg_classes_intersect_p 660 ira_assert (ira_reg_classes_intersect_p
618 [ALLOCNO_COVER_CLASS (a)][ALLOCNO_COVER_CLASS (another_a)]); 661 [ALLOCNO_COVER_CLASS (a)][ALLOCNO_COVER_CLASS (another_a)]);
619 if ((another_parent_a = ALLOCNO_CAP (another_a)) == NULL 662
620 && (another_parent_a = (parent->regno_allocno_map 663 another_parent_a = ira_parent_or_cap_allocno (another_a);
621 [ALLOCNO_REGNO (another_a)])) == NULL) 664 if (another_parent_a == NULL)
622 continue; 665 continue;
623 ira_assert (ALLOCNO_NUM (another_parent_a) >= 0); 666 ira_assert (ALLOCNO_NUM (another_parent_a) >= 0);
624 ira_assert (ALLOCNO_COVER_CLASS (another_a) 667 ira_assert (ALLOCNO_COVER_CLASS (another_a)
625 == ALLOCNO_COVER_CLASS (another_parent_a)); 668 == ALLOCNO_COVER_CLASS (another_parent_a));
626 SET_ALLOCNO_SET_BIT (conflicts[parent_num], 669 ira_assert (ALLOCNO_NUM_OBJECTS (another_a)
627 ALLOCNO_CONFLICT_ID (another_parent_a), 670 == ALLOCNO_NUM_OBJECTS (another_parent_a));
628 ALLOCNO_MIN (parent_a), 671 SET_MINMAX_SET_BIT (conflicts[parent_num],
629 ALLOCNO_MAX (parent_a)); 672 OBJECT_CONFLICT_ID (ALLOCNO_OBJECT (another_parent_a,
673 another_word)),
674 OBJECT_MIN (parent_obj),
675 OBJECT_MAX (parent_obj));
630 } 676 }
631 } 677 }
632 678
633 /* Build conflict vectors or bit conflict vectors (whatever is more 679 /* Build conflict vectors or bit conflict vectors (whatever is more
634 profitable) of all allocnos from the conflict table. */ 680 profitable) of all allocnos from the conflict table. */
636 build_conflicts (void) 682 build_conflicts (void)
637 { 683 {
638 int i; 684 int i;
639 ira_allocno_t a, cap; 685 ira_allocno_t a, cap;
640 686
641 collected_conflict_allocnos 687 collected_conflict_objects
642 = (ira_allocno_t *) ira_allocate (sizeof (ira_allocno_t) 688 = (ira_object_t *) ira_allocate (sizeof (ira_object_t)
643 * ira_allocnos_num); 689 * ira_objects_num);
644 for (i = max_reg_num () - 1; i >= FIRST_PSEUDO_REGISTER; i--) 690 for (i = max_reg_num () - 1; i >= FIRST_PSEUDO_REGISTER; i--)
645 for (a = ira_regno_allocno_map[i]; 691 for (a = ira_regno_allocno_map[i];
646 a != NULL; 692 a != NULL;
647 a = ALLOCNO_NEXT_REGNO_ALLOCNO (a)) 693 a = ALLOCNO_NEXT_REGNO_ALLOCNO (a))
648 { 694 {
649 build_allocno_conflicts (a); 695 int j, nregs = ALLOCNO_NUM_OBJECTS (a);
650 for (cap = ALLOCNO_CAP (a); cap != NULL; cap = ALLOCNO_CAP (cap)) 696 for (j = 0; j < nregs; j++)
651 build_allocno_conflicts (cap); 697 {
698 ira_object_t obj = ALLOCNO_OBJECT (a, j);
699 build_object_conflicts (obj);
700 for (cap = ALLOCNO_CAP (a); cap != NULL; cap = ALLOCNO_CAP (cap))
701 {
702 ira_object_t cap_obj = ALLOCNO_OBJECT (cap, j);
703 gcc_assert (ALLOCNO_NUM_OBJECTS (cap) == ALLOCNO_NUM_OBJECTS (a));
704 build_object_conflicts (cap_obj);
705 }
706 }
652 } 707 }
653 ira_free (collected_conflict_allocnos); 708 ira_free (collected_conflict_objects);
654 } 709 }
655 710
656 711
657 712
658 /* Print hard reg set SET with TITLE to FILE. */ 713 /* Print hard reg set SET with TITLE to FILE. */
686 741
687 static void 742 static void
688 print_allocno_conflicts (FILE * file, bool reg_p, ira_allocno_t a) 743 print_allocno_conflicts (FILE * file, bool reg_p, ira_allocno_t a)
689 { 744 {
690 HARD_REG_SET conflicting_hard_regs; 745 HARD_REG_SET conflicting_hard_regs;
691 ira_allocno_t conflict_a;
692 ira_allocno_conflict_iterator aci;
693 basic_block bb; 746 basic_block bb;
747 int n, i;
694 748
695 if (reg_p) 749 if (reg_p)
696 fprintf (file, ";; r%d", ALLOCNO_REGNO (a)); 750 fprintf (file, ";; r%d", ALLOCNO_REGNO (a));
697 else 751 else
698 { 752 {
701 fprintf (file, "b%d", bb->index); 755 fprintf (file, "b%d", bb->index);
702 else 756 else
703 fprintf (file, "l%d", ALLOCNO_LOOP_TREE_NODE (a)->loop->num); 757 fprintf (file, "l%d", ALLOCNO_LOOP_TREE_NODE (a)->loop->num);
704 putc (')', file); 758 putc (')', file);
705 } 759 }
760
706 fputs (" conflicts:", file); 761 fputs (" conflicts:", file);
707 if (ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a) != NULL) 762 n = ALLOCNO_NUM_OBJECTS (a);
708 FOR_EACH_ALLOCNO_CONFLICT (a, conflict_a, aci) 763 for (i = 0; i < n; i++)
709 { 764 {
710 if (reg_p) 765 ira_object_t obj = ALLOCNO_OBJECT (a, i);
711 fprintf (file, " r%d,", ALLOCNO_REGNO (conflict_a)); 766 ira_object_t conflict_obj;
712 else 767 ira_object_conflict_iterator oci;
713 { 768
714 fprintf (file, " a%d(r%d,", ALLOCNO_NUM (conflict_a), 769 if (OBJECT_CONFLICT_ARRAY (obj) == NULL)
715 ALLOCNO_REGNO (conflict_a)); 770 continue;
716 if ((bb = ALLOCNO_LOOP_TREE_NODE (conflict_a)->bb) != NULL) 771 if (n > 1)
717 fprintf (file, "b%d)", bb->index); 772 fprintf (file, "\n;; subobject %d:", i);
718 else 773 FOR_EACH_OBJECT_CONFLICT (obj, conflict_obj, oci)
719 fprintf (file, "l%d)", 774 {
720 ALLOCNO_LOOP_TREE_NODE (conflict_a)->loop->num); 775 ira_allocno_t conflict_a = OBJECT_ALLOCNO (conflict_obj);
721 } 776 if (reg_p)
722 } 777 fprintf (file, " r%d,", ALLOCNO_REGNO (conflict_a));
723 COPY_HARD_REG_SET (conflicting_hard_regs, 778 else
724 ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a)); 779 {
725 AND_COMPL_HARD_REG_SET (conflicting_hard_regs, ira_no_alloc_regs); 780 fprintf (file, " a%d(r%d", ALLOCNO_NUM (conflict_a),
726 AND_HARD_REG_SET (conflicting_hard_regs, 781 ALLOCNO_REGNO (conflict_a));
727 reg_class_contents[ALLOCNO_COVER_CLASS (a)]); 782 if (ALLOCNO_NUM_OBJECTS (conflict_a) > 1)
728 print_hard_reg_set (file, "\n;; total conflict hard regs:", 783 fprintf (file, ",w%d", OBJECT_SUBWORD (conflict_obj));
729 conflicting_hard_regs); 784 if ((bb = ALLOCNO_LOOP_TREE_NODE (conflict_a)->bb) != NULL)
730 COPY_HARD_REG_SET (conflicting_hard_regs, 785 fprintf (file, ",b%d", bb->index);
731 ALLOCNO_CONFLICT_HARD_REGS (a)); 786 else
732 AND_COMPL_HARD_REG_SET (conflicting_hard_regs, ira_no_alloc_regs); 787 fprintf (file, ",l%d",
733 AND_HARD_REG_SET (conflicting_hard_regs, 788 ALLOCNO_LOOP_TREE_NODE (conflict_a)->loop->num);
734 reg_class_contents[ALLOCNO_COVER_CLASS (a)]); 789 putc (')', file);
735 print_hard_reg_set (file, ";; conflict hard regs:", 790 }
736 conflicting_hard_regs); 791 }
737 putc ('\n', file); 792 COPY_HARD_REG_SET (conflicting_hard_regs, OBJECT_TOTAL_CONFLICT_HARD_REGS (obj));
793 AND_COMPL_HARD_REG_SET (conflicting_hard_regs, ira_no_alloc_regs);
794 AND_HARD_REG_SET (conflicting_hard_regs,
795 reg_class_contents[ALLOCNO_COVER_CLASS (a)]);
796 print_hard_reg_set (file, "\n;; total conflict hard regs:",
797 conflicting_hard_regs);
798
799 COPY_HARD_REG_SET (conflicting_hard_regs, OBJECT_CONFLICT_HARD_REGS (obj));
800 AND_COMPL_HARD_REG_SET (conflicting_hard_regs, ira_no_alloc_regs);
801 AND_HARD_REG_SET (conflicting_hard_regs,
802 reg_class_contents[ALLOCNO_COVER_CLASS (a)]);
803 print_hard_reg_set (file, ";; conflict hard regs:",
804 conflicting_hard_regs);
805 putc ('\n', file);
806 }
807
738 } 808 }
739 809
740 /* Print information about allocno or only regno (if REG_P) conflicts 810 /* Print information about allocno or only regno (if REG_P) conflicts
741 to FILE. */ 811 to FILE. */
742 static void 812 static void
771 if (ira_conflicts_p) 841 if (ira_conflicts_p)
772 { 842 {
773 ira_conflicts_p = build_conflict_bit_table (); 843 ira_conflicts_p = build_conflict_bit_table ();
774 if (ira_conflicts_p) 844 if (ira_conflicts_p)
775 { 845 {
846 ira_object_t obj;
847 ira_object_iterator oi;
848
776 build_conflicts (); 849 build_conflicts ();
777 ira_traverse_loop_tree (true, ira_loop_tree_root, NULL, add_copies); 850 ira_traverse_loop_tree (true, ira_loop_tree_root, NULL, add_copies);
778 /* We need finished conflict table for the subsequent call. */ 851 /* We need finished conflict table for the subsequent call. */
779 if (flag_ira_region == IRA_REGION_ALL 852 if (flag_ira_region == IRA_REGION_ALL
780 || flag_ira_region == IRA_REGION_MIXED) 853 || flag_ira_region == IRA_REGION_MIXED)
781 propagate_copies (); 854 propagate_copies ();
855
782 /* Now we can free memory for the conflict table (see function 856 /* Now we can free memory for the conflict table (see function
783 build_allocno_conflicts for details). */ 857 build_object_conflicts for details). */
784 FOR_EACH_ALLOCNO (a, ai) 858 FOR_EACH_OBJECT (obj, oi)
785 { 859 {
786 if (ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a) 860 if (OBJECT_CONFLICT_ARRAY (obj) != conflicts[OBJECT_CONFLICT_ID (obj)])
787 != conflicts[ALLOCNO_NUM (a)]) 861 ira_free (conflicts[OBJECT_CONFLICT_ID (obj)]);
788 ira_free (conflicts[ALLOCNO_NUM (a)]);
789 } 862 }
790 ira_free (conflicts); 863 ira_free (conflicts);
791 } 864 }
792 } 865 }
793 if (! CLASS_LIKELY_SPILLED_P (base_reg_class (VOIDmode, ADDRESS, SCRATCH))) 866 if (! targetm.class_likely_spilled_p (base_reg_class (VOIDmode, ADDRESS,
867 SCRATCH)))
794 CLEAR_HARD_REG_SET (temp_hard_reg_set); 868 CLEAR_HARD_REG_SET (temp_hard_reg_set);
795 else 869 else
796 { 870 {
797 COPY_HARD_REG_SET (temp_hard_reg_set, 871 COPY_HARD_REG_SET (temp_hard_reg_set,
798 reg_class_contents[base_reg_class (VOIDmode, ADDRESS, SCRATCH)]); 872 reg_class_contents[base_reg_class (VOIDmode, ADDRESS, SCRATCH)]);
799 AND_COMPL_HARD_REG_SET (temp_hard_reg_set, ira_no_alloc_regs); 873 AND_COMPL_HARD_REG_SET (temp_hard_reg_set, ira_no_alloc_regs);
800 AND_HARD_REG_SET (temp_hard_reg_set, call_used_reg_set); 874 AND_HARD_REG_SET (temp_hard_reg_set, call_used_reg_set);
801 } 875 }
802 FOR_EACH_ALLOCNO (a, ai) 876 FOR_EACH_ALLOCNO (a, ai)
803 { 877 {
804 reg_attrs *attrs; 878 int i, n = ALLOCNO_NUM_OBJECTS (a);
805 tree decl; 879 for (i = 0; i < n; i++)
806
807 if ((! flag_caller_saves && ALLOCNO_CALLS_CROSSED_NUM (a) != 0)
808 /* For debugging purposes don't put user defined variables in
809 callee-clobbered registers. */
810 || (optimize == 0
811 && (attrs = REG_ATTRS (regno_reg_rtx [ALLOCNO_REGNO (a)])) != NULL
812 && (decl = attrs->decl) != NULL
813 && VAR_OR_FUNCTION_DECL_P (decl)
814 && ! DECL_ARTIFICIAL (decl)))
815 { 880 {
816 IOR_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a), 881 ira_object_t obj = ALLOCNO_OBJECT (a, i);
817 call_used_reg_set); 882 reg_attrs *attrs = REG_ATTRS (regno_reg_rtx [ALLOCNO_REGNO (a)]);
818 IOR_HARD_REG_SET (ALLOCNO_CONFLICT_HARD_REGS (a), 883 tree decl;
819 call_used_reg_set); 884
820 } 885 if ((! flag_caller_saves && ALLOCNO_CALLS_CROSSED_NUM (a) != 0)
821 else if (ALLOCNO_CALLS_CROSSED_NUM (a) != 0) 886 /* For debugging purposes don't put user defined variables in
822 { 887 callee-clobbered registers. */
823 IOR_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a), 888 || (optimize == 0
824 no_caller_save_reg_set); 889 && attrs != NULL
825 IOR_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a), 890 && (decl = attrs->decl) != NULL
826 temp_hard_reg_set); 891 && VAR_OR_FUNCTION_DECL_P (decl)
827 IOR_HARD_REG_SET (ALLOCNO_CONFLICT_HARD_REGS (a), 892 && ! DECL_ARTIFICIAL (decl)))
828 no_caller_save_reg_set); 893 {
829 IOR_HARD_REG_SET (ALLOCNO_CONFLICT_HARD_REGS (a), 894 IOR_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
830 temp_hard_reg_set); 895 call_used_reg_set);
896 IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj),
897 call_used_reg_set);
898 }
899 else if (ALLOCNO_CALLS_CROSSED_NUM (a) != 0)
900 {
901 IOR_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
902 no_caller_save_reg_set);
903 IOR_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
904 temp_hard_reg_set);
905 IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj),
906 no_caller_save_reg_set);
907 IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj),
908 temp_hard_reg_set);
909 }
910
911 if (ALLOCNO_CALLS_CROSSED_NUM (a) != 0)
912 {
913 int regno;
914
915 /* Allocnos bigger than the saved part of call saved
916 regs must conflict with them. */
917 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
918 if (!TEST_HARD_REG_BIT (call_used_reg_set, regno)
919 && HARD_REGNO_CALL_PART_CLOBBERED (regno,
920 obj->allocno->mode))
921 {
922 SET_HARD_REG_BIT (OBJECT_CONFLICT_HARD_REGS (obj), regno);
923 SET_HARD_REG_BIT (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
924 regno);
925 }
926 }
831 } 927 }
832 } 928 }
833 if (optimize && ira_conflicts_p 929 if (optimize && ira_conflicts_p
834 && internal_flag_ira_verbose > 2 && ira_dump_file != NULL) 930 && internal_flag_ira_verbose > 2 && ira_dump_file != NULL)
835 print_conflicts (ira_dump_file, false); 931 print_conflicts (ira_dump_file, false);