Mercurial > hg > CbC > CbC_gcc
annotate gcc/ira-lives.c @ 66:b362627d71ba
bug-fix: modify tail-call-optimization enforcing rules. (calls.c.)
author | Ryoma SHINYA <shinya@firefly.cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 14 Dec 2010 03:58:33 +0900 |
parents | 77e2b8dfacca |
children | b7f97abdc517 |
rev | line source |
---|---|
0 | 1 /* IRA processing allocno lives to build allocno live ranges. |
2 Copyright (C) 2006, 2007, 2008, 2009 | |
3 Free Software Foundation, Inc. | |
4 Contributed by Vladimir Makarov <vmakarov@redhat.com>. | |
5 | |
6 This file is part of GCC. | |
7 | |
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 | |
11 version. | |
12 | |
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 | |
16 for more details. | |
17 | |
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/>. */ | |
21 | |
22 #include "config.h" | |
23 #include "system.h" | |
24 #include "coretypes.h" | |
25 #include "tm.h" | |
26 #include "regs.h" | |
27 #include "rtl.h" | |
28 #include "tm_p.h" | |
29 #include "target.h" | |
30 #include "flags.h" | |
31 #include "except.h" | |
32 #include "hard-reg-set.h" | |
33 #include "basic-block.h" | |
34 #include "insn-config.h" | |
35 #include "recog.h" | |
36 #include "toplev.h" | |
37 #include "params.h" | |
38 #include "df.h" | |
39 #include "sparseset.h" | |
40 #include "ira-int.h" | |
41 | |
42 /* The code in this file is similar to one in global but the code | |
43 works on the allocno basis and creates live ranges instead of | |
44 pseudo-register conflicts. */ | |
45 | |
46 /* Program points are enumerated by numbers from range | |
47 0..IRA_MAX_POINT-1. There are approximately two times more program | |
48 points than insns. Program points are places in the program where | |
49 liveness info can be changed. In most general case (there are more | |
50 complicated cases too) some program points correspond to places | |
51 where input operand dies and other ones correspond to places where | |
52 output operands are born. */ | |
53 int ira_max_point; | |
54 | |
55 /* Arrays of size IRA_MAX_POINT mapping a program point to the allocno | |
56 live ranges with given start/finish point. */ | |
57 allocno_live_range_t *ira_start_point_ranges, *ira_finish_point_ranges; | |
58 | |
59 /* Number of the current program point. */ | |
60 static int curr_point; | |
61 | |
62 /* Point where register pressure excess started or -1 if there is no | |
63 register pressure excess. Excess pressure for a register class at | |
64 some point means that there are more allocnos of given register | |
65 class living at the point than number of hard-registers of the | |
66 class available for the allocation. It is defined only for cover | |
67 classes. */ | |
68 static int high_pressure_start_point[N_REG_CLASSES]; | |
69 | |
70 /* Allocnos live at current point in the scan. */ | |
71 static sparseset allocnos_live; | |
72 | |
73 /* Set of hard regs (except eliminable ones) currently live. */ | |
74 static HARD_REG_SET hard_regs_live; | |
75 | |
76 /* The loop tree node corresponding to the current basic block. */ | |
77 static ira_loop_tree_node_t curr_bb_node; | |
78 | |
79 /* The number of the last processed call. */ | |
80 static int last_call_num; | |
81 /* The number of last call at which given allocno was saved. */ | |
82 static int *allocno_saved_at_call; | |
83 | |
84 /* The function processing birth of register REGNO. It updates living | |
85 hard regs and conflict hard regs for living allocnos or starts a | |
86 new live range for the allocno corresponding to REGNO if it is | |
87 necessary. */ | |
88 static void | |
89 make_regno_born (int regno) | |
90 { | |
91 unsigned int i; | |
92 ira_allocno_t a; | |
93 allocno_live_range_t p; | |
94 | |
95 if (regno < FIRST_PSEUDO_REGISTER) | |
96 { | |
97 SET_HARD_REG_BIT (hard_regs_live, regno); | |
98 EXECUTE_IF_SET_IN_SPARSESET (allocnos_live, i) | |
99 { | |
100 SET_HARD_REG_BIT (ALLOCNO_CONFLICT_HARD_REGS (ira_allocnos[i]), | |
101 regno); | |
102 SET_HARD_REG_BIT (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (ira_allocnos[i]), | |
103 regno); | |
104 } | |
105 return; | |
106 } | |
107 a = ira_curr_regno_allocno_map[regno]; | |
108 if (a == NULL) | |
109 return; | |
110 if ((p = ALLOCNO_LIVE_RANGES (a)) == NULL | |
111 || (p->finish != curr_point && p->finish + 1 != curr_point)) | |
112 ALLOCNO_LIVE_RANGES (a) | |
113 = ira_create_allocno_live_range (a, curr_point, -1, | |
114 ALLOCNO_LIVE_RANGES (a)); | |
115 } | |
116 | |
117 /* Update ALLOCNO_EXCESS_PRESSURE_POINTS_NUM for allocno A. */ | |
118 static void | |
119 update_allocno_pressure_excess_length (ira_allocno_t a) | |
120 { | |
121 int start, i; | |
122 enum reg_class cover_class, cl; | |
123 allocno_live_range_t p; | |
124 | |
125 cover_class = ALLOCNO_COVER_CLASS (a); | |
126 for (i = 0; | |
127 (cl = ira_reg_class_super_classes[cover_class][i]) != LIM_REG_CLASSES; | |
128 i++) | |
129 { | |
130 if (high_pressure_start_point[cl] < 0) | |
131 continue; | |
132 p = ALLOCNO_LIVE_RANGES (a); | |
133 ira_assert (p != NULL); | |
134 start = (high_pressure_start_point[cl] > p->start | |
135 ? high_pressure_start_point[cl] : p->start); | |
136 ALLOCNO_EXCESS_PRESSURE_POINTS_NUM (a) += curr_point - start + 1; | |
137 } | |
138 } | |
139 | |
140 /* Process the death of register REGNO. This updates hard_regs_live | |
141 or finishes the current live range for the allocno corresponding to | |
142 REGNO. */ | |
143 static void | |
144 make_regno_dead (int regno) | |
145 { | |
146 ira_allocno_t a; | |
147 allocno_live_range_t p; | |
148 | |
149 if (regno < FIRST_PSEUDO_REGISTER) | |
150 { | |
151 CLEAR_HARD_REG_BIT (hard_regs_live, regno); | |
152 return; | |
153 } | |
154 a = ira_curr_regno_allocno_map[regno]; | |
155 if (a == NULL) | |
156 return; | |
157 p = ALLOCNO_LIVE_RANGES (a); | |
158 ira_assert (p != NULL); | |
159 p->finish = curr_point; | |
160 update_allocno_pressure_excess_length (a); | |
161 } | |
162 | |
163 /* The current register pressures for each cover class for the current | |
164 basic block. */ | |
165 static int curr_reg_pressure[N_REG_CLASSES]; | |
166 | |
167 /* Mark allocno A as currently living and update current register | |
168 pressure, maximal register pressure for the current BB, start point | |
169 of the register pressure excess, and conflicting hard registers of | |
170 A. */ | |
171 static void | |
172 set_allocno_live (ira_allocno_t a) | |
173 { | |
174 int i; | |
175 enum reg_class cover_class, cl; | |
176 | |
177 /* Invalidate because it is referenced. */ | |
178 allocno_saved_at_call[ALLOCNO_NUM (a)] = 0; | |
179 if (sparseset_bit_p (allocnos_live, ALLOCNO_NUM (a))) | |
180 return; | |
181 sparseset_set_bit (allocnos_live, ALLOCNO_NUM (a)); | |
182 IOR_HARD_REG_SET (ALLOCNO_CONFLICT_HARD_REGS (a), hard_regs_live); | |
183 IOR_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a), hard_regs_live); | |
184 cover_class = ALLOCNO_COVER_CLASS (a); | |
185 for (i = 0; | |
186 (cl = ira_reg_class_super_classes[cover_class][i]) != LIM_REG_CLASSES; | |
187 i++) | |
188 { | |
189 curr_reg_pressure[cl] += ira_reg_class_nregs[cl][ALLOCNO_MODE (a)]; | |
190 if (high_pressure_start_point[cl] < 0 | |
191 && (curr_reg_pressure[cl] > ira_available_class_regs[cl])) | |
192 high_pressure_start_point[cl] = curr_point; | |
193 if (curr_bb_node->reg_pressure[cl] < curr_reg_pressure[cl]) | |
194 curr_bb_node->reg_pressure[cl] = curr_reg_pressure[cl]; | |
195 } | |
196 } | |
197 | |
198 /* Mark allocno A as currently not living and update current register | |
199 pressure, start point of the register pressure excess, and register | |
200 pressure excess length for living allocnos. */ | |
201 static void | |
202 clear_allocno_live (ira_allocno_t a) | |
203 { | |
204 int i; | |
205 unsigned int j; | |
206 enum reg_class cover_class, cl; | |
207 bool set_p; | |
208 | |
209 /* Invalidate because it is referenced. */ | |
210 allocno_saved_at_call[ALLOCNO_NUM (a)] = 0; | |
211 if (sparseset_bit_p (allocnos_live, ALLOCNO_NUM (a))) | |
212 { | |
213 cover_class = ALLOCNO_COVER_CLASS (a); | |
214 set_p = false; | |
215 for (i = 0; | |
216 (cl = ira_reg_class_super_classes[cover_class][i]) | |
217 != LIM_REG_CLASSES; | |
218 i++) | |
219 { | |
220 curr_reg_pressure[cl] -= ira_reg_class_nregs[cl][ALLOCNO_MODE (a)]; | |
221 ira_assert (curr_reg_pressure[cl] >= 0); | |
222 if (high_pressure_start_point[cl] >= 0 | |
223 && curr_reg_pressure[cl] <= ira_available_class_regs[cl]) | |
224 set_p = true; | |
225 } | |
226 if (set_p) | |
227 { | |
228 EXECUTE_IF_SET_IN_SPARSESET (allocnos_live, j) | |
229 update_allocno_pressure_excess_length (ira_allocnos[j]); | |
230 for (i = 0; | |
231 (cl = ira_reg_class_super_classes[cover_class][i]) | |
232 != LIM_REG_CLASSES; | |
233 i++) | |
234 if (high_pressure_start_point[cl] >= 0 | |
235 && curr_reg_pressure[cl] <= ira_available_class_regs[cl]) | |
236 high_pressure_start_point[cl] = -1; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
237 |
0 | 238 } |
239 } | |
240 sparseset_clear_bit (allocnos_live, ALLOCNO_NUM (a)); | |
241 } | |
242 | |
243 /* Mark the register REG as live. Store a 1 in hard_regs_live or | |
244 allocnos_live for this register or the corresponding allocno, | |
245 record how many consecutive hardware registers it actually | |
246 needs. */ | |
247 static void | |
248 mark_reg_live (rtx reg) | |
249 { | |
250 int i, regno; | |
251 | |
252 gcc_assert (REG_P (reg)); | |
253 regno = REGNO (reg); | |
254 | |
255 if (regno >= FIRST_PSEUDO_REGISTER) | |
256 { | |
257 ira_allocno_t a = ira_curr_regno_allocno_map[regno]; | |
258 | |
259 if (a != NULL) | |
260 { | |
261 if (sparseset_bit_p (allocnos_live, ALLOCNO_NUM (a))) | |
262 { | |
263 /* Invalidate because it is referenced. */ | |
264 allocno_saved_at_call[ALLOCNO_NUM (a)] = 0; | |
265 return; | |
266 } | |
267 set_allocno_live (a); | |
268 } | |
269 make_regno_born (regno); | |
270 } | |
271 else if (! TEST_HARD_REG_BIT (ira_no_alloc_regs, regno)) | |
272 { | |
273 int last = regno + hard_regno_nregs[regno][GET_MODE (reg)]; | |
274 enum reg_class cover_class, cl; | |
275 | |
276 while (regno < last) | |
277 { | |
278 if (! TEST_HARD_REG_BIT (hard_regs_live, regno) | |
279 && ! TEST_HARD_REG_BIT (eliminable_regset, regno)) | |
280 { | |
281 cover_class = ira_hard_regno_cover_class[regno]; | |
282 for (i = 0; | |
283 (cl = ira_reg_class_super_classes[cover_class][i]) | |
284 != LIM_REG_CLASSES; | |
285 i++) | |
286 { | |
287 curr_reg_pressure[cl]++; | |
288 if (high_pressure_start_point[cl] < 0 | |
289 && (curr_reg_pressure[cl] | |
290 > ira_available_class_regs[cl])) | |
291 high_pressure_start_point[cl] = curr_point; | |
292 } | |
293 make_regno_born (regno); | |
294 for (i = 0; | |
295 (cl = ira_reg_class_super_classes[cover_class][i]) | |
296 != LIM_REG_CLASSES; | |
297 i++) | |
298 { | |
299 if (curr_bb_node->reg_pressure[cl] < curr_reg_pressure[cl]) | |
300 curr_bb_node->reg_pressure[cl] = curr_reg_pressure[cl]; | |
301 } | |
302 } | |
303 regno++; | |
304 } | |
305 } | |
306 } | |
307 | |
308 /* Mark the register referenced by use or def REF as live. */ | |
309 static void | |
310 mark_ref_live (df_ref ref) | |
311 { | |
312 rtx reg; | |
313 | |
314 reg = DF_REF_REG (ref); | |
315 if (GET_CODE (reg) == SUBREG) | |
316 reg = SUBREG_REG (reg); | |
317 mark_reg_live (reg); | |
318 } | |
319 | |
320 /* Mark the register REG as dead. Store a 0 in hard_regs_live or | |
321 allocnos_live for the register. */ | |
322 static void | |
323 mark_reg_dead (rtx reg) | |
324 { | |
325 int regno; | |
326 | |
327 gcc_assert (REG_P (reg)); | |
328 regno = REGNO (reg); | |
329 | |
330 if (regno >= FIRST_PSEUDO_REGISTER) | |
331 { | |
332 ira_allocno_t a = ira_curr_regno_allocno_map[regno]; | |
333 | |
334 if (a != NULL) | |
335 { | |
336 if (! sparseset_bit_p (allocnos_live, ALLOCNO_NUM (a))) | |
337 { | |
338 /* Invalidate because it is referenced. */ | |
339 allocno_saved_at_call[ALLOCNO_NUM (a)] = 0; | |
340 return; | |
341 } | |
342 clear_allocno_live (a); | |
343 } | |
344 make_regno_dead (regno); | |
345 } | |
346 else if (! TEST_HARD_REG_BIT (ira_no_alloc_regs, regno)) | |
347 { | |
348 int i; | |
349 unsigned int j; | |
350 int last = regno + hard_regno_nregs[regno][GET_MODE (reg)]; | |
351 enum reg_class cover_class, cl; | |
352 bool set_p; | |
353 | |
354 while (regno < last) | |
355 { | |
356 if (TEST_HARD_REG_BIT (hard_regs_live, regno)) | |
357 { | |
358 set_p = false; | |
359 cover_class = ira_hard_regno_cover_class[regno]; | |
360 for (i = 0; | |
361 (cl = ira_reg_class_super_classes[cover_class][i]) | |
362 != LIM_REG_CLASSES; | |
363 i++) | |
364 { | |
365 curr_reg_pressure[cl]--; | |
366 if (high_pressure_start_point[cl] >= 0 | |
367 && curr_reg_pressure[cl] <= ira_available_class_regs[cl]) | |
368 set_p = true; | |
369 ira_assert (curr_reg_pressure[cl] >= 0); | |
370 } | |
371 if (set_p) | |
372 { | |
373 EXECUTE_IF_SET_IN_SPARSESET (allocnos_live, j) | |
374 update_allocno_pressure_excess_length (ira_allocnos[j]); | |
375 for (i = 0; | |
376 (cl = ira_reg_class_super_classes[cover_class][i]) | |
377 != LIM_REG_CLASSES; | |
378 i++) | |
379 if (high_pressure_start_point[cl] >= 0 | |
380 && (curr_reg_pressure[cl] | |
381 <= ira_available_class_regs[cl])) | |
382 high_pressure_start_point[cl] = -1; | |
383 } | |
384 make_regno_dead (regno); | |
385 } | |
386 regno++; | |
387 } | |
388 } | |
389 } | |
390 | |
391 /* Mark the register referenced by definition DEF as dead, if the | |
392 definition is a total one. */ | |
393 static void | |
394 mark_ref_dead (df_ref def) | |
395 { | |
396 rtx reg; | |
397 | |
398 if (DF_REF_FLAGS_IS_SET (def, DF_REF_PARTIAL) | |
399 || DF_REF_FLAGS_IS_SET (def, DF_REF_CONDITIONAL)) | |
400 return; | |
401 | |
402 reg = DF_REF_REG (def); | |
403 if (GET_CODE (reg) == SUBREG) | |
404 reg = SUBREG_REG (reg); | |
405 mark_reg_dead (reg); | |
406 } | |
407 | |
408 /* Make pseudo REG conflicting with pseudo DREG, if the 1st pseudo | |
409 class is intersected with class CL. Advance the current program | |
410 point before making the conflict if ADVANCE_P. Return TRUE if we | |
411 will need to advance the current program point. */ | |
412 static bool | |
413 make_pseudo_conflict (rtx reg, enum reg_class cl, rtx dreg, bool advance_p) | |
414 { | |
415 ira_allocno_t a; | |
416 | |
417 if (GET_CODE (reg) == SUBREG) | |
418 reg = SUBREG_REG (reg); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
419 |
0 | 420 if (! REG_P (reg) || REGNO (reg) < FIRST_PSEUDO_REGISTER) |
421 return advance_p; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
422 |
0 | 423 a = ira_curr_regno_allocno_map[REGNO (reg)]; |
424 if (! reg_classes_intersect_p (cl, ALLOCNO_COVER_CLASS (a))) | |
425 return advance_p; | |
426 | |
427 if (advance_p) | |
428 curr_point++; | |
429 | |
430 mark_reg_live (reg); | |
431 mark_reg_live (dreg); | |
432 mark_reg_dead (reg); | |
433 mark_reg_dead (dreg); | |
434 | |
435 return false; | |
436 } | |
437 | |
438 /* Check and make if necessary conflicts for pseudo DREG of class | |
439 DEF_CL of the current insn with input operand USE of class USE_CL. | |
440 Advance the current program point before making the conflict if | |
441 ADVANCE_P. Return TRUE if we will need to advance the current | |
442 program point. */ | |
443 static bool | |
444 check_and_make_def_use_conflict (rtx dreg, enum reg_class def_cl, | |
445 int use, enum reg_class use_cl, | |
446 bool advance_p) | |
447 { | |
448 if (! reg_classes_intersect_p (def_cl, use_cl)) | |
449 return advance_p; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
450 |
0 | 451 advance_p = make_pseudo_conflict (recog_data.operand[use], |
452 use_cl, dreg, advance_p); | |
453 /* Reload may end up swapping commutative operands, so you | |
454 have to take both orderings into account. The | |
455 constraints for the two operands can be completely | |
456 different. (Indeed, if the constraints for the two | |
457 operands are the same for all alternatives, there's no | |
458 point marking them as commutative.) */ | |
459 if (use < recog_data.n_operands + 1 | |
460 && recog_data.constraints[use][0] == '%') | |
461 advance_p | |
462 = make_pseudo_conflict (recog_data.operand[use + 1], | |
463 use_cl, dreg, advance_p); | |
464 if (use >= 1 | |
465 && recog_data.constraints[use - 1][0] == '%') | |
466 advance_p | |
467 = make_pseudo_conflict (recog_data.operand[use - 1], | |
468 use_cl, dreg, advance_p); | |
469 return advance_p; | |
470 } | |
471 | |
472 /* Check and make if necessary conflicts for definition DEF of class | |
473 DEF_CL of the current insn with input operands. Process only | |
474 constraints of alternative ALT. */ | |
475 static void | |
476 check_and_make_def_conflict (int alt, int def, enum reg_class def_cl) | |
477 { | |
478 int use, use_match; | |
479 ira_allocno_t a; | |
480 enum reg_class use_cl, acl; | |
481 bool advance_p; | |
482 rtx dreg = recog_data.operand[def]; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
483 |
0 | 484 if (def_cl == NO_REGS) |
485 return; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
486 |
0 | 487 if (GET_CODE (dreg) == SUBREG) |
488 dreg = SUBREG_REG (dreg); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
489 |
0 | 490 if (! REG_P (dreg) || REGNO (dreg) < FIRST_PSEUDO_REGISTER) |
491 return; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
492 |
0 | 493 a = ira_curr_regno_allocno_map[REGNO (dreg)]; |
494 acl = ALLOCNO_COVER_CLASS (a); | |
495 if (! reg_classes_intersect_p (acl, def_cl)) | |
496 return; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
497 |
0 | 498 advance_p = true; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
499 |
0 | 500 for (use = 0; use < recog_data.n_operands; use++) |
501 { | |
502 if (use == def || recog_data.operand_type[use] == OP_OUT) | |
36 | 503 continue; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
504 |
0 | 505 if (recog_op_alt[use][alt].anything_ok) |
506 use_cl = ALL_REGS; | |
507 else | |
508 use_cl = recog_op_alt[use][alt].cl; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
509 |
0 | 510 advance_p = check_and_make_def_use_conflict (dreg, def_cl, use, |
511 use_cl, advance_p); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
512 |
0 | 513 if ((use_match = recog_op_alt[use][alt].matches) >= 0) |
514 { | |
515 if (use_match == def) | |
36 | 516 continue; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
517 |
0 | 518 if (recog_op_alt[use_match][alt].anything_ok) |
519 use_cl = ALL_REGS; | |
520 else | |
521 use_cl = recog_op_alt[use_match][alt].cl; | |
522 advance_p = check_and_make_def_use_conflict (dreg, def_cl, use, | |
523 use_cl, advance_p); | |
524 } | |
525 } | |
526 } | |
527 | |
528 /* Make conflicts of early clobber pseudo registers of the current | |
529 insn with its inputs. Avoid introducing unnecessary conflicts by | |
530 checking classes of the constraints and pseudos because otherwise | |
531 significant code degradation is possible for some targets. */ | |
532 static void | |
533 make_early_clobber_and_input_conflicts (void) | |
534 { | |
535 int alt; | |
536 int def, def_match; | |
537 enum reg_class def_cl; | |
538 | |
539 for (alt = 0; alt < recog_data.n_alternatives; alt++) | |
540 for (def = 0; def < recog_data.n_operands; def++) | |
541 { | |
542 def_cl = NO_REGS; | |
543 if (recog_op_alt[def][alt].earlyclobber) | |
544 { | |
545 if (recog_op_alt[def][alt].anything_ok) | |
546 def_cl = ALL_REGS; | |
547 else | |
548 def_cl = recog_op_alt[def][alt].cl; | |
549 check_and_make_def_conflict (alt, def, def_cl); | |
550 } | |
551 if ((def_match = recog_op_alt[def][alt].matches) >= 0 | |
552 && (recog_op_alt[def_match][alt].earlyclobber | |
553 || recog_op_alt[def][alt].earlyclobber)) | |
554 { | |
555 if (recog_op_alt[def_match][alt].anything_ok) | |
556 def_cl = ALL_REGS; | |
557 else | |
558 def_cl = recog_op_alt[def_match][alt].cl; | |
559 check_and_make_def_conflict (alt, def, def_cl); | |
560 } | |
561 } | |
562 } | |
563 | |
564 /* Mark early clobber hard registers of the current INSN as live (if | |
565 LIVE_P) or dead. Return true if there are such registers. */ | |
566 static bool | |
567 mark_hard_reg_early_clobbers (rtx insn, bool live_p) | |
568 { | |
569 df_ref *def_rec; | |
570 bool set_p = false; | |
571 | |
572 for (def_rec = DF_INSN_DEFS (insn); *def_rec; def_rec++) | |
573 if (DF_REF_FLAGS_IS_SET (*def_rec, DF_REF_MUST_CLOBBER)) | |
574 { | |
575 rtx dreg = DF_REF_REG (*def_rec); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
576 |
0 | 577 if (GET_CODE (dreg) == SUBREG) |
578 dreg = SUBREG_REG (dreg); | |
579 if (! REG_P (dreg) || REGNO (dreg) >= FIRST_PSEUDO_REGISTER) | |
580 continue; | |
581 | |
582 /* Hard register clobbers are believed to be early clobber | |
583 because there is no way to say that non-operand hard | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
584 register clobbers are not early ones. */ |
0 | 585 if (live_p) |
586 mark_ref_live (*def_rec); | |
587 else | |
588 mark_ref_dead (*def_rec); | |
589 set_p = true; | |
590 } | |
591 | |
592 return set_p; | |
593 } | |
594 | |
595 /* Checks that CONSTRAINTS permits to use only one hard register. If | |
596 it is so, the function returns the class of the hard register. | |
597 Otherwise it returns NO_REGS. */ | |
598 static enum reg_class | |
599 single_reg_class (const char *constraints, rtx op, rtx equiv_const) | |
600 { | |
601 int ignore_p; | |
602 enum reg_class cl, next_cl; | |
603 int c; | |
604 | |
605 cl = NO_REGS; | |
606 for (ignore_p = false; | |
607 (c = *constraints); | |
608 constraints += CONSTRAINT_LEN (c, constraints)) | |
609 if (c == '#') | |
610 ignore_p = true; | |
611 else if (c == ',') | |
612 ignore_p = false; | |
613 else if (! ignore_p) | |
614 switch (c) | |
615 { | |
616 case ' ': | |
617 case '\t': | |
618 case '=': | |
619 case '+': | |
620 case '*': | |
621 case '&': | |
622 case '%': | |
623 case '!': | |
624 case '?': | |
625 break; | |
626 case 'i': | |
627 if (CONSTANT_P (op) | |
628 || (equiv_const != NULL_RTX && CONSTANT_P (equiv_const))) | |
629 return NO_REGS; | |
630 break; | |
631 | |
632 case 'n': | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
633 if (CONST_INT_P (op) |
0 | 634 || (GET_CODE (op) == CONST_DOUBLE && GET_MODE (op) == VOIDmode) |
635 || (equiv_const != NULL_RTX | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
636 && (CONST_INT_P (equiv_const) |
0 | 637 || (GET_CODE (equiv_const) == CONST_DOUBLE |
638 && GET_MODE (equiv_const) == VOIDmode)))) | |
639 return NO_REGS; | |
640 break; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
641 |
0 | 642 case 's': |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
643 if ((CONSTANT_P (op) && !CONST_INT_P (op) |
0 | 644 && (GET_CODE (op) != CONST_DOUBLE || GET_MODE (op) != VOIDmode)) |
645 || (equiv_const != NULL_RTX | |
646 && CONSTANT_P (equiv_const) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
647 && !CONST_INT_P (equiv_const) |
0 | 648 && (GET_CODE (equiv_const) != CONST_DOUBLE |
649 || GET_MODE (equiv_const) != VOIDmode))) | |
650 return NO_REGS; | |
651 break; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
652 |
0 | 653 case 'I': |
654 case 'J': | |
655 case 'K': | |
656 case 'L': | |
657 case 'M': | |
658 case 'N': | |
659 case 'O': | |
660 case 'P': | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
661 if ((CONST_INT_P (op) |
0 | 662 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (op), c, constraints)) |
663 || (equiv_const != NULL_RTX | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
664 && CONST_INT_P (equiv_const) |
0 | 665 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (equiv_const), |
666 c, constraints))) | |
667 return NO_REGS; | |
668 break; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
669 |
0 | 670 case 'E': |
671 case 'F': | |
672 if (GET_CODE (op) == CONST_DOUBLE | |
673 || (GET_CODE (op) == CONST_VECTOR | |
674 && GET_MODE_CLASS (GET_MODE (op)) == MODE_VECTOR_FLOAT) | |
675 || (equiv_const != NULL_RTX | |
676 && (GET_CODE (equiv_const) == CONST_DOUBLE | |
677 || (GET_CODE (equiv_const) == CONST_VECTOR | |
678 && (GET_MODE_CLASS (GET_MODE (equiv_const)) | |
679 == MODE_VECTOR_FLOAT))))) | |
680 return NO_REGS; | |
681 break; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
682 |
0 | 683 case 'G': |
684 case 'H': | |
685 if ((GET_CODE (op) == CONST_DOUBLE | |
686 && CONST_DOUBLE_OK_FOR_CONSTRAINT_P (op, c, constraints)) | |
687 || (equiv_const != NULL_RTX | |
688 && GET_CODE (equiv_const) == CONST_DOUBLE | |
689 && CONST_DOUBLE_OK_FOR_CONSTRAINT_P (equiv_const, | |
690 c, constraints))) | |
691 return NO_REGS; | |
692 /* ??? what about memory */ | |
693 case 'r': | |
694 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': | |
695 case 'h': case 'j': case 'k': case 'l': | |
696 case 'q': case 't': case 'u': | |
697 case 'v': case 'w': case 'x': case 'y': case 'z': | |
698 case 'A': case 'B': case 'C': case 'D': | |
699 case 'Q': case 'R': case 'S': case 'T': case 'U': | |
700 case 'W': case 'Y': case 'Z': | |
701 next_cl = (c == 'r' | |
702 ? GENERAL_REGS | |
703 : REG_CLASS_FROM_CONSTRAINT (c, constraints)); | |
704 if ((cl != NO_REGS && next_cl != cl) | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
705 || (ira_available_class_regs[next_cl] |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
706 > ira_reg_class_nregs[next_cl][GET_MODE (op)])) |
0 | 707 return NO_REGS; |
708 cl = next_cl; | |
709 break; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
710 |
0 | 711 case '0': case '1': case '2': case '3': case '4': |
712 case '5': case '6': case '7': case '8': case '9': | |
713 next_cl | |
714 = single_reg_class (recog_data.constraints[c - '0'], | |
715 recog_data.operand[c - '0'], NULL_RTX); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
716 if ((cl != NO_REGS && next_cl != cl) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
717 || next_cl == NO_REGS |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
718 || (ira_available_class_regs[next_cl] |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
719 > ira_reg_class_nregs[next_cl][GET_MODE (op)])) |
0 | 720 return NO_REGS; |
721 cl = next_cl; | |
722 break; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
723 |
0 | 724 default: |
725 return NO_REGS; | |
726 } | |
727 return cl; | |
728 } | |
729 | |
730 /* The function checks that operand OP_NUM of the current insn can use | |
731 only one hard register. If it is so, the function returns the | |
732 class of the hard register. Otherwise it returns NO_REGS. */ | |
733 static enum reg_class | |
734 single_reg_operand_class (int op_num) | |
735 { | |
736 if (op_num < 0 || recog_data.n_alternatives == 0) | |
737 return NO_REGS; | |
738 return single_reg_class (recog_data.constraints[op_num], | |
739 recog_data.operand[op_num], NULL_RTX); | |
740 } | |
741 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
742 /* The function sets up hard register set *SET to hard registers which |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
743 might be used by insn reloads because the constraints are too |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
744 strict. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
745 void |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
746 ira_implicitly_set_insn_hard_regs (HARD_REG_SET *set) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
747 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
748 int i, c, regno = 0; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
749 bool ignore_p; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
750 enum reg_class cl; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
751 rtx op; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
752 enum machine_mode mode; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
753 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
754 CLEAR_HARD_REG_SET (*set); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
755 for (i = 0; i < recog_data.n_operands; i++) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
756 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
757 op = recog_data.operand[i]; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
758 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
759 if (GET_CODE (op) == SUBREG) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
760 op = SUBREG_REG (op); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
761 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
762 if (GET_CODE (op) == SCRATCH |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
763 || (REG_P (op) && (regno = REGNO (op)) >= FIRST_PSEUDO_REGISTER)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
764 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
765 const char *p = recog_data.constraints[i]; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
766 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
767 mode = (GET_CODE (op) == SCRATCH |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
768 ? GET_MODE (op) : PSEUDO_REGNO_MODE (regno)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
769 cl = NO_REGS; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
770 for (ignore_p = false; (c = *p); p += CONSTRAINT_LEN (c, p)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
771 if (c == '#') |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
772 ignore_p = true; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
773 else if (c == ',') |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
774 ignore_p = false; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
775 else if (! ignore_p) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
776 switch (c) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
777 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
778 case 'r': |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
779 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
780 case 'h': case 'j': case 'k': case 'l': |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
781 case 'q': case 't': case 'u': |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
782 case 'v': case 'w': case 'x': case 'y': case 'z': |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
783 case 'A': case 'B': case 'C': case 'D': |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
784 case 'Q': case 'R': case 'S': case 'T': case 'U': |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
785 case 'W': case 'Y': case 'Z': |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
786 cl = (c == 'r' |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
787 ? GENERAL_REGS |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
788 : REG_CLASS_FROM_CONSTRAINT (c, p)); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
789 if (cl != NO_REGS |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
790 && (ira_available_class_regs[cl] |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
791 <= ira_reg_class_nregs[cl][mode])) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
792 IOR_HARD_REG_SET (*set, reg_class_contents[cl]); |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
793 break; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
794 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
795 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
796 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
797 } |
0 | 798 /* Processes input operands, if IN_P, or output operands otherwise of |
799 the current insn with FREQ to find allocno which can use only one | |
800 hard register and makes other currently living allocnos conflicting | |
801 with the hard register. */ | |
802 static void | |
803 process_single_reg_class_operands (bool in_p, int freq) | |
804 { | |
805 int i, regno, cost; | |
806 unsigned int px; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
807 enum reg_class cl; |
0 | 808 rtx operand; |
809 ira_allocno_t operand_a, a; | |
810 | |
811 for (i = 0; i < recog_data.n_operands; i++) | |
812 { | |
813 operand = recog_data.operand[i]; | |
814 if (in_p && recog_data.operand_type[i] != OP_IN | |
815 && recog_data.operand_type[i] != OP_INOUT) | |
816 continue; | |
817 if (! in_p && recog_data.operand_type[i] != OP_OUT | |
818 && recog_data.operand_type[i] != OP_INOUT) | |
819 continue; | |
820 cl = single_reg_operand_class (i); | |
821 if (cl == NO_REGS) | |
822 continue; | |
823 | |
824 operand_a = NULL; | |
825 | |
826 if (GET_CODE (operand) == SUBREG) | |
827 operand = SUBREG_REG (operand); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
828 |
0 | 829 if (REG_P (operand) |
830 && (regno = REGNO (operand)) >= FIRST_PSEUDO_REGISTER) | |
831 { | |
832 enum machine_mode mode; | |
833 enum reg_class cover_class; | |
834 | |
835 operand_a = ira_curr_regno_allocno_map[regno]; | |
836 mode = ALLOCNO_MODE (operand_a); | |
837 cover_class = ALLOCNO_COVER_CLASS (operand_a); | |
838 if (ira_class_subset_p[cl][cover_class] | |
839 && ira_class_hard_regs_num[cl] != 0 | |
840 && (ira_class_hard_reg_index[cover_class] | |
841 [ira_class_hard_regs[cl][0]]) >= 0 | |
842 && reg_class_size[cl] <= (unsigned) CLASS_MAX_NREGS (cl, mode)) | |
843 { | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
844 int i, size; |
19
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
845 cost |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
846 = (freq |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
847 * (in_p |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
848 ? ira_get_register_move_cost (mode, cover_class, cl) |
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
849 : ira_get_register_move_cost (mode, cl, cover_class))); |
0 | 850 ira_allocate_and_set_costs |
851 (&ALLOCNO_CONFLICT_HARD_REG_COSTS (operand_a), cover_class, 0); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
852 size = ira_reg_class_nregs[cover_class][mode]; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
853 for (i = 0; i < size; i++) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
854 ALLOCNO_CONFLICT_HARD_REG_COSTS (operand_a) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
855 [ira_class_hard_reg_index |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
856 [cover_class][ira_class_hard_regs[cl][i]]] |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
857 -= cost; |
0 | 858 } |
859 } | |
860 | |
861 EXECUTE_IF_SET_IN_SPARSESET (allocnos_live, px) | |
862 { | |
863 a = ira_allocnos[px]; | |
864 if (a != operand_a) | |
865 { | |
866 /* We could increase costs of A instead of making it | |
867 conflicting with the hard register. But it works worse | |
868 because it will be spilled in reload in anyway. */ | |
869 IOR_HARD_REG_SET (ALLOCNO_CONFLICT_HARD_REGS (a), | |
870 reg_class_contents[cl]); | |
871 IOR_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a), | |
872 reg_class_contents[cl]); | |
873 } | |
874 } | |
875 } | |
876 } | |
877 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
878 /* Return true when one of the predecessor edges of BB is marked with |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
879 EDGE_ABNORMAL_CALL or EDGE_EH. */ |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
880 static bool |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
881 bb_has_abnormal_call_pred (basic_block bb) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
882 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
883 edge e; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
884 edge_iterator ei; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
885 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
886 FOR_EACH_EDGE (e, ei, bb->preds) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
887 { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
888 if (e->flags & (EDGE_ABNORMAL_CALL | EDGE_EH)) |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
889 return true; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
890 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
891 return false; |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
892 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
893 |
0 | 894 /* Process insns of the basic block given by its LOOP_TREE_NODE to |
895 update allocno live ranges, allocno hard register conflicts, | |
896 intersected calls, and register pressure info for allocnos for the | |
897 basic block for and regions containing the basic block. */ | |
898 static void | |
899 process_bb_node_lives (ira_loop_tree_node_t loop_tree_node) | |
900 { | |
901 int i, freq; | |
902 unsigned int j; | |
903 basic_block bb; | |
904 rtx insn; | |
905 bitmap_iterator bi; | |
906 bitmap reg_live_out; | |
907 unsigned int px; | |
908 bool set_p; | |
909 | |
910 bb = loop_tree_node->bb; | |
911 if (bb != NULL) | |
912 { | |
913 for (i = 0; i < ira_reg_class_cover_size; i++) | |
914 { | |
915 curr_reg_pressure[ira_reg_class_cover[i]] = 0; | |
916 high_pressure_start_point[ira_reg_class_cover[i]] = -1; | |
917 } | |
918 curr_bb_node = loop_tree_node; | |
919 reg_live_out = DF_LR_OUT (bb); | |
920 sparseset_clear (allocnos_live); | |
921 REG_SET_TO_HARD_REG_SET (hard_regs_live, reg_live_out); | |
922 AND_COMPL_HARD_REG_SET (hard_regs_live, eliminable_regset); | |
923 AND_COMPL_HARD_REG_SET (hard_regs_live, ira_no_alloc_regs); | |
924 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) | |
925 if (TEST_HARD_REG_BIT (hard_regs_live, i)) | |
926 { | |
927 enum reg_class cover_class, cl; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
928 |
0 | 929 cover_class = ira_class_translate[REGNO_REG_CLASS (i)]; |
930 for (j = 0; | |
931 (cl = ira_reg_class_super_classes[cover_class][j]) | |
932 != LIM_REG_CLASSES; | |
933 j++) | |
934 { | |
935 curr_reg_pressure[cl]++; | |
936 if (curr_bb_node->reg_pressure[cl] < curr_reg_pressure[cl]) | |
937 curr_bb_node->reg_pressure[cl] = curr_reg_pressure[cl]; | |
938 ira_assert (curr_reg_pressure[cl] | |
939 <= ira_available_class_regs[cl]); | |
940 } | |
941 } | |
942 EXECUTE_IF_SET_IN_BITMAP (reg_live_out, FIRST_PSEUDO_REGISTER, j, bi) | |
943 { | |
944 ira_allocno_t a = ira_curr_regno_allocno_map[j]; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
945 |
0 | 946 if (a == NULL) |
947 continue; | |
948 ira_assert (! sparseset_bit_p (allocnos_live, ALLOCNO_NUM (a))); | |
949 set_allocno_live (a); | |
950 make_regno_born (j); | |
951 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
952 |
0 | 953 freq = REG_FREQ_FROM_BB (bb); |
954 if (freq == 0) | |
955 freq = 1; | |
956 | |
957 /* Invalidate all allocno_saved_at_call entries. */ | |
958 last_call_num++; | |
959 | |
960 /* Scan the code of this basic block, noting which allocnos and | |
961 hard regs are born or die. | |
962 | |
963 Note that this loop treats uninitialized values as live until | |
964 the beginning of the block. For example, if an instruction | |
965 uses (reg:DI foo), and only (subreg:SI (reg:DI foo) 0) is ever | |
966 set, FOO will remain live until the beginning of the block. | |
967 Likewise if FOO is not set at all. This is unnecessarily | |
968 pessimistic, but it probably doesn't matter much in practice. */ | |
969 FOR_BB_INSNS_REVERSE (bb, insn) | |
970 { | |
971 df_ref *def_rec, *use_rec; | |
972 bool call_p; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
973 |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
974 if (!NONDEBUG_INSN_P (insn)) |
0 | 975 continue; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
976 |
0 | 977 if (internal_flag_ira_verbose > 2 && ira_dump_file != NULL) |
978 fprintf (ira_dump_file, " Insn %u(l%d): point = %d\n", | |
979 INSN_UID (insn), loop_tree_node->parent->loop->num, | |
980 curr_point); | |
981 | |
982 /* Mark each defined value as live. We need to do this for | |
983 unused values because they still conflict with quantities | |
984 that are live at the time of the definition. | |
985 | |
986 Ignore DF_REF_MAY_CLOBBERs on a call instruction. Such | |
987 references represent the effect of the called function | |
988 on a call-clobbered register. Marking the register as | |
989 live would stop us from allocating it to a call-crossing | |
990 allocno. */ | |
991 call_p = CALL_P (insn); | |
992 for (def_rec = DF_INSN_DEFS (insn); *def_rec; def_rec++) | |
993 if (!call_p || !DF_REF_FLAGS_IS_SET (*def_rec, DF_REF_MAY_CLOBBER)) | |
994 mark_ref_live (*def_rec); | |
995 | |
996 /* If INSN has multiple outputs, then any value used in one | |
997 of the outputs conflicts with the other outputs. Model this | |
998 by making the used value live during the output phase. | |
999 | |
1000 It is unsafe to use !single_set here since it will ignore | |
1001 an unused output. Just because an output is unused does | |
1002 not mean the compiler can assume the side effect will not | |
1003 occur. Consider if ALLOCNO appears in the address of an | |
1004 output and we reload the output. If we allocate ALLOCNO | |
1005 to the same hard register as an unused output we could | |
1006 set the hard register before the output reload insn. */ | |
1007 if (GET_CODE (PATTERN (insn)) == PARALLEL && multiple_sets (insn)) | |
1008 for (use_rec = DF_INSN_USES (insn); *use_rec; use_rec++) | |
1009 { | |
1010 int i; | |
1011 rtx reg; | |
1012 | |
1013 reg = DF_REF_REG (*use_rec); | |
1014 for (i = XVECLEN (PATTERN (insn), 0) - 1; i >= 0; i--) | |
1015 { | |
1016 rtx set; | |
1017 | |
1018 set = XVECEXP (PATTERN (insn), 0, i); | |
1019 if (GET_CODE (set) == SET | |
1020 && reg_overlap_mentioned_p (reg, SET_DEST (set))) | |
1021 { | |
1022 /* After the previous loop, this is a no-op if | |
1023 REG is contained within SET_DEST (SET). */ | |
1024 mark_ref_live (*use_rec); | |
1025 break; | |
1026 } | |
1027 } | |
1028 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
1029 |
0 | 1030 extract_insn (insn); |
1031 preprocess_constraints (); | |
1032 process_single_reg_class_operands (false, freq); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
1033 |
0 | 1034 /* See which defined values die here. */ |
1035 for (def_rec = DF_INSN_DEFS (insn); *def_rec; def_rec++) | |
1036 if (!call_p || !DF_REF_FLAGS_IS_SET (*def_rec, DF_REF_MAY_CLOBBER)) | |
1037 mark_ref_dead (*def_rec); | |
1038 | |
1039 if (call_p) | |
1040 { | |
1041 last_call_num++; | |
1042 /* The current set of live allocnos are live across the call. */ | |
1043 EXECUTE_IF_SET_IN_SPARSESET (allocnos_live, i) | |
1044 { | |
1045 ira_allocno_t a = ira_allocnos[i]; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
1046 |
0 | 1047 if (allocno_saved_at_call[i] != last_call_num) |
1048 /* Here we are mimicking caller-save.c behaviour | |
1049 which does not save hard register at a call if | |
1050 it was saved on previous call in the same basic | |
1051 block and the hard register was not mentioned | |
1052 between the two calls. */ | |
1053 ALLOCNO_CALL_FREQ (a) += freq; | |
1054 /* Mark it as saved at the next call. */ | |
1055 allocno_saved_at_call[i] = last_call_num + 1; | |
1056 ALLOCNO_CALLS_CROSSED_NUM (a)++; | |
1057 /* Don't allocate allocnos that cross setjmps or any | |
1058 call, if this function receives a nonlocal | |
1059 goto. */ | |
1060 if (cfun->has_nonlocal_label | |
1061 || find_reg_note (insn, REG_SETJMP, | |
1062 NULL_RTX) != NULL_RTX) | |
1063 { | |
1064 SET_HARD_REG_SET (ALLOCNO_CONFLICT_HARD_REGS (a)); | |
1065 SET_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a)); | |
1066 } | |
1067 if (can_throw_internal (insn)) | |
1068 { | |
1069 IOR_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a), | |
1070 call_used_reg_set); | |
1071 IOR_HARD_REG_SET (ALLOCNO_CONFLICT_HARD_REGS (a), | |
1072 call_used_reg_set); | |
1073 } | |
1074 } | |
1075 } | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
1076 |
0 | 1077 make_early_clobber_and_input_conflicts (); |
1078 | |
1079 curr_point++; | |
1080 | |
1081 /* Mark each used value as live. */ | |
1082 for (use_rec = DF_INSN_USES (insn); *use_rec; use_rec++) | |
1083 mark_ref_live (*use_rec); | |
1084 | |
1085 process_single_reg_class_operands (true, freq); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
1086 |
0 | 1087 set_p = mark_hard_reg_early_clobbers (insn, true); |
1088 | |
1089 if (set_p) | |
1090 { | |
1091 mark_hard_reg_early_clobbers (insn, false); | |
1092 | |
1093 /* Mark each hard reg as live again. For example, a | |
1094 hard register can be in clobber and in an insn | |
1095 input. */ | |
1096 for (use_rec = DF_INSN_USES (insn); *use_rec; use_rec++) | |
1097 { | |
1098 rtx ureg = DF_REF_REG (*use_rec); | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
1099 |
0 | 1100 if (GET_CODE (ureg) == SUBREG) |
1101 ureg = SUBREG_REG (ureg); | |
1102 if (! REG_P (ureg) || REGNO (ureg) >= FIRST_PSEUDO_REGISTER) | |
1103 continue; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
1104 |
0 | 1105 mark_ref_live (*use_rec); |
1106 } | |
1107 } | |
1108 | |
1109 curr_point++; | |
1110 } | |
1111 | |
1112 #ifdef EH_RETURN_DATA_REGNO | |
1113 if (bb_has_eh_pred (bb)) | |
1114 for (j = 0; ; ++j) | |
1115 { | |
1116 unsigned int regno = EH_RETURN_DATA_REGNO (j); | |
1117 if (regno == INVALID_REGNUM) | |
1118 break; | |
1119 make_regno_born (regno); | |
1120 } | |
1121 #endif | |
1122 | |
1123 /* Allocnos can't go in stack regs at the start of a basic block | |
1124 that is reached by an abnormal edge. Likewise for call | |
1125 clobbered regs, because caller-save, fixup_abnormal_edges and | |
1126 possibly the table driven EH machinery are not quite ready to | |
1127 handle such allocnos live across such edges. */ | |
1128 if (bb_has_abnormal_pred (bb)) | |
1129 { | |
1130 #ifdef STACK_REGS | |
1131 EXECUTE_IF_SET_IN_SPARSESET (allocnos_live, px) | |
1132 { | |
1133 ALLOCNO_NO_STACK_REG_P (ira_allocnos[px]) = true; | |
1134 ALLOCNO_TOTAL_NO_STACK_REG_P (ira_allocnos[px]) = true; | |
1135 } | |
1136 for (px = FIRST_STACK_REG; px <= LAST_STACK_REG; px++) | |
1137 make_regno_born (px); | |
1138 #endif | |
1139 /* No need to record conflicts for call clobbered regs if we | |
1140 have nonlocal labels around, as we don't ever try to | |
1141 allocate such regs in this case. */ | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
1142 if (!cfun->has_nonlocal_label && bb_has_abnormal_call_pred (bb)) |
0 | 1143 for (px = 0; px < FIRST_PSEUDO_REGISTER; px++) |
1144 if (call_used_regs[px]) | |
1145 make_regno_born (px); | |
1146 } | |
1147 | |
1148 EXECUTE_IF_SET_IN_SPARSESET (allocnos_live, i) | |
1149 { | |
1150 make_regno_dead (ALLOCNO_REGNO (ira_allocnos[i])); | |
1151 } | |
1152 | |
1153 curr_point++; | |
1154 | |
1155 } | |
1156 /* Propagate register pressure to upper loop tree nodes: */ | |
1157 if (loop_tree_node != ira_loop_tree_root) | |
1158 for (i = 0; i < ira_reg_class_cover_size; i++) | |
1159 { | |
1160 enum reg_class cover_class; | |
1161 | |
1162 cover_class = ira_reg_class_cover[i]; | |
1163 if (loop_tree_node->reg_pressure[cover_class] | |
1164 > loop_tree_node->parent->reg_pressure[cover_class]) | |
1165 loop_tree_node->parent->reg_pressure[cover_class] | |
1166 = loop_tree_node->reg_pressure[cover_class]; | |
1167 } | |
1168 } | |
1169 | |
1170 /* Create and set up IRA_START_POINT_RANGES and | |
1171 IRA_FINISH_POINT_RANGES. */ | |
1172 static void | |
1173 create_start_finish_chains (void) | |
1174 { | |
1175 ira_allocno_t a; | |
1176 ira_allocno_iterator ai; | |
1177 allocno_live_range_t r; | |
1178 | |
1179 ira_start_point_ranges | |
1180 = (allocno_live_range_t *) ira_allocate (ira_max_point | |
1181 * sizeof (allocno_live_range_t)); | |
1182 memset (ira_start_point_ranges, 0, | |
1183 ira_max_point * sizeof (allocno_live_range_t)); | |
1184 ira_finish_point_ranges | |
1185 = (allocno_live_range_t *) ira_allocate (ira_max_point | |
1186 * sizeof (allocno_live_range_t)); | |
1187 memset (ira_finish_point_ranges, 0, | |
1188 ira_max_point * sizeof (allocno_live_range_t)); | |
1189 FOR_EACH_ALLOCNO (a, ai) | |
1190 { | |
1191 for (r = ALLOCNO_LIVE_RANGES (a); r != NULL; r = r->next) | |
1192 { | |
1193 r->start_next = ira_start_point_ranges[r->start]; | |
1194 ira_start_point_ranges[r->start] = r; | |
1195 r->finish_next = ira_finish_point_ranges[r->finish]; | |
1196 ira_finish_point_ranges[r->finish] = r; | |
1197 } | |
1198 } | |
1199 } | |
1200 | |
1201 /* Rebuild IRA_START_POINT_RANGES and IRA_FINISH_POINT_RANGES after | |
1202 new live ranges and program points were added as a result if new | |
1203 insn generation. */ | |
1204 void | |
1205 ira_rebuild_start_finish_chains (void) | |
1206 { | |
1207 ira_free (ira_finish_point_ranges); | |
1208 ira_free (ira_start_point_ranges); | |
1209 create_start_finish_chains (); | |
1210 } | |
1211 | |
1212 /* Compress allocno live ranges by removing program points where | |
1213 nothing happens. */ | |
1214 static void | |
1215 remove_some_program_points_and_update_live_ranges (void) | |
1216 { | |
1217 unsigned i; | |
1218 int n; | |
1219 int *map; | |
1220 ira_allocno_t a; | |
1221 ira_allocno_iterator ai; | |
1222 allocno_live_range_t r; | |
1223 bitmap born_or_died; | |
1224 bitmap_iterator bi; | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
36
diff
changeset
|
1225 |
0 | 1226 born_or_died = ira_allocate_bitmap (); |
1227 FOR_EACH_ALLOCNO (a, ai) | |
1228 { | |
1229 for (r = ALLOCNO_LIVE_RANGES (a); r != NULL; r = r->next) | |
1230 { | |
1231 ira_assert (r->start <= r->finish); | |
1232 bitmap_set_bit (born_or_died, r->start); | |
1233 bitmap_set_bit (born_or_died, r->finish); | |
1234 } | |
1235 } | |
1236 map = (int *) ira_allocate (sizeof (int) * ira_max_point); | |
1237 n = 0; | |
1238 EXECUTE_IF_SET_IN_BITMAP(born_or_died, 0, i, bi) | |
1239 { | |
1240 map[i] = n++; | |
1241 } | |
1242 ira_free_bitmap (born_or_died); | |
1243 if (internal_flag_ira_verbose > 1 && ira_dump_file != NULL) | |
1244 fprintf (ira_dump_file, "Compressing live ranges: from %d to %d - %d%%\n", | |
1245 ira_max_point, n, 100 * n / ira_max_point); | |
1246 ira_max_point = n; | |
1247 FOR_EACH_ALLOCNO (a, ai) | |
1248 { | |
1249 for (r = ALLOCNO_LIVE_RANGES (a); r != NULL; r = r->next) | |
1250 { | |
1251 r->start = map[r->start]; | |
1252 r->finish = map[r->finish]; | |
1253 } | |
1254 } | |
1255 ira_free (map); | |
1256 } | |
1257 | |
1258 /* Print live ranges R to file F. */ | |
1259 void | |
1260 ira_print_live_range_list (FILE *f, allocno_live_range_t r) | |
1261 { | |
1262 for (; r != NULL; r = r->next) | |
1263 fprintf (f, " [%d..%d]", r->start, r->finish); | |
1264 fprintf (f, "\n"); | |
1265 } | |
1266 | |
1267 /* Print live ranges R to stderr. */ | |
1268 void | |
1269 ira_debug_live_range_list (allocno_live_range_t r) | |
1270 { | |
1271 ira_print_live_range_list (stderr, r); | |
1272 } | |
1273 | |
1274 /* Print live ranges of allocno A to file F. */ | |
1275 static void | |
1276 print_allocno_live_ranges (FILE *f, ira_allocno_t a) | |
1277 { | |
1278 fprintf (f, " a%d(r%d):", ALLOCNO_NUM (a), ALLOCNO_REGNO (a)); | |
1279 ira_print_live_range_list (f, ALLOCNO_LIVE_RANGES (a)); | |
1280 } | |
1281 | |
1282 /* Print live ranges of allocno A to stderr. */ | |
1283 void | |
1284 ira_debug_allocno_live_ranges (ira_allocno_t a) | |
1285 { | |
1286 print_allocno_live_ranges (stderr, a); | |
1287 } | |
1288 | |
1289 /* Print live ranges of all allocnos to file F. */ | |
1290 static void | |
1291 print_live_ranges (FILE *f) | |
1292 { | |
1293 ira_allocno_t a; | |
1294 ira_allocno_iterator ai; | |
1295 | |
1296 FOR_EACH_ALLOCNO (a, ai) | |
1297 print_allocno_live_ranges (f, a); | |
1298 } | |
1299 | |
1300 /* Print live ranges of all allocnos to stderr. */ | |
1301 void | |
1302 ira_debug_live_ranges (void) | |
1303 { | |
1304 print_live_ranges (stderr); | |
1305 } | |
1306 | |
1307 /* The main entry function creates live ranges, set up | |
1308 CONFLICT_HARD_REGS and TOTAL_CONFLICT_HARD_REGS for allocnos, and | |
1309 calculate register pressure info. */ | |
1310 void | |
1311 ira_create_allocno_live_ranges (void) | |
1312 { | |
1313 allocnos_live = sparseset_alloc (ira_allocnos_num); | |
1314 curr_point = 0; | |
1315 last_call_num = 0; | |
1316 allocno_saved_at_call | |
1317 = (int *) ira_allocate (ira_allocnos_num * sizeof (int)); | |
1318 memset (allocno_saved_at_call, 0, ira_allocnos_num * sizeof (int)); | |
1319 ira_traverse_loop_tree (true, ira_loop_tree_root, NULL, | |
1320 process_bb_node_lives); | |
1321 ira_max_point = curr_point; | |
1322 create_start_finish_chains (); | |
1323 if (internal_flag_ira_verbose > 2 && ira_dump_file != NULL) | |
1324 print_live_ranges (ira_dump_file); | |
1325 /* Clean up. */ | |
1326 ira_free (allocno_saved_at_call); | |
1327 sparseset_free (allocnos_live); | |
1328 } | |
1329 | |
1330 /* Compress allocno live ranges. */ | |
1331 void | |
1332 ira_compress_allocno_live_ranges (void) | |
1333 { | |
1334 remove_some_program_points_and_update_live_ranges (); | |
1335 ira_rebuild_start_finish_chains (); | |
1336 if (internal_flag_ira_verbose > 2 && ira_dump_file != NULL) | |
1337 { | |
1338 fprintf (ira_dump_file, "Ranges after the compression:\n"); | |
1339 print_live_ranges (ira_dump_file); | |
1340 } | |
1341 } | |
1342 | |
1343 /* Free arrays IRA_START_POINT_RANGES and IRA_FINISH_POINT_RANGES. */ | |
1344 void | |
1345 ira_finish_allocno_live_ranges (void) | |
1346 { | |
1347 ira_free (ira_finish_point_ranges); | |
1348 ira_free (ira_start_point_ranges); | |
1349 } |