comparison gcc/df-problems.c @ 55:77e2b8dfacca gcc-4.4.5

update it from 4.4.3 to 4.5.0
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Fri, 12 Feb 2010 23:39:51 +0900
parents a06113de4d67
children b7f97abdc517
comparison
equal deleted inserted replaced
52:c156f1bd5cd9 55:77e2b8dfacca
1 /* Standard problems for dataflow support routines. 1 /* Standard problems for dataflow support routines.
2 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
3 2008, 2009 Free Software Foundation, Inc. 3 2008, 2009 Free Software Foundation, Inc.
4 Originally contributed by Michael P. Hayes 4 Originally contributed by Michael P. Hayes
5 (m.hayes@elec.canterbury.ac.nz, mhayes@redhat.com) 5 (m.hayes@elec.canterbury.ac.nz, mhayes@redhat.com)
6 Major rewrite contributed by Danny Berlin (dberlin@dberlin.org) 6 Major rewrite contributed by Danny Berlin (dberlin@dberlin.org)
7 and Kenneth Zadeck (zadeck@naturalbridge.com). 7 and Kenneth Zadeck (zadeck@naturalbridge.com).
8 8
9 This file is part of GCC. 9 This file is part of GCC.
45 #include "dce.h" 45 #include "dce.h"
46 #include "vecprim.h" 46 #include "vecprim.h"
47 47
48 /* Note that turning REG_DEAD_DEBUGGING on will cause 48 /* Note that turning REG_DEAD_DEBUGGING on will cause
49 gcc.c-torture/unsorted/dump-noaddr.c to fail because it prints 49 gcc.c-torture/unsorted/dump-noaddr.c to fail because it prints
50 addresses in the dumps. */ 50 addresses in the dumps. */
51 #if 0 51 #if 0
52 #define REG_DEAD_DEBUGGING 52 #define REG_DEAD_DEBUGGING
53 #endif 53 #endif
54 54
55 #define DF_SPARSE_THRESHOLD 32 55 #define DF_SPARSE_THRESHOLD 32
71 { 71 {
72 gcc_assert (df_lr); 72 gcc_assert (df_lr);
73 73
74 if (df_live) 74 if (df_live)
75 return DF_LIVE_OUT (bb); 75 return DF_LIVE_OUT (bb);
76 else 76 else
77 return DF_LR_OUT (bb); 77 return DF_LR_OUT (bb);
78 } 78 }
79 79
80 /* Get the live at in set for BB no matter what problem happens to be 80 /* Get the live at in set for BB no matter what problem happens to be
81 defined. This function is used by the register allocators who 81 defined. This function is used by the register allocators who
87 { 87 {
88 gcc_assert (df_lr); 88 gcc_assert (df_lr);
89 89
90 if (df_live) 90 if (df_live)
91 return DF_LIVE_IN (bb); 91 return DF_LIVE_IN (bb);
92 else 92 else
93 return DF_LR_IN (bb); 93 return DF_LR_IN (bb);
94 } 94 }
95 95
96 /*---------------------------------------------------------------------------- 96 /*----------------------------------------------------------------------------
97 Utility functions. 97 Utility functions.
134 } 134 }
135 135
136 136
137 /* Print some basic block info as part of df_dump. */ 137 /* Print some basic block info as part of df_dump. */
138 138
139 void 139 void
140 df_print_bb_index (basic_block bb, FILE *file) 140 df_print_bb_index (basic_block bb, FILE *file)
141 { 141 {
142 edge e; 142 edge e;
143 edge_iterator ei; 143 edge_iterator ei;
144 144
145 fprintf (file, "\n( "); 145 fprintf (file, "\n( ");
146 FOR_EACH_EDGE (e, ei, bb->preds) 146 FOR_EACH_EDGE (e, ei, bb->preds)
147 { 147 {
148 basic_block pred = e->src; 148 basic_block pred = e->src;
149 fprintf (file, "%d%s ", pred->index, e->flags & EDGE_EH ? "(EH)" : ""); 149 fprintf (file, "%d%s ", pred->index, e->flags & EDGE_EH ? "(EH)" : "");
150 } 150 }
151 fprintf (file, ")->[%d]->( ", bb->index); 151 fprintf (file, ")->[%d]->( ", bb->index);
152 FOR_EACH_EDGE (e, ei, bb->succs) 152 FOR_EACH_EDGE (e, ei, bb->succs)
153 { 153 {
154 basic_block succ = e->dest; 154 basic_block succ = e->dest;
155 fprintf (file, "%d%s ", succ->index, e->flags & EDGE_EH ? "(EH)" : ""); 155 fprintf (file, "%d%s ", succ->index, e->flags & EDGE_EH ? "(EH)" : "");
156 } 156 }
157 fprintf (file, ")\n"); 157 fprintf (file, ")\n");
158 } 158 }
159
160
161
162 /* Make sure that the seen_in_insn and seen_in_block sbitmaps are set
163 up correctly. */
164
165 static void
166 df_set_seen (void)
167 {
168 seen_in_block = BITMAP_ALLOC (&df_bitmap_obstack);
169 seen_in_insn = BITMAP_ALLOC (&df_bitmap_obstack);
170 }
171
172
173 static void
174 df_unset_seen (void)
175 {
176 BITMAP_FREE (seen_in_block);
177 BITMAP_FREE (seen_in_insn);
178 }
179
180 159
181 160
182 /*---------------------------------------------------------------------------- 161 /*----------------------------------------------------------------------------
183 REACHING DEFINITIONS 162 REACHING DEFINITIONS
184 163
187 block. The id field in the ref is used to index into these sets. 166 block. The id field in the ref is used to index into these sets.
188 See df.h for details. 167 See df.h for details.
189 ----------------------------------------------------------------------------*/ 168 ----------------------------------------------------------------------------*/
190 169
191 /* This problem plays a large number of games for the sake of 170 /* This problem plays a large number of games for the sake of
192 efficiency. 171 efficiency.
193 172
194 1) The order of the bits in the bitvectors. After the scanning 173 1) The order of the bits in the bitvectors. After the scanning
195 phase, all of the defs are sorted. All of the defs for the reg 0 174 phase, all of the defs are sorted. All of the defs for the reg 0
196 are first, followed by all defs for reg 1 and so on. 175 are first, followed by all defs for reg 1 and so on.
197 176
198 2) There are two kill sets, one if the number of defs is less or 177 2) There are two kill sets, one if the number of defs is less or
199 equal to DF_SPARSE_THRESHOLD and another if the number of defs is 178 equal to DF_SPARSE_THRESHOLD and another if the number of defs is
200 greater. 179 greater.
201 180
202 <= : Data is built directly in the kill set. 181 <= : Data is built directly in the kill set.
214 /* Private data used to compute the solution for this problem. These 193 /* Private data used to compute the solution for this problem. These
215 data structures are not accessible outside of this module. */ 194 data structures are not accessible outside of this module. */
216 struct df_rd_problem_data 195 struct df_rd_problem_data
217 { 196 {
218 /* The set of defs to regs invalidated by call. */ 197 /* The set of defs to regs invalidated by call. */
219 bitmap sparse_invalidated_by_call; 198 bitmap sparse_invalidated_by_call;
220 /* The set of defs to regs invalidate by call for rd. */ 199 /* The set of defs to regs invalidate by call for rd. */
221 bitmap dense_invalidated_by_call; 200 bitmap dense_invalidated_by_call;
222 /* An obstack for the bitmaps we need for this problem. */ 201 /* An obstack for the bitmaps we need for this problem. */
223 bitmap_obstack rd_bitmaps; 202 bitmap_obstack rd_bitmaps;
224 }; 203 };
225 204
226 /* Set basic block info. */ 205 /* Set basic block info. */
227 206
228 static void 207 static void
229 df_rd_set_bb_info (unsigned int index, 208 df_rd_set_bb_info (unsigned int index,
230 struct df_rd_bb_info *bb_info) 209 struct df_rd_bb_info *bb_info)
231 { 210 {
232 gcc_assert (df_rd); 211 gcc_assert (df_rd);
233 gcc_assert (index < df_rd->block_info_size); 212 gcc_assert (index < df_rd->block_info_size);
234 df_rd->block_info[index] = bb_info; 213 df_rd->block_info[index] = bb_info;
236 215
237 216
238 /* Free basic block info. */ 217 /* Free basic block info. */
239 218
240 static void 219 static void
241 df_rd_free_bb_info (basic_block bb ATTRIBUTE_UNUSED, 220 df_rd_free_bb_info (basic_block bb ATTRIBUTE_UNUSED,
242 void *vbb_info) 221 void *vbb_info)
243 { 222 {
244 struct df_rd_bb_info *bb_info = (struct df_rd_bb_info *) vbb_info; 223 struct df_rd_bb_info *bb_info = (struct df_rd_bb_info *) vbb_info;
245 if (bb_info) 224 if (bb_info)
246 { 225 {
255 234
256 235
257 /* Allocate or reset bitmaps for DF_RD blocks. The solution bits are 236 /* Allocate or reset bitmaps for DF_RD blocks. The solution bits are
258 not touched unless the block is new. */ 237 not touched unless the block is new. */
259 238
260 static void 239 static void
261 df_rd_alloc (bitmap all_blocks) 240 df_rd_alloc (bitmap all_blocks)
262 { 241 {
263 unsigned int bb_index; 242 unsigned int bb_index;
264 bitmap_iterator bi; 243 bitmap_iterator bi;
265 struct df_rd_problem_data *problem_data; 244 struct df_rd_problem_data *problem_data;
266 245
267 if (!df_rd->block_pool) 246 if (!df_rd->block_pool)
268 df_rd->block_pool = create_alloc_pool ("df_rd_block pool", 247 df_rd->block_pool = create_alloc_pool ("df_rd_block pool",
269 sizeof (struct df_rd_bb_info), 50); 248 sizeof (struct df_rd_bb_info), 50);
270 249
271 if (df_rd->problem_data) 250 if (df_rd->problem_data)
272 { 251 {
273 problem_data = (struct df_rd_problem_data *) df_rd->problem_data; 252 problem_data = (struct df_rd_problem_data *) df_rd->problem_data;
274 bitmap_clear (problem_data->sparse_invalidated_by_call); 253 bitmap_clear (problem_data->sparse_invalidated_by_call);
275 bitmap_clear (problem_data->dense_invalidated_by_call); 254 bitmap_clear (problem_data->dense_invalidated_by_call);
276 } 255 }
277 else 256 else
278 { 257 {
279 problem_data = XNEW (struct df_rd_problem_data); 258 problem_data = XNEW (struct df_rd_problem_data);
280 df_rd->problem_data = problem_data; 259 df_rd->problem_data = problem_data;
281 260
282 bitmap_obstack_initialize (&problem_data->rd_bitmaps); 261 bitmap_obstack_initialize (&problem_data->rd_bitmaps);
294 273
295 EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi) 274 EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
296 { 275 {
297 struct df_rd_bb_info *bb_info = df_rd_get_bb_info (bb_index); 276 struct df_rd_bb_info *bb_info = df_rd_get_bb_info (bb_index);
298 if (bb_info) 277 if (bb_info)
299 { 278 {
300 bitmap_clear (bb_info->kill); 279 bitmap_clear (bb_info->kill);
301 bitmap_clear (bb_info->sparse_kill); 280 bitmap_clear (bb_info->sparse_kill);
302 bitmap_clear (bb_info->gen); 281 bitmap_clear (bb_info->gen);
303 } 282 }
304 else 283 else
305 { 284 {
306 bb_info = (struct df_rd_bb_info *) pool_alloc (df_rd->block_pool); 285 bb_info = (struct df_rd_bb_info *) pool_alloc (df_rd->block_pool);
307 df_rd_set_bb_info (bb_index, bb_info); 286 df_rd_set_bb_info (bb_index, bb_info);
308 bb_info->kill = BITMAP_ALLOC (&problem_data->rd_bitmaps); 287 bb_info->kill = BITMAP_ALLOC (&problem_data->rd_bitmaps);
309 bb_info->sparse_kill = BITMAP_ALLOC (&problem_data->rd_bitmaps); 288 bb_info->sparse_kill = BITMAP_ALLOC (&problem_data->rd_bitmaps);
310 bb_info->gen = BITMAP_ALLOC (&problem_data->rd_bitmaps); 289 bb_info->gen = BITMAP_ALLOC (&problem_data->rd_bitmaps);
314 } 293 }
315 df_rd->optional_p = true; 294 df_rd->optional_p = true;
316 } 295 }
317 296
318 297
319 /* Process a list of DEFs for df_rd_bb_local_compute. */ 298 /* Add the effect of the top artificial defs of BB to the reaching definitions
320 299 bitmap LOCAL_RD. */
321 static void 300
322 df_rd_bb_local_compute_process_def (struct df_rd_bb_info *bb_info, 301 void
302 df_rd_simulate_artificial_defs_at_top (basic_block bb, bitmap local_rd)
303 {
304 int bb_index = bb->index;
305 df_ref *def_rec;
306 for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
307 {
308 df_ref def = *def_rec;
309 if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
310 {
311 unsigned int dregno = DF_REF_REGNO (def);
312 if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
313 bitmap_clear_range (local_rd,
314 DF_DEFS_BEGIN (dregno),
315 DF_DEFS_COUNT (dregno));
316 bitmap_set_bit (local_rd, DF_REF_ID (def));
317 }
318 }
319 }
320
321 /* Add the effect of the defs of INSN to the reaching definitions bitmap
322 LOCAL_RD. */
323
324 void
325 df_rd_simulate_one_insn (basic_block bb ATTRIBUTE_UNUSED, rtx insn,
326 bitmap local_rd)
327 {
328 unsigned uid = INSN_UID (insn);
329 df_ref *def_rec;
330
331 for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
332 {
333 df_ref def = *def_rec;
334 unsigned int dregno = DF_REF_REGNO (def);
335 if ((!(df->changeable_flags & DF_NO_HARD_REGS))
336 || (dregno >= FIRST_PSEUDO_REGISTER))
337 {
338 if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
339 bitmap_clear_range (local_rd,
340 DF_DEFS_BEGIN (dregno),
341 DF_DEFS_COUNT (dregno));
342 if (!(DF_REF_FLAGS (def)
343 & (DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER)))
344 bitmap_set_bit (local_rd, DF_REF_ID (def));
345 }
346 }
347 }
348
349 /* Process a list of DEFs for df_rd_bb_local_compute. This is a bit
350 more complicated than just simulating, because we must produce the
351 gen and kill sets and hence deal with the two possible representations
352 of kill sets. */
353
354 static void
355 df_rd_bb_local_compute_process_def (struct df_rd_bb_info *bb_info,
323 df_ref *def_rec, 356 df_ref *def_rec,
324 enum df_ref_flags top_flag) 357 int top_flag)
325 { 358 {
326 while (*def_rec) 359 while (*def_rec)
327 { 360 {
328 df_ref def = *def_rec; 361 df_ref def = *def_rec;
329 if (top_flag == (DF_REF_FLAGS (def) & DF_REF_AT_TOP)) 362 if (top_flag == (DF_REF_FLAGS (def) & DF_REF_AT_TOP))
330 { 363 {
331 unsigned int regno = DF_REF_REGNO (def); 364 unsigned int regno = DF_REF_REGNO (def);
332 unsigned int begin = DF_DEFS_BEGIN (regno); 365 unsigned int begin = DF_DEFS_BEGIN (regno);
333 unsigned int n_defs = DF_DEFS_COUNT (regno); 366 unsigned int n_defs = DF_DEFS_COUNT (regno);
334 367
335 if ((!(df->changeable_flags & DF_NO_HARD_REGS)) 368 if ((!(df->changeable_flags & DF_NO_HARD_REGS))
336 || (regno >= FIRST_PSEUDO_REGISTER)) 369 || (regno >= FIRST_PSEUDO_REGISTER))
337 { 370 {
338 /* Only the last def(s) for a regno in the block has any 371 /* Only the last def(s) for a regno in the block has any
339 effect. */ 372 effect. */
340 if (!bitmap_bit_p (seen_in_block, regno)) 373 if (!bitmap_bit_p (seen_in_block, regno))
341 { 374 {
342 /* The first def for regno in insn gets to knock out the 375 /* The first def for regno in insn gets to knock out the
343 defs from other instructions. */ 376 defs from other instructions. */
344 if ((!bitmap_bit_p (seen_in_insn, regno)) 377 if ((!bitmap_bit_p (seen_in_insn, regno))
345 /* If the def is to only part of the reg, it does 378 /* If the def is to only part of the reg, it does
346 not kill the other defs that reach here. */ 379 not kill the other defs that reach here. */
347 && (!(DF_REF_FLAGS (def) & 380 && (!(DF_REF_FLAGS (def) &
348 (DF_REF_PARTIAL | DF_REF_CONDITIONAL | DF_REF_MAY_CLOBBER)))) 381 (DF_REF_PARTIAL | DF_REF_CONDITIONAL | DF_REF_MAY_CLOBBER))))
349 { 382 {
350 if (n_defs > DF_SPARSE_THRESHOLD) 383 if (n_defs > DF_SPARSE_THRESHOLD)
351 { 384 {
352 bitmap_set_bit (bb_info->sparse_kill, regno); 385 bitmap_set_bit (bb_info->sparse_kill, regno);
356 { 389 {
357 bitmap_set_range (bb_info->kill, begin, n_defs); 390 bitmap_set_range (bb_info->kill, begin, n_defs);
358 bitmap_clear_range (bb_info->gen, begin, n_defs); 391 bitmap_clear_range (bb_info->gen, begin, n_defs);
359 } 392 }
360 } 393 }
361 394
362 bitmap_set_bit (seen_in_insn, regno); 395 bitmap_set_bit (seen_in_insn, regno);
363 /* All defs for regno in the instruction may be put into 396 /* All defs for regno in the instruction may be put into
364 the gen set. */ 397 the gen set. */
365 if (!(DF_REF_FLAGS (def) 398 if (!(DF_REF_FLAGS (def)
366 & (DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER))) 399 & (DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER)))
367 bitmap_set_bit (bb_info->gen, DF_REF_ID (def)); 400 bitmap_set_bit (bb_info->gen, DF_REF_ID (def));
368 } 401 }
369 } 402 }
370 } 403 }
384 bitmap_clear (seen_in_block); 417 bitmap_clear (seen_in_block);
385 bitmap_clear (seen_in_insn); 418 bitmap_clear (seen_in_insn);
386 419
387 /* Artificials are only hard regs. */ 420 /* Artificials are only hard regs. */
388 if (!(df->changeable_flags & DF_NO_HARD_REGS)) 421 if (!(df->changeable_flags & DF_NO_HARD_REGS))
389 df_rd_bb_local_compute_process_def (bb_info, 422 df_rd_bb_local_compute_process_def (bb_info,
390 df_get_artificial_defs (bb_index), 423 df_get_artificial_defs (bb_index),
391 0); 424 0);
392 425
393 FOR_BB_INSNS_REVERSE (bb, insn) 426 FOR_BB_INSNS_REVERSE (bb, insn)
394 { 427 {
395 unsigned int uid = INSN_UID (insn); 428 unsigned int uid = INSN_UID (insn);
396 429
397 if (!INSN_P (insn)) 430 if (!INSN_P (insn))
398 continue; 431 continue;
399 432
400 df_rd_bb_local_compute_process_def (bb_info, 433 df_rd_bb_local_compute_process_def (bb_info,
401 DF_INSN_UID_DEFS (uid), 0); 434 DF_INSN_UID_DEFS (uid), 0);
402 435
403 /* This complex dance with the two bitmaps is required because 436 /* This complex dance with the two bitmaps is required because
404 instructions can assign twice to the same pseudo. This 437 instructions can assign twice to the same pseudo. This
405 generally happens with calls that will have one def for the 438 generally happens with calls that will have one def for the
412 445
413 /* Process the artificial defs at the top of the block last since we 446 /* Process the artificial defs at the top of the block last since we
414 are going backwards through the block and these are logically at 447 are going backwards through the block and these are logically at
415 the start. */ 448 the start. */
416 if (!(df->changeable_flags & DF_NO_HARD_REGS)) 449 if (!(df->changeable_flags & DF_NO_HARD_REGS))
417 df_rd_bb_local_compute_process_def (bb_info, 450 df_rd_bb_local_compute_process_def (bb_info,
418 df_get_artificial_defs (bb_index), 451 df_get_artificial_defs (bb_index),
419 DF_REF_AT_TOP); 452 DF_REF_AT_TOP);
420 } 453 }
421 454
422 455
431 struct df_rd_problem_data *problem_data 464 struct df_rd_problem_data *problem_data
432 = (struct df_rd_problem_data *) df_rd->problem_data; 465 = (struct df_rd_problem_data *) df_rd->problem_data;
433 bitmap sparse_invalidated = problem_data->sparse_invalidated_by_call; 466 bitmap sparse_invalidated = problem_data->sparse_invalidated_by_call;
434 bitmap dense_invalidated = problem_data->dense_invalidated_by_call; 467 bitmap dense_invalidated = problem_data->dense_invalidated_by_call;
435 468
436 df_set_seen (); 469 seen_in_block = BITMAP_ALLOC (&df_bitmap_obstack);
470 seen_in_insn = BITMAP_ALLOC (&df_bitmap_obstack);
437 471
438 df_maybe_reorganize_def_refs (DF_REF_ORDER_BY_REG); 472 df_maybe_reorganize_def_refs (DF_REF_ORDER_BY_REG);
439 473
440 EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi) 474 EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
441 { 475 {
442 df_rd_bb_local_compute (bb_index); 476 df_rd_bb_local_compute (bb_index);
443 } 477 }
444 478
445 /* Set up the knockout bit vectors to be applied across EH_EDGES. */ 479 /* Set up the knockout bit vectors to be applied across EH_EDGES. */
446 EXECUTE_IF_SET_IN_BITMAP (regs_invalidated_by_call_regset, 0, regno, bi) 480 EXECUTE_IF_SET_IN_BITMAP (regs_invalidated_by_call_regset, 0, regno, bi)
447 { 481 {
448 if (DF_DEFS_COUNT (regno) > DF_SPARSE_THRESHOLD) 482 if (DF_DEFS_COUNT (regno) > DF_SPARSE_THRESHOLD)
449 bitmap_set_bit (sparse_invalidated, regno); 483 bitmap_set_bit (sparse_invalidated, regno);
450 else 484 else
451 bitmap_set_range (dense_invalidated, 485 bitmap_set_range (dense_invalidated,
452 DF_DEFS_BEGIN (regno), 486 DF_DEFS_BEGIN (regno),
453 DF_DEFS_COUNT (regno)); 487 DF_DEFS_COUNT (regno));
454 } 488 }
455 df_unset_seen (); 489
490 BITMAP_FREE (seen_in_block);
491 BITMAP_FREE (seen_in_insn);
456 } 492 }
457 493
458 494
459 /* Initialize the solution bit vectors for problem. */ 495 /* Initialize the solution bit vectors for problem. */
460 496
461 static void 497 static void
462 df_rd_init_solution (bitmap all_blocks) 498 df_rd_init_solution (bitmap all_blocks)
463 { 499 {
464 unsigned int bb_index; 500 unsigned int bb_index;
465 bitmap_iterator bi; 501 bitmap_iterator bi;
466 502
467 EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi) 503 EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
468 { 504 {
469 struct df_rd_bb_info *bb_info = df_rd_get_bb_info (bb_index); 505 struct df_rd_bb_info *bb_info = df_rd_get_bb_info (bb_index);
470 506
471 bitmap_copy (bb_info->out, bb_info->gen); 507 bitmap_copy (bb_info->out, bb_info->gen);
472 bitmap_clear (bb_info->in); 508 bitmap_clear (bb_info->in);
473 } 509 }
474 } 510 }
475 511
479 df_rd_confluence_n (edge e) 515 df_rd_confluence_n (edge e)
480 { 516 {
481 bitmap op1 = df_rd_get_bb_info (e->dest->index)->in; 517 bitmap op1 = df_rd_get_bb_info (e->dest->index)->in;
482 bitmap op2 = df_rd_get_bb_info (e->src->index)->out; 518 bitmap op2 = df_rd_get_bb_info (e->src->index)->out;
483 519
484 if (e->flags & EDGE_FAKE) 520 if (e->flags & EDGE_FAKE)
485 return; 521 return;
486 522
487 if (e->flags & EDGE_EH) 523 if (e->flags & EDGE_EH)
488 { 524 {
489 struct df_rd_problem_data *problem_data 525 struct df_rd_problem_data *problem_data
497 bitmap_copy (tmp, op2); 533 bitmap_copy (tmp, op2);
498 bitmap_and_compl_into (tmp, dense_invalidated); 534 bitmap_and_compl_into (tmp, dense_invalidated);
499 535
500 EXECUTE_IF_SET_IN_BITMAP (sparse_invalidated, 0, regno, bi) 536 EXECUTE_IF_SET_IN_BITMAP (sparse_invalidated, 0, regno, bi)
501 { 537 {
502 bitmap_clear_range (tmp, 538 bitmap_clear_range (tmp,
503 DF_DEFS_BEGIN (regno), 539 DF_DEFS_BEGIN (regno),
504 DF_DEFS_COUNT (regno)); 540 DF_DEFS_COUNT (regno));
505 } 541 }
506 bitmap_ior_into (op1, tmp); 542 bitmap_ior_into (op1, tmp);
507 BITMAP_FREE (tmp); 543 BITMAP_FREE (tmp);
508 } 544 }
525 bitmap kill = bb_info->kill; 561 bitmap kill = bb_info->kill;
526 bitmap sparse_kill = bb_info->sparse_kill; 562 bitmap sparse_kill = bb_info->sparse_kill;
527 563
528 if (bitmap_empty_p (sparse_kill)) 564 if (bitmap_empty_p (sparse_kill))
529 return bitmap_ior_and_compl (out, gen, in, kill); 565 return bitmap_ior_and_compl (out, gen, in, kill);
530 else 566 else
531 { 567 {
532 struct df_rd_problem_data *problem_data; 568 struct df_rd_problem_data *problem_data;
533 bool changed = false; 569 bool changed = false;
534 bitmap tmp; 570 bitmap tmp;
535 571
539 tmp = BITMAP_ALLOC (&problem_data->rd_bitmaps); 575 tmp = BITMAP_ALLOC (&problem_data->rd_bitmaps);
540 576
541 bitmap_copy (tmp, in); 577 bitmap_copy (tmp, in);
542 EXECUTE_IF_SET_IN_BITMAP (sparse_kill, 0, regno, bi) 578 EXECUTE_IF_SET_IN_BITMAP (sparse_kill, 0, regno, bi)
543 { 579 {
544 bitmap_clear_range (tmp, 580 bitmap_clear_range (tmp,
545 DF_DEFS_BEGIN (regno), 581 DF_DEFS_BEGIN (regno),
546 DF_DEFS_COUNT (regno)); 582 DF_DEFS_COUNT (regno));
547 } 583 }
548 bitmap_and_compl_into (tmp, kill); 584 bitmap_and_compl_into (tmp, kill);
549 bitmap_ior_into (tmp, gen); 585 bitmap_ior_into (tmp, gen);
550 changed = !bitmap_equal_p (tmp, out); 586 changed = !bitmap_equal_p (tmp, out);
551 if (changed) 587 if (changed)
552 { 588 {
553 BITMAP_FREE (out); 589 BITMAP_FREE (out);
554 bb_info->out = tmp; 590 bb_info->out = tmp;
555 } 591 }
556 else 592 else
557 BITMAP_FREE (tmp); 593 BITMAP_FREE (tmp);
558 return changed; 594 return changed;
559 } 595 }
560 } 596 }
561 597
570 606
571 if (problem_data) 607 if (problem_data)
572 { 608 {
573 free_alloc_pool (df_rd->block_pool); 609 free_alloc_pool (df_rd->block_pool);
574 bitmap_obstack_release (&problem_data->rd_bitmaps); 610 bitmap_obstack_release (&problem_data->rd_bitmaps);
575 611
576 df_rd->block_info_size = 0; 612 df_rd->block_info_size = 0;
577 free (df_rd->block_info); 613 free (df_rd->block_info);
578 free (df_rd->problem_data); 614 free (df_rd->problem_data);
579 } 615 }
580 free (df_rd); 616 free (df_rd);
588 { 624 {
589 struct df_rd_problem_data *problem_data 625 struct df_rd_problem_data *problem_data
590 = (struct df_rd_problem_data *) df_rd->problem_data; 626 = (struct df_rd_problem_data *) df_rd->problem_data;
591 unsigned int m = DF_REG_SIZE(df); 627 unsigned int m = DF_REG_SIZE(df);
592 unsigned int regno; 628 unsigned int regno;
593 629
594 if (!df_rd->block_info) 630 if (!df_rd->block_info)
595 return; 631 return;
596 632
597 fprintf (file, ";; Reaching defs:\n\n"); 633 fprintf (file, ";; Reaching defs:\n\n");
598 634
599 fprintf (file, " sparse invalidated \t"); 635 fprintf (file, " sparse invalidated \t");
601 fprintf (file, " dense invalidated \t"); 637 fprintf (file, " dense invalidated \t");
602 dump_bitmap (file, problem_data->dense_invalidated_by_call); 638 dump_bitmap (file, problem_data->dense_invalidated_by_call);
603 639
604 for (regno = 0; regno < m; regno++) 640 for (regno = 0; regno < m; regno++)
605 if (DF_DEFS_COUNT (regno)) 641 if (DF_DEFS_COUNT (regno))
606 fprintf (file, "%d[%d,%d] ", regno, 642 fprintf (file, "%d[%d,%d] ", regno,
607 DF_DEFS_BEGIN (regno), 643 DF_DEFS_BEGIN (regno),
608 DF_DEFS_COUNT (regno)); 644 DF_DEFS_COUNT (regno));
609 fprintf (file, "\n"); 645 fprintf (file, "\n");
610 646
611 } 647 }
612 648
617 df_rd_top_dump (basic_block bb, FILE *file) 653 df_rd_top_dump (basic_block bb, FILE *file)
618 { 654 {
619 struct df_rd_bb_info *bb_info = df_rd_get_bb_info (bb->index); 655 struct df_rd_bb_info *bb_info = df_rd_get_bb_info (bb->index);
620 if (!bb_info || !bb_info->in) 656 if (!bb_info || !bb_info->in)
621 return; 657 return;
622 658
623 fprintf (file, ";; rd in \t(%d)\n", (int) bitmap_count_bits (bb_info->in)); 659 fprintf (file, ";; rd in \t(%d)\n", (int) bitmap_count_bits (bb_info->in));
624 dump_bitmap (file, bb_info->in); 660 dump_bitmap (file, bb_info->in);
625 fprintf (file, ";; rd gen \t(%d)\n", (int) bitmap_count_bits (bb_info->gen)); 661 fprintf (file, ";; rd gen \t(%d)\n", (int) bitmap_count_bits (bb_info->gen));
626 dump_bitmap (file, bb_info->gen); 662 dump_bitmap (file, bb_info->gen);
627 fprintf (file, ";; rd kill\t(%d)\n", (int) bitmap_count_bits (bb_info->kill)); 663 fprintf (file, ";; rd kill\t(%d)\n", (int) bitmap_count_bits (bb_info->kill));
635 df_rd_bottom_dump (basic_block bb, FILE *file) 671 df_rd_bottom_dump (basic_block bb, FILE *file)
636 { 672 {
637 struct df_rd_bb_info *bb_info = df_rd_get_bb_info (bb->index); 673 struct df_rd_bb_info *bb_info = df_rd_get_bb_info (bb->index);
638 if (!bb_info || !bb_info->out) 674 if (!bb_info || !bb_info->out)
639 return; 675 return;
640 676
641 fprintf (file, ";; rd out \t(%d)\n", (int) bitmap_count_bits (bb_info->out)); 677 fprintf (file, ";; rd out \t(%d)\n", (int) bitmap_count_bits (bb_info->out));
642 dump_bitmap (file, bb_info->out); 678 dump_bitmap (file, bb_info->out);
643 } 679 }
644 680
645 /* All of the information associated with every instance of the problem. */ 681 /* All of the information associated with every instance of the problem. */
652 NULL, /* Reset global information. */ 688 NULL, /* Reset global information. */
653 df_rd_free_bb_info, /* Free basic block info. */ 689 df_rd_free_bb_info, /* Free basic block info. */
654 df_rd_local_compute, /* Local compute function. */ 690 df_rd_local_compute, /* Local compute function. */
655 df_rd_init_solution, /* Init the solution specific data. */ 691 df_rd_init_solution, /* Init the solution specific data. */
656 df_worklist_dataflow, /* Worklist solver. */ 692 df_worklist_dataflow, /* Worklist solver. */
657 NULL, /* Confluence operator 0. */ 693 NULL, /* Confluence operator 0. */
658 df_rd_confluence_n, /* Confluence operator n. */ 694 df_rd_confluence_n, /* Confluence operator n. */
659 df_rd_transfer_function, /* Transfer function. */ 695 df_rd_transfer_function, /* Transfer function. */
660 NULL, /* Finalize function. */ 696 NULL, /* Finalize function. */
661 df_rd_free, /* Free all of the problem information. */ 697 df_rd_free, /* Free all of the problem information. */
662 df_rd_free, /* Remove this problem from the stack of dataflow problems. */ 698 df_rd_free, /* Remove this problem from the stack of dataflow problems. */
663 df_rd_start_dump, /* Debugging. */ 699 df_rd_start_dump, /* Debugging. */
664 df_rd_top_dump, /* Debugging start block. */ 700 df_rd_top_dump, /* Debugging start block. */
665 df_rd_bottom_dump, /* Debugging end block. */ 701 df_rd_bottom_dump, /* Debugging end block. */
666 NULL, /* Incremental solution verify start. */ 702 NULL, /* Incremental solution verify start. */
667 NULL, /* Incremental solution verify end. */ 703 NULL, /* Incremental solution verify end. */
668 NULL, /* Dependent problem. */ 704 NULL, /* Dependent problem. */
669 TV_DF_RD, /* Timing variable. */ 705 TV_DF_RD, /* Timing variable. */
670 true /* Reset blocks on dropping out of blocks_to_analyze. */ 706 true /* Reset blocks on dropping out of blocks_to_analyze. */
671 }; 707 };
672 708
673 709
674 710
675 /* Create a new DATAFLOW instance and add it to an existing instance 711 /* Create a new RD instance and add it to the existing instance
676 of DF. The returned structure is what is used to get at the 712 of DF. */
677 solution. */
678 713
679 void 714 void
680 df_rd_add_problem (void) 715 df_rd_add_problem (void)
681 { 716 {
682 df_add_problem (&problem_RD); 717 df_add_problem (&problem_RD);
702 737
703 738
704 /* Set basic block info. */ 739 /* Set basic block info. */
705 740
706 static void 741 static void
707 df_lr_set_bb_info (unsigned int index, 742 df_lr_set_bb_info (unsigned int index,
708 struct df_lr_bb_info *bb_info) 743 struct df_lr_bb_info *bb_info)
709 { 744 {
710 gcc_assert (df_lr); 745 gcc_assert (df_lr);
711 gcc_assert (index < df_lr->block_info_size); 746 gcc_assert (index < df_lr->block_info_size);
712 df_lr->block_info[index] = bb_info; 747 df_lr->block_info[index] = bb_info;
713 } 748 }
714 749
715 750
716 /* Free basic block info. */ 751 /* Free basic block info. */
717 752
718 static void 753 static void
719 df_lr_free_bb_info (basic_block bb ATTRIBUTE_UNUSED, 754 df_lr_free_bb_info (basic_block bb ATTRIBUTE_UNUSED,
720 void *vbb_info) 755 void *vbb_info)
721 { 756 {
722 struct df_lr_bb_info *bb_info = (struct df_lr_bb_info *) vbb_info; 757 struct df_lr_bb_info *bb_info = (struct df_lr_bb_info *) vbb_info;
723 if (bb_info) 758 if (bb_info)
724 { 759 {
732 767
733 768
734 /* Allocate or reset bitmaps for DF_LR blocks. The solution bits are 769 /* Allocate or reset bitmaps for DF_LR blocks. The solution bits are
735 not touched unless the block is new. */ 770 not touched unless the block is new. */
736 771
737 static void 772 static void
738 df_lr_alloc (bitmap all_blocks ATTRIBUTE_UNUSED) 773 df_lr_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
739 { 774 {
740 unsigned int bb_index; 775 unsigned int bb_index;
741 bitmap_iterator bi; 776 bitmap_iterator bi;
742 777
743 if (!df_lr->block_pool) 778 if (!df_lr->block_pool)
744 df_lr->block_pool = create_alloc_pool ("df_lr_block pool", 779 df_lr->block_pool = create_alloc_pool ("df_lr_block pool",
745 sizeof (struct df_lr_bb_info), 50); 780 sizeof (struct df_lr_bb_info), 50);
746 781
747 df_grow_bb_info (df_lr); 782 df_grow_bb_info (df_lr);
748 783
749 EXECUTE_IF_SET_IN_BITMAP (df_lr->out_of_date_transfer_functions, 0, bb_index, bi) 784 EXECUTE_IF_SET_IN_BITMAP (df_lr->out_of_date_transfer_functions, 0, bb_index, bi)
750 { 785 {
751 struct df_lr_bb_info *bb_info = df_lr_get_bb_info (bb_index); 786 struct df_lr_bb_info *bb_info = df_lr_get_bb_info (bb_index);
752 if (bb_info) 787 if (bb_info)
753 { 788 {
754 bitmap_clear (bb_info->def); 789 bitmap_clear (bb_info->def);
755 bitmap_clear (bb_info->use); 790 bitmap_clear (bb_info->use);
756 } 791 }
757 else 792 else
758 { 793 {
759 bb_info = (struct df_lr_bb_info *) pool_alloc (df_lr->block_pool); 794 bb_info = (struct df_lr_bb_info *) pool_alloc (df_lr->block_pool);
760 df_lr_set_bb_info (bb_index, bb_info); 795 df_lr_set_bb_info (bb_index, bb_info);
761 bb_info->use = BITMAP_ALLOC (NULL); 796 bb_info->use = BITMAP_ALLOC (NULL);
762 bb_info->def = BITMAP_ALLOC (NULL); 797 bb_info->def = BITMAP_ALLOC (NULL);
763 bb_info->in = BITMAP_ALLOC (NULL); 798 bb_info->in = BITMAP_ALLOC (NULL);
769 } 804 }
770 805
771 806
772 /* Reset the global solution for recalculation. */ 807 /* Reset the global solution for recalculation. */
773 808
774 static void 809 static void
775 df_lr_reset (bitmap all_blocks) 810 df_lr_reset (bitmap all_blocks)
776 { 811 {
777 unsigned int bb_index; 812 unsigned int bb_index;
778 bitmap_iterator bi; 813 bitmap_iterator bi;
779 814
821 856
822 FOR_BB_INSNS_REVERSE (bb, insn) 857 FOR_BB_INSNS_REVERSE (bb, insn)
823 { 858 {
824 unsigned int uid = INSN_UID (insn); 859 unsigned int uid = INSN_UID (insn);
825 860
826 if (!INSN_P (insn)) 861 if (!NONDEBUG_INSN_P (insn))
827 continue; 862 continue;
828 863
829 for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++) 864 for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
830 { 865 {
831 df_ref def = *def_rec; 866 df_ref def = *def_rec;
832 /* If the def is to only part of the reg, it does 867 /* If the def is to only part of the reg, it does
858 unsigned int dregno = DF_REF_REGNO (def); 893 unsigned int dregno = DF_REF_REGNO (def);
859 bitmap_set_bit (bb_info->def, dregno); 894 bitmap_set_bit (bb_info->def, dregno);
860 bitmap_clear_bit (bb_info->use, dregno); 895 bitmap_clear_bit (bb_info->use, dregno);
861 } 896 }
862 } 897 }
863 898
864 #ifdef EH_USES 899 #ifdef EH_USES
865 /* Process the uses that are live into an exception handler. */ 900 /* Process the uses that are live into an exception handler. */
866 for (use_rec = df_get_artificial_uses (bb_index); *use_rec; use_rec++) 901 for (use_rec = df_get_artificial_uses (bb_index); *use_rec; use_rec++)
867 { 902 {
868 df_ref use = *use_rec; 903 df_ref use = *use_rec;
886 static void 921 static void
887 df_lr_local_compute (bitmap all_blocks ATTRIBUTE_UNUSED) 922 df_lr_local_compute (bitmap all_blocks ATTRIBUTE_UNUSED)
888 { 923 {
889 unsigned int bb_index; 924 unsigned int bb_index;
890 bitmap_iterator bi; 925 bitmap_iterator bi;
891 926
892 bitmap_clear (df->hardware_regs_used); 927 bitmap_clear (df->hardware_regs_used);
893 928
894 /* The all-important stack pointer must always be live. */ 929 /* The all-important stack pointer must always be live. */
895 bitmap_set_bit (df->hardware_regs_used, STACK_POINTER_REGNUM); 930 bitmap_set_bit (df->hardware_regs_used, STACK_POINTER_REGNUM);
896 931
897 /* Before reload, there are a few registers that must be forced 932 /* Before reload, there are a few registers that must be forced
898 live everywhere -- which might not already be the case for 933 live everywhere -- which might not already be the case for
899 blocks within infinite loops. */ 934 blocks within infinite loops. */
900 if (!reload_completed) 935 if (!reload_completed)
901 { 936 {
902 /* Any reference to any pseudo before reload is a potential 937 /* Any reference to any pseudo before reload is a potential
903 reference of the frame pointer. */ 938 reference of the frame pointer. */
904 bitmap_set_bit (df->hardware_regs_used, FRAME_POINTER_REGNUM); 939 bitmap_set_bit (df->hardware_regs_used, FRAME_POINTER_REGNUM);
905 940
906 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM 941 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
907 /* Pseudos with argument area equivalences may require 942 /* Pseudos with argument area equivalences may require
908 reloading via the argument pointer. */ 943 reloading via the argument pointer. */
909 if (fixed_regs[ARG_POINTER_REGNUM]) 944 if (fixed_regs[ARG_POINTER_REGNUM])
910 bitmap_set_bit (df->hardware_regs_used, ARG_POINTER_REGNUM); 945 bitmap_set_bit (df->hardware_regs_used, ARG_POINTER_REGNUM);
911 #endif 946 #endif
912 947
913 /* Any constant, or pseudo with constant equivalences, may 948 /* Any constant, or pseudo with constant equivalences, may
914 require reloading from memory using the pic register. */ 949 require reloading from memory using the pic register. */
915 if ((unsigned) PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM 950 if ((unsigned) PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM
916 && fixed_regs[PIC_OFFSET_TABLE_REGNUM]) 951 && fixed_regs[PIC_OFFSET_TABLE_REGNUM])
917 bitmap_set_bit (df->hardware_regs_used, PIC_OFFSET_TABLE_REGNUM); 952 bitmap_set_bit (df->hardware_regs_used, PIC_OFFSET_TABLE_REGNUM);
918 } 953 }
919 954
920 EXECUTE_IF_SET_IN_BITMAP (df_lr->out_of_date_transfer_functions, 0, bb_index, bi) 955 EXECUTE_IF_SET_IN_BITMAP (df_lr->out_of_date_transfer_functions, 0, bb_index, bi)
921 { 956 {
922 if (bb_index == EXIT_BLOCK) 957 if (bb_index == EXIT_BLOCK)
923 { 958 {
924 /* The exit block is special for this problem and its bits are 959 /* The exit block is special for this problem and its bits are
934 } 969 }
935 970
936 971
937 /* Initialize the solution vectors. */ 972 /* Initialize the solution vectors. */
938 973
939 static void 974 static void
940 df_lr_init (bitmap all_blocks) 975 df_lr_init (bitmap all_blocks)
941 { 976 {
942 unsigned int bb_index; 977 unsigned int bb_index;
943 bitmap_iterator bi; 978 bitmap_iterator bi;
944 979
958 df_lr_confluence_0 (basic_block bb) 993 df_lr_confluence_0 (basic_block bb)
959 { 994 {
960 bitmap op1 = df_lr_get_bb_info (bb->index)->out; 995 bitmap op1 = df_lr_get_bb_info (bb->index)->out;
961 if (bb != EXIT_BLOCK_PTR) 996 if (bb != EXIT_BLOCK_PTR)
962 bitmap_copy (op1, df->hardware_regs_used); 997 bitmap_copy (op1, df->hardware_regs_used);
963 } 998 }
964 999
965 1000
966 /* Confluence function that ignores fake edges. */ 1001 /* Confluence function that ignores fake edges. */
967 1002
968 static void 1003 static void
969 df_lr_confluence_n (edge e) 1004 df_lr_confluence_n (edge e)
970 { 1005 {
971 bitmap op1 = df_lr_get_bb_info (e->src->index)->out; 1006 bitmap op1 = df_lr_get_bb_info (e->src->index)->out;
972 bitmap op2 = df_lr_get_bb_info (e->dest->index)->in; 1007 bitmap op2 = df_lr_get_bb_info (e->dest->index)->in;
973 1008
974 /* Call-clobbered registers die across exception and call edges. */ 1009 /* Call-clobbered registers die across exception and call edges. */
975 /* ??? Abnormal call edges ignored for the moment, as this gets 1010 /* ??? Abnormal call edges ignored for the moment, as this gets
976 confused by sibling call edges, which crashes reg-stack. */ 1011 confused by sibling call edges, which crashes reg-stack. */
977 if (e->flags & EDGE_EH) 1012 if (e->flags & EDGE_EH)
978 bitmap_ior_and_compl_into (op1, op2, regs_invalidated_by_call_regset); 1013 bitmap_ior_and_compl_into (op1, op2, regs_invalidated_by_call_regset);
979 else 1014 else
980 bitmap_ior_into (op1, op2); 1015 bitmap_ior_into (op1, op2);
981 1016
982 bitmap_ior_into (op1, df->hardware_regs_used); 1017 bitmap_ior_into (op1, df->hardware_regs_used);
983 } 1018 }
984 1019
985 1020
986 /* Transfer function. */ 1021 /* Transfer function. */
987 1022
988 static bool 1023 static bool
1050 BITMAP_FREE (bb_info->in); 1085 BITMAP_FREE (bb_info->in);
1051 BITMAP_FREE (bb_info->out); 1086 BITMAP_FREE (bb_info->out);
1052 } 1087 }
1053 } 1088 }
1054 free_alloc_pool (df_lr->block_pool); 1089 free_alloc_pool (df_lr->block_pool);
1055 1090
1056 df_lr->block_info_size = 0; 1091 df_lr->block_info_size = 0;
1057 free (df_lr->block_info); 1092 free (df_lr->block_info);
1058 } 1093 }
1059 1094
1060 BITMAP_FREE (df_lr->out_of_date_transfer_functions); 1095 BITMAP_FREE (df_lr->out_of_date_transfer_functions);
1069 { 1104 {
1070 struct df_lr_bb_info *bb_info = df_lr_get_bb_info (bb->index); 1105 struct df_lr_bb_info *bb_info = df_lr_get_bb_info (bb->index);
1071 struct df_lr_problem_data *problem_data; 1106 struct df_lr_problem_data *problem_data;
1072 if (!bb_info || !bb_info->in) 1107 if (!bb_info || !bb_info->in)
1073 return; 1108 return;
1074 1109
1075 fprintf (file, ";; lr in \t"); 1110 fprintf (file, ";; lr in \t");
1076 df_print_regset (file, bb_info->in); 1111 df_print_regset (file, bb_info->in);
1077 if (df_lr->problem_data) 1112 if (df_lr->problem_data)
1078 { 1113 {
1079 problem_data = (struct df_lr_problem_data *)df_lr->problem_data; 1114 problem_data = (struct df_lr_problem_data *)df_lr->problem_data;
1082 } 1117 }
1083 fprintf (file, ";; lr use \t"); 1118 fprintf (file, ";; lr use \t");
1084 df_print_regset (file, bb_info->use); 1119 df_print_regset (file, bb_info->use);
1085 fprintf (file, ";; lr def \t"); 1120 fprintf (file, ";; lr def \t");
1086 df_print_regset (file, bb_info->def); 1121 df_print_regset (file, bb_info->def);
1087 } 1122 }
1088 1123
1089 1124
1090 /* Debugging info at bottom of bb. */ 1125 /* Debugging info at bottom of bb. */
1091 1126
1092 static void 1127 static void
1094 { 1129 {
1095 struct df_lr_bb_info *bb_info = df_lr_get_bb_info (bb->index); 1130 struct df_lr_bb_info *bb_info = df_lr_get_bb_info (bb->index);
1096 struct df_lr_problem_data *problem_data; 1131 struct df_lr_problem_data *problem_data;
1097 if (!bb_info || !bb_info->out) 1132 if (!bb_info || !bb_info->out)
1098 return; 1133 return;
1099 1134
1100 fprintf (file, ";; lr out \t"); 1135 fprintf (file, ";; lr out \t");
1101 df_print_regset (file, bb_info->out); 1136 df_print_regset (file, bb_info->out);
1102 if (df_lr->problem_data) 1137 if (df_lr->problem_data)
1103 { 1138 {
1104 problem_data = (struct df_lr_problem_data *)df_lr->problem_data; 1139 problem_data = (struct df_lr_problem_data *)df_lr->problem_data;
1105 fprintf (file, ";; old out \t"); 1140 fprintf (file, ";; old out \t");
1106 df_print_regset (file, problem_data->out[bb->index]); 1141 df_print_regset (file, problem_data->out[bb->index]);
1107 } 1142 }
1108 } 1143 }
1109 1144
1110 1145
1111 /* Build the datastructure to verify that the solution to the dataflow 1146 /* Build the datastructure to verify that the solution to the dataflow
1112 equations is not dirty. */ 1147 equations is not dirty. */
1113 1148
1120 { 1155 {
1121 df_lr->problem_data = NULL; 1156 df_lr->problem_data = NULL;
1122 return; 1157 return;
1123 } 1158 }
1124 1159
1125 /* Set it true so that the solution is recomputed. */ 1160 /* Set it true so that the solution is recomputed. */
1126 df_lr->solutions_dirty = true; 1161 df_lr->solutions_dirty = true;
1127 1162
1128 problem_data = XNEW (struct df_lr_problem_data); 1163 problem_data = XNEW (struct df_lr_problem_data);
1129 df_lr->problem_data = problem_data; 1164 df_lr->problem_data = problem_data;
1130 problem_data->in = XNEWVEC (bitmap, last_basic_block); 1165 problem_data->in = XNEWVEC (bitmap, last_basic_block);
1194 df_lr_reset, /* Reset global information. */ 1229 df_lr_reset, /* Reset global information. */
1195 df_lr_free_bb_info, /* Free basic block info. */ 1230 df_lr_free_bb_info, /* Free basic block info. */
1196 df_lr_local_compute, /* Local compute function. */ 1231 df_lr_local_compute, /* Local compute function. */
1197 df_lr_init, /* Init the solution specific data. */ 1232 df_lr_init, /* Init the solution specific data. */
1198 df_worklist_dataflow, /* Worklist solver. */ 1233 df_worklist_dataflow, /* Worklist solver. */
1199 df_lr_confluence_0, /* Confluence operator 0. */ 1234 df_lr_confluence_0, /* Confluence operator 0. */
1200 df_lr_confluence_n, /* Confluence operator n. */ 1235 df_lr_confluence_n, /* Confluence operator n. */
1201 df_lr_transfer_function, /* Transfer function. */ 1236 df_lr_transfer_function, /* Transfer function. */
1202 df_lr_finalize, /* Finalize function. */ 1237 df_lr_finalize, /* Finalize function. */
1203 df_lr_free, /* Free all of the problem information. */ 1238 df_lr_free, /* Free all of the problem information. */
1204 NULL, /* Remove this problem from the stack of dataflow problems. */ 1239 NULL, /* Remove this problem from the stack of dataflow problems. */
1205 NULL, /* Debugging. */ 1240 NULL, /* Debugging. */
1206 df_lr_top_dump, /* Debugging start block. */ 1241 df_lr_top_dump, /* Debugging start block. */
1207 df_lr_bottom_dump, /* Debugging end block. */ 1242 df_lr_bottom_dump, /* Debugging end block. */
1208 df_lr_verify_solution_start,/* Incremental solution verify start. */ 1243 df_lr_verify_solution_start,/* Incremental solution verify start. */
1209 df_lr_verify_solution_end, /* Incremental solution verify end. */ 1244 df_lr_verify_solution_end, /* Incremental solution verify end. */
1210 NULL, /* Dependent problem. */ 1245 NULL, /* Dependent problem. */
1211 TV_DF_LR, /* Timing variable. */ 1246 TV_DF_LR, /* Timing variable. */
1212 false /* Reset blocks on dropping out of blocks_to_analyze. */ 1247 false /* Reset blocks on dropping out of blocks_to_analyze. */
1213 }; 1248 };
1214 1249
1215 1250
1216 /* Create a new DATAFLOW instance and add it to an existing instance 1251 /* Create a new DATAFLOW instance and add it to an existing instance
1257 if (bb_info) 1292 if (bb_info)
1258 { 1293 {
1259 /* Make a copy of the transfer functions and then compute 1294 /* Make a copy of the transfer functions and then compute
1260 new ones to see if the transfer functions have 1295 new ones to see if the transfer functions have
1261 changed. */ 1296 changed. */
1262 if (!bitmap_bit_p (df_lr->out_of_date_transfer_functions, 1297 if (!bitmap_bit_p (df_lr->out_of_date_transfer_functions,
1263 bb->index)) 1298 bb->index))
1264 { 1299 {
1265 bitmap_copy (saved_def, bb_info->def); 1300 bitmap_copy (saved_def, bb_info->def);
1266 bitmap_copy (saved_use, bb_info->use); 1301 bitmap_copy (saved_use, bb_info->use);
1267 bitmap_clear (bb_info->def); 1302 bitmap_clear (bb_info->def);
1275 else 1310 else
1276 { 1311 {
1277 /* If we do not have basic block info, the block must be in 1312 /* If we do not have basic block info, the block must be in
1278 the list of dirty blocks or else some one has added a 1313 the list of dirty blocks or else some one has added a
1279 block behind our backs. */ 1314 block behind our backs. */
1280 gcc_assert (bitmap_bit_p (df_lr->out_of_date_transfer_functions, 1315 gcc_assert (bitmap_bit_p (df_lr->out_of_date_transfer_functions,
1281 bb->index)); 1316 bb->index));
1282 } 1317 }
1283 /* Make sure no one created a block without following 1318 /* Make sure no one created a block without following
1284 procedures. */ 1319 procedures. */
1285 gcc_assert (df_scan_get_bb_info (bb->index)); 1320 gcc_assert (df_scan_get_bb_info (bb->index));
1286 } 1321 }
1287 1322
1288 /* Make sure there are no dirty bits in blocks that have been deleted. */ 1323 /* Make sure there are no dirty bits in blocks that have been deleted. */
1289 gcc_assert (!bitmap_intersect_compl_p (df_lr->out_of_date_transfer_functions, 1324 gcc_assert (!bitmap_intersect_compl_p (df_lr->out_of_date_transfer_functions,
1290 all_blocks)); 1325 all_blocks));
1291 1326
1292 BITMAP_FREE (saved_def); 1327 BITMAP_FREE (saved_def);
1293 BITMAP_FREE (saved_use); 1328 BITMAP_FREE (saved_use);
1294 BITMAP_FREE (saved_adef); 1329 BITMAP_FREE (saved_adef);
1295 BITMAP_FREE (saved_ause); 1330 BITMAP_FREE (saved_ause);
1312 regnum (see df.h for details). In and out bitvectors in struct 1347 regnum (see df.h for details). In and out bitvectors in struct
1313 df_live_bb_info actually refers to the must-initialized problem; 1348 df_live_bb_info actually refers to the must-initialized problem;
1314 1349
1315 Then, the in and out sets for the LIVE problem itself are computed. 1350 Then, the in and out sets for the LIVE problem itself are computed.
1316 These are the logical AND of the IN and OUT sets from the LR problem 1351 These are the logical AND of the IN and OUT sets from the LR problem
1317 and the must-initialized problem. 1352 and the must-initialized problem.
1318 ----------------------------------------------------------------------------*/ 1353 ----------------------------------------------------------------------------*/
1319 1354
1320 /* Private data used to verify the solution for this problem. */ 1355 /* Private data used to verify the solution for this problem. */
1321 struct df_live_problem_data 1356 struct df_live_problem_data
1322 { 1357 {
1330 static bitmap df_live_scratch; 1365 static bitmap df_live_scratch;
1331 1366
1332 /* Set basic block info. */ 1367 /* Set basic block info. */
1333 1368
1334 static void 1369 static void
1335 df_live_set_bb_info (unsigned int index, 1370 df_live_set_bb_info (unsigned int index,
1336 struct df_live_bb_info *bb_info) 1371 struct df_live_bb_info *bb_info)
1337 { 1372 {
1338 gcc_assert (df_live); 1373 gcc_assert (df_live);
1339 gcc_assert (index < df_live->block_info_size); 1374 gcc_assert (index < df_live->block_info_size);
1340 df_live->block_info[index] = bb_info; 1375 df_live->block_info[index] = bb_info;
1342 1377
1343 1378
1344 /* Free basic block info. */ 1379 /* Free basic block info. */
1345 1380
1346 static void 1381 static void
1347 df_live_free_bb_info (basic_block bb ATTRIBUTE_UNUSED, 1382 df_live_free_bb_info (basic_block bb ATTRIBUTE_UNUSED,
1348 void *vbb_info) 1383 void *vbb_info)
1349 { 1384 {
1350 struct df_live_bb_info *bb_info = (struct df_live_bb_info *) vbb_info; 1385 struct df_live_bb_info *bb_info = (struct df_live_bb_info *) vbb_info;
1351 if (bb_info) 1386 if (bb_info)
1352 { 1387 {
1360 1395
1361 1396
1362 /* Allocate or reset bitmaps for DF_LIVE blocks. The solution bits are 1397 /* Allocate or reset bitmaps for DF_LIVE blocks. The solution bits are
1363 not touched unless the block is new. */ 1398 not touched unless the block is new. */
1364 1399
1365 static void 1400 static void
1366 df_live_alloc (bitmap all_blocks ATTRIBUTE_UNUSED) 1401 df_live_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
1367 { 1402 {
1368 unsigned int bb_index; 1403 unsigned int bb_index;
1369 bitmap_iterator bi; 1404 bitmap_iterator bi;
1370 1405
1371 if (!df_live->block_pool) 1406 if (!df_live->block_pool)
1372 df_live->block_pool = create_alloc_pool ("df_live_block pool", 1407 df_live->block_pool = create_alloc_pool ("df_live_block pool",
1373 sizeof (struct df_live_bb_info), 100); 1408 sizeof (struct df_live_bb_info), 100);
1374 if (!df_live_scratch) 1409 if (!df_live_scratch)
1375 df_live_scratch = BITMAP_ALLOC (NULL); 1410 df_live_scratch = BITMAP_ALLOC (NULL);
1376 1411
1377 df_grow_bb_info (df_live); 1412 df_grow_bb_info (df_live);
1378 1413
1379 EXECUTE_IF_SET_IN_BITMAP (df_live->out_of_date_transfer_functions, 0, bb_index, bi) 1414 EXECUTE_IF_SET_IN_BITMAP (df_live->out_of_date_transfer_functions, 0, bb_index, bi)
1380 { 1415 {
1381 struct df_live_bb_info *bb_info = df_live_get_bb_info (bb_index); 1416 struct df_live_bb_info *bb_info = df_live_get_bb_info (bb_index);
1382 if (bb_info) 1417 if (bb_info)
1383 { 1418 {
1384 bitmap_clear (bb_info->kill); 1419 bitmap_clear (bb_info->kill);
1385 bitmap_clear (bb_info->gen); 1420 bitmap_clear (bb_info->gen);
1386 } 1421 }
1387 else 1422 else
1388 { 1423 {
1389 bb_info = (struct df_live_bb_info *) pool_alloc (df_live->block_pool); 1424 bb_info = (struct df_live_bb_info *) pool_alloc (df_live->block_pool);
1390 df_live_set_bb_info (bb_index, bb_info); 1425 df_live_set_bb_info (bb_index, bb_info);
1391 bb_info->kill = BITMAP_ALLOC (NULL); 1426 bb_info->kill = BITMAP_ALLOC (NULL);
1392 bb_info->gen = BITMAP_ALLOC (NULL); 1427 bb_info->gen = BITMAP_ALLOC (NULL);
1393 bb_info->in = BITMAP_ALLOC (NULL); 1428 bb_info->in = BITMAP_ALLOC (NULL);
1398 } 1433 }
1399 1434
1400 1435
1401 /* Reset the global solution for recalculation. */ 1436 /* Reset the global solution for recalculation. */
1402 1437
1403 static void 1438 static void
1404 df_live_reset (bitmap all_blocks) 1439 df_live_reset (bitmap all_blocks)
1405 { 1440 {
1406 unsigned int bb_index; 1441 unsigned int bb_index;
1407 bitmap_iterator bi; 1442 bitmap_iterator bi;
1408 1443
1480 unsigned int bb_index; 1515 unsigned int bb_index;
1481 bitmap_iterator bi; 1516 bitmap_iterator bi;
1482 1517
1483 df_grow_insn_info (); 1518 df_grow_insn_info ();
1484 1519
1485 EXECUTE_IF_SET_IN_BITMAP (df_live->out_of_date_transfer_functions, 1520 EXECUTE_IF_SET_IN_BITMAP (df_live->out_of_date_transfer_functions,
1486 0, bb_index, bi) 1521 0, bb_index, bi)
1487 { 1522 {
1488 df_live_bb_local_compute (bb_index); 1523 df_live_bb_local_compute (bb_index);
1489 } 1524 }
1490 1525
1492 } 1527 }
1493 1528
1494 1529
1495 /* Initialize the solution vectors. */ 1530 /* Initialize the solution vectors. */
1496 1531
1497 static void 1532 static void
1498 df_live_init (bitmap all_blocks) 1533 df_live_init (bitmap all_blocks)
1499 { 1534 {
1500 unsigned int bb_index; 1535 unsigned int bb_index;
1501 bitmap_iterator bi; 1536 bitmap_iterator bi;
1502 1537
1517 static void 1552 static void
1518 df_live_confluence_n (edge e) 1553 df_live_confluence_n (edge e)
1519 { 1554 {
1520 bitmap op1 = df_live_get_bb_info (e->dest->index)->in; 1555 bitmap op1 = df_live_get_bb_info (e->dest->index)->in;
1521 bitmap op2 = df_live_get_bb_info (e->src->index)->out; 1556 bitmap op2 = df_live_get_bb_info (e->src->index)->out;
1522 1557
1523 if (e->flags & EDGE_FAKE) 1558 if (e->flags & EDGE_FAKE)
1524 return; 1559 return;
1525 1560
1526 bitmap_ior_into (op1, op2); 1561 bitmap_ior_into (op1, op2);
1527 } 1562 }
1528 1563
1529 1564
1530 /* Transfer function for the forwards must-initialized problem. */ 1565 /* Transfer function for the forwards must-initialized problem. */
1531 1566
1532 static bool 1567 static bool
1537 bitmap in = bb_info->in; 1572 bitmap in = bb_info->in;
1538 bitmap out = bb_info->out; 1573 bitmap out = bb_info->out;
1539 bitmap gen = bb_info->gen; 1574 bitmap gen = bb_info->gen;
1540 bitmap kill = bb_info->kill; 1575 bitmap kill = bb_info->kill;
1541 1576
1542 /* We need to use a scratch set here so that the value returned from 1577 /* We need to use a scratch set here so that the value returned from this
1543 this function invocation properly reflects if the sets changed in 1578 function invocation properly reflects whether the sets changed in a
1544 a significant way; i.e. not just because the lr set was anded 1579 significant way; i.e. not just because the lr set was anded in. */
1545 in. */
1546 bitmap_and (df_live_scratch, gen, bb_lr_info->out); 1580 bitmap_and (df_live_scratch, gen, bb_lr_info->out);
1547 /* No register may reach a location where it is not used. Thus 1581 /* No register may reach a location where it is not used. Thus
1548 we trim the rr result to the places where it is used. */ 1582 we trim the rr result to the places where it is used. */
1549 bitmap_and_into (in, bb_lr_info->in); 1583 bitmap_and_into (in, bb_lr_info->in);
1550 1584
1565 1599
1566 EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi) 1600 EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
1567 { 1601 {
1568 struct df_lr_bb_info *bb_lr_info = df_lr_get_bb_info (bb_index); 1602 struct df_lr_bb_info *bb_lr_info = df_lr_get_bb_info (bb_index);
1569 struct df_live_bb_info *bb_live_info = df_live_get_bb_info (bb_index); 1603 struct df_live_bb_info *bb_live_info = df_live_get_bb_info (bb_index);
1570 1604
1571 /* No register may reach a location where it is not used. Thus 1605 /* No register may reach a location where it is not used. Thus
1572 we trim the rr result to the places where it is used. */ 1606 we trim the rr result to the places where it is used. */
1573 bitmap_and_into (bb_live_info->in, bb_lr_info->in); 1607 bitmap_and_into (bb_live_info->in, bb_lr_info->in);
1574 bitmap_and_into (bb_live_info->out, bb_lr_info->out); 1608 bitmap_and_into (bb_live_info->out, bb_lr_info->out);
1575 } 1609 }
1576 1610
1577 df_live->solutions_dirty = false; 1611 df_live->solutions_dirty = false;
1578 } 1612 }
1579 } 1613 }
1580 1614
1581 1615
1585 df_live_free (void) 1619 df_live_free (void)
1586 { 1620 {
1587 if (df_live->block_info) 1621 if (df_live->block_info)
1588 { 1622 {
1589 unsigned int i; 1623 unsigned int i;
1590 1624
1591 for (i = 0; i < df_live->block_info_size; i++) 1625 for (i = 0; i < df_live->block_info_size; i++)
1592 { 1626 {
1593 struct df_live_bb_info *bb_info = df_live_get_bb_info (i); 1627 struct df_live_bb_info *bb_info = df_live_get_bb_info (i);
1594 if (bb_info) 1628 if (bb_info)
1595 { 1629 {
1597 BITMAP_FREE (bb_info->kill); 1631 BITMAP_FREE (bb_info->kill);
1598 BITMAP_FREE (bb_info->in); 1632 BITMAP_FREE (bb_info->in);
1599 BITMAP_FREE (bb_info->out); 1633 BITMAP_FREE (bb_info->out);
1600 } 1634 }
1601 } 1635 }
1602 1636
1603 free_alloc_pool (df_live->block_pool); 1637 free_alloc_pool (df_live->block_pool);
1604 df_live->block_info_size = 0; 1638 df_live->block_info_size = 0;
1605 free (df_live->block_info); 1639 free (df_live->block_info);
1606 1640
1607 if (df_live_scratch) 1641 if (df_live_scratch)
1620 struct df_live_bb_info *bb_info = df_live_get_bb_info (bb->index); 1654 struct df_live_bb_info *bb_info = df_live_get_bb_info (bb->index);
1621 struct df_live_problem_data *problem_data; 1655 struct df_live_problem_data *problem_data;
1622 1656
1623 if (!bb_info || !bb_info->in) 1657 if (!bb_info || !bb_info->in)
1624 return; 1658 return;
1625 1659
1626 fprintf (file, ";; live in \t"); 1660 fprintf (file, ";; live in \t");
1627 df_print_regset (file, bb_info->in); 1661 df_print_regset (file, bb_info->in);
1628 if (df_live->problem_data) 1662 if (df_live->problem_data)
1629 { 1663 {
1630 problem_data = (struct df_live_problem_data *)df_live->problem_data; 1664 problem_data = (struct df_live_problem_data *)df_live->problem_data;
1646 struct df_live_bb_info *bb_info = df_live_get_bb_info (bb->index); 1680 struct df_live_bb_info *bb_info = df_live_get_bb_info (bb->index);
1647 struct df_live_problem_data *problem_data; 1681 struct df_live_problem_data *problem_data;
1648 1682
1649 if (!bb_info || !bb_info->out) 1683 if (!bb_info || !bb_info->out)
1650 return; 1684 return;
1651 1685
1652 fprintf (file, ";; live out \t"); 1686 fprintf (file, ";; live out \t");
1653 df_print_regset (file, bb_info->out); 1687 df_print_regset (file, bb_info->out);
1654 if (df_live->problem_data) 1688 if (df_live->problem_data)
1655 { 1689 {
1656 problem_data = (struct df_live_problem_data *)df_live->problem_data; 1690 problem_data = (struct df_live_problem_data *)df_live->problem_data;
1672 { 1706 {
1673 df_live->problem_data = NULL; 1707 df_live->problem_data = NULL;
1674 return; 1708 return;
1675 } 1709 }
1676 1710
1677 /* Set it true so that the solution is recomputed. */ 1711 /* Set it true so that the solution is recomputed. */
1678 df_live->solutions_dirty = true; 1712 df_live->solutions_dirty = true;
1679 1713
1680 problem_data = XNEW (struct df_live_problem_data); 1714 problem_data = XNEW (struct df_live_problem_data);
1681 df_live->problem_data = problem_data; 1715 df_live->problem_data = problem_data;
1682 problem_data->in = XNEWVEC (bitmap, last_basic_block); 1716 problem_data->in = XNEWVEC (bitmap, last_basic_block);
1741 df_live_reset, /* Reset global information. */ 1775 df_live_reset, /* Reset global information. */
1742 df_live_free_bb_info, /* Free basic block info. */ 1776 df_live_free_bb_info, /* Free basic block info. */
1743 df_live_local_compute, /* Local compute function. */ 1777 df_live_local_compute, /* Local compute function. */
1744 df_live_init, /* Init the solution specific data. */ 1778 df_live_init, /* Init the solution specific data. */
1745 df_worklist_dataflow, /* Worklist solver. */ 1779 df_worklist_dataflow, /* Worklist solver. */
1746 NULL, /* Confluence operator 0. */ 1780 NULL, /* Confluence operator 0. */
1747 df_live_confluence_n, /* Confluence operator n. */ 1781 df_live_confluence_n, /* Confluence operator n. */
1748 df_live_transfer_function, /* Transfer function. */ 1782 df_live_transfer_function, /* Transfer function. */
1749 df_live_finalize, /* Finalize function. */ 1783 df_live_finalize, /* Finalize function. */
1750 df_live_free, /* Free all of the problem information. */ 1784 df_live_free, /* Free all of the problem information. */
1751 df_live_free, /* Remove this problem from the stack of dataflow problems. */ 1785 df_live_free, /* Remove this problem from the stack of dataflow problems. */
1752 NULL, /* Debugging. */ 1786 NULL, /* Debugging. */
1780 void 1814 void
1781 df_live_set_all_dirty (void) 1815 df_live_set_all_dirty (void)
1782 { 1816 {
1783 basic_block bb; 1817 basic_block bb;
1784 FOR_ALL_BB (bb) 1818 FOR_ALL_BB (bb)
1785 bitmap_set_bit (df_live->out_of_date_transfer_functions, 1819 bitmap_set_bit (df_live->out_of_date_transfer_functions,
1786 bb->index); 1820 bb->index);
1787 } 1821 }
1788 1822
1789 1823
1790 /* Verify that all of the lr related info is consistent and 1824 /* Verify that all of the lr related info is consistent and
1815 if (bb_info) 1849 if (bb_info)
1816 { 1850 {
1817 /* Make a copy of the transfer functions and then compute 1851 /* Make a copy of the transfer functions and then compute
1818 new ones to see if the transfer functions have 1852 new ones to see if the transfer functions have
1819 changed. */ 1853 changed. */
1820 if (!bitmap_bit_p (df_live->out_of_date_transfer_functions, 1854 if (!bitmap_bit_p (df_live->out_of_date_transfer_functions,
1821 bb->index)) 1855 bb->index))
1822 { 1856 {
1823 bitmap_copy (saved_gen, bb_info->gen); 1857 bitmap_copy (saved_gen, bb_info->gen);
1824 bitmap_copy (saved_kill, bb_info->kill); 1858 bitmap_copy (saved_kill, bb_info->kill);
1825 bitmap_clear (bb_info->gen); 1859 bitmap_clear (bb_info->gen);
1833 else 1867 else
1834 { 1868 {
1835 /* If we do not have basic block info, the block must be in 1869 /* If we do not have basic block info, the block must be in
1836 the list of dirty blocks or else some one has added a 1870 the list of dirty blocks or else some one has added a
1837 block behind our backs. */ 1871 block behind our backs. */
1838 gcc_assert (bitmap_bit_p (df_live->out_of_date_transfer_functions, 1872 gcc_assert (bitmap_bit_p (df_live->out_of_date_transfer_functions,
1839 bb->index)); 1873 bb->index));
1840 } 1874 }
1841 /* Make sure no one created a block without following 1875 /* Make sure no one created a block without following
1842 procedures. */ 1876 procedures. */
1843 gcc_assert (df_scan_get_bb_info (bb->index)); 1877 gcc_assert (df_scan_get_bb_info (bb->index));
1844 } 1878 }
1845 1879
1846 /* Make sure there are no dirty bits in blocks that have been deleted. */ 1880 /* Make sure there are no dirty bits in blocks that have been deleted. */
1847 gcc_assert (!bitmap_intersect_compl_p (df_live->out_of_date_transfer_functions, 1881 gcc_assert (!bitmap_intersect_compl_p (df_live->out_of_date_transfer_functions,
1848 all_blocks)); 1882 all_blocks));
1849 BITMAP_FREE (saved_gen); 1883 BITMAP_FREE (saved_gen);
1850 BITMAP_FREE (saved_kill); 1884 BITMAP_FREE (saved_kill);
1851 BITMAP_FREE (all_blocks); 1885 BITMAP_FREE (all_blocks);
1852 } 1886 }
1853 1887
1869 struct df_link * 1903 struct df_link *
1870 df_chain_create (df_ref src, df_ref dst) 1904 df_chain_create (df_ref src, df_ref dst)
1871 { 1905 {
1872 struct df_link *head = DF_REF_CHAIN (src); 1906 struct df_link *head = DF_REF_CHAIN (src);
1873 struct df_link *link = (struct df_link *) pool_alloc (df_chain->block_pool); 1907 struct df_link *link = (struct df_link *) pool_alloc (df_chain->block_pool);
1874 1908
1875 DF_REF_CHAIN (src) = link; 1909 DF_REF_CHAIN (src) = link;
1876 link->next = head; 1910 link->next = head;
1877 link->ref = dst; 1911 link->ref = dst;
1878 return link; 1912 return link;
1879 } 1913 }
1880 1914
1881 1915
1882 /* Delete any du or ud chains that start at REF and point to 1916 /* Delete any du or ud chains that start at REF and point to
1883 TARGET. */ 1917 TARGET. */
1884 static void 1918 static void
1885 df_chain_unlink_1 (df_ref ref, df_ref target) 1919 df_chain_unlink_1 (df_ref ref, df_ref target)
1886 { 1920 {
1887 struct df_link *chain = DF_REF_CHAIN (ref); 1921 struct df_link *chain = DF_REF_CHAIN (ref);
1888 struct df_link *prev = NULL; 1922 struct df_link *prev = NULL;
1921 DF_REF_CHAIN (ref) = NULL; 1955 DF_REF_CHAIN (ref) = NULL;
1922 } 1956 }
1923 1957
1924 1958
1925 /* Copy the du or ud chain starting at FROM_REF and attach it to 1959 /* Copy the du or ud chain starting at FROM_REF and attach it to
1926 TO_REF. */ 1960 TO_REF. */
1927 1961
1928 void 1962 void
1929 df_chain_copy (df_ref to_ref, 1963 df_chain_copy (df_ref to_ref,
1930 struct df_link *from_ref) 1964 struct df_link *from_ref)
1931 { 1965 {
1932 while (from_ref) 1966 while (from_ref)
1933 { 1967 {
1934 df_chain_create (to_ref, from_ref->ref); 1968 df_chain_create (to_ref, from_ref->ref);
1943 df_chain_remove_problem (void) 1977 df_chain_remove_problem (void)
1944 { 1978 {
1945 bitmap_iterator bi; 1979 bitmap_iterator bi;
1946 unsigned int bb_index; 1980 unsigned int bb_index;
1947 1981
1948 /* Wholesale destruction of the old chains. */ 1982 /* Wholesale destruction of the old chains. */
1949 if (df_chain->block_pool) 1983 if (df_chain->block_pool)
1950 free_alloc_pool (df_chain->block_pool); 1984 free_alloc_pool (df_chain->block_pool);
1951 1985
1952 EXECUTE_IF_SET_IN_BITMAP (df_chain->out_of_date_transfer_functions, 0, bb_index, bi) 1986 EXECUTE_IF_SET_IN_BITMAP (df_chain->out_of_date_transfer_functions, 0, bb_index, bi)
1953 { 1987 {
1960 for (def_rec = df_get_artificial_defs (bb->index); *def_rec; def_rec++) 1994 for (def_rec = df_get_artificial_defs (bb->index); *def_rec; def_rec++)
1961 DF_REF_CHAIN (*def_rec) = NULL; 1995 DF_REF_CHAIN (*def_rec) = NULL;
1962 if (df_chain_problem_p (DF_UD_CHAIN)) 1996 if (df_chain_problem_p (DF_UD_CHAIN))
1963 for (use_rec = df_get_artificial_uses (bb->index); *use_rec; use_rec++) 1997 for (use_rec = df_get_artificial_uses (bb->index); *use_rec; use_rec++)
1964 DF_REF_CHAIN (*use_rec) = NULL; 1998 DF_REF_CHAIN (*use_rec) = NULL;
1965 1999
1966 FOR_BB_INSNS (bb, insn) 2000 FOR_BB_INSNS (bb, insn)
1967 { 2001 {
1968 unsigned int uid = INSN_UID (insn); 2002 unsigned int uid = INSN_UID (insn);
1969 2003
1970 if (INSN_P (insn)) 2004 if (INSN_P (insn))
1971 { 2005 {
1972 if (df_chain_problem_p (DF_DU_CHAIN)) 2006 if (df_chain_problem_p (DF_DU_CHAIN))
1973 for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++) 2007 for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
1974 DF_REF_CHAIN (*def_rec) = NULL; 2008 DF_REF_CHAIN (*def_rec) = NULL;
1999 } 2033 }
2000 2034
2001 2035
2002 /* Create def-use or use-def chains. */ 2036 /* Create def-use or use-def chains. */
2003 2037
2004 static void 2038 static void
2005 df_chain_alloc (bitmap all_blocks ATTRIBUTE_UNUSED) 2039 df_chain_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
2006 { 2040 {
2007 df_chain_remove_problem (); 2041 df_chain_remove_problem ();
2008 df_chain->block_pool = create_alloc_pool ("df_chain_block pool", 2042 df_chain->block_pool = create_alloc_pool ("df_chain_block pool",
2009 sizeof (struct df_link), 50); 2043 sizeof (struct df_link), 50);
2010 df_chain->optional_p = true; 2044 df_chain->optional_p = true;
2011 } 2045 }
2012 2046
2013 2047
2023 /* Create the chains for a list of USEs. */ 2057 /* Create the chains for a list of USEs. */
2024 2058
2025 static void 2059 static void
2026 df_chain_create_bb_process_use (bitmap local_rd, 2060 df_chain_create_bb_process_use (bitmap local_rd,
2027 df_ref *use_rec, 2061 df_ref *use_rec,
2028 enum df_ref_flags top_flag) 2062 int top_flag)
2029 { 2063 {
2030 bitmap_iterator bi; 2064 bitmap_iterator bi;
2031 unsigned int def_index; 2065 unsigned int def_index;
2032 2066
2033 while (*use_rec) 2067 while (*use_rec)
2034 { 2068 {
2035 df_ref use = *use_rec; 2069 df_ref use = *use_rec;
2036 unsigned int uregno = DF_REF_REGNO (use); 2070 unsigned int uregno = DF_REF_REGNO (use);
2037 if ((!(df->changeable_flags & DF_NO_HARD_REGS)) 2071 if ((!(df->changeable_flags & DF_NO_HARD_REGS))
2043 { 2077 {
2044 if (top_flag == (DF_REF_FLAGS (use) & DF_REF_AT_TOP)) 2078 if (top_flag == (DF_REF_FLAGS (use) & DF_REF_AT_TOP))
2045 { 2079 {
2046 unsigned int first_index = DF_DEFS_BEGIN (uregno); 2080 unsigned int first_index = DF_DEFS_BEGIN (uregno);
2047 unsigned int last_index = first_index + count - 1; 2081 unsigned int last_index = first_index + count - 1;
2048 2082
2049 EXECUTE_IF_SET_IN_BITMAP (local_rd, first_index, def_index, bi) 2083 EXECUTE_IF_SET_IN_BITMAP (local_rd, first_index, def_index, bi)
2050 { 2084 {
2051 df_ref def; 2085 df_ref def;
2052 if (def_index > last_index) 2086 if (def_index > last_index)
2053 break; 2087 break;
2054 2088
2055 def = DF_DEFS_GET (def_index); 2089 def = DF_DEFS_GET (def_index);
2056 if (df_chain_problem_p (DF_DU_CHAIN)) 2090 if (df_chain_problem_p (DF_DU_CHAIN))
2057 df_chain_create (def, use); 2091 df_chain_create (def, use);
2058 if (df_chain_problem_p (DF_UD_CHAIN)) 2092 if (df_chain_problem_p (DF_UD_CHAIN))
2059 df_chain_create (use, def); 2093 df_chain_create (use, def);
2074 { 2108 {
2075 basic_block bb = BASIC_BLOCK (bb_index); 2109 basic_block bb = BASIC_BLOCK (bb_index);
2076 struct df_rd_bb_info *bb_info = df_rd_get_bb_info (bb_index); 2110 struct df_rd_bb_info *bb_info = df_rd_get_bb_info (bb_index);
2077 rtx insn; 2111 rtx insn;
2078 bitmap cpy = BITMAP_ALLOC (NULL); 2112 bitmap cpy = BITMAP_ALLOC (NULL);
2079 df_ref *def_rec;
2080 2113
2081 bitmap_copy (cpy, bb_info->in); 2114 bitmap_copy (cpy, bb_info->in);
2082 bitmap_set_bit (df_chain->out_of_date_transfer_functions, bb_index); 2115 bitmap_set_bit (df_chain->out_of_date_transfer_functions, bb_index);
2083 2116
2084 /* Since we are going forwards, process the artificial uses first 2117 /* Since we are going forwards, process the artificial uses first
2085 then the artificial defs second. */ 2118 then the artificial defs second. */
2086 2119
2087 #ifdef EH_USES 2120 #ifdef EH_USES
2088 /* Create the chains for the artificial uses from the EH_USES at the 2121 /* Create the chains for the artificial uses from the EH_USES at the
2089 beginning of the block. */ 2122 beginning of the block. */
2090 2123
2091 /* Artificials are only hard regs. */ 2124 /* Artificials are only hard regs. */
2092 if (!(df->changeable_flags & DF_NO_HARD_REGS)) 2125 if (!(df->changeable_flags & DF_NO_HARD_REGS))
2093 df_chain_create_bb_process_use (cpy, 2126 df_chain_create_bb_process_use (cpy,
2094 df_get_artificial_uses (bb->index), 2127 df_get_artificial_uses (bb->index),
2095 DF_REF_AT_TOP); 2128 DF_REF_AT_TOP);
2096 #endif 2129 #endif
2097 2130
2098 for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++) 2131 df_rd_simulate_artificial_defs_at_top (bb, cpy);
2099 { 2132
2100 df_ref def = *def_rec;
2101 if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
2102 {
2103 unsigned int dregno = DF_REF_REGNO (def);
2104 if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
2105 bitmap_clear_range (cpy,
2106 DF_DEFS_BEGIN (dregno),
2107 DF_DEFS_COUNT (dregno));
2108 bitmap_set_bit (cpy, DF_REF_ID (def));
2109 }
2110 }
2111
2112 /* Process the regular instructions next. */ 2133 /* Process the regular instructions next. */
2113 FOR_BB_INSNS (bb, insn) 2134 FOR_BB_INSNS (bb, insn)
2114 { 2135 if (INSN_P (insn))
2115 df_ref *def_rec; 2136 {
2116 unsigned int uid = INSN_UID (insn); 2137 unsigned int uid = INSN_UID (insn);
2117 2138
2118 if (!INSN_P (insn)) 2139 /* First scan the uses and link them up with the defs that remain
2119 continue; 2140 in the cpy vector. */
2120 2141 df_chain_create_bb_process_use (cpy, DF_INSN_UID_USES (uid), 0);
2121 /* Now scan the uses and link them up with the defs that remain 2142 if (df->changeable_flags & DF_EQ_NOTES)
2122 in the cpy vector. */ 2143 df_chain_create_bb_process_use (cpy, DF_INSN_UID_EQ_USES (uid), 0);
2123 2144
2124 df_chain_create_bb_process_use (cpy, DF_INSN_UID_USES (uid), 0); 2145 /* Since we are going forwards, process the defs second. */
2125 2146 df_rd_simulate_one_insn (bb, insn, cpy);
2126 if (df->changeable_flags & DF_EQ_NOTES) 2147 }
2127 df_chain_create_bb_process_use (cpy, DF_INSN_UID_EQ_USES (uid), 0);
2128
2129
2130 /* Since we are going forwards, process the defs second. This
2131 pass only changes the bits in cpy. */
2132 for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
2133 {
2134 df_ref def = *def_rec;
2135 unsigned int dregno = DF_REF_REGNO (def);
2136 if ((!(df->changeable_flags & DF_NO_HARD_REGS))
2137 || (dregno >= FIRST_PSEUDO_REGISTER))
2138 {
2139 if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
2140 bitmap_clear_range (cpy,
2141 DF_DEFS_BEGIN (dregno),
2142 DF_DEFS_COUNT (dregno));
2143 if (!(DF_REF_FLAGS (def)
2144 & (DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER)))
2145 bitmap_set_bit (cpy, DF_REF_ID (def));
2146 }
2147 }
2148 }
2149 2148
2150 /* Create the chains for the artificial uses of the hard registers 2149 /* Create the chains for the artificial uses of the hard registers
2151 at the end of the block. */ 2150 at the end of the block. */
2152 if (!(df->changeable_flags & DF_NO_HARD_REGS)) 2151 if (!(df->changeable_flags & DF_NO_HARD_REGS))
2153 df_chain_create_bb_process_use (cpy, 2152 df_chain_create_bb_process_use (cpy,
2154 df_get_artificial_uses (bb->index), 2153 df_get_artificial_uses (bb->index),
2155 0); 2154 0);
2156 2155
2157 BITMAP_FREE (cpy); 2156 BITMAP_FREE (cpy);
2158 } 2157 }
2159 2158
2163 static void 2162 static void
2164 df_chain_finalize (bitmap all_blocks) 2163 df_chain_finalize (bitmap all_blocks)
2165 { 2164 {
2166 unsigned int bb_index; 2165 unsigned int bb_index;
2167 bitmap_iterator bi; 2166 bitmap_iterator bi;
2168 2167
2169 EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi) 2168 EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
2170 { 2169 {
2171 df_chain_create_bb (bb_index); 2170 df_chain_create_bb (bb_index);
2172 } 2171 }
2173 } 2172 }
2193 { 2192 {
2194 rtx insn; 2193 rtx insn;
2195 df_ref *def_rec = df_get_artificial_defs (bb->index); 2194 df_ref *def_rec = df_get_artificial_defs (bb->index);
2196 if (*def_rec) 2195 if (*def_rec)
2197 { 2196 {
2198 2197
2199 fprintf (file, ";; DU chains for artificial defs\n"); 2198 fprintf (file, ";; DU chains for artificial defs\n");
2200 while (*def_rec) 2199 while (*def_rec)
2201 { 2200 {
2202 df_ref def = *def_rec; 2201 df_ref def = *def_rec;
2203 fprintf (file, ";; reg %d ", DF_REF_REGNO (def)); 2202 fprintf (file, ";; reg %d ", DF_REF_REGNO (def));
2204 df_chain_dump (DF_REF_CHAIN (def), file); 2203 df_chain_dump (DF_REF_CHAIN (def), file);
2205 fprintf (file, "\n"); 2204 fprintf (file, "\n");
2206 def_rec++; 2205 def_rec++;
2207 } 2206 }
2208 } 2207 }
2209 2208
2210 FOR_BB_INSNS (bb, insn) 2209 FOR_BB_INSNS (bb, insn)
2211 { 2210 {
2212 if (INSN_P (insn)) 2211 if (INSN_P (insn))
2213 { 2212 {
2214 struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn); 2213 struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
2215 def_rec = DF_INSN_INFO_DEFS (insn_info); 2214 def_rec = DF_INSN_INFO_DEFS (insn_info);
2216 if (*def_rec) 2215 if (*def_rec)
2217 { 2216 {
2218 fprintf (file, ";; DU chains for insn luid %d uid %d\n", 2217 fprintf (file, ";; DU chains for insn luid %d uid %d\n",
2219 DF_INSN_INFO_LUID (insn_info), INSN_UID (insn)); 2218 DF_INSN_INFO_LUID (insn_info), INSN_UID (insn));
2220 2219
2221 while (*def_rec) 2220 while (*def_rec)
2222 { 2221 {
2223 df_ref def = *def_rec; 2222 df_ref def = *def_rec;
2224 fprintf (file, ";; reg %d ", DF_REF_REGNO (def)); 2223 fprintf (file, ";; reg %d ", DF_REF_REGNO (def));
2225 if (DF_REF_FLAGS (def) & DF_REF_READ_WRITE) 2224 if (DF_REF_FLAGS (def) & DF_REF_READ_WRITE)
2252 fprintf (file, ";; reg %d ", DF_REF_REGNO (use)); 2251 fprintf (file, ";; reg %d ", DF_REF_REGNO (use));
2253 df_chain_dump (DF_REF_CHAIN (use), file); 2252 df_chain_dump (DF_REF_CHAIN (use), file);
2254 fprintf (file, "\n"); 2253 fprintf (file, "\n");
2255 use_rec++; 2254 use_rec++;
2256 } 2255 }
2257 } 2256 }
2258 2257
2259 FOR_BB_INSNS (bb, insn) 2258 FOR_BB_INSNS (bb, insn)
2260 { 2259 {
2261 if (INSN_P (insn)) 2260 if (INSN_P (insn))
2262 { 2261 {
2263 struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn); 2262 struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
2264 df_ref *eq_use_rec = DF_INSN_INFO_EQ_USES (insn_info); 2263 df_ref *eq_use_rec = DF_INSN_INFO_EQ_USES (insn_info);
2265 use_rec = DF_INSN_INFO_USES (insn_info); 2264 use_rec = DF_INSN_INFO_USES (insn_info);
2266 if (*use_rec || *eq_use_rec) 2265 if (*use_rec || *eq_use_rec)
2267 { 2266 {
2268 fprintf (file, ";; UD chains for insn luid %d uid %d\n", 2267 fprintf (file, ";; UD chains for insn luid %d uid %d\n",
2269 DF_INSN_INFO_LUID (insn_info), INSN_UID (insn)); 2268 DF_INSN_INFO_LUID (insn_info), INSN_UID (insn));
2270 2269
2271 while (*use_rec) 2270 while (*use_rec)
2272 { 2271 {
2273 df_ref use = *use_rec; 2272 df_ref use = *use_rec;
2274 fprintf (file, ";; reg %d ", DF_REF_REGNO (use)); 2273 fprintf (file, ";; reg %d ", DF_REF_REGNO (use));
2275 if (DF_REF_FLAGS (use) & DF_REF_READ_WRITE) 2274 if (DF_REF_FLAGS (use) & DF_REF_READ_WRITE)
2301 df_chain_reset, /* Reset global information. */ 2300 df_chain_reset, /* Reset global information. */
2302 NULL, /* Free basic block info. */ 2301 NULL, /* Free basic block info. */
2303 NULL, /* Local compute function. */ 2302 NULL, /* Local compute function. */
2304 NULL, /* Init the solution specific data. */ 2303 NULL, /* Init the solution specific data. */
2305 NULL, /* Iterative solver. */ 2304 NULL, /* Iterative solver. */
2306 NULL, /* Confluence operator 0. */ 2305 NULL, /* Confluence operator 0. */
2307 NULL, /* Confluence operator n. */ 2306 NULL, /* Confluence operator n. */
2308 NULL, /* Transfer function. */ 2307 NULL, /* Transfer function. */
2309 df_chain_finalize, /* Finalize function. */ 2308 df_chain_finalize, /* Finalize function. */
2310 df_chain_free, /* Free all of the problem information. */ 2309 df_chain_free, /* Free all of the problem information. */
2311 df_chain_fully_remove_problem,/* Remove this problem from the stack of dataflow problems. */ 2310 df_chain_fully_remove_problem,/* Remove this problem from the stack of dataflow problems. */
2312 NULL, /* Debugging. */ 2311 NULL, /* Debugging. */
2323 /* Create a new DATAFLOW instance and add it to an existing instance 2322 /* Create a new DATAFLOW instance and add it to an existing instance
2324 of DF. The returned structure is what is used to get at the 2323 of DF. The returned structure is what is used to get at the
2325 solution. */ 2324 solution. */
2326 2325
2327 void 2326 void
2328 df_chain_add_problem (enum df_chain_flags chain_flags) 2327 df_chain_add_problem (unsigned int chain_flags)
2329 { 2328 {
2330 df_add_problem (&problem_CHAIN); 2329 df_add_problem (&problem_CHAIN);
2331 df_chain->local_flags = (unsigned int)chain_flags; 2330 df_chain->local_flags = chain_flags;
2332 df_chain->out_of_date_transfer_functions = BITMAP_ALLOC (NULL); 2331 df_chain->out_of_date_transfer_functions = BITMAP_ALLOC (NULL);
2333 } 2332 }
2334 2333
2335 #undef df_chain_problem_p 2334 #undef df_chain_problem_p
2336 2335
2375 /* Indexed by regno, this is true if there are subregs, extracts or 2374 /* Indexed by regno, this is true if there are subregs, extracts or
2376 strict_low_parts for this regno. */ 2375 strict_low_parts for this regno. */
2377 bitmap needs_expansion; 2376 bitmap needs_expansion;
2378 2377
2379 /* The start position and len for each regno in the various bit 2378 /* The start position and len for each regno in the various bit
2380 vectors. */ 2379 vectors. */
2381 unsigned int* regno_start; 2380 unsigned int* regno_start;
2382 unsigned int* regno_len; 2381 unsigned int* regno_len;
2383 /* An obstack for the bitmaps we need for this problem. */ 2382 /* An obstack for the bitmaps we need for this problem. */
2384 bitmap_obstack byte_lr_bitmaps; 2383 bitmap_obstack byte_lr_bitmaps;
2385 }; 2384 };
2386 2385
2387 2386
2388 /* Get the starting location for REGNO in the df_byte_lr bitmaps. */ 2387 /* Get the starting location for REGNO in the df_byte_lr bitmaps. */
2389 2388
2390 int 2389 int
2391 df_byte_lr_get_regno_start (unsigned int regno) 2390 df_byte_lr_get_regno_start (unsigned int regno)
2392 { 2391 {
2393 struct df_byte_lr_problem_data *problem_data 2392 struct df_byte_lr_problem_data *problem_data
2394 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data;; 2393 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data;;
2395 return problem_data->regno_start[regno]; 2394 return problem_data->regno_start[regno];
2396 } 2395 }
2397 2396
2398 2397
2399 /* Get the len for REGNO in the df_byte_lr bitmaps. */ 2398 /* Get the len for REGNO in the df_byte_lr bitmaps. */
2400 2399
2401 int 2400 int
2402 df_byte_lr_get_regno_len (unsigned int regno) 2401 df_byte_lr_get_regno_len (unsigned int regno)
2403 { 2402 {
2404 struct df_byte_lr_problem_data *problem_data 2403 struct df_byte_lr_problem_data *problem_data
2405 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data;; 2404 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data;;
2406 return problem_data->regno_len[regno]; 2405 return problem_data->regno_len[regno];
2407 } 2406 }
2408 2407
2409 2408
2410 /* Set basic block info. */ 2409 /* Set basic block info. */
2411 2410
2412 static void 2411 static void
2413 df_byte_lr_set_bb_info (unsigned int index, 2412 df_byte_lr_set_bb_info (unsigned int index,
2414 struct df_byte_lr_bb_info *bb_info) 2413 struct df_byte_lr_bb_info *bb_info)
2415 { 2414 {
2416 gcc_assert (df_byte_lr); 2415 gcc_assert (df_byte_lr);
2417 gcc_assert (index < df_byte_lr->block_info_size); 2416 gcc_assert (index < df_byte_lr->block_info_size);
2418 df_byte_lr->block_info[index] = bb_info; 2417 df_byte_lr->block_info[index] = bb_info;
2419 } 2418 }
2420 2419
2421 2420
2422 /* Free basic block info. */ 2421 /* Free basic block info. */
2423 2422
2424 static void 2423 static void
2425 df_byte_lr_free_bb_info (basic_block bb ATTRIBUTE_UNUSED, 2424 df_byte_lr_free_bb_info (basic_block bb ATTRIBUTE_UNUSED,
2426 void *vbb_info) 2425 void *vbb_info)
2427 { 2426 {
2428 struct df_byte_lr_bb_info *bb_info = (struct df_byte_lr_bb_info *) vbb_info; 2427 struct df_byte_lr_bb_info *bb_info = (struct df_byte_lr_bb_info *) vbb_info;
2429 if (bb_info) 2428 if (bb_info)
2430 { 2429 {
2441 extracts, subregs or strict_low_parts. */ 2440 extracts, subregs or strict_low_parts. */
2442 2441
2443 static void 2442 static void
2444 df_byte_lr_check_regs (df_ref *ref_rec) 2443 df_byte_lr_check_regs (df_ref *ref_rec)
2445 { 2444 {
2446 struct df_byte_lr_problem_data *problem_data 2445 struct df_byte_lr_problem_data *problem_data
2447 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data; 2446 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data;
2448 2447
2449 for (; *ref_rec; ref_rec++) 2448 for (; *ref_rec; ref_rec++)
2450 { 2449 {
2451 df_ref ref = *ref_rec; 2450 df_ref ref = *ref_rec;
2452 if (DF_REF_FLAGS_IS_SET (ref, DF_REF_SIGN_EXTRACT 2451 if (DF_REF_FLAGS_IS_SET (ref, DF_REF_SIGN_EXTRACT
2453 | DF_REF_ZERO_EXTRACT 2452 | DF_REF_ZERO_EXTRACT
2454 | DF_REF_STRICT_LOW_PART) 2453 | DF_REF_STRICT_LOW_PART)
2455 || GET_CODE (DF_REF_REG (ref)) == SUBREG) 2454 || GET_CODE (DF_REF_REG (ref)) == SUBREG)
2456 bitmap_set_bit (problem_data->needs_expansion, DF_REF_REGNO (ref)); 2455 bitmap_set_bit (problem_data->needs_expansion, DF_REF_REGNO (ref));
2457 } 2456 }
2458 } 2457 }
2459 2458
2460 2459
2461 /* Expand bitmap SRC which is indexed by regno to DEST which is indexed by 2460 /* Expand bitmap SRC which is indexed by regno to DEST which is indexed by
2462 regno_start and regno_len. */ 2461 regno_start and regno_len. */
2463 2462
2464 static void 2463 static void
2465 df_byte_lr_expand_bitmap (bitmap dest, bitmap src) 2464 df_byte_lr_expand_bitmap (bitmap dest, bitmap src)
2466 { 2465 {
2467 struct df_byte_lr_problem_data *problem_data 2466 struct df_byte_lr_problem_data *problem_data
2468 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data; 2467 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data;
2469 bitmap_iterator bi; 2468 bitmap_iterator bi;
2470 unsigned int i; 2469 unsigned int i;
2471 2470
2472 bitmap_clear (dest); 2471 bitmap_clear (dest);
2473 EXECUTE_IF_SET_IN_BITMAP (src, 0, i, bi) 2472 EXECUTE_IF_SET_IN_BITMAP (src, 0, i, bi)
2474 { 2473 {
2475 bitmap_set_range (dest, problem_data->regno_start[i], 2474 bitmap_set_range (dest, problem_data->regno_start[i],
2476 problem_data->regno_len[i]); 2475 problem_data->regno_len[i]);
2477 } 2476 }
2478 } 2477 }
2479 2478
2480 2479
2481 /* Allocate or reset bitmaps for DF_BYTE_LR blocks. The solution bits are 2480 /* Allocate or reset bitmaps for DF_BYTE_LR blocks. The solution bits are
2482 not touched unless the block is new. */ 2481 not touched unless the block is new. */
2483 2482
2484 static void 2483 static void
2485 df_byte_lr_alloc (bitmap all_blocks ATTRIBUTE_UNUSED) 2484 df_byte_lr_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
2486 { 2485 {
2487 unsigned int bb_index; 2486 unsigned int bb_index;
2488 bitmap_iterator bi; 2487 bitmap_iterator bi;
2489 basic_block bb; 2488 basic_block bb;
2490 unsigned int regno; 2489 unsigned int regno;
2491 unsigned int index = 0; 2490 unsigned int index = 0;
2492 unsigned int max_reg = max_reg_num(); 2491 unsigned int max_reg = max_reg_num();
2493 struct df_byte_lr_problem_data *problem_data 2492 struct df_byte_lr_problem_data *problem_data
2494 = problem_data = XNEW (struct df_byte_lr_problem_data); 2493 = XNEW (struct df_byte_lr_problem_data);
2495 2494
2496 df_byte_lr->problem_data = problem_data; 2495 df_byte_lr->problem_data = problem_data;
2497 2496
2498 if (!df_byte_lr->block_pool) 2497 if (!df_byte_lr->block_pool)
2499 df_byte_lr->block_pool = create_alloc_pool ("df_byte_lr_block pool", 2498 df_byte_lr->block_pool = create_alloc_pool ("df_byte_lr_block pool",
2500 sizeof (struct df_byte_lr_bb_info), 50); 2499 sizeof (struct df_byte_lr_bb_info), 50);
2501 2500
2502 df_grow_bb_info (df_byte_lr); 2501 df_grow_bb_info (df_byte_lr);
2503 2502
2504 /* Create the mapping from regnos to slots. This does not change 2503 /* Create the mapping from regnos to slots. This does not change
2511 problem_data->regno_start = XNEWVEC (unsigned int, max_reg); 2510 problem_data->regno_start = XNEWVEC (unsigned int, max_reg);
2512 problem_data->regno_len = XNEWVEC (unsigned int, max_reg); 2511 problem_data->regno_len = XNEWVEC (unsigned int, max_reg);
2513 problem_data->hardware_regs_used = BITMAP_ALLOC (&problem_data->byte_lr_bitmaps); 2512 problem_data->hardware_regs_used = BITMAP_ALLOC (&problem_data->byte_lr_bitmaps);
2514 problem_data->invalidated_by_call = BITMAP_ALLOC (&problem_data->byte_lr_bitmaps); 2513 problem_data->invalidated_by_call = BITMAP_ALLOC (&problem_data->byte_lr_bitmaps);
2515 problem_data->needs_expansion = BITMAP_ALLOC (&problem_data->byte_lr_bitmaps); 2514 problem_data->needs_expansion = BITMAP_ALLOC (&problem_data->byte_lr_bitmaps);
2516 2515
2517 /* Discover which regno's use subregs, extracts or 2516 /* Discover which regno's use subregs, extracts or
2518 strict_low_parts. */ 2517 strict_low_parts. */
2519 FOR_EACH_BB (bb) 2518 FOR_EACH_BB (bb)
2520 { 2519 {
2521 rtx insn; 2520 rtx insn;
2531 bitmap_set_bit (df_byte_lr->out_of_date_transfer_functions, bb->index); 2530 bitmap_set_bit (df_byte_lr->out_of_date_transfer_functions, bb->index);
2532 } 2531 }
2533 2532
2534 bitmap_set_bit (df_byte_lr->out_of_date_transfer_functions, ENTRY_BLOCK); 2533 bitmap_set_bit (df_byte_lr->out_of_date_transfer_functions, ENTRY_BLOCK);
2535 bitmap_set_bit (df_byte_lr->out_of_date_transfer_functions, EXIT_BLOCK); 2534 bitmap_set_bit (df_byte_lr->out_of_date_transfer_functions, EXIT_BLOCK);
2536 2535
2537 /* Allocate the slots for each regno. */ 2536 /* Allocate the slots for each regno. */
2538 for (regno = 0; regno < max_reg; regno++) 2537 for (regno = 0; regno < max_reg; regno++)
2539 { 2538 {
2540 int len; 2539 int len;
2541 problem_data->regno_start[regno] = index; 2540 problem_data->regno_start[regno] = index;
2542 if (bitmap_bit_p (problem_data->needs_expansion, regno)) 2541 if (bitmap_bit_p (problem_data->needs_expansion, regno))
2543 len = GET_MODE_SIZE (GET_MODE (regno_reg_rtx[regno])); 2542 len = GET_MODE_SIZE (GET_MODE (regno_reg_rtx[regno]));
2544 else 2543 else
2545 len = 1; 2544 len = 1;
2546 2545
2547 problem_data->regno_len[regno] = len; 2546 problem_data->regno_len[regno] = len;
2548 index += len; 2547 index += len;
2549 } 2548 }
2550 2549
2551 df_byte_lr_expand_bitmap (problem_data->hardware_regs_used, 2550 df_byte_lr_expand_bitmap (problem_data->hardware_regs_used,
2552 df->hardware_regs_used); 2551 df->hardware_regs_used);
2553 df_byte_lr_expand_bitmap (problem_data->invalidated_by_call, 2552 df_byte_lr_expand_bitmap (problem_data->invalidated_by_call,
2554 regs_invalidated_by_call_regset); 2553 regs_invalidated_by_call_regset);
2555 2554
2556 EXECUTE_IF_SET_IN_BITMAP (df_byte_lr->out_of_date_transfer_functions, 0, bb_index, bi) 2555 EXECUTE_IF_SET_IN_BITMAP (df_byte_lr->out_of_date_transfer_functions, 0, bb_index, bi)
2557 { 2556 {
2558 struct df_byte_lr_bb_info *bb_info = df_byte_lr_get_bb_info (bb_index); 2557 struct df_byte_lr_bb_info *bb_info = df_byte_lr_get_bb_info (bb_index);
2559 if (bb_info) 2558 if (bb_info)
2560 { 2559 {
2561 bitmap_clear (bb_info->def); 2560 bitmap_clear (bb_info->def);
2562 bitmap_clear (bb_info->use); 2561 bitmap_clear (bb_info->use);
2563 } 2562 }
2564 else 2563 else
2565 { 2564 {
2566 bb_info = (struct df_byte_lr_bb_info *) pool_alloc (df_byte_lr->block_pool); 2565 bb_info = (struct df_byte_lr_bb_info *) pool_alloc (df_byte_lr->block_pool);
2567 df_byte_lr_set_bb_info (bb_index, bb_info); 2566 df_byte_lr_set_bb_info (bb_index, bb_info);
2568 bb_info->use = BITMAP_ALLOC (&problem_data->byte_lr_bitmaps); 2567 bb_info->use = BITMAP_ALLOC (&problem_data->byte_lr_bitmaps);
2569 bb_info->def = BITMAP_ALLOC (&problem_data->byte_lr_bitmaps); 2568 bb_info->def = BITMAP_ALLOC (&problem_data->byte_lr_bitmaps);
2570 bb_info->in = BITMAP_ALLOC (&problem_data->byte_lr_bitmaps); 2569 bb_info->in = BITMAP_ALLOC (&problem_data->byte_lr_bitmaps);
2571 bb_info->out = BITMAP_ALLOC (&problem_data->byte_lr_bitmaps); 2570 bb_info->out = BITMAP_ALLOC (&problem_data->byte_lr_bitmaps);
2572 } 2571 }
2573 } 2572 }
2574 2573
2575 df_byte_lr->optional_p = true; 2574 df_byte_lr->optional_p = true;
2576 } 2575 }
2577 2576
2578 2577
2579 /* Reset the global solution for recalculation. */ 2578 /* Reset the global solution for recalculation. */
2580 2579
2581 static void 2580 static void
2582 df_byte_lr_reset (bitmap all_blocks) 2581 df_byte_lr_reset (bitmap all_blocks)
2583 { 2582 {
2584 unsigned int bb_index; 2583 unsigned int bb_index;
2585 bitmap_iterator bi; 2584 bitmap_iterator bi;
2586 2585
2597 /* Compute local live register info for basic block BB. */ 2596 /* Compute local live register info for basic block BB. */
2598 2597
2599 static void 2598 static void
2600 df_byte_lr_bb_local_compute (unsigned int bb_index) 2599 df_byte_lr_bb_local_compute (unsigned int bb_index)
2601 { 2600 {
2602 struct df_byte_lr_problem_data *problem_data 2601 struct df_byte_lr_problem_data *problem_data
2603 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data; 2602 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data;
2604 basic_block bb = BASIC_BLOCK (bb_index); 2603 basic_block bb = BASIC_BLOCK (bb_index);
2605 struct df_byte_lr_bb_info *bb_info = df_byte_lr_get_bb_info (bb_index); 2604 struct df_byte_lr_bb_info *bb_info = df_byte_lr_get_bb_info (bb_index);
2606 rtx insn; 2605 rtx insn;
2607 df_ref *def_rec; 2606 df_ref *def_rec;
2638 FOR_BB_INSNS_REVERSE (bb, insn) 2637 FOR_BB_INSNS_REVERSE (bb, insn)
2639 { 2638 {
2640 unsigned int uid = INSN_UID (insn); 2639 unsigned int uid = INSN_UID (insn);
2641 2640
2642 if (!INSN_P (insn)) 2641 if (!INSN_P (insn))
2643 continue; 2642 continue;
2644 2643
2645 for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++) 2644 for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
2646 { 2645 {
2647 df_ref def = *def_rec; 2646 df_ref def = *def_rec;
2648 /* If the def is to only part of the reg, it does 2647 /* If the def is to only part of the reg, it does
2699 unsigned int len = problem_data->regno_len[dregno]; 2698 unsigned int len = problem_data->regno_len[dregno];
2700 bitmap_set_range (bb_info->def, start, len); 2699 bitmap_set_range (bb_info->def, start, len);
2701 bitmap_clear_range (bb_info->use, start, len); 2700 bitmap_clear_range (bb_info->use, start, len);
2702 } 2701 }
2703 } 2702 }
2704 2703
2705 #ifdef EH_USES 2704 #ifdef EH_USES
2706 /* Process the uses that are live into an exception handler. */ 2705 /* Process the uses that are live into an exception handler. */
2707 for (use_rec = df_get_artificial_uses (bb_index); *use_rec; use_rec++) 2706 for (use_rec = df_get_artificial_uses (bb_index); *use_rec; use_rec++)
2708 { 2707 {
2709 df_ref use = *use_rec; 2708 df_ref use = *use_rec;
2745 } 2744 }
2746 2745
2747 2746
2748 /* Initialize the solution vectors. */ 2747 /* Initialize the solution vectors. */
2749 2748
2750 static void 2749 static void
2751 df_byte_lr_init (bitmap all_blocks) 2750 df_byte_lr_init (bitmap all_blocks)
2752 { 2751 {
2753 unsigned int bb_index; 2752 unsigned int bb_index;
2754 bitmap_iterator bi; 2753 bitmap_iterator bi;
2755 2754
2766 noreturn function that throws. And even if it isn't, getting the 2765 noreturn function that throws. And even if it isn't, getting the
2767 unwind info right helps debugging. */ 2766 unwind info right helps debugging. */
2768 static void 2767 static void
2769 df_byte_lr_confluence_0 (basic_block bb) 2768 df_byte_lr_confluence_0 (basic_block bb)
2770 { 2769 {
2771 struct df_byte_lr_problem_data *problem_data 2770 struct df_byte_lr_problem_data *problem_data
2772 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data; 2771 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data;
2773 bitmap op1 = df_byte_lr_get_bb_info (bb->index)->out; 2772 bitmap op1 = df_byte_lr_get_bb_info (bb->index)->out;
2774 if (bb != EXIT_BLOCK_PTR) 2773 if (bb != EXIT_BLOCK_PTR)
2775 bitmap_copy (op1, problem_data->hardware_regs_used); 2774 bitmap_copy (op1, problem_data->hardware_regs_used);
2776 } 2775 }
2777 2776
2778 2777
2779 /* Confluence function that ignores fake edges. */ 2778 /* Confluence function that ignores fake edges. */
2780 2779
2781 static void 2780 static void
2782 df_byte_lr_confluence_n (edge e) 2781 df_byte_lr_confluence_n (edge e)
2783 { 2782 {
2784 struct df_byte_lr_problem_data *problem_data 2783 struct df_byte_lr_problem_data *problem_data
2785 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data; 2784 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data;
2786 bitmap op1 = df_byte_lr_get_bb_info (e->src->index)->out; 2785 bitmap op1 = df_byte_lr_get_bb_info (e->src->index)->out;
2787 bitmap op2 = df_byte_lr_get_bb_info (e->dest->index)->in; 2786 bitmap op2 = df_byte_lr_get_bb_info (e->dest->index)->in;
2788 2787
2789 /* Call-clobbered registers die across exception and call edges. */ 2788 /* Call-clobbered registers die across exception and call edges. */
2790 /* ??? Abnormal call edges ignored for the moment, as this gets 2789 /* ??? Abnormal call edges ignored for the moment, as this gets
2791 confused by sibling call edges, which crashes reg-stack. */ 2790 confused by sibling call edges, which crashes reg-stack. */
2792 if (e->flags & EDGE_EH) 2791 if (e->flags & EDGE_EH)
2793 bitmap_ior_and_compl_into (op1, op2, problem_data->invalidated_by_call); 2792 bitmap_ior_and_compl_into (op1, op2, problem_data->invalidated_by_call);
2794 else 2793 else
2795 bitmap_ior_into (op1, op2); 2794 bitmap_ior_into (op1, op2);
2796 2795
2797 bitmap_ior_into (op1, problem_data->hardware_regs_used); 2796 bitmap_ior_into (op1, problem_data->hardware_regs_used);
2798 } 2797 }
2799 2798
2800 2799
2801 /* Transfer function. */ 2800 /* Transfer function. */
2802 2801
2803 static bool 2802 static bool
2844 df_byte_lr_top_dump (basic_block bb, FILE *file) 2843 df_byte_lr_top_dump (basic_block bb, FILE *file)
2845 { 2844 {
2846 struct df_byte_lr_bb_info *bb_info = df_byte_lr_get_bb_info (bb->index); 2845 struct df_byte_lr_bb_info *bb_info = df_byte_lr_get_bb_info (bb->index);
2847 if (!bb_info || !bb_info->in) 2846 if (!bb_info || !bb_info->in)
2848 return; 2847 return;
2849 2848
2850 fprintf (file, ";; blr in \t"); 2849 fprintf (file, ";; blr in \t");
2851 df_print_byte_regset (file, bb_info->in); 2850 df_print_byte_regset (file, bb_info->in);
2852 fprintf (file, ";; blr use \t"); 2851 fprintf (file, ";; blr use \t");
2853 df_print_byte_regset (file, bb_info->use); 2852 df_print_byte_regset (file, bb_info->use);
2854 fprintf (file, ";; blr def \t"); 2853 fprintf (file, ";; blr def \t");
2855 df_print_byte_regset (file, bb_info->def); 2854 df_print_byte_regset (file, bb_info->def);
2856 } 2855 }
2857 2856
2858 2857
2859 /* Debugging info at bottom of bb. */ 2858 /* Debugging info at bottom of bb. */
2860 2859
2861 static void 2860 static void
2862 df_byte_lr_bottom_dump (basic_block bb, FILE *file) 2861 df_byte_lr_bottom_dump (basic_block bb, FILE *file)
2863 { 2862 {
2864 struct df_byte_lr_bb_info *bb_info = df_byte_lr_get_bb_info (bb->index); 2863 struct df_byte_lr_bb_info *bb_info = df_byte_lr_get_bb_info (bb->index);
2865 if (!bb_info || !bb_info->out) 2864 if (!bb_info || !bb_info->out)
2866 return; 2865 return;
2867 2866
2868 fprintf (file, ";; blr out \t"); 2867 fprintf (file, ";; blr out \t");
2869 df_print_byte_regset (file, bb_info->out); 2868 df_print_byte_regset (file, bb_info->out);
2870 } 2869 }
2871 2870
2872 2871
2873 /* All of the information associated with every instance of the problem. */ 2872 /* All of the information associated with every instance of the problem. */
2874 2873
2875 static struct df_problem problem_BYTE_LR = 2874 static struct df_problem problem_BYTE_LR =
2880 df_byte_lr_reset, /* Reset global information. */ 2879 df_byte_lr_reset, /* Reset global information. */
2881 df_byte_lr_free_bb_info, /* Free basic block info. */ 2880 df_byte_lr_free_bb_info, /* Free basic block info. */
2882 df_byte_lr_local_compute, /* Local compute function. */ 2881 df_byte_lr_local_compute, /* Local compute function. */
2883 df_byte_lr_init, /* Init the solution specific data. */ 2882 df_byte_lr_init, /* Init the solution specific data. */
2884 df_worklist_dataflow, /* Worklist solver. */ 2883 df_worklist_dataflow, /* Worklist solver. */
2885 df_byte_lr_confluence_0, /* Confluence operator 0. */ 2884 df_byte_lr_confluence_0, /* Confluence operator 0. */
2886 df_byte_lr_confluence_n, /* Confluence operator n. */ 2885 df_byte_lr_confluence_n, /* Confluence operator n. */
2887 df_byte_lr_transfer_function, /* Transfer function. */ 2886 df_byte_lr_transfer_function, /* Transfer function. */
2888 NULL, /* Finalize function. */ 2887 NULL, /* Finalize function. */
2889 df_byte_lr_free, /* Free all of the problem information. */ 2888 df_byte_lr_free, /* Free all of the problem information. */
2890 df_byte_lr_free, /* Remove this problem from the stack of dataflow problems. */ 2889 df_byte_lr_free, /* Remove this problem from the stack of dataflow problems. */
2891 NULL, /* Debugging. */ 2890 NULL, /* Debugging. */
2892 df_byte_lr_top_dump, /* Debugging start block. */ 2891 df_byte_lr_top_dump, /* Debugging start block. */
2893 df_byte_lr_bottom_dump, /* Debugging end block. */ 2892 df_byte_lr_bottom_dump, /* Debugging end block. */
2894 NULL, /* Incremental solution verify start. */ 2893 NULL, /* Incremental solution verify start. */
2895 NULL, /* Incremental solution verify end. */ 2894 NULL, /* Incremental solution verify end. */
2896 NULL, /* Dependent problem. */ 2895 NULL, /* Dependent problem. */
2897 TV_DF_BYTE_LR, /* Timing variable. */ 2896 TV_DF_BYTE_LR, /* Timing variable. */
2898 false /* Reset blocks on dropping out of blocks_to_analyze. */ 2897 false /* Reset blocks on dropping out of blocks_to_analyze. */
2899 }; 2898 };
2900 2899
2901 2900
2902 /* Create a new DATAFLOW instance and add it to an existing instance 2901 /* Create a new DATAFLOW instance and add it to an existing instance
2916 /* Simulate the effects of the defs of INSN on LIVE. */ 2915 /* Simulate the effects of the defs of INSN on LIVE. */
2917 2916
2918 void 2917 void
2919 df_byte_lr_simulate_defs (rtx insn, bitmap live) 2918 df_byte_lr_simulate_defs (rtx insn, bitmap live)
2920 { 2919 {
2921 struct df_byte_lr_problem_data *problem_data 2920 struct df_byte_lr_problem_data *problem_data
2922 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data; 2921 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data;
2923 df_ref *def_rec; 2922 df_ref *def_rec;
2924 unsigned int uid = INSN_UID (insn); 2923 unsigned int uid = INSN_UID (insn);
2925 2924
2926 for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++) 2925 for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
2944 2943
2945 if (len) 2944 if (len)
2946 bitmap_clear_range (live, start, len); 2945 bitmap_clear_range (live, start, len);
2947 } 2946 }
2948 } 2947 }
2949 } 2948 }
2950 2949
2951 2950
2952 /* Simulate the effects of the uses of INSN on LIVE. */ 2951 /* Simulate the effects of the uses of INSN on LIVE. */
2953 2952
2954 void 2953 void
2955 df_byte_lr_simulate_uses (rtx insn, bitmap live) 2954 df_byte_lr_simulate_uses (rtx insn, bitmap live)
2956 { 2955 {
2957 struct df_byte_lr_problem_data *problem_data 2956 struct df_byte_lr_problem_data *problem_data
2958 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data; 2957 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data;
2959 df_ref *use_rec; 2958 df_ref *use_rec;
2960 unsigned int uid = INSN_UID (insn); 2959 unsigned int uid = INSN_UID (insn);
2961 2960
2962 for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++) 2961 for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++)
2965 unsigned int uregno = DF_REF_REGNO (use); 2964 unsigned int uregno = DF_REF_REGNO (use);
2966 unsigned int start = problem_data->regno_start[uregno]; 2965 unsigned int start = problem_data->regno_start[uregno];
2967 unsigned int len = problem_data->regno_len[uregno]; 2966 unsigned int len = problem_data->regno_len[uregno];
2968 unsigned int sb; 2967 unsigned int sb;
2969 unsigned int lb; 2968 unsigned int lb;
2970 2969
2971 if (!df_compute_accessed_bytes (use, DF_MM_MAY, &sb, &lb)) 2970 if (!df_compute_accessed_bytes (use, DF_MM_MAY, &sb, &lb))
2972 { 2971 {
2973 start += sb; 2972 start += sb;
2974 len = lb - sb; 2973 len = lb - sb;
2975 } 2974 }
2976 2975
2977 /* Add use to set of uses in this BB. */ 2976 /* Add use to set of uses in this BB. */
2978 if (len) 2977 if (len)
2979 bitmap_set_range (live, start, len); 2978 bitmap_set_range (live, start, len);
2980 } 2979 }
2981 } 2980 }
2982 2981
2983 2982
2984 /* Apply the artificial uses and defs at the top of BB in a forwards 2983 /* Apply the artificial uses and defs at the top of BB in a forwards
2985 direction. */ 2984 direction. */
2986 2985
2987 void 2986 void
2988 df_byte_lr_simulate_artificial_refs_at_top (basic_block bb, bitmap live) 2987 df_byte_lr_simulate_artificial_refs_at_top (basic_block bb, bitmap live)
2989 { 2988 {
2990 struct df_byte_lr_problem_data *problem_data 2989 struct df_byte_lr_problem_data *problem_data
2991 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data; 2990 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data;
2992 df_ref *def_rec; 2991 df_ref *def_rec;
2993 #ifdef EH_USES 2992 #ifdef EH_USES
2994 df_ref *use_rec; 2993 df_ref *use_rec;
2995 #endif 2994 #endif
2996 int bb_index = bb->index; 2995 int bb_index = bb->index;
2997 2996
2998 #ifdef EH_USES 2997 #ifdef EH_USES
2999 for (use_rec = df_get_artificial_uses (bb_index); *use_rec; use_rec++) 2998 for (use_rec = df_get_artificial_uses (bb_index); *use_rec; use_rec++)
3000 { 2999 {
3001 df_ref use = *use_rec; 3000 df_ref use = *use_rec;
3002 if (DF_REF_FLAGS (use) & DF_REF_AT_TOP) 3001 if (DF_REF_FLAGS (use) & DF_REF_AT_TOP)
3011 3010
3012 for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++) 3011 for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
3013 { 3012 {
3014 df_ref def = *def_rec; 3013 df_ref def = *def_rec;
3015 if (DF_REF_FLAGS (def) & DF_REF_AT_TOP) 3014 if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
3016 { 3015 {
3017 unsigned int dregno = DF_REF_REGNO (def); 3016 unsigned int dregno = DF_REF_REGNO (def);
3018 unsigned int start = problem_data->regno_start[dregno]; 3017 unsigned int start = problem_data->regno_start[dregno];
3019 unsigned int len = problem_data->regno_len[dregno]; 3018 unsigned int len = problem_data->regno_len[dregno];
3020 bitmap_clear_range (live, start, len); 3019 bitmap_clear_range (live, start, len);
3021 } 3020 }
3024 3023
3025 3024
3026 /* Apply the artificial uses and defs at the end of BB in a backwards 3025 /* Apply the artificial uses and defs at the end of BB in a backwards
3027 direction. */ 3026 direction. */
3028 3027
3029 void 3028 void
3030 df_byte_lr_simulate_artificial_refs_at_end (basic_block bb, bitmap live) 3029 df_byte_lr_simulate_artificial_refs_at_end (basic_block bb, bitmap live)
3031 { 3030 {
3032 struct df_byte_lr_problem_data *problem_data 3031 struct df_byte_lr_problem_data *problem_data
3033 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data; 3032 = (struct df_byte_lr_problem_data *)df_byte_lr->problem_data;
3034 df_ref *def_rec; 3033 df_ref *def_rec;
3035 df_ref *use_rec; 3034 df_ref *use_rec;
3036 int bb_index = bb->index; 3035 int bb_index = bb->index;
3037 3036
3038 for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++) 3037 for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
3039 { 3038 {
3040 df_ref def = *def_rec; 3039 df_ref def = *def_rec;
3041 if ((DF_REF_FLAGS (def) & DF_REF_AT_TOP) == 0) 3040 if ((DF_REF_FLAGS (def) & DF_REF_AT_TOP) == 0)
3042 { 3041 {
3064 3063
3065 /*---------------------------------------------------------------------------- 3064 /*----------------------------------------------------------------------------
3066 This problem computes REG_DEAD and REG_UNUSED notes. 3065 This problem computes REG_DEAD and REG_UNUSED notes.
3067 ----------------------------------------------------------------------------*/ 3066 ----------------------------------------------------------------------------*/
3068 3067
3069 static void 3068 static void
3070 df_note_alloc (bitmap all_blocks ATTRIBUTE_UNUSED) 3069 df_note_alloc (bitmap all_blocks ATTRIBUTE_UNUSED)
3071 { 3070 {
3072 df_note->optional_p = true; 3071 df_note->optional_p = true;
3073 } 3072 }
3074 3073
3075 #ifdef REG_DEAD_DEBUGGING 3074 #ifdef REG_DEAD_DEBUGGING
3076 static void 3075 static void
3077 df_print_note (const char *prefix, rtx insn, rtx note) 3076 df_print_note (const char *prefix, rtx insn, rtx note)
3078 { 3077 {
3079 if (dump_file) 3078 if (dump_file)
3080 { 3079 {
3081 fprintf (dump_file, "%s %d ", prefix, INSN_UID (insn)); 3080 fprintf (dump_file, "%s %d ", prefix, INSN_UID (insn));
3089 /* After reg-stack, the x86 floating point stack regs are difficult to 3088 /* After reg-stack, the x86 floating point stack regs are difficult to
3090 analyze because of all of the pushes, pops and rotations. Thus, we 3089 analyze because of all of the pushes, pops and rotations. Thus, we
3091 just leave the notes alone. */ 3090 just leave the notes alone. */
3092 3091
3093 #ifdef STACK_REGS 3092 #ifdef STACK_REGS
3094 static inline bool 3093 static inline bool
3095 df_ignore_stack_reg (int regno) 3094 df_ignore_stack_reg (int regno)
3096 { 3095 {
3097 return regstack_completed 3096 return regstack_completed
3098 && IN_RANGE (regno, FIRST_STACK_REG, LAST_STACK_REG); 3097 && IN_RANGE (regno, FIRST_STACK_REG, LAST_STACK_REG);
3099 } 3098 }
3100 #else 3099 #else
3101 static inline bool 3100 static inline bool
3102 df_ignore_stack_reg (int regno ATTRIBUTE_UNUSED) 3101 df_ignore_stack_reg (int regno ATTRIBUTE_UNUSED)
3103 { 3102 {
3104 return false; 3103 return false;
3105 } 3104 }
3106 #endif 3105 #endif
3120 while (link) 3119 while (link)
3121 { 3120 {
3122 switch (REG_NOTE_KIND (link)) 3121 switch (REG_NOTE_KIND (link))
3123 { 3122 {
3124 case REG_DEAD: 3123 case REG_DEAD:
3125 /* After reg-stack, we need to ignore any unused notes 3124 /* After reg-stack, we need to ignore any unused notes
3126 for the stack registers. */ 3125 for the stack registers. */
3127 if (df_ignore_stack_reg (REGNO (XEXP (link, 0)))) 3126 if (df_ignore_stack_reg (REGNO (XEXP (link, 0))))
3128 { 3127 {
3129 pprev = &XEXP (link, 1); 3128 pprev = &XEXP (link, 1);
3130 link = *pprev; 3129 link = *pprev;
3140 *pprev = link = next; 3139 *pprev = link = next;
3141 } 3140 }
3142 break; 3141 break;
3143 3142
3144 case REG_UNUSED: 3143 case REG_UNUSED:
3145 /* After reg-stack, we need to ignore any unused notes 3144 /* After reg-stack, we need to ignore any unused notes
3146 for the stack registers. */ 3145 for the stack registers. */
3147 if (df_ignore_stack_reg (REGNO (XEXP (link, 0)))) 3146 if (df_ignore_stack_reg (REGNO (XEXP (link, 0))))
3148 { 3147 {
3149 pprev = &XEXP (link, 1); 3148 pprev = &XEXP (link, 1);
3150 link = *pprev; 3149 link = *pprev;
3158 XEXP (link, 1) = unused; 3157 XEXP (link, 1) = unused;
3159 unused = link; 3158 unused = link;
3160 *pprev = link = next; 3159 *pprev = link = next;
3161 } 3160 }
3162 break; 3161 break;
3163 3162
3164 default: 3163 default:
3165 pprev = &XEXP (link, 1); 3164 pprev = &XEXP (link, 1);
3166 link = *pprev; 3165 link = *pprev;
3167 break; 3166 break;
3168 } 3167 }
3179 static inline rtx 3178 static inline rtx
3180 df_set_note (enum reg_note note_type, rtx insn, rtx old, rtx reg) 3179 df_set_note (enum reg_note note_type, rtx insn, rtx old, rtx reg)
3181 { 3180 {
3182 rtx curr = old; 3181 rtx curr = old;
3183 rtx prev = NULL; 3182 rtx prev = NULL;
3183
3184 gcc_assert (!DEBUG_INSN_P (insn));
3184 3185
3185 while (curr) 3186 while (curr)
3186 if (XEXP (curr, 0) == reg) 3187 if (XEXP (curr, 0) == reg)
3187 { 3188 {
3188 if (prev) 3189 if (prev)
3196 else 3197 else
3197 { 3198 {
3198 prev = curr; 3199 prev = curr;
3199 curr = XEXP (curr, 1); 3200 curr = XEXP (curr, 1);
3200 } 3201 }
3201 3202
3202 /* Did not find the note. */ 3203 /* Did not find the note. */
3203 add_reg_note (insn, note_type, reg); 3204 add_reg_note (insn, note_type, reg);
3204 return old; 3205 return old;
3205 } 3206 }
3206 3207
3237 instruction. 3238 instruction.
3238 */ 3239 */
3239 3240
3240 static rtx 3241 static rtx
3241 df_set_unused_notes_for_mw (rtx insn, rtx old, struct df_mw_hardreg *mws, 3242 df_set_unused_notes_for_mw (rtx insn, rtx old, struct df_mw_hardreg *mws,
3242 bitmap live, bitmap do_not_gen, 3243 bitmap live, bitmap do_not_gen,
3243 bitmap artificial_uses) 3244 bitmap artificial_uses)
3244 { 3245 {
3245 unsigned int r; 3246 unsigned int r;
3246 3247
3247 #ifdef REG_DEAD_DEBUGGING 3248 #ifdef REG_DEAD_DEBUGGING
3248 if (dump_file) 3249 if (dump_file)
3249 fprintf (dump_file, "mw_set_unused looking at mws[%d..%d]\n", 3250 fprintf (dump_file, "mw_set_unused looking at mws[%d..%d]\n",
3250 mws->start_regno, mws->end_regno); 3251 mws->start_regno, mws->end_regno);
3251 #endif 3252 #endif
3252 3253
3253 if (df_whole_mw_reg_unused_p (mws, live, artificial_uses)) 3254 if (df_whole_mw_reg_unused_p (mws, live, artificial_uses))
3254 { 3255 {
3312 register. */ 3313 register. */
3313 3314
3314 static rtx 3315 static rtx
3315 df_set_dead_notes_for_mw (rtx insn, rtx old, struct df_mw_hardreg *mws, 3316 df_set_dead_notes_for_mw (rtx insn, rtx old, struct df_mw_hardreg *mws,
3316 bitmap live, bitmap do_not_gen, 3317 bitmap live, bitmap do_not_gen,
3317 bitmap artificial_uses) 3318 bitmap artificial_uses, bool *added_notes_p)
3318 { 3319 {
3319 unsigned int r; 3320 unsigned int r;
3320 3321 bool is_debug = *added_notes_p;
3322
3323 *added_notes_p = false;
3324
3321 #ifdef REG_DEAD_DEBUGGING 3325 #ifdef REG_DEAD_DEBUGGING
3322 if (dump_file) 3326 if (dump_file)
3323 { 3327 {
3324 fprintf (dump_file, "mw_set_dead looking at mws[%d..%d]\n do_not_gen =", 3328 fprintf (dump_file, "mw_set_dead looking at mws[%d..%d]\n do_not_gen =",
3325 mws->start_regno, mws->end_regno); 3329 mws->start_regno, mws->end_regno);
3326 df_print_regset (dump_file, do_not_gen); 3330 df_print_regset (dump_file, do_not_gen);
3327 fprintf (dump_file, " live ="); 3331 fprintf (dump_file, " live =");
3328 df_print_regset (dump_file, live); 3332 df_print_regset (dump_file, live);
3329 fprintf (dump_file, " artificial uses ="); 3333 fprintf (dump_file, " artificial uses =");
3332 #endif 3336 #endif
3333 3337
3334 if (df_whole_mw_reg_dead_p (mws, live, artificial_uses, do_not_gen)) 3338 if (df_whole_mw_reg_dead_p (mws, live, artificial_uses, do_not_gen))
3335 { 3339 {
3336 /* Add a dead note for the entire multi word register. */ 3340 /* Add a dead note for the entire multi word register. */
3341 if (is_debug)
3342 {
3343 *added_notes_p = true;
3344 return old;
3345 }
3337 old = df_set_note (REG_DEAD, insn, old, mws->mw_reg); 3346 old = df_set_note (REG_DEAD, insn, old, mws->mw_reg);
3338 #ifdef REG_DEAD_DEBUGGING 3347 #ifdef REG_DEAD_DEBUGGING
3339 df_print_note ("adding 1: ", insn, REG_NOTES (insn)); 3348 df_print_note ("adding 1: ", insn, REG_NOTES (insn));
3340 #endif 3349 #endif
3341 } 3350 }
3344 for (r = mws->start_regno; r <= mws->end_regno; r++) 3353 for (r = mws->start_regno; r <= mws->end_regno; r++)
3345 if (!bitmap_bit_p (live, r) 3354 if (!bitmap_bit_p (live, r)
3346 && !bitmap_bit_p (artificial_uses, r) 3355 && !bitmap_bit_p (artificial_uses, r)
3347 && !bitmap_bit_p (do_not_gen, r)) 3356 && !bitmap_bit_p (do_not_gen, r))
3348 { 3357 {
3358 if (is_debug)
3359 {
3360 *added_notes_p = true;
3361 return old;
3362 }
3349 old = df_set_note (REG_DEAD, insn, old, regno_reg_rtx[r]); 3363 old = df_set_note (REG_DEAD, insn, old, regno_reg_rtx[r]);
3350 #ifdef REG_DEAD_DEBUGGING 3364 #ifdef REG_DEAD_DEBUGGING
3351 df_print_note ("adding 2: ", insn, REG_NOTES (insn)); 3365 df_print_note ("adding 2: ", insn, REG_NOTES (insn));
3352 #endif 3366 #endif
3353 } 3367 }
3358 3372
3359 /* Create a REG_UNUSED note if necessary for DEF in INSN updating 3373 /* Create a REG_UNUSED note if necessary for DEF in INSN updating
3360 LIVE. Do not generate notes for registers in ARTIFICIAL_USES. */ 3374 LIVE. Do not generate notes for registers in ARTIFICIAL_USES. */
3361 3375
3362 static rtx 3376 static rtx
3363 df_create_unused_note (rtx insn, rtx old, df_ref def, 3377 df_create_unused_note (rtx insn, rtx old, df_ref def,
3364 bitmap live, bitmap artificial_uses) 3378 bitmap live, bitmap artificial_uses)
3365 { 3379 {
3366 unsigned int dregno = DF_REF_REGNO (def); 3380 unsigned int dregno = DF_REF_REGNO (def);
3367 3381
3368 #ifdef REG_DEAD_DEBUGGING 3382 #ifdef REG_DEAD_DEBUGGING
3369 if (dump_file) 3383 if (dump_file)
3370 { 3384 {
3371 fprintf (dump_file, " regular looking at def "); 3385 fprintf (dump_file, " regular looking at def ");
3372 df_ref_debug (def, dump_file); 3386 df_ref_debug (def, dump_file);
3376 if (!(bitmap_bit_p (live, dregno) 3390 if (!(bitmap_bit_p (live, dregno)
3377 || (DF_REF_FLAGS (def) & DF_REF_MW_HARDREG) 3391 || (DF_REF_FLAGS (def) & DF_REF_MW_HARDREG)
3378 || bitmap_bit_p (artificial_uses, dregno) 3392 || bitmap_bit_p (artificial_uses, dregno)
3379 || df_ignore_stack_reg (dregno))) 3393 || df_ignore_stack_reg (dregno)))
3380 { 3394 {
3381 rtx reg = (DF_REF_LOC (def)) 3395 rtx reg = (DF_REF_LOC (def))
3382 ? *DF_REF_REAL_LOC (def): DF_REF_REG (def); 3396 ? *DF_REF_REAL_LOC (def): DF_REF_REG (def);
3383 old = df_set_note (REG_UNUSED, insn, old, reg); 3397 old = df_set_note (REG_UNUSED, insn, old, reg);
3384 #ifdef REG_DEAD_DEBUGGING 3398 #ifdef REG_DEAD_DEBUGGING
3385 df_print_note ("adding 3: ", insn, REG_NOTES (insn)); 3399 df_print_note ("adding 3: ", insn, REG_NOTES (insn));
3386 #endif 3400 #endif
3387 } 3401 }
3388 3402
3389 return old; 3403 return old;
3390 } 3404 }
3391 3405
3392 3406
3393 /* Recompute the REG_DEAD and REG_UNUSED notes and compute register 3407 /* Recompute the REG_DEAD and REG_UNUSED notes and compute register
3394 info: lifetime, bb, and number of defs and uses for basic block 3408 info: lifetime, bb, and number of defs and uses for basic block
3395 BB. The three bitvectors are scratch regs used here. */ 3409 BB. The three bitvectors are scratch regs used here. */
3396 3410
3397 static void 3411 static void
3398 df_note_bb_compute (unsigned int bb_index, 3412 df_note_bb_compute (unsigned int bb_index,
3399 bitmap live, bitmap do_not_gen, bitmap artificial_uses) 3413 bitmap live, bitmap do_not_gen, bitmap artificial_uses)
3400 { 3414 {
3401 basic_block bb = BASIC_BLOCK (bb_index); 3415 basic_block bb = BASIC_BLOCK (bb_index);
3402 rtx insn; 3416 rtx insn;
3403 df_ref *def_rec; 3417 df_ref *def_rec;
3433 df_ref use = *use_rec; 3447 df_ref use = *use_rec;
3434 if ((DF_REF_FLAGS (use) & DF_REF_AT_TOP) == 0) 3448 if ((DF_REF_FLAGS (use) & DF_REF_AT_TOP) == 0)
3435 { 3449 {
3436 unsigned int regno = DF_REF_REGNO (use); 3450 unsigned int regno = DF_REF_REGNO (use);
3437 bitmap_set_bit (live, regno); 3451 bitmap_set_bit (live, regno);
3438 3452
3439 /* Notes are not generated for any of the artificial registers 3453 /* Notes are not generated for any of the artificial registers
3440 at the bottom of the block. */ 3454 at the bottom of the block. */
3441 bitmap_set_bit (artificial_uses, regno); 3455 bitmap_set_bit (artificial_uses, regno);
3442 } 3456 }
3443 } 3457 }
3444 3458
3445 #ifdef REG_DEAD_DEBUGGING 3459 #ifdef REG_DEAD_DEBUGGING
3446 if (dump_file) 3460 if (dump_file)
3447 { 3461 {
3448 fprintf (dump_file, "live before artificials out "); 3462 fprintf (dump_file, "live before artificials out ");
3449 df_print_regset (dump_file, live); 3463 df_print_regset (dump_file, live);
3454 { 3468 {
3455 unsigned int uid = INSN_UID (insn); 3469 unsigned int uid = INSN_UID (insn);
3456 struct df_mw_hardreg **mws_rec; 3470 struct df_mw_hardreg **mws_rec;
3457 rtx old_dead_notes; 3471 rtx old_dead_notes;
3458 rtx old_unused_notes; 3472 rtx old_unused_notes;
3459 3473 int debug_insn;
3474
3460 if (!INSN_P (insn)) 3475 if (!INSN_P (insn))
3461 continue; 3476 continue;
3477
3478 debug_insn = DEBUG_INSN_P (insn);
3462 3479
3463 bitmap_clear (do_not_gen); 3480 bitmap_clear (do_not_gen);
3464 df_kill_notes (insn, &old_dead_notes, &old_unused_notes); 3481 df_kill_notes (insn, &old_dead_notes, &old_unused_notes);
3465 3482
3466 /* Process the defs. */ 3483 /* Process the defs. */
3476 /* We only care about real sets for calls. Clobbers cannot 3493 /* We only care about real sets for calls. Clobbers cannot
3477 be depended on to really die. */ 3494 be depended on to really die. */
3478 mws_rec = DF_INSN_UID_MWS (uid); 3495 mws_rec = DF_INSN_UID_MWS (uid);
3479 while (*mws_rec) 3496 while (*mws_rec)
3480 { 3497 {
3481 struct df_mw_hardreg *mws = *mws_rec; 3498 struct df_mw_hardreg *mws = *mws_rec;
3482 if ((DF_MWS_REG_DEF_P (mws)) 3499 if ((DF_MWS_REG_DEF_P (mws))
3483 && !df_ignore_stack_reg (mws->start_regno)) 3500 && !df_ignore_stack_reg (mws->start_regno))
3484 old_unused_notes 3501 old_unused_notes
3485 = df_set_unused_notes_for_mw (insn, old_unused_notes, 3502 = df_set_unused_notes_for_mw (insn, old_unused_notes,
3486 mws, live, do_not_gen, 3503 mws, live, do_not_gen,
3487 artificial_uses); 3504 artificial_uses);
3488 mws_rec++; 3505 mws_rec++;
3489 } 3506 }
3490 3507
3491 /* All of the defs except the return value are some sort of 3508 /* All of the defs except the return value are some sort of
3495 df_ref def = *def_rec; 3512 df_ref def = *def_rec;
3496 unsigned int dregno = DF_REF_REGNO (def); 3513 unsigned int dregno = DF_REF_REGNO (def);
3497 if (!DF_REF_FLAGS_IS_SET (def, DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER)) 3514 if (!DF_REF_FLAGS_IS_SET (def, DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER))
3498 { 3515 {
3499 old_unused_notes 3516 old_unused_notes
3500 = df_create_unused_note (insn, old_unused_notes, 3517 = df_create_unused_note (insn, old_unused_notes,
3501 def, live, artificial_uses); 3518 def, live, artificial_uses);
3502 bitmap_set_bit (do_not_gen, dregno); 3519 bitmap_set_bit (do_not_gen, dregno);
3503 } 3520 }
3504 3521
3505 if (!DF_REF_FLAGS_IS_SET (def, DF_REF_PARTIAL | DF_REF_CONDITIONAL)) 3522 if (!DF_REF_FLAGS_IS_SET (def, DF_REF_PARTIAL | DF_REF_CONDITIONAL))
3510 { 3527 {
3511 /* Regular insn. */ 3528 /* Regular insn. */
3512 mws_rec = DF_INSN_UID_MWS (uid); 3529 mws_rec = DF_INSN_UID_MWS (uid);
3513 while (*mws_rec) 3530 while (*mws_rec)
3514 { 3531 {
3515 struct df_mw_hardreg *mws = *mws_rec; 3532 struct df_mw_hardreg *mws = *mws_rec;
3516 if (DF_MWS_REG_DEF_P (mws)) 3533 if (DF_MWS_REG_DEF_P (mws))
3517 old_unused_notes 3534 old_unused_notes
3518 = df_set_unused_notes_for_mw (insn, old_unused_notes, 3535 = df_set_unused_notes_for_mw (insn, old_unused_notes,
3519 mws, live, do_not_gen, 3536 mws, live, do_not_gen,
3520 artificial_uses); 3537 artificial_uses);
3521 mws_rec++; 3538 mws_rec++;
3522 } 3539 }
3523 3540
3524 for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++) 3541 for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
3525 { 3542 {
3526 df_ref def = *def_rec; 3543 df_ref def = *def_rec;
3527 unsigned int dregno = DF_REF_REGNO (def); 3544 unsigned int dregno = DF_REF_REGNO (def);
3528 old_unused_notes 3545 old_unused_notes
3529 = df_create_unused_note (insn, old_unused_notes, 3546 = df_create_unused_note (insn, old_unused_notes,
3530 def, live, artificial_uses); 3547 def, live, artificial_uses);
3531 3548
3532 if (!DF_REF_FLAGS_IS_SET (def, DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER)) 3549 if (!DF_REF_FLAGS_IS_SET (def, DF_REF_MUST_CLOBBER | DF_REF_MAY_CLOBBER))
3533 bitmap_set_bit (do_not_gen, dregno); 3550 bitmap_set_bit (do_not_gen, dregno);
3534 3551
3535 if (!DF_REF_FLAGS_IS_SET (def, DF_REF_PARTIAL | DF_REF_CONDITIONAL)) 3552 if (!DF_REF_FLAGS_IS_SET (def, DF_REF_PARTIAL | DF_REF_CONDITIONAL))
3536 bitmap_clear_bit (live, dregno); 3553 bitmap_clear_bit (live, dregno);
3537 } 3554 }
3538 } 3555 }
3539 3556
3540 /* Process the uses. */ 3557 /* Process the uses. */
3541 mws_rec = DF_INSN_UID_MWS (uid); 3558 mws_rec = DF_INSN_UID_MWS (uid);
3542 while (*mws_rec) 3559 while (*mws_rec)
3543 { 3560 {
3544 struct df_mw_hardreg *mws = *mws_rec; 3561 struct df_mw_hardreg *mws = *mws_rec;
3545 if ((DF_MWS_REG_DEF_P (mws)) 3562 if ((DF_MWS_REG_DEF_P (mws))
3546 && !df_ignore_stack_reg (mws->start_regno)) 3563 && !df_ignore_stack_reg (mws->start_regno))
3547 old_dead_notes 3564 {
3548 = df_set_dead_notes_for_mw (insn, old_dead_notes, 3565 bool really_add_notes = debug_insn != 0;
3549 mws, live, do_not_gen, 3566
3550 artificial_uses); 3567 old_dead_notes
3568 = df_set_dead_notes_for_mw (insn, old_dead_notes,
3569 mws, live, do_not_gen,
3570 artificial_uses,
3571 &really_add_notes);
3572
3573 if (really_add_notes)
3574 debug_insn = -1;
3575 }
3551 mws_rec++; 3576 mws_rec++;
3552 } 3577 }
3553 3578
3554 for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++) 3579 for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++)
3555 { 3580 {
3556 df_ref use = *use_rec; 3581 df_ref use = *use_rec;
3557 unsigned int uregno = DF_REF_REGNO (use); 3582 unsigned int uregno = DF_REF_REGNO (use);
3558 3583
3559 #ifdef REG_DEAD_DEBUGGING 3584 #ifdef REG_DEAD_DEBUGGING
3560 if (dump_file) 3585 if (dump_file && !debug_insn)
3561 { 3586 {
3562 fprintf (dump_file, " regular looking at use "); 3587 fprintf (dump_file, " regular looking at use ");
3563 df_ref_debug (use, dump_file); 3588 df_ref_debug (use, dump_file);
3564 } 3589 }
3565 #endif 3590 #endif
3566 if (!bitmap_bit_p (live, uregno)) 3591 if (!bitmap_bit_p (live, uregno))
3567 { 3592 {
3593 if (debug_insn)
3594 {
3595 debug_insn = -1;
3596 break;
3597 }
3598
3568 if ( (!(DF_REF_FLAGS (use) & DF_REF_MW_HARDREG)) 3599 if ( (!(DF_REF_FLAGS (use) & DF_REF_MW_HARDREG))
3569 && (!bitmap_bit_p (do_not_gen, uregno)) 3600 && (!bitmap_bit_p (do_not_gen, uregno))
3570 && (!bitmap_bit_p (artificial_uses, uregno)) 3601 && (!bitmap_bit_p (artificial_uses, uregno))
3571 && (!(DF_REF_FLAGS (use) & DF_REF_READ_WRITE)) 3602 && (!(DF_REF_FLAGS (use) & DF_REF_READ_WRITE))
3572 && (!df_ignore_stack_reg (uregno))) 3603 && (!df_ignore_stack_reg (uregno)))
3573 { 3604 {
3574 rtx reg = (DF_REF_LOC (use)) 3605 rtx reg = (DF_REF_LOC (use))
3575 ? *DF_REF_REAL_LOC (use) : DF_REF_REG (use); 3606 ? *DF_REF_REAL_LOC (use) : DF_REF_REG (use);
3576 old_dead_notes = df_set_note (REG_DEAD, insn, old_dead_notes, reg); 3607 old_dead_notes = df_set_note (REG_DEAD, insn, old_dead_notes, reg);
3577 3608
3578 #ifdef REG_DEAD_DEBUGGING 3609 #ifdef REG_DEAD_DEBUGGING
3579 df_print_note ("adding 4: ", insn, REG_NOTES (insn)); 3610 df_print_note ("adding 4: ", insn, REG_NOTES (insn));
3593 while (old_dead_notes) 3624 while (old_dead_notes)
3594 { 3625 {
3595 rtx next = XEXP (old_dead_notes, 1); 3626 rtx next = XEXP (old_dead_notes, 1);
3596 free_EXPR_LIST_node (old_dead_notes); 3627 free_EXPR_LIST_node (old_dead_notes);
3597 old_dead_notes = next; 3628 old_dead_notes = next;
3629 }
3630
3631 if (debug_insn == -1)
3632 {
3633 /* ??? We could probably do better here, replacing dead
3634 registers with their definitions. */
3635 INSN_VAR_LOCATION_LOC (insn) = gen_rtx_UNKNOWN_VAR_LOC ();
3636 df_insn_rescan_debug_internal (insn);
3598 } 3637 }
3599 } 3638 }
3600 } 3639 }
3601 3640
3602 3641
3645 NULL, /* Reset global information. */ 3684 NULL, /* Reset global information. */
3646 NULL, /* Free basic block info. */ 3685 NULL, /* Free basic block info. */
3647 df_note_compute, /* Local compute function. */ 3686 df_note_compute, /* Local compute function. */
3648 NULL, /* Init the solution specific data. */ 3687 NULL, /* Init the solution specific data. */
3649 NULL, /* Iterative solver. */ 3688 NULL, /* Iterative solver. */
3650 NULL, /* Confluence operator 0. */ 3689 NULL, /* Confluence operator 0. */
3651 NULL, /* Confluence operator n. */ 3690 NULL, /* Confluence operator n. */
3652 NULL, /* Transfer function. */ 3691 NULL, /* Transfer function. */
3653 NULL, /* Finalize function. */ 3692 NULL, /* Finalize function. */
3654 df_note_free, /* Free all of the problem information. */ 3693 df_note_free, /* Free all of the problem information. */
3655 df_note_free, /* Remove this problem from the stack of dataflow problems. */ 3694 df_note_free, /* Remove this problem from the stack of dataflow problems. */
3656 NULL, /* Debugging. */ 3695 NULL, /* Debugging. */
3676 3715
3677 3716
3678 3717
3679 3718
3680 /*---------------------------------------------------------------------------- 3719 /*----------------------------------------------------------------------------
3681 Functions for simulating the effects of single insns. 3720 Functions for simulating the effects of single insns.
3682 3721
3683 You can either simulate in the forwards direction, starting from 3722 You can either simulate in the forwards direction, starting from
3684 the top of a block or the backwards direction from the end of the 3723 the top of a block or the backwards direction from the end of the
3685 block. The main difference is that if you go forwards, the uses 3724 block. If you go backwards, defs are examined first to clear bits,
3686 are examined first then the defs, and if you go backwards, the defs 3725 then uses are examined to set bits. If you go forwards, defs are
3687 are examined first then the uses. 3726 examined first to set bits, then REG_DEAD and REG_UNUSED notes
3727 are examined to clear bits. In either case, the result of examining
3728 a def can be undone (respectively by a use or a REG_UNUSED note).
3688 3729
3689 If you start at the top of the block, use one of DF_LIVE_IN or 3730 If you start at the top of the block, use one of DF_LIVE_IN or
3690 DF_LR_IN. If you start at the bottom of the block use one of 3731 DF_LR_IN. If you start at the bottom of the block use one of
3691 DF_LIVE_OUT or DF_LR_OUT. BE SURE TO PASS A COPY OF THESE SETS, 3732 DF_LIVE_OUT or DF_LR_OUT. BE SURE TO PASS A COPY OF THESE SETS,
3692 THEY WILL BE DESTROYED. 3733 THEY WILL BE DESTROYED.
3728 /* If the def is to only part of the reg, it does 3769 /* If the def is to only part of the reg, it does
3729 not kill the other defs that reach here. */ 3770 not kill the other defs that reach here. */
3730 if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL))) 3771 if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
3731 bitmap_clear_bit (live, dregno); 3772 bitmap_clear_bit (live, dregno);
3732 } 3773 }
3733 } 3774 }
3734 3775
3735 3776
3736 /* Simulate the effects of the uses of INSN on LIVE. */ 3777 /* Simulate the effects of the uses of INSN on LIVE. */
3737 3778
3738 void 3779 void
3739 df_simulate_uses (rtx insn, bitmap live) 3780 df_simulate_uses (rtx insn, bitmap live)
3740 { 3781 {
3741 df_ref *use_rec; 3782 df_ref *use_rec;
3742 unsigned int uid = INSN_UID (insn); 3783 unsigned int uid = INSN_UID (insn);
3784
3785 if (DEBUG_INSN_P (insn))
3786 return;
3743 3787
3744 for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++) 3788 for (use_rec = DF_INSN_UID_USES (uid); *use_rec; use_rec++)
3745 { 3789 {
3746 df_ref use = *use_rec; 3790 df_ref use = *use_rec;
3747 /* Add use to set of uses in this BB. */ 3791 /* Add use to set of uses in this BB. */
3769 i.e. they process the defs before the uses. 3813 i.e. they process the defs before the uses.
3770 3814
3771 df_simulate_initialize_backwards should be called first with a 3815 df_simulate_initialize_backwards should be called first with a
3772 bitvector copyied from the DF_LIVE_OUT or DF_LR_OUT. Then 3816 bitvector copyied from the DF_LIVE_OUT or DF_LR_OUT. Then
3773 df_simulate_one_insn_backwards should be called for each insn in 3817 df_simulate_one_insn_backwards should be called for each insn in
3774 the block, starting with the last on. Finally, 3818 the block, starting with the last one. Finally,
3775 df_simulate_finalize_backwards can be called to get a new value 3819 df_simulate_finalize_backwards can be called to get a new value
3776 of the sets at the top of the block (this is rarely used). 3820 of the sets at the top of the block (this is rarely used).
3777 ----------------------------------------------------------------------------*/ 3821 ----------------------------------------------------------------------------*/
3778 3822
3779 /* Apply the artificial uses and defs at the end of BB in a backwards 3823 /* Apply the artificial uses and defs at the end of BB in a backwards
3780 direction. */ 3824 direction. */
3781 3825
3782 void 3826 void
3783 df_simulate_initialize_backwards (basic_block bb, bitmap live) 3827 df_simulate_initialize_backwards (basic_block bb, bitmap live)
3784 { 3828 {
3785 df_ref *def_rec; 3829 df_ref *def_rec;
3786 df_ref *use_rec; 3830 df_ref *use_rec;
3787 int bb_index = bb->index; 3831 int bb_index = bb->index;
3788 3832
3789 for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++) 3833 for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
3790 { 3834 {
3791 df_ref def = *def_rec; 3835 df_ref def = *def_rec;
3792 if ((DF_REF_FLAGS (def) & DF_REF_AT_TOP) == 0) 3836 if ((DF_REF_FLAGS (def) & DF_REF_AT_TOP) == 0)
3793 bitmap_clear_bit (live, DF_REF_REGNO (def)); 3837 bitmap_clear_bit (live, DF_REF_REGNO (def));
3802 } 3846 }
3803 3847
3804 3848
3805 /* Simulate the backwards effects of INSN on the bitmap LIVE. */ 3849 /* Simulate the backwards effects of INSN on the bitmap LIVE. */
3806 3850
3807 void 3851 void
3808 df_simulate_one_insn_backwards (basic_block bb, rtx insn, bitmap live) 3852 df_simulate_one_insn_backwards (basic_block bb, rtx insn, bitmap live)
3809 { 3853 {
3810 if (! INSN_P (insn)) 3854 if (!NONDEBUG_INSN_P (insn))
3811 return; 3855 return;
3812 3856
3813 df_simulate_defs (insn, live); 3857 df_simulate_defs (insn, live);
3814 df_simulate_uses (insn, live); 3858 df_simulate_uses (insn, live);
3815 df_simulate_fixup_sets (bb, live); 3859 df_simulate_fixup_sets (bb, live);
3816 } 3860 }
3817 3861
3818 3862
3819 /* Apply the artificial uses and defs at the top of BB in a backwards 3863 /* Apply the artificial uses and defs at the top of BB in a backwards
3820 direction. */ 3864 direction. */
3821 3865
3822 void 3866 void
3823 df_simulate_finalize_backwards (basic_block bb, bitmap live) 3867 df_simulate_finalize_backwards (basic_block bb, bitmap live)
3824 { 3868 {
3825 df_ref *def_rec; 3869 df_ref *def_rec;
3826 #ifdef EH_USES 3870 #ifdef EH_USES
3827 df_ref *use_rec; 3871 df_ref *use_rec;
3828 #endif 3872 #endif
3829 int bb_index = bb->index; 3873 int bb_index = bb->index;
3830 3874
3831 for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++) 3875 for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
3832 { 3876 {
3833 df_ref def = *def_rec; 3877 df_ref def = *def_rec;
3834 if (DF_REF_FLAGS (def) & DF_REF_AT_TOP) 3878 if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
3835 bitmap_clear_bit (live, DF_REF_REGNO (def)); 3879 bitmap_clear_bit (live, DF_REF_REGNO (def));
3845 #endif 3889 #endif
3846 } 3890 }
3847 /*---------------------------------------------------------------------------- 3891 /*----------------------------------------------------------------------------
3848 The following three functions are used only for FORWARDS scanning: 3892 The following three functions are used only for FORWARDS scanning:
3849 i.e. they process the defs and the REG_DEAD and REG_UNUSED notes. 3893 i.e. they process the defs and the REG_DEAD and REG_UNUSED notes.
3850 Thus it is important to add the DF_NOTES problem to the stack of 3894 Thus it is important to add the DF_NOTES problem to the stack of
3851 problems computed before using these functions. 3895 problems computed before using these functions.
3852 3896
3853 df_simulate_initialize_forwards should be called first with a 3897 df_simulate_initialize_forwards should be called first with a
3854 bitvector copyied from the DF_LIVE_IN or DF_LR_IN. Then 3898 bitvector copyied from the DF_LIVE_IN or DF_LR_IN. Then
3855 df_simulate_one_insn_forwards should be called for each insn in 3899 df_simulate_one_insn_forwards should be called for each insn in
3856 the block, starting with the last on. Finally, 3900 the block, starting with the first one.
3857 df_simulate_finalize_forwards can be called to get a new value
3858 of the sets at the bottom of the block (this is rarely used).
3859 ----------------------------------------------------------------------------*/ 3901 ----------------------------------------------------------------------------*/
3860 3902
3861 /* Apply the artificial uses and defs at the top of BB in a backwards 3903 /* Apply the artificial uses and defs at the top of BB in a forwards
3862 direction. */ 3904 direction. ??? This is wrong; defs mark the point where a pseudo
3863 3905 becomes live when scanning forwards (unless a def is unused). Since
3864 void 3906 there are no REG_UNUSED notes for artificial defs, passes that
3907 require artificial defs probably should not call this function
3908 unless (as is the case for fwprop) they are correct when liveness
3909 bitmaps are *under*estimated. */
3910
3911 void
3865 df_simulate_initialize_forwards (basic_block bb, bitmap live) 3912 df_simulate_initialize_forwards (basic_block bb, bitmap live)
3866 { 3913 {
3867 df_ref *def_rec; 3914 df_ref *def_rec;
3868 int bb_index = bb->index; 3915 int bb_index = bb->index;
3869 3916
3870 for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++) 3917 for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
3871 { 3918 {
3872 df_ref def = *def_rec; 3919 df_ref def = *def_rec;
3873 if (DF_REF_FLAGS (def) & DF_REF_AT_TOP) 3920 if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
3874 bitmap_clear_bit (live, DF_REF_REGNO (def)); 3921 bitmap_clear_bit (live, DF_REF_REGNO (def));
3875 } 3922 }
3876 } 3923 }
3877 3924
3878 /* Simulate the backwards effects of INSN on the bitmap LIVE. */ 3925 /* Simulate the forwards effects of INSN on the bitmap LIVE. */
3879 3926
3880 void 3927 void
3881 df_simulate_one_insn_forwards (basic_block bb, rtx insn, bitmap live) 3928 df_simulate_one_insn_forwards (basic_block bb, rtx insn, bitmap live)
3882 { 3929 {
3883 rtx link; 3930 rtx link;
3884 if (! INSN_P (insn)) 3931 if (! INSN_P (insn))
3885 return; 3932 return;
3886 3933
3887 /* Make sure that the DF_NOTES really is an active df problem. */ 3934 /* Make sure that DF_NOTE really is an active df problem. */
3888 gcc_assert (df_note); 3935 gcc_assert (df_note);
3889 3936
3890 df_simulate_defs (insn, live); 3937 /* Note that this is the opposite as how the problem is defined, because
3938 in the LR problem defs _kill_ liveness. However, they do so backwards,
3939 while here the scan is performed forwards! So, first assume that the
3940 def is live, and if this is not true REG_UNUSED notes will rectify the
3941 situation. */
3942 df_simulate_find_defs (insn, live);
3891 3943
3892 /* Clear all of the registers that go dead. */ 3944 /* Clear all of the registers that go dead. */
3893 for (link = REG_NOTES (insn); link; link = XEXP (link, 1)) 3945 for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
3894 { 3946 {
3895 switch (REG_NOTE_KIND (link)) 3947 switch (REG_NOTE_KIND (link))
3948 {
3896 case REG_DEAD: 3949 case REG_DEAD:
3897 case REG_UNUSED: 3950 case REG_UNUSED:
3898 { 3951 {
3899 rtx reg = XEXP (link, 0); 3952 rtx reg = XEXP (link, 0);
3900 int regno = REGNO (reg); 3953 int regno = REGNO (reg);
3901 if (regno < FIRST_PSEUDO_REGISTER) 3954 if (regno < FIRST_PSEUDO_REGISTER)
3902 { 3955 {
3903 int n = hard_regno_nregs[regno][GET_MODE (reg)]; 3956 int n = hard_regno_nregs[regno][GET_MODE (reg)];
3904 while (--n >= 0) 3957 while (--n >= 0)
3905 bitmap_clear_bit (live, regno + n); 3958 bitmap_clear_bit (live, regno + n);
3906 } 3959 }
3907 else 3960 else
3908 bitmap_clear_bit (live, regno); 3961 bitmap_clear_bit (live, regno);
3962 }
3909 break; 3963 break;
3910 default: 3964 default:
3911 break; 3965 break;
3912 } 3966 }
3913 } 3967 }
3914 df_simulate_fixup_sets (bb, live); 3968 df_simulate_fixup_sets (bb, live);
3915 } 3969 }
3916 3970
3917 3971
3918 /* Apply the artificial uses and defs at the end of BB in a backwards 3972
3919 direction. */ 3973 /*----------------------------------------------------------------------------
3920 3974 MULTIPLE DEFINITIONS
3921 void 3975
3922 df_simulate_finalize_forwards (basic_block bb, bitmap live) 3976 Find the locations in the function reached by multiple definition sites
3923 { 3977 for a live pseudo. In and out bitvectors are built for each basic
3978 block. They are restricted for efficiency to live registers.
3979
3980 The gen and kill sets for the problem are obvious. Together they
3981 include all defined registers in a basic block; the gen set includes
3982 registers where a partial or conditional or may-clobber definition is
3983 last in the BB, while the kill set includes registers with a complete
3984 definition coming last. However, the computation of the dataflow
3985 itself is interesting.
3986
3987 The idea behind it comes from SSA form's iterated dominance frontier
3988 criterion for inserting PHI functions. Just like in that case, we can use
3989 the dominance frontier to find places where multiple definitions meet;
3990 a register X defined in a basic block BB1 has multiple definitions in
3991 basic blocks in BB1's dominance frontier.
3992
3993 So, the in-set of a basic block BB2 is not just the union of the
3994 out-sets of BB2's predecessors, but includes some more bits that come
3995 from the basic blocks of whose dominance frontier BB2 is part (BB1 in
3996 the previous paragraph). I called this set the init-set of BB2.
3997
3998 (Note: I actually use the kill-set only to build the init-set.
3999 gen bits are anyway propagated from BB1 to BB2 by dataflow).
4000
4001 For example, if you have
4002
4003 BB1 : r10 = 0
4004 r11 = 0
4005 if <...> goto BB2 else goto BB3;
4006
4007 BB2 : r10 = 1
4008 r12 = 1
4009 goto BB3;
4010
4011 BB3 :
4012
4013 you have BB3 in BB2's dominance frontier but not in BB1's, so that the
4014 init-set of BB3 includes r10 and r12, but not r11. Note that we do
4015 not need to iterate the dominance frontier, because we do not insert
4016 anything like PHI functions there! Instead, dataflow will take care of
4017 propagating the information to BB3's successors.
4018 ---------------------------------------------------------------------------*/
4019
4020 /* Scratch var used by transfer functions. This is used to do md analysis
4021 only for live registers. */
4022 static bitmap df_md_scratch;
4023
4024 /* Set basic block info. */
4025
4026 static void
4027 df_md_set_bb_info (unsigned int index,
4028 struct df_md_bb_info *bb_info)
4029 {
4030 gcc_assert (df_md);
4031 gcc_assert (index < df_md->block_info_size);
4032 df_md->block_info[index] = bb_info;
4033 }
4034
4035
4036 static void
4037 df_md_free_bb_info (basic_block bb ATTRIBUTE_UNUSED,
4038 void *vbb_info)
4039 {
4040 struct df_md_bb_info *bb_info = (struct df_md_bb_info *) vbb_info;
4041 if (bb_info)
4042 {
4043 BITMAP_FREE (bb_info->kill);
4044 BITMAP_FREE (bb_info->gen);
4045 BITMAP_FREE (bb_info->init);
4046 BITMAP_FREE (bb_info->in);
4047 BITMAP_FREE (bb_info->out);
4048 pool_free (df_md->block_pool, bb_info);
4049 }
4050 }
4051
4052
4053 /* Allocate or reset bitmaps for DF_MD. The solution bits are
4054 not touched unless the block is new. */
4055
4056 static void
4057 df_md_alloc (bitmap all_blocks)
4058 {
4059 unsigned int bb_index;
4060 bitmap_iterator bi;
4061
4062 if (!df_md->block_pool)
4063 df_md->block_pool = create_alloc_pool ("df_md_block pool",
4064 sizeof (struct df_md_bb_info), 50);
4065
4066 df_grow_bb_info (df_md);
4067 df_md_scratch = BITMAP_ALLOC (NULL);
4068
4069 EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
4070 {
4071 struct df_md_bb_info *bb_info = df_md_get_bb_info (bb_index);
4072 if (bb_info)
4073 {
4074 bitmap_clear (bb_info->init);
4075 bitmap_clear (bb_info->gen);
4076 bitmap_clear (bb_info->kill);
4077 bitmap_clear (bb_info->in);
4078 bitmap_clear (bb_info->out);
4079 }
4080 else
4081 {
4082 bb_info = (struct df_md_bb_info *) pool_alloc (df_md->block_pool);
4083 df_md_set_bb_info (bb_index, bb_info);
4084 bb_info->init = BITMAP_ALLOC (NULL);
4085 bb_info->gen = BITMAP_ALLOC (NULL);
4086 bb_info->kill = BITMAP_ALLOC (NULL);
4087 bb_info->in = BITMAP_ALLOC (NULL);
4088 bb_info->out = BITMAP_ALLOC (NULL);
4089 }
4090 }
4091
4092 df_md->optional_p = true;
4093 }
4094
4095 /* Add the effect of the top artificial defs of BB to the multiple definitions
4096 bitmap LOCAL_MD. */
4097
4098 void
4099 df_md_simulate_artificial_defs_at_top (basic_block bb, bitmap local_md)
4100 {
4101 int bb_index = bb->index;
3924 df_ref *def_rec; 4102 df_ref *def_rec;
3925 int bb_index = bb->index;
3926
3927 for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++) 4103 for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
3928 { 4104 {
3929 df_ref def = *def_rec; 4105 df_ref def = *def_rec;
3930 if ((DF_REF_FLAGS (def) & DF_REF_AT_TOP) == 0) 4106 if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
3931 bitmap_clear_bit (live, DF_REF_REGNO (def)); 4107 {
3932 } 4108 unsigned int dregno = DF_REF_REGNO (def);
3933 } 4109 if (DF_REF_FLAGS (def)
3934 4110 & (DF_REF_PARTIAL | DF_REF_CONDITIONAL | DF_REF_MAY_CLOBBER))
3935 4111 bitmap_set_bit (local_md, dregno);
4112 else
4113 bitmap_clear_bit (local_md, dregno);
4114 }
4115 }
4116 }
4117
4118
4119 /* Add the effect of the defs of INSN to the reaching definitions bitmap
4120 LOCAL_MD. */
4121
4122 void
4123 df_md_simulate_one_insn (basic_block bb ATTRIBUTE_UNUSED, rtx insn,
4124 bitmap local_md)
4125 {
4126 unsigned uid = INSN_UID (insn);
4127 df_ref *def_rec;
4128
4129 for (def_rec = DF_INSN_UID_DEFS (uid); *def_rec; def_rec++)
4130 {
4131 df_ref def = *def_rec;
4132 unsigned int dregno = DF_REF_REGNO (def);
4133 if ((!(df->changeable_flags & DF_NO_HARD_REGS))
4134 || (dregno >= FIRST_PSEUDO_REGISTER))
4135 {
4136 if (DF_REF_FLAGS (def)
4137 & (DF_REF_PARTIAL | DF_REF_CONDITIONAL | DF_REF_MAY_CLOBBER))
4138 bitmap_set_bit (local_md, DF_REF_ID (def));
4139 else
4140 bitmap_clear_bit (local_md, DF_REF_ID (def));
4141 }
4142 }
4143 }
4144
4145 static void
4146 df_md_bb_local_compute_process_def (struct df_md_bb_info *bb_info,
4147 df_ref *def_rec,
4148 int top_flag)
4149 {
4150 df_ref def;
4151 bitmap_clear (seen_in_insn);
4152
4153 while ((def = *def_rec++) != NULL)
4154 {
4155 unsigned int dregno = DF_REF_REGNO (def);
4156 if (((!(df->changeable_flags & DF_NO_HARD_REGS))
4157 || (dregno >= FIRST_PSEUDO_REGISTER))
4158 && top_flag == (DF_REF_FLAGS (def) & DF_REF_AT_TOP))
4159 {
4160 if (!bitmap_bit_p (seen_in_insn, dregno))
4161 {
4162 if (DF_REF_FLAGS (def)
4163 & (DF_REF_PARTIAL | DF_REF_CONDITIONAL | DF_REF_MAY_CLOBBER))
4164 {
4165 bitmap_set_bit (bb_info->gen, dregno);
4166 bitmap_clear_bit (bb_info->kill, dregno);
4167 }
4168 else
4169 {
4170 /* When we find a clobber and a regular def,
4171 make sure the regular def wins. */
4172 bitmap_set_bit (seen_in_insn, dregno);
4173 bitmap_set_bit (bb_info->kill, dregno);
4174 bitmap_clear_bit (bb_info->gen, dregno);
4175 }
4176 }
4177 }
4178 }
4179 }
4180
4181
4182 /* Compute local multiple def info for basic block BB. */
4183
4184 static void
4185 df_md_bb_local_compute (unsigned int bb_index)
4186 {
4187 basic_block bb = BASIC_BLOCK (bb_index);
4188 struct df_md_bb_info *bb_info = df_md_get_bb_info (bb_index);
4189 rtx insn;
4190
4191 /* Artificials are only hard regs. */
4192 if (!(df->changeable_flags & DF_NO_HARD_REGS))
4193 df_md_bb_local_compute_process_def (bb_info,
4194 df_get_artificial_defs (bb_index),
4195 DF_REF_AT_TOP);
4196
4197 FOR_BB_INSNS (bb, insn)
4198 {
4199 unsigned int uid = INSN_UID (insn);
4200 if (!INSN_P (insn))
4201 continue;
4202
4203 df_md_bb_local_compute_process_def (bb_info, DF_INSN_UID_DEFS (uid), 0);
4204 }
4205
4206 if (!(df->changeable_flags & DF_NO_HARD_REGS))
4207 df_md_bb_local_compute_process_def (bb_info,
4208 df_get_artificial_defs (bb_index),
4209 0);
4210 }
4211
4212 /* Compute local reaching def info for each basic block within BLOCKS. */
4213
4214 static void
4215 df_md_local_compute (bitmap all_blocks)
4216 {
4217 unsigned int bb_index, df_bb_index;
4218 bitmap_iterator bi1, bi2;
4219 basic_block bb;
4220 bitmap *frontiers;
4221
4222 seen_in_insn = BITMAP_ALLOC (NULL);
4223
4224 EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi1)
4225 {
4226 df_md_bb_local_compute (bb_index);
4227 }
4228
4229 BITMAP_FREE (seen_in_insn);
4230
4231 frontiers = XNEWVEC (bitmap, last_basic_block);
4232 FOR_ALL_BB (bb)
4233 frontiers[bb->index] = BITMAP_ALLOC (NULL);
4234
4235 compute_dominance_frontiers (frontiers);
4236
4237 /* Add each basic block's kills to the nodes in the frontier of the BB. */
4238 EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi1)
4239 {
4240 bitmap kill = df_md_get_bb_info (bb_index)->kill;
4241 EXECUTE_IF_SET_IN_BITMAP (frontiers[bb_index], 0, df_bb_index, bi2)
4242 {
4243 basic_block bb = BASIC_BLOCK (df_bb_index);
4244 if (bitmap_bit_p (all_blocks, df_bb_index))
4245 bitmap_ior_and_into (df_md_get_bb_info (df_bb_index)->init, kill,
4246 df_get_live_in (bb));
4247 }
4248 }
4249
4250 FOR_ALL_BB (bb)
4251 BITMAP_FREE (frontiers[bb->index]);
4252 free (frontiers);
4253 }
4254
4255
4256 /* Reset the global solution for recalculation. */
4257
4258 static void
4259 df_md_reset (bitmap all_blocks)
4260 {
4261 unsigned int bb_index;
4262 bitmap_iterator bi;
4263
4264 EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
4265 {
4266 struct df_md_bb_info *bb_info = df_md_get_bb_info (bb_index);
4267 gcc_assert (bb_info);
4268 bitmap_clear (bb_info->in);
4269 bitmap_clear (bb_info->out);
4270 }
4271 }
4272
4273 static bool
4274 df_md_transfer_function (int bb_index)
4275 {
4276 basic_block bb = BASIC_BLOCK (bb_index);
4277 struct df_md_bb_info *bb_info = df_md_get_bb_info (bb_index);
4278 bitmap in = bb_info->in;
4279 bitmap out = bb_info->out;
4280 bitmap gen = bb_info->gen;
4281 bitmap kill = bb_info->kill;
4282
4283 /* We need to use a scratch set here so that the value returned from this
4284 function invocation properly reflects whether the sets changed in a
4285 significant way; i.e. not just because the live set was anded in. */
4286 bitmap_and (df_md_scratch, gen, df_get_live_out (bb));
4287
4288 /* Multiple definitions of a register are not relevant if it is not
4289 live. Thus we trim the result to the places where it is live. */
4290 bitmap_and_into (in, df_get_live_in (bb));
4291
4292 return bitmap_ior_and_compl (out, df_md_scratch, in, kill);
4293 }
4294
4295 /* Initialize the solution bit vectors for problem. */
4296
4297 static void
4298 df_md_init (bitmap all_blocks)
4299 {
4300 unsigned int bb_index;
4301 bitmap_iterator bi;
4302
4303 EXECUTE_IF_SET_IN_BITMAP (all_blocks, 0, bb_index, bi)
4304 {
4305 struct df_md_bb_info *bb_info = df_md_get_bb_info (bb_index);
4306
4307 bitmap_copy (bb_info->in, bb_info->init);
4308 df_md_transfer_function (bb_index);
4309 }
4310 }
4311
4312 static void
4313 df_md_confluence_0 (basic_block bb)
4314 {
4315 struct df_md_bb_info *bb_info = df_md_get_bb_info (bb->index);
4316 bitmap_copy (bb_info->in, bb_info->init);
4317 }
4318
4319 /* In of target gets or of out of source. */
4320
4321 static void
4322 df_md_confluence_n (edge e)
4323 {
4324 bitmap op1 = df_md_get_bb_info (e->dest->index)->in;
4325 bitmap op2 = df_md_get_bb_info (e->src->index)->out;
4326
4327 if (e->flags & EDGE_FAKE)
4328 return;
4329
4330 if (e->flags & EDGE_EH)
4331 bitmap_ior_and_compl_into (op1, op2, regs_invalidated_by_call_regset);
4332 else
4333 bitmap_ior_into (op1, op2);
4334 }
4335
4336 /* Free all storage associated with the problem. */
4337
4338 static void
4339 df_md_free (void)
4340 {
4341 unsigned int i;
4342 for (i = 0; i < df_md->block_info_size; i++)
4343 {
4344 struct df_md_bb_info *bb_info = df_md_get_bb_info (i);
4345 if (bb_info)
4346 {
4347 BITMAP_FREE (bb_info->kill);
4348 BITMAP_FREE (bb_info->gen);
4349 BITMAP_FREE (bb_info->init);
4350 BITMAP_FREE (bb_info->in);
4351 BITMAP_FREE (bb_info->out);
4352 }
4353 }
4354
4355 BITMAP_FREE (df_md_scratch);
4356 free_alloc_pool (df_md->block_pool);
4357
4358 df_md->block_info_size = 0;
4359 free (df_md->block_info);
4360 free (df_md);
4361 }
4362
4363
4364 /* Debugging info at top of bb. */
4365
4366 static void
4367 df_md_top_dump (basic_block bb, FILE *file)
4368 {
4369 struct df_md_bb_info *bb_info = df_md_get_bb_info (bb->index);
4370 if (!bb_info || !bb_info->in)
4371 return;
4372
4373 fprintf (file, ";; md in \t");
4374 df_print_regset (file, bb_info->in);
4375 fprintf (file, ";; md init \t");
4376 df_print_regset (file, bb_info->init);
4377 fprintf (file, ";; md gen \t");
4378 df_print_regset (file, bb_info->gen);
4379 fprintf (file, ";; md kill \t");
4380 df_print_regset (file, bb_info->kill);
4381 }
4382
4383 /* Debugging info at bottom of bb. */
4384
4385 static void
4386 df_md_bottom_dump (basic_block bb, FILE *file)
4387 {
4388 struct df_md_bb_info *bb_info = df_md_get_bb_info (bb->index);
4389 if (!bb_info || !bb_info->out)
4390 return;
4391
4392 fprintf (file, ";; md out \t");
4393 df_print_regset (file, bb_info->out);
4394 }
4395
4396 static struct df_problem problem_MD =
4397 {
4398 DF_MD, /* Problem id. */
4399 DF_FORWARD, /* Direction. */
4400 df_md_alloc, /* Allocate the problem specific data. */
4401 df_md_reset, /* Reset global information. */
4402 df_md_free_bb_info, /* Free basic block info. */
4403 df_md_local_compute, /* Local compute function. */
4404 df_md_init, /* Init the solution specific data. */
4405 df_worklist_dataflow, /* Worklist solver. */
4406 df_md_confluence_0, /* Confluence operator 0. */
4407 df_md_confluence_n, /* Confluence operator n. */
4408 df_md_transfer_function, /* Transfer function. */
4409 NULL, /* Finalize function. */
4410 df_md_free, /* Free all of the problem information. */
4411 df_md_free, /* Remove this problem from the stack of dataflow problems. */
4412 NULL, /* Debugging. */
4413 df_md_top_dump, /* Debugging start block. */
4414 df_md_bottom_dump, /* Debugging end block. */
4415 NULL, /* Incremental solution verify start. */
4416 NULL, /* Incremental solution verify end. */
4417 NULL, /* Dependent problem. */
4418 TV_DF_MD, /* Timing variable. */
4419 false /* Reset blocks on dropping out of blocks_to_analyze. */
4420 };
4421
4422 /* Create a new MD instance and add it to the existing instance
4423 of DF. */
4424
4425 void
4426 df_md_add_problem (void)
4427 {
4428 df_add_problem (&problem_MD);
4429 }
4430
4431
4432