1 /* IRA conflict builder.
2 Copyright (C) 2006, 2007, 2008, 2009
3 Free Software Foundation, Inc.
4 Contributed by Vladimir Makarov <vmakarov@redhat.com>.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
24 #include "coretypes.h"
31 #include "hard-reg-set.h"
32 #include "basic-block.h"
33 #include "insn-config.h"
38 #include "sparseset.h"
40 #include "addresses.h"
42 /* This file contains code responsible for allocno conflict creation,
43 allocno copy creation and allocno info accumulation on upper level
46 /* ira_allocnos_num array of arrays of bits, recording whether two
47 allocno's conflict (can't go in the same hardware register).
49 Some arrays will be used as conflict bit vector of the
50 corresponding allocnos see function build_allocno_conflicts. */
51 static IRA_INT_TYPE
**conflicts
;
53 /* Macro to test a conflict of A1 and A2 in `conflicts'. */
54 #define CONFLICT_ALLOCNO_P(A1, A2) \
55 (ALLOCNO_MIN (A1) <= ALLOCNO_CONFLICT_ID (A2) \
56 && ALLOCNO_CONFLICT_ID (A2) <= ALLOCNO_MAX (A1) \
57 && TEST_ALLOCNO_SET_BIT (conflicts[ALLOCNO_NUM (A1)], \
58 ALLOCNO_CONFLICT_ID (A2), \
64 /* Build allocno conflict table by processing allocno live ranges.
65 Return true if the table was built. The table is not built if it
68 build_conflict_bit_table (void)
70 int i
, num
, id
, allocated_words_num
, conflict_bit_vec_words_num
;
72 enum reg_class cover_class
;
73 ira_allocno_t allocno
, live_a
;
74 allocno_live_range_t r
;
75 ira_allocno_iterator ai
;
76 sparseset allocnos_live
;
77 int allocno_set_words
;
79 allocno_set_words
= (ira_allocnos_num
+ IRA_INT_BITS
- 1) / IRA_INT_BITS
;
80 allocated_words_num
= 0;
81 FOR_EACH_ALLOCNO (allocno
, ai
)
83 if (ALLOCNO_MAX (allocno
) < ALLOCNO_MIN (allocno
))
85 conflict_bit_vec_words_num
86 = ((ALLOCNO_MAX (allocno
) - ALLOCNO_MIN (allocno
) + IRA_INT_BITS
)
88 allocated_words_num
+= conflict_bit_vec_words_num
;
89 if ((unsigned long long) allocated_words_num
* sizeof (IRA_INT_TYPE
)
90 > (unsigned long long) IRA_MAX_CONFLICT_TABLE_SIZE
* 1024 * 1024)
92 if (internal_flag_ira_verbose
> 0 && ira_dump_file
!= NULL
)
95 "+++Conflict table will be too big(>%dMB) -- don't use it\n",
96 IRA_MAX_CONFLICT_TABLE_SIZE
);
100 allocnos_live
= sparseset_alloc (ira_allocnos_num
);
101 conflicts
= (IRA_INT_TYPE
**) ira_allocate (sizeof (IRA_INT_TYPE
*)
103 allocated_words_num
= 0;
104 FOR_EACH_ALLOCNO (allocno
, ai
)
106 num
= ALLOCNO_NUM (allocno
);
107 if (ALLOCNO_MAX (allocno
) < ALLOCNO_MIN (allocno
))
109 conflicts
[num
] = NULL
;
112 conflict_bit_vec_words_num
113 = ((ALLOCNO_MAX (allocno
) - ALLOCNO_MIN (allocno
) + IRA_INT_BITS
)
115 allocated_words_num
+= conflict_bit_vec_words_num
;
117 = (IRA_INT_TYPE
*) ira_allocate (sizeof (IRA_INT_TYPE
)
118 * conflict_bit_vec_words_num
);
119 memset (conflicts
[num
], 0,
120 sizeof (IRA_INT_TYPE
) * conflict_bit_vec_words_num
);
122 if (internal_flag_ira_verbose
> 0 && ira_dump_file
!= NULL
)
125 "+++Allocating %ld bytes for conflict table (uncompressed size %ld)\n",
126 (long) allocated_words_num
* sizeof (IRA_INT_TYPE
),
127 (long) allocno_set_words
* ira_allocnos_num
* sizeof (IRA_INT_TYPE
));
128 for (i
= 0; i
< ira_max_point
; i
++)
130 for (r
= ira_start_point_ranges
[i
]; r
!= NULL
; r
= r
->start_next
)
132 allocno
= r
->allocno
;
133 num
= ALLOCNO_NUM (allocno
);
134 id
= ALLOCNO_CONFLICT_ID (allocno
);
135 cover_class
= ALLOCNO_COVER_CLASS (allocno
);
136 sparseset_set_bit (allocnos_live
, num
);
137 EXECUTE_IF_SET_IN_SPARSESET (allocnos_live
, j
)
139 live_a
= ira_allocnos
[j
];
140 if (ira_reg_classes_intersect_p
141 [cover_class
][ALLOCNO_COVER_CLASS (live_a
)]
142 /* Don't set up conflict for the allocno with itself. */
145 SET_ALLOCNO_SET_BIT (conflicts
[num
],
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
));
156 for (r
= ira_finish_point_ranges
[i
]; r
!= NULL
; r
= r
->finish_next
)
157 sparseset_clear_bit (allocnos_live
, ALLOCNO_NUM (r
->allocno
));
159 sparseset_free (allocnos_live
);
165 /* Return TRUE if the operand constraint STR is commutative. */
167 commutative_constraint_p (const char *str
)
172 for (ignore_p
= false;;)
177 str
+= CONSTRAINT_LEN (c
, str
);
184 /* Usually `%' is the first constraint character but the
185 documentation does not require this. */
193 /* Return the number of the operand which should be the same in any
194 case as operand with number OP_NUM (or negative value if there is
195 no such operand). If USE_COMMUT_OP_P is TRUE, the function makes
196 temporarily commutative operand exchange before this. The function
197 takes only really possible alternatives into consideration. */
199 get_dup_num (int op_num
, bool use_commut_op_p
)
201 int curr_alt
, c
, original
, dup
;
202 bool ignore_p
, commut_op_used_p
;
206 if (op_num
< 0 || recog_data
.n_alternatives
== 0)
208 op
= recog_data
.operand
[op_num
];
209 commut_op_used_p
= true;
212 if (commutative_constraint_p (recog_data
.constraints
[op_num
]))
214 else if (op_num
> 0 && commutative_constraint_p (recog_data
.constraints
218 commut_op_used_p
= false;
220 str
= recog_data
.constraints
[op_num
];
221 for (ignore_p
= false, original
= -1, curr_alt
= 0;;)
241 /* Accept a register which might be placed in memory. */
251 GO_IF_LEGITIMATE_ADDRESS (VOIDmode
, op
, win_p
);
261 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
262 case 'h': case 'j': case 'k': case 'l':
263 case 'q': case 't': case 'u':
264 case 'v': case 'w': case 'x': case 'y': case 'z':
265 case 'A': case 'B': case 'C': case 'D':
266 case 'Q': case 'R': case 'S': case 'T': case 'U':
267 case 'W': case 'Y': case 'Z':
272 ? GENERAL_REGS
: REG_CLASS_FROM_CONSTRAINT (c
, str
));
275 #ifdef EXTRA_CONSTRAINT_STR
276 else if (EXTRA_CONSTRAINT_STR (op
, c
, str
))
282 case '0': case '1': case '2': case '3': case '4':
283 case '5': case '6': case '7': case '8': case '9':
284 if (original
!= -1 && original
!= c
)
289 str
+= CONSTRAINT_LEN (c
, str
);
293 dup
= original
- '0';
296 if (commutative_constraint_p (recog_data
.constraints
[dup
]))
299 && commutative_constraint_p (recog_data
.constraints
[dup
-1]))
301 else if (! commut_op_used_p
)
307 /* Return the operand which should be, in any case, the same as
308 operand with number OP_NUM. If USE_COMMUT_OP_P is TRUE, the
309 function makes temporarily commutative operand exchange before
312 get_dup (int op_num
, bool use_commut_op_p
)
314 int n
= get_dup_num (op_num
, use_commut_op_p
);
319 return recog_data
.operand
[n
];
322 /* Check that X is REG or SUBREG of REG. */
323 #define REG_SUBREG_P(x) \
324 (REG_P (x) || (GET_CODE (x) == SUBREG && REG_P (SUBREG_REG (x))))
326 /* Return X if X is a REG, otherwise it should be SUBREG of REG and
327 the function returns the reg in this case. *OFFSET will be set to
328 0 in the first case or the regno offset in the first case. */
330 go_through_subreg (rtx x
, int *offset
)
337 ira_assert (GET_CODE (x
) == SUBREG
);
338 reg
= SUBREG_REG (x
);
339 ira_assert (REG_P (reg
));
340 if (REGNO (reg
) < FIRST_PSEUDO_REGISTER
)
341 *offset
= subreg_regno_offset (REGNO (reg
), GET_MODE (reg
),
342 SUBREG_BYTE (x
), GET_MODE (x
));
344 *offset
= (SUBREG_BYTE (x
) / REGMODE_NATURAL_SIZE (GET_MODE (x
)));
348 /* Process registers REG1 and REG2 in move INSN with execution
349 frequency FREQ. The function also processes the registers in a
350 potential move insn (INSN == NULL in this case) with frequency
351 FREQ. The function can modify hard register costs of the
352 corresponding allocnos or create a copy involving the corresponding
353 allocnos. The function does nothing if the both registers are hard
354 registers. When nothing is changed, the function returns
357 process_regs_for_copy (rtx reg1
, rtx reg2
, bool constraint_p
,
360 int allocno_preferenced_hard_regno
, cost
, index
, offset1
, offset2
;
363 enum reg_class rclass
, cover_class
;
364 enum machine_mode mode
;
366 ira_loop_tree_node_t parent
;
368 gcc_assert (REG_SUBREG_P (reg1
) && REG_SUBREG_P (reg2
));
369 only_regs_p
= REG_P (reg1
) && REG_P (reg2
);
370 reg1
= go_through_subreg (reg1
, &offset1
);
371 reg2
= go_through_subreg (reg2
, &offset2
);
372 /* Set up hard regno preferenced by allocno. If allocno gets the
373 hard regno the copy (or potential move) insn will be removed. */
374 if (HARD_REGISTER_P (reg1
))
376 if (HARD_REGISTER_P (reg2
))
378 allocno_preferenced_hard_regno
= REGNO (reg1
) + offset1
- offset2
;
379 a
= ira_curr_regno_allocno_map
[REGNO (reg2
)];
381 else if (HARD_REGISTER_P (reg2
))
383 allocno_preferenced_hard_regno
= REGNO (reg2
) + offset2
- offset1
;
384 a
= ira_curr_regno_allocno_map
[REGNO (reg1
)];
386 else if (!CONFLICT_ALLOCNO_P (ira_curr_regno_allocno_map
[REGNO (reg1
)],
387 ira_curr_regno_allocno_map
[REGNO (reg2
)])
388 && offset1
== offset2
)
390 cp
= ira_add_allocno_copy (ira_curr_regno_allocno_map
[REGNO (reg1
)],
391 ira_curr_regno_allocno_map
[REGNO (reg2
)],
392 freq
, constraint_p
, insn
,
393 ira_curr_loop_tree_node
);
394 bitmap_set_bit (ira_curr_loop_tree_node
->local_copies
, cp
->num
);
399 if (! IN_RANGE (allocno_preferenced_hard_regno
, 0, FIRST_PSEUDO_REGISTER
- 1))
400 /* Can not be tied. */
402 rclass
= REGNO_REG_CLASS (allocno_preferenced_hard_regno
);
403 mode
= ALLOCNO_MODE (a
);
404 cover_class
= ALLOCNO_COVER_CLASS (a
);
405 if (only_regs_p
&& insn
!= NULL_RTX
406 && reg_class_size
[rclass
] <= (unsigned) CLASS_MAX_NREGS (rclass
, mode
))
407 /* It is already taken into account in ira-costs.c. */
409 index
= ira_class_hard_reg_index
[cover_class
][allocno_preferenced_hard_regno
];
411 /* Can not be tied. It is not in the cover class. */
413 if (HARD_REGISTER_P (reg1
))
414 cost
= ira_register_move_cost
[mode
][cover_class
][rclass
] * freq
;
416 cost
= ira_register_move_cost
[mode
][rclass
][cover_class
] * freq
;
419 ira_allocate_and_set_costs
420 (&ALLOCNO_HARD_REG_COSTS (a
), cover_class
,
421 ALLOCNO_COVER_CLASS_COST (a
));
422 ira_allocate_and_set_costs
423 (&ALLOCNO_CONFLICT_HARD_REG_COSTS (a
), cover_class
, 0);
424 ALLOCNO_HARD_REG_COSTS (a
)[index
] -= cost
;
425 ALLOCNO_CONFLICT_HARD_REG_COSTS (a
)[index
] -= cost
;
426 if (ALLOCNO_HARD_REG_COSTS (a
)[index
] < ALLOCNO_COVER_CLASS_COST (a
))
427 ALLOCNO_COVER_CLASS_COST (a
) = ALLOCNO_HARD_REG_COSTS (a
)[index
];
428 if (ALLOCNO_CAP (a
) != NULL
)
430 else if ((parent
= ALLOCNO_LOOP_TREE_NODE (a
)->parent
) == NULL
431 || (a
= parent
->regno_allocno_map
[ALLOCNO_REGNO (a
)]) == NULL
)
437 /* Process all of the output registers of the current insn and
438 the input register REG (its operand number OP_NUM) which dies in the
439 insn as if there were a move insn between them with frequency
442 process_reg_shuffles (rtx reg
, int op_num
, int freq
)
447 gcc_assert (REG_SUBREG_P (reg
));
448 for (i
= 0; i
< recog_data
.n_operands
; i
++)
450 another_reg
= recog_data
.operand
[i
];
452 if (!REG_SUBREG_P (another_reg
) || op_num
== i
453 || recog_data
.operand_type
[i
] != OP_OUT
)
456 process_regs_for_copy (reg
, another_reg
, false, NULL_RTX
, freq
);
460 /* Process INSN and create allocno copies if necessary. For example,
461 it might be because INSN is a pseudo-register move or INSN is two
464 add_insn_allocno_copies (rtx insn
)
466 rtx set
, operand
, dup
;
468 bool commut_p
, bound_p
;
471 freq
= REG_FREQ_FROM_BB (BLOCK_FOR_INSN (insn
));
474 if ((set
= single_set (insn
)) != NULL_RTX
475 && REG_SUBREG_P (SET_DEST (set
)) && REG_SUBREG_P (SET_SRC (set
))
476 && ! side_effects_p (set
)
477 && find_reg_note (insn
, REG_DEAD
,
478 REG_P (SET_SRC (set
))
480 : SUBREG_REG (SET_SRC (set
))) != NULL_RTX
)
481 process_regs_for_copy (SET_DEST (set
), SET_SRC (set
), false, insn
, freq
);
485 for (i
= 0; i
< recog_data
.n_operands
; i
++)
487 operand
= recog_data
.operand
[i
];
488 if (REG_SUBREG_P (operand
)
489 && find_reg_note (insn
, REG_DEAD
,
491 ? operand
: SUBREG_REG (operand
)) != NULL_RTX
)
493 str
= recog_data
.constraints
[i
];
494 while (*str
== ' ' && *str
== '\t')
497 for (j
= 0, commut_p
= false; j
< 2; j
++, commut_p
= true)
498 if ((dup
= get_dup (i
, commut_p
)) != NULL_RTX
499 && REG_SUBREG_P (dup
)
500 && process_regs_for_copy (operand
, dup
, true,
505 /* If an operand dies, prefer its hard register for the
506 output operands by decreasing the hard register cost
507 or creating the corresponding allocno copies. The
508 cost will not correspond to a real move insn cost, so
509 make the frequency smaller. */
510 process_reg_shuffles (operand
, i
, freq
< 8 ? 1 : freq
/ 8);
516 /* Add copies originated from BB given by LOOP_TREE_NODE. */
518 add_copies (ira_loop_tree_node_t loop_tree_node
)
523 bb
= loop_tree_node
->bb
;
526 FOR_BB_INSNS (bb
, insn
)
528 add_insn_allocno_copies (insn
);
531 /* Propagate copies the corresponding allocnos on upper loop tree
534 propagate_copies (void)
537 ira_copy_iterator ci
;
538 ira_allocno_t a1
, a2
, parent_a1
, parent_a2
;
539 ira_loop_tree_node_t parent
;
541 FOR_EACH_COPY (cp
, ci
)
545 if (ALLOCNO_LOOP_TREE_NODE (a1
) == ira_loop_tree_root
)
547 ira_assert ((ALLOCNO_LOOP_TREE_NODE (a2
) != ira_loop_tree_root
));
548 parent
= ALLOCNO_LOOP_TREE_NODE (a1
)->parent
;
549 if ((parent_a1
= ALLOCNO_CAP (a1
)) == NULL
)
550 parent_a1
= parent
->regno_allocno_map
[ALLOCNO_REGNO (a1
)];
551 if ((parent_a2
= ALLOCNO_CAP (a2
)) == NULL
)
552 parent_a2
= parent
->regno_allocno_map
[ALLOCNO_REGNO (a2
)];
553 ira_assert (parent_a1
!= NULL
&& parent_a2
!= NULL
);
554 if (! CONFLICT_ALLOCNO_P (parent_a1
, parent_a2
))
555 ira_add_allocno_copy (parent_a1
, parent_a2
, cp
->freq
,
556 cp
->constraint_p
, cp
->insn
, cp
->loop_tree_node
);
560 /* Array used to collect all conflict allocnos for given allocno. */
561 static ira_allocno_t
*collected_conflict_allocnos
;
563 /* Build conflict vectors or bit conflict vectors (whatever is more
564 profitable) for allocno A from the conflict table and propagate the
565 conflicts to upper level allocno. */
567 build_allocno_conflicts (ira_allocno_t a
)
569 int i
, px
, parent_num
;
570 int conflict_bit_vec_words_num
;
571 ira_loop_tree_node_t parent
;
572 ira_allocno_t parent_a
, another_a
, another_parent_a
;
574 IRA_INT_TYPE
*allocno_conflicts
;
575 ira_allocno_set_iterator asi
;
577 allocno_conflicts
= conflicts
[ALLOCNO_NUM (a
)];
579 FOR_EACH_ALLOCNO_IN_SET (allocno_conflicts
,
580 ALLOCNO_MIN (a
), ALLOCNO_MAX (a
), i
, asi
)
582 another_a
= ira_conflict_id_allocno_map
[i
];
583 ira_assert (ira_reg_classes_intersect_p
584 [ALLOCNO_COVER_CLASS (a
)][ALLOCNO_COVER_CLASS (another_a
)]);
585 collected_conflict_allocnos
[px
++] = another_a
;
587 if (ira_conflict_vector_profitable_p (a
, px
))
589 ira_allocate_allocno_conflict_vec (a
, px
);
590 vec
= (ira_allocno_t
*) ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a
);
591 memcpy (vec
, collected_conflict_allocnos
, sizeof (ira_allocno_t
) * px
);
593 ALLOCNO_CONFLICT_ALLOCNOS_NUM (a
) = px
;
597 ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a
) = conflicts
[ALLOCNO_NUM (a
)];
598 if (ALLOCNO_MAX (a
) < ALLOCNO_MIN (a
))
599 conflict_bit_vec_words_num
= 0;
601 conflict_bit_vec_words_num
602 = ((ALLOCNO_MAX (a
) - ALLOCNO_MIN (a
) + IRA_INT_BITS
)
604 ALLOCNO_CONFLICT_ALLOCNO_ARRAY_SIZE (a
)
605 = conflict_bit_vec_words_num
* sizeof (IRA_INT_TYPE
);
607 parent
= ALLOCNO_LOOP_TREE_NODE (a
)->parent
;
608 if ((parent_a
= ALLOCNO_CAP (a
)) == NULL
610 || (parent_a
= parent
->regno_allocno_map
[ALLOCNO_REGNO (a
)])
613 ira_assert (parent
!= NULL
);
614 ira_assert (ALLOCNO_COVER_CLASS (a
) == ALLOCNO_COVER_CLASS (parent_a
));
615 parent_num
= ALLOCNO_NUM (parent_a
);
616 FOR_EACH_ALLOCNO_IN_SET (allocno_conflicts
,
617 ALLOCNO_MIN (a
), ALLOCNO_MAX (a
), i
, asi
)
619 another_a
= ira_conflict_id_allocno_map
[i
];
620 ira_assert (ira_reg_classes_intersect_p
621 [ALLOCNO_COVER_CLASS (a
)][ALLOCNO_COVER_CLASS (another_a
)]);
622 if ((another_parent_a
= ALLOCNO_CAP (another_a
)) == NULL
623 && (another_parent_a
= (parent
->regno_allocno_map
624 [ALLOCNO_REGNO (another_a
)])) == NULL
)
626 ira_assert (ALLOCNO_NUM (another_parent_a
) >= 0);
627 ira_assert (ALLOCNO_COVER_CLASS (another_a
)
628 == ALLOCNO_COVER_CLASS (another_parent_a
));
629 SET_ALLOCNO_SET_BIT (conflicts
[parent_num
],
630 ALLOCNO_CONFLICT_ID (another_parent_a
),
631 ALLOCNO_MIN (parent_a
),
632 ALLOCNO_MAX (parent_a
));
636 /* Build conflict vectors or bit conflict vectors (whatever is more
637 profitable) of all allocnos from the conflict table. */
639 build_conflicts (void)
642 ira_allocno_t a
, cap
;
644 collected_conflict_allocnos
645 = (ira_allocno_t
*) ira_allocate (sizeof (ira_allocno_t
)
647 for (i
= max_reg_num () - 1; i
>= FIRST_PSEUDO_REGISTER
; i
--)
648 for (a
= ira_regno_allocno_map
[i
];
650 a
= ALLOCNO_NEXT_REGNO_ALLOCNO (a
))
652 build_allocno_conflicts (a
);
653 for (cap
= ALLOCNO_CAP (a
); cap
!= NULL
; cap
= ALLOCNO_CAP (cap
))
654 build_allocno_conflicts (cap
);
656 ira_free (collected_conflict_allocnos
);
661 /* Print hard reg set SET with TITLE to FILE. */
663 print_hard_reg_set (FILE *file
, const char *title
, HARD_REG_SET set
)
667 fprintf (file
, title
);
668 for (start
= -1, i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
670 if (TEST_HARD_REG_BIT (set
, i
))
672 if (i
== 0 || ! TEST_HARD_REG_BIT (set
, i
- 1))
676 && (i
== FIRST_PSEUDO_REGISTER
- 1 || ! TEST_HARD_REG_BIT (set
, i
)))
679 fprintf (file
, " %d", start
);
680 else if (start
== i
- 2)
681 fprintf (file
, " %d %d", start
, start
+ 1);
683 fprintf (file
, " %d-%d", start
, i
- 1);
687 fprintf (file
, "\n");
690 /* Print information about allocno or only regno (if REG_P) conflicts
693 print_conflicts (FILE *file
, bool reg_p
)
696 ira_allocno_iterator ai
;
697 HARD_REG_SET conflicting_hard_regs
;
699 FOR_EACH_ALLOCNO (a
, ai
)
701 ira_allocno_t conflict_a
;
702 ira_allocno_conflict_iterator aci
;
706 fprintf (file
, ";; r%d", ALLOCNO_REGNO (a
));
709 fprintf (file
, ";; a%d(r%d,", ALLOCNO_NUM (a
), ALLOCNO_REGNO (a
));
710 if ((bb
= ALLOCNO_LOOP_TREE_NODE (a
)->bb
) != NULL
)
711 fprintf (file
, "b%d", bb
->index
);
713 fprintf (file
, "l%d", ALLOCNO_LOOP_TREE_NODE (a
)->loop
->num
);
716 fprintf (file
, " conflicts:");
717 if (ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a
) != NULL
)
718 FOR_EACH_ALLOCNO_CONFLICT (a
, conflict_a
, aci
)
721 fprintf (file
, " r%d,", ALLOCNO_REGNO (conflict_a
));
724 fprintf (file
, " a%d(r%d,", ALLOCNO_NUM (conflict_a
),
725 ALLOCNO_REGNO (conflict_a
));
726 if ((bb
= ALLOCNO_LOOP_TREE_NODE (conflict_a
)->bb
) != NULL
)
727 fprintf (file
, "b%d)", bb
->index
);
729 fprintf (file
, "l%d)",
730 ALLOCNO_LOOP_TREE_NODE (conflict_a
)->loop
->num
);
733 COPY_HARD_REG_SET (conflicting_hard_regs
,
734 ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a
));
735 AND_COMPL_HARD_REG_SET (conflicting_hard_regs
, ira_no_alloc_regs
);
736 AND_HARD_REG_SET (conflicting_hard_regs
,
737 reg_class_contents
[ALLOCNO_COVER_CLASS (a
)]);
738 print_hard_reg_set (file
, "\n;; total conflict hard regs:",
739 conflicting_hard_regs
);
740 COPY_HARD_REG_SET (conflicting_hard_regs
,
741 ALLOCNO_CONFLICT_HARD_REGS (a
));
742 AND_COMPL_HARD_REG_SET (conflicting_hard_regs
, ira_no_alloc_regs
);
743 AND_HARD_REG_SET (conflicting_hard_regs
,
744 reg_class_contents
[ALLOCNO_COVER_CLASS (a
)]);
745 print_hard_reg_set (file
, ";; conflict hard regs:",
746 conflicting_hard_regs
);
748 fprintf (file
, "\n");
751 /* Print information about allocno or only regno (if REG_P) conflicts
754 ira_debug_conflicts (bool reg_p
)
756 print_conflicts (stderr
, reg_p
);
761 /* Entry function which builds allocno conflicts and allocno copies
762 and accumulate some allocno info on upper level regions. */
764 ira_build_conflicts (void)
767 ira_allocno_iterator ai
;
768 HARD_REG_SET temp_hard_reg_set
;
772 ira_conflicts_p
= build_conflict_bit_table ();
776 ira_traverse_loop_tree (true, ira_loop_tree_root
, NULL
, add_copies
);
777 /* We need finished conflict table for the subsequent call. */
778 if (flag_ira_region
== IRA_REGION_ALL
779 || flag_ira_region
== IRA_REGION_MIXED
)
781 /* Now we can free memory for the conflict table (see function
782 build_allocno_conflicts for details). */
783 FOR_EACH_ALLOCNO (a
, ai
)
785 if (ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a
)
786 != conflicts
[ALLOCNO_NUM (a
)])
787 ira_free (conflicts
[ALLOCNO_NUM (a
)]);
789 ira_free (conflicts
);
792 if (! CLASS_LIKELY_SPILLED_P (base_reg_class (VOIDmode
, ADDRESS
, SCRATCH
)))
793 CLEAR_HARD_REG_SET (temp_hard_reg_set
);
796 COPY_HARD_REG_SET (temp_hard_reg_set
,
797 reg_class_contents
[base_reg_class (VOIDmode
, ADDRESS
, SCRATCH
)]);
798 AND_COMPL_HARD_REG_SET (temp_hard_reg_set
, ira_no_alloc_regs
);
799 AND_HARD_REG_SET (temp_hard_reg_set
, call_used_reg_set
);
801 FOR_EACH_ALLOCNO (a
, ai
)
806 if ((! flag_caller_saves
&& ALLOCNO_CALLS_CROSSED_NUM (a
) != 0)
807 /* For debugging purposes don't put user defined variables in
808 callee-clobbered registers. */
810 && (attrs
= REG_ATTRS (regno_reg_rtx
[ALLOCNO_REGNO (a
)])) != NULL
811 && (decl
= attrs
->decl
) != NULL
812 && VAR_OR_FUNCTION_DECL_P (decl
)
813 && ! DECL_ARTIFICIAL (decl
)))
815 IOR_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a
),
817 IOR_HARD_REG_SET (ALLOCNO_CONFLICT_HARD_REGS (a
),
820 else if (ALLOCNO_CALLS_CROSSED_NUM (a
) != 0)
822 IOR_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a
),
823 no_caller_save_reg_set
);
824 IOR_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a
),
826 IOR_HARD_REG_SET (ALLOCNO_CONFLICT_HARD_REGS (a
),
827 no_caller_save_reg_set
);
828 IOR_HARD_REG_SET (ALLOCNO_CONFLICT_HARD_REGS (a
),
832 if (optimize
&& ira_conflicts_p
833 && internal_flag_ira_verbose
> 2 && ira_dump_file
!= NULL
)
834 print_conflicts (ira_dump_file
, false);