Mercurial > hg > CbC > CbC_gcc
comparison gcc/ira-conflicts.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | f6334be47118 |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* IRA conflict builder. | 1 /* IRA conflict builder. |
2 Copyright (C) 2006, 2007, 2008, 2009, 2010 | 2 Copyright (C) 2006-2017 Free Software Foundation, Inc. |
3 Free Software Foundation, Inc. | |
4 Contributed by Vladimir Makarov <vmakarov@redhat.com>. | 3 Contributed by Vladimir Makarov <vmakarov@redhat.com>. |
5 | 4 |
6 This file is part of GCC. | 5 This file is part of GCC. |
7 | 6 |
8 GCC is free software; you can redistribute it and/or modify it under | 7 GCC is free software; you can redistribute it and/or modify it under |
20 <http://www.gnu.org/licenses/>. */ | 19 <http://www.gnu.org/licenses/>. */ |
21 | 20 |
22 #include "config.h" | 21 #include "config.h" |
23 #include "system.h" | 22 #include "system.h" |
24 #include "coretypes.h" | 23 #include "coretypes.h" |
25 #include "tm.h" | 24 #include "backend.h" |
25 #include "target.h" | |
26 #include "rtl.h" | |
27 #include "predict.h" | |
28 #include "memmodel.h" | |
29 #include "tm_p.h" | |
30 #include "insn-config.h" | |
26 #include "regs.h" | 31 #include "regs.h" |
27 #include "rtl.h" | 32 #include "ira.h" |
28 #include "tm_p.h" | 33 #include "ira-int.h" |
29 #include "target.h" | |
30 #include "flags.h" | |
31 #include "hard-reg-set.h" | |
32 #include "basic-block.h" | |
33 #include "insn-config.h" | |
34 #include "recog.h" | |
35 #include "diagnostic-core.h" | |
36 #include "params.h" | 34 #include "params.h" |
37 #include "df.h" | |
38 #include "sparseset.h" | 35 #include "sparseset.h" |
39 #include "ira-int.h" | |
40 #include "addresses.h" | 36 #include "addresses.h" |
41 | 37 |
42 /* This file contains code responsible for allocno conflict creation, | 38 /* This file contains code responsible for allocno conflict creation, |
43 allocno copy creation and allocno info accumulation on upper level | 39 allocno copy creation and allocno info accumulation on upper level |
44 regions. */ | 40 regions. */ |
59 OBJECT_MIN (C1), OBJECT_MAX (C1))) | 55 OBJECT_MIN (C1), OBJECT_MAX (C1))) |
60 | 56 |
61 | 57 |
62 /* Record a conflict between objects OBJ1 and OBJ2. If necessary, | 58 /* Record a conflict between objects OBJ1 and OBJ2. If necessary, |
63 canonicalize the conflict by recording it for lower-order subobjects | 59 canonicalize the conflict by recording it for lower-order subobjects |
64 of the corresponding allocnos. */ | 60 of the corresponding allocnos. */ |
65 static void | 61 static void |
66 record_object_conflict (ira_object_t obj1, ira_object_t obj2) | 62 record_object_conflict (ira_object_t obj1, ira_object_t obj2) |
67 { | 63 { |
68 ira_allocno_t a1 = OBJECT_ALLOCNO (obj1); | 64 ira_allocno_t a1 = OBJECT_ALLOCNO (obj1); |
69 ira_allocno_t a2 = OBJECT_ALLOCNO (obj2); | 65 ira_allocno_t a2 = OBJECT_ALLOCNO (obj2); |
95 static bool | 91 static bool |
96 build_conflict_bit_table (void) | 92 build_conflict_bit_table (void) |
97 { | 93 { |
98 int i; | 94 int i; |
99 unsigned int j; | 95 unsigned int j; |
100 enum reg_class cover_class; | 96 enum reg_class aclass; |
101 int object_set_words, allocated_words_num, conflict_bit_vec_words_num; | 97 int object_set_words, allocated_words_num, conflict_bit_vec_words_num; |
102 live_range_t r; | 98 live_range_t r; |
103 ira_allocno_t allocno; | 99 ira_allocno_t allocno; |
104 ira_allocno_iterator ai; | 100 ira_allocno_iterator ai; |
105 sparseset objects_live; | 101 sparseset objects_live; |
114 continue; | 110 continue; |
115 conflict_bit_vec_words_num | 111 conflict_bit_vec_words_num |
116 = ((OBJECT_MAX (obj) - OBJECT_MIN (obj) + IRA_INT_BITS) | 112 = ((OBJECT_MAX (obj) - OBJECT_MIN (obj) + IRA_INT_BITS) |
117 / IRA_INT_BITS); | 113 / IRA_INT_BITS); |
118 allocated_words_num += conflict_bit_vec_words_num; | 114 allocated_words_num += conflict_bit_vec_words_num; |
119 if ((unsigned long long) allocated_words_num * sizeof (IRA_INT_TYPE) | 115 if ((uint64_t) allocated_words_num * sizeof (IRA_INT_TYPE) |
120 > (unsigned long long) IRA_MAX_CONFLICT_TABLE_SIZE * 1024 * 1024) | 116 > (uint64_t) IRA_MAX_CONFLICT_TABLE_SIZE * 1024 * 1024) |
121 { | 117 { |
122 if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL) | 118 if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL) |
123 fprintf | 119 fprintf |
124 (ira_dump_file, | 120 (ira_dump_file, |
125 "+++Conflict table will be too big(>%dMB) -- don't use it\n", | 121 "+++Conflict table will be too big(>%dMB) -- don't use it\n", |
168 ira_allocno_t allocno = OBJECT_ALLOCNO (obj); | 164 ira_allocno_t allocno = OBJECT_ALLOCNO (obj); |
169 int id = OBJECT_CONFLICT_ID (obj); | 165 int id = OBJECT_CONFLICT_ID (obj); |
170 | 166 |
171 gcc_assert (id < ira_objects_num); | 167 gcc_assert (id < ira_objects_num); |
172 | 168 |
173 cover_class = ALLOCNO_COVER_CLASS (allocno); | 169 aclass = ALLOCNO_CLASS (allocno); |
174 sparseset_set_bit (objects_live, id); | |
175 EXECUTE_IF_SET_IN_SPARSESET (objects_live, j) | 170 EXECUTE_IF_SET_IN_SPARSESET (objects_live, j) |
176 { | 171 { |
177 ira_object_t live_obj = ira_object_id_map[j]; | 172 ira_object_t live_obj = ira_object_id_map[j]; |
178 ira_allocno_t live_a = OBJECT_ALLOCNO (live_obj); | 173 ira_allocno_t live_a = OBJECT_ALLOCNO (live_obj); |
179 enum reg_class live_cover_class = ALLOCNO_COVER_CLASS (live_a); | 174 enum reg_class live_aclass = ALLOCNO_CLASS (live_a); |
180 | 175 |
181 if (ira_reg_classes_intersect_p[cover_class][live_cover_class] | 176 if (ira_reg_classes_intersect_p[aclass][live_aclass] |
182 /* Don't set up conflict for the allocno with itself. */ | 177 /* Don't set up conflict for the allocno with itself. */ |
183 && live_a != allocno) | 178 && live_a != allocno) |
184 { | 179 { |
185 record_object_conflict (obj, live_obj); | 180 record_object_conflict (obj, live_obj); |
186 } | 181 } |
187 } | 182 } |
183 sparseset_set_bit (objects_live, id); | |
188 } | 184 } |
189 | 185 |
190 for (r = ira_finish_point_ranges[i]; r != NULL; r = r->finish_next) | 186 for (r = ira_finish_point_ranges[i]; r != NULL; r = r->finish_next) |
191 sparseset_clear_bit (objects_live, OBJECT_CONFLICT_ID (r->object)); | 187 sparseset_clear_bit (objects_live, OBJECT_CONFLICT_ID (r->object)); |
192 } | 188 } |
203 /* Due to the fact that we canonicalize conflicts (see | 199 /* Due to the fact that we canonicalize conflicts (see |
204 record_object_conflict), we only need to test for conflicts of | 200 record_object_conflict), we only need to test for conflicts of |
205 the lowest order words. */ | 201 the lowest order words. */ |
206 ira_object_t obj1 = ALLOCNO_OBJECT (a1, 0); | 202 ira_object_t obj1 = ALLOCNO_OBJECT (a1, 0); |
207 ira_object_t obj2 = ALLOCNO_OBJECT (a2, 0); | 203 ira_object_t obj2 = ALLOCNO_OBJECT (a2, 0); |
204 | |
208 return OBJECTS_CONFLICT_P (obj1, obj2); | 205 return OBJECTS_CONFLICT_P (obj1, obj2); |
209 } | |
210 | |
211 /* Return TRUE if the operand constraint STR is commutative. */ | |
212 static bool | |
213 commutative_constraint_p (const char *str) | |
214 { | |
215 bool ignore_p; | |
216 int c; | |
217 | |
218 for (ignore_p = false;;) | |
219 { | |
220 c = *str; | |
221 if (c == '\0') | |
222 break; | |
223 str += CONSTRAINT_LEN (c, str); | |
224 if (c == '#') | |
225 ignore_p = true; | |
226 else if (c == ',') | |
227 ignore_p = false; | |
228 else if (! ignore_p) | |
229 { | |
230 /* Usually `%' is the first constraint character but the | |
231 documentation does not require this. */ | |
232 if (c == '%') | |
233 return true; | |
234 } | |
235 } | |
236 return false; | |
237 } | |
238 | |
239 /* Return the number of the operand which should be the same in any | |
240 case as operand with number OP_NUM (or negative value if there is | |
241 no such operand). If USE_COMMUT_OP_P is TRUE, the function makes | |
242 temporarily commutative operand exchange before this. The function | |
243 takes only really possible alternatives into consideration. */ | |
244 static int | |
245 get_dup_num (int op_num, bool use_commut_op_p) | |
246 { | |
247 int curr_alt, c, original, dup; | |
248 bool ignore_p, commut_op_used_p; | |
249 const char *str; | |
250 rtx op; | |
251 | |
252 if (op_num < 0 || recog_data.n_alternatives == 0) | |
253 return -1; | |
254 op = recog_data.operand[op_num]; | |
255 commut_op_used_p = true; | |
256 if (use_commut_op_p) | |
257 { | |
258 if (commutative_constraint_p (recog_data.constraints[op_num])) | |
259 op_num++; | |
260 else if (op_num > 0 && commutative_constraint_p (recog_data.constraints | |
261 [op_num - 1])) | |
262 op_num--; | |
263 else | |
264 commut_op_used_p = false; | |
265 } | |
266 str = recog_data.constraints[op_num]; | |
267 for (ignore_p = false, original = -1, curr_alt = 0;;) | |
268 { | |
269 c = *str; | |
270 if (c == '\0') | |
271 break; | |
272 if (c == '#') | |
273 ignore_p = true; | |
274 else if (c == ',') | |
275 { | |
276 curr_alt++; | |
277 ignore_p = false; | |
278 } | |
279 else if (! ignore_p) | |
280 switch (c) | |
281 { | |
282 case 'X': | |
283 return -1; | |
284 | |
285 case 'm': | |
286 case 'o': | |
287 /* Accept a register which might be placed in memory. */ | |
288 return -1; | |
289 break; | |
290 | |
291 case 'V': | |
292 case '<': | |
293 case '>': | |
294 break; | |
295 | |
296 case 'p': | |
297 if (address_operand (op, VOIDmode)) | |
298 return -1; | |
299 break; | |
300 | |
301 case 'g': | |
302 return -1; | |
303 | |
304 case 'r': | |
305 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': | |
306 case 'h': case 'j': case 'k': case 'l': | |
307 case 'q': case 't': case 'u': | |
308 case 'v': case 'w': case 'x': case 'y': case 'z': | |
309 case 'A': case 'B': case 'C': case 'D': | |
310 case 'Q': case 'R': case 'S': case 'T': case 'U': | |
311 case 'W': case 'Y': case 'Z': | |
312 { | |
313 enum reg_class cl; | |
314 | |
315 cl = (c == 'r' | |
316 ? GENERAL_REGS : REG_CLASS_FROM_CONSTRAINT (c, str)); | |
317 if (cl != NO_REGS) | |
318 return -1; | |
319 #ifdef EXTRA_CONSTRAINT_STR | |
320 else if (EXTRA_CONSTRAINT_STR (op, c, str)) | |
321 return -1; | |
322 #endif | |
323 break; | |
324 } | |
325 | |
326 case '0': case '1': case '2': case '3': case '4': | |
327 case '5': case '6': case '7': case '8': case '9': | |
328 if (original != -1 && original != c) | |
329 return -1; | |
330 original = c; | |
331 break; | |
332 } | |
333 str += CONSTRAINT_LEN (c, str); | |
334 } | |
335 if (original == -1) | |
336 return -1; | |
337 dup = original - '0'; | |
338 if (use_commut_op_p) | |
339 { | |
340 if (commutative_constraint_p (recog_data.constraints[dup])) | |
341 dup++; | |
342 else if (dup > 0 | |
343 && commutative_constraint_p (recog_data.constraints[dup -1])) | |
344 dup--; | |
345 else if (! commut_op_used_p) | |
346 return -1; | |
347 } | |
348 return dup; | |
349 } | 206 } |
350 | 207 |
351 /* Check that X is REG or SUBREG of REG. */ | 208 /* Check that X is REG or SUBREG of REG. */ |
352 #define REG_SUBREG_P(x) \ | 209 #define REG_SUBREG_P(x) \ |
353 (REG_P (x) || (GET_CODE (x) == SUBREG && REG_P (SUBREG_REG (x)))) | 210 (REG_P (x) || (GET_CODE (x) == SUBREG && REG_P (SUBREG_REG (x)))) |
382 allocnos. The function does nothing if the both registers are hard | 239 allocnos. The function does nothing if the both registers are hard |
383 registers. When nothing is changed, the function returns | 240 registers. When nothing is changed, the function returns |
384 FALSE. */ | 241 FALSE. */ |
385 static bool | 242 static bool |
386 process_regs_for_copy (rtx reg1, rtx reg2, bool constraint_p, | 243 process_regs_for_copy (rtx reg1, rtx reg2, bool constraint_p, |
387 rtx insn, int freq) | 244 rtx_insn *insn, int freq) |
388 { | 245 { |
389 int allocno_preferenced_hard_regno, cost, index, offset1, offset2; | 246 int allocno_preferenced_hard_regno, cost, index, offset1, offset2; |
390 bool only_regs_p; | 247 bool only_regs_p; |
391 ira_allocno_t a; | 248 ira_allocno_t a; |
392 enum reg_class rclass, cover_class; | 249 reg_class_t rclass, aclass; |
393 enum machine_mode mode; | 250 machine_mode mode; |
394 ira_copy_t cp; | 251 ira_copy_t cp; |
395 | 252 |
396 gcc_assert (REG_SUBREG_P (reg1) && REG_SUBREG_P (reg2)); | 253 gcc_assert (REG_SUBREG_P (reg1) && REG_SUBREG_P (reg2)); |
397 only_regs_p = REG_P (reg1) && REG_P (reg2); | 254 only_regs_p = REG_P (reg1) && REG_P (reg2); |
398 reg1 = go_through_subreg (reg1, &offset1); | 255 reg1 = go_through_subreg (reg1, &offset1); |
413 } | 270 } |
414 else | 271 else |
415 { | 272 { |
416 ira_allocno_t a1 = ira_curr_regno_allocno_map[REGNO (reg1)]; | 273 ira_allocno_t a1 = ira_curr_regno_allocno_map[REGNO (reg1)]; |
417 ira_allocno_t a2 = ira_curr_regno_allocno_map[REGNO (reg2)]; | 274 ira_allocno_t a2 = ira_curr_regno_allocno_map[REGNO (reg2)]; |
275 | |
418 if (!allocnos_conflict_for_copy_p (a1, a2) && offset1 == offset2) | 276 if (!allocnos_conflict_for_copy_p (a1, a2) && offset1 == offset2) |
419 { | 277 { |
420 cp = ira_add_allocno_copy (a1, a2, freq, constraint_p, insn, | 278 cp = ira_add_allocno_copy (a1, a2, freq, constraint_p, insn, |
421 ira_curr_loop_tree_node); | 279 ira_curr_loop_tree_node); |
422 bitmap_set_bit (ira_curr_loop_tree_node->local_copies, cp->num); | 280 bitmap_set_bit (ira_curr_loop_tree_node->local_copies, cp->num); |
424 } | 282 } |
425 else | 283 else |
426 return false; | 284 return false; |
427 } | 285 } |
428 | 286 |
429 if (! IN_RANGE (allocno_preferenced_hard_regno, 0, FIRST_PSEUDO_REGISTER - 1)) | 287 if (! IN_RANGE (allocno_preferenced_hard_regno, |
288 0, FIRST_PSEUDO_REGISTER - 1)) | |
430 /* Can not be tied. */ | 289 /* Can not be tied. */ |
431 return false; | 290 return false; |
432 rclass = REGNO_REG_CLASS (allocno_preferenced_hard_regno); | 291 rclass = REGNO_REG_CLASS (allocno_preferenced_hard_regno); |
433 mode = ALLOCNO_MODE (a); | 292 mode = ALLOCNO_MODE (a); |
434 cover_class = ALLOCNO_COVER_CLASS (a); | 293 aclass = ALLOCNO_CLASS (a); |
435 if (only_regs_p && insn != NULL_RTX | 294 if (only_regs_p && insn != NULL_RTX |
436 && reg_class_size[rclass] <= (unsigned) CLASS_MAX_NREGS (rclass, mode)) | 295 && reg_class_size[rclass] <= ira_reg_class_max_nregs [rclass][mode]) |
437 /* It is already taken into account in ira-costs.c. */ | 296 /* It is already taken into account in ira-costs.c. */ |
438 return false; | 297 return false; |
439 index = ira_class_hard_reg_index[cover_class][allocno_preferenced_hard_regno]; | 298 index = ira_class_hard_reg_index[aclass][allocno_preferenced_hard_regno]; |
440 if (index < 0) | 299 if (index < 0) |
441 /* Can not be tied. It is not in the cover class. */ | 300 /* Can not be tied. It is not in the allocno class. */ |
442 return false; | 301 return false; |
302 ira_init_register_move_cost_if_necessary (mode); | |
443 if (HARD_REGISTER_P (reg1)) | 303 if (HARD_REGISTER_P (reg1)) |
444 cost = ira_get_register_move_cost (mode, cover_class, rclass) * freq; | 304 cost = ira_register_move_cost[mode][aclass][rclass] * freq; |
445 else | 305 else |
446 cost = ira_get_register_move_cost (mode, rclass, cover_class) * freq; | 306 cost = ira_register_move_cost[mode][rclass][aclass] * freq; |
447 do | 307 do |
448 { | 308 { |
449 ira_allocate_and_set_costs | 309 ira_allocate_and_set_costs |
450 (&ALLOCNO_HARD_REG_COSTS (a), cover_class, | 310 (&ALLOCNO_HARD_REG_COSTS (a), aclass, |
451 ALLOCNO_COVER_CLASS_COST (a)); | 311 ALLOCNO_CLASS_COST (a)); |
452 ira_allocate_and_set_costs | 312 ira_allocate_and_set_costs |
453 (&ALLOCNO_CONFLICT_HARD_REG_COSTS (a), cover_class, 0); | 313 (&ALLOCNO_CONFLICT_HARD_REG_COSTS (a), aclass, 0); |
454 ALLOCNO_HARD_REG_COSTS (a)[index] -= cost; | 314 ALLOCNO_HARD_REG_COSTS (a)[index] -= cost; |
455 ALLOCNO_CONFLICT_HARD_REG_COSTS (a)[index] -= cost; | 315 ALLOCNO_CONFLICT_HARD_REG_COSTS (a)[index] -= cost; |
456 if (ALLOCNO_HARD_REG_COSTS (a)[index] < ALLOCNO_COVER_CLASS_COST (a)) | 316 if (ALLOCNO_HARD_REG_COSTS (a)[index] < ALLOCNO_CLASS_COST (a)) |
457 ALLOCNO_COVER_CLASS_COST (a) = ALLOCNO_HARD_REG_COSTS (a)[index]; | 317 ALLOCNO_CLASS_COST (a) = ALLOCNO_HARD_REG_COSTS (a)[index]; |
318 ira_add_allocno_pref (a, allocno_preferenced_hard_regno, freq); | |
458 a = ira_parent_or_cap_allocno (a); | 319 a = ira_parent_or_cap_allocno (a); |
459 } | 320 } |
460 while (a != NULL); | 321 while (a != NULL); |
461 return true; | 322 return true; |
462 } | 323 } |
479 if (!REG_SUBREG_P (another_reg) || op_num == i | 340 if (!REG_SUBREG_P (another_reg) || op_num == i |
480 || recog_data.operand_type[i] != OP_OUT | 341 || recog_data.operand_type[i] != OP_OUT |
481 || bound_p[i]) | 342 || bound_p[i]) |
482 continue; | 343 continue; |
483 | 344 |
484 process_regs_for_copy (reg, another_reg, false, NULL_RTX, freq); | 345 process_regs_for_copy (reg, another_reg, false, NULL, freq); |
485 } | 346 } |
486 } | 347 } |
487 | 348 |
488 /* Process INSN and create allocno copies if necessary. For example, | 349 /* Process INSN and create allocno copies if necessary. For example, |
489 it might be because INSN is a pseudo-register move or INSN is two | 350 it might be because INSN is a pseudo-register move or INSN is two |
490 operand insn. */ | 351 operand insn. */ |
491 static void | 352 static void |
492 add_insn_allocno_copies (rtx insn) | 353 add_insn_allocno_copies (rtx_insn *insn) |
493 { | 354 { |
494 rtx set, operand, dup; | 355 rtx set, operand, dup; |
495 const char *str; | 356 bool bound_p[MAX_RECOG_OPERANDS]; |
496 bool commut_p, bound_p[MAX_RECOG_OPERANDS]; | 357 int i, n, freq; |
497 int i, j, n, freq; | 358 HARD_REG_SET alts; |
498 | 359 |
499 freq = REG_FREQ_FROM_BB (BLOCK_FOR_INSN (insn)); | 360 freq = REG_FREQ_FROM_BB (BLOCK_FOR_INSN (insn)); |
500 if (freq == 0) | 361 if (freq == 0) |
501 freq = 1; | 362 freq = 1; |
502 if ((set = single_set (insn)) != NULL_RTX | 363 if ((set = single_set (insn)) != NULL_RTX |
505 && find_reg_note (insn, REG_DEAD, | 366 && find_reg_note (insn, REG_DEAD, |
506 REG_P (SET_SRC (set)) | 367 REG_P (SET_SRC (set)) |
507 ? SET_SRC (set) | 368 ? SET_SRC (set) |
508 : SUBREG_REG (SET_SRC (set))) != NULL_RTX) | 369 : SUBREG_REG (SET_SRC (set))) != NULL_RTX) |
509 { | 370 { |
510 process_regs_for_copy (SET_DEST (set), SET_SRC (set), false, insn, freq); | 371 process_regs_for_copy (SET_SRC (set), SET_DEST (set), |
372 false, insn, freq); | |
511 return; | 373 return; |
512 } | 374 } |
513 /* Fast check of possibility of constraint or shuffle copies. If | 375 /* Fast check of possibility of constraint or shuffle copies. If |
514 there are no dead registers, there will be no such copies. */ | 376 there are no dead registers, there will be no such copies. */ |
515 if (! find_reg_note (insn, REG_DEAD, NULL_RTX)) | 377 if (! find_reg_note (insn, REG_DEAD, NULL_RTX)) |
516 return; | 378 return; |
517 extract_insn (insn); | 379 ira_setup_alts (insn, alts); |
518 for (i = 0; i < recog_data.n_operands; i++) | 380 for (i = 0; i < recog_data.n_operands; i++) |
519 bound_p[i] = false; | 381 bound_p[i] = false; |
520 for (i = 0; i < recog_data.n_operands; i++) | 382 for (i = 0; i < recog_data.n_operands; i++) |
521 { | 383 { |
522 operand = recog_data.operand[i]; | 384 operand = recog_data.operand[i]; |
523 if (! REG_SUBREG_P (operand)) | 385 if (! REG_SUBREG_P (operand)) |
524 continue; | 386 continue; |
525 str = recog_data.constraints[i]; | 387 if ((n = ira_get_dup_out_num (i, alts)) >= 0) |
526 while (*str == ' ' || *str == '\t') | 388 { |
527 str++; | 389 bound_p[n] = true; |
528 for (j = 0, commut_p = false; j < 2; j++, commut_p = true) | 390 dup = recog_data.operand[n]; |
529 if ((n = get_dup_num (i, commut_p)) >= 0) | 391 if (REG_SUBREG_P (dup) |
530 { | 392 && find_reg_note (insn, REG_DEAD, |
531 bound_p[n] = true; | 393 REG_P (operand) |
532 dup = recog_data.operand[n]; | 394 ? operand |
533 if (REG_SUBREG_P (dup) | 395 : SUBREG_REG (operand)) != NULL_RTX) |
534 && find_reg_note (insn, REG_DEAD, | 396 process_regs_for_copy (operand, dup, true, NULL, |
535 REG_P (operand) | 397 freq); |
536 ? operand | 398 } |
537 : SUBREG_REG (operand)) != NULL_RTX) | |
538 process_regs_for_copy (operand, dup, true, NULL_RTX, freq); | |
539 } | |
540 } | 399 } |
541 for (i = 0; i < recog_data.n_operands; i++) | 400 for (i = 0; i < recog_data.n_operands; i++) |
542 { | 401 { |
543 operand = recog_data.operand[i]; | 402 operand = recog_data.operand[i]; |
544 if (REG_SUBREG_P (operand) | 403 if (REG_SUBREG_P (operand) |
557 /* Add copies originated from BB given by LOOP_TREE_NODE. */ | 416 /* Add copies originated from BB given by LOOP_TREE_NODE. */ |
558 static void | 417 static void |
559 add_copies (ira_loop_tree_node_t loop_tree_node) | 418 add_copies (ira_loop_tree_node_t loop_tree_node) |
560 { | 419 { |
561 basic_block bb; | 420 basic_block bb; |
562 rtx insn; | 421 rtx_insn *insn; |
563 | 422 |
564 bb = loop_tree_node->bb; | 423 bb = loop_tree_node->bb; |
565 if (bb == NULL) | 424 if (bb == NULL) |
566 return; | 425 return; |
567 FOR_BB_INSNS (bb, insn) | 426 FOR_BB_INSNS (bb, insn) |
606 ira_allocno_t parent_a, another_parent_a; | 465 ira_allocno_t parent_a, another_parent_a; |
607 ira_object_t parent_obj; | 466 ira_object_t parent_obj; |
608 ira_allocno_t a = OBJECT_ALLOCNO (obj); | 467 ira_allocno_t a = OBJECT_ALLOCNO (obj); |
609 IRA_INT_TYPE *object_conflicts; | 468 IRA_INT_TYPE *object_conflicts; |
610 minmax_set_iterator asi; | 469 minmax_set_iterator asi; |
470 int parent_min, parent_max ATTRIBUTE_UNUSED; | |
611 | 471 |
612 object_conflicts = conflicts[OBJECT_CONFLICT_ID (obj)]; | 472 object_conflicts = conflicts[OBJECT_CONFLICT_ID (obj)]; |
613 px = 0; | 473 px = 0; |
614 FOR_EACH_BIT_IN_MINMAX_SET (object_conflicts, | 474 FOR_EACH_BIT_IN_MINMAX_SET (object_conflicts, |
615 OBJECT_MIN (obj), OBJECT_MAX (obj), i, asi) | 475 OBJECT_MIN (obj), OBJECT_MAX (obj), i, asi) |
616 { | 476 { |
617 ira_object_t another_obj = ira_object_id_map[i]; | 477 ira_object_t another_obj = ira_object_id_map[i]; |
618 ira_allocno_t another_a = OBJECT_ALLOCNO (obj); | 478 ira_allocno_t another_a = OBJECT_ALLOCNO (obj); |
479 | |
619 ira_assert (ira_reg_classes_intersect_p | 480 ira_assert (ira_reg_classes_intersect_p |
620 [ALLOCNO_COVER_CLASS (a)][ALLOCNO_COVER_CLASS (another_a)]); | 481 [ALLOCNO_CLASS (a)][ALLOCNO_CLASS (another_a)]); |
621 collected_conflict_objects[px++] = another_obj; | 482 collected_conflict_objects[px++] = another_obj; |
622 } | 483 } |
623 if (ira_conflict_vector_profitable_p (obj, px)) | 484 if (ira_conflict_vector_profitable_p (obj, px)) |
624 { | 485 { |
625 ira_object_t *vec; | 486 ira_object_t *vec; |
630 OBJECT_NUM_CONFLICTS (obj) = px; | 491 OBJECT_NUM_CONFLICTS (obj) = px; |
631 } | 492 } |
632 else | 493 else |
633 { | 494 { |
634 int conflict_bit_vec_words_num; | 495 int conflict_bit_vec_words_num; |
496 | |
635 OBJECT_CONFLICT_ARRAY (obj) = object_conflicts; | 497 OBJECT_CONFLICT_ARRAY (obj) = object_conflicts; |
636 if (OBJECT_MAX (obj) < OBJECT_MIN (obj)) | 498 if (OBJECT_MAX (obj) < OBJECT_MIN (obj)) |
637 conflict_bit_vec_words_num = 0; | 499 conflict_bit_vec_words_num = 0; |
638 else | 500 else |
639 conflict_bit_vec_words_num | 501 conflict_bit_vec_words_num |
644 } | 506 } |
645 | 507 |
646 parent_a = ira_parent_or_cap_allocno (a); | 508 parent_a = ira_parent_or_cap_allocno (a); |
647 if (parent_a == NULL) | 509 if (parent_a == NULL) |
648 return; | 510 return; |
649 ira_assert (ALLOCNO_COVER_CLASS (a) == ALLOCNO_COVER_CLASS (parent_a)); | 511 ira_assert (ALLOCNO_CLASS (a) == ALLOCNO_CLASS (parent_a)); |
650 ira_assert (ALLOCNO_NUM_OBJECTS (a) == ALLOCNO_NUM_OBJECTS (parent_a)); | 512 ira_assert (ALLOCNO_NUM_OBJECTS (a) == ALLOCNO_NUM_OBJECTS (parent_a)); |
651 parent_obj = ALLOCNO_OBJECT (parent_a, OBJECT_SUBWORD (obj)); | 513 parent_obj = ALLOCNO_OBJECT (parent_a, OBJECT_SUBWORD (obj)); |
652 parent_num = OBJECT_CONFLICT_ID (parent_obj); | 514 parent_num = OBJECT_CONFLICT_ID (parent_obj); |
515 parent_min = OBJECT_MIN (parent_obj); | |
516 parent_max = OBJECT_MAX (parent_obj); | |
653 FOR_EACH_BIT_IN_MINMAX_SET (object_conflicts, | 517 FOR_EACH_BIT_IN_MINMAX_SET (object_conflicts, |
654 OBJECT_MIN (obj), OBJECT_MAX (obj), i, asi) | 518 OBJECT_MIN (obj), OBJECT_MAX (obj), i, asi) |
655 { | 519 { |
656 ira_object_t another_obj = ira_object_id_map[i]; | 520 ira_object_t another_obj = ira_object_id_map[i]; |
657 ira_allocno_t another_a = OBJECT_ALLOCNO (another_obj); | 521 ira_allocno_t another_a = OBJECT_ALLOCNO (another_obj); |
658 int another_word = OBJECT_SUBWORD (another_obj); | 522 int another_word = OBJECT_SUBWORD (another_obj); |
659 | 523 |
660 ira_assert (ira_reg_classes_intersect_p | 524 ira_assert (ira_reg_classes_intersect_p |
661 [ALLOCNO_COVER_CLASS (a)][ALLOCNO_COVER_CLASS (another_a)]); | 525 [ALLOCNO_CLASS (a)][ALLOCNO_CLASS (another_a)]); |
662 | 526 |
663 another_parent_a = ira_parent_or_cap_allocno (another_a); | 527 another_parent_a = ira_parent_or_cap_allocno (another_a); |
664 if (another_parent_a == NULL) | 528 if (another_parent_a == NULL) |
665 continue; | 529 continue; |
666 ira_assert (ALLOCNO_NUM (another_parent_a) >= 0); | 530 ira_assert (ALLOCNO_NUM (another_parent_a) >= 0); |
667 ira_assert (ALLOCNO_COVER_CLASS (another_a) | 531 ira_assert (ALLOCNO_CLASS (another_a) |
668 == ALLOCNO_COVER_CLASS (another_parent_a)); | 532 == ALLOCNO_CLASS (another_parent_a)); |
669 ira_assert (ALLOCNO_NUM_OBJECTS (another_a) | 533 ira_assert (ALLOCNO_NUM_OBJECTS (another_a) |
670 == ALLOCNO_NUM_OBJECTS (another_parent_a)); | 534 == ALLOCNO_NUM_OBJECTS (another_parent_a)); |
671 SET_MINMAX_SET_BIT (conflicts[parent_num], | 535 SET_MINMAX_SET_BIT (conflicts[parent_num], |
672 OBJECT_CONFLICT_ID (ALLOCNO_OBJECT (another_parent_a, | 536 OBJECT_CONFLICT_ID (ALLOCNO_OBJECT (another_parent_a, |
673 another_word)), | 537 another_word)), |
674 OBJECT_MIN (parent_obj), | 538 parent_min, parent_max); |
675 OBJECT_MAX (parent_obj)); | |
676 } | 539 } |
677 } | 540 } |
678 | 541 |
679 /* Build conflict vectors or bit conflict vectors (whatever is more | 542 /* Build conflict vectors or bit conflict vectors (whatever is more |
680 profitable) of all allocnos from the conflict table. */ | 543 profitable) of all allocnos from the conflict table. */ |
752 { | 615 { |
753 fprintf (file, ";; a%d(r%d,", ALLOCNO_NUM (a), ALLOCNO_REGNO (a)); | 616 fprintf (file, ";; a%d(r%d,", ALLOCNO_NUM (a), ALLOCNO_REGNO (a)); |
754 if ((bb = ALLOCNO_LOOP_TREE_NODE (a)->bb) != NULL) | 617 if ((bb = ALLOCNO_LOOP_TREE_NODE (a)->bb) != NULL) |
755 fprintf (file, "b%d", bb->index); | 618 fprintf (file, "b%d", bb->index); |
756 else | 619 else |
757 fprintf (file, "l%d", ALLOCNO_LOOP_TREE_NODE (a)->loop->num); | 620 fprintf (file, "l%d", ALLOCNO_LOOP_TREE_NODE (a)->loop_num); |
758 putc (')', file); | 621 putc (')', file); |
759 } | 622 } |
760 | 623 |
761 fputs (" conflicts:", file); | 624 fputs (" conflicts:", file); |
762 n = ALLOCNO_NUM_OBJECTS (a); | 625 n = ALLOCNO_NUM_OBJECTS (a); |
783 fprintf (file, ",w%d", OBJECT_SUBWORD (conflict_obj)); | 646 fprintf (file, ",w%d", OBJECT_SUBWORD (conflict_obj)); |
784 if ((bb = ALLOCNO_LOOP_TREE_NODE (conflict_a)->bb) != NULL) | 647 if ((bb = ALLOCNO_LOOP_TREE_NODE (conflict_a)->bb) != NULL) |
785 fprintf (file, ",b%d", bb->index); | 648 fprintf (file, ",b%d", bb->index); |
786 else | 649 else |
787 fprintf (file, ",l%d", | 650 fprintf (file, ",l%d", |
788 ALLOCNO_LOOP_TREE_NODE (conflict_a)->loop->num); | 651 ALLOCNO_LOOP_TREE_NODE (conflict_a)->loop_num); |
789 putc (')', file); | 652 putc (')', file); |
790 } | 653 } |
791 } | 654 } |
792 COPY_HARD_REG_SET (conflicting_hard_regs, OBJECT_TOTAL_CONFLICT_HARD_REGS (obj)); | 655 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); | 656 AND_COMPL_HARD_REG_SET (conflicting_hard_regs, ira_no_alloc_regs); |
794 AND_HARD_REG_SET (conflicting_hard_regs, | 657 AND_HARD_REG_SET (conflicting_hard_regs, |
795 reg_class_contents[ALLOCNO_COVER_CLASS (a)]); | 658 reg_class_contents[ALLOCNO_CLASS (a)]); |
796 print_hard_reg_set (file, "\n;; total conflict hard regs:", | 659 print_hard_reg_set (file, "\n;; total conflict hard regs:", |
797 conflicting_hard_regs); | 660 conflicting_hard_regs); |
798 | 661 |
799 COPY_HARD_REG_SET (conflicting_hard_regs, OBJECT_CONFLICT_HARD_REGS (obj)); | 662 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); | 663 AND_COMPL_HARD_REG_SET (conflicting_hard_regs, ira_no_alloc_regs); |
801 AND_HARD_REG_SET (conflicting_hard_regs, | 664 AND_HARD_REG_SET (conflicting_hard_regs, |
802 reg_class_contents[ALLOCNO_COVER_CLASS (a)]); | 665 reg_class_contents[ALLOCNO_CLASS (a)]); |
803 print_hard_reg_set (file, ";; conflict hard regs:", | 666 print_hard_reg_set (file, ";; conflict hard regs:", |
804 conflicting_hard_regs); | 667 conflicting_hard_regs); |
805 putc ('\n', file); | 668 putc ('\n', file); |
806 } | 669 } |
807 | 670 |
832 /* Entry function which builds allocno conflicts and allocno copies | 695 /* Entry function which builds allocno conflicts and allocno copies |
833 and accumulate some allocno info on upper level regions. */ | 696 and accumulate some allocno info on upper level regions. */ |
834 void | 697 void |
835 ira_build_conflicts (void) | 698 ira_build_conflicts (void) |
836 { | 699 { |
700 enum reg_class base; | |
837 ira_allocno_t a; | 701 ira_allocno_t a; |
838 ira_allocno_iterator ai; | 702 ira_allocno_iterator ai; |
839 HARD_REG_SET temp_hard_reg_set; | 703 HARD_REG_SET temp_hard_reg_set; |
840 | 704 |
841 if (ira_conflicts_p) | 705 if (ira_conflicts_p) |
845 { | 709 { |
846 ira_object_t obj; | 710 ira_object_t obj; |
847 ira_object_iterator oi; | 711 ira_object_iterator oi; |
848 | 712 |
849 build_conflicts (); | 713 build_conflicts (); |
850 ira_traverse_loop_tree (true, ira_loop_tree_root, NULL, add_copies); | 714 ira_traverse_loop_tree (true, ira_loop_tree_root, add_copies, NULL); |
851 /* We need finished conflict table for the subsequent call. */ | 715 /* We need finished conflict table for the subsequent call. */ |
852 if (flag_ira_region == IRA_REGION_ALL | 716 if (flag_ira_region == IRA_REGION_ALL |
853 || flag_ira_region == IRA_REGION_MIXED) | 717 || flag_ira_region == IRA_REGION_MIXED) |
854 propagate_copies (); | 718 propagate_copies (); |
855 | 719 |
861 ira_free (conflicts[OBJECT_CONFLICT_ID (obj)]); | 725 ira_free (conflicts[OBJECT_CONFLICT_ID (obj)]); |
862 } | 726 } |
863 ira_free (conflicts); | 727 ira_free (conflicts); |
864 } | 728 } |
865 } | 729 } |
866 if (! targetm.class_likely_spilled_p (base_reg_class (VOIDmode, ADDRESS, | 730 base = base_reg_class (VOIDmode, ADDR_SPACE_GENERIC, ADDRESS, SCRATCH); |
867 SCRATCH))) | 731 if (! targetm.class_likely_spilled_p (base)) |
868 CLEAR_HARD_REG_SET (temp_hard_reg_set); | 732 CLEAR_HARD_REG_SET (temp_hard_reg_set); |
869 else | 733 else |
870 { | 734 { |
871 COPY_HARD_REG_SET (temp_hard_reg_set, | 735 COPY_HARD_REG_SET (temp_hard_reg_set, reg_class_contents[base]); |
872 reg_class_contents[base_reg_class (VOIDmode, ADDRESS, SCRATCH)]); | |
873 AND_COMPL_HARD_REG_SET (temp_hard_reg_set, ira_no_alloc_regs); | 736 AND_COMPL_HARD_REG_SET (temp_hard_reg_set, ira_no_alloc_regs); |
874 AND_HARD_REG_SET (temp_hard_reg_set, call_used_reg_set); | 737 AND_HARD_REG_SET (temp_hard_reg_set, call_used_reg_set); |
875 } | 738 } |
876 FOR_EACH_ALLOCNO (a, ai) | 739 FOR_EACH_ALLOCNO (a, ai) |
877 { | 740 { |
878 int i, n = ALLOCNO_NUM_OBJECTS (a); | 741 int i, n = ALLOCNO_NUM_OBJECTS (a); |
742 | |
879 for (i = 0; i < n; i++) | 743 for (i = 0; i < n; i++) |
880 { | 744 { |
881 ira_object_t obj = ALLOCNO_OBJECT (a, i); | 745 ira_object_t obj = ALLOCNO_OBJECT (a, i); |
882 reg_attrs *attrs = REG_ATTRS (regno_reg_rtx [ALLOCNO_REGNO (a)]); | 746 machine_mode obj_mode = obj->allocno->mode; |
883 tree decl; | 747 rtx allocno_reg = regno_reg_rtx [ALLOCNO_REGNO (a)]; |
884 | 748 |
885 if ((! flag_caller_saves && ALLOCNO_CALLS_CROSSED_NUM (a) != 0) | 749 if ((! flag_caller_saves && ALLOCNO_CALLS_CROSSED_NUM (a) != 0) |
886 /* For debugging purposes don't put user defined variables in | 750 /* For debugging purposes don't put user defined variables in |
887 callee-clobbered registers. */ | 751 callee-clobbered registers. However, do allow parameters |
752 in callee-clobbered registers to improve debugging. This | |
753 is a bit of a fragile hack. */ | |
888 || (optimize == 0 | 754 || (optimize == 0 |
889 && attrs != NULL | 755 && REG_USERVAR_P (allocno_reg) |
890 && (decl = attrs->decl) != NULL | 756 && ! reg_is_parm_p (allocno_reg))) |
891 && VAR_OR_FUNCTION_DECL_P (decl) | |
892 && ! DECL_ARTIFICIAL (decl))) | |
893 { | 757 { |
894 IOR_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), | 758 IOR_HARD_REG_SET (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), |
895 call_used_reg_set); | 759 call_used_reg_set); |
896 IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj), | 760 IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj), |
897 call_used_reg_set); | 761 call_used_reg_set); |
906 no_caller_save_reg_set); | 770 no_caller_save_reg_set); |
907 IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj), | 771 IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj), |
908 temp_hard_reg_set); | 772 temp_hard_reg_set); |
909 } | 773 } |
910 | 774 |
775 /* Now we deal with paradoxical subreg cases where certain registers | |
776 cannot be accessed in the widest mode. */ | |
777 machine_mode outer_mode = ALLOCNO_WMODE (a); | |
778 machine_mode inner_mode = ALLOCNO_MODE (a); | |
779 if (paradoxical_subreg_p (outer_mode, inner_mode)) | |
780 { | |
781 enum reg_class aclass = ALLOCNO_CLASS (a); | |
782 for (int j = ira_class_hard_regs_num[aclass] - 1; j >= 0; --j) | |
783 { | |
784 int inner_regno = ira_class_hard_regs[aclass][j]; | |
785 int outer_regno = simplify_subreg_regno (inner_regno, | |
786 inner_mode, 0, | |
787 outer_mode); | |
788 if (outer_regno < 0 | |
789 || !in_hard_reg_set_p (reg_class_contents[aclass], | |
790 outer_mode, outer_regno)) | |
791 { | |
792 SET_HARD_REG_BIT (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), | |
793 inner_regno); | |
794 SET_HARD_REG_BIT (OBJECT_CONFLICT_HARD_REGS (obj), | |
795 inner_regno); | |
796 } | |
797 } | |
798 } | |
799 | |
911 if (ALLOCNO_CALLS_CROSSED_NUM (a) != 0) | 800 if (ALLOCNO_CALLS_CROSSED_NUM (a) != 0) |
912 { | 801 { |
913 int regno; | 802 int regno; |
914 | 803 |
915 /* Allocnos bigger than the saved part of call saved | 804 /* Allocnos bigger than the saved part of call saved |
916 regs must conflict with them. */ | 805 regs must conflict with them. */ |
917 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) | 806 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) |
918 if (!TEST_HARD_REG_BIT (call_used_reg_set, regno) | 807 if (!TEST_HARD_REG_BIT (call_used_reg_set, regno) |
919 && HARD_REGNO_CALL_PART_CLOBBERED (regno, | 808 && targetm.hard_regno_call_part_clobbered (regno, |
920 obj->allocno->mode)) | 809 obj_mode)) |
921 { | 810 { |
922 SET_HARD_REG_BIT (OBJECT_CONFLICT_HARD_REGS (obj), regno); | 811 SET_HARD_REG_BIT (OBJECT_CONFLICT_HARD_REGS (obj), regno); |
923 SET_HARD_REG_BIT (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), | 812 SET_HARD_REG_BIT (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), |
924 regno); | 813 regno); |
925 } | 814 } |