Mercurial > hg > CbC > CbC_gcc
comparison gcc/ira-int.h @ 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 |
---|---|
1 /* Integrated Register Allocator (IRA) intercommunication header file. | 1 /* Integrated Register Allocator (IRA) intercommunication header file. |
2 Copyright (C) 2006, 2007, 2008, 2009 | 2 Copyright (C) 2006, 2007, 2008, 2009, 2010 |
3 Free Software Foundation, Inc. | 3 Free Software Foundation, Inc. |
4 Contributed by Vladimir Makarov <vmakarov@redhat.com>. | 4 Contributed by Vladimir Makarov <vmakarov@redhat.com>. |
5 | 5 |
6 This file is part of GCC. | 6 This file is part of GCC. |
7 | 7 |
57 /* Dump file of the allocator if it is not NULL. */ | 57 /* Dump file of the allocator if it is not NULL. */ |
58 extern FILE *ira_dump_file; | 58 extern FILE *ira_dump_file; |
59 | 59 |
60 /* Typedefs for pointers to allocno live range, allocno, and copy of | 60 /* Typedefs for pointers to allocno live range, allocno, and copy of |
61 allocnos. */ | 61 allocnos. */ |
62 typedef struct ira_allocno_live_range *allocno_live_range_t; | 62 typedef struct live_range *live_range_t; |
63 typedef struct ira_allocno *ira_allocno_t; | 63 typedef struct ira_allocno *ira_allocno_t; |
64 typedef struct ira_allocno_copy *ira_copy_t; | 64 typedef struct ira_allocno_copy *ira_copy_t; |
65 typedef struct ira_object *ira_object_t; | |
65 | 66 |
66 /* Definition of vector of allocnos and copies. */ | 67 /* Definition of vector of allocnos and copies. */ |
67 DEF_VEC_P(ira_allocno_t); | 68 DEF_VEC_P(ira_allocno_t); |
68 DEF_VEC_ALLOC_P(ira_allocno_t, heap); | 69 DEF_VEC_ALLOC_P(ira_allocno_t, heap); |
70 DEF_VEC_P(ira_object_t); | |
71 DEF_VEC_ALLOC_P(ira_object_t, heap); | |
69 DEF_VEC_P(ira_copy_t); | 72 DEF_VEC_P(ira_copy_t); |
70 DEF_VEC_ALLOC_P(ira_copy_t, heap); | 73 DEF_VEC_ALLOC_P(ira_copy_t, heap); |
71 | 74 |
72 /* Typedef for pointer to the subsequent structure. */ | 75 /* Typedef for pointer to the subsequent structure. */ |
73 typedef struct ira_loop_tree_node *ira_loop_tree_node_t; | 76 typedef struct ira_loop_tree_node *ira_loop_tree_node_t; |
187 #endif | 190 #endif |
188 | 191 |
189 #define IRA_LOOP_NODE(loop) IRA_LOOP_NODE_BY_INDEX ((loop)->num) | 192 #define IRA_LOOP_NODE(loop) IRA_LOOP_NODE_BY_INDEX ((loop)->num) |
190 | 193 |
191 | 194 |
192 | |
193 /* The structure describes program points where a given allocno lives. | 195 /* The structure describes program points where a given allocno lives. |
194 To save memory we store allocno conflicts only for the same cover | 196 To save memory we store allocno conflicts only for the same cover |
195 class allocnos which is enough to assign hard registers. To find | 197 class allocnos which is enough to assign hard registers. To find |
196 conflicts for other allocnos (e.g. to assign stack memory slot) we | 198 conflicts for other allocnos (e.g. to assign stack memory slot) we |
197 use the live ranges. If the live ranges of two allocnos are | 199 use the live ranges. If the live ranges of two allocnos are |
198 intersected, the allocnos are in conflict. */ | 200 intersected, the allocnos are in conflict. */ |
199 struct ira_allocno_live_range | 201 struct live_range |
200 { | 202 { |
201 /* Allocno whose live range is described by given structure. */ | 203 /* Object whose live range is described by given structure. */ |
202 ira_allocno_t allocno; | 204 ira_object_t object; |
203 /* Program point range. */ | 205 /* Program point range. */ |
204 int start, finish; | 206 int start, finish; |
205 /* Next structure describing program points where the allocno | 207 /* Next structure describing program points where the allocno |
206 lives. */ | 208 lives. */ |
207 allocno_live_range_t next; | 209 live_range_t next; |
208 /* Pointer to structures with the same start/finish. */ | 210 /* Pointer to structures with the same start/finish. */ |
209 allocno_live_range_t start_next, finish_next; | 211 live_range_t start_next, finish_next; |
210 }; | 212 }; |
211 | 213 |
212 /* Program points are enumerated by numbers from range | 214 /* Program points are enumerated by numbers from range |
213 0..IRA_MAX_POINT-1. There are approximately two times more program | 215 0..IRA_MAX_POINT-1. There are approximately two times more program |
214 points than insns. Program points are places in the program where | 216 points than insns. Program points are places in the program where |
218 output operands are born. */ | 220 output operands are born. */ |
219 extern int ira_max_point; | 221 extern int ira_max_point; |
220 | 222 |
221 /* Arrays of size IRA_MAX_POINT mapping a program point to the allocno | 223 /* Arrays of size IRA_MAX_POINT mapping a program point to the allocno |
222 live ranges with given start/finish point. */ | 224 live ranges with given start/finish point. */ |
223 extern allocno_live_range_t *ira_start_point_ranges, *ira_finish_point_ranges; | 225 extern live_range_t *ira_start_point_ranges, *ira_finish_point_ranges; |
226 | |
227 /* A structure representing conflict information for an allocno | |
228 (or one of its subwords). */ | |
229 struct ira_object | |
230 { | |
231 /* The allocno associated with this record. */ | |
232 ira_allocno_t allocno; | |
233 /* Vector of accumulated conflicting conflict_redords with NULL end | |
234 marker (if OBJECT_CONFLICT_VEC_P is true) or conflict bit vector | |
235 otherwise. Only ira_objects belonging to allocnos with the | |
236 same cover class are in the vector or in the bit vector. */ | |
237 void *conflicts_array; | |
238 /* Pointer to structures describing at what program point the | |
239 object lives. We always maintain the list in such way that *the | |
240 ranges in the list are not intersected and ordered by decreasing | |
241 their program points*. */ | |
242 live_range_t live_ranges; | |
243 /* The subword within ALLOCNO which is represented by this object. | |
244 Zero means the lowest-order subword (or the entire allocno in case | |
245 it is not being tracked in subwords). */ | |
246 int subword; | |
247 /* Allocated size of the conflicts array. */ | |
248 unsigned int conflicts_array_size; | |
249 /* A unique number for every instance of this structure, which is used | |
250 to represent it in conflict bit vectors. */ | |
251 int id; | |
252 /* Before building conflicts, MIN and MAX are initialized to | |
253 correspondingly minimal and maximal points of the accumulated | |
254 live ranges. Afterwards, they hold the minimal and maximal ids | |
255 of other ira_objects that this one can conflict with. */ | |
256 int min, max; | |
257 /* Initial and accumulated hard registers conflicting with this | |
258 object and as a consequences can not be assigned to the allocno. | |
259 All non-allocatable hard regs and hard regs of cover classes | |
260 different from given allocno one are included in the sets. */ | |
261 HARD_REG_SET conflict_hard_regs, total_conflict_hard_regs; | |
262 /* Number of accumulated conflicts in the vector of conflicting | |
263 objects. */ | |
264 int num_accumulated_conflicts; | |
265 /* TRUE if conflicts are represented by a vector of pointers to | |
266 ira_object structures. Otherwise, we use a bit vector indexed | |
267 by conflict ID numbers. */ | |
268 unsigned int conflict_vec_p : 1; | |
269 }; | |
224 | 270 |
225 /* A structure representing an allocno (allocation entity). Allocno | 271 /* A structure representing an allocno (allocation entity). Allocno |
226 represents a pseudo-register in an allocation region. If | 272 represents a pseudo-register in an allocation region. If |
227 pseudo-register does not live in a region but it lives in the | 273 pseudo-register does not live in a region but it lives in the |
228 nested regions, it is represented in the region by special allocno | 274 nested regions, it is represented in the region by special allocno |
299 /* Coalesced allocnos form a cyclic list. One allocno given by | 345 /* Coalesced allocnos form a cyclic list. One allocno given by |
300 FIRST_COALESCED_ALLOCNO represents all coalesced allocnos. The | 346 FIRST_COALESCED_ALLOCNO represents all coalesced allocnos. The |
301 list is chained by NEXT_COALESCED_ALLOCNO. */ | 347 list is chained by NEXT_COALESCED_ALLOCNO. */ |
302 ira_allocno_t first_coalesced_allocno; | 348 ira_allocno_t first_coalesced_allocno; |
303 ira_allocno_t next_coalesced_allocno; | 349 ira_allocno_t next_coalesced_allocno; |
304 /* Pointer to structures describing at what program point the | 350 /* The number of objects tracked in the following array. */ |
305 allocno lives. We always maintain the list in such way that *the | 351 int num_objects; |
306 ranges in the list are not intersected and ordered by decreasing | 352 /* An array of structures describing conflict information and live |
307 their program points*. */ | 353 ranges for each object associated with the allocno. There may be |
308 allocno_live_range_t live_ranges; | 354 more than one such object in cases where the allocno represents a |
309 /* Before building conflicts the two member values are | 355 multi-word register. */ |
310 correspondingly minimal and maximal points of the accumulated | 356 ira_object_t objects[2]; |
311 allocno live ranges. After building conflicts the values are | |
312 correspondingly minimal and maximal conflict ids of allocnos with | |
313 which given allocno can conflict. */ | |
314 int min, max; | |
315 /* Vector of accumulated conflicting allocnos with NULL end marker | |
316 (if CONFLICT_VEC_P is true) or conflict bit vector otherwise. | |
317 Only allocnos with the same cover class are in the vector or in | |
318 the bit vector. */ | |
319 void *conflict_allocno_array; | |
320 /* The unique member value represents given allocno in conflict bit | |
321 vectors. */ | |
322 int conflict_id; | |
323 /* Allocated size of the previous array. */ | |
324 unsigned int conflict_allocno_array_size; | |
325 /* Initial and accumulated hard registers conflicting with this | |
326 allocno and as a consequences can not be assigned to the allocno. | |
327 All non-allocatable hard regs and hard regs of cover classes | |
328 different from given allocno one are included in the sets. */ | |
329 HARD_REG_SET conflict_hard_regs, total_conflict_hard_regs; | |
330 /* Number of accumulated conflicts in the vector of conflicting | |
331 allocnos. */ | |
332 int conflict_allocnos_num; | |
333 /* Accumulated frequency of calls which given allocno | 357 /* Accumulated frequency of calls which given allocno |
334 intersects. */ | 358 intersects. */ |
335 int call_freq; | 359 int call_freq; |
336 /* Accumulated number of the intersected calls. */ | 360 /* Accumulated number of the intersected calls. */ |
337 int calls_crossed_num; | 361 int calls_crossed_num; |
372 colorable. */ | 396 colorable. */ |
373 unsigned int may_be_spilled_p : 1; | 397 unsigned int may_be_spilled_p : 1; |
374 /* TRUE if the allocno was removed from the splay tree used to | 398 /* TRUE if the allocno was removed from the splay tree used to |
375 choose allocn for spilling (see ira-color.c::. */ | 399 choose allocn for spilling (see ira-color.c::. */ |
376 unsigned int splay_removed_p : 1; | 400 unsigned int splay_removed_p : 1; |
377 /* TRUE if conflicts for given allocno are represented by vector of | |
378 pointers to the conflicting allocnos. Otherwise, we use a bit | |
379 vector where a bit with given index represents allocno with the | |
380 same number. */ | |
381 unsigned int conflict_vec_p : 1; | |
382 /* Non NULL if we remove restoring value from given allocno to | 401 /* Non NULL if we remove restoring value from given allocno to |
383 MEM_OPTIMIZED_DEST at loop exit (see ira-emit.c) because the | 402 MEM_OPTIMIZED_DEST at loop exit (see ira-emit.c) because the |
384 allocno value is not changed inside the loop. */ | 403 allocno value is not changed inside the loop. */ |
385 ira_allocno_t mem_optimized_dest; | 404 ira_allocno_t mem_optimized_dest; |
386 /* Array of usage costs (accumulated and the one updated during | 405 /* Array of usage costs (accumulated and the one updated during |
427 #define ALLOCNO_REG(A) ((A)->reg) | 446 #define ALLOCNO_REG(A) ((A)->reg) |
428 #define ALLOCNO_NEXT_REGNO_ALLOCNO(A) ((A)->next_regno_allocno) | 447 #define ALLOCNO_NEXT_REGNO_ALLOCNO(A) ((A)->next_regno_allocno) |
429 #define ALLOCNO_LOOP_TREE_NODE(A) ((A)->loop_tree_node) | 448 #define ALLOCNO_LOOP_TREE_NODE(A) ((A)->loop_tree_node) |
430 #define ALLOCNO_CAP(A) ((A)->cap) | 449 #define ALLOCNO_CAP(A) ((A)->cap) |
431 #define ALLOCNO_CAP_MEMBER(A) ((A)->cap_member) | 450 #define ALLOCNO_CAP_MEMBER(A) ((A)->cap_member) |
432 #define ALLOCNO_CONFLICT_ALLOCNO_ARRAY(A) ((A)->conflict_allocno_array) | |
433 #define ALLOCNO_CONFLICT_ALLOCNO_ARRAY_SIZE(A) \ | |
434 ((A)->conflict_allocno_array_size) | |
435 #define ALLOCNO_CONFLICT_ALLOCNOS_NUM(A) \ | |
436 ((A)->conflict_allocnos_num) | |
437 #define ALLOCNO_CONFLICT_HARD_REGS(A) ((A)->conflict_hard_regs) | |
438 #define ALLOCNO_TOTAL_CONFLICT_HARD_REGS(A) ((A)->total_conflict_hard_regs) | |
439 #define ALLOCNO_NREFS(A) ((A)->nrefs) | 451 #define ALLOCNO_NREFS(A) ((A)->nrefs) |
440 #define ALLOCNO_FREQ(A) ((A)->freq) | 452 #define ALLOCNO_FREQ(A) ((A)->freq) |
441 #define ALLOCNO_HARD_REGNO(A) ((A)->hard_regno) | 453 #define ALLOCNO_HARD_REGNO(A) ((A)->hard_regno) |
442 #define ALLOCNO_CALL_FREQ(A) ((A)->call_freq) | 454 #define ALLOCNO_CALL_FREQ(A) ((A)->call_freq) |
443 #define ALLOCNO_CALLS_CROSSED_NUM(A) ((A)->calls_crossed_num) | 455 #define ALLOCNO_CALLS_CROSSED_NUM(A) ((A)->calls_crossed_num) |
453 #define ALLOCNO_BAD_SPILL_P(A) ((A)->bad_spill_p) | 465 #define ALLOCNO_BAD_SPILL_P(A) ((A)->bad_spill_p) |
454 #define ALLOCNO_IN_GRAPH_P(A) ((A)->in_graph_p) | 466 #define ALLOCNO_IN_GRAPH_P(A) ((A)->in_graph_p) |
455 #define ALLOCNO_ASSIGNED_P(A) ((A)->assigned_p) | 467 #define ALLOCNO_ASSIGNED_P(A) ((A)->assigned_p) |
456 #define ALLOCNO_MAY_BE_SPILLED_P(A) ((A)->may_be_spilled_p) | 468 #define ALLOCNO_MAY_BE_SPILLED_P(A) ((A)->may_be_spilled_p) |
457 #define ALLOCNO_SPLAY_REMOVED_P(A) ((A)->splay_removed_p) | 469 #define ALLOCNO_SPLAY_REMOVED_P(A) ((A)->splay_removed_p) |
458 #define ALLOCNO_CONFLICT_VEC_P(A) ((A)->conflict_vec_p) | |
459 #define ALLOCNO_MODE(A) ((A)->mode) | 470 #define ALLOCNO_MODE(A) ((A)->mode) |
460 #define ALLOCNO_COPIES(A) ((A)->allocno_copies) | 471 #define ALLOCNO_COPIES(A) ((A)->allocno_copies) |
461 #define ALLOCNO_HARD_REG_COSTS(A) ((A)->hard_reg_costs) | 472 #define ALLOCNO_HARD_REG_COSTS(A) ((A)->hard_reg_costs) |
462 #define ALLOCNO_UPDATED_HARD_REG_COSTS(A) ((A)->updated_hard_reg_costs) | 473 #define ALLOCNO_UPDATED_HARD_REG_COSTS(A) ((A)->updated_hard_reg_costs) |
463 #define ALLOCNO_CONFLICT_HARD_REG_COSTS(A) \ | 474 #define ALLOCNO_CONFLICT_HARD_REG_COSTS(A) \ |
475 #define ALLOCNO_NEXT_BUCKET_ALLOCNO(A) ((A)->next_bucket_allocno) | 486 #define ALLOCNO_NEXT_BUCKET_ALLOCNO(A) ((A)->next_bucket_allocno) |
476 #define ALLOCNO_PREV_BUCKET_ALLOCNO(A) ((A)->prev_bucket_allocno) | 487 #define ALLOCNO_PREV_BUCKET_ALLOCNO(A) ((A)->prev_bucket_allocno) |
477 #define ALLOCNO_TEMP(A) ((A)->temp) | 488 #define ALLOCNO_TEMP(A) ((A)->temp) |
478 #define ALLOCNO_FIRST_COALESCED_ALLOCNO(A) ((A)->first_coalesced_allocno) | 489 #define ALLOCNO_FIRST_COALESCED_ALLOCNO(A) ((A)->first_coalesced_allocno) |
479 #define ALLOCNO_NEXT_COALESCED_ALLOCNO(A) ((A)->next_coalesced_allocno) | 490 #define ALLOCNO_NEXT_COALESCED_ALLOCNO(A) ((A)->next_coalesced_allocno) |
480 #define ALLOCNO_LIVE_RANGES(A) ((A)->live_ranges) | 491 #define ALLOCNO_OBJECT(A,N) ((A)->objects[N]) |
481 #define ALLOCNO_MIN(A) ((A)->min) | 492 #define ALLOCNO_NUM_OBJECTS(A) ((A)->num_objects) |
482 #define ALLOCNO_MAX(A) ((A)->max) | 493 |
483 #define ALLOCNO_CONFLICT_ID(A) ((A)->conflict_id) | 494 #define OBJECT_ALLOCNO(C) ((C)->allocno) |
495 #define OBJECT_SUBWORD(C) ((C)->subword) | |
496 #define OBJECT_CONFLICT_ARRAY(C) ((C)->conflicts_array) | |
497 #define OBJECT_CONFLICT_VEC(C) ((ira_object_t *)(C)->conflicts_array) | |
498 #define OBJECT_CONFLICT_BITVEC(C) ((IRA_INT_TYPE *)(C)->conflicts_array) | |
499 #define OBJECT_CONFLICT_ARRAY_SIZE(C) ((C)->conflicts_array_size) | |
500 #define OBJECT_CONFLICT_VEC_P(C) ((C)->conflict_vec_p) | |
501 #define OBJECT_NUM_CONFLICTS(C) ((C)->num_accumulated_conflicts) | |
502 #define OBJECT_CONFLICT_HARD_REGS(C) ((C)->conflict_hard_regs) | |
503 #define OBJECT_TOTAL_CONFLICT_HARD_REGS(C) ((C)->total_conflict_hard_regs) | |
504 #define OBJECT_MIN(C) ((C)->min) | |
505 #define OBJECT_MAX(C) ((C)->max) | |
506 #define OBJECT_CONFLICT_ID(C) ((C)->id) | |
507 #define OBJECT_LIVE_RANGES(A) ((A)->live_ranges) | |
484 | 508 |
485 /* Map regno -> allocnos with given regno (see comments for | 509 /* Map regno -> allocnos with given regno (see comments for |
486 allocno member `next_regno_allocno'). */ | 510 allocno member `next_regno_allocno'). */ |
487 extern ira_allocno_t *ira_regno_allocno_map; | 511 extern ira_allocno_t *ira_regno_allocno_map; |
488 | 512 |
489 /* Array of references to all allocnos. The order number of the | 513 /* Array of references to all allocnos. The order number of the |
490 allocno corresponds to the index in the array. Removed allocnos | 514 allocno corresponds to the index in the array. Removed allocnos |
491 have NULL element value. */ | 515 have NULL element value. */ |
492 extern ira_allocno_t *ira_allocnos; | 516 extern ira_allocno_t *ira_allocnos; |
493 | 517 |
494 /* Sizes of the previous array. */ | 518 /* The size of the previous array. */ |
495 extern int ira_allocnos_num; | 519 extern int ira_allocnos_num; |
496 | 520 |
497 /* Map conflict id -> allocno with given conflict id (see comments for | 521 /* Map a conflict id to its corresponding ira_object structure. */ |
498 allocno member `conflict_id'). */ | 522 extern ira_object_t *ira_object_id_map; |
499 extern ira_allocno_t *ira_conflict_id_allocno_map; | 523 |
524 /* The size of the previous array. */ | |
525 extern int ira_objects_num; | |
500 | 526 |
501 /* The following structure represents a copy of two allocnos. The | 527 /* The following structure represents a copy of two allocnos. The |
502 copies represent move insns or potential move insns usually because | 528 copies represent move insns or potential move insns usually because |
503 of two operand insn constraints. To remove register shuffle, we | 529 of two operand insn constraints. To remove register shuffle, we |
504 also create copies between allocno which is output of an insn and | 530 also create copies between allocno which is output of an insn and |
562 for pseudo-register live range splitting (see ira-emit.c). */ | 588 for pseudo-register live range splitting (see ira-emit.c). */ |
563 extern int ira_overall_cost; | 589 extern int ira_overall_cost; |
564 extern int ira_reg_cost, ira_mem_cost; | 590 extern int ira_reg_cost, ira_mem_cost; |
565 extern int ira_load_cost, ira_store_cost, ira_shuffle_cost; | 591 extern int ira_load_cost, ira_store_cost, ira_shuffle_cost; |
566 extern int ira_move_loops_num, ira_additional_jumps_num; | 592 extern int ira_move_loops_num, ira_additional_jumps_num; |
567 | 593 |
568 /* Maximal value of element of array ira_reg_class_nregs. */ | 594 /* This page contains a bitset implementation called 'min/max sets' used to |
569 extern int ira_max_nregs; | 595 record conflicts in IRA. |
570 | 596 They are named min/maxs set since we keep track of a minimum and a maximum |
571 /* The number of bits in each element of array used to implement a bit | 597 bit number for each set representing the bounds of valid elements. Otherwise, |
572 vector of allocnos and what type that element has. We use the | 598 the implementation resembles sbitmaps in that we store an array of integers |
573 largest integer format on the host machine. */ | 599 whose bits directly represent the members of the set. */ |
600 | |
601 /* The type used as elements in the array, and the number of bits in | |
602 this type. */ | |
603 | |
574 #define IRA_INT_BITS HOST_BITS_PER_WIDE_INT | 604 #define IRA_INT_BITS HOST_BITS_PER_WIDE_INT |
575 #define IRA_INT_TYPE HOST_WIDE_INT | 605 #define IRA_INT_TYPE HOST_WIDE_INT |
576 | 606 |
577 /* Set, clear or test bit number I in R, a bit vector of elements with | 607 /* Set, clear or test bit number I in R, a bit vector of elements with |
578 minimal index and maximal index equal correspondingly to MIN and | 608 minimal index and maximal index equal correspondingly to MIN and |
579 MAX. */ | 609 MAX. */ |
580 #if defined ENABLE_IRA_CHECKING && (GCC_VERSION >= 2007) | 610 #if defined ENABLE_IRA_CHECKING && (GCC_VERSION >= 2007) |
581 | 611 |
582 #define SET_ALLOCNO_SET_BIT(R, I, MIN, MAX) __extension__ \ | 612 #define SET_MINMAX_SET_BIT(R, I, MIN, MAX) __extension__ \ |
583 (({ int _min = (MIN), _max = (MAX), _i = (I); \ | 613 (({ int _min = (MIN), _max = (MAX), _i = (I); \ |
584 if (_i < _min || _i > _max) \ | 614 if (_i < _min || _i > _max) \ |
585 { \ | 615 { \ |
586 fprintf (stderr, \ | 616 fprintf (stderr, \ |
587 "\n%s: %d: error in %s: %d not in range [%d,%d]\n", \ | 617 "\n%s: %d: error in %s: %d not in range [%d,%d]\n", \ |
590 } \ | 620 } \ |
591 ((R)[(unsigned) (_i - _min) / IRA_INT_BITS] \ | 621 ((R)[(unsigned) (_i - _min) / IRA_INT_BITS] \ |
592 |= ((IRA_INT_TYPE) 1 << ((unsigned) (_i - _min) % IRA_INT_BITS))); })) | 622 |= ((IRA_INT_TYPE) 1 << ((unsigned) (_i - _min) % IRA_INT_BITS))); })) |
593 | 623 |
594 | 624 |
595 #define CLEAR_ALLOCNO_SET_BIT(R, I, MIN, MAX) __extension__ \ | 625 #define CLEAR_MINMAX_SET_BIT(R, I, MIN, MAX) __extension__ \ |
596 (({ int _min = (MIN), _max = (MAX), _i = (I); \ | 626 (({ int _min = (MIN), _max = (MAX), _i = (I); \ |
597 if (_i < _min || _i > _max) \ | 627 if (_i < _min || _i > _max) \ |
598 { \ | 628 { \ |
599 fprintf (stderr, \ | 629 fprintf (stderr, \ |
600 "\n%s: %d: error in %s: %d not in range [%d,%d]\n", \ | 630 "\n%s: %d: error in %s: %d not in range [%d,%d]\n", \ |
602 gcc_unreachable (); \ | 632 gcc_unreachable (); \ |
603 } \ | 633 } \ |
604 ((R)[(unsigned) (_i - _min) / IRA_INT_BITS] \ | 634 ((R)[(unsigned) (_i - _min) / IRA_INT_BITS] \ |
605 &= ~((IRA_INT_TYPE) 1 << ((unsigned) (_i - _min) % IRA_INT_BITS))); })) | 635 &= ~((IRA_INT_TYPE) 1 << ((unsigned) (_i - _min) % IRA_INT_BITS))); })) |
606 | 636 |
607 #define TEST_ALLOCNO_SET_BIT(R, I, MIN, MAX) __extension__ \ | 637 #define TEST_MINMAX_SET_BIT(R, I, MIN, MAX) __extension__ \ |
608 (({ int _min = (MIN), _max = (MAX), _i = (I); \ | 638 (({ int _min = (MIN), _max = (MAX), _i = (I); \ |
609 if (_i < _min || _i > _max) \ | 639 if (_i < _min || _i > _max) \ |
610 { \ | 640 { \ |
611 fprintf (stderr, \ | 641 fprintf (stderr, \ |
612 "\n%s: %d: error in %s: %d not in range [%d,%d]\n", \ | 642 "\n%s: %d: error in %s: %d not in range [%d,%d]\n", \ |
616 ((R)[(unsigned) (_i - _min) / IRA_INT_BITS] \ | 646 ((R)[(unsigned) (_i - _min) / IRA_INT_BITS] \ |
617 & ((IRA_INT_TYPE) 1 << ((unsigned) (_i - _min) % IRA_INT_BITS))); })) | 647 & ((IRA_INT_TYPE) 1 << ((unsigned) (_i - _min) % IRA_INT_BITS))); })) |
618 | 648 |
619 #else | 649 #else |
620 | 650 |
621 #define SET_ALLOCNO_SET_BIT(R, I, MIN, MAX) \ | 651 #define SET_MINMAX_SET_BIT(R, I, MIN, MAX) \ |
622 ((R)[(unsigned) ((I) - (MIN)) / IRA_INT_BITS] \ | 652 ((R)[(unsigned) ((I) - (MIN)) / IRA_INT_BITS] \ |
623 |= ((IRA_INT_TYPE) 1 << ((unsigned) ((I) - (MIN)) % IRA_INT_BITS))) | 653 |= ((IRA_INT_TYPE) 1 << ((unsigned) ((I) - (MIN)) % IRA_INT_BITS))) |
624 | 654 |
625 #define CLEAR_ALLOCNO_SET_BIT(R, I, MIN, MAX) \ | 655 #define CLEAR_MINMAX_SET_BIT(R, I, MIN, MAX) \ |
626 ((R)[(unsigned) ((I) - (MIN)) / IRA_INT_BITS] \ | 656 ((R)[(unsigned) ((I) - (MIN)) / IRA_INT_BITS] \ |
627 &= ~((IRA_INT_TYPE) 1 << ((unsigned) ((I) - (MIN)) % IRA_INT_BITS))) | 657 &= ~((IRA_INT_TYPE) 1 << ((unsigned) ((I) - (MIN)) % IRA_INT_BITS))) |
628 | 658 |
629 #define TEST_ALLOCNO_SET_BIT(R, I, MIN, MAX) \ | 659 #define TEST_MINMAX_SET_BIT(R, I, MIN, MAX) \ |
630 ((R)[(unsigned) ((I) - (MIN)) / IRA_INT_BITS] \ | 660 ((R)[(unsigned) ((I) - (MIN)) / IRA_INT_BITS] \ |
631 & ((IRA_INT_TYPE) 1 << ((unsigned) ((I) - (MIN)) % IRA_INT_BITS))) | 661 & ((IRA_INT_TYPE) 1 << ((unsigned) ((I) - (MIN)) % IRA_INT_BITS))) |
632 | 662 |
633 #endif | 663 #endif |
634 | 664 |
635 /* The iterator for allocno set implemented ed as allocno bit | 665 /* The iterator for min/max sets. */ |
636 vector. */ | |
637 typedef struct { | 666 typedef struct { |
638 | 667 |
639 /* Array containing the allocno bit vector. */ | 668 /* Array containing the bit vector. */ |
640 IRA_INT_TYPE *vec; | 669 IRA_INT_TYPE *vec; |
641 | 670 |
642 /* The number of the current element in the vector. */ | 671 /* The number of the current element in the vector. */ |
643 unsigned int word_num; | 672 unsigned int word_num; |
644 | 673 |
651 /* Index corresponding to the 1st bit of the bit vector. */ | 680 /* Index corresponding to the 1st bit of the bit vector. */ |
652 int start_val; | 681 int start_val; |
653 | 682 |
654 /* The word of the bit vector currently visited. */ | 683 /* The word of the bit vector currently visited. */ |
655 unsigned IRA_INT_TYPE word; | 684 unsigned IRA_INT_TYPE word; |
656 } ira_allocno_set_iterator; | 685 } minmax_set_iterator; |
657 | 686 |
658 /* Initialize the iterator I for allocnos bit vector VEC containing | 687 /* Initialize the iterator I for bit vector VEC containing minimal and |
659 minimal and maximal values MIN and MAX. */ | 688 maximal values MIN and MAX. */ |
660 static inline void | 689 static inline void |
661 ira_allocno_set_iter_init (ira_allocno_set_iterator *i, | 690 minmax_set_iter_init (minmax_set_iterator *i, IRA_INT_TYPE *vec, int min, |
662 IRA_INT_TYPE *vec, int min, int max) | 691 int max) |
663 { | 692 { |
664 i->vec = vec; | 693 i->vec = vec; |
665 i->word_num = 0; | 694 i->word_num = 0; |
666 i->nel = max < min ? 0 : max - min + 1; | 695 i->nel = max < min ? 0 : max - min + 1; |
667 i->start_val = min; | 696 i->start_val = min; |
668 i->bit_num = 0; | 697 i->bit_num = 0; |
669 i->word = i->nel == 0 ? 0 : vec[0]; | 698 i->word = i->nel == 0 ? 0 : vec[0]; |
670 } | 699 } |
671 | 700 |
672 /* Return TRUE if we have more allocnos to visit, in which case *N is | 701 /* Return TRUE if we have more allocnos to visit, in which case *N is |
673 set to the allocno number to be visited. Otherwise, return | 702 set to the number of the element to be visited. Otherwise, return |
674 FALSE. */ | 703 FALSE. */ |
675 static inline bool | 704 static inline bool |
676 ira_allocno_set_iter_cond (ira_allocno_set_iterator *i, int *n) | 705 minmax_set_iter_cond (minmax_set_iterator *i, int *n) |
677 { | 706 { |
678 /* Skip words that are zeros. */ | 707 /* Skip words that are zeros. */ |
679 for (; i->word == 0; i->word = i->vec[i->word_num]) | 708 for (; i->word == 0; i->word = i->vec[i->word_num]) |
680 { | 709 { |
681 i->word_num++; | 710 i->word_num++; |
693 *n = (int) i->bit_num + i->start_val; | 722 *n = (int) i->bit_num + i->start_val; |
694 | 723 |
695 return true; | 724 return true; |
696 } | 725 } |
697 | 726 |
698 /* Advance to the next allocno in the set. */ | 727 /* Advance to the next element in the set. */ |
699 static inline void | 728 static inline void |
700 ira_allocno_set_iter_next (ira_allocno_set_iterator *i) | 729 minmax_set_iter_next (minmax_set_iterator *i) |
701 { | 730 { |
702 i->word >>= 1; | 731 i->word >>= 1; |
703 i->bit_num++; | 732 i->bit_num++; |
704 } | 733 } |
705 | 734 |
706 /* Loop over all elements of allocno set given by bit vector VEC and | 735 /* Loop over all elements of a min/max set given by bit vector VEC and |
707 their minimal and maximal values MIN and MAX. In each iteration, N | 736 their minimal and maximal values MIN and MAX. In each iteration, N |
708 is set to the number of next allocno. ITER is an instance of | 737 is set to the number of next allocno. ITER is an instance of |
709 ira_allocno_set_iterator used to iterate the allocnos in the set. */ | 738 minmax_set_iterator used to iterate over the set. */ |
710 #define FOR_EACH_ALLOCNO_IN_SET(VEC, MIN, MAX, N, ITER) \ | 739 #define FOR_EACH_BIT_IN_MINMAX_SET(VEC, MIN, MAX, N, ITER) \ |
711 for (ira_allocno_set_iter_init (&(ITER), (VEC), (MIN), (MAX)); \ | 740 for (minmax_set_iter_init (&(ITER), (VEC), (MIN), (MAX)); \ |
712 ira_allocno_set_iter_cond (&(ITER), &(N)); \ | 741 minmax_set_iter_cond (&(ITER), &(N)); \ |
713 ira_allocno_set_iter_next (&(ITER))) | 742 minmax_set_iter_next (&(ITER))) |
714 | 743 |
744 struct target_ira_int { | |
745 /* Initialized once. It is a maximal possible size of the allocated | |
746 struct costs. */ | |
747 int x_max_struct_costs_size; | |
748 | |
749 /* Allocated and initialized once, and used to initialize cost values | |
750 for each insn. */ | |
751 struct costs *x_init_cost; | |
752 | |
753 /* Allocated once, and used for temporary purposes. */ | |
754 struct costs *x_temp_costs; | |
755 | |
756 /* Allocated once, and used for the cost calculation. */ | |
757 struct costs *x_op_costs[MAX_RECOG_OPERANDS]; | |
758 struct costs *x_this_op_costs[MAX_RECOG_OPERANDS]; | |
759 | |
760 /* Classes used for cost calculation. They may be different on | |
761 different iterations of the cost calculations or in different | |
762 optimization modes. */ | |
763 enum reg_class *x_cost_classes; | |
764 | |
765 /* Hard registers that can not be used for the register allocator for | |
766 all functions of the current compilation unit. */ | |
767 HARD_REG_SET x_no_unit_alloc_regs; | |
768 | |
769 /* Map: hard regs X modes -> set of hard registers for storing value | |
770 of given mode starting with given hard register. */ | |
771 HARD_REG_SET (x_ira_reg_mode_hard_regset | |
772 [FIRST_PSEUDO_REGISTER][NUM_MACHINE_MODES]); | |
773 | |
774 /* Array based on TARGET_REGISTER_MOVE_COST. Don't use | |
775 ira_register_move_cost directly. Use function of | |
776 ira_get_may_move_cost instead. */ | |
777 move_table *x_ira_register_move_cost[MAX_MACHINE_MODE]; | |
778 | |
779 /* Similar to may_move_in_cost but it is calculated in IRA instead of | |
780 regclass. Another difference we take only available hard registers | |
781 into account to figure out that one register class is a subset of | |
782 the another one. Don't use it directly. Use function of | |
783 ira_get_may_move_cost instead. */ | |
784 move_table *x_ira_may_move_in_cost[MAX_MACHINE_MODE]; | |
785 | |
786 /* Similar to may_move_out_cost but it is calculated in IRA instead of | |
787 regclass. Another difference we take only available hard registers | |
788 into account to figure out that one register class is a subset of | |
789 the another one. Don't use it directly. Use function of | |
790 ira_get_may_move_cost instead. */ | |
791 move_table *x_ira_may_move_out_cost[MAX_MACHINE_MODE]; | |
792 | |
793 /* Register class subset relation: TRUE if the first class is a subset | |
794 of the second one considering only hard registers available for the | |
795 allocation. */ | |
796 int x_ira_class_subset_p[N_REG_CLASSES][N_REG_CLASSES]; | |
797 | |
798 /* Array of the number of hard registers of given class which are | |
799 available for allocation. The order is defined by the the hard | |
800 register numbers. */ | |
801 short x_ira_non_ordered_class_hard_regs[N_REG_CLASSES][FIRST_PSEUDO_REGISTER]; | |
802 | |
803 /* Index (in ira_class_hard_regs; for given register class and hard | |
804 register (in general case a hard register can belong to several | |
805 register classes;. The index is negative for hard registers | |
806 unavailable for the allocation. */ | |
807 short x_ira_class_hard_reg_index[N_REG_CLASSES][FIRST_PSEUDO_REGISTER]; | |
808 | |
809 /* Array whose values are hard regset of hard registers available for | |
810 the allocation of given register class whose HARD_REGNO_MODE_OK | |
811 values for given mode are zero. */ | |
812 HARD_REG_SET x_prohibited_class_mode_regs[N_REG_CLASSES][NUM_MACHINE_MODES]; | |
813 | |
814 /* The value is number of elements in the subsequent array. */ | |
815 int x_ira_important_classes_num; | |
816 | |
817 /* The array containing non-empty classes (including non-empty cover | |
818 classes; which are subclasses of cover classes. Such classes is | |
819 important for calculation of the hard register usage costs. */ | |
820 enum reg_class x_ira_important_classes[N_REG_CLASSES]; | |
821 | |
822 /* The biggest important class inside of intersection of the two | |
823 classes (that is calculated taking only hard registers available | |
824 for allocation into account;. If the both classes contain no hard | |
825 registers available for allocation, the value is calculated with | |
826 taking all hard-registers including fixed ones into account. */ | |
827 enum reg_class x_ira_reg_class_intersect[N_REG_CLASSES][N_REG_CLASSES]; | |
828 | |
829 /* True if the two classes (that is calculated taking only hard | |
830 registers available for allocation into account; are | |
831 intersected. */ | |
832 bool x_ira_reg_classes_intersect_p[N_REG_CLASSES][N_REG_CLASSES]; | |
833 | |
834 /* Classes with end marker LIM_REG_CLASSES which are intersected with | |
835 given class (the first index;. That includes given class itself. | |
836 This is calculated taking only hard registers available for | |
837 allocation into account. */ | |
838 enum reg_class x_ira_reg_class_super_classes[N_REG_CLASSES][N_REG_CLASSES]; | |
839 | |
840 /* The biggest important class inside of union of the two classes | |
841 (that is calculated taking only hard registers available for | |
842 allocation into account;. If the both classes contain no hard | |
843 registers available for allocation, the value is calculated with | |
844 taking all hard-registers including fixed ones into account. In | |
845 other words, the value is the corresponding reg_class_subunion | |
846 value. */ | |
847 enum reg_class x_ira_reg_class_union[N_REG_CLASSES][N_REG_CLASSES]; | |
848 | |
849 /* For each reg class, table listing all the classes contained in it | |
850 (excluding the class itself. Non-allocatable registers are | |
851 excluded from the consideration;. */ | |
852 enum reg_class x_alloc_reg_class_subclasses[N_REG_CLASSES][N_REG_CLASSES]; | |
853 | |
854 /* Array whose values are hard regset of hard registers for which | |
855 move of the hard register in given mode into itself is | |
856 prohibited. */ | |
857 HARD_REG_SET x_ira_prohibited_mode_move_regs[NUM_MACHINE_MODES]; | |
858 | |
859 /* Flag of that the above array has been initialized. */ | |
860 bool x_ira_prohibited_mode_move_regs_initialized_p; | |
861 }; | |
862 | |
863 extern struct target_ira_int default_target_ira_int; | |
864 #if SWITCHABLE_TARGET | |
865 extern struct target_ira_int *this_target_ira_int; | |
866 #else | |
867 #define this_target_ira_int (&default_target_ira_int) | |
868 #endif | |
869 | |
870 #define ira_reg_mode_hard_regset \ | |
871 (this_target_ira_int->x_ira_reg_mode_hard_regset) | |
872 #define ira_register_move_cost \ | |
873 (this_target_ira_int->x_ira_register_move_cost) | |
874 #define ira_may_move_in_cost \ | |
875 (this_target_ira_int->x_ira_may_move_in_cost) | |
876 #define ira_may_move_out_cost \ | |
877 (this_target_ira_int->x_ira_may_move_out_cost) | |
878 #define ira_class_subset_p \ | |
879 (this_target_ira_int->x_ira_class_subset_p) | |
880 #define ira_non_ordered_class_hard_regs \ | |
881 (this_target_ira_int->x_ira_non_ordered_class_hard_regs) | |
882 #define ira_class_hard_reg_index \ | |
883 (this_target_ira_int->x_ira_class_hard_reg_index) | |
884 #define prohibited_class_mode_regs \ | |
885 (this_target_ira_int->x_prohibited_class_mode_regs) | |
886 #define ira_important_classes_num \ | |
887 (this_target_ira_int->x_ira_important_classes_num) | |
888 #define ira_important_classes \ | |
889 (this_target_ira_int->x_ira_important_classes) | |
890 #define ira_reg_class_intersect \ | |
891 (this_target_ira_int->x_ira_reg_class_intersect) | |
892 #define ira_reg_classes_intersect_p \ | |
893 (this_target_ira_int->x_ira_reg_classes_intersect_p) | |
894 #define ira_reg_class_super_classes \ | |
895 (this_target_ira_int->x_ira_reg_class_super_classes) | |
896 #define ira_reg_class_union \ | |
897 (this_target_ira_int->x_ira_reg_class_union) | |
898 #define ira_prohibited_mode_move_regs \ | |
899 (this_target_ira_int->x_ira_prohibited_mode_move_regs) | |
900 | |
715 /* ira.c: */ | 901 /* ira.c: */ |
716 | |
717 /* Map: hard regs X modes -> set of hard registers for storing value | |
718 of given mode starting with given hard register. */ | |
719 extern HARD_REG_SET ira_reg_mode_hard_regset | |
720 [FIRST_PSEUDO_REGISTER][NUM_MACHINE_MODES]; | |
721 | |
722 /* Array analogous to macro REGISTER_MOVE_COST. Don't use | |
723 ira_register_move_cost directly. Use function of | |
724 ira_get_may_move_cost instead. */ | |
725 extern move_table *ira_register_move_cost[MAX_MACHINE_MODE]; | |
726 | |
727 /* Similar to may_move_in_cost but it is calculated in IRA instead of | |
728 regclass. Another difference we take only available hard registers | |
729 into account to figure out that one register class is a subset of | |
730 the another one. Don't use it directly. Use function of | |
731 ira_get_may_move_cost instead. */ | |
732 extern move_table *ira_may_move_in_cost[MAX_MACHINE_MODE]; | |
733 | |
734 /* Similar to may_move_out_cost but it is calculated in IRA instead of | |
735 regclass. Another difference we take only available hard registers | |
736 into account to figure out that one register class is a subset of | |
737 the another one. Don't use it directly. Use function of | |
738 ira_get_may_move_cost instead. */ | |
739 extern move_table *ira_may_move_out_cost[MAX_MACHINE_MODE]; | |
740 | |
741 /* Register class subset relation: TRUE if the first class is a subset | |
742 of the second one considering only hard registers available for the | |
743 allocation. */ | |
744 extern int ira_class_subset_p[N_REG_CLASSES][N_REG_CLASSES]; | |
745 | |
746 /* Array of the number of hard registers of given class which are | |
747 available for allocation. The order is defined by the the hard | |
748 register numbers. */ | |
749 extern short ira_non_ordered_class_hard_regs[N_REG_CLASSES][FIRST_PSEUDO_REGISTER]; | |
750 | |
751 /* Index (in ira_class_hard_regs) for given register class and hard | |
752 register (in general case a hard register can belong to several | |
753 register classes). The index is negative for hard registers | |
754 unavailable for the allocation. */ | |
755 extern short ira_class_hard_reg_index[N_REG_CLASSES][FIRST_PSEUDO_REGISTER]; | |
756 | |
757 /* Array whose values are hard regset of hard registers available for | |
758 the allocation of given register class whose HARD_REGNO_MODE_OK | |
759 values for given mode are zero. */ | |
760 extern HARD_REG_SET prohibited_class_mode_regs | |
761 [N_REG_CLASSES][NUM_MACHINE_MODES]; | |
762 | |
763 /* Array whose values are hard regset of hard registers for which | |
764 move of the hard register in given mode into itself is | |
765 prohibited. */ | |
766 extern HARD_REG_SET ira_prohibited_mode_move_regs[NUM_MACHINE_MODES]; | |
767 | |
768 /* The value is number of elements in the subsequent array. */ | |
769 extern int ira_important_classes_num; | |
770 | |
771 /* The array containing non-empty classes (including non-empty cover | |
772 classes) which are subclasses of cover classes. Such classes is | |
773 important for calculation of the hard register usage costs. */ | |
774 extern enum reg_class ira_important_classes[N_REG_CLASSES]; | |
775 | |
776 /* The array containing indexes of important classes in the previous | |
777 array. The array elements are defined only for important | |
778 classes. */ | |
779 extern int ira_important_class_nums[N_REG_CLASSES]; | |
780 | |
781 /* The biggest important class inside of intersection of the two | |
782 classes (that is calculated taking only hard registers available | |
783 for allocation into account). If the both classes contain no hard | |
784 registers available for allocation, the value is calculated with | |
785 taking all hard-registers including fixed ones into account. */ | |
786 extern enum reg_class ira_reg_class_intersect[N_REG_CLASSES][N_REG_CLASSES]; | |
787 | |
788 /* True if the two classes (that is calculated taking only hard | |
789 registers available for allocation into account) are | |
790 intersected. */ | |
791 extern bool ira_reg_classes_intersect_p[N_REG_CLASSES][N_REG_CLASSES]; | |
792 | |
793 /* Classes with end marker LIM_REG_CLASSES which are intersected with | |
794 given class (the first index). That includes given class itself. | |
795 This is calculated taking only hard registers available for | |
796 allocation into account. */ | |
797 extern enum reg_class ira_reg_class_super_classes[N_REG_CLASSES][N_REG_CLASSES]; | |
798 /* The biggest important class inside of union of the two classes | |
799 (that is calculated taking only hard registers available for | |
800 allocation into account). If the both classes contain no hard | |
801 registers available for allocation, the value is calculated with | |
802 taking all hard-registers including fixed ones into account. In | |
803 other words, the value is the corresponding reg_class_subunion | |
804 value. */ | |
805 extern enum reg_class ira_reg_class_union[N_REG_CLASSES][N_REG_CLASSES]; | |
806 | 902 |
807 extern void *ira_allocate (size_t); | 903 extern void *ira_allocate (size_t); |
808 extern void *ira_reallocate (void *, size_t); | 904 extern void *ira_reallocate (void *, size_t); |
809 extern void ira_free (void *addr); | 905 extern void ira_free (void *addr); |
810 extern bitmap ira_allocate_bitmap (void); | 906 extern bitmap ira_allocate_bitmap (void); |
836 extern void ira_debug_allocno_copies (ira_allocno_t); | 932 extern void ira_debug_allocno_copies (ira_allocno_t); |
837 | 933 |
838 extern void ira_traverse_loop_tree (bool, ira_loop_tree_node_t, | 934 extern void ira_traverse_loop_tree (bool, ira_loop_tree_node_t, |
839 void (*) (ira_loop_tree_node_t), | 935 void (*) (ira_loop_tree_node_t), |
840 void (*) (ira_loop_tree_node_t)); | 936 void (*) (ira_loop_tree_node_t)); |
937 extern ira_allocno_t ira_parent_allocno (ira_allocno_t); | |
938 extern ira_allocno_t ira_parent_or_cap_allocno (ira_allocno_t); | |
841 extern ira_allocno_t ira_create_allocno (int, bool, ira_loop_tree_node_t); | 939 extern ira_allocno_t ira_create_allocno (int, bool, ira_loop_tree_node_t); |
940 extern void ira_create_allocno_objects (ira_allocno_t); | |
842 extern void ira_set_allocno_cover_class (ira_allocno_t, enum reg_class); | 941 extern void ira_set_allocno_cover_class (ira_allocno_t, enum reg_class); |
843 extern bool ira_conflict_vector_profitable_p (ira_allocno_t, int); | 942 extern bool ira_conflict_vector_profitable_p (ira_object_t, int); |
844 extern void ira_allocate_allocno_conflict_vec (ira_allocno_t, int); | 943 extern void ira_allocate_conflict_vec (ira_object_t, int); |
845 extern void ira_allocate_allocno_conflicts (ira_allocno_t, int); | 944 extern void ira_allocate_object_conflicts (ira_object_t, int); |
846 extern void ira_add_allocno_conflict (ira_allocno_t, ira_allocno_t); | 945 extern void ior_hard_reg_conflicts (ira_allocno_t, HARD_REG_SET *); |
847 extern void ira_print_expanded_allocno (ira_allocno_t); | 946 extern void ira_print_expanded_allocno (ira_allocno_t); |
848 extern allocno_live_range_t ira_create_allocno_live_range | 947 extern void ira_add_live_range_to_object (ira_object_t, int, int); |
849 (ira_allocno_t, int, int, allocno_live_range_t); | 948 extern live_range_t ira_create_live_range (ira_object_t, int, int, |
850 extern allocno_live_range_t ira_copy_allocno_live_range_list | 949 live_range_t); |
851 (allocno_live_range_t); | 950 extern live_range_t ira_copy_live_range_list (live_range_t); |
852 extern allocno_live_range_t ira_merge_allocno_live_ranges | 951 extern live_range_t ira_merge_live_ranges (live_range_t, live_range_t); |
853 (allocno_live_range_t, allocno_live_range_t); | 952 extern bool ira_live_ranges_intersect_p (live_range_t, live_range_t); |
854 extern bool ira_allocno_live_ranges_intersect_p (allocno_live_range_t, | 953 extern void ira_finish_live_range (live_range_t); |
855 allocno_live_range_t); | 954 extern void ira_finish_live_range_list (live_range_t); |
856 extern void ira_finish_allocno_live_range (allocno_live_range_t); | |
857 extern void ira_finish_allocno_live_range_list (allocno_live_range_t); | |
858 extern void ira_free_allocno_updated_costs (ira_allocno_t); | 955 extern void ira_free_allocno_updated_costs (ira_allocno_t); |
859 extern ira_copy_t ira_create_copy (ira_allocno_t, ira_allocno_t, | 956 extern ira_copy_t ira_create_copy (ira_allocno_t, ira_allocno_t, |
860 int, bool, rtx, ira_loop_tree_node_t); | 957 int, bool, rtx, ira_loop_tree_node_t); |
861 extern void ira_add_allocno_copy_to_list (ira_copy_t); | 958 extern void ira_add_allocno_copy_to_list (ira_copy_t); |
862 extern void ira_swap_allocno_copy_ends_if_necessary (ira_copy_t); | 959 extern void ira_swap_allocno_copy_ends_if_necessary (ira_copy_t); |
863 extern void ira_remove_allocno_copy_from_list (ira_copy_t); | |
864 extern ira_copy_t ira_add_allocno_copy (ira_allocno_t, ira_allocno_t, int, | 960 extern ira_copy_t ira_add_allocno_copy (ira_allocno_t, ira_allocno_t, int, |
865 bool, rtx, ira_loop_tree_node_t); | 961 bool, rtx, ira_loop_tree_node_t); |
866 | 962 |
867 extern int *ira_allocate_cost_vector (enum reg_class); | 963 extern int *ira_allocate_cost_vector (enum reg_class); |
868 extern void ira_free_cost_vector (int *, enum reg_class); | 964 extern void ira_free_cost_vector (int *, enum reg_class); |
879 extern void ira_tune_allocno_costs_and_cover_classes (void); | 975 extern void ira_tune_allocno_costs_and_cover_classes (void); |
880 | 976 |
881 /* ira-lives.c */ | 977 /* ira-lives.c */ |
882 | 978 |
883 extern void ira_rebuild_start_finish_chains (void); | 979 extern void ira_rebuild_start_finish_chains (void); |
884 extern void ira_print_live_range_list (FILE *, allocno_live_range_t); | 980 extern void ira_print_live_range_list (FILE *, live_range_t); |
885 extern void ira_debug_live_range_list (allocno_live_range_t); | 981 extern void ira_debug_live_range_list (live_range_t); |
886 extern void ira_debug_allocno_live_ranges (ira_allocno_t); | 982 extern void ira_debug_allocno_live_ranges (ira_allocno_t); |
887 extern void ira_debug_live_ranges (void); | 983 extern void ira_debug_live_ranges (void); |
888 extern void ira_create_allocno_live_ranges (void); | 984 extern void ira_create_allocno_live_ranges (void); |
889 extern void ira_compress_allocno_live_ranges (void); | 985 extern void ira_compress_allocno_live_ranges (void); |
890 extern void ira_finish_allocno_live_ranges (void); | 986 extern void ira_finish_allocno_live_ranges (void); |
967 allocno. ITER is an instance of ira_allocno_iterator used to iterate | 1063 allocno. ITER is an instance of ira_allocno_iterator used to iterate |
968 the allocnos. */ | 1064 the allocnos. */ |
969 #define FOR_EACH_ALLOCNO(A, ITER) \ | 1065 #define FOR_EACH_ALLOCNO(A, ITER) \ |
970 for (ira_allocno_iter_init (&(ITER)); \ | 1066 for (ira_allocno_iter_init (&(ITER)); \ |
971 ira_allocno_iter_cond (&(ITER), &(A));) | 1067 ira_allocno_iter_cond (&(ITER), &(A));) |
972 | 1068 |
973 | 1069 /* The iterator for all objects. */ |
1070 typedef struct { | |
1071 /* The number of the current element in ira_object_id_map. */ | |
1072 int n; | |
1073 } ira_object_iterator; | |
1074 | |
1075 /* Initialize the iterator I. */ | |
1076 static inline void | |
1077 ira_object_iter_init (ira_object_iterator *i) | |
1078 { | |
1079 i->n = 0; | |
1080 } | |
1081 | |
1082 /* Return TRUE if we have more objects to visit, in which case *OBJ is | |
1083 set to the object to be visited. Otherwise, return FALSE. */ | |
1084 static inline bool | |
1085 ira_object_iter_cond (ira_object_iterator *i, ira_object_t *obj) | |
1086 { | |
1087 int n; | |
1088 | |
1089 for (n = i->n; n < ira_objects_num; n++) | |
1090 if (ira_object_id_map[n] != NULL) | |
1091 { | |
1092 *obj = ira_object_id_map[n]; | |
1093 i->n = n + 1; | |
1094 return true; | |
1095 } | |
1096 return false; | |
1097 } | |
1098 | |
1099 /* Loop over all objects. In each iteration, OBJ is set to the next | |
1100 object. ITER is an instance of ira_object_iterator used to iterate | |
1101 the objects. */ | |
1102 #define FOR_EACH_OBJECT(OBJ, ITER) \ | |
1103 for (ira_object_iter_init (&(ITER)); \ | |
1104 ira_object_iter_cond (&(ITER), &(OBJ));) | |
1105 | |
1106 /* The iterator for objects associated with an allocno. */ | |
1107 typedef struct { | |
1108 /* The number of the element the allocno's object array. */ | |
1109 int n; | |
1110 } ira_allocno_object_iterator; | |
1111 | |
1112 /* Initialize the iterator I. */ | |
1113 static inline void | |
1114 ira_allocno_object_iter_init (ira_allocno_object_iterator *i) | |
1115 { | |
1116 i->n = 0; | |
1117 } | |
1118 | |
1119 /* Return TRUE if we have more objects to visit in allocno A, in which | |
1120 case *O is set to the object to be visited. Otherwise, return | |
1121 FALSE. */ | |
1122 static inline bool | |
1123 ira_allocno_object_iter_cond (ira_allocno_object_iterator *i, ira_allocno_t a, | |
1124 ira_object_t *o) | |
1125 { | |
1126 *o = ALLOCNO_OBJECT (a, i->n); | |
1127 return i->n++ < ALLOCNO_NUM_OBJECTS (a); | |
1128 } | |
1129 | |
1130 /* Loop over all objects associated with allocno A. In each | |
1131 iteration, O is set to the next object. ITER is an instance of | |
1132 ira_allocno_object_iterator used to iterate the conflicts. */ | |
1133 #define FOR_EACH_ALLOCNO_OBJECT(A, O, ITER) \ | |
1134 for (ira_allocno_object_iter_init (&(ITER)); \ | |
1135 ira_allocno_object_iter_cond (&(ITER), (A), &(O));) | |
974 | 1136 |
975 | 1137 |
976 /* The iterator for copies. */ | 1138 /* The iterator for copies. */ |
977 typedef struct { | 1139 typedef struct { |
978 /* The number of the current element in IRA_COPIES. */ | 1140 /* The number of the current element in IRA_COPIES. */ |
1007 copy. ITER is an instance of ira_copy_iterator used to iterate | 1169 copy. ITER is an instance of ira_copy_iterator used to iterate |
1008 the copies. */ | 1170 the copies. */ |
1009 #define FOR_EACH_COPY(C, ITER) \ | 1171 #define FOR_EACH_COPY(C, ITER) \ |
1010 for (ira_copy_iter_init (&(ITER)); \ | 1172 for (ira_copy_iter_init (&(ITER)); \ |
1011 ira_copy_iter_cond (&(ITER), &(C));) | 1173 ira_copy_iter_cond (&(ITER), &(C));) |
1012 | |
1013 | |
1014 | 1174 |
1015 | 1175 /* The iterator for object conflicts. */ |
1016 /* The iterator for allocno conflicts. */ | |
1017 typedef struct { | 1176 typedef struct { |
1018 | 1177 |
1019 /* TRUE if the conflicts are represented by vector of allocnos. */ | 1178 /* TRUE if the conflicts are represented by vector of allocnos. */ |
1020 bool allocno_conflict_vec_p; | 1179 bool conflict_vec_p; |
1021 | 1180 |
1022 /* The conflict vector or conflict bit vector. */ | 1181 /* The conflict vector or conflict bit vector. */ |
1023 void *vec; | 1182 void *vec; |
1024 | 1183 |
1025 /* The number of the current element in the vector (of type | 1184 /* The number of the current element in the vector (of type |
1026 ira_allocno_t or IRA_INT_TYPE). */ | 1185 ira_object_t or IRA_INT_TYPE). */ |
1027 unsigned int word_num; | 1186 unsigned int word_num; |
1028 | 1187 |
1029 /* The bit vector size. It is defined only if | 1188 /* The bit vector size. It is defined only if |
1030 ALLOCNO_CONFLICT_VEC_P is FALSE. */ | 1189 OBJECT_CONFLICT_VEC_P is FALSE. */ |
1031 unsigned int size; | 1190 unsigned int size; |
1032 | 1191 |
1033 /* The current bit index of bit vector. It is defined only if | 1192 /* The current bit index of bit vector. It is defined only if |
1034 ALLOCNO_CONFLICT_VEC_P is FALSE. */ | 1193 OBJECT_CONFLICT_VEC_P is FALSE. */ |
1035 unsigned int bit_num; | 1194 unsigned int bit_num; |
1036 | 1195 |
1037 /* Allocno conflict id corresponding to the 1st bit of the bit | 1196 /* The object id corresponding to the 1st bit of the bit vector. It |
1038 vector. It is defined only if ALLOCNO_CONFLICT_VEC_P is | 1197 is defined only if OBJECT_CONFLICT_VEC_P is FALSE. */ |
1039 FALSE. */ | |
1040 int base_conflict_id; | 1198 int base_conflict_id; |
1041 | 1199 |
1042 /* The word of bit vector currently visited. It is defined only if | 1200 /* The word of bit vector currently visited. It is defined only if |
1043 ALLOCNO_CONFLICT_VEC_P is FALSE. */ | 1201 OBJECT_CONFLICT_VEC_P is FALSE. */ |
1044 unsigned IRA_INT_TYPE word; | 1202 unsigned IRA_INT_TYPE word; |
1045 } ira_allocno_conflict_iterator; | 1203 } ira_object_conflict_iterator; |
1046 | 1204 |
1047 /* Initialize the iterator I with ALLOCNO conflicts. */ | 1205 /* Initialize the iterator I with ALLOCNO conflicts. */ |
1048 static inline void | 1206 static inline void |
1049 ira_allocno_conflict_iter_init (ira_allocno_conflict_iterator *i, | 1207 ira_object_conflict_iter_init (ira_object_conflict_iterator *i, |
1050 ira_allocno_t allocno) | 1208 ira_object_t obj) |
1051 { | 1209 { |
1052 i->allocno_conflict_vec_p = ALLOCNO_CONFLICT_VEC_P (allocno); | 1210 i->conflict_vec_p = OBJECT_CONFLICT_VEC_P (obj); |
1053 i->vec = ALLOCNO_CONFLICT_ALLOCNO_ARRAY (allocno); | 1211 i->vec = OBJECT_CONFLICT_ARRAY (obj); |
1054 i->word_num = 0; | 1212 i->word_num = 0; |
1055 if (i->allocno_conflict_vec_p) | 1213 if (i->conflict_vec_p) |
1056 i->size = i->bit_num = i->base_conflict_id = i->word = 0; | 1214 i->size = i->bit_num = i->base_conflict_id = i->word = 0; |
1057 else | 1215 else |
1058 { | 1216 { |
1059 if (ALLOCNO_MIN (allocno) > ALLOCNO_MAX (allocno)) | 1217 if (OBJECT_MIN (obj) > OBJECT_MAX (obj)) |
1060 i->size = 0; | 1218 i->size = 0; |
1061 else | 1219 else |
1062 i->size = ((ALLOCNO_MAX (allocno) - ALLOCNO_MIN (allocno) | 1220 i->size = ((OBJECT_MAX (obj) - OBJECT_MIN (obj) |
1063 + IRA_INT_BITS) | 1221 + IRA_INT_BITS) |
1064 / IRA_INT_BITS) * sizeof (IRA_INT_TYPE); | 1222 / IRA_INT_BITS) * sizeof (IRA_INT_TYPE); |
1065 i->bit_num = 0; | 1223 i->bit_num = 0; |
1066 i->base_conflict_id = ALLOCNO_MIN (allocno); | 1224 i->base_conflict_id = OBJECT_MIN (obj); |
1067 i->word = (i->size == 0 ? 0 : ((IRA_INT_TYPE *) i->vec)[0]); | 1225 i->word = (i->size == 0 ? 0 : ((IRA_INT_TYPE *) i->vec)[0]); |
1068 } | 1226 } |
1069 } | 1227 } |
1070 | 1228 |
1071 /* Return TRUE if we have more conflicting allocnos to visit, in which | 1229 /* Return TRUE if we have more conflicting allocnos to visit, in which |
1072 case *A is set to the allocno to be visited. Otherwise, return | 1230 case *A is set to the allocno to be visited. Otherwise, return |
1073 FALSE. */ | 1231 FALSE. */ |
1074 static inline bool | 1232 static inline bool |
1075 ira_allocno_conflict_iter_cond (ira_allocno_conflict_iterator *i, | 1233 ira_object_conflict_iter_cond (ira_object_conflict_iterator *i, |
1076 ira_allocno_t *a) | 1234 ira_object_t *pobj) |
1077 { | 1235 { |
1078 ira_allocno_t conflict_allocno; | 1236 ira_object_t obj; |
1079 | 1237 |
1080 if (i->allocno_conflict_vec_p) | 1238 if (i->conflict_vec_p) |
1081 { | 1239 { |
1082 conflict_allocno = ((ira_allocno_t *) i->vec)[i->word_num]; | 1240 obj = ((ira_object_t *) i->vec)[i->word_num]; |
1083 if (conflict_allocno == NULL) | 1241 if (obj == NULL) |
1084 return false; | 1242 return false; |
1085 *a = conflict_allocno; | |
1086 return true; | |
1087 } | 1243 } |
1088 else | 1244 else |
1089 { | 1245 { |
1090 /* Skip words that are zeros. */ | 1246 /* Skip words that are zeros. */ |
1091 for (; i->word == 0; i->word = ((IRA_INT_TYPE *) i->vec)[i->word_num]) | 1247 for (; i->word == 0; i->word = ((IRA_INT_TYPE *) i->vec)[i->word_num]) |
1101 | 1257 |
1102 /* Skip bits that are zero. */ | 1258 /* Skip bits that are zero. */ |
1103 for (; (i->word & 1) == 0; i->word >>= 1) | 1259 for (; (i->word & 1) == 0; i->word >>= 1) |
1104 i->bit_num++; | 1260 i->bit_num++; |
1105 | 1261 |
1106 *a = ira_conflict_id_allocno_map[i->bit_num + i->base_conflict_id]; | 1262 obj = ira_object_id_map[i->bit_num + i->base_conflict_id]; |
1107 | |
1108 return true; | |
1109 } | 1263 } |
1264 | |
1265 *pobj = obj; | |
1266 return true; | |
1110 } | 1267 } |
1111 | 1268 |
1112 /* Advance to the next conflicting allocno. */ | 1269 /* Advance to the next conflicting allocno. */ |
1113 static inline void | 1270 static inline void |
1114 ira_allocno_conflict_iter_next (ira_allocno_conflict_iterator *i) | 1271 ira_object_conflict_iter_next (ira_object_conflict_iterator *i) |
1115 { | 1272 { |
1116 if (i->allocno_conflict_vec_p) | 1273 if (i->conflict_vec_p) |
1117 i->word_num++; | 1274 i->word_num++; |
1118 else | 1275 else |
1119 { | 1276 { |
1120 i->word >>= 1; | 1277 i->word >>= 1; |
1121 i->bit_num++; | 1278 i->bit_num++; |
1122 } | 1279 } |
1123 } | 1280 } |
1124 | 1281 |
1125 /* Loop over all allocnos conflicting with ALLOCNO. In each | 1282 /* Loop over all objects conflicting with OBJ. In each iteration, |
1126 iteration, A is set to the next conflicting allocno. ITER is an | 1283 CONF is set to the next conflicting object. ITER is an instance |
1127 instance of ira_allocno_conflict_iterator used to iterate the | 1284 of ira_object_conflict_iterator used to iterate the conflicts. */ |
1128 conflicts. */ | 1285 #define FOR_EACH_OBJECT_CONFLICT(OBJ, CONF, ITER) \ |
1129 #define FOR_EACH_ALLOCNO_CONFLICT(ALLOCNO, A, ITER) \ | 1286 for (ira_object_conflict_iter_init (&(ITER), (OBJ)); \ |
1130 for (ira_allocno_conflict_iter_init (&(ITER), (ALLOCNO)); \ | 1287 ira_object_conflict_iter_cond (&(ITER), &(CONF)); \ |
1131 ira_allocno_conflict_iter_cond (&(ITER), &(A)); \ | 1288 ira_object_conflict_iter_next (&(ITER))) |
1132 ira_allocno_conflict_iter_next (&(ITER))) | |
1133 | 1289 |
1134 | 1290 |
1135 | 1291 |
1136 /* The function returns TRUE if hard registers starting with | 1292 /* The function returns TRUE if hard registers starting with |
1137 HARD_REGNO and containing value of MODE are not in set | 1293 HARD_REGNO and containing value of MODE are not in set |